[U-Boot] U-boot environment variables keep disappearing

Hi folks,
I'm a newbie.
I'm trying to write a basic script in u-boot which erases and writes x-loader to NAND between 0x0 and 0x80000.
When I save some basic environment variables to u-boot such as: set foo bar saveenv
foo is always there when i come back. However, when I write a slightly longer program and save it using saveenv (and check it's there using "print"), it is gone by the time I reboot.
The slightly longer program is this: formatXLoader=if test "$firstFormat" -eq "0"; then echo Formatting NAND for X-Loader...; mmc init; fatload mmc 0:1 80000000 MLO; nandecc hw 2; nand erase 0 80000; echo Formatting complete. Writing X-Loader to NAND; nand write 80000000 0 80000; echo X-Loader written successfully; set firstFormat 1; else echo X-loader already written to NAND; fi
Why is my formatXLoader program disappearing? I am pulling out my hair.
Thankyou! :)
participants (1)
-
andyjjones