cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Visitor
Visitor
4,347 Views
Registered: ‎08-01-2014

Change U-boot autoload with Petalinux or how to avoid BOOTP broadcast ...

I would like to change the U-boot to autoload but cannot find a menu entry in the petalinux-config menu.

 

At the heart of my problem, I want to get rid of the BOOTP broadcast wait during U-boot - I thought changing autoload might do it. 

 

In the Xilinx U-boot github repo there is a flag for AUTOBOOT (https://github.com/Xilinx/u-boot-xlnx/blob/master/cmd/Kconfig) but no choice in the petalinux config file generated at <petalinux project>/subsystems/linux/configs/u-boot/config

 

 

0 Kudos
Reply
10 Replies
Observer
Observer
2,756 Views
Registered: ‎02-05-2018

I'm trying to figure out the same thing and the solution seems to be here: https://forums.xilinx.com/t5/Embedded-Linux/Petalinux-boot-problem/m-p/368177#M7063

 

I'm reading page 78 of the 2017.4 UG1144 and it says to edit the platform-auto.h file, and then immediately tells me not to because it's autogenerated each time I enter petalinux-config.

 

Looking at platform-auto.h, I see where is sets "autload=no", and according to these other posts, I want to set it to "yes".

 

UG1144 suggests adding a CONFIG_ option in the platform-top.h file.  However, I'm struggling to figure out if there is a CONFIG_ option to set the autload value.

 

Any guidance is appreciated.

0 Kudos
Reply
Xilinx Employee
Xilinx Employee
2,750 Views
Registered: ‎01-21-2014

I believe you should be editing platform-top.h to override the u-boot environment variables that are defined in platform-auto.h.  

 

See https://www.xilinx.com/support/answers/69780.html for an example of changing an environment variable that is originally defined in platform-auto.h. 

 

 

Regards, 

Terry

 

Mentor
Mentor
2,716 Views
Registered: ‎06-10-2008

You can also try: petalinux-config -c u-boot

0 Kudos
Reply
Voyager
Voyager
1,961 Views
Registered: ‎05-25-2016

So what is the consensus - are we supposed to be editing the header files or using the petalinux-config -c u-boot menu?

0 Kudos
Reply
Contributor
Contributor
1,945 Views
Registered: ‎10-02-2018

Hi, @m3atwad 

It depends on if you are using the u-boot provided by petalinux or using an external source. If you are using u-boot provided by petalinux then you should edit the platform-top.h file to override the environment variables generated in the platform-auto.h and then run petalinux-build

If you are using a git repo (u-boot-xlnx) then you can edit the /include/configs/zynq-common.h and <board>.h files.

Hope that helps.

Voyager
Voyager
1,939 Views
Registered: ‎05-25-2016

Hi e.friel,

 

Thank you for the response!  I think I am using the default uboot in petalinux.  I did not do anything custom or outside the normal operation of petalinux.  I downloaded petalinux and used UG1144 as a guide for a basic build.

 

I noticed that platform-top.h doesn't have much in it.  How exactly should I go about adding the environment variables?  For example, my platform-top.h is shown below.

#include <configs/platform-auto.h>
#define CONFIG_SYS_BOOTM_LEN 0xF000000
#define DFU_ALT_INFO_RAM \
                "dfu_ram_info=" \
        "setenv dfu_alt_info " \
        "image.ub ram $netstart 0x1e00000\0" \
        "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0" \
        "thor_ram=run dfu_ram_info && thordown 0 ram 0\0"

#define DFU_ALT_INFO_MMC \
        "dfu_mmc_info=" \
        "set dfu_alt_info " \
        "${kernel_image} fat 0 1\\\\;" \
        "dfu_mmc=run dfu_mmc_info && dfu 0 mmc 0\0" \
        "thor_mmc=run dfu_mmc_info && thordown 0 mmc 0\0"


/*Required for uartless designs */
#ifndef CONFIG_BAUDRATE
#define CONFIG_BAUDRATE 115200
#ifdef CONFIG_DEBUG_UART
#undef CONFIG_DEBUG_UART
#endif
#endif

/*Define CONFIG_ZYNQ_EEPROM here and its necessaries in u-boot menuconfig if you had EEPROM memory. */
#ifdef CONFIG_ZYNQ_EEPROM
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN         1
#define CONFIG_SYS_I2C_EEPROM_ADDR             0x54
#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS      4
#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  5
#define CONFIG_SYS_EEPROM_SIZE                 1024 /* Bytes */
#define CONFIG_SYS_I2C_MUX_ADDR                0x74
#define CONFIG_SYS_I2C_MUX_EEPROM_SEL          0x4
#endif

There is no mention of my environment variables in there, but they are in the platform-auto.h.  When I look at platform-auto.h I see the below.

/* 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:00:1e:53\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=0x10000000\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=0x20000\0" \ 
	"bootenvstart=0x500000\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" \ 
""

Do I need to copy and paste all the environment infor from platform-auto.h, paste it in platform-top.h and modify it there?  Or could I just do something like the below

#define CONFIG_EXTRA_ENV_SETTINGS \
"autoload=no\0"

I'm unsure what the correct software apprach here is I'm worried about making a mess of these files.

 

 

0 Kudos
Reply
Contributor
Contributor
1,932 Views
Registered: ‎10-02-2018

@m3atwad 

Exactly what you did there. Define your environment settings (CONFIG_EXTRA_ENV_SETTINGS) in platform-top.h and then override the variables. For example overriding ip address, default boot command etc.

#define CONFIG_EXTRA_ENV_SETTINGS \
"autoload=no\0"
"ipaddr=192.168.1.10\0" \
"default_bootcmd=run sdboot\0" \

Rebuild:

petalinux-build -c u-boot

And then test it out.

 

0 Kudos
Reply
Mentor
Mentor
1,913 Views
Registered: ‎06-10-2008

To override what's in platform-auto.h you must first #undef the old macro and then redefine it with what you need. Everything that you do not copy-paste will be lost.

0 Kudos
Reply
Voyager
Voyager
1,882 Views
Registered: ‎05-25-2016

Also,

 

I've changed this env variable and still no go.  BOOTP is still happening and takes a while to timeout.  I changed my platform-top.h and attached it.  I think I've gotten the changes correct.  I copied the CONFIG_EXTRA_ENV_SETTINGS from platform-auto.h to platform-top.h and undef'd it previously if it was already defined.  I also checked u-boot and the autoload is set to yes.  Is there another environment variable I need to change?

21.jpg

 

 

0 Kudos
Reply
Contributor
Contributor
1,864 Views
Registered: ‎10-02-2018

Set autoload to no, undefine the BOOTP and DHCP macros and make sure dhcp is not defined in the preboot macro.

/* BOOTP options */
#undef CONFIG_BOOTP_SERVERIP
#undef CONFIG_BOOTP_BOOTFILESIZE
#undef CONFIG_BOOTP_BOOTPATH
#undef CONFIG_BOOTP_GATEWAY
#undef CONFIG_BOOTP_HOSTNAME
#undef CONFIG_BOOTP_MAY_FAIL

Preboot may look like something like this, remove the dhcp:

* PREBOOT */
#define CONFIG_PREBOOT  "echo U-BOOT for Zybo;setenv preboot; echo; dhcp"

Rebuild, repackage BOOT.BIN and copy onto FAT32 partition of SD card.

Hope that helps