-
-
Save faddat/172d375fcf31f998bdaaa381c1ae3fcb to your computer and use it in GitHub Desktop.
Shell script for creating banana pi image with kernel 3.4.90
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
rm -rf build | |
mkdir -p build | |
echo "[INFO] Creating u-boot for bananapi" | |
if [ ! -d u-boot-bananapi ]; then | |
git clone https://github.com/LeMaker/u-boot-bananapi.git | |
elif [ -d u-boot-bananapi ]; then | |
( cd u-boot-bananapi && git pull ) | |
fi | |
(cd u-boot-bananapi && | |
make CROSS_COMPILE=arm-linux-gnueabihf- Bananapi_config && | |
make CROSS_COMPILE=arm-linux-gnueabihf- | |
cp u-boot-sunxi-with-spl.bin ../build/u-boot-sunxi-with-spl.bin) | |
cho "[INFO] Creating sunxi-tools" | |
if [ ! -d sunxi-tools ]; then | |
git clone https://github.com/LeMaker/sunxi-tools.git | |
elif [ -d sunxi-tools ]; then | |
( cd sunxi-tools && git pull ) | |
fi | |
(cd sunxi-tools && | |
make clean && | |
make) | |
echo "[INFO] Creating script.bin" | |
if [ ! -d sunxi-boards ]; then | |
git clone https://github.com/LeMaker/sunxi-boards.git | |
elif [ -d sunxi-boards ]; then | |
( cd sunxi-boards && git pull ) | |
fi | |
cp sunxi-boards/sys_config/a20/Bananapi.fex Bananapi.fex | |
sunxi-tools/fex2bin Bananapi.fex build/script.bin | |
echo "[INFO] Creating Boot uImage" | |
if [ ! -d linux-bananapi ]; then | |
git clone https://github.com/LeMaker/linux-bananapi.git | |
elif [ -d linux-bananapi ]; then | |
( cd linux-bananapi && git pull ) | |
fi | |
( cd linux-bananapi && | |
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun7i_defconfig && | |
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig && | |
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage modules && | |
cp arch/arm/boot/uImage ../build/uImage && | |
cp .config ../build/.config && | |
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=../build/modules modules_install ) | |
IMG_FILE="bananapi.img" | |
echo "[INFO] Allocating image space" | |
dd if=/dev/zero of=${IMG_FILE} bs=1M count=4500 | |
LOOP_DEV=`sudo losetup -f --show ${IMG_FILE}` | |
LOOP_PART_BOOT="${LOOP_DEV}p1" | |
LOOP_PART_SYS="${LOOP_DEV}p2" | |
sudo parted -s "${LOOP_DEV}" mklabel msdos | |
sudo parted -s "${LOOP_DEV}" unit cyl mkpart primary fat32 -- 0 2cyl | |
sudo parted -s "${LOOP_DEV}" unit cyl mkpart primary ext2 -- 2cyl -0 | |
sudo parted -s "${LOOP_DEV}" set 1 boot on | |
sudo parted -s "${LOOP_DEV}" print | |
sudo partprobe "${LOOP_DEV}" | |
echo "[INFO] Creating filesystems" | |
sudo mkfs.vfat "${LOOP_PART_BOOT}" -I -n boot | |
sudo mkfs.ext4 -O ^has_journal -E stride=2,stripe-width=1024 -b 4096 "${LOOP_PART_SYS}" -L system | |
sync | |
echo "[INFO] Burning the bootloader" | |
sudo dd if=/dev/zero of=${LOOP_DEV} bs=1k count=1023 seek=1 | |
sudo dd if=build/u-boot-sunxi-with-spl.bin of=${LOOP_DEV} bs=1024 seek=8 | |
sync | |
echo "[INFO] Copying boot files" | |
sudo mount -t vfat "${LOOP_PART_BOOT}" /mnt | |
sudo cp build/uImage /mnt | |
sudo cp build/script.bin /mnt | |
sudo cp uEnv.txt /mnt | |
sudo cp build/.config /mnt | |
sync | |
ls -al /mnt | |
sudo umount /mnt | |
# NOTE: This file system "debian-fs" is just taken from a standard bananian image. | |
echo "[INFO] Copying pbo filesystem (based in raspbian)" | |
sudo mount -t ext4 "${LOOP_PART_SYS}" /mnt | |
sudo rm -rf /mnt/* | |
sudo cp -r debian-fs/* /mnt | |
if [ -f /mnt/README.md ]; then | |
sudo rm -rf /mnt/README.md | |
fi | |
sync | |
echo "[INFO] Modules" | |
sudo mkdir -p /mnt/lib/modules | |
sudo rm -rf /mnt/lib/modules/ | |
sudo cp -r build/modules/lib /mnt/ | |
sync | |
echo "[INFO] Additional folders required for boot" | |
sudo mkdir -p /mnt/proc | |
sudo mkdir -p /mnt/sys | |
sudo mkdir -p /mnt/mnt | |
sudo mkdir -p /mnt/tmp | |
sudo mkdir -p /mnt/boot | |
sync | |
ls -al /mnt | |
sudo umount /mnt | |
echo | |
echo Umount | |
echo | |
sudo losetup -d ${LOOP_DEV} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment