Executing a new u-boot image from existing u-boot prompt

Hi friends,

    Sorry blogging after long time.

    I recently got a question on how to bring an u-boot image to RAM temporarily for testing and debugging purpose instead of burning it every time to flash or eeprom after making small changes. I couldn't respond to that one on time, my apologies. So here's how we could do it.


     Although u-boot is just a secondary boot loader it provides a good set of commands to do this job. It provides the tftp command by which you could bring a u-boot image into a location in RAM and execute it from there using 'go' command.
    Whats more, you could also easily flash this image you brought to RAM to the NAND or NOR flash. But there is one small catch, as u-boot is just a boot loader it doesn't understand any filesystem. So we need to work with physical address. For this we need to know the memory mapping of the memories RAM, NAND, NOR wherever we need to put the image.

Bringing the image to RAM and executing from there:

      For this we use the tftp command, so your board needs to have network cable connected either directly to the host machine where the image is or to the same network. then do the following on you board:

     # setenv ipaddr <some available ipaddr for your board>
          eg: setenv ipaddr 10.99.14.100
                      This will set the ip address of the board.

     # setenv serverip <ip address of the host machine with the u-boot image you want to use>
          e.g.: setenv serverip 10.99.14.72
                      This will set the ip address of the server machine. When the tftp command will be executed it will search for machine with this ip and fetch the image from there ( see next command ).

     # tftp <memory address of RAM in higher locations in hex>  <location of image in tftpboot directory>
          e.g.: tftp 0x1000000 charvi/images/u-boot.bin
                       This command is tricky. If your using it for the first time you may have to make many retries before you get this working correctly. Firstly, you will have to setup tftpd ( tftp daemon/server ) running on the host machine whose ip address you entered as the server ip in the previous command. Next you have to create a tftpboot directory under /. This will be given as a part of setting up the server which can be easily followed from steps on googling. Next keep the new u-boot image in it or any sub-directory and mention the path as the second argument. NOTE: the path will not contain /tftpboot in the path but only the subsequent location.
    For example: if the location is /tftpboot/charvi/images/u-boot.bin then you will only give "charvi/images/u-boot.bin" as the second argument.
The first argument is the physical location higher in RAM somewhere. Please take care while choosing some location in RAM. Choose some higher location as your current u-boot will be residing in the initial location. Also the location should not be much high so that the new image doesn't get space once it is decompressed. Again some trial and error will have to be done for newbies. If "boom" your prompt goes away don't worry, just do a power-on reset and ta-da there's your previous u-boot prompt.

     #go <memory location of the new image>
         This is the u-boot command which can execute stand alone applications. The location given as argument is same where we just brought our u-boot image via tftp.


Here is a doc with more u-boot commands for reference: http://www.lysator.liu.se/~kjell-e/embedded/U-boot-quick-reference-LITE5200BUBPG.pdf


We could also flash the image to NAND or NOR after this as I said. Will write about it in next posts or if someboady wants it earlier just mail me.

C Ya.

No comments:

Post a Comment