GE Bx50v3 cleanups
Subsystems (2)
v2 cover GE Bx50v3 cleanups
Here are some further cleanups for the GE Bx50v3 board(s):
PATCH 1+2: cleanup preprocessor usage in common/image-fit.c,
introduced after feedback from Simon Glass in PATCHv1
PATCH 3+4: replace magic numbers by analyzing name string from
the fitImage config node
PATCH 5: rely on PHY driver as much as possible
Changes since PATCHv1:
* introduce patch 1 & 2
* update patch 3 to avoid #if
-- Sebastian
Sebastian Reichel (5):
compiler.h: add host_build()
image: cleanup pre-processor usage
image: support board_fit_config_name_match
board: ge: bx50v3: remove confidx magic numbers
board: ge: bx50v3: cleanup phy config
arch/arm/dts/imx6q-ba16.dtsi | 11 ++ board/ge/bx50v3/bx50v3.c | 51 ++++----- common/image-fit.c | 212 +++++++++++++++++------------------ include/compiler.h | 9 ++ include/configs/ge_bx50v3.h | 4 +- include/image.h | 4 + 6 files changed, 153 insertions(+), 138 deletions(-)
Signature · 1 line
2.29.2
PATCH v2 1/5 compiler.h: add host_build()
Add a host_build() function, so that it's possible to check for software being build with USE_HOSTCC without relying on preprocessor conditions. In other words
#ifdef USE_HOSTCC
host_only_code();
#endif
can be written like this instead:
if (host_build())
host_only_code();
This improves code readability and test coverage and compiler will eleminate this unreachable code.
--- include/compiler.h | 9 +++++++++ 1 file changed, 9 insertions(+)
include/compiler.h +9 -0
@@ -6,6 +6,7 @@#define __COMPILER_H__#include <stddef.h> +#include <stdbool.h> #ifdef USE_HOSTCC
@@ -150,4 +151,12 @@ typedef unsigned long int uintptr_t;#define MEM_SUPPORT_64BIT_DATA 0#endif +static inline bool host_build (void ) { +#ifdef USE_HOSTCC +return true; +#else +return false; +#endif +} +#endif
Signature · 1 line
2.29.2
PATCH v2 1/5 compiler.h: add host_build()
Quoted 9 lines · Sebastian Reichel
Add a
host_build()function, so that it's possible to check for software being build withUSE_HOSTCCwithout relying on preprocessor conditions. In other words#ifdef USE_HOSTCC host_only_code();#endif
Quoted 7 lines
can be written like this instead:
if (
host_build())host_only_code();This improves code readability and test coverage and compiler will eleminate this unreachable code.
eliminate
Quoted 6 lines
Signed-off-by Sebastian Reichel <[email protected]>--- include/compiler.h | 9 +++++++++ 1 file changed, 9 insertions(+)
PATCH v2 1/5 compiler.h: add host_build()
In reply to Sebastian ReichelQuoted 11 lines
Add a
host_build()function, so that it's possible to check for software being build withUSE_HOSTCCwithout relying on preprocessor conditions. In other words
#ifdefUSE_HOSTCC
host_only_code();
#endif
can be written like this instead:
if (host_build())
host_only_code();
This improves code readability and test coverage and compiler will eleminate this unreachable code.
Quoted 2 lines
Signed-off-by Sebastian Reichel <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v2 2/5 image: cleanup pre-processor usage
In reply to Sebastian ReichelReplace most #ifdef checks for USE_HOSTCC and CONFIG_* with normal if instructions.
--- common/image-fit.c | 193 +++++++++++++++++++++------------------------ include/image.h | 4 + 2 files changed, 96 insertions(+), 101 deletions(-)
common/image-fit.c +92 -101
@@ -15,7 +15,6 @@#include <u-boot/crc.h> #else #include <linux/compiler.h> -#include <linux/kconfig.h> #include <common.h> #include <errno.h> #include <log.h>
@@ -28,6 +27,7 @@ DECLARE_GLOBAL_DATA_PTR;#include <bootm.h> #include <image.h> #include <bootstage.h> +#include <linux/kconfig.h> #include <u-boot/crc.h> #include <u-boot/md5.h> #include <u-boot/sha1.h>
@@ -486,16 +486,16 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) ret =fit_image_get_data_and_size (fit, image_noffset, &data, &size); -#ifndef USE_HOSTCC -printf ("%s Data Start: " , p); -if (ret) { -printf ("unavailable\n" ); - }else { -void *vdata = (void *)data; +if (!host_build ()) { +printf ("%s Data Start: " , p); +if (ret) { +printf ("unavailable\n" ); + }else { +void *vdata = (void *)data; -printf ("0x%08lx\n" , (ulong )map_to_sysmem (vdata)); +printf ("0x%08lx\n" , (ulong )map_to_sysmem (vdata)); + } } -#endif printf ("%s Data Size: " , p);if (ret)
@@ -1420,7 +1420,6 @@ int fit_all_image_verify(const void *fit)return 1 ; } -#ifdef CONFIG_FIT_CIPHER static int fit_image_uncipher (const void *fit,int image_noffset,void **data,size_t *size) {
@@ -1444,7 +1443,6 @@ static int fit_image_uncipher(const void *fit, int image_noffset, out:return ret; } -#endif /* CONFIG_FIT_CIPHER */ /** * fit_image_check_os - check whether image node is of a given os type
@@ -1486,9 +1484,8 @@ int fit_image_check_arch(const void *fit, int noffset, uint8_t arch)uint8_t image_arch;int aarch32_support =0 ; -#ifdef CONFIG_ARM64_SUPPORT_AARCH32 - aarch32_support =1 ; -#endif +if (IS_ENABLED (CONFIG_ARM64_SUPPORT_AARCH32 )) + aarch32_support =1 ;if (fit_image_get_arch (fit, noffset, &image_arch))return 0 ;
@@ -1977,13 +1974,13 @@ int fit_image_load(bootm_headers_t *images, ulong addr, }bootstage_mark (bootstage_id +BOOTSTAGE_SUB_CHECK_ARCH ); -#if !defined(USE_HOSTCC ) && !defined(CONFIG_SANDBOX ) -if (!fit_image_check_target_arch (fit, noffset)) { -puts ("Unsupported Architecture\n" ); -bootstage_error (bootstage_id +BOOTSTAGE_SUB_CHECK_ARCH ); -return -ENOEXEC ; +if (!host_build () &&IS_ENABLED (CONFIG_SANDBOX )) { +if (!fit_image_check_target_arch (fit, noffset)) { +puts ("Unsupported Architecture\n" ); +bootstage_error (bootstage_id +BOOTSTAGE_SUB_CHECK_ARCH ); +return -ENOEXEC ; + } } -#endif #ifndef USE_HOSTCC fit_image_get_arch (fit, noffset, &os_arch);
@@ -2029,9 +2026,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,return -ENOENT ; } -#ifdef CONFIG_FIT_CIPHER /* Decrypt data before uncompress/move */ -if (IMAGE_ENABLE_DECRYPT ) { +if (IS_ENABLED (CONFIG_FIT_CIPHER ) &&IMAGE_ENABLE_DECRYPT ) {puts (" Decrypting Data ... " );if (fit_image_uncipher (fit, noffset, &buf, &size)) {puts ("Error\n" );
@@ -2039,12 +2035,10 @@ int fit_image_load(bootm_headers_t *images, ulong addr, }puts ("OK\n" ); } -#endif -#if !defined(USE_HOSTCC ) && defined(CONFIG_FIT_IMAGE_POST_PROCESS )/* perform any post-processing on the image data */ -board_fit_image_post_process (&buf, &size); -#endif +if (!host_build () &&IS_ENABLED (CONFIG_FIT_IMAGE_POST_PROCESS )) +board_fit_image_post_process (&buf, &size); len = (ulong )size;
@@ -2166,14 +2160,12 @@ int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,char *fit_uname_config_copy =NULL ;char *next_config =NULL ;ulong load, len; -#ifdef CONFIG_OF_LIBFDT_OVERLAY ulong image_start, image_end;ulong ovload, ovlen;const char *uconfig;const char *uname;void *base, *ov;int i, err, noffset, ov_noffset; -#endif fit_uname = fit_unamep ? *fit_unamep :NULL ;
@@ -2212,84 +2204,83 @@ int boot_get_fdt_fit(bootm_headers_t *images, ulong addr, goto out;/* we need to apply overlays */ - -#ifdef CONFIG_OF_LIBFDT_OVERLAY - image_start = addr; - image_end = addr +fit_get_size (fit); -/* verify that relocation took place by load address not being in fit */ -if (load >= image_start && load < image_end) { -/* check is simplified; fit load checks for overlaps */ -printf ("Overlayed FDT requires relocation\n" ); - fdt_noffset = -EBADF ; - goto out; - } - - base =map_sysmem (load, len); - -/* apply extra configs in FIT first, followed by args */ -for (i =1 ; ; i++) { -if (i < count) { - noffset =fit_conf_get_prop_node_index (fit, cfg_noffset, -FIT_FDT_PROP , i); - uname =fit_get_name (fit, noffset,NULL ); - uconfig =NULL ; - }else { -if (!next_config) -break ; - uconfig = next_config; - next_config =strchr (next_config,'#' ); -if (next_config) - *next_config++ ='\0' ; - uname =NULL ; - -/* -* fit_image_load() would load the first FDT from the -* extra config only when uconfig is specified. -* Check if the extra config contains multiple FDTs and -* if so, load them. -*/ - cfg_noffset =fit_conf_get_node (fit, uconfig); - - i =0 ; - count =fit_conf_get_prop_node_count (fit, cfg_noffset, -FIT_FDT_PROP ); +if (IS_ENABLED (CONFIG_OF_LIBFDT_OVERLAY )) { + image_start = addr; + image_end = addr +fit_get_size (fit); +/* verify that relocation took place by load address not being in fit */ +if (load >= image_start && load < image_end) { +/* check is simplified; fit load checks for overlaps */ +printf ("Overlayed FDT requires relocation\n" ); + fdt_noffset = -EBADF ; + goto out; } -debug ("%d: using uname=%s uconfig=%s\n" , i, uname, uconfig); + base =map_sysmem (load, len); + +/* apply extra configs in FIT first, followed by args */ +for (i =1 ; ; i++) { +if (i < count) { + noffset =fit_conf_get_prop_node_index (fit, cfg_noffset, +FIT_FDT_PROP , i); + uname =fit_get_name (fit, noffset,NULL ); + uconfig =NULL ; + }else { +if (!next_config) +break ; + uconfig = next_config; + next_config =strchr (next_config,'#' ); +if (next_config) + *next_config++ ='\0' ; + uname =NULL ; + +/* +* fit_image_load() would load the first FDT from the +* extra config only when uconfig is specified. +* Check if the extra config contains multiple FDTs and +* if so, load them. +*/ + cfg_noffset =fit_conf_get_node (fit, uconfig); + + i =0 ; + count =fit_conf_get_prop_node_count (fit, cfg_noffset, +FIT_FDT_PROP ); + } - ov_noffset =fit_image_load (images, - addr, &uname, &uconfig, - arch,IH_TYPE_FLATDT , -BOOTSTAGE_ID_FIT_FDT_START , -FIT_LOAD_REQUIRED , &ovload, &ovlen); -if (ov_noffset <0 ) { -printf ("load of %s failed\n" , uname); -continue ; - } -debug ("%s loaded at 0x%08lx len=0x%08lx\n" , - uname, ovload, ovlen); - ov =map_sysmem (ovload, ovlen); - - base =map_sysmem (load, len + ovlen); - err =fdt_open_into (base, base, len + ovlen); -if (err <0 ) { -printf ("failed on fdt_open_into\n" ); - fdt_noffset = err; - goto out; - } -/* the verbose method prints out messages on error */ - err =fdt_overlay_apply_verbose (base, ov); -if (err <0 ) { - fdt_noffset = err; - goto out; +debug ("%d: using uname=%s uconfig=%s\n" , i, uname, uconfig); + + ov_noffset =fit_image_load (images, + addr, &uname, &uconfig, + arch,IH_TYPE_FLATDT , +BOOTSTAGE_ID_FIT_FDT_START , +FIT_LOAD_REQUIRED , &ovload, &ovlen); +if (ov_noffset <0 ) { +printf ("load of %s failed\n" , uname); +continue ; + } +debug ("%s loaded@0x%08lx len=0x%08lx\n" , + uname, ovload, ovlen); + ov =map_sysmem (ovload, ovlen); + + base =map_sysmem (load, len + ovlen); + err =fdt_open_into (base, base, len + ovlen); +if (err <0 ) { +printf ("failed on fdt_open_into\n" ); + fdt_noffset = err; + goto out; + } +/* the verbose method prints out messages on error */ + err =fdt_overlay_apply_verbose (base, ov); +if (err <0 ) { + fdt_noffset = err; + goto out; + } +fdt_pack (base); + len =fdt_totalsize (base); } -fdt_pack (base); - len =fdt_totalsize (base); + }else { +printf ("config with overlays but CONFIG_OF_LIBFDT_OVERLAY not set\n" ); + fdt_noffset = -EBADF ; } -#else -printf ("config with overlays but CONFIG_OF_LIBFDT_OVERLAY not set\n" ); - fdt_noffset = -EBADF ; -#endif out:if (datap)
include/image.h +4 -0
@@ -1552,6 +1552,10 @@ int board_fit_config_name_match(const char *name);* @return no return value (failure should be handled internally) */ void board_fit_image_post_process (void **p_image,size_t *p_size); +#else +static inline void board_fit_image_post_process (void **p_image,size_t *p_size) +{ +}#endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */ #define FDT_ERROR ((ulong)(-1))
Signature · 1 line
2.29.2
PATCH v2 2/5 image: cleanup pre-processor usage
Hi Sebastian,
Quoted 9 lines · Sebastian Reichel
Replace most #ifdef checks for
USE_HOSTCCand CONFIG_* with normal if instructions.Signed-off-by Sebastian Reichel <[email protected]>--- common/image-fit.c | 193 +++++++++++++++++++++------------------------ include/image.h | 4 + 2 files changed, 96 insertions(+), 101 deletions(-)
Quoted 171 lines
common/image-fit.c +20
-60@@ -15,7 +15,6 @@#include <u-boot/crc.h> #else #include <linux/compiler.h> -#include <linux/kconfig.h> #include <common.h> #include <errno.h> #include <log.h> @@ -28,6 +27,7 @@ DECLARE_GLOBAL_DATA_PTR;#include <bootm.h> #include <image.h> #include <bootstage.h> +#include <linux/kconfig.h> #include <u-boot/crc.h> #include <u-boot/md5.h> #include <u-boot/sha1.h> @@ -486,16 +486,16 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) ret =fit_image_get_data_and_size (fit, image_noffset, &data, &size); -#ifndef USE_HOSTCC -printf ("%s Data Start: " , p); -if (ret) { -printf ("unavailable\n" ); - }else { -void *vdata = (void *)data; +if (!host_build ()) { +printf ("%s Data Start: " , p); +if (ret) { +printf ("unavailable\n" ); + }else { +void *vdata = (void *)data; -printf ("0x%08lx\n" , (ulong )map_to_sysmem (vdata)); +printf ("0x%08lx\n" , (ulong )map_to_sysmem (vdata)); + } } -#endif printf ("%s Data Size: " , p);if (ret)@@ -1420,7 +1420,6 @@ int fit_all_image_verify(const void *fit)return 1 ; } -#ifdef CONFIG_FIT_CIPHER static int fit_image_uncipher (const void *fit,int image_noffset,void **data,size_t *size) {@@ -1444,7 +1443,6 @@ static int fit_image_uncipher(const void *fit, int image_noffset, out:return ret; } -#endif /* CONFIG_FIT_CIPHER */ /** * fit_image_check_os - check whether image node is of a given os type @@ -1486,9 +1484,8 @@ int fit_image_check_arch(const void *fit, int noffset, uint8_t arch)uint8_t image_arch;int aarch32_support =0 ; -#ifdef CONFIG_ARM64_SUPPORT_AARCH32 - aarch32_support =1 ; -#endif +if (IS_ENABLED (CONFIG_ARM64_SUPPORT_AARCH32 )) + aarch32_support =1 ;if (fit_image_get_arch (fit, noffset, &image_arch))return 0 ;@@ -1977,13 +1974,13 @@ int fit_image_load(bootm_headers_t *images, ulong addr, }bootstage_mark (bootstage_id +BOOTSTAGE_SUB_CHECK_ARCH ); -#if !defined(USE_HOSTCC ) && !defined(CONFIG_SANDBOX ) -if (!fit_image_check_target_arch (fit, noffset)) { -puts ("Unsupported Architecture\n" ); -bootstage_error (bootstage_id +BOOTSTAGE_SUB_CHECK_ARCH ); -return -ENOEXEC ; +if (!host_build () &&IS_ENABLED (CONFIG_SANDBOX )) { +if (!fit_image_check_target_arch (fit, noffset)) { +puts ("Unsupported Architecture\n" ); +bootstage_error (bootstage_id +BOOTSTAGE_SUB_CHECK_ARCH ); +return -ENOEXEC ; + } } -#endif #ifndef USE_HOSTCC fit_image_get_arch (fit, noffset, &os_arch);@@ -2029,9 +2026,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr,return -ENOENT ; } -#ifdef CONFIG_FIT_CIPHER /* Decrypt data before uncompress/move */ -if (IMAGE_ENABLE_DECRYPT ) { +if (IS_ENABLED (CONFIG_FIT_CIPHER ) &&IMAGE_ENABLE_DECRYPT ) {puts (" Decrypting Data ... " );if (fit_image_uncipher (fit, noffset, &buf, &size)) {puts ("Error\n" );@@ -2039,12 +2035,10 @@ int fit_image_load(bootm_headers_t *images, ulong addr, }puts ("OK\n" ); } -#endif -#if !defined(USE_HOSTCC ) && defined(CONFIG_FIT_IMAGE_POST_PROCESS )/* perform any post-processing on the image data */ -board_fit_image_post_process (&buf, &size); -#endif +if (!host_build () &&IS_ENABLED (CONFIG_FIT_IMAGE_POST_PROCESS )) +board_fit_image_post_process (&buf, &size); len = (ulong )size;@@ -2166,14 +2160,12 @@ int boot_get_fdt_fit(bootm_headers_t *images, ulong addr,char *fit_uname_config_copy =NULL ;char *next_config =NULL ;ulong load, len; -#ifdef CONFIG_OF_LIBFDT_OVERLAY ulong image_start, image_end;ulong ovload, ovlen;const char *uconfig;const char *uname;void *base, *ov;int i, err, noffset, ov_noffset; -#endif fit_uname = fit_unamep ? *fit_unamep :NULL ;@@ -2212,84 +2204,83 @@ int boot_get_fdt_fit(bootm_headers_t *images, ulong addr, goto out;/* we need to apply overlays */ - -#ifdef CONFIG_OF_LIBFDT_OVERLAY - image_start = addr; - image_end = addr +fit_get_size (fit); -/* verify that relocation took place by load address not being in fit */ -if (load >= image_start && load < image_end) { -/* check is simplified; fit load checks for overlaps */ -printf ("Overlayed FDT requires relocation\n" ); - fdt_noffset = -EBADF ; - goto out; - } - - base =map_sysmem (load, len); - -/* apply extra configs in FIT first, followed by args */ -for (i =1 ; ; i++) { -if (i < count) { - noffset =fit_conf_get_prop_node_index (fit, cfg_noffset, -FIT_FDT_PROP , i); - uname =fit_get_name (fit, noffset,NULL ); - uconfig =NULL ; - }else { -if (!next_config) -break ; - uconfig = next_config; - next_config =strchr (next_config,'#' ); -if (next_config) - *next_config++ ='\0' ; - uname =NULL ; - -/* -* fit_image_load() would load the first FDT from the
common/image-fit.c int boot_get_fdt_fit(bootm_headers_t *images, ulong addr, · line 2207
Quoted 10 lines
common/image-fit.c +1
-9-* extra config only when uconfig is specified. -* Check if the extra config contains multiple FDTs and -* if so, load them. -*/ - cfg_noffset =fit_conf_get_node (fit, uconfig); - - i =0 ; - count =fit_conf_get_prop_node_count (fit, cfg_noffset, -FIT_FDT_PROP ); +if (IS_ENABLED (CONFIG_OF_LIBFDT_OVERLAY )) {
The odd thing about the host build is that it normally does not have access to the CONFIG options. Presumably IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) is therefore 0
However, in general on the host we want to enable all features relevant to the host tools.
if (host_build() || IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY))
(BTW this is a general comment and I don't think it affects this patch...if you do adjust things it should be done after this series, since from what I can tell your series does not change behaviour)
Regards,
Simon
PATCH v2 3/5 image: support board_fit_config_name_match
In reply to Sebastian ReichelSupport reusing board_fit_config_name_match() to automatically select a sensible default configuration for booting fitImages using 'bootm'.
--- common/image-fit.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
common/image-fit.c +13 -6
@@ -1738,12 +1738,19 @@ int fit_conf_get_node(const void *fit, const char *conf_uname)if (conf_uname ==NULL ) {/* get configuration unit name from the default property */ debug ("No configuration specified, trying default...\n" ); - conf_uname = (char *)fdt_getprop (fit, confs_noffset, -FIT_DEFAULT_PROP , &len); -if (conf_uname ==NULL ) { -fit_get_debug (fit, confs_noffset,FIT_DEFAULT_PROP , - len); -return len; +if (!host_build () &&IS_ENABLED (CONFIG_MULTI_DTB_FIT )) { + noffset =fit_find_config_node (fit); +if (noffset <0 ) +return noffset; + conf_uname =fdt_get_name (fit, noffset,NULL ); + }else { + conf_uname = (char *)fdt_getprop (fit, confs_noffset, +FIT_DEFAULT_PROP , &len); +if (conf_uname ==NULL ) { +fit_get_debug (fit, confs_noffset,FIT_DEFAULT_PROP , + len); +return len; + } }debug ("Found default configuration: '%s'\n" , conf_uname); }
Signature · 1 line
2.29.2
PATCH v2 3/5 image: support board_fit_config_name_match
Quoted 10 lines · Sebastian Reichel
Support reusing
board_fit_config_name_match()to automatically select a sensible default configuration for booting fitImages using 'bootm'.Signed-off-by Sebastian Reichel <[email protected]>--- common/image-fit.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)
Can you see if you can add a test for this case?
PATCH v2 3/5 image: support board_fit_config_name_match
In reply to Sebastian ReichelQuoted 4 lines · Sebastian Reichel
Support reusing
board_fit_config_name_match()to automatically select a sensible default configuration for booting fitImages using 'bootm'.
For reasons I have not understood, this patch breaks "sometimes" the build :
+common/image-fit.c: In function 'boot_get_fdt_fit':+common/image-fit.c:2279:10: error: implicit declaration of function 'fdt_overlay_apply_verbose'; did you mean 'fdt_overlay_apply_node'? [-Werror=implicit-function-declaration]
+ 2279 | err = fdt_overlay_apply_verbose(base, ov); + | ^~~~~~~~~~~~~~~~~~~~~~~~~ + | fdt_overlay_apply_node
+cc1: all warnings being treated as errors
https://gitlab.denx.de/u-boot/custodians/u-boot-imx/-/jobs/193967
And it looks to me that fdt_support.h is included.
This happens if I run buildman locally, too. But it is not deterministic, sometimes it succeed.
snapper9g20 and snapper9260 seem to trigger more frequently the issues (but they are not the ones). So I applied the patches related to the board, but I left this out.
Best regards,
Stefano Babic
Quoted 36 lines
Signed-off-by Sebastian Reichel <[email protected]>--- common/image-fit.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)common/image-fit.c +13
-6@@ -1738,12 +1738,19 @@ int fit_conf_get_node(const void *fit, const char *conf_uname)if (conf_uname ==NULL ) {/* get configuration unit name from the default property */ debug ("No configuration specified, trying default...\n" ); - conf_uname = (char *)fdt_getprop (fit, confs_noffset, -FIT_DEFAULT_PROP , &len); -if (conf_uname ==NULL ) { -fit_get_debug (fit, confs_noffset,FIT_DEFAULT_PROP , - len); -return len; +if (!host_build () &&IS_ENABLED (CONFIG_MULTI_DTB_FIT )) { + noffset =fit_find_config_node (fit); +if (noffset <0 ) +return noffset; + conf_uname =fdt_get_name (fit, noffset,NULL ); + }else { + conf_uname = (char *)fdt_getprop (fit, confs_noffset, +FIT_DEFAULT_PROP , &len); +if (conf_uname ==NULL ) { +fit_get_debug (fit, confs_noffset,FIT_DEFAULT_PROP , + len); +return len; + } }debug ("Found default configuration: '%s'\n" , conf_uname); }
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v2 3/5 image: support board_fit_config_name_match
Hi,
Quoted 19 lines · Stefano Babic
Quoted 4 lines · Sebastian Reichel
Support reusing
board_fit_config_name_match()to automatically select a sensible default configuration for booting fitImages using 'bootm'.For reasons I have not understood, this patch breaks "sometimes" the build :
(quoted diff) +2
-0+common/image-fit.c: In function 'boot_get_fdt_fit': +common/image-fit.c:2279:10: error: implicit declaration of function'
fdt_overlay_apply_verbose'; did you mean 'fdt_overlay_apply_node'? [-Werror=implicit-function-declaration]
+ 2279 | err =fdt_overlay_apply_verbose(base, ov);(quoted diff) +3
-0+ | ^~~~~~~~~~~~~~~~~~~~~~~~~ + | fdt_overlay_apply_node +cc1: all warnings being treated as errorshttps://gitlab.denx.de/u-boot/custodians/u-boot-imx/-/jobs/193967
Quoted 7 lines
And it looks to me that
fdt_support.his included.This happens if I run buildman locally, too. But it is not deterministic, sometimes it succeed.
snapper9g20 and snapper9260 seem to trigger more frequently the issues (but they are not the ones).
I found the root cause. It's not this patch, but the previous one. fdt_support.h is included, but in it all declartions only happen if OF_LIBFDT is defined. My previous patch changes the code block calling fdt_overlay_apply_verbose() from ifdef OF_LIBFDT_OVERLAY to IS_ENABLED(OF_LIBFDT_OVERLAY). Note, that OF_LIBFDT_OVERLAY requires OF_LIBFDT.
I'm about to send PATCHv3 dropping the OF_LIBFDT_OVERLAY related cleanup.
Quoted 2 lines
So I applied the patches related to the board, but I left this out.
Not applying this patch results in GE Bx50v3 boards no longer booting properly with the default config :(
-- Sebastian
Quoted 31 lines
Best regards,
Stefano BabicQuoted 28 lines
Signed-off-by Sebastian Reichel <[email protected]>--- common/image-fit.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)common/image-fit.c +9
-6@@ -1738,12 +1738,19 @@ int fit_conf_get_node(const void *fit, const char *conf_uname)if (conf_uname ==NULL ) {/* get configuration unit name from the default property */ debug ("No configuration specified, trying default...\n" ); - conf_uname = (char *)fdt_getprop (fit, confs_noffset, -FIT_DEFAULT_PROP , &len); -if (conf_uname ==NULL ) { -fit_get_debug (fit, confs_noffset,FIT_DEFAULT_PROP , - len); -return len; +if (!host_build () &&IS_ENABLED (CONFIG_MULTI_DTB_FIT )) { + noffset =fit_find_config_node (fit); +if (noffset <0 ) +return noffset; + conf_uname =fdt_get_name (fit, noffset,NULL ); + }else { + conf_uname = (char *)fdt_getprop (fit, confs_noffset, +FIT_DEFAULT_PROP , &len); +if (conf_uname ==NULL ) {
Quoted 16 lines
Quoted 8 lines
common/image-fit.c +4
-0+fit_get_debug (fit, confs_noffset,FIT_DEFAULT_PROP , + len); +return len; + } }debug ("Found default configuration: '%s'\n" , conf_uname); }Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210104/83b8334d/attachment.sig>
PATCH v2 3/5 image: support board_fit_config_name_match
Hi Sebastian,
Quoted 27 lines · Sebastian Reichel
Hi,
Quoted 24 lines · Stefano Babic
Quoted 4 lines · Sebastian Reichel
Support reusing
board_fit_config_name_match()to automatically select a sensible default configuration for booting fitImages using 'bootm'.For reasons I have not understood, this patch breaks "sometimes" the build :
(quoted diff) +2
-0+common/image-fit.c: In function 'boot_get_fdt_fit': +common/image-fit.c:2279:10: error: implicit declaration of function'
fdt_overlay_apply_verbose'; did you mean 'fdt_overlay_apply_node'? [-Werror=implicit-function-declaration]
+ 2279 | err =fdt_overlay_apply_verbose(base, ov);(quoted diff) +3
-0+ | ^~~~~~~~~~~~~~~~~~~~~~~~~ + | fdt_overlay_apply_node +cc1: all warnings being treated as errorshttps://gitlab.denx.de/u-boot/custodians/u-boot-imx/-/jobs/193967
And it looks to me that
fdt_support.his included.This happens if I run buildman locally, too. But it is not deterministic, sometimes it succeed.
Quoted 9 lines
Quoted 2 lines
snapper9g20 and snapper9260 seem to trigger more frequently the issues (but they are not the ones).
I found the root cause. It's not this patch, but the previous one.
fdt_support.his included, but in it all declartions only happen ifOF_LIBFDTis defined. My previous patch changes the code block callingfdt_overlay_apply_verbose()from ifdefOF_LIBFDT_OVERLAYtoIS_ENABLED(OF_LIBFDT_OVERLAY). Note, thatOF_LIBFDT_OVERLAYrequiresOF_LIBFDT.
Good catch !
Quoted 4 lines
I'm about to send PATCHv3 dropping the
OF_LIBFDT_OVERLAYrelated cleanup.
Thanks !
Quoted 6 lines
Quoted 2 lines
So I applied the patches related to the board, but I left this out.
Not applying this patch results in GE Bx50v3 boards no longer booting properly with the default config :(
I will then apply it and ask Tom to include it in the release - thanks !
Best regards,
Stefano
Quoted 49 lines
-- Sebastian
Quoted 47 lines
Best regards,
Stefano BabicQuoted 36 lines
Signed-off-by Sebastian Reichel <[email protected]>--- common/image-fit.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-)common/image-fit.c +13
-6@@ -1738,12 +1738,19 @@ int fit_conf_get_node(const void *fit, const char *conf_uname)if (conf_uname ==NULL ) {/* get configuration unit name from the default property */ debug ("No configuration specified, trying default...\n" ); - conf_uname = (char *)fdt_getprop (fit, confs_noffset, -FIT_DEFAULT_PROP , &len); -if (conf_uname ==NULL ) { -fit_get_debug (fit, confs_noffset,FIT_DEFAULT_PROP , - len); -return len; +if (!host_build () &&IS_ENABLED (CONFIG_MULTI_DTB_FIT )) { + noffset =fit_find_config_node (fit); +if (noffset <0 ) +return noffset; + conf_uname =fdt_get_name (fit, noffset,NULL ); + }else { + conf_uname = (char *)fdt_getprop (fit, confs_noffset, +FIT_DEFAULT_PROP , &len); +if (conf_uname ==NULL ) { +fit_get_debug (fit, confs_noffset,FIT_DEFAULT_PROP , + len); +return len; + } }debug ("Found default configuration: '%s'\n" , conf_uname); }Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v2 3/5 image: support board_fit_config_name_match
Hi Stefano,
Quoted 5 lines · Stefano Babic
Quoted 2 lines
I'm about to send PATCHv3 dropping the
OF_LIBFDT_OVERLAYrelated cleanup.Thanks !
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
So I applied the patches related to the board, but I left this out.
Not applying this patch results in GE Bx50v3 boards no longer booting properly with the default config :(
I will then apply it and ask Tom to include it in the release - thanks!
Thanks, this is PATCHv3 for the remaining patches:
https://patchwork.ozlabs.org/project/uboot/list/?series=222707
-- Sebastian
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210105/8f9be3b6/attachment.sig>
PATCH v2 3/5 image: support board_fit_config_name_match
Hi Sebastian,
Quoted 11 lines · Sebastian Reichel
Hi Stefano,
Quoted 8 lines · Stefano Babic
Quoted 2 lines
I'm about to send PATCHv3 dropping the
OF_LIBFDT_OVERLAYrelated cleanup.Thanks !
Quoted 3 lines
Quoted 2 lines
So I applied the patches related to the board, but I left this out.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Not applying this patch results in GE Bx50v3 boards no longer booting properly with the default config :(
I will then apply it and ask Tom to include it in the release - thanks!
Thanks, this is PATCHv3 for the remaining patches:
Yes, I saw them and I asked Tom to pick them up ;-)
Stefano
Quoted 3 lines
-- Sebastian
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v2 4/5 board: ge: bx50v3: remove confidx magic numbers
In reply to Sebastian ReichelInstead of hardcoding index magic numbers in the board code, also rely on board_fit_config_name_match choosing the right config for the fitImage containing the kernel.
--- board/ge/bx50v3/bx50v3.c | 16 ++++++++++------ include/configs/ge_bx50v3.h | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-)
board/ge/bx50v3/bx50v3.c +10 -6
@@ -356,15 +356,12 @@ static void process_vpd(struct vpd_cache *vpd)switch (vpd->product_id) {case VPD_PRODUCT_B450 : -env_set ("confidx" ,"1" ); i210_index =1 ;break ;case VPD_PRODUCT_B650 : -env_set ("confidx" ,"2" ); i210_index =1 ;break ;case VPD_PRODUCT_B850 : -env_set ("confidx" ,"3" ); i210_index =2 ;break ; }
@@ -554,16 +551,23 @@ int ft_board_setup(void *blob, struct bd_info *bd)int board_fit_config_name_match (const char *name) { +const char *machine = name; +if (!vpd.is_read)return strcmp (name,"imx6q-bx50v3" ); +if (!strncmp (machine,"Boot " ,5 )) + machine +=5 ; +if (!strncmp (machine,"imx6q-" ,6 )) + machine +=6 ; +switch (vpd.product_id) {case VPD_PRODUCT_B450 : -return strcmp (name,"imx6q-b450v3" ); +return strcasecmp (machine,"b450v3" );case VPD_PRODUCT_B650 : -return strcmp (name,"imx6q-b650v3" ); +return strcasecmp (machine,"b650v3" );case VPD_PRODUCT_B850 : -return strcmp (name,"imx6q-b850v3" ); +return strcasecmp (machine,"b850v3" );default :return -1 ; }
include/configs/ge_bx50v3.h +2 -2
@@ -62,7 +62,7 @@"networkboot=" \"run setnetworkboot; " \"nfs ${loadaddr} /srv/nfs/fitImage; " \ -"bootm ${loadaddr}#conf@${confidx}\0" \ +"bootm ${loadaddr}\0" \ #define CONFIG_NETWORKBOOTCOMMAND \"run networkboot; " \
@@ -111,7 +111,7 @@"doboot=" \"echo Booting from ${dev}:${devnum}:${partnum} ...; " \"run setargs; " \ -"bootm ${loadaddr}#conf@${confidx}\0" \ +"bootm ${loadaddr}\0" \"tryboot=" \"setenv partnum 1; run hasfirstboot || setenv partnum 2; " \"run loadimage || run swappartitions && run loadimage || " \
Signature · 1 line
2.29.2
PATCH v2 4/5 board: ge: bx50v3: remove confidx magic numbers
Quoted 4 lines
Instead of hardcoding index magic numbers in the board code, also rely on
board_fit_config_name_matchchoosing the right config for the fitImage containing the kernel.Signed-off-by Sebastian Reichel <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v2 5/5 board: ge: bx50v3: cleanup phy config
In reply to Sebastian ReichelThe current PHY rework does the following things:
1. Configure 125MHz clock
2. Setup the TX clock delay (RX is enabled by default),
3. Setup reserved bits to avoid voltage peak
The clock delays are nowadays already configured by the PHY driver (in ar803x_delay_config). The code for that can simply be dropped. The clock speed can also be configured by the PHY driver by adding the device tree property "qca,clk-out-frequency".
What is left is setting up the undocumented reserved bits to avoid the voltage peak problem. I slightly improved its documentation while updating the board's PHY rework code.
--- arch/arm/dts/imx6q-ba16.dtsi | 11 +++++++++++ board/ge/bx50v3/bx50v3.c | 35 ++++++++++++----------------------- 2 files changed, 23 insertions(+), 23 deletions(-)
arch/arm/dts/imx6q-ba16.dtsi +11 -0
@@ -174,6 +174,17 @@ pinctrl-0 = <&pinctrl_enet>; phy-mode = "rgmii-id"; status = "okay"; + phy-handle = <&phy0>; + + mdio { + #address-cells = <1>; + #size-cells = <0>; + + phy0: ethernet-phy at 4 { + reg = <4>; + qca,clk-out-frequency = <125000000>; + }; + }; }; &hdmi {
board/ge/bx50v3/bx50v3.c +12 -23
@@ -47,6 +47,10 @@ DECLARE_GLOBAL_DATA_PTR;#define VPD_PRODUCT_B650 2#define VPD_PRODUCT_B450 3 +#define AR8033_DBG_REG_ADDR 0x1d +#define AR8033_DBG_REG_DATA 0x1e +#define AR8033_SERDES_REG 0x5 +static int productid;/* Default to generic. */ static struct vpd_cache vpd;
@@ -61,31 +65,16 @@ int dram_init(void)return 0 ; } -static int mx6_rgmii_rework (struct phy_device *phydev) -{ -/* Configure AR8033 to ouput a 125MHz clk from CLK_25M */ -/* set device address 0x7 */ -phy_write (phydev,MDIO_DEVAD_NONE ,0xd ,0x7 ); -/* offset 0x8016: CLK_25M Clock Select */ -phy_write (phydev,MDIO_DEVAD_NONE ,0xe ,0x8016 ); -/* enable register write, no post increment, address 0x7 */ -phy_write (phydev,MDIO_DEVAD_NONE ,0xd ,0x4007 ); -/* set to 125 MHz from local PLL source */ -phy_write (phydev,MDIO_DEVAD_NONE ,0xe ,0x18 ); - -/* rgmii tx clock delay enable */ -/* set debug port address: SerDes Test and System Mode Control */ -phy_write (phydev,MDIO_DEVAD_NONE ,0x1d ,0x05 ); -/* enable rgmii tx clock delay */ -/* set the reserved bits to avoid board specific voltage peak issue*/ -phy_write (phydev,MDIO_DEVAD_NONE ,0x1e ,0x3D47 ); - -return 0 ; -} -int board_phy_config (struct phy_device *phydev) { -mx6_rgmii_rework (phydev); +/* +* Set reserved bits to avoid board specific voltage peak issue. The +* value is a magic number provided directly by Qualcomm. Note, that +* PHY driver will take control of BIT(8) in this register to control +* TX clock delay, so we do not initialize that bit here. +*/ +phy_write (phydev,MDIO_DEVAD_NONE ,AR8033_DBG_REG_ADDR ,AR8033_SERDES_REG ); +phy_write (phydev,MDIO_DEVAD_NONE ,AR8033_DBG_REG_DATA ,0x3c47 );if (phydev->drv->config) phydev->drv->config (phydev);
Signature · 1 line
2.29.2
PATCH v2 5/5 board: ge: bx50v3: cleanup phy config
Quoted 12 lines
The current PHY rework does the following things:
1. Configure 125MHz clock
2. Setup the TX clock delay (RX is enabled by default),
3. Setup reserved bits to avoid voltage peak
The clock delays are nowadays already configured by the PHY driver (inar803x_delay_config). The code for that can simply be dropped. The clock speed can also be configured by the PHY driver by adding the device tree property "qca,clk-out-frequency".
What is left is setting up the undocumented reserved bits to avoid the voltage peak problem. I slightly improved its documentation while updating the board's PHY rework code.
Quoted 1 line
Signed-off-by Sebastian Reichel <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================