[U-Boot] [RFC/PATCH] sunxi: Populate the default environment for sunxi-based systems

Hello,
in the following email you can find a patch to populate the default environment for sunxi-based systems about which I would apprechiate your opinion.
With the current progress in mainlining sunxi platform support, mainline u-boot will probably soon be able to replace u-boot-sunxi (https://github.com/linux-sunxi/u-boot-sunxi) for many use cases. Currently the default environment in mainline u-boot for sunxi-based systems is rather bare; the only predefined variable is bootm_size (which is required for proper initrd- and dtb-relocation). U-boot-sunxi predefines a set of environment variables which are commonly used by existing boot scripts and also offers a predefined bootcmd for automatic search and execution of bootscripts. I think that to facilitate using mainline u-boot as a drop-in replacement for u-boot-sunxi, mainline u-boot should provide similar defaults.
The original environment in u-boot-sunxi was written for an older u-boot release and does not make use of modern u-boot features (e.g. it uses hardcoded filesystem-specific load commands), so just copying the environment 1:1 to mainline u-boot does not make sense IMHO. My patch tries to implement the minimum required for autobooting existing boot scripts with more modern u-boot functions.
In addition to that, the patch defines some standard environment variables which are commonly defined on other u-boot platforms, but which have not been defined by u-boot-sunxi, in particular kernel_addr_r, ramdisk_addr_r and fdt_addr_r. Debian supports a wide range of armhf system and tries to unify support for the different platforms as good as possible. Having the same predefined variables with (platform-specific) load addresses on all platforms would help us a lot with regard to generic boot scripts and simplified user documentation.
Regarding the actual values for the various load addresses I am not in all cases perfectly sure about the best variant. Following is the reasoning for my choices:
- fdt_addr_r
U-boot-sunxi loads the FEX binary (Allwinner's proprietary hardware description format for their android kernels, i.e. a file functionally roughly equivalent to a dtb) to address 0x43000000, so I guess using the same for the dtb makes sense.
- scriptaddr
has historically been expected to be 0x44000000; some old boot scripts assume this address.
- kernel_addr_r and ramdisk_addr_r
Allwinner has historically loaded their kernels to 0x48000000 (system specific kernels with all drivers compiled in, no initrd).
Debian has been using 0x46000000 for the kernel and 0x48000000 for the initrd. These values work well in practice, so I have used them in the patch, but if there are reasons to change them, I am happy to do so.
Comments welcome :-).
Regards, Karsten

Predefine a set of standard environment variables (kernel_addr_r, ramdisk_addr_r, fdt_addr_r and scriptaddr) to sensible values on sunxi-based systems and provide a default environment that allows autobooting of existing boot scripts which were written for pre-mainlining u-boot-sunxi versions.
Signed-off-by: Karsten Merker merker@debian.org --- include/configs/sunxi-common.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h index 6a3044f..ac8cb8f 100644 --- a/include/configs/sunxi-common.h +++ b/include/configs/sunxi-common.h @@ -124,7 +124,17 @@ #define CONFIG_ENV_SIZE (128 << 10) /* 128 KiB */
#define CONFIG_EXTRA_ENV_SETTINGS \ - "bootm_size=0x10000000\0" + "bootm_size=0x10000000\0" \ + "fdt_addr_r=0x43000000\0" \ + "scriptaddr=0x44000000\0" \ + "kernel_addr_r=0x46000000\0" \ + "ramdisk_addr_r=0x48000000\0" \ + "device=mmc\0" \ + "partition=0:1\0" \ + "bootdelay=3\0" \ + "bootcmd=if test -n "${loadbootscr}"; then run loadbootscr; fi\0" \ + "bootscr=boot.scr\0" \ + "loadbootscr=if test -n "${device}" && test -n "${partition}"; then for p in /boot/ /; do load ${device} ${partition} ${scriptaddr} ${p}${bootscr} && echo "Running ${p}${bootscr} from ${device} ${partition}" && source ${scriptaddr}; done; fi\0"
#define CONFIG_SYS_BOOT_GET_CMDLINE

Hi,
On 08/10/2014 11:00 PM, Karsten Merker wrote:
Hello,
in the following email you can find a patch to populate the default environment for sunxi-based systems about which I would apprechiate your opinion.
With the current progress in mainlining sunxi platform support, mainline u-boot will probably soon be able to replace u-boot-sunxi (https://github.com/linux-sunxi/u-boot-sunxi) for many use cases. Currently the default environment in mainline u-boot for sunxi-based systems is rather bare; the only predefined variable is bootm_size (which is required for proper initrd- and dtb-relocation). U-boot-sunxi predefines a set of environment variables which are commonly used by existing boot scripts and also offers a predefined bootcmd for automatic search and execution of bootscripts. I think that to facilitate using mainline u-boot as a drop-in replacement for u-boot-sunxi, mainline u-boot should provide similar defaults.
The original environment in u-boot-sunxi was written for an older u-boot release and does not make use of modern u-boot features (e.g. it uses hardcoded filesystem-specific load commands), so just copying the environment 1:1 to mainline u-boot does not make sense IMHO. My patch tries to implement the minimum required for autobooting existing boot scripts with more modern u-boot functions.
In addition to that, the patch defines some standard environment variables which are commonly defined on other u-boot platforms, but which have not been defined by u-boot-sunxi, in particular kernel_addr_r, ramdisk_addr_r and fdt_addr_r. Debian supports a wide range of armhf system and tries to unify support for the different platforms as good as possible. Having the same predefined variables with (platform-specific) load addresses on all platforms would help us a lot with regard to generic boot scripts and simplified user documentation.
Regarding the actual values for the various load addresses I am not in all cases perfectly sure about the best variant. Following is the reasoning for my choices:
fdt_addr_r
U-boot-sunxi loads the FEX binary (Allwinner's proprietary hardware description format for their android kernels, i.e. a file functionally roughly equivalent to a dtb) to address 0x43000000, so I guess using the same for the dtb makes sense.
scriptaddr
has historically been expected to be 0x44000000; some old boot scripts assume this address.
kernel_addr_r and ramdisk_addr_r
Allwinner has historically loaded their kernels to 0x48000000 (system specific kernels with all drivers compiled in, no initrd).
Debian has been using 0x46000000 for the kernel and 0x48000000 for the initrd. These values work well in practice, so I have used them in the patch, but if there are reasons to change them, I am happy to do so.
Comments welcome :-).
Thanks for this patch, but this does the same as a series I've already pending, see:
https://github.com/jwrdegoede/u-boot-sunxi/commits/next
I've not yet send a pull-request for this because it uses the new generic $bootcmd support: https://github.com/jwrdegoede/u-boot-sunxi/commit/34e421a155c83c52f6e6edb259...
This commit has just been merged by Tom Rini, so right now these patches are good to go. I'll send a pull-request for them soon.
Let me know if somehow these patches won't work for Debian. One of the goals of the generic $bootcmd support is that distributions can just drop an extlinux.conf in the boot partition, and then u-boot will automatically find it and do the right thing.
Regards,
Hans

On Mon, Aug 11, 2014 at 06:22:09PM +0200, Hans de Goede wrote:
On 08/10/2014 11:00 PM, Karsten Merker wrote:
Hello,
in the following email you can find a patch to populate the default environment for sunxi-based systems about which I would apprechiate your opinion.
With the current progress in mainlining sunxi platform support, mainline u-boot will probably soon be able to replace u-boot-sunxi (https://github.com/linux-sunxi/u-boot-sunxi) for many use cases. Currently the default environment in mainline u-boot for sunxi-based systems is rather bare; the only predefined variable is bootm_size (which is required for proper initrd- and dtb-relocation). U-boot-sunxi predefines a set of environment variables which are commonly used by existing boot scripts and also offers a predefined bootcmd for automatic search and execution of bootscripts. I think that to facilitate using mainline u-boot as a drop-in replacement for u-boot-sunxi, mainline u-boot should provide similar defaults.
[...]
Thanks for this patch, but this does the same as a series I've already pending, see:
Sorry, I had not seen that - in this case please disregard my patch.
I've not yet send a pull-request for this because it uses the new generic $bootcmd support: https://github.com/jwrdegoede/u-boot-sunxi/commit/34e421a155c83c52f6e6edb259...
This commit has just been merged by Tom Rini, so right now these patches are good to go. I'll send a pull-request for them soon.
Let me know if somehow these patches won't work for Debian. One of the goals of the generic $bootcmd support is that distributions can just drop an extlinux.conf in the boot partition, and then u-boot will automatically find it and do the right thing.
I have just run a few short tests with them - looks good. Using the new infrastructure requires adjustments to existing bootscripts written for u-boot-sunxi due to different variable names (${devtype} vs. ${device}, ${devnum}:${bootpart} vs. ${partition}), so it is not a real drop-in replacement for u-boot-sunxi, but if it gets adopted by all platforms, I think having a common and versatile infrastructure for all of them is worth breaking compatibility to u-boot-sunxi in this regard.
Regards, Karsten

On Mon, 2014-08-11 at 22:13 +0200, Karsten Merker wrote: (sorry for the delay, just getting back from vacation)
(sorry again if this comes through twice, my MUA crashed the first time I hit send, I don't think the mail made it out though...)
I've not yet send a pull-request for this because it uses the new generic $bootcmd support: https://github.com/jwrdegoede/u-boot-sunxi/commit/34e421a155c83c52f6e6edb259...
This commit has just been merged by Tom Rini, so right now these patches are good to go. I'll send a pull-request for them soon.
Let me know if somehow these patches won't work for Debian. One of the goals of the generic $bootcmd support is that distributions can just drop an extlinux.conf in the boot partition, and then u-boot will automatically find it and do the right thing.
I have just run a few short tests with them - looks good. Using the new infrastructure requires adjustments to existing bootscripts written for u-boot-sunxi due to different variable names (${devtype} vs. ${device}, ${devnum}:${bootpart} vs. ${partition}), so it is not a real drop-in replacement for u-boot-sunxi, but if it gets adopted by all platforms, I think having a common and versatile infrastructure for all of them is worth breaking compatibility to u-boot-sunxi in this regard.
I agree, the consistency is well worth it.
With Debian hat on: we should have a conversation with Vagrant WRT the planned u-boot version for Jessie. v2014.10 should be available before the freeze in November so hopefully we can go with that for Jessie, but if not then perhaps we can backport some minimal set of patches so that at least the env names match even if we don't manage to get the full updated default env.
Ian
participants (3)
-
Hans de Goede
-
Ian Campbell
-
Karsten Merker