Skip to content

Commit e20fadb

Browse files
committed
Add GitHub CI
1 parent 2de9ed8 commit e20fadb

File tree

3 files changed

+264
-0
lines changed

3 files changed

+264
-0
lines changed

.github/workflows/build.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: Build Kernel + DTB + initramfs + DFU Image (N31)
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
build-initramfs:
9+
runs-on: ubuntu-24.04
10+
outputs:
11+
artifact-path: freemyipod/initramfs.cpio.gz
12+
steps:
13+
- name: Checkout source
14+
uses: actions/checkout@v6
15+
16+
- name: Install system dependencies
17+
run: |
18+
sudo apt-get update
19+
sudo apt-get install -y qemu-user-static
20+
21+
- name: Cache initramfs
22+
id: cache
23+
uses: actions/cache@v5
24+
with:
25+
path: freemyipod/initramfs.cpio.gz
26+
key: initramfs-${{ hashFiles('freemyipod/build-initramfs.sh') }}
27+
28+
- name: Build initramfs if cache miss
29+
if: steps.cache.outputs.cache-hit != 'true'
30+
run: |
31+
chmod +x freemyipod/build-initramfs.sh
32+
freemyipod/build-initramfs.sh
33+
echo "Initramfs built successfully at freemyipod/initramfs.cpio.gz"
34+
35+
- name: Upload initramfs artifact
36+
uses: actions/upload-artifact@v7
37+
with:
38+
name: initramfs
39+
path: freemyipod/initramfs.cpio.gz
40+
41+
build-kernel:
42+
runs-on: ubuntu-24.04
43+
outputs:
44+
zimage-path: linux/arch/arm/boot/zImage
45+
dtb-path: linux/arch/arm/boot/dts/samsung/s5l8740-n31.dtb
46+
steps:
47+
- name: Checkout source
48+
uses: actions/checkout@v6
49+
50+
- name: Install system dependencies
51+
run: |
52+
sudo apt-get update
53+
sudo apt-get install -y \
54+
gcc-arm-none-eabi \
55+
make \
56+
bc \
57+
bison \
58+
flex \
59+
libssl-dev \
60+
libncurses-dev \
61+
device-tree-compiler \
62+
python3 \
63+
python3-pip
64+
65+
- name: Install Python dependencies for dtbs_check
66+
run: |
67+
pip3 install --upgrade pip
68+
pip3 install dtschema yamllint
69+
70+
- name: Configure kernel
71+
run: |
72+
make ARCH=arm apple_n31_defconfig
73+
74+
- name: Build kernel
75+
run: |
76+
make ARCH=arm CROSS_COMPILE=arm-none-eabi- -j $(nproc) dtbs_check dtbs zImage
77+
78+
- name: Copy kernel and DTB to /freemyipod
79+
run: |
80+
cp arch/arm/boot/zImage freemyipod/zImage
81+
cp arch/arm/boot/dts/samsung/s5l8740-n31.dtb freemyipod/s5l8740-n31.dtb
82+
83+
- name: Upload kernel artifacts
84+
uses: actions/upload-artifact@v7
85+
with:
86+
name: kernel
87+
path: |
88+
freemyipod/zImage
89+
freemyipod/s5l8740-n31.dtb
90+
91+
build-final-image:
92+
runs-on: ubuntu-24.04
93+
needs:
94+
- build-initramfs
95+
- build-kernel
96+
steps:
97+
- name: Checkout source
98+
uses: actions/checkout@v6
99+
100+
- name: Download initramfs artifact
101+
uses: actions/download-artifact@v3
102+
with:
103+
name: initramfs
104+
path: freemyipod
105+
106+
- name: Download kernel artifacts
107+
uses: actions/download-artifact@v3
108+
with:
109+
name: kernel
110+
path: freemyipod
111+
112+
- name: Install mkimage and dtc
113+
run: |
114+
sudo apt-get update
115+
sudo apt-get install -y u-boot-tools device-tree-compiler
116+
117+
- name: Build final image
118+
working-directory: freemyipod
119+
run: |
120+
mkimage -f kernel_fdt.its kernel_fdt.itb
121+
122+
- name: Upload final image
123+
uses: actions/upload-artifact@v7
124+
with:
125+
name: dfu-image
126+
path: freemyipod/kernel_fdt.itb

freemyipod/build-initramfs.sh

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
3+
set -eEx
4+
5+
ARCH=armv7
6+
VER=3.23.2
7+
MAJOR=v${VER%.*}
8+
TAR=alpine-minirootfs-${VER}-${ARCH}.tar.gz
9+
URL=https://dl-cdn.alpinelinux.org/alpine/${MAJOR}/releases/${ARCH}/${TAR}
10+
11+
wget -c $URL
12+
WORK_DIR=$(mktemp -d)
13+
trap 'rm -rf "$WORK_DIR"' EXIT
14+
tar xf ${TAR} -C $WORK_DIR
15+
16+
# create minimal /init for initramfs
17+
cat >"$WORK_DIR/init" <<'EOF'
18+
#!/bin/sh
19+
20+
echo "initramfs: starting init"
21+
exec /sbin/init
22+
EOF
23+
24+
chmod +x "$WORK_DIR/init"
25+
26+
# setup networking
27+
echo 'nameserver 8.8.8.8' > "$WORK_DIR/etc/resolv.conf"
28+
echo nano7g > "$WORK_DIR/etc/hostname"
29+
cat >"$WORK_DIR/etc/network/interfaces" <<'EOF'
30+
auto lo
31+
iface lo inet
32+
33+
auto usb0
34+
iface usb0 inet static
35+
address 10.0.0.2
36+
netmask 255.255.255.0
37+
gateway 10.0.0.1
38+
EOF
39+
40+
# setup the rootfs
41+
cp $(which qemu-arm-static) $WORK_DIR
42+
# install packages
43+
sudo systemd-nspawn -D $WORK_DIR /qemu-arm-static /sbin/apk add dropbear openrc haveged chrony zlib evtest i2c-tools
44+
45+
sudo systemd-nspawn -D $WORK_DIR /qemu-arm-static /bin/sh -c "export PATH=
46+
source /etc/profile
47+
48+
# setup services
49+
for s in devfs dmesg root
50+
do
51+
rc-update add \$s sysinit
52+
done
53+
54+
for s in chronyd bootmisc hostname sysctl haveged
55+
do
56+
rc-update add \$s boot
57+
done
58+
59+
rc-update add networking
60+
rc-update add dropbear
61+
62+
# pre-generate dropbear host keys
63+
for algo in rsa ecdsa ed25519
64+
do dropbearkey -t \$algo -f /etc/dropbear/dropbear_\${algo}_host_key; done
65+
66+
# set root password
67+
echo -ne 'alpine\nalpine\n' | passwd root
68+
69+
# mount sysfs
70+
mount -t sysfs sysfs /sys
71+
"
72+
73+
rm -rf "$WORK_DIR/qemu-arm-static"
74+
75+
# make the initramfs
76+
(
77+
find $WORK_DIR -printf "%P\0" |
78+
sudo cpio --directory=$WORK_DIR --null --create --verbose --owner root:root --format=newc |
79+
gzip -9
80+
) > initramfs.cpio.gz

freemyipod/kernel_fdt.its

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/dts-v1/;
2+
3+
/ {
4+
description = "Single Linux kernel with FDT and initramfs";
5+
#address-cells = <1>;
6+
7+
images {
8+
/* Linux kernel */
9+
kernel {
10+
description = "Linux kernel";
11+
data = /incbin/("zImage");
12+
type = "kernel";
13+
arch = "arm";
14+
os = "linux";
15+
compression = "none";
16+
load = <0x08000000>;
17+
entry = <0x08000000>;
18+
hash {
19+
algo = "crc32";
20+
};
21+
};
22+
23+
/* Flattened Device Tree */
24+
fdt {
25+
description = "Flattened Device Tree blob";
26+
data = /incbin/("s5l8740-n31.dtb");
27+
type = "flat_dt";
28+
arch = "arm";
29+
compression = "none";
30+
hash {
31+
algo = "crc32";
32+
};
33+
};
34+
35+
/* Gzipped initramfs */
36+
ramdisk {
37+
description = "Gzipped Initramfs";
38+
data = /incbin/("initramfs.cpio.gz");
39+
type = "ramdisk";
40+
arch = "arm";
41+
os = "linux";
42+
compression = "gzip";
43+
hash {
44+
algo = "crc32";
45+
};
46+
};
47+
};
48+
49+
configurations {
50+
default = "conf-1";
51+
conf-1 {
52+
description = "Boot Linux kernel with FDT and initramfs";
53+
kernel = "kernel";
54+
fdt = "fdt";
55+
ramdisk = "ramdisk";
56+
};
57+
};
58+
};

0 commit comments

Comments
 (0)