From d6719fd49f6394bbd91f90384b5f5a6a5baaad36 Mon Sep 17 00:00:00 2001 From: Takumi Sueda Date: Fri, 28 Jul 2023 22:18:52 +0900 Subject: [PATCH] Enhance build scripts to generate a buildroot SD image --- Makefile | 15 ++++++++++++--- image/build_image.sh | 13 ++++++++----- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 3cc25d3..a7ea1ed 100644 --- a/Makefile +++ b/Makefile @@ -135,7 +135,6 @@ lilobuild: liloclean: make -C ./brainlilo clean - brainux: @if [ "$(shell uname)" != "Linux" ]; then \ echo "Debootstrap is only available in Linux!"; \ @@ -155,11 +154,21 @@ brainux: sudo rm brainux/setup_brainux.sh sudo ./os-brainux/override.sh ./os-brainux/override ./brainux +buildroot_rootfs: + make -C buildroot brain_imx28_defconfig + make -C buildroot -j 12 + sudo mkdir -p buildroot_rootfs + sudo tar -C ./buildroot_rootfs -xf buildroot/output/images/rootfs.tar + image/sd.img: clean_work - ./image/build_image.sh + ./image/build_image.sh brainux sd.img 3072 image/sd_x1.img: clean_work - ./image/build_image_x1.sh + ./image/build_image_x1.sh brainux sd_x1.img 3072 + +image/sd_buildroot.img: clean_work + ./image/build_image.sh buildroot_rootfs sd_buildroot.img 128 + .PHONY: clean_work: diff --git a/image/build_image.sh b/image/build_image.sh index a3f12f0..9cb4f33 100755 --- a/image/build_image.sh +++ b/image/build_image.sh @@ -5,7 +5,10 @@ JOBS=$(nproc) REPO=$(git rev-parse --show-toplevel) WORK=${REPO}/image/work LINUX=${REPO}/linux-brain -IMG=${REPO}/image/sd.img +ROOTFS=$1 +IMG_NAME=$2 +IMG=${REPO}/image/${IMG_NAME} +SIZE_M=$3 export CROSS_COMPILE=arm-linux-gnueabi- mkdir -p ${WORK} @@ -34,7 +37,7 @@ for i in "a7200" "sh1" "sh2" "sh3" "sh4" "sh5" "sh6" "sh7"; do esac done -dd if=/dev/zero of=${IMG} bs=1M count=3072 +dd if=/dev/zero of=${IMG} bs=1M count=${SIZE_M} START1=2048 SECTORS1=$((1024 * 1024 * 64 / 512)) @@ -49,7 +52,7 @@ sfdisk ${IMG} < ${WORK}/part.sfdisk sudo kpartx -av ${IMG} -LOOPDEV=$(losetup -l | grep sd.img | grep -o 'loop.' | tail -n 1) +LOOPDEV=$(losetup -l | grep ${IMG_NAME} | grep -o 'loop.' | tail -n 1) sudo mkfs.fat -n boot -F32 -v -I /dev/mapper/${LOOPDEV}p1 sudo mkfs.ext4 -L rootfs /dev/mapper/${LOOPDEV}p2 @@ -71,13 +74,13 @@ sudo touch "${LILO}/index.din" sudo touch "${LILO}/AppMain.cfg" sudo cp ${REPO}/brainlilo/*.dll "${LILO}/" sudo cp ${REPO}/brainlilo/BrainLILO.exe "${LILO}/AppMain_.exe" -gzip -d ${REPO}/image/exeopener.exe.gz +gzip -cd ${REPO}/image/exeopener.exe.gz > ${REPO}/image/exeopener.exe sudo cp ${REPO}/image/exeopener.exe "${LILO}/AppMain.exe" sudo mkdir -p ${WORK}/p1/loader sudo cp ${WORK}/lilobin/*.bin ${WORK}/p1/loader/ -sudo cp -ra ${REPO}/brainux/* ${WORK}/p2/ +sudo cp -ra ${REPO}/${ROOTFS}/* ${WORK}/p2/ sudo umount ${WORK}/p1 ${WORK}/p2 sudo kpartx -d ${IMG}