DebianOn is an effort to document how to install, configure and use Debian on some specific hardware. Therefore potential buyers would know if that hardware is supported and owners would know how get the best out of that hardware. The purpose is not to duplicate the Debian Official Documentation, but to document how to install Debian on some specific hardware. If you need help to get Debian running on your hardware, please have a look at our user support channels where you may find specific channels (mailing list, IRC channel) dedicated to certain types of hardware. |
Translation(s): none
Contents
Preface
This guide is a work in progress. At this point in time the end result is an installed system that can't find its own rootfs, resulting in a kernel panic. If you can improve this guide, please do. If you came here to find an alternative to outdated images provided by board vendors through Google drive, you might want to check if Armbian supports your device.
Requirements
- A single board computer with:
- Allwinner H3 or similar Armv7 SoC. Instructions for Armv8/64 bit would be different.
- Video out (like HDMI) and a connected display
A Device Tree Blob file in https://d-i.debian.org/daily-images/armhf/daily/device-tree/
An internet connection using an adapter that is supported out-of-the-box. Using the onboard ethernet or a USB ethernet dongle is the easiest way to achieve this. This guide doesn't cover setting up WiFi.
- A USB keyboard
- A Micro SD(HC/XC) card, 32GB or more recommended, class 10 or faster recommended, ANY EXISTING DATA ON THIS CARD WILL BE LOST.
- Another machine with a working Debian installation and Micro SD card reader (this can be an ordinary AMD64 laptop/desktop)
This guide was written using a Banana Pi M2+ but should apply to similar single board computers with an Allwinner H3 with only a few adjustments. Notably, you need to use the Device Tree Blob (.dtb) file that applies to your particular computer.
Compile U-boot
Run the following commands on your existing Debian system:
apt-get install git bison flex gcc-arm-linux-gnueabihf python3-setuptools swig python3-dev libssl-dev build-essential mkdir u-boot-build git clone https://source.denx.de/u-boot/u-boot.git cd u-boot git checkout v2023.10 make O=../u-boot-build/ bananapi_m2_plus_h3_defconfig
You should replace "bananapi_m2_plus_h3_defconfig" with the file for your board. You can find the file in the u-boot/configs directory or by looking at https://source.denx.de/u-boot/u-boot/-/tree/master/configs.
You may want to replace "v2023.10" with the current version, see https://source.denx.de/u-boot/u-boot/-/tags.
Preparing SD card
Partioning
Insert your SD card (ANY EXISTING DATA ON THIS CARD WILL BE LOST) in your existing Debian system. Use a disk partioning tool like GParted to create a 1000MB partition with FAT32 and a larger EXT4 partition to install Debian, 20GB+ is recommended. Make sure you are modifying the correct storage device as all existing data on it will be lost!
If you prefer fdisk, enter:
o n (press enter) (press enter) +1000M t c n (press enter) (press enter) (press enter) (press enter) w
And run sudo mkfs -t vfat -n UBOOT /dev/sdx1 to format the first partition as FAT32. Replace "sdx1" with the device name of your SD card, dmesg or df may help to find the device name.
Note on swap: do not create a swap partition on the SD card. If you need a swap partition, create it on an external hard disk or SSD. If that's not possible, at least use a separate USB stick or memory card. This will prevent your system from becoming unbootable once the swap inevitably wears down your USB stick or memory card.
Copy the bootloader
sudo dd if=u-boot-build/u-boot-sunxi-with-spl.bin of=/dev/sdx bs=1024 seek=8
Replace "sdx" with the device name of your SD card, dmesg or df may help to find the device name. This should be the device, not the partition. So /dev/sdx, not /dev/sdx1.
Note: newer Allwinner ?SoCs (starting with the H3 from late 2014) also support loading the bootloader from a 128K offset. When using the MBR partioning scheme either is fine. But if you're using a GPT partion table (which can be bigger than 8K) and you have an H3 or newer, you may need to use a 128K offset (seek=128) instead.
Copy the installer
wget "https://ftp.debian.org/debian/dists/stable/main/installer-armhf/current/images/hd-media/hd-media.tar.gz" tar -axf hd-media.tar.gz
Copy the dtbs directory, boot.scr, initrd.gz and vmlinuz files you just extracted to the FAT32 partition on the SD card.
Tip: the dtbs directory contains about 900 files which may take a while to copy to your SD card. You can instead create a directory named "dtbs" on the SD card and copy only the .dtb for your device.
Get the netinst ISO from https://cdimage.debian.org/debian-cd/current/armhf/iso-cd/ and copy it to the 1GB FAT32 partition on the SD card. Don't extract it, just copy the .iso file.
If you prefer Debian testing instead of stable, use the daily hd-media tarball and the weekly testing CD instead. Note that the hd-media and ISO image need to match, do not combine the daily hd-media tarball with the ISO image for Debian stable.
Remove the SD card from the computer and insert it into the single board computer.
Installation
The Debian installation should now start. Refer to DebianInstall if you need help with this. During installation you may want to set the "noatime" flag for your boot partition to reduce wear of the SD card.
If you have a Banana Pi M2+ or similar and the screen remains black at this point, various things could be wrong:
- You didn't prepare or insert the SD card correctly. If no SD card is installed or there is no valid U-boot, the screen is expected to remain black.
- Power supply issues. Your cable could be too thin, you're using MicroUSB instead of the barrel jack, your power supply may be inadequate.
- Your single board computer could simply be dead. You could try a vendor-provided image to see if the board can display anything.
- Faulty HDMI cable.
- Wrong input selected on display.
At the end of the installation you'll get the error The 'grub-pc' package failed to install into /target/. This is particularly odd as grub-pc doesn't even exist for the armhf architecture, so this may be a bug. You'll have to continue without installing the bootloader. As you do, a dialog will pop up like "You will need to boot manually with the /vmlinuz kernel on partition /dev/mmcblk1p2 and root=/dev/mmcblk1p2 passed as kernel argument." make a note of these values!
Complete the installation and unplug the power from the single board computer. Remove the SD card and insert it into your existing Debian system. Copy the .dtb for your device to the /boot directory of the new Debian installation. Put the card back into your single board computer.
Configuring U-boot
While booting you'll see a message about pressing any key to stop autoboot. Press any key and you'll get a prompt.
In the following commands, replace "root=/dev/mmcblk1p2" with the kernel argument the installer told you to use and replace "sun8i-h3-bananapi-m2-plus-v1.2.dtb" with the filename of the .dtb for your device.
=> setenv bootargs "root=/dev/mmcblk1p2 ro rootwait" => setenv bootcmd "ext4load mmc 0:2 ${fdt_addr_r} /boot/sun8i-h3-bananapi-m2-plus-v1.2.dtb ; fdt addr ${fdt_addr_r} 0x40000 ; ext4load mmc 0:2 ${kernel_addr_r} /boot/vmlinuz ; ext4load mmc 0:2 ${ramdisk_addr_r} /boot/initrd.img ; bootz ${kernel_addr_r} ${ramdisk_addr_r}:${filesize} ${fdt_addr_r}" => saveenv => reset
Now the computer will reboot. The kernel of your new install will be loaded and it'll wait forever for your root device to show up. If you remove the "rootwait" argument above, it'll show a kernel panic instead. Please complete this guide if you can.
Credits
This guide is based on information from:
https://www.earth.li/~noodles/blog/2023/10/debian-on-bpi-m2-zero.html by Jonathan ?McDowell
https://u-boot.readthedocs.io/en/latest/board/allwinner/sunxi.html