cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Adventurer
Adventurer
601 Views
Registered: ‎08-07-2014

How to change default u-boot's dhcp "image.ub" load address

Jump to solution

Hello All:

I'm using Petalinux 2018.3 and configured u-boot to fetch FIT file "image.ub" using the u-boot's dhcp command:

 

DHCP client bound to address 192.168.2.128 (3761 ms)
Using ethernet@ff0e0000 device
TFTP from server 192.168.2.254; our IP address is 192.168.2.128
Filename 'image.ub'.
Load address: 0x100000
Loading: #################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
#################################################################
###############################
14.6 MiB/s
done
Bytes transferred = 7124072 (6cb468 hex)

 

As you can see, the default load address is 0x100000. Due to a specific functionality in our project, I'd like to load it in another address.

Is there any way to configure that load address in the u-boot "shell", using a variable or something? I prefer that than changing the source code....

thanks in advance!

Brasilino

1 Solution

Accepted Solutions
Adventurer
Adventurer
469 Views
Registered: ‎08-07-2014

Hello @sandeepg 

 

Thanks for the help. However, I've noticed that netstart variable sets the address for loading the image when netboot is executed, which in turn executes tftpboot command:

#define CONFIG_EXTRA_ENV_SETTINGS \
[...] 
"netboot=tftpboot ${netstart} ${kernel_img} && bootm\0" \
[...]

It doesn't change where the dhcp command store the image (look that I didn't saveenv on purpose, but that doesn't matter for me):

ZynqMP> setenv netstart 0x2000000
ZynqMP> dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
DHCP client bound to address 192.168.2.201 (3008 ms)
Using ethernet@ff0e0000 device
TFTP from server 192.168.2.254; our IP address is 192.168.2.201
Filename 'image.ub'.
Load address: 0x100000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################
         14.8 MiB/s
done
Bytes transferred = 7124072 (6cb468 hex)

Looking into u-boot source code[1], I've seen that loadaddr is the variable I'm looking for. So:

ZynqMP> setenv loadaddr 0x2000000
ZynqMP> dhcp
BOOTP broadcast 1
DHCP client bound to address 192.168.2.201 (4 ms)
Using ethernet@ff0e0000 device
TFTP from server 192.168.2.254; our IP address is 192.168.2.201
Filename 'image.ub'.
Load address: 0x2000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################
         15 MiB/s
done
Bytes transferred = 7124072 (6cb468 hex)

Regards

Brasilino

[1] https://github.com/Xilinx/u-boot-xlnx/blob/f6b4a4548dbc358ce801b860df08440de79aa7c5/cmd/net.c#L190

View solution in original post

0 Kudos
Reply
2 Replies
Moderator
Moderator
570 Views
Registered: ‎04-24-2017

Hi @brasilino ,

Yes you can change the load address of FIT image using using below two methods.

Method 1:

Halt at u-boot and run below command 

ZynqMP> setenv netstart <address>
ZynqMP> saveenv
ZynqMP> bootm

Method2:

  1. Copy the U-boot environment variable define CONFIG_EXTRA_ENV_SETTINGS from <plnx-proj-root>/project-spec/meta-plnx-generated/recipes-bsp/u-boot/configs/platform-auto.h
  2. Modify the netstart env variable
    /* Extra U-Boot Env settings */
    #define CONFIG_EXTRA_ENV_SETTINGS \
    	SERIAL_MULTI \ 
    	CONSOLE_ARG \ 
    	DFU_ALT_INFO_RAM \ 
    	DFU_ALT_INFO_MMC \ 
    	PSSERIAL0 \ 
    	"nc=setenv stdout nc;setenv stdin nc;\0" \ 
    	"ethaddr=00:0a:35:04:b6:2e\0" \
    	"bootenv=uEnv.txt\0" \ 
    	"importbootenv=echo \"Importing environment from SD ...\"; " \ 
    		"env import -t ${loadbootenv_addr} $filesize\0" \ 
    	"loadbootenv=load mmc $sdbootdev:$partid ${loadbootenv_addr} ${bootenv}\0" \ 
    	"sd_uEnvtxt_existence_test=test -e mmc $sdbootdev:$partid /uEnv.txt\0" \ 
    	"uenvboot=" \ 
    		"if run sd_uEnvtxt_existence_test; then " \ 
    			"run loadbootenv; " \ 
    			"echo Loaded environment from ${bootenv}; " \ 
    			"run importbootenv; " \ 
    			"fi; " \ 
    		"if test -n $uenvcmd; then " \ 
    			"echo Running uenvcmd ...; " \ 
    			"run uenvcmd; " \ 
    		"fi\0" \ 
    	"autoload=no\0" \ 
    	"sdbootdev=0\0" \ 
    	"clobstart=0x10000000\0" \ 
    	"netstart=0x20000000\0" \ 
    	"dtbnetstart=0x23fff000\0" \ 
    	"loadaddr=0x10000000\0" \ 
    	"boot_img=BOOT.BIN\0" \ 
    	"load_boot=tftpboot ${clobstart} ${boot_img}\0" \ 
    	"update_boot=setenv img boot; setenv psize ${bootsize}; setenv installcmd \"install_boot\"; run load_boot ${installcmd}; setenv img; setenv psize; setenv installcmd\0" \ 
    	"install_boot=mmcinfo && fatwrite mmc ${sdbootdev} ${clobstart} ${boot_img} ${filesize}\0" \ 
    	"bootenvsize=0x40000\0" \ 
    	"bootenvstart=0x1e00000\0" \ 
    	"eraseenv=sf probe 0 && sf erase ${bootenvstart} ${bootenvsize}\0" \ 
    	"jffs2_img=rootfs.jffs2\0" \ 
    	"load_jffs2=tftpboot ${clobstart} ${jffs2_img}\0" \ 
    	"update_jffs2=setenv img jffs2; setenv psize ${jffs2size}; setenv installcmd \"install_jffs2\"; run load_jffs2 test_img; setenv img; setenv psize; setenv installcmd\0" \ 
    	"sd_update_jffs2=echo Updating jffs2 from SD; mmcinfo && fatload mmc ${sdbootdev}:1 ${clobstart} ${jffs2_img} && run install_jffs2\0" \ 
    	"install_jffs2=sf probe 0 && sf erase ${jffs2start} ${jffs2size} && " \ 
    		"sf write ${clobstart} ${jffs2start} ${filesize}\0" \ 
    	"kernel_img=image.ub\0" \ 
    	"load_kernel=tftpboot ${clobstart} ${kernel_img}\0" \ 
    	"update_kernel=setenv img kernel; setenv psize ${kernelsize}; setenv installcmd \"install_kernel\"; run load_kernel ${installcmd}; setenv img; setenv psize; setenv installcmd\0" \ 
    	"install_kernel=mmcinfo && fatwrite mmc ${sdbootdev} ${clobstart} ${kernel_img} ${filesize}\0" \ 
    	"cp_kernel2ram=mmcinfo && fatload mmc ${sdbootdev} ${netstart} ${kernel_img}\0" \ 
    	"dtb_img=system.dtb\0" \ 
    	"load_dtb=tftpboot ${clobstart} ${dtb_img}\0" \ 
    	"update_dtb=setenv img dtb; setenv psize ${dtbsize}; setenv installcmd \"install_dtb\"; run load_dtb test_img; setenv img; setenv psize; setenv installcmd\0" \ 
    	"sd_update_dtb=echo Updating dtb from SD; mmcinfo && fatload mmc ${sdbootdev}:1 ${clobstart} ${dtb_img} && run install_dtb\0" \ 
    	"loadbootenv_addr=0x00100000\0" \ 
    	"fault=echo ${img} image size is greater than allocated place - partition ${img} is NOT UPDATED\0" \ 
    	"test_crc=if imi ${clobstart}; then run test_img; else echo ${img} Bad CRC - ${img} is NOT UPDATED; fi\0" \ 
    	"test_img=setenv var \"if test ${filesize} -gt ${psize}\\; then run fault\\; else run ${installcmd}\\; fi\"; run var; setenv var\0" \ 
    	"netboot=tftpboot ${netstart} ${kernel_img} && bootm\0" \ 
    	"default_bootcmd=run uenvboot; run cp_kernel2ram && bootm ${netstart}\0" \ 
    ""
  3. Clean and rebuild u-boot
    $ petalinux-build -c u-boot -x cleanall
    $ petalinux-build -c u-boot

 

Thanks,
Sandeep
PetaLinux Yocto | Embedded SW Support

---------------------------------------------------------------------------
Don’t forget to Reply, Kudo, and Accept as Solution.
---------------------------------------------------------------------------
0 Kudos
Reply
Adventurer
Adventurer
470 Views
Registered: ‎08-07-2014

Hello @sandeepg 

 

Thanks for the help. However, I've noticed that netstart variable sets the address for loading the image when netboot is executed, which in turn executes tftpboot command:

#define CONFIG_EXTRA_ENV_SETTINGS \
[...] 
"netboot=tftpboot ${netstart} ${kernel_img} && bootm\0" \
[...]

It doesn't change where the dhcp command store the image (look that I didn't saveenv on purpose, but that doesn't matter for me):

ZynqMP> setenv netstart 0x2000000
ZynqMP> dhcp
BOOTP broadcast 1
BOOTP broadcast 2
BOOTP broadcast 3
BOOTP broadcast 4
DHCP client bound to address 192.168.2.201 (3008 ms)
Using ethernet@ff0e0000 device
TFTP from server 192.168.2.254; our IP address is 192.168.2.201
Filename 'image.ub'.
Load address: 0x100000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################
         14.8 MiB/s
done
Bytes transferred = 7124072 (6cb468 hex)

Looking into u-boot source code[1], I've seen that loadaddr is the variable I'm looking for. So:

ZynqMP> setenv loadaddr 0x2000000
ZynqMP> dhcp
BOOTP broadcast 1
DHCP client bound to address 192.168.2.201 (4 ms)
Using ethernet@ff0e0000 device
TFTP from server 192.168.2.254; our IP address is 192.168.2.201
Filename 'image.ub'.
Load address: 0x2000000
Loading: #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         #################################################################
         ###############################
         15 MiB/s
done
Bytes transferred = 7124072 (6cb468 hex)

Regards

Brasilino

[1] https://github.com/Xilinx/u-boot-xlnx/blob/f6b4a4548dbc358ce801b860df08440de79aa7c5/cmd/net.c#L190

View solution in original post

0 Kudos
Reply