Full Version: BUilding everything from scratch (buildroot)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

I bought rock64 and now I am trying to prepare very minimal script that will build all steps from scratch. Intend is to publish it to buildroot repository later. But I have problem booting kernel. Some information what have I already done and where I am stuck.

1. tpl, spl and uboot are build from ayufan repository, branch "2017.09-rockchip-ayufan-1035-gd646df03ac", and "rock64-rk3328_defconfig", no changes have been made to the files. To create tpl/spl image I use these commands (this is flashed to 0x40). Note, no rockchip binary blobs anywhere!

$MKIMAGE -n rk3328 -T rksd -d $BINARIES_DIR/u-boot-tpl.bin $BINARIES_DIR/u-boot-tpl.img
cat $BINARIES_DIR/u-boot-tpl.img $BINARIES_DIR/u-boot-spl.bin > $BINARIES_DIR/u-boot-tpl-spl.img

2. then ATF is built, also from ayufan repository and "rk3328" as a platform. Generated BL31 is used to generate u-boot.itb (with make u-boot.itb from ayufan repo). That u-boot.itb is flashed to 0x200 on sdcard.

3. Kernel, no surprise here, it's from ayufan repo, "rockchip_linux_defconfig" used and "rockchip/rk3328-rock64" dts from in-tree, again no changes have been made.

4. Now sdcard image is generated with this config:

image sdcard.img {
   hdimage {

   partition uboot-spl {
       in-partition-table = "no"
       image = "u-boot-tpl-spl.img"
       offset = 32768 # 512 * 0x40 from start of sd card

   partition uboot {
       in-partition-table = "no"
       image = "u-boot.itb"
       offset = 262144 # 512 * 0x200 from start of sd card

   partition rootfs {
       partition-type = 0x83
       image = "rootfs.ext4"
       size = 500M

It's in mbr dos format (so no gpt). On rootfs there is extlinux, Image and dtb in /boot directory.

5. Toolchain is gcc 7.x and binutils 2.29.x.

Now logs,

<debug_uart> U-Boot TPL board init
configuring DDR parameters
DRAM frequency: 800MHz
configuring DDR parameters
Trying to boot from BOOTROM
Returning to boot ROM...

U-Boot SPL 2017.09 (Nov 11 2018 - 00:07:11)
setup_ddr_param  1
booted from SD
Trying to boot from MMC2

U-Boot 2017.09 (Nov 11 2018 - 00:07:11 +0100)

Model: Pine64 Rock64
DRAM:  4 GiB
MMC:   [email protected]: 0, [email protected]: 1
SF: Detected gd25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

In:    [email protected]
Out:   [email protected]
Err:   [email protected]
Model: Pine64 Rock64
Net:   eth0: [email protected]
Hit any key to stop autoboot:  0
Card did not respond to voltage select!
mmc_init: -95, time 10
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found /boot/extlinux/extlinux.conf
Retrieving file: /boot/extlinux/extlinux.conf
205 bytes read in 36 ms (4.9 KiB/s)
1:      rock64 linux-next
Retrieving file: /boot/Image
20054024 bytes read in 17452 ms (1.1 MiB/s)
append: earlyprintk earlycon=uart8250,mmio32,0xff130000 console=ttyS2,1500000n8 console=tty0 root=/dev/mmcblk0p1 rootwait
Retrieving file: /boot/rk3328-rock64.dtb
70953 bytes read in 29 ms (2.3 MiB/s)
## Flattened Device Tree blob at 01f00000
  Booting using the fdt blob at 0x1f00000
  Loading Device Tree to 00000000fceed000, end 00000000fcf01528 ... OK

Starting kernel ...

And that's it. No more output and I am completaly out of ideas how to proceed.

u-boot properly boots, it finds my kernel and dtb, it loads it but it fails to boot it. Kernel and dtb are good, I downloaded slackware image for rock64 and replaced Image and dtb, and it started - I could see todays date and my build host in kernel message, so it's enough of a proof linux and dtb are generated properly.

Anybody got any idea what am I missing? I was thinking that it might be mbr instead of gpt or missing initrd, but slackware image doesn't use them as well. I would appreciate any advice or ideas how to proceed with that.
I found what was wrong. Buildroot by default used build/rk3328/release/bl31.bin file, and uboot needs
build/rk3328/release/bl31/bl31.elf. Somehow bl31.bin was enough for the u-boot to start, but not for kernel. Also it works with mainline kernel and mainline ATF.

If someone is interested I've published my patch for rock64 board to work with buildroot. Default config uses mainline stuff whenever possible, the only forked thing is uboot from ayufan, both kernel and atf are taken from mainline. Patch can be downloaded from here:

Note, you also need this patch as dependency:

If you use buildroot, or would like to use rock64 with buildroot, and you have some spare time, please test and review those patches, so they can be accepted into buildroot. Thanks.
   I am interested in testing your patch but I don't know how (I am really a newbie in image building). In fact I am interested because I would like to try to flash an image on a sd or mmc card after having booted a minimal kernel through ethernet (I was unable to boot the regular images - Debian, ubuntu, Armbian - directly from ethernet : the boot starts but I could not obtain a console). Where can I find the procedure ?

Thanks a lot for your share!

I am also interested for testing the method, but not sure how to compile u-boot and kernel based on ayufan repository, Can you share your build method for it?
I have compiled buildroot success using the buildroot.2019.02 download from buildroot web site and compile using rock64_defconfig, then write output/image files( loader1 = u-boot-tpl-spl.img, loader2 = u-boot.itb ) to SD card,

console error log:

<debug_uart> U-Boot TPL board init
data training error
col error
DRAM frequency: 800MHz
data training error

Can you help me explain this info? How to fix it?
Hi ,

sorry for not replying, kinda forgot about that topic, and notification didn't reach me, hmm.

Did you fix this problem? If not, do you flash generated sdcard.img or do you flash it manually? There should be sdcard.img which has all ofset in place, so it's as easy as

dd if=sdcard.img of=/dev/mmcblkp0

I'll try to compile with buildroot 2019.2 and check this out.

Patch has been merged into buildroot, but if you still want to test this, steps are really easy. Clone newest buildroot, then

make rock64_defconfig
cd output/images
sudo dd if=sdcard.img of=/dev/mmcblk0

Just make sure /dev/mmcblk0 (or /dev/sdb if you are using usb2mmc coverter) is really your sd card, or you can mess up your disk!

I've built rock64_defconfig with 2019.02 and I have no problem booting image. Make sure you use sdcard.img file and not "u-boot-tpl-spl.img" and familly.

If using sdcard.img doesn't work then I have no clue what might be wrong. You might want to look into "drivers/ram/rockchip/sdram_rk3328.c" file. In line 372 there is data_training(), you can try adding there some printf()s to know what is going on. Maybe there is something wrong with DDRAM? Check if increasing time to ram to train from 50usec to 200usec fixes the issue.