From 4725f92df8f75de8c3d412e0b189786ab0201fd7 Mon Sep 17 00:00:00 2001 From: James Smith Date: Mon, 12 Jan 2026 11:53:04 -0800 Subject: [PATCH] Share board configs between bootloader and app firmware, drop cmake --- .github/workflows/build.yml | 41 +++---- bootloader/.gitignore | 1 - bootloader/README.md | 33 ------ bootloader/bootloader-efr32xg22e.slcp | 21 ---- bootloader/bootloader-rf-bm-bg22c3.slcp | 21 ---- firmware/.gersemirc | 7 -- firmware/README.md | 137 ------------------------ firmware/app/README.md | 119 ++++++++++++++++++++ firmware/app/build.sh | 23 ++++ firmware/{ => app}/src/app_properties.h | 0 firmware/{ => app}/src/button.c | 0 firmware/{ => app}/src/button.h | 0 firmware/{ => app}/src/channel_wheel.c | 0 firmware/{ => app}/src/channel_wheel.h | 0 firmware/{ => app}/src/led.c | 0 firmware/{ => app}/src/led.h | 0 firmware/{ => app}/src/main.c | 1 + firmware/{ => app}/src/settings.c | 0 firmware/{ => app}/src/settings.h | 0 firmware/{ => app}/src/version.h | 0 firmware/{ => app}/wavephoenix.slcp | 4 + firmware/boards/efr32xg22e.slcc | 11 ++ firmware/boards/rf-bm-bg22c3.slcc | 11 ++ firmware/{ => boards}/wavephoenix.slce | 2 +- firmware/bootloader/README.md | 65 +++++++++++ firmware/bootloader/bootloader.slcp | 14 +++ firmware/bootloader/build.sh | 18 ++++ firmware/build.sh | 22 ---- 28 files changed, 288 insertions(+), 263 deletions(-) delete mode 100644 bootloader/.gitignore delete mode 100644 bootloader/README.md delete mode 100644 bootloader/bootloader-efr32xg22e.slcp delete mode 100644 bootloader/bootloader-rf-bm-bg22c3.slcp delete mode 100644 firmware/.gersemirc delete mode 100644 firmware/README.md create mode 100644 firmware/app/README.md create mode 100755 firmware/app/build.sh rename firmware/{ => app}/src/app_properties.h (100%) rename firmware/{ => app}/src/button.c (100%) rename firmware/{ => app}/src/button.h (100%) rename firmware/{ => app}/src/channel_wheel.c (100%) rename firmware/{ => app}/src/channel_wheel.h (100%) rename firmware/{ => app}/src/led.c (100%) rename firmware/{ => app}/src/led.h (100%) rename firmware/{ => app}/src/main.c (99%) rename firmware/{ => app}/src/settings.c (100%) rename firmware/{ => app}/src/settings.h (100%) rename firmware/{ => app}/src/version.h (100%) rename firmware/{ => app}/wavephoenix.slcp (91%) rename firmware/{ => boards}/wavephoenix.slce (87%) create mode 100644 firmware/bootloader/README.md create mode 100644 firmware/bootloader/bootloader.slcp create mode 100755 firmware/bootloader/build.sh delete mode 100755 firmware/build.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b8e5f48..069aa08 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,7 +4,7 @@ on: push: branches: [main] tags: ["v*"] - paths: ["bootloader/**", "firmware/**"] + paths: ["firmware/**"] pull_request: branches: [main] workflow_dispatch: @@ -32,7 +32,7 @@ jobs: - name: Install build dependencies run: | sudo apt-get update - sudo apt-get install -y cmake ninja-build unzip wget + sudo apt-get install -y unzip wget - name: Set up Java uses: actions/setup-java@v4 @@ -118,34 +118,36 @@ jobs: # Build bootloader - name: Generate bootloader project files - working-directory: bootloader + working-directory: firmware/bootloader run: | - slc generate bootloader-${{ matrix.board }}.slcp \ - -o cmake \ + slc generate bootloader.slcp \ + --with "${{ matrix.board }};wavephoenix" \ + --sdk-extensions=../boards \ + -o makefile \ -d target/${{ matrix.board }} - name: Build bootloader - working-directory: bootloader/target/${{ matrix.board }}/bootloader_cmake + working-directory: firmware/bootloader run: | - cmake --workflow --preset project + make -C target/${{ matrix.board }} -f bootloader.Makefile release # Build firmware - - name: Generate firmware project files - working-directory: firmware + - name: Generate app firmware project files + working-directory: firmware/app run: | slc generate wavephoenix.slcp \ --with "${{ matrix.board }};wavephoenix" \ - --sdk-extensions=.,libjoybus,libwavebird \ - -o cmake \ + --sdk-extensions=../boards,../libjoybus,../libwavebird \ + -o makefile \ -d target/${{ matrix.board }} - - name: Build firmware - working-directory: firmware/target/${{ matrix.board }}/wavephoenix_cmake + - name: Build app firmware + working-directory: firmware/app run: | - cmake --workflow --preset project + make -C target/${{ matrix.board }} -f wavephoenix.Makefile release - - name: Generate firmware .gbl - working-directory: firmware/target/${{ matrix.board }}/wavephoenix_cmake/build/default_config + - name: Generate app firmware .gbl + working-directory: firmware/app/target/${{ matrix.board }}/build/release run: | commander gbl create \ --app wavephoenix.s37 \ @@ -160,14 +162,13 @@ jobs: VERSION="trunk" fi - mv bootloader/target/${{ matrix.board }}/bootloader_cmake/build/default_config/bootloader.hex "wavephoenix-bootloader-${VERSION}-${{ matrix.board }}.hex" - mv firmware/target/${{ matrix.board }}/wavephoenix_cmake/build/default_config/wavephoenix.hex "wavephoenix-receiver-${VERSION}-${{ matrix.board }}.hex" - mv firmware/target/${{ matrix.board }}/wavephoenix_cmake/build/default_config/wavephoenix.gbl "wavephoenix-receiver-${VERSION}-${{ matrix.board }}.gbl" + mv firmware/bootloader/target/${{ matrix.board }}/build/release/bootloader.hex "wavephoenix-bootloader-${VERSION}-${{ matrix.board }}.hex" + mv firmware/app/target/${{ matrix.board }}/build/release/wavephoenix.hex "wavephoenix-receiver-${VERSION}-${{ matrix.board }}.hex" + mv firmware/app/target/${{ matrix.board }}/build/release/wavephoenix.gbl "wavephoenix-receiver-${VERSION}-${{ matrix.board }}.gbl" - name: Update trunk tag if: github.ref == 'refs/heads/main' run: | - cd ${{ env.REPO_PATH }} git tag -f trunk git push -f origin trunk env: diff --git a/bootloader/.gitignore b/bootloader/.gitignore deleted file mode 100644 index 8b93443..0000000 --- a/bootloader/.gitignore +++ /dev/null @@ -1 +0,0 @@ -bootloader_project*/ \ No newline at end of file diff --git a/bootloader/README.md b/bootloader/README.md deleted file mode 100644 index 89280eb..0000000 --- a/bootloader/README.md +++ /dev/null @@ -1,33 +0,0 @@ -# Bootloader - -Gecko Bootloader with OTA update support. - -## Building - -Generate a cmake project from the .slcp file (replace rf-bm-bg22c with your board): - -```sh -slc generate --project-file bootloader-rf-bm-bg22c.slcp --export-destination bootloader_project --output-type cmake -``` - -Build the project: - -```sh -cd bootloader_project/bootloader_cmake -cmake --workflow --preset project -cmake --preset project && cmake --build --preset default_config -``` - -## Flashing - -### Using OpenOCD - -```bash -openocd -f "interface/cmsis-dap.cfg" -c "transport select swd" -f "target/efm32s2.cfg" -c "init; halt; flash write_image erase bootloader_project/bootloader_cmake/build/default_config/bootloader.hex; reset run; exit" -``` - -### Using probe-rs - -```bash -probe-rs download --chip EFR32BG22C224F512 --binary-format hex bootloader_project/bootloader_cmake/build/default_config/bootloader.hex -``` diff --git a/bootloader/bootloader-efr32xg22e.slcp b/bootloader/bootloader-efr32xg22e.slcp deleted file mode 100644 index 5d89fc8..0000000 --- a/bootloader/bootloader-efr32xg22e.slcp +++ /dev/null @@ -1,21 +0,0 @@ -project_name: bootloader -quality: production -description: Standalone Bootloader using the Bluetooth AppLoader OTA DFU. This implements in-place application updates using Bluetooth connection. - -component: - - id: EFR32MG22C224F512IM40 - - id: bootloader_core - - id: bootloader_apploader - - id: bootloader_image_parser - - id: bootloader_debug - - id: bootloader_gpio_activation - -configuration: - - name: BTL_APPLOADER_DEVICE_NAME - value: "\"WavePhoenix\"" - -define: - - name: SL_BTL_BUTTON_PORT - value: gpioPortC - - name: SL_BTL_BUTTON_PIN - value: 7 \ No newline at end of file diff --git a/bootloader/bootloader-rf-bm-bg22c3.slcp b/bootloader/bootloader-rf-bm-bg22c3.slcp deleted file mode 100644 index 3a37bee..0000000 --- a/bootloader/bootloader-rf-bm-bg22c3.slcp +++ /dev/null @@ -1,21 +0,0 @@ -project_name: bootloader -quality: production -description: Standalone Bootloader using the Bluetooth AppLoader OTA DFU. This implements in-place application updates using Bluetooth connection. - -component: - - id: EFR32BG22C224F512GM32 - - id: bootloader_core - - id: bootloader_apploader - - id: bootloader_image_parser - - id: bootloader_debug - - id: bootloader_gpio_activation - -configuration: - - name: BTL_APPLOADER_DEVICE_NAME - value: "\"WavePhoenix\"" - -define: - - name: SL_BTL_BUTTON_PORT - value: gpioPortB - - name: SL_BTL_BUTTON_PIN - value: 0 \ No newline at end of file diff --git a/firmware/.gersemirc b/firmware/.gersemirc deleted file mode 100644 index 16905fb..0000000 --- a/firmware/.gersemirc +++ /dev/null @@ -1,7 +0,0 @@ -# yaml-language-server: $schema=https://raw.githubusercontent.com/BlankSpruce/gersemi/master/gersemi/configuration.schema.json - -definitions: [] -indent: 2 -line_length: 100 -list_expansion: favour-inlining -unsafe: false diff --git a/firmware/README.md b/firmware/README.md deleted file mode 100644 index 828f628..0000000 --- a/firmware/README.md +++ /dev/null @@ -1,137 +0,0 @@ -# WavePhoenix Receiver Firmware - -This is the firmware for the WavePhoenix receiver, a replacement for the original WaveBird receiver. The WavePhoenix receiver is based on the EFR32BG22 SoC, and is compatible with the original WaveBird controller. - -## Building - -### Dependencies - -- [CMake](https://cmake.org/) -- [Ninja](https://ninja-build.org/) -- [GNU Arm Embedded Toolchain](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm) -- [Silicon Labs Gecko SDK](https://github.com/SiliconLabs/Gecko_SDK) (requires Git LFS) -- [Simplicity Commander](https://www.silabs.com/developers/simplicity-studio/simplicity-commander?tab=downloads) (optional, to generate OTA binaries) -- Python 3.10 and packages `jinja2`, `pyyaml`, `numpy` and `scipy` - -### Configuration - -- The `GECKO_SDK_PATH` env variable should be set to the path of the Gecko SDK -- The `SIMPLICITY_COMMANDER_PATH` env variable should be set to the path of Simplicity Commander, if installed - -### Building for RF-BM-BG22C3 - -From the `firmware` directory, run: - -```bash -cmake --preset rf-bm-bg22c3 && cmake --build --preset rf-bm-bg22c3 -``` - -This will generate: - -- `build/rf-bm-bg22c3/receiver/receiver.hex` - The firmware binary for SWD flashing -- `build/rf-bm-bg22c3/receiver/receiver.gbl` - The firmware binary for OTA flashing - -## Flashing - -> [!NOTE] -> A bootloader **must** be installed for the receiver firmware to boot. See the `bootloader` directory for more information. - -### Over-the-air (OTA) flashing - -The easiest way to flash the firmware is to use the OTA update feature of the bootloader. If you have a computer with Bluetooth, you can use the [WavePhoenix CLI](https://github.com/loopj/wavephoenix-cli) to flash the firmware: - -```bash -wavephoenix flash firmware.gbl -``` - -Alternatively, you can use the [Simplicity Connect mobile app](https://www.silabs.com/developer-tools/simplicity-connect-mobile-app?tab=downloads) to flash the firmware. - -### Using OpenOCD - -If you have a generic SWD debugger, you can use OpenOCD to flash the firmware. The [Raspberry Pi Debug Probe](https://www.raspberrypi.com/products/debug-probe/) is a good, affordable option. If you happen to have a Raspberry Pi Pico, you can install the [debugprobe firmware](https://github.com/raspberrypi/debugprobe) on it to turn it into an SWD debug probe! - -- Download and install [Arduino's fork of OpenOCD](https://github.com/facchinm/OpenOCD/tree/arduino-0.12.0-rtx5), which adds support for EFR32 Series 2 SoCs: - - [Windows](https://downloads.arduino.cc/tools/openocd-0.12.0-arduino1-static-i686-w64-mingw32.tar.bz2) - - [macOS](https://downloads.arduino.cc/tools/openocd-0.12.0-arduino1-static-x86_64-apple-darwin19.tar.bz2) - - [Linux](https://downloads.arduino.cc/tools/openocd-0.12.0-arduino1-static-x86_64-ubuntu16.04-linux-gnu.tar.bz2) -- Connect GND, SWDIO, SWCLK, and 3V3 between the debug probe and the SoC -- Flash the firmware: - - ```bash - cmake --build --preset release --target receiver_flash_openocd - ``` - -### Using JLink - -If you have a JLink debugger, you can use the JLink Command Line Tools to flash the firmware. - -- Install the [JLink Command Line Tools](https://www.segger.com/downloads/jlink/) -- Connect GND, SWDIO, SWCLK between the debug probe and the SoC -- Supply power to the device, and connect 3V3 to VTREF on the debugger -- Flash the firmware: - - ```bash - echo -e "h\nloadfile receiver.hex\nr\ng\nqc" | JLinkExe -nogui 1 -device EFR32BG22C224F512GM32 -if SWD -speed 4000 - ``` - -## Customizing the firmware - -The receiver firmware can be customized by setting various flags in a `board_config.h` file in a subdirectory of the -`config` directory. Setting the CMake variable `BOARD` to the name of the subdirectory will -include the `board_config.h` file in the build. - -### SI data line - -The SI data line is the communication line between the receiver and the console, and is **required** for -WavePhoenix to function. - -Define the following: - -- `SI_DATA_PORT` - The GPIO port for the SI data line -- `SI_DATA_PIN` - The GPIO pin for the SI data line - -### Status LED - -The WavePhoenix receiver firmware supports an optional status LED. The LED will blink on radio activity, just like -the original WaveBird receiver. The LED will also indicate pairing status in virtual pairing mode. - -To enable the optional status LED, define the following: - -- `HAS_STATUS_LED` - Set to `1` to enable status LED support -- `STATUS_LED_PORT` - The GPIO port for the status LED -- `STATUS_LED_PIN` - The GPIO pin for the status LED -- `STATUS_LED_INVERT` - Set to `1` to invert the LED logic (i.e. LED on when GPIO is low) - -### Pairing button - -The WavePhoenix receiver firmware supports a one-button "virtual pairing" mode. Connect one side of a switch to a -GPIO, and the other side to ground. When the button is pressed, the receiver will enter pairing mode. Pressing and -holding buttons on the controller will cause the receiver to pair with the controller. The exact behavior is -customizable by passing a pairing qualification function to `wavebird_radio_configure_qualification`. - -To enable the pairing button, define the following: - -- `HAS_PAIR_BTN` - Set to `1` to enable pairing button support -- `PAIR_BTN_PORT` - The GPIO port for the pairing button -- `PAIR_BTN_PIN` - The GPIO pin for the pairing button - -### Channel wheel - -The WavePhoenix receiver firmware supports an optional 16-position channel selection wheel, just like the original -WaveBird receiver. The channel wheel is a rotary DIP switch with 4 data pins, and one common pin. The common pin -should be connected to ground, and the data pins should be connected to GPIOs. - -Due to the way interrupts work on EFR32 devices, the pin numbers must be different for each channel wheel pin, -even if they are on the different ports. - -To enable the optional channel selection wheel, define the following: - -- `HAS_CHANNEL_WHEEL` - Set to `1` to enable channel wheel support -- `CHANNEL_WHEEL_PORT_0` - The GPIO port for the first channel wheel pin -- `CHANNEL_WHEEL_PIN_0` - The GPIO pin for the first channel wheel pin -- `CHANNEL_WHEEL_PORT_1` - The GPIO port for the second channel wheel pin -- `CHANNEL_WHEEL_PIN_1` - The GPIO pin for the second channel wheel pin -- `CHANNEL_WHEEL_PORT_2` - The GPIO port for the third channel wheel pin -- `CHANNEL_WHEEL_PIN_2` - The GPIO pin for the third channel wheel pin -- `CHANNEL_WHEEL_PORT_3` - The GPIO port for the fourth channel wheel pin -- `CHANNEL_WHEEL_PIN_3` - The GPIO pin for the fourth channel wheel pin diff --git a/firmware/app/README.md b/firmware/app/README.md new file mode 100644 index 0000000..a0786f7 --- /dev/null +++ b/firmware/app/README.md @@ -0,0 +1,119 @@ +# WavePhoenix App Firmware + +## Dependencies + +- [GNU Arm Embedded Toolchain](https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain) +- [Silicon Labs Simplicity SDK](https://github.com/SiliconLabs/simplicity_sdk) +- [Silicon Labs Configurator (SLC-CLI)](https://www.silabs.com/software-and-tools/simplicity-studio/configurator-command-line-interface) (requires Java) +- [Simplicity Commander](https://www.silabs.com/developers/simplicity-studio/simplicity-commander?tab=downloads) (optional, required to generate OTA binaries) + +## Configuration + +You'll need to tell SLC-CLI where your Simplicity SDK and ARM toolchain are located: + +```bash +slc configuration --sdk path/to/simplicity_sdk +slc configuration --gcc-toolchain path/to/gcc-arm-none-eabi +slc signature trust --sdk path/to/simplicity_sdk +``` + +## Building + +To build the WavePhoenix app, run the following script, replacing `rf-bm-bg22c3` with your target board: + +```bash +BOARD=rf-bm-bg22c3 ./build.sh +``` + +This will generate: + +- `target/rf-bm-bg22c3/build/release/wavephoenix.hex` - The firmware binary for SWD flashing +- `target/rf-bm-bg22c3/build/release/wavephoenix.gbl` - The firmware binary for OTA flashing + +## Flashing + +> [!IMPORTANT] +> A bootloader **must** be installed before flashing the app firmware. See the [`bootloader`](../bootloader) directory for more information. + +### Over-the-air (OTA) flashing + +If you have a computer or phone with Bluetooth, you can use [WavePhoenix Web](https://web.wavephoenix.com) to flash the firmware. + +### Using Simplicity Commander + +If you are using a dev board with a built-in J-Link debugger, you can use Simplicity Commander to flash the firmware: + +```bash +commander flash wavephoenix.hex +``` + +### Using OpenOCD + +If you are using a generic SWD debug probe, you can use OpenOCD to flash the firmware: + +1. Download and install Arduino's fork of OpenOCD ([Windows](https://downloads.arduino.cc/tools/openocd-0.12.0-arduino1-static-i686-w64-mingw32.tar.bz2), [macOS](https://downloads.arduino.cc/tools/openocd-0.12.0-arduino1-static-x86_64-apple-darwin19.tar.bz2), [Linux](https://downloads.arduino.cc/tools/openocd-0.12.0-arduino1-static-x86_64-ubuntu16.04-linux-gnu.tar.bz2)) + +2. Connect GND, SWDIO, SWCLK, and 3V3 between the debug probe and the SoC +3. Flash the firmware, replacing `wavephoenix.hex` with the path to your firmware file: + + ```bash + openocd -f interface/cmsis-dap.cfg \ + -c "transport select swd" \ + -f target/efm32s2.cfg \ + -c "init; halt; flash write_image erase wavephoenix.hex; exit" + ``` + +## Customizing the firmware + +The WavePhoenix firmware can be customized by setting various flags in board configuration files. See the [`boards`](../boards) folder for examples. + +### Joybus Configuration + +The Joybus GPIO is the communication line between the WavePhoenix and the console, and is **required** for WavePhoenix to function. + +Define the following: + +- `JOYBUS_PORT` - The GPIO port for the SI data line (e.g. `gpioPortD`) +- `JOYBUS_PIN` - The GPIO pin for the SI data line (e.g. `3`) +- `JOYBUS_TIMER` - The timer peripheral to use in `libjoybus` (e.g. `TIMER0`) +- `JOYBUS_USART` - The USART peripheral to use in `libjoybus` (e.g. `USART0`) + +### Status LED + +The WavePhoenix receiver firmware supports an optional status LED. The LED will blink on radio activity, just like the original WaveBird receiver. The LED will also indicate pairing status in virtual pairing mode. + +To enable the optional status LED, define the following: + +- `HAS_STATUS_LED` - Set to `1` to enable status LED support +- `STATUS_LED_PORT` - The GPIO port for the status LED +- `STATUS_LED_PIN` - The GPIO pin for the status LED +- `STATUS_LED_INVERT` - Set to `1` to invert the LED logic (i.e. LED on when GPIO is low) + +### Pairing button + +The WavePhoenix receiver firmware supports a one-button "virtual pairing" mode. Connect one side of a switch to a GPIO, and the other side to ground. When the button is pressed, the receiver will enter pairing mode. Pressing and holding buttons on the controller will cause the receiver to pair with the controller. The exact behavior is +customizable by passing a pairing qualification function to `wavebird_radio_configure_qualification`. + +To enable the pairing button, define the following: + +- `HAS_PAIR_BTN` - Set to `1` to enable pairing button support +- `PAIR_BTN_PORT` - The GPIO port for the pairing button +- `PAIR_BTN_PIN` - The GPIO pin for the pairing button + +### Channel wheel + +The WavePhoenix receiver firmware supports an optional 16-position channel selection wheel, just like the original WaveBird receiver. The channel wheel is a rotary DIP switch with 4 data pins, and one common pin. The common pin should be connected to ground, and the data pins should be connected to GPIOs. + +Due to the way interrupts work on EFR32 devices, the pin numbers must be different for each channel wheel pin, even if they are on the different ports. + +To enable the optional channel selection wheel, define the following: + +- `HAS_CHANNEL_WHEEL` - Set to `1` to enable channel wheel support +- `CHANNEL_WHEEL_PORT_0` - The GPIO port for the first channel wheel pin +- `CHANNEL_WHEEL_PIN_0` - The GPIO pin for the first channel wheel pin +- `CHANNEL_WHEEL_PORT_1` - The GPIO port for the second channel wheel pin +- `CHANNEL_WHEEL_PIN_1` - The GPIO pin for the second channel wheel pin +- `CHANNEL_WHEEL_PORT_2` - The GPIO port for the third channel wheel pin +- `CHANNEL_WHEEL_PIN_2` - The GPIO pin for the third channel wheel pin +- `CHANNEL_WHEEL_PORT_3` - The GPIO port for the fourth channel wheel pin +- `CHANNEL_WHEEL_PIN_3` - The GPIO pin for the fourth channel wheel pin diff --git a/firmware/app/build.sh b/firmware/app/build.sh new file mode 100755 index 0000000..1bddddd --- /dev/null +++ b/firmware/app/build.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +# Exit immediately if a command exits with a non-zero status +set -e + +# Check that BOARD environment variable is set +if [[ -z "$BOARD" ]]; then + echo "Error: BOARD environment variable not set" + exit 1 +fi + +# Generate the makefile project for the specified board +slc generate wavephoenix.slcp \ + --with "$BOARD;wavephoenix" \ + --sdk-extensions=../boards,../libjoybus,../libwavebird \ + -o makefile \ + -d target/$BOARD + +# Build the project +make -C target/$BOARD -f wavephoenix.Makefile release + +# Generate the .gbl file with Simplicity Commander" +commander gbl create --app target/$BOARD/build/release/wavephoenix.s37 target/$BOARD/build/release/wavephoenix.gbl \ No newline at end of file diff --git a/firmware/src/app_properties.h b/firmware/app/src/app_properties.h similarity index 100% rename from firmware/src/app_properties.h rename to firmware/app/src/app_properties.h diff --git a/firmware/src/button.c b/firmware/app/src/button.c similarity index 100% rename from firmware/src/button.c rename to firmware/app/src/button.c diff --git a/firmware/src/button.h b/firmware/app/src/button.h similarity index 100% rename from firmware/src/button.h rename to firmware/app/src/button.h diff --git a/firmware/src/channel_wheel.c b/firmware/app/src/channel_wheel.c similarity index 100% rename from firmware/src/channel_wheel.c rename to firmware/app/src/channel_wheel.c diff --git a/firmware/src/channel_wheel.h b/firmware/app/src/channel_wheel.h similarity index 100% rename from firmware/src/channel_wheel.h rename to firmware/app/src/channel_wheel.h diff --git a/firmware/src/led.c b/firmware/app/src/led.c similarity index 100% rename from firmware/src/led.c rename to firmware/app/src/led.c diff --git a/firmware/src/led.h b/firmware/app/src/led.h similarity index 100% rename from firmware/src/led.h rename to firmware/app/src/led.h diff --git a/firmware/src/main.c b/firmware/app/src/main.c similarity index 99% rename from firmware/src/main.c rename to firmware/app/src/main.c index 40f948d..f2f862c 100644 --- a/firmware/src/main.c +++ b/firmware/app/src/main.c @@ -111,6 +111,7 @@ static void initialize_controller(uint8_t controller_type) break; default: printf("Unknown controller type '%d', defaulting to WaveBird", controller_type); + /* fall through */ case WP_CONT_TYPE_GC_WAVEBIRD: joybus_gc_controller_init(&joybus_gc_controller, JOYBUS_WAVEBIRD_RECEIVER); break; diff --git a/firmware/src/settings.c b/firmware/app/src/settings.c similarity index 100% rename from firmware/src/settings.c rename to firmware/app/src/settings.c diff --git a/firmware/src/settings.h b/firmware/app/src/settings.h similarity index 100% rename from firmware/src/settings.h rename to firmware/app/src/settings.h diff --git a/firmware/src/version.h b/firmware/app/src/version.h similarity index 100% rename from firmware/src/version.h rename to firmware/app/src/version.h diff --git a/firmware/wavephoenix.slcp b/firmware/app/wavephoenix.slcp similarity index 91% rename from firmware/wavephoenix.slcp rename to firmware/app/wavephoenix.slcp index 6ee345d..7825ad2 100644 --- a/firmware/wavephoenix.slcp +++ b/firmware/app/wavephoenix.slcp @@ -43,3 +43,7 @@ configuration: define: - name: APP_PROPERTIES_CONFIG_FILE value: '"app_properties.h"' + +toolchain_settings: + - option: gcc_compiler_option + value: "-Wno-unused-parameter" \ No newline at end of file diff --git a/firmware/boards/efr32xg22e.slcc b/firmware/boards/efr32xg22e.slcc index 3b2bde7..ed01b9a 100644 --- a/firmware/boards/efr32xg22e.slcc +++ b/firmware/boards/efr32xg22e.slcc @@ -12,6 +12,7 @@ requires: - name: printf define: + # Joybus configuration - name: JOYBUS_PORT value: gpioPortD - name: JOYBUS_PIN @@ -20,12 +21,16 @@ define: value: TIMER1 - name: JOYBUS_USART value: USART0 + + # Pair button configuration - name: HAS_PAIR_BTN value: 1 - name: PAIR_BTN_PORT value: gpioPortC - name: PAIR_BTN_PIN value: 7 + + # Status LED configuration - name: HAS_STATUS_LED value: 1 - name: STATUS_LED_PORT @@ -34,3 +39,9 @@ define: value: 4 - name: STATUS_LED_INVERT value: 0 + + # Bootloader button configuration + - name: SL_BTL_BUTTON_PORT + value: gpioPortC + - name: SL_BTL_BUTTON_PIN + value: 7 diff --git a/firmware/boards/rf-bm-bg22c3.slcc b/firmware/boards/rf-bm-bg22c3.slcc index 6fac91e..723f08c 100644 --- a/firmware/boards/rf-bm-bg22c3.slcc +++ b/firmware/boards/rf-bm-bg22c3.slcc @@ -9,6 +9,7 @@ requires: - name: efr32bg22c224f512gm32 define: + # Joybus configuration - name: JOYBUS_PORT value: gpioPortA - name: JOYBUS_PIN @@ -17,6 +18,8 @@ define: value: TIMER1 - name: JOYBUS_USART value: USART0 + + # Pair button configuration - name: HAS_PAIR_BTN value: 1 - name: PAIR_BTN_PORT @@ -25,6 +28,8 @@ define: value: 0 - name: HAS_STATUS_LED value: 1 + + # Status LED configuration - name: STATUS_LED_PORT value: gpioPortC - name: STATUS_LED_PIN @@ -33,3 +38,9 @@ define: value: 0 - name: SL_CLOCK_MANAGER_HFXO_CTUNE value: 72 + + # Bootloader button configuration + - name: SL_BTL_BUTTON_PORT + value: gpioPortB + - name: SL_BTL_BUTTON_PIN + value: 0 diff --git a/firmware/wavephoenix.slce b/firmware/boards/wavephoenix.slce similarity index 87% rename from firmware/wavephoenix.slce rename to firmware/boards/wavephoenix.slce index fa77d13..368b47b 100644 --- a/firmware/wavephoenix.slce +++ b/firmware/boards/wavephoenix.slce @@ -7,4 +7,4 @@ sdk: version: 2025.6.2 component_path: - - path: boards \ No newline at end of file + - path: . \ No newline at end of file diff --git a/firmware/bootloader/README.md b/firmware/bootloader/README.md new file mode 100644 index 0000000..a69e3f2 --- /dev/null +++ b/firmware/bootloader/README.md @@ -0,0 +1,65 @@ +# WavePhoenix Bootloader + +## Dependencies + +- [GNU Arm Embedded Toolchain](https://developer.arm.com/Tools%20and%20Software/GNU%20Toolchain) +- [Silicon Labs Simplicity SDK](https://github.com/SiliconLabs/simplicity_sdk) +- [Silicon Labs Configurator (SLC-CLI)](https://www.silabs.com/software-and-tools/simplicity-studio/configurator-command-line-interface) (requires Java) + +## Configuration + +You'll need to tell SLC-CLI where your Simplicity SDK and ARM toolchain are located: + +```bash +slc configuration --sdk path/to/simplicity_sdk +slc configuration --gcc-toolchain path/to/gcc-arm-none-eabi +slc signature trust --sdk path/to/simplicity_sdk +``` + +## Building + +To build the WavePhoenix bootloader, run the following script, replacing `rf-bm-bg22c3` with your target board: + +```bash +BOARD=rf-bm-bg22c3 ./build.sh +``` + +This will generate `target/rf-bm-bg22c3/build/release/bootloader.hex`. + +## Flashing + +### Using Simplicity Commander + +If you are using a dev board with a built-in J-Link debugger, you can use Simplicity Commander to flash the bootloader: + +```bash +commander flash bootloader.hex +``` + +### Using OpenOCD + +If you are using a generic SWD debug probe, you can use OpenOCD to flash the bootloader: + +1. Download and install Arduino's fork of OpenOCD ([Windows](https://downloads.arduino.cc/tools/openocd-0.12.0-arduino1-static-i686-w64-mingw32.tar.bz2), [macOS](https://downloads.arduino.cc/tools/openocd-0.12.0-arduino1-static-x86_64-apple-darwin19.tar.bz2), [Linux](https://downloads.arduino.cc/tools/openocd-0.12.0-arduino1-static-x86_64-ubuntu16.04-linux-gnu.tar.bz2)) + +2. Connect GND, SWDIO, SWCLK, and 3V3 between the debug probe and the SoC. + +3. If this is your first time flashing this chip, you'll need to do a full device erase to unlock the debug interface: + + ```bash + openocd -f interface/cmsis-dap.cfg \ + -c "transport select swd" \ + -f target/efm32s2.cfg \ + -c "init; halt; efm32 mass_erase 0; exit" + ``` + +4. Disconnect then reconnect the debug probe. + +5. Then, flash the bootloader, replacing `bootloader.hex` with the path to your bootloader file: + + ```bash + openocd -f interface/cmsis-dap.cfg \ + -c "transport select swd" \ + -f target/efm32s2.cfg \ + -c "init; halt; flash write_image erase bootloader.hex; exit" + ``` \ No newline at end of file diff --git a/firmware/bootloader/bootloader.slcp b/firmware/bootloader/bootloader.slcp new file mode 100644 index 0000000..560717b --- /dev/null +++ b/firmware/bootloader/bootloader.slcp @@ -0,0 +1,14 @@ +project_name: bootloader +quality: production +description: WavePhoenix Bootloader + +component: + - id: bootloader_core + - id: bootloader_apploader + - id: bootloader_image_parser + - id: bootloader_debug + - id: bootloader_gpio_activation + +configuration: + - name: BTL_APPLOADER_DEVICE_NAME + value: "\"WavePhoenix\"" \ No newline at end of file diff --git a/firmware/bootloader/build.sh b/firmware/bootloader/build.sh new file mode 100755 index 0000000..c198ee8 --- /dev/null +++ b/firmware/bootloader/build.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +set -e + +# Check that BOARD environment variable is set +if [[ -z "$BOARD" ]]; then + echo "Error: BOARD environment variable not set" + exit 1 +fi + +# Generate the makefile project for the specified board +slc generate bootloader.slcp \ + --with "$BOARD;wavephoenix" \ + --sdk-extensions=../boards \ + -o makefile \ + -d target/$BOARD + +# Build the project +make -C target/$BOARD -f bootloader.Makefile release \ No newline at end of file diff --git a/firmware/build.sh b/firmware/build.sh deleted file mode 100755 index 987866e..0000000 --- a/firmware/build.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# Check that BOARD environment variable is set -if [[ -z "$BOARD" ]]; then - echo "Error: BOARD environment variable not set" - exit 1 -fi - -# Clean previous build artifacts -rm -rf target/$BOARD - -# Generate the CMake project for the specified board -slc generate wavephoenix.slcp --with "$BOARD;wavephoenix" --export-destination target/$BOARD --output-type cmake --sdk-extensions=.,libjoybus,libwavebird - -# Build the project -cd target/$BOARD/wavephoenix_cmake -cmake --workflow --preset project - -# Generate the .gbl file -/Applications/Commander.app/Contents/MacOS/commander gbl create \ - --app build/default_config/wavephoenix.s37 \ - build/default_config/wavephoenix.gbl \ No newline at end of file