Skip to content

Commit

Permalink
Merge pull request #34 from nekorouter/main
Browse files Browse the repository at this point in the history
Enable building image on Debian
  • Loading branch information
sehraf authored Nov 6, 2024
2 parents 9fa3f9c + 4572a37 commit 8195227
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
4 changes: 3 additions & 1 deletion 1_compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ patch_config() {
./scripts/config --file "../${DIR}-build/.config" "$_OP" "$key"
}

for DEP in riscv64-linux-gnu-gcc swig cpio; do
DEP_LIST="DEP_LIST_$ID"
eval DEP_LIST=\$$DEP_LIST
for DEP in $DEP_LIST; do
check_deps ${DEP}
done

Expand Down
8 changes: 7 additions & 1 deletion 2_create_sd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ set -e

. ./consts.sh

# Dependency list
DEP_LIST_arch="arch-install-scripts qemu-user-static qemu-user-static-binfmt"
DEP_LIST_debian="arch-install-scripts qemu-user-static"

check_root_fs() {
if [ ! -f "${ROOT_FS}" ]; then
wget "${ROOT_FS_DL}"
Expand Down Expand Up @@ -44,7 +48,9 @@ DEVICE=${1}

if [ "${USE_CHROOT}" != 0 ]; then
# check_deps for arch-chroot on non RISC-V host
for DEP in arch-install-scripts qemu-user-static qemu-user-static-binfmt; do
DEP_LIST="DEP_LIST_$ID"
eval DEP_LIST=\$$DEP_LIST
for DEP in $DEP_LIST; do
check_deps ${DEP}
done
fi
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ There are multiple sources for an Archlinux image:
- WiFi driver (rtl8723ds) based on https://github.com/lwfinger/rtl8723ds
- RootFS based on https://archriscv.felixc.at (root password is ~~`sifive`~~ `archriscv`)

## How to build
## How to build on ArchLinux
1. Install requirements: `pacman -Sy riscv64-linux-gnu-gcc swig cpio python3 python-setuptools base-devel bc`
1. If you want to `chroot` into the RISC-V image, you also need `arch-install-scripts qemu-user-static qemu-user-static-binfmt`
1. Edit `consts.sh` to your needs. For example, you may want to select a [different DTB](https://github.com/sehraf/riscv-arch-image-builder/blob/5c450da98d578617781ae13f9d2b0850a61b21c4/consts.sh#L22) for a different board variant.
1. Run `1_compile.sh` which compiles everything into the `output` folder.
1. Run `2_create_sd.sh /dev/<device>` to flash everything on the SD card.
1. Configure your Archlinux :rocket:

## How to build on Debian
1. Install requirements: `apt install -y gcc-riscv64-linux-gnu bison flex python3-dev libssl-dev swig cpio python3-setuptools build-essential bc`
1. If you want to `chroot` into the RISC-V image, you also need `arch-install-scripts qemu-user-static`
1. Edit `consts.sh` to your needs. For example, you may want to select a [different DTB](https://github.com/sehraf/riscv-arch-image-builder/blob/5c450da98d578617781ae13f9d2b0850a61b21c4/consts.sh#L22) for a different board variant.
1. Run `1_compile.sh` which compiles everything into the `output` folder.
1. Run `2_create_sd.sh /dev/<device>` to flash everything on the SD card.
1. Configure your Archlinux :rocket:

## Using loop image file instead of a SD card
Simply loop it using `sudo losetup -f -P <file>` and then use `/dev/loopX` as the target device.

Expand Down
29 changes: 26 additions & 3 deletions consts.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
#!/usr/bin/sh

if [ -f /etc/os-release ]; then
. /etc/os-release
fi

# Dependency list
DEP_LIST_arch="riscv64-linux-gnu-gcc swig cpio"
DEP_LIST_debian="gcc-riscv64-linux-gnu bison flex python3-dev libssl-dev"

export CROSS_COMPILE='riscv64-linux-gnu-'
export ARCH='riscv'
PWD="$(pwd)"
Expand Down Expand Up @@ -58,10 +67,24 @@ export IGNORE_COMMITS=0
export DEBUG='n'

check_deps() {
if ! pacman -Qi "${1}" >/dev/null; then
echo "Please install '${1}'"
case $ID in
arch)
if ! pacman -Qi "${1}" >/dev/null; then
echo "Please install '${1}'"
exit 1
fi
;;
debian)
if ! dpkg -l "${1}" >/dev/null; then
echo "Please install '${1}'"
exit 1
fi
;;
*)
echo "This script is running on not supported distro!"
exit 1
fi
;;
esac
}

if [ -n "${CI_BUILD}" ]; then
Expand Down

0 comments on commit 8195227

Please sign in to comment.