Skip to content

Commit

Permalink
First major version
Browse files Browse the repository at this point in the history
This is probably still in testing
  • Loading branch information
kiteretro committed Jan 21, 2018
1 parent b30fbb8 commit ea909a8
Show file tree
Hide file tree
Showing 63 changed files with 4,517 additions and 0 deletions.
18 changes: 18 additions & 0 deletions build/README.md
@@ -0,0 +1,18 @@
# Get pre-compiled kernel
https://github.com/geebles/rpi-precompiled-kernels

# Build
```
cd Circuit-Sword/build
chmod +x upgrade-kernel.sh build-image.sh
wget https://github.com/RetroPie/RetroPie-Setup/releases/download/4.3/retropie-4.3-rpi2_rpi3.img.gz
gunzip retropie-4.3-rpi2_rpi3.img.gz
sudo ./upgrade-kernel.sh YES retropie-4.3-rpi2_rpi3.img pi_4.14.14-v7+.zip
sudo ./build-image.sh YES retropie-4.3-rpi2_rpi3_pi_4.14.14-v7+.img
```

Burn resulting .img to SD and boot!
142 changes: 142 additions & 0 deletions build/build-image.sh
@@ -0,0 +1,142 @@
#!/bin/bash

#
# This file originates from Kite's Circuit Sword control board project.
# Author: Kite (Giles Burgess)
#
# THIS HEADER MUST REMAIN WITH THIS FILE AT ALL TIMES
#
# This firmware is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This firmware is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this repo. If not, see <http://www.gnu.org/licenses/>.
#

if [ "$EUID" -ne 0 ]
then echo "Please run as root (sudo)"
exit 1
fi

if [ $# != 2 ] && [ $# != 3 ] ; then
echo "Usage: ./<cmd> YES <image.img> [branch]"
exit 1
fi

#####################################################################
# Vars

if [[ $2 != "" ]] ; then
IMG=$2
fi

if [[ $3 != "" ]] ; then
BRANCH=$3
else
BRANCH="master"
fi

BUILD="CSO_CM3_"$(date +"%Y%m%d-%H%M%S")
GITHUBPROJECT="Circuit-Sword"
GITHUBURL="https://github.com/geebles/$GITHUBPROJECT"
PIHOMEDIR="$DEST/home/pi"
BINDIR="$PIHOMEDIR/$GITHUBPROJECT"
USER="pi"

MOUNTFAT32="/mnt/fat32"
MOUNTEXT4="/mnt/ext4"

#####################################################################
# Functions
execute() { #STRING
if [ $# != 1 ] ; then
echo "ERROR: No args passed"
exit 1
fi
cmd=$1

echo "[*] EXECUTE: [$cmd]"
eval "$cmd"
ret=$?

if [ $ret != 0 ] ; then
echo "ERROR: Command exited with [$ret]"
exit 1
fi

return 0
}

exists() { #FILE
if [ $# != 1 ] ; then
echo "ERROR: No args passed"
exit 1
fi

file=$1

if [ -f $file ]; then
echo "[i] FILE: [$file] exists."
return 0
else
echo "[i] FILE: [$file] does not exist."
return 1
fi
}

#####################################################################
# LOGIC!
echo "BUILDING.."

# Sanity check IMG
if ! exists $IMG ; then
echo "ERROR: IMG [$IMG] doesn't exist"
exit 1
fi

OUTFILE=$(basename $IMG .img)"_$BUILD.img"
ZIPFILE=$(basename $IMG .img)"_$BUILD.zip"

# Sanity check OUTFILE
if exists $OUTFILE ; then
echo "ERROR: OUTFILE [$OUTFILE] exists! Can't create new image"
exit 1
fi

# Check the mounted dir is clean
MNTDIRCLEANCOUNT=$(ls $MOUNTFAT32 | wc -l)
if [ $MNTDIRCLEANCOUNT != 0 ] ; then
echo "ERROR: Mount dir [$MOUNTFAT32] is not empty [$MNTDIRCLEANCOUNT], perhaps something is mounted on it?"
exit 1
fi

# Check the mounted dir is clean
MNTDIRCLEANCOUNT=$(ls $MOUNTEXT4 | wc -l)
if [ $MNTDIRCLEANCOUNT != 0 ] ; then
echo "ERROR: Mount dir [$MOUNTEXT4] is not empty [$MNTDIRCLEANCOUNT], perhaps something is mounted on it?"
exit 1
fi

# Copy img to new + name
execute "cp $IMG $OUTFILE"

# Mount
execute "mount -o loop,offset=4194304 $OUTFILE $MOUNTFAT32"
execute "mount -o loop,offset=63963136 $OUTFILE $MOUNTEXT4"

# Install
execute "../install.sh YES $BRANCH $MOUNTFAT32 $MOUNTEXT4"

# Unmount
execute "umount $MOUNTFAT32"
execute "umount $MOUNTEXT4"

# DONE
echo "SUCCESS: Image [$OUTFILE] has been built!"
52 changes: 52 additions & 0 deletions build/build-kernel.txt
@@ -0,0 +1,52 @@
https://www.raspberrypi.org/documentation/linux/kernel/building.md
https://www.raspberrypi.org/documentation/linux/kernel/configuring.md

sudo apt-get -y update
sudo apt-get -y install git bc libncurses5-dev
git clone --depth=1 https://github.com/raspberrypi/linux --branch rpi-4.14.y

cd linux
KERNEL=kernel7
make bcm2709_defconfig

# <enable rl8723bs>
# make menuconfig
# Device Drivers -> Staging drivers -> Realtek RTL8723BS SDIO..
sed -i 's/# CONFIG_RTL8723BS is not set/CONFIG_RTL8723BS=m/' .config

make -j4 zImage modules dtbs

mkdir ../modules
sudo make INSTALL_MOD_PATH=../modules/ modules_install

rm -f ../modules/lib/modules/*/build
rm -f ../modules/lib/modules/*/source

mkdir ../pi
mkdir ../pi/overlays

cp arch/arm/boot/dts/*.dtb ../pi/
cp arch/arm/boot/dts/overlays/*.dtb* ../pi/overlays/
cp arch/arm/boot/dts/overlays/README ../pi/overlays/
cp arch/arm/boot/zImage ../pi/$KERNEL.img

sudo mkdir -p /mnt/fat32
sudo mkdir -p /mnt/ext4

wget https://github.com/RetroPie/RetroPie-Setup/releases/download/4.3/retropie-4.3-rpi2_rpi3.img.gz
gunzip retropie-4.3-rpi2_rpi3.img.gz
FILE=retropie-4.3-rpi2_rpi3.img

sudo mount -o loop,offset=4194304 $FILE /mnt/fat32
sudo mount -o loop,offset=63963136 $FILE /mnt/ext4

sudo cp mnt/fat32/$KERNEL.img /mnt/fat32/$KERNEL-backup.img
sudo cp ../pi/$KERNEL.img /mnt/fat32/$KERNEL.img
sudo cp ../pi/*.dtb /mnt/fat32/
sudo cp ../pi/overlays/*.dtb* /mnt/fat32/overlays/
sudo cp ../pi/overlays/README /mnt/fat32/overlays/

sudo rsync -avh ../modules/ /mnt/ext4/

sudo umount /mnt/fat32
sudo umount /mnt/ext4

0 comments on commit ea909a8

Please sign in to comment.