Skip to content

Commit e701b40

Browse files
committed
Enable to build custom Linux image
All Buildroot, BusyBox, and Linux configuration files are saved in the assets directory to allow someone to build on their own. The mk/external.mk functions has been updated to enable downloading via 'git clone' and verifying the downloaded files excluding the git-related files. The Linux kernel image and Buildroot version are controlled in mk/external.mk, when the LINUX_VERSION or BUILDROOT_VERSION changes, the new Linux kernel image and rootfs.cpio are built and pushed to the rv32emu-prebuilt repository, the user ELF executables and system image are identified by suffix 'ELF' and 'Linux-Image' at release of rv32emu-prebuilt repository. Additionally, a 'build-linux-image' make target has been introduced to simplify the cloning and automatic building process.
1 parent a6ecb0c commit e701b40

File tree

11 files changed

+3479
-12
lines changed

11 files changed

+3479
-12
lines changed

.github/workflows/build-artifact.yml

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ jobs:
2727
tests/quake/**
2828
tests/scimark2/**
2929
tests/*.c
30+
- name: Test file change of Linux image
31+
id: test-linux-image-version-change
32+
uses: tj-actions/changed-files@v45
33+
with:
34+
files: |
35+
mk/external.mk
3036
- name: Set alias
3137
id: has_changed_files
3238
run: |
@@ -35,8 +41,60 @@ jobs:
3541
else
3642
echo "has_changed_files=false" >> $GITHUB_OUTPUT
3743
fi
44+
if [[ ${{ steps.test-linux-image-version-change.outputs.any_modified }} == true ]]; then
45+
# Determine if the changes are from Buildroot or the Linux version (The Linux might have several patches, so also need to check the SHA value)
46+
echo -n $(git --no-pager diff HEAD^ HEAD | grep -e "+BUILDROOT_VERSION" -e "+LINUX_VERSION" -e "+LINUX_DATA_SHA1") >> linux-image-version-change
47+
if [[ -s linux-image-version-change ]]; then
48+
echo "has_changed_linux_image_version=true" >> $GITHUB_OUTPUT
49+
else
50+
echo "has_changed_linux_image_version=false" >> $GITHUB_OUTPUT
51+
fi
52+
else
53+
echo "has_changed_linux_image_version=false" >> $GITHUB_OUTPUT
54+
fi
3855
outputs:
3956
has_changed_files: ${{ steps.has_changed_files.outputs.has_changed_files }}
57+
has_changed_linux_image_version: ${{ steps.has_changed_files.outputs.has_changed_linux_image_version }}
58+
59+
build-linux-image-artifact:
60+
needs: [detect-file-change]
61+
if: ${{ needs.detect-file-change.outputs.has_changed_linux_image_version == 'true' || github.event_name == 'workflow_dispatch' }}
62+
runs-on: ubuntu-22.04
63+
steps:
64+
- name: Checkout repository
65+
uses: actions/checkout@v4
66+
with:
67+
submodules: 'true'
68+
- name: Install dependencies
69+
run: |
70+
sudo apt-get update -q -y
71+
sudo apt-get upgrade -q -y
72+
sudo apt-get install -q -y build-essential git
73+
- name: Build Linux image
74+
run: |
75+
make build-linux-image
76+
make artifact ENABLE_PREBUILT=0 ENABLE_SYSTEM=1
77+
mkdir -p /tmp/rv32emu-linux-image-prebuilt/linux-image
78+
mv build/linux-image/Image /tmp/rv32emu-linux-image-prebuilt/linux-image
79+
mv build/linux-image/rootfs.cpio /tmp/rv32emu-linux-image-prebuilt/linux-image
80+
mv build/sha1sum-linux-image /tmp
81+
- name: Create tarball
82+
run: |
83+
cd /tmp
84+
tar -zcvf rv32emu-linux-image-prebuilt.tar.gz rv32emu-linux-image-prebuilt
85+
- name: Create GitHub Release
86+
env:
87+
GH_TOKEN: ${{ secrets.RV32EMU_PREBUILT_TOKEN }}
88+
run: |
89+
RELEASE_TAG=$(date +'%Y.%m.%d'-Linux-Image)
90+
cd /tmp
91+
gh release create $RELEASE_TAG \
92+
--repo sysprog21/rv32emu-prebuilt \
93+
--title "$RELEASE_TAG""-nightly"
94+
gh release upload $RELEASE_TAG \
95+
rv32emu-linux-image-prebuilt.tar.gz \
96+
sha1sum-linux-image \
97+
--repo sysprog21/rv32emu-prebuilt
4098
4199
build-artifact:
42100
needs: [detect-file-change]
@@ -83,7 +141,7 @@ jobs:
83141
env:
84142
GH_TOKEN: ${{ secrets.RV32EMU_PREBUILT_TOKEN }}
85143
run: |
86-
RELEASE_TAG=$(date +'%Y.%m.%d')
144+
RELEASE_TAG=$(date +'%Y.%m.%d'-ELF)
87145
cd /tmp
88146
gh release create $RELEASE_TAG \
89147
--repo sysprog21/rv32emu-prebuilt \
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
BR2_riscv=y
2+
BR2_ARCH="riscv32"
3+
BR2_NORMALIZED_ARCH="riscv"
4+
BR2_ENDIAN="LITTLE"
5+
BR2_GCC_TARGET_ABI="ilp32"
6+
BR2_READELF_ARCH_NAME="RISC-V"
7+
BR2_RISCV_ISA_RVI=y
8+
BR2_RISCV_ISA_RVM=y
9+
BR2_RISCV_ISA_RVA=y
10+
# BR2_riscv_g is not set
11+
BR2_riscv_custom=y
12+
BR2_RISCV_ISA_CUSTOM_RVM=y
13+
BR2_RISCV_ISA_CUSTOM_RVA=y
14+
# BR2_RISCV_ISA_CUSTOM_RVF is not set
15+
# BR2_RISCV_ISA_CUSTOM_RVC is not set
16+
BR2_RISCV_32=y
17+
# BR2_RISCV_64 is not set
18+
BR2_RISCV_ABI_ILP32=y
19+
BR2_BINFMT_ELF=y
20+
BR2_TOOLCHAIN_BUILDROOT_VENDOR="buildroot"
21+
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
22+
BR2_TOOLCHAIN_BUILDROOT_LIBC="glibc"
23+
# BR2_TOOLCHAIN_BUILDROOT_CXX is not set
24+
BR2_KERNEL_HEADERS_6_1=y
25+
BR2_BINUTILS_VERSION_2_42_X=y
26+
# BR2_BINUTILS_GPROFNG is not set
27+
BR2_GCC_VERSION_14_X=y
28+
BR2_EXTRA_GCC_CONFIG_OPTIONS="--enable-softfloat"
29+
BR2_TOOLCHAIN_HEADERS_AT_LEAST="6.1"
30+
BR2_TOOLCHAIN_GCC_AT_LEAST_14=y
31+
BR2_TOOLCHAIN_GCC_AT_LEAST="14"
32+
BR2_SSP_NONE=y
33+
# BR2_SSP_REGULAR is not set
34+
# BR2_SSP_STRONG is not set
35+
BR2_RELRO_NONE=y
36+
# BR2_RELRO_PARTIAL is not set
37+
# BR2_RELRO_FULL is not set
38+
BR2_FORTIFY_SOURCE_1=y
39+
# BR2_PACKAGE_URANDOM_SCRIPTS is not set
40+
BR2_TARGET_ROOTFS_CPIO=y
41+
BR2_TARGET_ROOTFS_CPIO_FULL=y
42+
# BR2_TARGET_ROOTFS_CPIO_DRACUT is not set
43+
BR2_TARGET_ROOTFS_CPIO_NONE=y
44+
# BR2_TARGET_ROOTFS_TAR is not set
45+
BR2_PACKAGE_BUSYBOX_CONFIG="busybox.config"
46+
BR2_PACKAGE_COREMARK=y
47+
BR2_PACKAGE_DHRYSTONE=y

0 commit comments

Comments
 (0)