descriptions, explanations and links (which took far too much time to be found out) that are useful to get arch linux running on a banana pi r2
Find a file
Christian Zimmermann 6da0b5764c further instructions
2020-11-28 16:07:18 +01:00
experimental mt7530 driver + neccesary patches (including dtc-lexer patch) 2020-10-11 22:07:29 +02:00
kernel switch to mainline kernel + add corresponding config + patchfiles (for v5.9) 2020-11-28 15:51:51 +01:00
kernel-pkgs rename kernel-headers -> kernel-pkgs 2020-11-28 15:54:18 +01:00
u-boot descriptions and files regarding u-boot stuff 2020-10-03 19:14:04 +02:00
.gitignore kernel: fuse support + .gitignore 2020-11-01 23:23:58 +01:00
boot.cmd further instructions 2020-11-28 16:07:18 +01:00
chroot-setup.sh update kernel config (raid + dm support) + various scripts 2020-07-31 00:52:54 +02:00
first10M.img further instructions 2020-11-28 16:07:18 +01:00
mkbootimg.sh update kernel config (raid + dm support) + various scripts 2020-07-31 00:52:54 +02:00
README.md further instructions 2020-11-28 16:07:18 +01:00
setup.sh update kernel config (raid + dm support) + various scripts 2020-07-31 00:52:54 +02:00

Everything this document is about is how to setup the sd card that finally is inserted to the banana. So lets start:

The sd card contains the following:

  • Pre-Loader
  • u-boot
  • vfat: boot (/dev/mmcblk1p1)
  • ext4: root (/dev/mmcblk1p2)
  • ...

Notice that the sd-card is named /dev/mmcblk1 in the running system on the banana pi, while it may have any name on your pc where you setup everythin (in the following /dev/mmcblk0 is assumed). Example formatting (last partion can be ignored, partition sizes of mmcblk0px, x >= 2 may be varied):

fdisk -l /dev/mmcblk0
  Festplatte /dev/mmcblk0: 14,84 GiB, 15931539456 Bytes, 31116288 Sektoren
  Einheiten: Sektoren von 1 * 512 = 512 Bytes
  Sektorgröße (logisch/physikalisch): 512 Bytes / 512 Bytes
  E/A-Größe (minimal/optimal): 512 Bytes / 512 Bytes
  Festplattenbezeichnungstyp: dos
  Festplattenbezeichner: 0x54fd6008
  
  Gerät          Boot   Anfang     Ende Sektoren Größe Kn Typ
  /dev/mmcblk0p1        204800   729087   524288  256M  c W95 FAT32 (LBA)
  /dev/mmcblk0p2        729088 22925311 22196224 10,6G 83 Linux
  /dev/mmcblk0p3      22925312 31115263  8189952  3,9G 83 Linux

For some reason I still have to figure out, creating the partition table directly with fdisk destroys the preloader. Hence, I recommend to dd the image first10M.img to the beginning of the SD card and then recreating the partitions using the existing partition table.

Pre-Loader:

Is included in first10M.img.

u-boot:

clone u-boot repository and compile:

git clone https://gitlab.denx.de/u-boot/u-boot.git
cd u-boot
cp -f <this_repo>/u-boot/mt7623n_bpir2_defconfig configs
make CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- ARCH=arm mt7623n_bpir2_defconfig
make CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- ARCH=arm 
dd if=u-boot.bin of=/dev/mmcblk0 bs=1k seek=320

maybe you have to patch scripts/dtc/dtc-lexer.l; apply the corresponding patch

boot-partition:

Contains:

/boot.img
/zImage
/dts/mt7623n-bananapi-bpi-r2.dtb

and further images (eg different kernel versions etc...). /boot.img can be created from the provided boot.cmd using the mkbootimg.sh script. I recommend to create a second .img file which boots into former kernel images (might be useful in the case of unsuccessful kernel update).

how to create these files:

(because they are not available anywhere, at least not for the most recent kernel. The most recent version provided by some debain derivates is 4.4 or 4.14... too old for my taste!)

git clone https://github.com/mbgg/linux-mediatek.git
cd linux-mediatek
git checkout <commit_I_recommend>
cp <this_repo>/kernel/linux-mediatek-<commit_hash>.config .config
cp <this_repo>/kernel/mt7623n-bananapi-bpi-r2.dts arch/arm/boot/dts
mkdir modules
make ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- oldconfig
make -j4 ARCH=arm CROSS_COMPILE=/usr/bin/arm-linux-gnueabihf- INSTALL_MOD_PATH=./modules zImage dtbs modules modules_install
mkdir boot.setup
mkdir root.setup
mount /dev/mmcblk0p1 boot.setup
mount /dev/mmcblk0p2 root.setup
cp arch/arm/boot/zImage boot.setup
cp arch/arm/boot/dts/mt7623n-bananapi-bpi-r2.dtb boot.setup/dts
rsync -uavP modules/lib/modules/ root.setup/lib/modules
mkimage -A arm -T script -C none -n "Load Kernel" -d <this_repo>/u-boot/boot.cmd boot.img
cp boot.img boot.setup
sync
umount boot.setup root.setup
rmdir boot.setup root.setup

root-partition:

If you did no mistake so far (...) this should be the easiest part: There are two possibilities:

  • Use the provided image [name], dd it to your root partition, boot into this root and update and customaize the system (you have to re-upload the kernel modules, see previous section)
  • dd the image to a temporary partition, boot into it, and setup the root partition using pacstrap (you dont need the linux or linux-firmware package, you already cared about these parts in the previous section); alternatively use the setup.sh script

... !!!