PINE64

Full Version: [help] Trying to build a close to mainline image
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello everyone,

So I'm new to the SBC world with my pine64+.
Therefore I did a lot of reading about bootloading, rootfs and all the crap about allwinner's BSP and boot0 firmware...

 I compiled a lot of stuff, but ended up figuring it would be easier to use the "base" image from apritzel. Problems are : 
- I don't have my pine with me to experiment
- I would like to make sure about what I need to do exactly

By using dumpimage of the boot script my understanding is the following:
- I can keep the dtb file which will be picked up through the ${fdtfile} in the boot script
- I should add my kernel in the image file as "uImage" or in "boot/uImage"
- the rootfs should be on the second partition of the image (therefore on mmcblk0p2 once on SD

I have an AARCH64 rootfs using a qemu debootstrap I found in one the pages
I know the kernel has a lot of shortcomings, but ethernet, SD should be ok if ssh agrees to work out of the box...

I also need to figure out how to setup initial user accounts on the image.

That's all  Smile
Any help appreciated
First of all, if you just want a mainline image, I've got one over here. Wink

To be honest, I don't know much about the 4.4 simpleimage, which I assume is the one you're talking about. But I can tell you how to build a functioning 4.7-rc1 image yourself. 

Getting bootloader set up

1: Get this firmware image and flash it to the SD card. That provides the boot0, a special version of uboot* and boot script.

Kernel compile

2: Download this kernel tree (by zip or git... your choice).
3: You said you had already compiled stuff... but if you still need a crosscompile toolchain, get one (apt-get install aarch64-linux-gnu-gcc should do the job on Ubuntu and maybe Debian)
4: Go into the directory you put the source in and fart around with menuconfig (make ARCH=arm64 CROSS_COMPILE=<name/path of crosscompiler, in above case "aarch64-linux-gnu-"> menuconfig) or go the lazy route and use my .config file (rename to .config, put into kernel directory)
5: Build kernel with make ARCH=arm64 CROSS_COMPILE=<crosscompiler as before> -j<number of cores in system> Image dtbs. Depending on the speed of the system you're running this on, you may have time to go get a drink, or a 5 course meal. Wink

Move kernel and DTBs

6: Assuming the build completed (didn't give any errors), from your kernel build directory go to arch/arm64/boot. Here you should find a file simply called "Image". Copy this to the root of the boot partition of the SD card, alongside the boot script (yes, this boot script works a little different from the usual one). From where you found the image, go deeper to dts/allwinner. Copy the files called "sun50i-a64-pine64-plus.dtb" and "sun50i-a64-pine64.dtb" to the same place as the kernel.

Make rootfs partition

7: This boot script needs the rootfs to be at sdX5/mmcblk0p5. So in your partitioning tool of choice, make the partition for that (make extended DOS type partition at #2, and a logical one inside that at #5).
8: Copy your rootfs of choice to the new partition.

9: Put SD card in Pine, pray to whatever serious or comical deity you choose to worship on this fateful day, turn on Pine, and hope it boots!
(A serial adapter set up as shown here will be very useful in case anything goes wrong)

I hope my 30 straight minutes of typing is helpful. Smile

* The normal BSP kernels can control the hidden ARISC core inside the A64, which manages power distribution. The mainline kernels can't do that yet. Without this special uboot, no power is provided to the Ethernet PHY, which means no Ethernet.
Thanks, fire219 !
: thanks, I was fearing this reply (which is the one you made to fire219 too  Wink )
I will when I have a bit more time and maybe my pine64 at hand.

: thanks for the writeup, I'm sure it will be helpful as it probably is one of the most comprehensive I've read.
I did read your post on 4.7.0-rc1 but really I want to be able to build my own kernel to decide which bit I want (well it seems not much things are working anyway  Smile  )

1. I have, that's my base, but i'm working on filesystem for now
Took it from here : https://github.com/apritzel/pine64/tree/master/images

2. I used this page
http://linux-sunxi.org/Pine64#Mainline_kernel
and picked the "stable" kernel info from here
http://linux-sunxi.org/Mainline_Kernel_H...e_releases
As it turns out it's probably a 4.7.0 kernel as the "stable" kernel git link provided is actually not pointing to stable but to RC...
Did not go to icenowy's repo.

3. yep got that one covered I think : crossbuild-essential-arm64
4. went with
make defconfig
5. ARCH=arm64 make -j2 Image dtbs modules
went fairly short

6.
Code:
$ xzcat pine64_firmware-20160601.img.xz | dd of=/AARCH/firmware/apritzel.img bs=1M
$ fdisk -lu /AARCH/firmware/apritzel.img
$ mount -o loop,offset=$((2048 * 512)) /AARCH/firmware/apritzel.img /mnt
$ cd /mnt
$ ls
boot.scr.uimg  sun50i-a64-pine64.dtb  sun50i-a64-pine64-plus.dtb

The dtb files are present in the firmware, why use the ones from the compilation ?
Is it not just a file describing the devices ? (may be a silly question)

I have the compiled kernel, so I should just copy that to this image, if I understand it right ?
From my findings, either at the root or in boot/

7. Ok that's another point where I'm not clear
From https://github.com/apritzel/pine64/blob/.../README.md
It seems it's my task to decide which partition and modify the boot script (not especially on p5)

I looked it up:

Code:
[email protected]:/mnt# ls
boot.scr.uimg  sun50i-a64-pine64.dtb  sun50i-a64-pine64-plus.dtb
[email protected]:/mnt# dumpimage -i boot.scr.uim boot.cmd
dumpimage: Can't open "boot.scr.uim": No such file or directory
[email protected]:/mnt# dumpimage -i boot.scr.uimg boot.cmd
[email protected]:/mnt# ls
boot.cmd  boot.scr.uimg  sun50i-a64-pine64.dtb sun50i-a64-pine64-plus.dtb
[email protected]:/mnt# cat boot.cmd 
?fatload mmc 0 $kernel_addr_r Image
fatload mmc 0 $fdt_addr_r $fdtfile
setenv bootargs "console=ttyS0,115200n8 ro root=/dev/mmcblk0p5 rootwait earlycon=uart,mmio32,0x01c28000"
booti $kernel_addr_r - $fdt_addr_r
[email protected]:/mnt#

So it seems i can use p2 from the existing boot script ?
Why should i do an extended p5 in p2 ?

8&9. I should be able to do (although not a believer...)
I don't have the UART serial adapter...
If you're using the "stable" kernel, then that is true mainline, which has very little support for the A64 SoC. It'll boot, but absolutely none of the interfaces other than UART will work. Apritzel's a64-v5 tree (found on the Pine mainline kernel page you linked) has support for Ethernet in conjunction with the aforementioned firmware image. The tree I suggested, Icenowy's a64-usb, adds on functioning USB (on the bottom port. Top one is USB OTG which no one has tackled yet...) to that.

The DTB (Device Tree Blob) files, just like you said, describe the devices and where/how to control them. You could try to use the ones that come with the firmware, but I've had issues from reusing old DTBs with new kernels. Since you can build them at the same time as you build the kernel, there's really no reason to not use your own.

On this firmware version, the kernel goes on the root directory. If we were working with a BSP kernel-based image, we'd put it in /boot.

Technically, you can set the boot script to look for the rootfs on any partition. However, when I did that, I got a checksum error from uboot. So I just ended up going along with the default p5. If you manage to get it to boot with a different partition set, I'd definitely love to know! Smile

I'm not a believer either; was just making a joke. Though you should know that if you do not pray to the lord and savior Linus Torvalds in hopes of him blessing a kernel compile, It's bound to fail! Wink

If you're going to be doing kernel work on the Pine or any other embedded/SBC system, you should really get a UART adapter. They're cheap and unbelievably useful...
thanks for everything.
I have all the material to prepare my image file I think...

I will prepare two, one on p2 and one on p5 :-)
... and I'll test that once back home
Ok, it seems my work is not conclusive and I am using image for now until I can receive an UART0 adapter and debug what's happening...
Hello again,

It seems I was finally able to build something usable using material from apritzel :
- the basic image file for the boot partition (mainly uboot)
- apritzel's repo for the working kernel with USB support (4.9 rc xx) as I was unable to compile ice snowy due to missing makefiles apparently. I put the resulting kernel and DTBs on the boot partition above replacing existing ones.
- I modified make_roofs.sh to build a functioning Debian sid rootfs from https://github.com/longsleep/build-pine6...impleimage

some of the instructions from here https://github.com/umiddelb/armhf/wiki/H...ARM-device

the main issue I had was really building a working set of partitions+partition table in file before doing the DD
Maybe I was just misreading the instructions in the make_simpleimage.sh from longsleep when I tried to adapt it to the uboot config from apritzel...

anyway !
now it seems to work although I have not tested network