Skip to contentSkip to conversation

rockchip: Fix TPL link error

PATCH Superseded FUKAUMI Naoki 5 participants 13 messages Jan 29, 2025 – Feb 11, 2025

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 rockchip: Fix TPL link error

Rockchip RK3399 targets build TPL. If CONFIG_SPL_USB_DWC3_GENERIC and CONFIG_SPL_USB_GADGET are enabled, linking u-boot-tpl will fail.

LD tpl/u-boot-tpl
ld.bfd: drivers/usb/dwc3/dwc3-generic.o: in function `dwc3_glue_bind_common':
/home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:527:(.text.dwc3_glue_bind_common+0x20): undefined reference to usb_get_dr_mode' /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:527:(.text.dwc3_glue_bind_common+0x20): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_get_dr_mode' ld.bfd: /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:529:(.text.dwc3_glue_bind_common+0x2c): undefined reference to usb_get_dr_mode' /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:529:(.text.dwc3_glue_bind_common+0x2c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_get_dr_mode' ld.bfd: drivers/usb/dwc3/dwc3-generic.o: in function `dwc3_glue_probe':
/home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:683:(.text.dwc3_glue_probe+0xb0): undefined reference to usb_get_dr_mode' /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:683:(.text.dwc3_glue_probe+0xb0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_get_dr_mode'

Do not compile drivers/usb/ for TPL.

---
 scripts/Makefile.xpl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.xpl +2 -2
index abc49fbe6c9..e4ca4d395ac 100644
@@ -125,8 +125,8 @@ endif
 
 libs-y += drivers/
 libs-$(CONFIG_SPL_MEMORY) += drivers/memory/
-libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/dwc3/
-libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/cdns3/
+libs-$(CONFIG_$(PHASE_)USB_GADGET) += drivers/usb/dwc3/
+libs-$(CONFIG_$(PHASE_)USB_GADGET) += drivers/usb/cdns3/
 libs-y += dts/
 libs-y += fs/
 libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/3 rockchip: Fix SPL link error for Radxa ROCK Pi 4

If CONFIG_EFI_CAPSULE_FIRMWARE_RAW, CONFIG_SPL_ENV_SUPPORT, and CONFIG_SPL_DFU are enabled, linking u-boot-spl will fail.

LD spl/u-boot-spl
ld.bfd: drivers/dfu/dfu.o: in function `dfu_init_env_entities':
/home/radxa/u-boot/drivers/dfu/dfu.c:173:(.text.dfu_init_env_entities+0x24): undefined reference to `set_dfu_alt_info'

Compile mach-rockchip/board.c for SPL.

---
 arch/arm/mach-rockchip/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-rockchip/Makefile +1 -1
index 5e7edc99cdc..e697df7ebcb 100644
@@ -22,10 +22,10 @@ ifeq ($(CONFIG_XPL_BUILD)$(CONFIG_TPL_BUILD),)
 # we can have the preprocessor correctly recognise both 0x0 and 0
 # meaning "turn it off".
 obj-y += boot_mode.o
-obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
 endif
 
 ifeq ($(CONFIG_TPL_BUILD),)
+obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
 obj-$(CONFIG_DISPLAY_CPUINFO) += cpu-info.o
 endif
 
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 2/3] rockchip: Fix SPL link error for Radxa ROCK Pi 4

Hi Naoki,

Quoted 19 lines · FUKAUMI Naoki

If CONFIG_EFI_CAPSULE_FIRMWARE_RAW, CONFIG_SPL_ENV_SUPPORT, and CONFIG_SPL_DFU are enabled, linking u-boot-spl will fail.

LD spl/u-boot-spl
ld.bfd: drivers/dfu/dfu.o: in function `dfu_init_env_entities':
/home/radxa/u-boot/drivers/dfu/dfu.c:173:(.text.dfu_init_env_entities+0x24): undefined reference to `set_dfu_alt_info'

Compile mach-rockchip/board.c for SPL.

---
  arch/arm/mach-rockchip/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-rockchip/Makefile +0 -0
index 5e7edc99cdc..e697df7ebcb 100644

arch/arm/mach-rockchip/Makefile ifeq ($(CONFIG_XPL_BUILD)$(CONFIG_TPL_BUILD),) · line 28

Quoted 8 lines
arch/arm/mach-rockchip/Makefile +1 -1
@@ -22,10 +22,10 @@ ifeq ($(CONFIG_XPL_BUILD)$(CONFIG_TPL_BUILD),)
  # we can have the preprocessor correctly recognise both 0x0 and 0
  # meaning "turn it off".
  obj-y += boot_mode.o
-obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
  endif
 
  ifeq ($(CONFIG_TPL_BUILD),)
+obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o

This is probably a tiny bit too enthusiastic.

This means the whole content of board.c will be compiled for SPL whereas it currently is compiled only for proper.

This means we need to be careful about what's in board.c.

Most IS_ENABLED(CONFIG_<config>) should probably be changed to CONFIG_IS_ENABLED(<config>) so that it handles SPL symbols too and doesn't attempt to build stuff for SPL when only proper symbols are selected (and not their SPL counterpart).

E.g.

- EFI_PARTITION
- SYS_DCACHE_OFF
- USB_GADGET
- DM_USB_GADGET

seems to have SPL symbols too, but

- EFI_HAVE_CAPSULE_SUPPORT
- ROCKCHIP_USB2_PHY
- FASTBOOT
- MISC_INIT_R
- ROCKCHIP_EFUSE (though does only build for proper (see the use of $(XPL_) in Makefile))
- ROCKCHIP_OTP (though does only build for proper (see the use of $(XPL_) in Makefile))
- BOARD_RNG_SEED
- RNG_ROCKCHIP

only have proper symbols.

Maybe it makes more sense to move the efi-specific part of board.c into efi.c and build that one whenever we actually need it?

What do you think?

Cheers,
Quentin

#3 lore raw

Re: [PATCH 2/3] rockchip: Fix SPL link error for Radxa ROCK Pi 4

Hi Quentin and Naoki,

Quoted 63 lines · Quentin Schulz

Hi Naoki,

Quoted 19 lines · FUKAUMI Naoki

If CONFIG_EFI_CAPSULE_FIRMWARE_RAW, CONFIG_SPL_ENV_SUPPORT, and CONFIG_SPL_DFU are enabled, linking u-boot-spl will fail.

LD spl/u-boot-spl
ld.bfd: drivers/dfu/dfu.o: in function `dfu_init_env_entities':
/home/radxa/u-boot/drivers/dfu/dfu.c:173:(.text.dfu_init_env_entities+0x24): undefined reference to `set_dfu_alt_info'

Compile mach-rockchip/board.c for SPL.

---
  arch/arm/mach-rockchip/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-rockchip/Makefile +0 -0
index 5e7edc99cdc..e697df7ebcb 100644

arch/arm/mach-rockchip/Makefile ifeq ($(CONFIG_XPL_BUILD)$(CONFIG_TPL_BUILD),) · line 28

Quoted 8 lines
arch/arm/mach-rockchip/Makefile +1 -1
@@ -22,10 +22,10 @@ ifeq ($(CONFIG_XPL_BUILD)$(CONFIG_TPL_BUILD),)
  # we can have the preprocessor correctly recognise both 0x0 and 0
  # meaning "turn it off".
  obj-y += boot_mode.o
-obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o
  endif
 
  ifeq ($(CONFIG_TPL_BUILD),)
+obj-$(CONFIG_ROCKCHIP_COMMON_BOARD) += board.o

This is probably a tiny bit too enthusiastic.

This means the whole content of board.c will be compiled for SPL whereas it currently is compiled only for proper.

This means we need to be careful about what's in board.c.

Most IS_ENABLED(CONFIG_<config>) should probably be changed to CONFIG_IS_ENABLED(<config>) so that it handles SPL symbols too and doesn't attempt to build stuff for SPL when only proper symbols are selected (and not their SPL counterpart).

E.g.

- EFI_PARTITION
- SYS_DCACHE_OFF
- USB_GADGET
- DM_USB_GADGET

seems to have SPL symbols too, but

- EFI_HAVE_CAPSULE_SUPPORT
- ROCKCHIP_USB2_PHY
- FASTBOOT
- MISC_INIT_R
- ROCKCHIP_EFUSE (though does only build for proper (see the use of $(XPL_) in Makefile))
- ROCKCHIP_OTP (though does only build for proper (see the use of $(XPL_) in Makefile))
- BOARD_RNG_SEED
- RNG_ROCKCHIP

Quoted 6 lines

only have proper symbols.

Maybe it makes more sense to move the efi-specific part of board.c into efi.c and build that one whenever we actually need it?

What do you think?

I fully agree, please move the efi-specific parts away from board.c.

In current state it is only the rock-pi-4c-rk3399 target that have use of set_dfu_alt_info(), rockchip_capsule_update_board_setup() is broken for rock-pi-4-rk3399, the code check for radxa,rockpi4b, and board target use radxa,rockpi4a :-)

Regards,
Jonas

Quoted 3 lines

Cheers,
Quentin

#4 lore raw

PATCH 3/3 rockchip: Fix binman error

In reply to FUKAUMI Naoki

After adding the below configs, binman produces an error.

CONFIG_SPL_DFU
CONFIG_SPL_ENV_SUPPORT
CONFIG_SPL_USB_DWC3_GENERIC
CONFIG_SPL_USB_GADGET

binman: Section '/binman/simple-bin-spi': Symbol '_binman_u_boot_any_prop_size'
in entry '/binman/simple-bin-spi/mkimage/u-boot-spl/u-boot-spl-nodtb': Entry 'u-boot-any' not found in list (u-boot-tpl-nodtb,u-boot-tpl-dtb,u-boot-tpl,u-boot-spl-nodtb,u-boot-spl-dtb,u-boot-spl,mkimage,fit,simple-bin-spi)

Add "no-write-symbols;" to u-boot-tpl and u-boot-spl.

---
 arch/arm/dts/rk3399-u-boot.dtsi   | 2 ++
 arch/arm/dts/rockchip-u-boot.dtsi | 4 ++++
 2 files changed, 6 insertions(+)
arch/arm/dts/rk3399-u-boot.dtsi +2 -0
index 70f35b6c197..0e3143f8235 100644
@@ -45,9 +45,11 @@
 			};
 #elif defined(CONFIG_TPL)
 			u-boot-tpl {
+				no-write-symbols;
 			};
 #endif
 			u-boot-spl {
+				no-write-symbols;
 			};
 		};
 		fit {
arch/arm/dts/rockchip-u-boot.dtsi +4 -0
index c8c928c7e50..fd005a24890 100644
@@ -27,9 +27,11 @@
 			};
 #elif defined(CONFIG_TPL)
 			u-boot-tpl {
+				no-write-symbols;
 			};
 #endif
 			u-boot-spl {
+				no-write-symbols;
 			};
 		};
 
@@ -187,9 +189,11 @@
 			};
 #elif defined(CONFIG_TPL)
 			u-boot-tpl {
+				no-write-symbols;
 			};
 #endif
 			u-boot-spl {
+				no-write-symbols;
 			};
 		};
 
Signature · 1 line
2.43.0
#5 lore raw

Re: [PATCH 3/3] rockchip: Fix binman error

Hi Naoki,

Quoted 7 lines · FUKAUMI Naoki

After adding the below configs, binman produces an error.

CONFIG_SPL_DFU
CONFIG_SPL_ENV_SUPPORT
CONFIG_SPL_USB_DWC3_GENERIC
CONFIG_SPL_USB_GADGET

Quoted 5 lines

binman: Section '/binman/simple-bin-spi': Symbol '_binman_u_boot_any_prop_size'
in entry '/binman/simple-bin-spi/mkimage/u-boot-spl/u-boot-spl-nodtb': Entry 'u-boot-any' not found in list (u-boot-tpl-nodtb,u-boot-tpl-dtb,u-boot-tpl,u-boot-spl-nodtb,u-boot-spl-dtb,u-boot-spl,mkimage,fit,simple-bin-spi)

Add "no-write-symbols;" to u-boot-tpl and u-boot-spl.

I'll be frank with you, I have no clue what's happening :)

But, it seems this only applies to the SPI image (disable ROCKCHIP_SPI_IMAGE and it'll built just fine). Why? No clue.

I've never liked how the simple-bin-spi was built because we should be reusing artifacts from simple-bin instead of rebuilding stuff. That's why you have /binman/simple-bin-spi/mkimage/fit being a blob, because we want to reuse the fitImage from /binman/simple-bin/mkimage/fit but we didn't do this for the other ones.

Can you try to revert your patch here and use this instead:

"""

arch/arm/dts/rk3399-u-boot.dtsi +6 -0
index 70f35b6c197..0a5771b706f 100644
@@ -45,9 +45,15 @@
 			};
 #elif defined(CONFIG_TPL)
 			u-boot-tpl {
+				/* sync with /binman/simple-bin/mkimage/u-boot-tpl */
+				type = "blob";
+				filename = "tpl/u-boot-tpl.bin";
 			};
 #endif
 			u-boot-spl {
+				/* sync with /binman/simple-bin/mkimage/u-boot-spl */
+				type = "blob";
+				filename = "spl/u-boot-spl.bin";
 			};
 		};
 		fit {
arch/arm/dts/rockchip-u-boot.dtsi +6 -0
index c8c928c7e50..fea49eb3145 100644
@@ -187,9 +187,15 @@
 			};
 #elif defined(CONFIG_TPL)
 			u-boot-tpl {
+				/* sync with /binman/simple-bin/mkimage/u-boot-tpl */
+				type = "blob";
+				filename = "tpl/u-boot-tpl.bin";
 			};
 #endif
 			u-boot-spl {
+				/* sync with /binman/simple-bin/mkimage/u-boot-spl */
+				type = "blob";
+				filename = "spl/u-boot-spl.bin";
 			};
 		};

"""

This seems to work for me on RK3399 Puma and Rock-Pi-4 builds with the symbols you listed enabled. I also believe this should be "better" than what we have today.

If that works, I'll send a proper patch for this :)

Cheers,
Quentin

#6 lore raw

Re: [PATCH 3/3] rockchip: Fix binman error

Hi Quentin,

Quoted 11 lines · Quentin Schulz

Hi Naoki,

Quoted 7 lines · FUKAUMI Naoki

After adding the below configs, binman produces an error.

CONFIG_SPL_DFU
CONFIG_SPL_ENV_SUPPORT
CONFIG_SPL_USB_DWC3_GENERIC
CONFIG_SPL_USB_GADGET

Quoted 7 lines
Quoted 5 lines

binman: Section '/binman/simple-bin-spi': Symbol '_binman_u_boot_any_prop_size'
in entry '/binman/simple-bin-spi/mkimage/u-boot-spl/u-boot-spl-nodtb': Entry 'u-boot-any' not found in list (u-boot-tpl-nodtb,u-boot-tpl-dtb,u-boot-tpl,u-boot-spl-nodtb,u-boot-spl-dtb,u-boot-spl,mkimage,fit,simple-bin-spi)

Add "no-write-symbols;" to u-boot-tpl and u-boot-spl.

I'll be frank with you, I have no clue what's happening :)

I means that simple-bin-spi has a binary inside it, u-boot-spl, which uses binman_sym_declare(ulong, u_boot_any, size). Most likely it is the one at the top of common/spl.c

This symbol is filled in (by binman, at build-time) with the size of the U-Boot binary. If there is no such U-Boot image then it cannot do this.

There is more information at [1]

Quoted 56 lines

But, it seems this only applies to the SPI image (disable ROCKCHIP_SPI_IMAGE and it'll built just fine). Why? No clue.

I've never liked how the simple-bin-spi was built because we should be reusing artifacts from simple-bin instead of rebuilding stuff. That's why you have /binman/simple-bin-spi/mkimage/fit being a blob, because we want to reuse the fitImage from /binman/simple-bin/mkimage/fit but we didn't do this for the other ones.

Can you try to revert your patch here and use this instead:

"""

arch/arm/dts/rk3399-u-boot.dtsi +6 -0
index 70f35b6c197..0a5771b706f 100644
@@ -45,9 +45,15 @@
                        };
  #elif defined(CONFIG_TPL)
                        u-boot-tpl {
+                               /* sync with /binman/simple-bin/mkimage/u-boot-tpl */
+                               type = "blob";
+                               filename = "tpl/u-boot-tpl.bin";
                        };
  #endif
                        u-boot-spl {
+                               /* sync with /binman/simple-bin/mkimage/u-boot-spl */
+                               type = "blob";
+                               filename = "spl/u-boot-spl.bin";
                        };
                };
                fit {
arch/arm/dts/rockchip-u-boot.dtsi +6 -0
index c8c928c7e50..fea49eb3145 100644
@@ -187,9 +187,15 @@
                        };
  #elif defined(CONFIG_TPL)
                        u-boot-tpl {
+                               /* sync with /binman/simple-bin/mkimage/u-boot-tpl */
+                               type = "blob";
+                               filename = "tpl/u-boot-tpl.bin";
                        };
  #endif
                        u-boot-spl {
+                               /* sync with /binman/simple-bin/mkimage/u-boot-spl */
+                               type = "blob";
+                               filename = "spl/u-boot-spl.bin";
                        };
                };

"""

Quoted 5 lines

This seems to work for me on RK3399 Puma and Rock-Pi-4 builds with the symbols you listed enabled. I also believe this should be "better" than what we have today.

If that works, I'll send a proper patch for this :)

Regards,
Simon

[1] https://docs.u-boot.org/en/latest/develop/package/binman.html#access-to-binman-entry-offsets-at-run-time-symbols

#7 lore raw

Re: [PATCH 3/3] rockchip: Fix binman error

Hi Simon,

Quoted 22 lines · Simon Glass

Hi Quentin,

Quoted 11 lines · Quentin Schulz

Hi Naoki,

Quoted 7 lines · FUKAUMI Naoki

After adding the below configs, binman produces an error.

CONFIG_SPL_DFU
CONFIG_SPL_ENV_SUPPORT
CONFIG_SPL_USB_DWC3_GENERIC
CONFIG_SPL_USB_GADGET

Quoted 7 lines
Quoted 5 lines

binman: Section '/binman/simple-bin-spi': Symbol '_binman_u_boot_any_prop_size'
in entry '/binman/simple-bin-spi/mkimage/u-boot-spl/u-boot-spl-nodtb': Entry 'u-boot-any' not found in list (u-boot-tpl-nodtb,u-boot-tpl-dtb,u-boot-tpl,u-boot-spl-nodtb,u-boot-spl-dtb,u-boot-spl,mkimage,fit,simple-bin-spi)

Add "no-write-symbols;" to u-boot-tpl and u-boot-spl.

I'll be frank with you, I have no clue what's happening :)

Quoted 8 lines

I means that simple-bin-spi has a binary inside it, u-boot-spl, which uses binman_sym_declare(ulong, u_boot_any, size). Most likely it is the one at the top of common/spl.c

This symbol is filled in (by binman, at build-time) with the size of the U-Boot binary. If there is no such U-Boot image then it cannot do this.

Why is it not failing right now? Why does it fail when you enable CONFIG_SPL_DFU, CONFIG_SPL_ENV_SUPPORT, CONFIG_SPL_USB_DWC3_GENERIC, CONFIG_SPL_USB_GADGET for Rock-Pi-4? This doesn't generate the u-boot.itb file we need for simple-bin-spi as we anyway take the fit blob generated by simple-bin instead.

It would make sense to always fail if this relies on u-boot.itb to be built for simple-bin-spi as well?

I suggested to use only blobs from simple-bin in simple-bin-spi but according to https://docs.u-boot.org/en/latest/develop/package/binman.html#image-dependencies this is undefined behavior. Maybe we should use a template (https://docs.u-boot.org/en/latest/develop/package/binman.html#templates) and rebuild everything for the SPI image as well. I saw such a patch in your VBE part H series I believe, maybe it makes sense to have this merged separately?

This feels somewhat wrong though, if I'm not mistaken every binary used in simple-bin and simple-bin-spi is the same, to the exception of how the idbloader.img is generated (-T rkspi/rksd), so it doesn't make a lot of sense to me to go through a complete rebuild of all binaries, instead of just running mkimage a second time with the same set of binaries. But if that's the only way to have something with defined behavior AND working, then so be it.

Cheers,
Quentin

#8 lore raw

Re: [PATCH 3/3] rockchip: Fix binman error

Hi Quentin,

Quoted 30 lines · Quentin Schulz

Hi Simon,

Quoted 26 lines · Simon Glass

Hi Quentin,

Quoted 11 lines · Quentin Schulz

Hi Naoki,

Quoted 7 lines · FUKAUMI Naoki

After adding the below configs, binman produces an error.

CONFIG_SPL_DFU
CONFIG_SPL_ENV_SUPPORT
CONFIG_SPL_USB_DWC3_GENERIC
CONFIG_SPL_USB_GADGET

Quoted 7 lines
Quoted 5 lines

binman: Section '/binman/simple-bin-spi': Symbol '_binman_u_boot_any_prop_size'
in entry '/binman/simple-bin-spi/mkimage/u-boot-spl/u-boot-spl-nodtb': Entry 'u-boot-any' not found in list (u-boot-tpl-nodtb,u-boot-tpl-dtb,u-boot-tpl,u-boot-spl-nodtb,u-boot-spl-dtb,u-boot-spl,mkimage,fit,simple-bin-spi)

Add "no-write-symbols;" to u-boot-tpl and u-boot-spl.

I'll be frank with you, I have no clue what's happening :)

I means that simple-bin-spi has a binary inside it, u-boot-spl, which uses binman_sym_declare(ulong, u_boot_any, size). Most likely it is the one at the top of common/spl.c

Quoted 8 lines
Quoted 4 lines

This symbol is filled in (by binman, at build-time) with the size of the U-Boot binary. If there is no such U-Boot image then it cannot do this.

Why is it not failing right now? Why does it fail when you enable CONFIG_SPL_DFU, CONFIG_SPL_ENV_SUPPORT, CONFIG_SPL_USB_DWC3_GENERIC, CONFIG_SPL_USB_GADGET for Rock-Pi-4?

I added these to the end of configs/rock-pi-4-rk3399_defconfig

CONFIG_SPL_DFU=y
CONFIG_SPL_ENV_SUPPORT=y
CONFIG_SPL_USB_DWC3_GENERIC=y
CONFIG_SPL_USB_GADGET=y
CONFIG_DM_USB=y

then build and don't see these errors. Can you please give a little more detail so I can repeat this?

Quoted 7 lines

This doesn't generate the
u-boot.itb file we need for simple-bin-spi as we anyway take the fit blob generated by simple-bin instead.

It would make sense to always fail if this relies on u-boot.itb to be built for simple-bin-spi as well?

Quoted 8 lines

I suggested to use only blobs from simple-bin in simple-bin-spi but according to
https://docs.u-boot.org/en/latest/develop/package/binman.html#image-dependencies
this is undefined behavior. Maybe we should use a template
(https://docs.u-boot.org/en/latest/develop/package/binman.html#templates)
and rebuild everything for the SPI image as well. I saw such a patch in your VBE part H series I believe, maybe it makes sense to have this merged separately?

Yes I am adding a template in that series, but I would rather get that submitted, since Binman does currently process images in series.

Quoted 8 lines

This feels somewhat wrong though, if I'm not mistaken every binary used in simple-bin and simple-bin-spi is the same, to the exception of how the idbloader.img is generated (-T rkspi/rksd), so it doesn't make a lot of sense to me to go through a complete rebuild of all binaries, instead of just running mkimage a second time with the same set of binaries. But if that's the only way to have something with defined behavior AND working, then so be it.

For now at least I think it is best to keep the images independent, with a template to reduce the duplication.

Regards.

Simon

#9 lore raw

Re: [PATCH 3/3] rockchip: Fix binman error

Hi,

Quoted 44 lines · Simon Glass

Hi Quentin,

Quoted 30 lines · Quentin Schulz

Hi Simon,

Quoted 26 lines · Simon Glass

Hi Quentin,

Quoted 11 lines · Quentin Schulz

Hi Naoki,

Quoted 7 lines · FUKAUMI Naoki

After adding the below configs, binman produces an error.

CONFIG_SPL_DFU
CONFIG_SPL_ENV_SUPPORT
CONFIG_SPL_USB_DWC3_GENERIC
CONFIG_SPL_USB_GADGET

Quoted 7 lines
Quoted 5 lines

binman: Section '/binman/simple-bin-spi': Symbol '_binman_u_boot_any_prop_size'
in entry '/binman/simple-bin-spi/mkimage/u-boot-spl/u-boot-spl-nodtb': Entry 'u-boot-any' not found in list (u-boot-tpl-nodtb,u-boot-tpl-dtb,u-boot-tpl,u-boot-spl-nodtb,u-boot-spl-dtb,u-boot-spl,mkimage,fit,simple-bin-spi)

Add "no-write-symbols;" to u-boot-tpl and u-boot-spl.

I'll be frank with you, I have no clue what's happening :)

I means that simple-bin-spi has a binary inside it, u-boot-spl, which uses binman_sym_declare(ulong, u_boot_any, size). Most likely it is the one at the top of common/spl.c

Quoted 8 lines
Quoted 4 lines

This symbol is filled in (by binman, at build-time) with the size of the U-Boot binary. If there is no such U-Boot image then it cannot do this.

Why is it not failing right now? Why does it fail when you enable CONFIG_SPL_DFU, CONFIG_SPL_ENV_SUPPORT, CONFIG_SPL_USB_DWC3_GENERIC, CONFIG_SPL_USB_GADGET for Rock-Pi-4?

I added these to the end of configs/rock-pi-4-rk3399_defconfig

Quoted 8 lines

CONFIG_SPL_DFU=y
CONFIG_SPL_ENV_SUPPORT=y
CONFIG_SPL_USB_DWC3_GENERIC=y
CONFIG_SPL_USB_GADGET=y
CONFIG_DM_USB=y

then build and don't see these errors. Can you please give a little more detail so I can repeat this?

This occurs when adding the above CONFIG to the following defconfig and building on today's master and next branch.

rock-4c-plus-rk3399_defconfig
rock-4se-rk3399_defconfig
rock-pi-4-rk3399_defconfig
rock-pi-4c-rk3399_defconfig

Best regards,

--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.

Quoted 35 lines
Quoted 7 lines

This doesn't generate the
u-boot.itb file we need for simple-bin-spi as we anyway take the fit blob generated by simple-bin instead.

It would make sense to always fail if this relies on u-boot.itb to be built for simple-bin-spi as well?

Quoted 8 lines

I suggested to use only blobs from simple-bin in simple-bin-spi but according to
https://docs.u-boot.org/en/latest/develop/package/binman.html#image-dependencies
this is undefined behavior. Maybe we should use a template
(https://docs.u-boot.org/en/latest/develop/package/binman.html#templates)
and rebuild everything for the SPI image as well. I saw such a patch in your VBE part H series I believe, maybe it makes sense to have this merged separately?

Yes I am adding a template in that series, but I would rather get that submitted, since Binman does currently process images in series.

Quoted 8 lines

This feels somewhat wrong though, if I'm not mistaken every binary used in simple-bin and simple-bin-spi is the same, to the exception of how the idbloader.img is generated (-T rkspi/rksd), so it doesn't make a lot of sense to me to go through a complete rebuild of all binaries, instead of just running mkimage a second time with the same set of binaries. But if that's the only way to have something with defined behavior AND working, then so be it.

For now at least I think it is best to keep the images independent, with a template to reduce the duplication.

Regards.

Simon

#10 lore raw

Re: [PATCH 3/3] rockchip: Fix binman error

In reply to Quentin Schulz

Hi Quentin,

Quoted 66 lines · Quentin Schulz

Hi Naoki,

Quoted 7 lines · FUKAUMI Naoki

After adding the below configs, binman produces an error.

  CONFIG_SPL_DFU
  CONFIG_SPL_ENV_SUPPORT
  CONFIG_SPL_USB_DWC3_GENERIC
  CONFIG_SPL_USB_GADGET

Quoted 5 lines

binman: Section '/binman/simple-bin-spi': Symbol '_binman_u_boot_any_prop_size'
    in entry '/binman/simple-bin-spi/mkimage/u-boot-spl/u-boot-spl- nodtb': Entry 'u-boot-any' not found in list (u-boot-tpl-nodtb,u-boot- tpl-dtb,u-boot-tpl,u-boot-spl-nodtb,u-boot-spl-dtb,u-boot- spl,mkimage,fit,simple-bin-spi)

Add "no-write-symbols;" to u-boot-tpl and u-boot-spl.

I'll be frank with you, I have no clue what's happening :)

But, it seems this only applies to the SPI image (disable ROCKCHIP_SPI_IMAGE and it'll built just fine). Why? No clue.

I've never liked how the simple-bin-spi was built because we should be reusing artifacts from simple-bin instead of rebuilding stuff. That's why you have /binman/simple-bin-spi/mkimage/fit being a blob, because we want to reuse the fitImage from /binman/simple-bin/mkimage/fit but we didn't do this for the other ones.

Can you try to revert your patch here and use this instead:

"""

arch/arm/dts/rk3399-u-boot.dtsi +6 -0
index 70f35b6c197..0a5771b706f 100644
@@ -45,9 +45,15 @@
              };
  #elif defined(CONFIG_TPL)
              u-boot-tpl {
+                /* sync with /binman/simple-bin/mkimage/u-boot-tpl */
+                type = "blob";
+                filename = "tpl/u-boot-tpl.bin";
              };
  #endif
              u-boot-spl {
+                /* sync with /binman/simple-bin/mkimage/u-boot-spl */
+                type = "blob";
+                filename = "spl/u-boot-spl.bin";
              };
          };
          fit {
arch/arm/dts/rockchip-u-boot.dtsi +6 -0
index c8c928c7e50..fea49eb3145 100644
@@ -187,9 +187,15 @@
              };
  #elif defined(CONFIG_TPL)
              u-boot-tpl {
+                /* sync with /binman/simple-bin/mkimage/u-boot-tpl */
+                type = "blob";
+                filename = "tpl/u-boot-tpl.bin";
              };
  #endif
              u-boot-spl {
+                /* sync with /binman/simple-bin/mkimage/u-boot-spl */
+                type = "blob";
+                filename = "spl/u-boot-spl.bin";
              };
          };

"""

Quoted 3 lines

This seems to work for me on RK3399 Puma and Rock-Pi-4 builds with the symbols you listed enabled. I also believe this should be "better" than what we have today.

If that works, I'll send a proper patch for this :)

Proper patch please :)

Best regards,

--
FUKAUMI Naoki
Radxa Computer (Shenzhen) Co., Ltd.

Quoted 3 lines

Cheers,
Quentin

#11 lore raw
In reply to FUKAUMI Naoki

Hi Naoki,

Quoted 25 lines · FUKAUMI Naoki

Rockchip RK3399 targets build TPL. If CONFIG_SPL_USB_DWC3_GENERIC and CONFIG_SPL_USB_GADGET are enabled, linking u-boot-tpl will fail.

LD tpl/u-boot-tpl
ld.bfd: drivers/usb/dwc3/dwc3-generic.o: in function `dwc3_glue_bind_common':
/home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:527:(.text.dwc3_glue_bind_common+0x20): undefined reference to usb_get_dr_mode' /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:527:(.text.dwc3_glue_bind_common+0x20): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_get_dr_mode' ld.bfd: /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:529:(.text.dwc3_glue_bind_common+0x2c): undefined reference to usb_get_dr_mode' /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:529:(.text.dwc3_glue_bind_common+0x2c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_get_dr_mode' ld.bfd: drivers/usb/dwc3/dwc3-generic.o: in function `dwc3_glue_probe':
/home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:683:(.text.dwc3_glue_probe+0xb0): undefined reference to usb_get_dr_mode' /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:683:(.text.dwc3_glue_probe+0xb0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_get_dr_mode'

Do not compile drivers/usb/ for TPL.

---
  scripts/Makefile.xpl | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.xpl +0 -0
index abc49fbe6c9..e4ca4d395ac 100644

scripts/Makefile.xpl endif · line 129

Quoted 7 lines
scripts/Makefile.xpl +2 -2
@@ -125,8 +125,8 @@ endif
 
  libs-y += drivers/
  libs-$(CONFIG_SPL_MEMORY) += drivers/memory/
-libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/dwc3/
-libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/cdns3/
+libs-$(CONFIG_$(PHASE_)USB_GADGET) += drivers/usb/dwc3/
+libs-$(CONFIG_$(PHASE_)USB_GADGET) += drivers/usb/cdns3/

I don't know what this is actually used for? Like why is it different from the typical Makefile we have for other subsystems and drivers?

Can't we simply remove those and add them in drivers/Makefile, like:

obj-$(CONFIG_$(PHASE_)USB_GADGET) += usb/dwc3/
obj-$(CONFIG_$(PHASE_)USB_GADGET) += usb/cdns3/

For example?

Otherwise makes sense to me.

Cheers,
Quentin

#12 lore raw
Quoted 38 lines · Quentin Schulz

Hi Naoki,

Quoted 25 lines · FUKAUMI Naoki

Rockchip RK3399 targets build TPL. If CONFIG_SPL_USB_DWC3_GENERIC and CONFIG_SPL_USB_GADGET are enabled, linking u-boot-tpl will fail.

LD tpl/u-boot-tpl
ld.bfd: drivers/usb/dwc3/dwc3-generic.o: in function `dwc3_glue_bind_common':
/home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:527:(.text.dwc3_glue_bind_common+0x20): undefined reference to usb_get_dr_mode' /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:527:(.text.dwc3_glue_bind_common+0x20): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_get_dr_mode' ld.bfd: /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:529:(.text.dwc3_glue_bind_common+0x2c): undefined reference to usb_get_dr_mode' /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:529:(.text.dwc3_glue_bind_common+0x2c): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_get_dr_mode' ld.bfd: drivers/usb/dwc3/dwc3-generic.o: in function `dwc3_glue_probe':
/home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:683:(.text.dwc3_glue_probe+0xb0): undefined reference to usb_get_dr_mode' /home/radxa/u-boot/drivers/usb/dwc3/dwc3-generic.c:683:(.text.dwc3_glue_probe+0xb0): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol usb_get_dr_mode'

Do not compile drivers/usb/ for TPL.

---
  scripts/Makefile.xpl | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
scripts/Makefile.xpl +0 -0
index abc49fbe6c9..e4ca4d395ac 100644

scripts/Makefile.xpl endif · line 128

Quoted 6 lines
scripts/Makefile.xpl +2 -2
@@ -125,8 +125,8 @@ endif
  libs-y += drivers/
  libs-$(CONFIG_SPL_MEMORY) += drivers/memory/
-libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/dwc3/
-libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/cdns3/
+libs-$(CONFIG_$(PHASE_)USB_GADGET) += drivers/usb/dwc3/
+libs-$(CONFIG_$(PHASE_)USB_GADGET) += drivers/usb/cdns3/

I don't know what this is actually used for? Like why is it different from the typical Makefile we have for other subsystems and drivers?

Quoted 6 lines

Can't we simply remove those and add them in drivers/Makefile, like:

obj-$(CONFIG_$(PHASE_)USB_GADGET) += usb/dwc3/
obj-$(CONFIG_$(PHASE_)USB_GADGET) += usb/cdns3/

For example?

The likely answer is that we used to not have consistent CONFIG naming here between SPL support and non-SPL support, and while that's since been corrected, this part was never updated to take advantage of that.

Signature · 1 line
Tom