Created
March 9, 2021 09:15
-
-
Save holmesconan/ef6e6b2e488087260d0564f5b24240d0 to your computer and use it in GitHub Desktop.
Build AOSP for Raspberry Pi 4 Under WSL2/Ubuntu 20.04
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/sh | |
sudo apt install -y \ | |
build-essential \ | |
gcc-arm-linux-gnueabihf \ | |
libssl-dev \ | |
flex \ | |
bison \ | |
python-mako \ | |
libncurses5 \ | |
libncurses5-dev \ | |
kpartx \ | |
curl \ | |
git |
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 | |
mkdir -p ~/bin | |
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo | |
chmod a+x ~/bin/repo | |
echo Please add `$HOME/bin` to your $PATH variable |
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 | |
case $1 in | |
# Android 10 | |
arpi-10) | |
# For Chinese | |
#repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-10.0.0_r41 | |
# For others | |
repo init -u https://android.googlesource.com/platform/manifest -b android-10.0.0_r41 | |
git clone https://github.com/android-rpi/local_manifests .repo/local_manifests -b arpi-10 | |
;; | |
# Android 11 | |
arpi-11) | |
# For Chinese | |
#repo init -u https://mirrors.tuna.tsinghua.edu.cn/git/AOSP/platform/manifest -b android-11.0.0_r33 | |
# For others | |
repo init -u https://android.googlesource.com/platform/manifest -b android-11.0.0_r33 | |
git clone https://github.com/android-rpi/local_manifests .repo/local_manifests -b arpi-11 | |
;; | |
*) | |
echo Usage $0 <arpi-10|arpi-11> | |
;; | |
esac | |
repo sync |
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/sh | |
export ARCH=arm | |
export CROSS_COMPILE=arm-linux-gnueabihf- | |
cd kernel/arpi | |
scripts/kconfig/merge_config.sh arch/arm/configs/bcm2711_defconfig kernel/configs/android-base.config kernel/configs/android-recommended.config | |
make zImage | |
make dtbs |
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 | |
source build/envsetup.sh | |
lunch rpi4-eng | |
make ramdisk systemimage vendorimage |
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 | |
DATE=`date +%Y%m%d` | |
IMGNAME=android-10-$DATE-rpi4.img | |
IMGSIZE=4 | |
#OUTDIR=${ANDROID_PRODUCT_OUT:="../out/target/product/rpi4"} | |
OUTDIR="out/target/product/rpi4" | |
if [ `id -u` != 0 ]; then | |
echo "Must be root to run script!" | |
exit | |
fi | |
if [ -f $IMGNAME ]; then | |
echo "File $IMGNAME already exists!" | |
else | |
echo "Creating image file $IMGNAME..." | |
dd if=/dev/zero of=$IMGNAME bs=1M count=$(echo "$IMGSIZE*1024" | bc) | |
sync | |
echo "Creating partitions..." | |
( | |
echo o | |
echo n | |
echo p | |
echo 1 | |
echo | |
echo +128M | |
echo n | |
echo p | |
echo 2 | |
echo | |
echo +1536M | |
echo n | |
echo p | |
echo 3 | |
echo | |
echo +256M | |
echo n | |
echo p | |
echo | |
echo | |
echo t | |
echo 1 | |
echo c | |
echo a | |
echo 1 | |
echo w | |
) | fdisk $IMGNAME | |
sync | |
LOOPDEV=`kpartx -av $IMGNAME | awk 'NR==1{ sub(/p[0-9]$/, "", $3); print $3 }'` | |
sync | |
if [ -z "$LOOPDEV" ]; then | |
echo "Unable to find loop device!" | |
kpartx -d $IMGNAME | |
exit | |
fi | |
echo "Image mounted as $LOOPDEV" | |
sleep 5 | |
mkfs.fat -F 32 /dev/mapper/${LOOPDEV}p1 -n boot | |
mkfs.ext4 /dev/mapper/${LOOPDEV}p2 -L system | |
mkfs.ext4 /dev/mapper/${LOOPDEV}p3 -L vendor | |
mkfs.ext4 /dev/mapper/${LOOPDEV}p4 -L userdata | |
resize2fs /dev/mapper/${LOOPDEV}p4 1343228 | |
echo "Copying system..." | |
dd if=$OUTDIR/system.img of=/dev/mapper/${LOOPDEV}p2 bs=1M | |
echo "Copying vendor..." | |
dd if=$OUTDIR/vendor.img of=/dev/mapper/${LOOPDEV}p3 bs=1M | |
echo "Copying boot..." | |
mkdir -p sdcard/boot | |
sync | |
mount /dev/mapper/${LOOPDEV}p1 sdcard/boot | |
sync | |
mkdir -p sdcard/boot/overlays | |
cp device/arpi/rpi4/boot/* sdcard/boot/ | |
cp $OUTDIR/ramdisk.img sdcard/boot | |
cp kernel/arpi/arch/arm/boot/zImage sdcard/boot/ | |
cp kernel/arpi/arch/arm/boot/dts/bcm2711-rpi-4-b.dtb sdcard/boot | |
cp kernel/arpi/arch/arm/boot/dts//overlays/*.dtbo sdcard/boot/overlays | |
cp kernel/arpi/arch/arm/boot/dts//overlays/README sdcard/boot/overlays | |
sync | |
umount /dev/mapper/${LOOPDEV}p1 | |
rm -rf sdcard | |
kpartx -d $IMGNAME | |
sync | |
echo "Done, created $IMGNAME!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Place all scripts into
$AOSP_DIR/scripts
, then using: