2021-02-20 04:29:49 +09:00
|
|
|
#!/bin/bash
|
|
|
|
set -uex -o pipefail
|
|
|
|
|
|
|
|
JOBS=$(nproc)
|
|
|
|
REPO=$(git rev-parse --show-toplevel)
|
|
|
|
WORK=${REPO}/image/work
|
|
|
|
LINUX=${REPO}/linux-brain
|
|
|
|
IMG=${REPO}/image/sd.img
|
2022-02-19 02:20:01 +09:00
|
|
|
export CROSS_COMPILE=arm-linux-gnueabi-
|
2021-02-20 04:29:49 +09:00
|
|
|
|
|
|
|
mkdir -p ${WORK}
|
2022-05-06 02:18:40 +09:00
|
|
|
mkdir -p ${WORK}/lilobin
|
2021-02-20 04:29:49 +09:00
|
|
|
|
2022-11-23 00:48:56 +09:00
|
|
|
for i in "a7200" "sh1" "sh2" "sh3" "sh4" "sh5" "sh6" "sh7"; do
|
2022-05-06 02:18:40 +09:00
|
|
|
NUM=$(echo $i | sed -E 's/sh//g')
|
|
|
|
|
|
|
|
make -C ${REPO}/u-boot-brain distclean pw${i}_defconfig
|
2021-02-20 04:29:49 +09:00
|
|
|
make -j${JOBS} -C ${REPO}/u-boot-brain u-boot.bin
|
|
|
|
|
|
|
|
case $i in
|
2022-11-23 00:48:56 +09:00
|
|
|
"a7200")
|
2022-05-06 02:18:40 +09:00
|
|
|
mv ${REPO}/u-boot-brain/u-boot.bin ${WORK}/lilobin/gen2.bin;;
|
|
|
|
"sh1" | "sh2" | "sh3")
|
|
|
|
mv ${REPO}/u-boot-brain/u-boot.bin ${WORK}/lilobin/gen3_${NUM}.bin;;
|
|
|
|
"sh4" | "sh5" | "sh6" | "sh7")
|
|
|
|
mv ${REPO}/u-boot-brain/u-boot.bin ${WORK}/lilobin/gen3_${NUM}.bin;;
|
2021-02-20 04:29:49 +09:00
|
|
|
*)
|
|
|
|
echo "WTF: $i"
|
|
|
|
exit 1;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
2021-02-23 23:36:22 +09:00
|
|
|
dd if=/dev/zero of=${IMG} bs=1M count=3072
|
2021-02-20 04:29:49 +09:00
|
|
|
|
|
|
|
START1=2048
|
|
|
|
SECTORS1=$((1024 * 1024 * 64 / 512))
|
|
|
|
START2=$((2048 + ${SECTORS1}))
|
|
|
|
|
|
|
|
cat <<EOF > ${WORK}/part.sfdisk
|
|
|
|
${IMG}1 : start=${START1}, size=${SECTORS1}, type=b
|
|
|
|
${IMG}2 : start=${START2}, type=83
|
|
|
|
EOF
|
|
|
|
|
|
|
|
sfdisk ${IMG} < ${WORK}/part.sfdisk
|
|
|
|
|
|
|
|
sudo kpartx -av ${IMG}
|
|
|
|
|
2021-05-05 22:05:49 +09:00
|
|
|
LOOPDEV=$(losetup -l | grep sd.img | grep -o 'loop.' | tail -n 1)
|
2021-02-20 04:29:49 +09:00
|
|
|
|
2022-07-11 19:18:20 +09:00
|
|
|
sudo mkfs.fat -n boot -F32 -v -I /dev/mapper/${LOOPDEV}p1
|
|
|
|
sudo mkfs.ext4 -L rootfs /dev/mapper/${LOOPDEV}p2
|
2021-02-20 04:29:49 +09:00
|
|
|
|
|
|
|
mkdir -p ${WORK}/p1 ${WORK}/p2
|
2022-05-06 02:18:40 +09:00
|
|
|
sudo mount -o utf8=true /dev/mapper/${LOOPDEV}p1 ${WORK}/p1
|
2021-02-20 04:29:49 +09:00
|
|
|
sudo mount /dev/mapper/${LOOPDEV}p2 ${WORK}/p2
|
|
|
|
|
|
|
|
sudo cp ${LINUX}/arch/arm/boot/zImage ${WORK}/p1/
|
2022-05-06 02:18:40 +09:00
|
|
|
sudo cp ${LINUX}/arch/arm/boot/dts/imx28-pw*.dtb ${WORK}/p1/
|
2021-02-20 04:29:49 +09:00
|
|
|
|
2022-05-06 02:18:40 +09:00
|
|
|
make -C ${REPO}/brainlilo
|
|
|
|
|
|
|
|
LILO="${WORK}/p1/アプリ/Launch Linux"
|
|
|
|
sudo mkdir -p "${LILO}"
|
|
|
|
sudo touch "${LILO}/index.din"
|
|
|
|
sudo touch "${LILO}/AppMain.cfg"
|
|
|
|
sudo cp ${REPO}/brainlilo/*.dll "${LILO}/"
|
2022-05-30 14:38:58 +09:00
|
|
|
sudo cp ${REPO}/brainlilo/BrainLILO.exe "${LILO}/AppMain_.exe"
|
|
|
|
gzip -d ${REPO}/image/exeopener.exe.gz
|
|
|
|
sudo cp ${REPO}/image/exeopener.exe "${LILO}/AppMain.exe"
|
2022-05-06 02:18:40 +09:00
|
|
|
|
|
|
|
sudo mkdir -p ${WORK}/p1/loader
|
|
|
|
sudo cp ${WORK}/lilobin/*.bin ${WORK}/p1/loader/
|
|
|
|
|
2021-02-20 04:29:49 +09:00
|
|
|
sudo cp -ra ${REPO}/brainux/* ${WORK}/p2/
|
|
|
|
|
|
|
|
sudo umount ${WORK}/p1 ${WORK}/p2
|
|
|
|
sudo kpartx -d ${IMG}
|
|
|
|
|
|
|
|
rmdir ${WORK}/p1 ${WORK}/p2
|
|
|
|
|