flatmax/buildroot.rockchip

failed to build rock5b

edwardzhou opened this issue · 30 comments

following the instruction in READE for build rock5b, got below error

  CC      examples/standalone/hello_world.o
  LD      examples/standalone/hello_world
  OBJCOPY examples/standalone/hello_world.srec
  OBJCOPY examples/standalone/hello_world.bin
  LDS     u-boot.lds
  LD      u-boot
/root/buildroot/output/host/bin/aarch64-buildroot-linux-uclibc-ld.bfd: arch/arm/mach-rockchip/built-in.o: in function `fdt_fixup_modules':
/root/buildroot/output/build/uboot-stable-5.10-rock5/arch/arm/mach-rockchip/rk3588/rk3588.c:1164: undefined reference to `_u_boot_list_2_driver_2_rockchip_otp'
/root/buildroot/output/host/bin/aarch64-buildroot-linux-uclibc-ld.bfd: arch/arm/mach-rockchip/built-in.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_u_boot_list_2_driver_2_rockchip_otp' which may bind externally can not be used when making a shared object; recompile with -fPIC
/root/buildroot/output/build/uboot-stable-5.10-rock5/arch/arm/mach-rockchip/rk3588/rk3588.c:1164:(.text.rk_board_dm_fdt_fixup+0xc): dangerous relocation: unsupported relocation
/root/buildroot/output/host/bin/aarch64-buildroot-linux-uclibc-ld.bfd: /root/buildroot/output/build/uboot-stable-5.10-rock5/arch/arm/mach-rockchip/rk3588/rk3588.c:1164: undefined reference to `_u_boot_list_2_driver_2_rockchip_otp'
make[2]: *** [Makefile:1284: u-boot] Error 1
make[1]: *** [Makefile:461: __build_one_by_one] Error 2
make[1]: Leaving directory '/root/buildroot/output/build/uboot-stable-5.10-rock5'
make: *** [boot/uboot/uboot.mk:533: /root/buildroot/output/build/uboot-stable-5.10-rock5/.stamp_dotconfig] Error 2

Got the same thing

Has this been looked into yet? I am seeing the exact same error as OP when building for the Rock 5b (RK3588).

I just did a test build and there were no failures. I got a full image compiled.

Can you confirm that you have all of the requirements installed ? Even python2 ?

Thank you for following up.

I had not installed python2 as the readme indicated it was needed if building for the cm3 and rock3 derivatives. That said, I did install it, ran make clean and then re-ran make and hit the same error:

  CC      examples/standalone/hello_world.o
  LD      examples/standalone/libstubs.o
  LD      examples/standalone/hello_world
  OBJCOPY examples/standalone/hello_world.srec
  OBJCOPY examples/standalone/hello_world.bin
  LD      u-boot
/home/paul/buildroot/output/host/bin/aarch64-buildroot-linux-uclibc-ld.bfd: arch/arm/mach-rockchip/built-in.o: in function `fdt_fixup_modules':
/home/paul/buildroot/output/build/uboot-stable-5.10-rock5/arch/arm/mach-rockchip/rk3588/rk3588.c:1164: undefined reference to `_u_boot_list_2_driver_2_rockchip_otp'
/home/paul/buildroot/output/host/bin/aarch64-buildroot-linux-uclibc-ld.bfd: arch/arm/mach-rockchip/built-in.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_u_boot_list_2_driver_2_rockchip_otp' which may bind externally can not be used when making a shared object; recompile with -fPIC
/home/paul/buildroot/output/build/uboot-stable-5.10-rock5/arch/arm/mach-rockchip/rk3588/rk3588.c:1164:(.text.rk_board_dm_fdt_fixup+0xc): dangerous relocation: unsupported relocation
/home/paul/buildroot/output/host/bin/aarch64-buildroot-linux-uclibc-ld.bfd: /home/paul/buildroot/output/build/uboot-stable-5.10-rock5/arch/arm/mach-rockchip/rk3588/rk3588.c:1164: undefined reference to `_u_boot_list_2_driver_2_rockchip_otp'
make[3]: *** [Makefile:1284: u-boot] Error 1
make[2]: *** [Makefile:461: __build_one_by_one] Error 2
make[1]: *** [boot/uboot/uboot.mk:533: /home/paul/buildroot/output/build/uboot-stable-5.10-rock5/.stamp_dotconfig] Error 2
make: *** [Makefile:84: _all] Error 2

What system are you building on ? OS ?

I was originally using Ubuntu Desktop 20.04 LTS running under VMWare (under Windows 11). It had been some time since I had built that VM, so I made a fresh VM with Ubuntu Desktop 23.04. Unfortunately, I encountered the same error.

For the sake of completeness, with the fresh version of 23.04 installed, I performed the following from the /home/paul directory:

  1. Cloned buildroot: git clone git://git.busybox.net/buildroot buildroot
  2. Installed prerequisites: sudo apt-get install -y build-essential gcc g++ autoconf automake libtool bison flex gettext
    sudo apt-get install -y patch texinfo wget git gawk curl lzma bc quilt
  3. Tried to install Python 2. This failed (E: Package 'python2' has no installation candidate): sudo apt install python2
  4. Cloned the external buildroot tree: git clone https://github.com/flatmax/buildroot.rockchip.git buildroot.rockchip.ext
  5. Ran the shell script for the Raxda Rock 5b board: source buildroot.rockchip.ext/setup.rock5b.sh /home/paul/buildroot
  6. Made a buildroot dowloads directory: mkdir ../buildroot.dl
  7. ran make

I ran the build without having python 2 since installing it on my 20.04 VM did not make a difference.

I did note the following prompts were not automatically answered by the build, but I do not believe my responses resulted in the build error(s) I am seeing:

Support Rockchip RK3528 (ROCKCHIP_RK3528) [N/y/?] (NEW)
Support Rockchip RK3562 (ROCKCHIP_RK3562) [N/y/?] (NEW)
Rockchip hotkey (ROCKCHIP_HOTKEY) [Y/n/?] (NEW)
Print log to linux pstore buffer (PSTORE) [N/y/?] (NEW)
Support BL33 runs as AArch32 mode (SPL_ATF_AARCH32_BL33) [N/y/?] (NEW)
Enable GPIO hog support (GPIO_HOG) [N/y/?] (NEW)
SKYHIGH SPI flash support (SPI_NAND_SKYHIGH) [Y/n/?] (NEW)
BOYA SPI flash support (SPI_FLASH_BOYA) [N/y/?] (NEW)
NORMEM SPI flash support (SPI_FLASH_NORMEM) [N/y/?] (NEW)
Maxim deserializer panel driver (DRM_PANEL_MAXIM_DESERIALIZER) [N/y/?] (NEW)
Rockchip TVE Support (DRM_ROCKCHIP_TVE) [N/y/?] (NEW)

Thanks again for the help; I must be doing something wrong.

ok - a few issues here...

You need to checkout a particular version of buildroot. According to the readme :

git checkout 2022.05

Second of all I am pretty sure that the version of uboot sourced still required python2. Here are a few solution ideas for that problem :
1] Downgrade ubuntu to one which provides python2 as an installation candidate
2] Workout how to install the simplest implementation of python2 on your current ubuntu system.
3] Check if they have updated uboot yet to use python3 : https://github.com/radxa/u-boot/tree/stable-5.10-rock5 . If they have then bump the version of uboot to download in the board's config file.

Once again, thank you for the follow up.

I actually had done the git checkout 2022.05, but did neglect to put it into my notes. Thank you for catching that.

I went all the way back to Ubuntu 18.04 and had not issues getting python installed. It did require sudo apt install python-minimal, but performing python2 -v shows 2,7.17 installed.

I did check the repo you reference and it does indeed still require python2, but there is a check in the make file to see if python2 is installed and an error is thrown if it is not found. I do not see that error, so I think there is a different issue.

The following is what I did under Ubuntu 18.04 and still I see the same error.

  1. Cloned buildroot: git clone git://git.busybox.net/buildroot buildroot
  2. Checkout for Rock 5b tested with version: git checkout 2022.05
  3. Installed prerequisites: sudo apt-get install -y build-essential gcc g++ autoconf automake libtool bison flex gettext
  4. sudo apt-get install -y patch texinfo wget git gawk curl lzma bc quilt
  5. Install python2: sudo apt install python-minimal
  6. Cloned the external buildroot tree: git clone https://github.com/flatmax/buildroot.rockchip.git buildroot.rockchip.ext
  7. Ran the shell script for the Raxda Rock 5b board: source buildroot.rockchip.ext/setup.rock5b.sh /home/paul/buildroot
  8. Made a buildroot dowloads directory: mkdir ../buildroot.dl
  9. ran make

May I please ask what environment you used to run a test build?

I've built this on various machines, ubuntu 22.04 and 22.10 for example.

After more failed attempts, I suspect this issue is going to come down to missing prerequisites that you happen to have in the environment used to re-test the build. My environment(s) all were vanilla Ubuntu (various versions) running under VMWare.

Even going back to Ubuntu 18.04, which comes with Python2 failed. All versions fail in the same way - even when Python2, which is still required, is installed. Moreover, two other users edwardzhou and c3charvat experienced the same failure.

I am able to build the configuration for the Rock 3A but the Rock 5b fails under all circumstances.

It is possible that pre-reqs are missing yes. When/if you find them, please let me know.

I got it working for the Rock 5b. Here are my steps:

  1. I use the buildroot branch "2022.05.x", which corresponds to the tag 2022.05.3 (commit 4dc1fffca0)

However this caused uboot to break during build due to some code references which could not be resolved. I had a look and was confident, that the code which caused the error is not needed for the RK3588 (but for some other SoC), so I created the following patch.

  1. Copy the following contents into a file "buildroot.rockchip.ext/patches.rk3588/uboot/004-rockchip-otp.patch":
Index: uboot-stable-5.10-rock5/arch/arm/mach-rockchip/rk3588/rk3588.c
===================================================================
--- uboot-stable-5.10-rock5.orig/arch/arm/mach-rockchip/rk3588/rk3588.c
+++ uboot-stable-5.10-rock5/arch/arm/mach-rockchip/rk3588/rk3588.c
@@ -1161,8 +1161,10 @@
 	u8 cpu_mask;
 	int ret;
 
-	ret = uclass_get_device_by_driver(UCLASS_MISC,
-					  DM_GET_DRIVER(rockchip_otp), &dev);
+	/* ret = uclass_get_device_by_driver(UCLASS_MISC, */
+					  /* DM_GET_DRIVER(rockchip_otp), &dev); */
+	return 0;
+
 	if (ret) {
 		printf("can't get otp device, ret=%d\n", ret);
 		return ret;

Afterwards it did build and I could boot it.

@flatmax would you like that we change the recommended version in the readme to "2022.05.x"or tag "2022.05.3" and add the patch to your repo? If so (I have actually never done this before) how should I do it? May I create a pull request?

@edwardzhou the actual reason why I tried buildroot version "2022.05.x" aka. tag "2022.05.3", is, that I also got some error during compilation before. I however don't recall it. But it might have been the same as you. After changing I then ran into the uboot issue, hence I created the abovementioned patch.

@prubin100 I just realize, that my patch (at first glance) corresponds to the error you report. Maybe just try integrating my patch - it might work.