GithubHelp home page GithubHelp logo

robseb / linuxbootimagefilegenerator Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 7.0 216 KB

Python Script to automatically generate a bootable Image (.img) file with a specifiable partition table and Linux files (e.g. zImage, u-boot,...) for embedded Linux distributions

License: MIT License

Python 100.00%
linux image image-file embedded embedded-systems build-automation build-system build-tool bootimage

linuxbootimagefilegenerator's Introduction

linuxbootimagefilegenerator's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

linuxbootimagefilegenerator's Issues

losetup failed to set up loop device: Resource temporarily unavailable

I though I'll share a problem which I ran into while using the LinuxBootImageFileGenerator.py. The workaround I implemented is attached in the code below.

Problem description and workaround

In function __createLoopbackDevice the error "losetup failed to set up loop device: Resource temporarily unavailable" gets thrown, resulting in Exception("Failed to get a loopback device")
I changed the __createLoopbackDevice to retry if it's fails to create dev loop, as the attached code below displays.

def __createLoopbackDevice(self, diagnosticOutput = True,size =0, offset_bytes = 0):
    self.__print(diagnosticOutput,'--> Create loopback device')
    # Calculate offset from sectors to byte
    retries = 0
    success = False
    while (not success):
        try:
            if offset_bytes != 0:
                loop_dev = self.__runCmdInShell(diagnosticOutput,
                    ["sudo","losetup", "--show", "-f", "-o "+str(offset_bytes),
                    "--sizelimit",str(size), self.__imageFilepath])
                success = True
            else:
                os.system('sudo losetup --show -f --sizelimit '+str(size)+' '+\
                            self.__imageFilepath)
                loop_dev = self.__runCmdInShell(diagnosticOutput,
                            ["sudo","losetup","--show", "-f",
                            "--sizelimit", str(size), self.__imageFilepath])
                success = True            
        except subprocess.CalledProcessError:
            retries += 1
            time.sleep(0.001)
            if retries > 1000:
                self.__unmountDeleteLoopbacks(diagnosticOutput)
                raise Exception("Failed to get a loopback device")
    # convert the loop device name as string
    loop_dev_str = str(loop_dev) 

Running on Ubuntu 18.04.5 LTS.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.