update build scripts for multi-distro compatibility, update script descriptions in README and add .gitignore

This commit is contained in:
DefenderOfHyrule 2026-01-30 12:19:06 +01:00
parent 6ac58738a8
commit b23720b976
4 changed files with 84 additions and 30 deletions

2
.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
Picofly-build*/
pico_sdk_import.cmake

View file

@ -79,10 +79,12 @@ Since Picofly firmware version `2.80`, the LED colors indicate the following mod
I've written two scripts that make compiling μsk easier, these scripts can be found in the root of the repository.
A short explanation about what they do:
* `picofly_build_local.sh` is a script that is ran from within the *root* of the cloned repository. You clone the repository, `cd` into the repository and run the script with `bash picofly_build_local.sh`. The script has a preconfigured workspace (`$WORKSPACE`) that clones the busk and pico-sdk repositories to the directory containing the cloned μsk repository, which is also where it'll create the `build` folder. This script is used to test and/or compile local changes made to μsk's code.
* `picofly_build_remote.sh` is a script that can be ran from whichever directory you'd like. This script (despite the possibly confusing name) does something similar to the previous script except that it clones the μsk, busk and pico-sdk repositories to `$WORKSPACE` (in this instance, this is `$HOME/Picofly-build`, but can be changed to whichever directory you'd like) automatically. This script can be used in the situation where you just want to have a quick way of cloning all relevant repositories and build the μsk firmware for yourself.
* `picofly_build_local.sh` is a script that is ran from within the *root* of the cloned repository. You clone the repository, `cd` into the repository and run the script with `bash picofly_build_local.sh`. The script has a preconfigured workspace (`$(pwd)/Picofly-build-local`) that clones the busk and pico-sdk repositories to the `Picofly-build-local`folder that's created in the root of the cloned μsk repository. This script is used to test and/or compile local changes made to μsk's code.
* `picofly_build_remote.sh` is a script that can be ran from whichever directory you'd like. This script (despite the possibly confusing name) does something similar to the previous script except that it clones the μsk, busk and pico-sdk repositories to `$HOME/Picofly-build-remote` (can be changed to whichever directory you'd like) automatically. This script can be ran with `bash picofly_build_remote.sh` from any location on your PC and can be used in the situation where you just want to have a quick way of cloning all relevant repositories and build the μsk firmware for yourself.
Please do note that, at the moment (16-01-2026), these scripts only work on Arch based Linux distributions (mainly EndeavourOS, as that's what I personally use). I'll add support for Fedora and Ubuntu/Debian based distro's in the future, but this is still WIP.
The resulting `firmware.uf2` and `update.bin` will be stored in `WORKSPACE/build/usk` for each script.
These scripts are now (as of 30-01-2026) compatible with all "mainstream" linux distributions :). If you face any issues, please report them in the issues tab.
## Modchip installation guide

View file

@ -7,7 +7,7 @@ GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}=== Picofly build script for EndeavourOS ===${NC}\n"
echo -e "${GREEN}=== Picofly build script (multi-distro) ===${NC}\n"
# check if we're in the usk directory
if [ ! -f "config.h" ] || [ ! -d ".git" ]; then
@ -16,15 +16,43 @@ if [ ! -f "config.h" ] || [ ! -d ".git" ]; then
exit 1
fi
# detect distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$ID
else
echo -e "${RED}Error: Cannot detect distribution${NC}"
exit 1
fi
# step 1: install dependencies
echo -e "${YELLOW}[1/7] Installing dependencies...${NC}"
echo -e "${YELLOW}[1/7] Installing dependencies for $DISTRO...${NC}"
case $DISTRO in
arch|endeavouros|manjaro)
sudo pacman -S --needed arm-none-eabi-gcc arm-none-eabi-newlib cmake make python git
;;
fedora)
sudo dnf install -y arm-none-eabi-gcc-cs arm-none-eabi-gcc-cs-c++ arm-none-eabi-newlib cmake make python3 git gcc-c++
;;
ubuntu|debian|pop|linuxmint)
sudo apt update
sudo apt install -y gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential cmake make python3 git
;;
*)
echo -e "${RED}Error: Unsupported distribution: $DISTRO${NC}"
echo "Please install the following packages manually:"
echo " - ARM embedded GCC toolchain (arm-none-eabi-gcc)"
echo " - newlib for ARM (arm-none-eabi-newlib)"
echo " - cmake, make, python3, git"
exit 1
;;
esac
# set workspace as parent directory of usk
WORKSPACE="$(cd .. && pwd)"
USK_DIR="$WORKSPACE/usk"
echo -e "${YELLOW}[2/7] Using workspace: $WORKSPACE${NC}"
# set workspace as build directory inside usk
WORKSPACE="$(pwd)/Picofly-build-local"
echo -e "${YELLOW}[2/7] Creating workspace at $WORKSPACE...${NC}"
mkdir -p "$WORKSPACE"
# step 2: clone sibling repositories
echo -e "${YELLOW}[3/7] Cloning sibling repositories...${NC}"
@ -48,11 +76,12 @@ export PICO_SDK_PATH="$WORKSPACE/pico-sdk"
# step 4: create symbolic links
echo -e "${YELLOW}[5/7] Creating symbolic links...${NC}"
USK_DIR="$(dirname "$WORKSPACE")"
ln -sf "$PICO_SDK_PATH/external/pico_sdk_import.cmake" "$WORKSPACE/busk/pico_sdk_import.cmake"
ln -sf "$PICO_SDK_PATH/external/pico_sdk_import.cmake" "$WORKSPACE/usk/pico_sdk_import.cmake"
ln -sf "$PICO_SDK_PATH/external/pico_sdk_import.cmake" "$USK_DIR/pico_sdk_import.cmake"
# step 5: create generated directory
mkdir -p "$WORKSPACE/usk/generated"
mkdir -p "$USK_DIR/generated"
# step 6: build busk
echo -e "${YELLOW}[6/7] Building busk...${NC}"
@ -68,23 +97,20 @@ cd "$WORKSPACE/build/busk"
cmake "$WORKSPACE/busk"
make
# prepare.py will look for ../busk/busk.bin from build/usk, which is build/busk/busk.bin
# restore original memmap_default.ld
rm -f "$MEMMAP_PATH"
mv "$MEMMAP_PATH.bak" "$MEMMAP_PATH"
cd "$WORKSPACE"
# step 7: build usk
echo -e "${YELLOW}[7/7] Building usk...${NC}"
mkdir -p "$WORKSPACE/build/usk"
cd "$WORKSPACE/build/usk"
cmake "$WORKSPACE/usk"
cmake "$USK_DIR"
make
# prepare.py looks for ../busk/busk.bin relative to build/usk
python3 "$WORKSPACE/usk/prepare.py"
python3 "$USK_DIR/prepare.py"
# clean up both builds
cd "$WORKSPACE/build/busk"
@ -99,8 +125,7 @@ echo -e " - firmware.uf2: ${WORKSPACE}/build/usk/firmware.uf2"
echo -e " - update.bin: ${WORKSPACE}/build/usk/update.bin"
# get version info
USK_VERSION_LO=$(sed -n 's/#define VER_LO \([0-9]*\)/\1/p' "$WORKSPACE/usk/config.h")
USK_VERSION_HI=$(sed -n 's/#define VER_HI \([0-9]*\)/\1/p' "$WORKSPACE/usk/config.h")
USK_VERSION_LO=$(sed -n 's/#define VER_LO \([0-9]*\)/\1/p' "$USK_DIR/config.h")
USK_VERSION_HI=$(sed -n 's/#define VER_HI \([0-9]*\)/\1/p' "$USK_DIR/config.h")
USK_VERSION="${USK_VERSION_HI}.${USK_VERSION_LO}"
echo -e "${GREEN}Version: Picofly ${USK_VERSION}${NC}\n"

View file

@ -7,14 +7,43 @@ GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # no color
echo -e "${GREEN}=== Picofly build script for EndeavourOS ===${NC}\n"
echo -e "${GREEN}=== Picofly build script (multi-distro) ===${NC}\n"
# detect distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
DISTRO=$ID
else
echo -e "${RED}Error: Cannot detect distribution${NC}"
exit 1
fi
# step 1: install dependencies
echo -e "${YELLOW}[1/8] Installing dependencies...${NC}"
echo -e "${YELLOW}[1/8] Installing dependencies for $DISTRO...${NC}"
case $DISTRO in
arch|endeavouros|manjaro)
sudo pacman -S --needed arm-none-eabi-gcc arm-none-eabi-newlib cmake make python git
;;
fedora)
sudo dnf install -y arm-none-eabi-gcc-cs arm-none-eabi-gcc-cs-c++ arm-none-eabi-newlib cmake make python3 git gcc-c++
;;
ubuntu|debian|pop|linuxmint)
sudo apt update
sudo apt install -y gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential cmake make python3 git
;;
*)
echo -e "${RED}Error: Unsupported distribution: $DISTRO${NC}"
echo "Please install the following packages manually:"
echo " - ARM embedded GCC toolchain (arm-none-eabi-gcc)"
echo " - newlib for ARM (arm-none-eabi-newlib)"
echo " - cmake, make, python3, git"
exit 1
;;
esac
# step 2: create workspace directory
WORKSPACE="$HOME/Picofly-build"
WORKSPACE="$HOME/Picofly-build-remote"
echo -e "${YELLOW}[2/8] Creating workspace at $WORKSPACE...${NC}"
mkdir -p "$WORKSPACE"
cd "$WORKSPACE"
@ -67,12 +96,9 @@ cd "$WORKSPACE/build/busk"
cmake "$WORKSPACE/busk"
make
# prepare.py will look for ../busk/busk.bin from build/usk, which is build/busk/busk.bin
# restore original memmap_default.ld
rm -f "$MEMMAP_PATH"
mv "$MEMMAP_PATH.bak" "$MEMMAP_PATH"
cd "$WORKSPACE"
# step 8: build usk
@ -101,5 +127,4 @@ echo -e " - update.bin: ${WORKSPACE}/build/usk/update.bin"
USK_VERSION_LO=$(sed -n 's/#define VER_LO \([0-9]*\)/\1/p' "$WORKSPACE/usk/config.h")
USK_VERSION_HI=$(sed -n 's/#define VER_HI \([0-9]*\)/\1/p' "$WORKSPACE/usk/config.h")
USK_VERSION="${USK_VERSION_HI}.${USK_VERSION_LO}"
echo -e "${GREEN}Version: Picofly ${USK_VERSION}${NC}\n"