Building the firmware from source
-
This tutorial explains the setup required to build the firmware from the GitHub source repository https://github.com/sg-wireless/sg-sdk
In this tutorial, I am using Windows 11 with Ubuntu 24.04 installed via WSL (Windows Subsystem for Linux). You can also use Ubuntu 24.04 or MacOS directly. If using Ubuntu 22.04, please see the note below regarding cmake.
Step1: Install necessary packages via apt
sudo apt-get install git wget flex bison gperf python3 python3-pip python3-setuptools cmake ninja-build ccache libffi-dev libssl-dev dfu-util libusb-1.0-0 python3-venvStep2: Clone the SG Wireless Open Source SDK
git clone https://github.com/sg-wireless/sg-sdk.gitStep3: Build the firmware
cd sg-sdk && ./fw_builder.sh --board SGW3501-F1-StarterKit buildDuring the first compilation, you will eventually get an error when using the latest version of Ubuntu 24.04:
../py/stackctrl.c: In function ‘mp_stack_ctrl_init’: ../py/stackctrl.c:32:32: error: storing the address of local variable ‘stack_dummy’ in ‘mp_state_ctx.thread.stack_top’ [-Werror=dangling-pointer=] 32 | MP_STATE_THREAD(stack_top) = (char *)&stack_dummy; ../py/stackctrl.c:31:18: note: ‘stack_dummy’ declared here 31 | volatile int stack_dummy; | ^~~~~~~~~~~ In file included from ../py/runtime.h:29, from ../py/stackctrl.c:27: ../py/mpstate.h:291:23: note: ‘mp_state_ctx’ declared here 291 | extern mp_state_ctx_t mp_state_ctx; | ^~~~~~~~~~~~ cc1: all warnings being treated as errors -e See https://github.com/micropython/micropython/wiki/Build-Troubleshooting make: *** [../py/mkrules.mk:83: build/py/stackctrl.o] Error 1 make: Leaving directory '/home/ehlers/sg-sdk/ext/micropython/mpy-cross' ninja: build stopped: subcommand failed. ninja failed with exit code 1 build failed!Please edit the file
ext/micropython/mpy-cross/Makefileand change line 20 to read:
CWARN = -Wall(remove -Werror)Now you can run
./fw_builder.sh --board SGW3501-F1-StarterKit buildagainThe firmware team is aware of this issue and it is already fixed in a newer version of Micropython. We will provide an update on this when the team has implemented the necessary update to support newer version of Micropython.
Step4: Flashing the firmware
If you are using Ubuntu Linux natively on your PC, you can simply connect the Starter Kit and run:
./fw_builder.sh --board SGW3501-F1-StarterKit flash --port /dev/ttyUSB0If you are using WSL, I suggest installing wsl-usb-gui

Select the entry with “Silicon Labs CP210x USB to UART Bridge (COMx)” that corresponds to the board you want to flash. In the screenshot above, I have two Starter Kits connected to my PC.
Once the device is attached to the WSL subsystem, you can flash it with the same command as above:
./fw_builder.sh --board SGW3501-F1-StarterKit flash --port /dev/ttyUSB0Note: On older versions of Ubuntu (ex: 22.04), the version of cmake installed with apt is too old. You can install a newer version by running:
sudo apt-get install python3-pip && pip3 install -U cmakePlease make sure you add the PATH where cmake is installed:
export PATH=~/.local/bin:$PATHPlease let me know if you experience any issues with building the firmware.
-
C cehlers referenced this topic on
-
Hi Christian Ehlers
Thanks for the great tutorial
I did hit one strange error as belowCMake Error at /home/rmg/repos/sg-sdk/ext/esp-idf/components/mbedtls/mbedtls/CMakeLists.txt:23 (cmake_minimum_required): Compatibility with CMake < 3.5 has been removed from CMake. Update the VERSION argument <min> value. Or, use the <min>...<max> syntax to tell CMake that the project requires at least <min> but has been updated to work with policies introduced by <max> or earlier. Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.My cmake version was 4.0.2. so I edited line 23 of CMakeLists.txt to
cmake_minimum_required(VERSION 3.5)and everything worked

I
-
I was testing my F1 starter kit since May. everything worked fine (LTE, Lora).
Yesterday I made a complete erase of flash (because the board was hanging) with./fw_builder.sh --board SGW3501-F1-StarterKit flash --port /dev/ttyUSB0
and reflash teh firmware with
./fw_builder.sh --board SGW3501-F1-StarterKit flash --port /dev/ttyUSB0
from then on the Lora radio was unable to join…do have I erased some Lora parameter?
-
You can reset the devnonce on TTN (or even set it to be ignored). Go to the end devices section on TTN, open the end device affected, go to settings and scroll down all the way to join settings and click expand.

The devnonce is stored in the nvs partition, which is normally not erased when just flashing a firmware update. But if the board is erased completely then the last devnonce used is also erased.