Used: arm-linux-gnueabihf-gcc (Linaro GCC 6.4-2017.08) 6.4.1 20170707
I used mainline u-boot for this - tested with 2019.10-rc3:
git clone https://gitlab.denx.de/u-boot/u-boot.git
cd u-boot
make Bananapi_defconfig
make -j$(nproc) CROSS_COMPILE=arm-linux-gnueabihf-
NOTE: latest u-boot requires swig! (apt-get install swig)
You need two files: u-boot-sunxi-with-spl.bin and the device tree u-boot.dtb (still investigating if this is the correct DT).
Manually formatted card with two partitions using Gparted. Used MBR partition table and created:
- boot partition - 16MB - FAT16 partition starting from 1M offset
- rootfs partition - the reset of the space - EXT4 partition
Do this after the formatting:
dd if=u-boot-sunxi-with-spl.bin of=${card} bs=1024 seek=8
WARNING: DO NOT USE THE PARITION, write directly to the card (ex: /dev/sdh, not /dev/sdh1!) NOTE: the file does not appear in the partition! Not sure if there is a better way.
At this stage the SD card can be tested in the board: plug it in, plug in a 3.3V serial in UART0(TX <--> RX; RX <--> TX), open a terminal with 115200 baud and see u-boot starting.
I used debootstrap to install these to the card. Plug in the card and make sure the rootfs partition is mounted somewhere. First install these on the host PC:
apt-get install debootstrap qemu-user-static
Then run bootstrap first stage:
debootstrap --arch=armhf --foreign buster <rootfs mount point>
If you get an error about noexec or nodev, use sudo mount -o remount,exec,dev <rootfs mount point>
Chroot to the initial image:
cp /usr/bin/qemu-arm-static /<rootfs mount point>/usr/bin/
chroot <rootfs mount point> /usr/bin/qemu-arm-static /bin/sh -i
Start the second stage
/debootstrap/debootstrap --second-stage
Then deviated a little from the sunxi guide and used the Debian one:
apt-get install makedev
mount none /proc -t proc
cd /dev
MAKEDEV
editor /etc/adjtime
Here is a sample:
0.0 0 0.0
0
UTC
dpkg-reconfigure tzdata
systemctl enable serial-getty@ttyS0.service
systemctl set-default multi-user.target
apt-get install locales
dpkg-reconfigure locales
Now the system should be up, and it only needs a kernel:
apt search linux-image
Then install the kernel package of your choice using its package name.
# apt install linux-image-arch-etc
- Stop u-boot autoboot
- Set the following env variables
setenv bootargs console=ttyS0,115200n8 root=/dev/mmcblk0p2 rootwait panic=10
ext4load mmc 0:2 ${fdt_addr_r} boot/u-boot.dtb
ext4load mmc 0:2 ${kernel_addr_r} boot/vmlinuz-4.19.0-5-armmp <replace with correct version>
ext4load mmc 0:2 ${ramdisk_addr_r} boot/initrd.img-4.19.0-5-armmp <replace with correct version>
- Boot the image - NOTE: initrd last for filesize to work!
bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}
WARNING: if you get a kernel panic about not finding init adjust the root=/dev/<device>
Run these commands. The saveenv part makes it permanent.
setenv bootargs console=ttyS0,115200n8 root=/dev/mmcblk0p2 rootwait panic=10
setenv bootcmd_mine 'ext4load mmc 0:2 \${fdt_addr_r} boot/u-boot.dtb; ext4load mmc 0:2 \${kernel_addr_r} vmlinuz; ext4load mmc 0:2 \${ramdisk_addr_r} initrd.img; bootz \${kernel_addr_r} \${ramdisk_addr_r}:\${filesize} \${fdt_addr_r};'
setenv bootcmd "run bootcmd_mine"
saveenv