LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Embedded & Single-board computer (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/)
-   -   U-Boot environment variable not updating (https://www.linuxquestions.org/questions/linux-embedded-and-single-board-computer-78/u-boot-environment-variable-not-updating-4175646392/)

efriel_linux 01-17-2019 09:11 AM

U-Boot environment variable not updating
 
I am trying to network boot Linux via TFTP and so when u-boot executes it says on the console, "ipaddr not set".

Yet when I print the variable ipaddr it shows the ip address is correct.
i.e. 'printenv ipaddr' -> ipaddr=192.168.1.20

Everytime I change the u-boot configuration I have to issue the command, "env default -a" in the u-boot to update the environment variables because they never seem to update for some reason.

Anyone know how to solve this to update the variables without manually issuing commands? :confused:

By the way I am booting the fsbl, bitstream and u-boot via sd card.



Code:

/* PREBOOT */
#define CONFIG_PREBOOT  "echo U-BOOT for ${hostname};setenv preboot; echo; dhcp"

/* Extra U-Boot Env settings */
#define CONFIG_EXTRA_ENV_SETTINGS \
        SERIAL_MULTI \
        CONSOLE_ARG \
        PSSERIAL0 \
        "nc=setenv stdout nc;setenv stdin nc;\0" \
        "ethaddr=\0" \
        "ipaddr=192.168.1.20\0" \
        "serverip=192.168.1.5\0"        \
        "kernel_load_address=0xa00000\0"        \
        "sdboot=echo boot Petalinux; mmcinfo && fatload mmc 0 ${netstart} ${kernel_img} && bootm \0" \
        "tftp_boot=mmcinfo;echo *** BOOTING FROM TFTP SERVER ***; tftpboot ${kernel_load_address} ${serverip}:${kernel_img} \0" \
        "autoload=no\0" \
        "clobstart=0x04000000\0" \
        "netstart=0x04000000\0" \
        "dtbnetstart=0x05800000\0" \
        "loadaddr=0x04000000\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 0 ${clobstart} ${boot_img} ${filesize}\0" \
        "bootenvsize=0x20000\0" \
        "bootenvstart=0x300000\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 0: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 0 ${clobstart} ${kernel_img} ${filesize}\0" \
        "cp_kernel2ram=mmcinfo && fatload mmc 0 ${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 0:1 ${clobstart} ${dtb_img} && run install_dtb\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 cp_kernel2ram && bootm ${netstart}\0" \
        "bootcmd_tftp=run tftp_boot && bootm ${kernel_load_address}\0"  \
""

/* BOOTCOMMAND */
#define CONFIG_BOOTCOMMAND      "run bootcmd_tftp"

#undef CONFIG_SPL_BUILD /* Disable SPL by default*/

#endif /* __PLNX_CONFIG_H */


blue_z 01-18-2019 04:10 PM

Quote:

Originally Posted by efriel_linux (Post 5950195)
Everytime I change the u-boot configuration I have to issue the command, "env default -a" in the u-boot to update the environment variables because they never seem to update for some reason.

You seem to be conflating the three sets of environment variables in U-Boot.

The default environment is the set of environment variables that are defined in source code, i.e. what you seem to call "the u-boot configuration".

The saved environment is the set of environment variables that are retained in persistent storage. They have to be written using the saveenv command, and are validated using a CRC32 checkword.

The active environment is the set of environment variables that are held in RAM while U-Boot executes.
On startup U-Boot tries to populate the active environment with the saved environment, but only if the CRC32 checkword confirms the integrity of the saved environment.
When validation is successful, the environment variables from the persistent storage (silently) become the active environment.
When validation fails, a notice is displayed, "Warning: Bad CRC, using default environment", and the environment variables from the default environment become the active environment.


Quote:

Originally Posted by efriel_linux (Post 5950195)
Anyone know how to solve this to update the variables without manually issuing commands?

There is no automatic "update" of environment variables from the default environment to the saved environment.
If you clobber the saved environment (e.g. delete the uEnv.txt file), then on startup U-Boot will be forced to use the default environment.
Or instead of making your changes to the U-Boot source code, build a custom uEnv.txt file that is installed with the updated U-Boot executable.


Regards

efriel_linux 01-21-2019 04:01 AM

Yes that makes sense!

Thanks for the feedback I will go with that approach

sharnbrooke 01-22-2019 01:39 PM

I get the following error message after trying to update Linux. How can I eliminate this problem, Please?

GPG error: https://dl.winehq.org/wine-builds/ubuntu bionic InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 76F1A20FF987672FThe repository 'https://dl.winehq.org/wine-builds/ubuntu bionic InRelease' is not signed.


All times are GMT -5. The time now is 07:43 AM.