Пример #1
0
 def install_uboot_env(self, mount_point):
     """
     Installs the uboot environment (uEnv.txt) to the given mount point.
     
     This methods needs :attr:`uboot_load_addr` and :attr:`workdir`
     to be already set.
     
     :param mount_point: Path where to install the uboot environment.
     :exception BoardError: On error.
     """
     
     self._l.info('Installing uboot environment')
     uboot_load_addr = hexutils.str_to_hex(self._uboot_load_addr)
     uenv_file = os.path.join(self._workdir, "uEnv.txt")
     if not self._dryrun:
         with open(uenv_file, "w") as uenv:
             bootargs = 'bootargs=%s' % self._bootargs.strip()
             uenvcmd = ('uenvcmd=echo Running uenvcmd ...; run loaduimage; '
                        'bootm %s' % uboot_load_addr)
             self._l.debug("  uEnv.txt <= '%s'" % bootargs)
             uenv.write("%s\n" % bootargs)
             self._l.debug("  uEnv.txt <= '%s'" % uenvcmd)
             uenv.write("%s\n" % uenvcmd)
     cmd = 'sudo cp %s %s' % (uenv_file, mount_point)
     if self._e.check_call(cmd) != 0:
         raise BoardError('Failed to install uboot env file.')
Пример #2
0
 def __init__(self, uboot, board, loader, nand_block_size=0,
              nand_page_size=0, ram_load_addr=None, dryrun=False):
     """
     :param uboot: :class:`Uboot` instance.
     :param board: :class:`Board` instance.
     :param loader: :class:`RamLoader` instance.
     :param nand_block_size: NAND block size (bytes). If not given, the
         value will be obtained from uboot (once).
     :param nand_page_size: NAND page size (bytes). If not given, the
         value will be obtained from uboot (once).
     :param ram_load_addr: RAM address to load components, in decimal or
         hexadecimal (`'0x'` prefix).
     :param dryrun: Enable dryrun mode. System and uboot commands will be
         logged, but not executed.
     :type dryrun: boolean
     """
     
     self._l = utils.logger.get_global_logger()
     self._e = utils.executer.get_global_executer()
     self._u = uboot
     self._board = board
     self._loader = loader
     self._nand_block_size = nand_block_size
     self._nand_page_size = nand_page_size
     self._ram_load_addr = None
     if hexutils.is_valid_addr(ram_load_addr):
         self._ram_load_addr = hexutils.str_to_hex(str(ram_load_addr))
     self._dryrun = dryrun
     self._board.dryrun = dryrun
     self._e.dryrun = dryrun
     self._u.dryrun = dryrun
     self._loader.dryrun = dryrun
     self._partitions = []
Пример #3
0
 def install_uboot(self, device):
     """
     Flashes UBL and uboot to the given device, using the uflash tool.
     
     This method needs :attr:`uflash_bin`, :attr:`ubl_file`, 
     :attr:`uboot_file`, :attr:`uboot_entry_addr`, and  
     :attr:`uboot_load_addr` to be already set.
     
     :param device: Device where to flash UBL and uboot (i.e. '/dev/sdb').
     :exception BoardError: On error.
     """
     
     uboot_load_addr = hexutils.str_to_hex(self._uboot_load_addr)
     uboot_entry_addr = hexutils.str_to_hex(self._uboot_entry_addr)
     self._l.info('Installing uboot')
     cmd = ('sudo ' + self._uflash_bin +
           ' -d ' + device +
           ' -b ' + self._uboot_file + 
           ' -e ' + uboot_entry_addr + 
           ' -l ' + uboot_load_addr)
     if self._e.check_call(cmd) != 0:
         raise BoardError('Failed to flash UBL and uboot into %s' % device)
Пример #4
0
    def install_uboot_env(self, mount_point):
        """
        Installs the uboot environment (uEnv.txt) to the given mount point.
        
        This methods needs :attr:`uboot_load_addr` and :attr:`workdir`
        to be already set.
        
        :param mount_point: Path where to install the uboot environment.
        :exception BoardError: On error.
        """

        self._l.info("Installing uboot environment")
        uboot_load_addr = hexutils.str_to_hex(self._uboot_load_addr)
        uenv_file = os.path.join(self._workdir, "uEnv.txt")
        if not self._dryrun:
            with open(uenv_file, "w") as uenv:
                bootargs = "bootargs=%s" % self._bootargs.strip()
                if self._kernel_tftp:
                    loadtftpimage = "loadtftpimage=%s" % self._tftp_loader.get_env_load_file_to_ram(
                        self._kernel_image, uboot_load_addr
                    )
                    self._l.debug("  uEnv.txt <= '%s'" % loadtftpimage)
                    uenv.write("%s\n" % loadtftpimage)
                    kernel_load = "run loadtftpimage"
                else:
                    kernel_load = "run loaduimage"

                uenvcmd = "uenvcmd=echo Running uenvcmd ...; %s; " % kernel_load
                if self._kernel_devicetree:
                    uenvcmd = uenvcmd + " run loadfdt; bootm ${loadaddr} - ${fdt_addr}"
                else:
                    uenvcmd = uenvcmd + " bootm"

                self._l.debug("  uEnv.txt <= '%s'" % bootargs)
                uenv.write("%s\n" % bootargs)
                self._l.debug("  uEnv.txt <= 'autostart=no")
                uenv.write("autostart=no\n")
                self._l.debug("  uEnv.txt <= '%s'" % uenvcmd)
                uenv.write("%s\n" % uenvcmd)
        cmd = "sudo cp %s %s" % (uenv_file, mount_point)
        if self._e.check_call(cmd) != 0:
            raise BoardError("Failed to install uboot env file.")
Пример #5
0
    def install_uboot_env(self, mount_point):
        """
        Installs the uboot environment (uEnv.txt) to the given mount point.
        
        This methods needs :attr:`uboot_load_addr` and :attr:`workdir`
        to be already set.
        
        :param mount_point: Path where to install the uboot environment.
        :exception BoardError: On error.
        """
        
        self._l.info('Installing uboot environment')
        uboot_load_addr = hexutils.str_to_hex(self._uboot_load_addr)
        uenv_file = os.path.join(self._workdir, "uEnv.txt")
        if not self._dryrun:
            with open(uenv_file, "w") as uenv:
                bootargs = 'bootargs=%s' % self._bootargs.strip()
                if self._kernel_tftp:
                    loadtftpimage = 'loadtftpimage=%s'% self._tftp_loader.get_env_load_file_to_ram(
                        self._kernel_image, uboot_load_addr)
                    self._l.debug("  uEnv.txt <= '%s'" % loadtftpimage)
                    uenv.write("%s\n" % loadtftpimage)
                    kernel_load = 'run loadtftpimage'
                else:
                    kernel_load = 'run loaduimage'
                    
                uenvcmd = ('uenvcmd=echo Running uenvcmd ...; %s; ' % kernel_load)
                if self._kernel_devicetree:
                    uenvcmd = uenvcmd + ' run loadfdt; bootm ${loadaddr} - ${fdt_addr}'
                else:
                    uenvcmd = uenvcmd + ' bootm'

                self._l.debug("  uEnv.txt <= '%s'" % bootargs)
                uenv.write("%s\n" % bootargs)
                self._l.debug("  uEnv.txt <= 'autostart=no")
                uenv.write("autostart=no\n")
                self._l.debug("  uEnv.txt <= '%s'" % uenvcmd)
                uenv.write("%s\n" % uenvcmd)
        cmd = 'sudo cp %s %s' % (uenv_file, mount_point)
        if self._e.check_call(cmd) != 0:
            raise BoardError('Failed to install uboot env file.')
Пример #6
0
    def __init__(self,
                 uboot,
                 board,
                 loader,
                 nand_block_size=0,
                 nand_page_size=0,
                 ram_load_addr=None,
                 dryrun=False):
        """
        :param uboot: :class:`Uboot` instance.
        :param board: :class:`Board` instance.
        :param loader: :class:`RamLoader` instance.
        :param nand_block_size: NAND block size (bytes). If not given, the
            value will be obtained from uboot (once).
        :param nand_page_size: NAND page size (bytes). If not given, the
            value will be obtained from uboot (once).
        :param ram_load_addr: RAM address to load components, in decimal or
            hexadecimal (`'0x'` prefix).
        :param dryrun: Enable dryrun mode. System and uboot commands will be
            logged, but not executed.
        :type dryrun: boolean
        """

        self._l = utils.logger.get_global_logger()
        self._e = utils.executer.get_global_executer()
        self._u = uboot
        self._board = board
        self._loader = loader
        self._nand_block_size = nand_block_size
        self._nand_page_size = nand_page_size
        self._ram_load_addr = None
        if hexutils.is_valid_addr(ram_load_addr):
            self._ram_load_addr = hexutils.str_to_hex(str(ram_load_addr))
        self._dryrun = dryrun
        self._board.dryrun = dryrun
        self._e.dryrun = dryrun
        self._u.dryrun = dryrun
        self._loader.dryrun = dryrun
        self._partitions = []