
With the previous suggestion from Wolfgang Denk, this patch removes the findfdt function from wandboard.h and instead replaces it with some simple logic in wandboard.c.
The new function "set_fdtfile" is called in board_late_init. This function simply finds the length of the dtb file name, allocates enough space for that string, and sets the fdtfile name to that string.
This results in slightly shorter / faster script code as well.
Dear Adam Duskett,
In message BLU436-SMTP46BCB8C63151CD3166FBD1B9360@phx.gbl you wrote:
With the release of kernel 4.1.15 for the imx6 line of processors, wandboard now uses imx6q-wandboard-revc1.dtb and imx6dl-wandboard-revc1.dtb. This patch fixes the naming convention to work with kernel 4.1.15
Signed-off-by: Adam Duskett adamduskett@outlook.com
include/configs/wandboard.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h index 99f5c0c..d41b600 100644 --- a/include/configs/wandboard.h +++ b/include/configs/wandboard.h @@ -135,9 +135,9 @@ "setenv bootargs ${bootargs} ${fbmem}\0" \ "findfdt="\ "if test $board_name = C1 && test $board_rev = MX6Q ; then " \
- "setenv fdtfile imx6q-wandboard.dtb; fi; " \
- "setenv fdtfile imx6q-wandboard-revc1.dtb; fi; " \
"if test $board_name = C1 && test $board_rev = MX6DL ; then " \
- "setenv fdtfile imx6dl-wandboard.dtb; fi; " \
- "setenv fdtfile imx6dl-wandboard-revc1.dtb; fi; " \
"if test $board_name = B1 && test $board_rev = MX6Q ; then " \ "setenv fdtfile imx6q-wandboard-revb1.dtb; fi; " \ "if test $board_name = B1 && test $board_rev = MX6DL ; then " \
Instead of adding to an ever growing list of names, would it not make sense to solve this programmatically, like by concatenating "i" + tolower($board_rev) + "-wandboard-rev" + tolower($board_name) + ".dtb"?
I guess this would also result in shorter / faster script code?
Best regards,
Wolfgang Denk
Signed-off-by: Adam Duskett Adamduskett@outlook.com --- Changes:
v1 - v2: - Removed findfdt from h file and moved it to init code.
board/wandboard/wandboard.c | 20 ++++++++++++++++++++ include/configs/wandboard.h | 12 ------------ 2 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/board/wandboard/wandboard.c b/board/wandboard/wandboard.c index 4ce74cd..a1037ed 100644 --- a/board/wandboard/wandboard.c +++ b/board/wandboard/wandboard.c @@ -29,6 +29,8 @@ #include <phy.h> #include <input.h> #include <i2c.h> +#include <linux/ctype.h> +#include <malloc.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -377,6 +379,22 @@ static bool is_revc1(void) return false; }
+static void set_fdtfile(void) +{ + char *fdtfile; + int i; + int length = strlen(getenv("board_rev")) + strlen("-wandboard-rev") + + strlen(getenv("board_name")) + strlen(".dtb") + 1; + fdtfile = malloc(length); + sprintf(fdtfile, "i%s-wandboard-rev%s.dtb", getenv("board_rev"), getenv("board_name")); + for (i = 0; i < length; i++){ + fdtfile[i] = tolower(fdtfile[i]); + } + + setenv("fdtfile", fdtfile); + free(fdtfile); +} + int board_late_init(void) { #ifdef CONFIG_CMD_BMODE @@ -393,6 +411,8 @@ int board_late_init(void) setenv("board_name", "C1"); else setenv("board_name", "B1"); + + set_fdtfile(); #endif return 0; } diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h index 99f5c0c..778c3f5 100644 --- a/include/configs/wandboard.h +++ b/include/configs/wandboard.h @@ -133,17 +133,6 @@ "echo '- no FWBADAPT-7WVGA-LCD-F07A-0102 display';" \ "fi; " \ "setenv bootargs ${bootargs} ${fbmem}\0" \ - "findfdt="\ - "if test $board_name = C1 && test $board_rev = MX6Q ; then " \ - "setenv fdtfile imx6q-wandboard.dtb; fi; " \ - "if test $board_name = C1 && test $board_rev = MX6DL ; then " \ - "setenv fdtfile imx6dl-wandboard.dtb; fi; " \ - "if test $board_name = B1 && test $board_rev = MX6Q ; then " \ - "setenv fdtfile imx6q-wandboard-revb1.dtb; fi; " \ - "if test $board_name = B1 && test $board_rev = MX6DL ; then " \ - "setenv fdtfile imx6dl-wandboard-revb1.dtb; fi; " \ - "if test $fdtfile = undefined; then " \ - "echo WARNING: Could not determine dtb to use; fi; \0" \ "kernel_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \ "pxefile_addr_r=" __stringify(CONFIG_LOADADDR) "\0" \ "ramdisk_addr_r=0x13000000\0" \ @@ -159,7 +148,6 @@ func(DHCP, dhcp, na)
#define CONFIG_BOOTCOMMAND \ - "run findfdt; " \ "run distro_bootcmd"
#include <config_distro_bootcmd.h>