experimental | ||
kernel | ||
kernel-pkgs | ||
u-boot | ||
.gitignore | ||
build-new-kernel.sh | ||
chroot-setup.sh | ||
first10M.img | ||
mkbootimg.sh | ||
README.md | ||
setup.sh |
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
/dbts/mt7623n-bananapi-bpi-r2.dtb
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/dtbs
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
... !!!
linux-headers + updating
TODO: adapt pacman sources such that the pkgs linux
and linux-headers
are installed from the local sources in linux-pkgs
.
In order to install the linux headers needed to build modules from other packages you need to compile the kernel directly on the arm cpu. Boot into the system and clone the main line kernel repository. Checkout the latest release tag. Create a link to the linux repository and run makepkg:
cd kernel-pkgs
mkdir src
ln -s /path/to/linux/repo src/linux
makepkg
If everything finishes successfully install the created packages. Before that, backup original zImage and dtbs files!
sudo cp /boot/zImage /boot/zImage.orig
sudo cp /boot/dtbs/mt7623n-bananapi-bpi-r2.dtb /boot/dtbs/mt7623n-bananapi-bpi-r2.orig.dtb
sudo pacman -U linux-armv7-${version}-armv7h.pkg.tar.xz
sudo pacman -U linux-armv7-headers-${version}-armv7h.pkg.tar.xz
Advise pacman to ignore these two packages. Otherwise it will update them from the official mirrors, which will probably not work:
# /etc/pacman.conf
IgnorePkg = linux-armv7 linux-armv7-headers