Search code examples
u-bootbuildroot

Custom u-boot environment variables using buildroot


How do you add a new set of custom environment variables to u-boot using buildroot as the os build system?

I attempted to patch the include/configs/rpi.h using an external tree patch to add a new variable but kconfig got grumpy (patch shown after complaining):

The following new ad-hoc CONFIG options were detected:
CONFIG_XXXXXX_ENV_SETTINGS

Please add these via Kconfig instead. Find a suitable Kconfig
file and add a 'config' or 'menuconfig' option.
Makefile:871: recipe for target 'all' failed



--- a/include/configs/rpi.h 2018-03-13 12:02:19.000000000 +0000
+++ b/include/configs/rpi.h 2018-11-19 12:32:15.728000000 +0000
@@ -140,0 +141,7 @@
+#define CONFIG_XXXXXX_ENV_SETTINGS \
+   "newboard=true" \
+   "hasFailedBoot=false" \
+   "hasFailedBootCount=0" \
+   "maximumFailedBootCount=3"  
+
+
@@ -145 +152,2 @@
-   BOOTENV
+   BOOTENV \
+   CONFIG_XXXXXX_ENV_SETTINGS

I can use uboot-menuconfig to set up u-boot specific stuff but am not sure how to create environment variables


Solution

  • You can set CONFIG_USE_DEFAULT_ENV_FILE in uboot-menuconfig and point that to a file that contains the complete default environment.

    Since you use Buildroot, don't forget to save the modified U-Boot configuration by changing its location (Buildroot option BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE) and running make uboot-update-defconfig.