This shows you the differences between two versions of the page.
|
ass:labs-2025:03:tasks:01 [2026/07/15 11:22] florin.stancu |
ass:labs-2025:03:tasks:01 [2026/07/15 15:33] (current) florin.stancu [01. Automatically booting our Linux] |
||
|---|---|---|---|
| Line 151: | Line 151: | ||
| Note that real devices have their uboot configuration proceed automatically with booting the OS if a physical button is NOT pressed (remember those old Android phones? you could stop this process by holding several volume keys together!). You can script this using GPIO (try the ''gpio'' command!), but it's out of scope for today (we don't have any physical buttons). | Note that real devices have their uboot configuration proceed automatically with booting the OS if a physical button is NOT pressed (remember those old Android phones? you could stop this process by holding several volume keys together!). You can script this using GPIO (try the ''gpio'' command!), but it's out of scope for today (we don't have any physical buttons). | ||
| + | === Bonus: load uboot environment from FAT32 partition === | ||
| + | |||
| + | If you wish to change without uboot's environment without recompiling u-boot itself, it's also possible (and very easy to do). | ||
| + | |||
| + | Since this is usually desirable for flexibility during upgrades, there are many ways to do this: activate one of ''CONFIG_ENV_IS_IN_*'' config options or use a startup script which loads the env from a .txt file on the FAT32 partition. We'll prefer the latter since it's more fun (& failproof on most boards!). | ||
| + | |||
| + | Basically, we will write a custom script to be executed by u-boot at startup. To do this, search for the ''PREBOOT'' config item inside u-boot's ''menuconfig''. | ||
| + | Since we added a custom default.env file, we need to activate ''USE_PREBOOT'' and specify our script as a hardcoded ''preboot='' environment variable. | ||
| + | |||
| + | Sample script: | ||
| + | <code> | ||
| + | preboot=if fatload mmc 0:1 ${loadaddr} uboot.txt; then env import -t ${loadaddr} ${filesize}; fi | ||
| + | </code> | ||
| + | |||
| + | That's it! Create this file on your board's FAT32 partition (using the same ''key=value'' assignments separated by newlines syntax) and boot it! You should now see your new environment values (''env print'')! | ||