Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • YouTube
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

SG Community Forum

  1. Home
  2. Tutorials
  3. Building the firmware from source

Building the firmware from source

Scheduled Pinned Locked Moved Tutorials
5 Posts 3 Posters 541 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cehlersC Offline
    cehlersC Offline
    cehlers
    wrote on last edited by cehlers
    #1

    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-venv
    

    Step2: Clone the SG Wireless Open Source SDK

    git clone https://github.com/sg-wireless/sg-sdk.git
    

    Step3: Build the firmware

    cd sg-sdk && ./fw_builder.sh --board SGW3501-F1-StarterKit build
    

    During 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/Makefile and change line 20 to read:
    CWARN = -Wall (remove -Werror)

    Now you can run ./fw_builder.sh --board SGW3501-F1-StarterKit build again

    The 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/ttyUSB0
    

    If you are using WSL, I suggest installing wsl-usb-gui

    c90bff24-431a-4d51-a8ea-071f259ce6a6-image.png

    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/ttyUSB0
    

    Note: 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 cmake
    

    Please make sure you add the PATH where cmake is installed:

    export PATH=~/.local/bin:$PATH
    

    Please let me know if you experience any issues with building the firmware.

    F1 introduction video: https://youtu.be/8fsoL0ga_lo

    1 Reply Last reply
    0
    • cehlersC cehlers referenced this topic on
    • R Offline
      R Offline
      rodgergr
      wrote on last edited by
      #2

      Hi Christian Ehlers
      Thanks for the great tutorial😀
      I did hit one strange error as below

      CMake 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

      1 Reply Last reply
      1
      • S Offline
        S Offline
        SicheoSrl
        wrote on last edited by
        #3

        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?

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SicheoSrl
          wrote on last edited by
          #4

          Ok. the problem is that resetting the firmware also reset the nonce sent from the Lora to the TTS server and the server refuse the join because the nonce now is lower than that in the server db…

          1 Reply Last reply
          0
          • cehlersC Offline
            cehlersC Offline
            cehlers
            wrote on last edited by cehlers
            #5

            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.

            image.png

            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.

            F1 introduction video: https://youtu.be/8fsoL0ga_lo

            1 Reply Last reply
            0

            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • YouTube