ARM: rpi: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support
PATCH 1/1 ARM: rpi: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support
Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support to set 'board_rev' and 'board_name' envs.
--- board/raspberrypi/rpi/rpi.c | 6 ++++++ include/configs/rpi-common.h | 1 + 2 files changed, 7 insertions(+)
board/raspberrypi/rpi/rpi.c +6 -0
@@ -240,6 +240,12 @@ int misc_init_r(void) {set_fdtfile ();set_usbethaddr (); +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG +char str_rev[11 ]; +sprintf (str_rev,"0x%X" , rpi_board_rev); +setenv ("board_rev" , str_rev); +setenv ("board_name" , models[rpi_board_rev].name); +#endif return 0 ; }
include/configs/rpi-common.h +1 -0
@@ -133,6 +133,7 @@#include <config_distro_defaults.h> /* Environment */ +#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG #define ENV_DEVICE_SETTINGS \ "stdin=serial,lcd\0" \ "stdout=serial,lcd\0" \
Signature · 1 line
1.8.4.5
PATCH 1/1 ARM: rpi: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support
Quoted 2 lines · Guillaume GARDET
Add
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGsupport to set 'board_rev' and 'board_name' envs.
That states what the patch does rather than why its useful to do it. Can you expand on why it's useful to set these variables?
Quoted 4 lines
board/raspberrypi/rpi/rpi.c +0
-0@@ -240,6 +240,12 @@ int misc_init_r(void) {
board/raspberrypi/rpi/rpi.c int misc_init_r(void) · line 250
Quoted 10 lines
board/raspberrypi/rpi/rpi.c +6
-0set_fdtfile ();set_usbethaddr (); +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG +char str_rev[11 ]; +sprintf (str_rev,"0x%X" , rpi_board_rev); +setenv ("board_rev" , str_rev); +setenv ("board_name" , models[rpi_board_rev].name); +#endif return 0 ; }
That adds a variable declaration in the middle of code. I'd suggest moving the new code into set_board_info() (a name that some other boards/SoCs that honor CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG use), and calling that function inside the ifdef in misc_init_r(). You can always make the function static and implement it before misc_init_r() so that the compiler is likely to inline it.
I'm not sure that models[rpi_board_rev].name contains values that are useful to place into an environment variable. It depends what you expect to do with that variable. Note that the values are not unique, and contain spaces, which might make the value hard to use and/or not reliable to differentiate between all the different types of boards.
Conceptually I have no general objection to this patch, although I am a little worried about turning the board_name variable into some kind of ABI.
PATCH 1/1 ARM: rpi: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support
Le 19/08/2015 05:14, Stephen Warren a ?crit :
Quoted 5 lines · Guillaume GARDET
Quoted 2 lines
Add
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGsupport to set 'board_rev' and 'board_name' envs.That states what the patch does rather than why its useful to do it. Can you expand on why it's useful to set these variables?
Using boot scripts you may need to get the board version / revision infos, for example to select the right DTB since u-boot DTB names and kernel DTB files do not match.
Quoted 12 lines
Quoted 12 lines
board/raspberrypi/rpi/rpi.c +6
-0@@ -240,6 +240,12 @@ int misc_init_r(void) {set_fdtfile ();set_usbethaddr (); +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG +char str_rev[11 ]; +sprintf (str_rev,"0x%X" , rpi_board_rev); +setenv ("board_rev" , str_rev); +setenv ("board_name" , models[rpi_board_rev].name); +#endif
Quoted 8 lines
board/raspberrypi/rpi/rpi.c int misc_init_r(void) · line 250
Quoted 2 lines
board/raspberrypi/rpi/rpi.c +0
-0return 0 ; }That adds a variable declaration in the middle of code. I'd suggest moving the new code into
set_board_info()(a name that some other boards/SoCs that honorCONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGuse), and calling that function inside the ifdef inmisc_init_r(). You can always make the function static and implement it beforemisc_init_r()so that the compiler is likely to inline it.
Ok, will do that.
Quoted 10 lines
I'm not sure that models[rpi_board_rev].name contains values that are useful to place into an environment variable. It depends what you expect to do with that variable. Note that the values are not unique, and contain spaces, which might make the value hard to use and/or not reliable to differentiate between all the different types of boards.
Conceptually I have no general objection to this patch, although I am a little worried about turning the
board_namevariable into some kind of ABI.
board_name variable should be considered to get a pretty board info print, not any kind of ABI. If people need to differentiate boards revs, just use board_rev variable.
Guillaume
PATCH 1/1 ARM: rpi: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support
Quoted 4 lines · Guillaume Gardet
Le 19/08/2015 05:14, Stephen Warren a ?crit :
Quoted 1 line · Guillaume GARDET
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines
Add
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGsupport to set 'board_rev' and 'board_name' envs.That states what the patch does rather than why its useful to do it. Can you expand on why it's useful to set these variables?
Using boot scripts you may need to get the board version / revision infos, for example to select the right DTB since u-boot DTB names and kernel DTB files do not match.
The fix here isn't to craft all kinds of complex scripts in U-Boot based on a slew of extra variables. Rather, the set of DT files in the kernel should be expanded so that there is one DT per board design, i.e. so the filenames in the kernel match the filenames that U-Boot expects.
Quoted 30 lines
Quoted 12 lines
Quoted 12 lines
board/raspberrypi/rpi/rpi.c +6
-0@@ -240,6 +240,12 @@ int misc_init_r(void) {set_fdtfile ();set_usbethaddr (); +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG +char str_rev[11 ]; +sprintf (str_rev,"0x%X" , rpi_board_rev); +setenv ("board_rev" , str_rev); +setenv ("board_name" , models[rpi_board_rev].name); +#endif return 0 ;Quoted 8 lines
board/raspberrypi/rpi/rpi.c int misc_init_r(void) · line 250
Quoted 1 line
board/raspberrypi/rpi/rpi.c +0
-0}That adds a variable declaration in the middle of code. I'd suggest moving the new code into
set_board_info()(a name that some other boards/SoCs that honorCONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGuse), and calling that function inside the ifdef inmisc_init_r(). You can always make the function static and implement it beforemisc_init_r()so that the compiler is likely to inline it.Ok, will do that.
Quoted 7 lines
I'm not sure that models[rpi_board_rev].name contains values that are useful to place into an environment variable. It depends what you expect to do with that variable. Note that the values are not unique, and contain spaces, which might make the value hard to use and/or not reliable to differentiate between all the different types of boards.
Quoted 7 lines
Quoted 3 lines
Conceptually I have no general objection to this patch, although I am a little worried about turning the
board_namevariable into some kind of ABI.
board_namevariable should be considered to get a pretty board info print, not any kind of ABI. If people need to differentiate boards revs, just useboard_revvariable.
The values in models[] are already printed when U-Boot starts.
If those are the only justifications for this patch, I'm not sure it's a good idea.
PATCH 1/1 ARM: rpi: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support
Quoted 10 lines · Stephen Warren
Quoted 9 lines · Guillaume Gardet
Le 19/08/2015 05:14, Stephen Warren a ?crit :
Quoted 5 lines · Guillaume GARDET
Quoted 2 lines
Add
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGsupport to set 'board_rev' and 'board_name' envs.That states what the patch does rather than why its useful to do it. Can you expand on why it's useful to set these variables?
Quoted 9 lines
Quoted 3 lines
Using boot scripts you may need to get the board version / revision infos, for example to select the right DTB since u-boot DTB names and kernel DTB files do not match.
The fix here isn't to craft all kinds of complex scripts in U-Boot based on a slew of extra variables. Rather, the set of DT files in the kernel should be expanded so that there is one DT per board design, i.e. so the filenames in the kernel match the filenames that U-Boot expects.
You speak of "the kernel" as if there were only one. FreeBSD also uses dtb files, and we often have to do local patches to u-boot source to make it emit identifying info such as soc type/model/rev and board rev so that we can choose the right dtb file.
The way we handle dtb files is nothing like what linux does, but we use the same dts source and dtb files as linux. In some cases we need u-boot to load those files, in other cases we just need some u-boot script code to set fdt_file to the right name, then our next-stage kernel loader handles the actual loading of the file. Who does the loading isn't as important as being able to choose the right file to load, given an sdcard image that contains a single kernel that works for a variety of related boards, but multiple dtb files, one per board.
-- Ian
PATCH 1/1 ARM: rpi: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support
Quoted 15 lines · Ian Lepore
Quoted 14 lines · Stephen Warren
Quoted 12 lines · Guillaume Gardet
Le 19/08/2015 05:14, Stephen Warren a ?crit :
Quoted 5 lines · Guillaume GARDET
Quoted 2 lines
Add
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGsupport to set 'board_rev' and 'board_name' envs.That states what the patch does rather than why its useful to do it. Can you expand on why it's useful to set these variables?
Using boot scripts you may need to get the board version / revision infos, for example to select the right DTB since u-boot DTB names and kernel DTB files do not match.
Quoted 6 lines
Quoted 4 lines
The fix here isn't to craft all kinds of complex scripts in U-Boot based on a slew of extra variables. Rather, the set of DT files in the kernel should be expanded so that there is one DT per board design, i.e. so the filenames in the kernel match the filenames that U-Boot expects.
You speak of "the kernel" as if there were only one.
You're right; I should have said "DT file repository" not "kernel" here. In practice, that's the Linux kernel at present though.
Still, I stand by my assertion that the values U-Boot expects for DTB filenames make sense, and we should update any/all repositories of DTB files so there is a complete set of matching files.
PATCH v2 1/1 ARM: rpi: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support
In reply to Stephen WarrenAdd CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support and enable it to set 'board_rev' and 'board_name' envs.
'board_rev' can be used in scripts to determine what board we are running on and 'board_name' for pretty printing.
---
Changes in V2:
* Move setenvs to set_board_info() function
* Expand patch log
board/raspberrypi/rpi/rpi.c | 13 +++++++++++++ include/configs/rpi-common.h | 1 + 2 files changed, 14 insertions(+)
board/raspberrypi/rpi/rpi.c +13 -0
@@ -236,10 +236,23 @@ static void set_usbethaddr(void)return ; } +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG +static void set_board_info (void ) +{ +char str_rev[11 ]; +sprintf (str_rev,"0x%X" , rpi_board_rev); +setenv ("board_rev" , str_rev); +setenv ("board_name" , models[rpi_board_rev].name); +} +#endif /* CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG */ +int misc_init_r (void ) {set_fdtfile ();set_usbethaddr (); +#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG +set_board_info (); +#endif return 0 ; }
include/configs/rpi-common.h +1 -0
@@ -133,6 +133,7 @@#include <config_distro_defaults.h> /* Environment */ +#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG #define ENV_DEVICE_SETTINGS \ "stdin=serial,lcd\0" \ "stdout=serial,lcd\0" \
Signature · 1 line
1.8.4.5
PATCH v2 1/1 ARM: rpi: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support
Quoted 4 lines · Guillaume GARDET
Add
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGsupport and enable it to set 'board_rev' and 'board_name' envs.
'board_rev' can be used in scripts to determine what board we are running on and 'board_name' for pretty printing.
The patch itself looks clean enough now, although like I said in response to V1 I'm still a little worried about the intended use-case, and do think there are likely better ways of solving any issue. Still, I guess the board_rev values are driven by the RPi firmware itself, so they're OK as an ABI.
PATCH v2 1/1 ARM: rpi: Add CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG support
In reply to Guillaume GARDETQuoted 10 lines · Guillaume GARDET
Add
CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIGsupport and enable it to set 'board_rev' and 'board_name' envs.
'board_rev' can be used in scripts to determine what board we are running on and 'board_name' for pretty printing.Signed-off-by Guillaume GARDET <[email protected]>Cc Stephen Warren <[email protected]>Acked-by Stephen Warren <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151024/1bb8a761/attachment.sig>