Page 1 of 1

How can I manually build u-boot and linux for NanoPi R2S?

Posted: Sat Dec 19, 2020 1:11 pm
by crocket
I read
  • http://opensource.rock-chips.com/wiki_Boot_option
  • http://opensource.rock-chips.com/wiki_Rockchip_Kernel
  • https://github.com/friendlyarm/sd-fuse_rk3328
I understood some things, but I still can't put things together. Are there instructions on building u-boot and linux for NanoPi R2S or any other rockchip SBC?

Re: How can I manually build u-boot and linux for NanoPi R2S?

Posted: Sun Dec 20, 2020 10:06 pm
by Kyra
Yup, for u-boot check out doc/README.rockchip. The instructions are a bit sparse for the RK3328, but pretend it's an RK3399 and you're most of the way there. You'll want "option 3" (i.e. with TPL).

Re: How can I manually build u-boot and linux for NanoPi R2S?

Posted: Tue Dec 22, 2020 10:40 am
by crocket
Kyra wrote:
Yup, for u-boot check out doc/README.rockchip. The instructions are a bit sparse for the RK3328, but pretend it's an RK3399 and you're most of the way there. You'll want "option 3" (i.e. with TPL).


So, as long as I use downstream u-boot, I can rely on https://github.com/u-boot/u-boot/blob/m ... E.rockchip

What about downstream linux? When will NanoPi R2S and NanoPi R4S support mainline u-boot and mainline linux?

Re: How can I manually build u-boot and linux for NanoPi R2S?

Posted: Tue Dec 22, 2020 2:00 pm
by Kyra
Technically they both do already, it's just a matter of a suitable devtree.

Re: How can I manually build u-boot and linux for NanoPi R2S?

Posted: Wed Dec 23, 2020 8:28 am
by crocket
Kyra wrote:
Technically they both do already, it's just a matter of a suitable devtree.


Are you saying that linus torvalds is being an asshole about accepting SBC support?

Re: How can I manually build u-boot and linux for NanoPi R2S?

Posted: Sun Dec 27, 2020 11:42 am
by crocket
Kyra wrote:
Yup, for u-boot check out doc/README.rockchip. The instructions are a bit sparse for the RK3328, but pretend it's an RK3399 and you're most of the way there. You'll want "option 3" (i.e. with TPL).


According to https://github.com/friendlyarm/sd-fuse_rk3328, friendlyarm's rk3328 SBCs seem to rely on miniloader.

Re: How can I manually build u-boot and linux for NanoPi R2S?

Posted: Wed Dec 30, 2020 11:14 am
by crocket
I set up `cross-aarch64-unknown-linux-gnu/gcc-6.5.0` on gentoo linux with

Code: Select all

sudo crossdev --stable --gcc 6.5.0 --target aarch64-unknown-linux-gnu

According to https://github.com/friendlyarm/sd-fuse_ ... -kernel.sh, I needed the following commands against nanopi-r2-v5.4.y branch of https://github.com/friendlyarm/kernel-rockchip

Code: Select all

make CROSS_COMPILE=aarch64-unknown-linux-gnu- ARCH=arm64 nanopi-r2_linux_defconfig
make CROSS_COMPILE=aarch64-unknown-linux-gnu- ARCH=arm64 -j8

After executing the commands, I got vmlinux and arch/arm64/boot/dts/rockchip/rk3328-nanopi-r2-rev[0-9][0-9].dtb.

https://github.com/crust-firmware/meta/issues/2 taught me to work around u-boot compilation issue with the following commands. u-boot doesn't compile without these commands because it conflicts with dtc.

Code: Select all

find . -name 'libfdt*.h' -exec sed -i 's/ _LIBFDT_/ LIBFDT_/g' {} +
find . -name 'fdt.h' -exec sed -i 's/ _FDT_H/ FDT_H/g' {} +

https://github.com/friendlyarm/sd-fuse_ ... d-uboot.sh taught me to execute the following commands against nanopi-r2-v2014.10 branch of https://github.com/friendlyarm/uboot-rockchip

Code: Select all

make CROSS_COMPILE=aarch64-unknown-linux-gnu- nanopi_r2_defconfig
make CROSS_COMPILE=aarch64-unknown-linux-gnu- -j8

After compiling u-boot, I am seeing the following output files.

  • uboot.img
  • trust.img
  • rk3328_loader_v1.16.250.bin

According to http://opensource.rock-chips.com/wiki_Boot_option, uboot.img and trust.img are for boot flow 1 which involves rockchip miniloader instead of u-boot TPL and u-boot SPL. rk3328_loader_v1.16.250.bin seems to be for firmware update via USB. I don't want to think about firmware update via USB until I get NanoPi R2S to work.

From the output of `make CROSS_COMPILE=aarch64-unknown-linux-gnu- -j8`, I discovered that `rk3328_loader_v1.16.250.bin` was made by `./tools/boot_merger ./tools/rk_tools/RKBOOT/RK3328MINIALL.ini`

`./tools/rk_tools/RKBOOT/RK3328MINIALL.ini` made me realize I needed to execute the following commands to obtain idbloader.img.

Code: Select all

./tools/mkimage -n rk3328 -T rksd -d ./tools/rk_tools/bin/rk33/rk3328_ddr_333MHz_v1.16.bin idbloader.img
cat ./tools/rk_tools/bin/rk33/rk322xh_miniloader_v2.50.bin >> idbloader.img

However, `./tools/mkimage -T rksd ...` fails because rksd is not a supported image type. Thus, I had to build upstream u-boot with the following commands.

Code: Select all

make CROSS_COMPILE=aarch64-unknown-linux-gnu- defconfig
make CROSS_COMPILE=aarch64-unknown-linux-gnu- -j8

Then, I executed

Code: Select all

/path/to/upstream_u-boot/tools/mkimage -n rk3328 -T rksd -d ./tools/rk_tools/bin/rk33/rk3328_ddr_333MHz_v1.16.bin idbloader.img
cat ./tools/rk_tools/bin/rk33/rk322xh_miniloader_v2.50.bin >> idbloader.img

At this point, I finished building u-boot and linux kernel. But, I haven't yet tested them.

Re: How can I manually build u-boot and linux for NanoPi R2S?

Posted: Wed Dec 30, 2020 12:40 pm
by crocket
How do friendlyelec developers actually build u-boot and linux kernel for NanoPi R2S?

Re: How can I manually build u-boot and linux for NanoPi R2S?

Posted: Fri Jan 01, 2021 6:44 am
by crocket
I'm trying to figure out how to write extlinux.conf for NanoPi R2S. Can anyone show me the content of extlinux.conf on NanoPi R2S?

Re: How can I manually build u-boot and linux for NanoPi R2S?

Posted: Sat Jan 02, 2021 7:13 am
by crocket
I wrote idbloader.img, uboot.img, and trust.img onto a microSD card.
I formatted /boot as an ext4 file system and put extlinux/extlinux.conf on it.
Armtix linux installed /boot/Image, /boot/initramfs-linux.img, /boot/dtbs/rockchip/rk3328-nanopi-r2s.dtb.

I tried to boot NanoPi R2s with the microSD card.

The serial console printed

Code: Select all

DDR version 1.16 20190528
ID:0x805 N
In
DDR4
333MHz
Bus Width=32 Col=10 Bank=4 Bank Group=2 Row=15 CS=1 Die Bus-Width=16 Size=1024MB
ddrconfig:14
OUT
Boot1 Release Time: May 13 2019 17:34:36, version: 2.50
ChipType = 0x11, 248
mmc2:cmd1,20
emmc reinit
mmc2:cmd1,20
emmc reinit
mmc2:cmd1,20
SdmmcInit=2 1
mmc0:cmd5,20
SdmmcInit=0 0
BootCapSize=0
UserCapSize=60906MB
FwPartOffset=2000 , 0
StorageInit ok = 31103
Raw SecureMode = 0
SecureInit read PBA: 0x4
SecureInit read PBA: 0x404
SecureInit read PBA: 0x804
SecureInit read PBA: 0xc04
SecureInit read PBA: 0x1004
SecureInit ret = 0, SecureMode = 0
atags_set_bootdev: ret:(0)
GPT part:  0, name:   Linux reserved, start:0x40, size:0x3fc0
GPT part:  1, name:   Linux reserved, start:0x4000, size:0x2000
, name:   Linux reserved, start:0x6000, size:0x2000
GPT part:  e: Linux filesystem, start:0x40000, size:0x76b4fdf
no find partition:uboot.
LoadTrust Addr:0x4000
No find bl30.bin
Load uboot, ReadLba = 2000
hdr 000000000337a3b0 + 0x0:0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

Load OK, addr=0x200000, size=0xa47c4
RunBL31 0x40000
NOTICE:  BL31: v1.3(release):734d842
NOTICE:  BL31: Built : 15:29:53, Dec 26 2019
NOTICE:  BL31:Rockchip release version: v1.3M GICv2 driver initialized
INFO:    Using opteed sec cpu_contexlat_rockchip_pmu_init: pd status 0xe
INFO:    BL31: InitializinINF [0x0] TEE-CORE:init_primary_helper:337: Initializing (1.1.0-235-g3b0152ca #231 Fri Mar 13 02:01:39 UTC 2020 aarch64)

INF 0] TEE-CORE:init_primary_helper:338: Release version: 1.4

INF [0x0] TEE-CORE:init_teecore:83: teecore inits done
INFO:    BL31: Preparing for EL3 exit to normal world
INFO:    Entry podress = 0x200000
INFO:    SPSR = 0x3c9


U-Boot 2014.10-RK3328-06-gc5b5cef-dirty (Dec 30 2020 - 21:15:05)

CPU: rk3328
cpU's clock information:
    arm pll = 600000000HZ
    general p00HZ
    new pll = 594000000HZ
k:0000000000200000(000000003fe00000)
Reserve memory for trust oGIC CPU mask = 0x00000001
SdmmcInit = 0 0
SDCard Update.
storage init OK!
Using default environment

Writing env to storage...
done
GetParam
W: Invalid Parameter's tag (0x00000000)!
Invalid parameter
No pmic detect.
CPU's clock information:
    arm pll = 1200000000 1200000000HZ
    ddr pll = 664000000HZ
    codec pll = 120000SecureBootEn = 0, SecureBootLock = 0

#Boot ver: 0000-00-00#0. found
no fuel gauge found
read logo on state from dts [0]
no address
Unable to boot:recovery
try to start backup
'backup'to start rockusb


Why does it fail?