As I dicussed in previous article, I would like to run a BSP (Allwinner/sunxi) kernel to enable video acceleration on my BananaPi. Since the code from the LeMaker website is rather old and messy, it won’t compile with a recent compiler. Therefore I will get an image containing this kernel. The ArchLinuxARM image provided by lemaker is rather old (2014) and uses an ancient 3.4 kernel. I hope my system will even boot on such an artefact.

The Mainline U-boot seems to have support for BSP kernels, so just extracting the kernel and its modules should be enough. Therefore I will mount the image through kpartx. This tool allows to mount disk images with partitions. Running the tool creates partitions I can mount for the image.

[root@8570w bananapi]# kpartx ArchLinux_For_BananaPi_v1412.img 
loop0p1 : 0 102400 /dev/loop0 2048
loop0p2 : 0 7063552 /dev/loop0 104448
loop deleted : /dev/loop0
[root@8570w bananapi]# kpartx -a ArchLinux_For_BananaPi_v1412.img
[root@8570w bananapi]# mount /dev/mapper/loop0p1  mnt
[root@8570w bananapi]# ls mnt
script.bin  uEnv.txt  uImage
[root@8570w bananapi]# mkdir BSP_kernel
[root@8570w bananapi]# cp mnt/* BSP_kernel/

Here is another thing where we see the BSP kernel is rather old, as it still uses the uImage format, rather then the zImage kernels use nowadays. Furthermore, we notice a script.bin file. This is a binary created from a FEX file. It’s used to configure the SoC, things like PIN muxing and video resolution, and fixing the MAC address.

[root@8570w bananapi]# umount mnt
[root@8570w bananapi]# mount /dev/mapper/loop0p2  mnt
[root@8570w bananapi]# umount mnt
[root@8570w bananapi]# mount /dev/mapper/loop0p2  mnt
[root@8570w bananapi]# cp -r mnt/lib/modules BSP_kernel/

So, we have got the files we’re looking for, transferring them to the Banana Pi

[andre@8570w bananapi]$ scp -r BSP_kernel/ banana: 

And placing them

[root@banana BSP_kernel]# cp -r modules/* /lib/modules
[root@banana BSP_kernel]# cp * /boot     
cp: omitting directory 'modules'

The U-boot configuration by ArchLinuxARM first tries to load a mainline kernel (zImage) and if not present, it will try to load a BSP kernel (uImage), so by renaming the zImage, we should boot the old kernel.

[root@banana BSP_kernel]# mv /boot/zImage /boot/zImage_bak

However, it seems the bootloader isn;t entirely compatible with the old kernel after all:

Found U-Boot script /boot/boot.scr
833 bytes read in 101 ms (7.8 KiB/s)
## Executing script at 43100000
** File not found /boot/zImage **
4822936 bytes read in 380 ms (12.1 MiB/s)
50972 bytes read in 123 ms (404.3 KiB/s)
## Booting kernel from Legacy Image at 48000000 ...
   Image Name:   Linux-3.4.103
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    4822872 Bytes = 4.6 MiB
   Load Address: 40008000
   Entry Point:  40008000
   Verifying Checksum ... OK
   Loading Kernel Image ... OK

Starting kernel ...

<6>Booting Linux on physical CPU 0
<6>Initializing cgroup subsys cpuset
<6>Initializing cgroup subsys cpu
<5>Linux version 3.4.103 (bananapi@lemaker) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #1 SMP PREEMPT Thu Dec 18 13:07:12 CST 2014
CPU: ARMv7 Processor [410fc074] revision 4 (ARMv7), cr=10c5387d
CPU: PIPT / VIPT nonaliasing data cache, VIPT aliasing instruction cache

Error: unrecognized/unsupported machine ID (r1 = 0x100010bb).

Error: unrecognized/unsupported machine ID (r1 = 0x100010bb).

Available machine support:

ID (hex)        NAME
Available machine support:

ID (hex)        NAME
000010bb        sun7i
000010bb        sun7i
0000102a        sun5i
0000102a        sun5i
00001008        sun4i
00001008        sun4i

Please check your kernel config and/or bootloader.

It seems the bootloader has set one bit the kernel doesn’t recognise. I could recompile U-boot with the option “Workaround for booting old kernels” under “ARM Architecture”. Now the kernel boots. Oh…. the BSP kernel, which by default flashes a LED when running. Rather annoying. However, the bootprocess gets stuck. I think this is because a 3.4 kernel is too old for systemd to work. Ancient kernels…. le sigh.

I’m going to burn the ancient image. I suppose it won’t be upgradable. But we’ll be sure whether it’s a kernel/systemd mismatch.

Logging in over serial fails, we can log in over ssh
it seems both

are running, conflicting

[root@lemaker etc]# systemctl stop serial-getty@ttyS0.service 
[root@lemaker etc]# systemctl disable serial-getty@ttyS0.service 
[root@lemaker etc]# systemctl stop getty@ttyS0.service 
[root@lemaker etc]# systemctl start getty@ttyS0.service 

Since we’re running an AllWinner BSP image, we need to fix the fex file to have a static MAC.

[root@lemaker boot]# pacman -S sunxi-tools
[root@lemaker boot]# bin2fex script.bin script.fex


MAC = "8a413f5bf892"

and run

[root@lemaker boot]# fex2bin script.fex script.bin

And while the mainline uboot enables the composite out by default, and even outputs the bootloader. From earlier experience with AllWinner/sunxi BSP kernels I know output is only enabled at some point during boot.

I have been debugging this for hours, turned out, the image from lemaker doesn’t mount the /boot partition, and in the /boot directory, the same files as I would expect on the boot partition where present. So I have been changing files that haven’t been loaded at all. To enable console, after mounting the boot parition!!!!! open uEnv.txt and make the disp. arguments look like disp.screen0_output_mode=pal disp.screen0_output_type=2

After all of this… I think I’ll finish up this article and go to the video acceleration and kodi, which was the original topic when I started writing, to another article. I will discuss one more thing and that will be systemd. The old image could be upgraded without problems

« »