[help] Trying to build a close to mainline image
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.
Community administrator and sysadmin for PINE64
(Translation: If something breaks on the website, forum, or chat network, I'm a good person to yell at about it)

Thanks, fire219 !
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
@MarkHaysHarris777 : 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.

@fire219 : 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
and picked the "stable" kernel info from here
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

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

root@debianCross:/mnt# ls
boot.scr.uimg  sun50i-a64-pine64.dtb  sun50i-a64-pine64-plus.dtb
root@debianCross:/mnt# dumpimage -i boot.scr.uim boot.cmd
dumpimage: Can't open "boot.scr.uim": No such file or directory
root@debianCross:/mnt# dumpimage -i boot.scr.uimg boot.cmd
root@debianCross:/mnt# ls
boot.cmd  boot.scr.uimg  sun50i-a64-pine64.dtb sun50i-a64-pine64-plus.dtb
root@debianCross:/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

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...
Community administrator and sysadmin for PINE64
(Translation: If something breaks on the website, forum, or chat network, I'm a good person to yell at about it)

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 @fire219 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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Pine64 Debian Stretch/mainline [4.14.7] CallMeFoxie 50 123,708 07-22-2019, 09:24 PM
Last Post: amp
  Script to build pure Debian images for Pine64+ amp 1 4,324 05-01-2019, 09:09 PM
Last Post: tllim
  Is there just one fuctioning Debian Desktop image? KNERD 7 13,429 03-29-2019, 02:00 AM
Last Post: desai_amogh
Question A64+ vs. A64-LTS - Build boots? Baldnerd 10 13,961 09-05-2018, 11:48 PM
Last Post: tllim
  Gambas3 installation on Debian image linusky 0 2,271 11-29-2016, 11:10 AM
Last Post: linusky
  Very long boot time with Debian image Xabaras76 5 7,513 07-14-2016, 03:49 PM
Last Post: Xabaras76
  Cannot install Dstat on Debian Base PineA64 image ywoody 6 7,887 07-11-2016, 07:15 PM
Last Post: dkryder
  Image without Guu WhiteSnake86 1 2,994 07-06-2016, 11:11 PM
Last Post: MarkHaysHarris777
  Pine64 not booting with image m16bishop 9 10,346 06-13-2016, 10:50 AM
Last Post: robertvaldimarsson
  dose the debian-mate-jessie-lenny.raposo image support lcd display? MicroDiery 1 2,997 06-03-2016, 07:59 AM
Last Post: Luke

Forum Jump:

Users browsing this thread: 1 Guest(s)