BUilding everything from scratch (buildroot)
#1
Hi,

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!

Code:
$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:

Code:
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,


Code:
<debug_uart> U-Boot TPL board init
configuring DDR parameters
LPDDR3
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:   rksdmmc@ff520000: 0, rksdmmc@ff500000: 1
SF: Detected gd25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

In:    serial@ff130000
Out:   serial@ff130000
Err:   serial@ff130000
Model: Pine64 Rock64
misc_init_r
cpuid=00000000000000000000000000000000
serial=0
Net:   eth0: ethernet@ff540000
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.
#2
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.
#3
Hi,

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:

http://patchwork.ozlabs.org/patch/1035643/

Note, you also need this patch as dependency:

http://patchwork.ozlabs.org/patch/996196/

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.
#4
Hello,
   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 ?

LMM.
#5
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?
#6
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
LPDDR3
DRAM frequency: 800MHz
data training error

Can you help me explain this info? How to fix it?
#7
Hi @hisstone,

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.


@LMM

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


Code:
make rock64_defconfig
make
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!
#8
Hi @hisstone

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.
#9
hi, @lm-  sorry for reply the testing result delay.

I have make image success with the buildroot-2019.02 version, and using sdcard.img with sd card. but the system booting with this error below:  note my rock64 hardware with  1G DDR  and the hw version is 2.0.

the system reset again and again with below messages:

Code:
U-Boot 2017.09 (Jul 11 2019 - 16:27:30 +0800)

Model: Pine64 Rock64
DRAM:  2.2 GiB
MMC:   rksdmmc@ff520000: 0, rksdmmc@ff500000: 1
SF: Detected gd25q128 with page size 256 Bytes, erase size 4 KiB, total 16 MiB
*** Warning - bad CRC, using default environment

In:    serial@ff130000
Out:   serial@ff130000
Err:   serial@ff130000
Model: Pine64 Rock64
misc_init_r
cpuid=00000000000000000000000000000000
serial=0
normal boot
Net:   eth0: ethernet@ff540000
Hit any key to stop autoboot:  0
Card did not respond to voltage select!
mmc_init: -95, time 9
switch to partitions #0, OK
mmc1 is current device
"Synchronous Abort" handler, esr 0x02000000
ELR:     8ff28b10
LR:      8ffb3080
x0 : 000000008ffa0e98 x1 : 0000000000000000
x2 : 0000000000000003 x3 : 000000008df11f60
x4 : 000000008ff28af8 x5 : 0000000000000076
x6 : 000000008df11d80 x7 : 0000000000000000
x8 : 000000008df30600 x9 : 00000001004fff02
x10: 000000008df108b0 x11: 000000008df1b470
x12: 0000000000000000 x13: 0000000000000200
x14: 000000008df050dc x15: 00000000ffffffff
x16: 000000006cf6fd9c x17: 00000000cc478442
x18: 000000008df0ce08 x19: 000000008ffa0e98
x20: 00000000ffffffff x21: 0000000000000000
x22: 000000008df11f60 x23: 000000008ffb32d4
x24: 0000000000000003 x25: 0000000000000000
x26: 0000000000000000 x27: 0000000000000000
x28: 000000008df11f90 x29: 00000000ffffff02

Resetting CPU ...

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

U-Boot SPL 2017.09 (Jul 11 2019 - 16:27:30)
setup_ddr_param  1
booted from SD
Trying to boot from MMC2

...
#10
I just built ayufans latest 4.4.20x   kernel and u-boot from his repo's successfully on the rock64 board not in qemu.
I ran stuff like make blah_defconfig for both and it worked.    Now I am sitting here wondering....great ya fumbled through that...now how are you gonna get that stuff onto the usb3 laptop hdd you have hanging off the board that has free space at the beginning and has a Linux from Scratch systemd build that's sitting on sda2.
I assume I have to dd in the 3 (?) required boot .img files I should have from building u-boot.  That's where I'm at and it's the limit of my knowledge on doing this stuff.   I previously built LFS and used ARch arm's uboot and kernel with no problem but Arch arm rootfs and kernel leave alot to be desired as far as correct setting of parameters (bad usb3, nic, ram mem speed drivers/configs) to successfully compile source pkgs the way armbian does.   That's the why of all this ayufan building fyi.
    
I think I got pretty far for a beginner with a source build of linux.    Now that I've written what I have can someone help me finish this process?    Or should I start a new tread?   I felt this thread has good background so I posted here. I can't find anything else on this but this thread that assumes alot of things the reader would know.  Thanks


Possibly Related Threads…
Thread Author Replies Views Last Post
  Hoe to Update Buildroot Package config from SDK build.sh file shivarj89 0 1,921 09-09-2019, 09:39 AM
Last Post: shivarj89
  Error when building kernel - realtek krystian 1 2,609 02-25-2018, 03:58 AM
Last Post: krystian

Forum Jump:


Users browsing this thread: 1 Guest(s)