Arch Linux Arm on Banana Pi compiled from Arch Linux


Copy Arch Linux arm base filesystem

We start with a fresh SD card. Firstly, format the SD card as described in the Cubieboard 2 tutorial. /dev/sdc is my SD card.

1
2
3
4
5
6
7
8
sudo dd if=/dev/zero of=/dev/sdc bs=1M count=8
fdisk /dev/sdc
sudo mkfs.ext4 /dev/sdc1
sudo mount /dev/sdc1 /mnt
cd /mnt/
sudo tar xf ~/ArchLinuxARM-armv7-latest.tar.gz
cd
sudo umount /mnt

The SD card is synced with the base file system of ALARM. Now onto creating the u-boot components u-boot-sunxi-with-spl.bin and boot.scr, you could refer to compiled files by tredaelli but as they caused boot problems for me, I will continue with creating those two by myself.

Compiling boot.scr and u-boot myself

I will at first install the Arch Linux uboot-tools package. Followed by creating both files from sources in a folder self-build that was placed in my working directory with the precompiled files. Use the Arch Linux wiki article to fetch the file contents.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
sudo pacman -S uboot-tools
mkcd self-build

# See wiki link above
vim boot.cmd

# -A arch, -O operating system, -T image type, -C compression,
# -a/-e load and entry address in hex, -n name, -d data file
mkimage -A arm -O linux -T script -C none -a 0 -e 0 -n 'BananaPi boot script' -d boot.cmd boot.scr

sudo mount /dev/sdc1 /mnt
sudo cp boot.scr /mnt/boot/boot.scr

Now the u-boot binary.

1
2
3
4
5
6
sudo pacman -S dtc
git clone git://git.denx.de/u-boot.git
cd u-boot
make -j 4 ARCH=arm  CROSS_COMPILE=arm-none-eabi- Bananapi_defconfig
make -j 4 ARCH=arm  CROSS_COMPILE=arm-none-eabi-
sudo dd if=u-boot-sunxi-with-spl.bin of=/dev/sdc bs=1024 seek=8

In the end, my workspace looked like this (sizes in bytes):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
├── [       4096]  cubieboard2/
│   ├── [        725]  boot.scr
│   └── [     484375]  u-boot-sunxi-with-spl.bin
├── [       4096]  self-build/
│   ├── [       4096]  u-boot/
│   │   ├── [     489693]  u-boot-sunxi-with-spl.bin
│   │   └── [           ]  [...]
│   ├── [        733]  boot.cmd
│   └── [        805]  boot.scr
├── [       4096]  tredaelli/
│   ├── [        805]  boot.scr
│   └── [     450694]  u-boot-sunxi-with-spl.bin
└── [  307892928]  ArchLinuxARM-armv7-latest.tar.gz

Make fails due to wrong Python version

In case you encounter a problem with your Python version when binman is called, manipulate $PATH to find Python2 first. Problem here is the shebang #!/usr/bin/env python, which is Python3 on Arch Linux but binman awaits Python2

1
2
3
4
5
6
7
8
mkdir /tmp/python
ln -s /usr/bin/python2 /tmp/python/python

# Check it
PATH=/tmp/python:$PATH python

# Run make as seen above
PATH=/tmp/python:$PATH make -j 4 ARCH=arm CROSS_COMPILE=arm-none-eabi-

Troubleshooting

Plug and play my ass. Again I needed to plug in a monitor to see what's broken. I was lucky DHCP worked. With the precompiled files in the steps above the kernel was not loaded and the Pi was stuck in trying to load pxelinux from the network. With the self compiled files the kernel booted and used the DHCP address.

SSH does not work

Port 22 connection refused! Systemctl showed start request repeated too quickly, refusing to start. Problem: Server keys could not be loaded. This might have been caused by power interrupt during debugging, so that the keys were generated but not written to SD card in time, resulting in empty files in /etc/ssh. As root on the Pi:

1
2
3
4
cd /etc/ssh/
rm -v ssh_host_*
ssh-keygen -A
systemctl restart sshd

See also SSH: Could not load host key: /etc/ssh/ssh_host_rsa_key.

netctl not able to start wifi configuration

I was trying to set up this Banana Pi with a 5Ghz wifi dongle (TP-Link TL-WDN3200, Ralink RT5572 chip, 148F:5572), configured the netctl profile /etc/netctl/wireless as followed:

1
2
3
4
5
6
7
8
9
Interface=wlan0
Connection=wireless
Security=wpa
ESSID='MySSID'
Key='MySecretPassword'
IP=static
Address='x.x.x.x/x'
Gateway='x.x.x.x'
DNS=('x.x.x.x')

Using netctl start wireless resulted in Could not create a wpa config file for interface. Problem: no wpa_supplicant installed. pacman -S wpa_supplicant solves this problem. Enable the profile with netctl enable wireless so it will be automatically started on boot.