How snappergps/snappergps-firmware works
Project type and purpose
• This is an embedded firmware project for a SnapperGPS receiver built on a Silicon Labs EFM32HG (Arm Cortex-M0+) MCU.
• It comprises a common “shared_library” of hardware-abstraction and peripheral drivers (CMSIS, EMLIB, EMUSB, plus custom ADC/flash/radio/timer modules) plus one or more “firmware_versions” that pull in that library, compile application logic (main.c), and produce a final .bin/.elf for flashing.
File structure (component candidates)
• Top-level:
• shared_library/ – reusable HAL and peripheral drivers
• firmware_versions/ – one subfolder per firmware variant (snapper, snapper-accelerometer)
• Makefiles under each variant for build definitions (compiler path, linker script, flash origin)
• shared_library submodules:
• cmsis/ – core startup and CMSIS definitions
• device/ – silicon-specific registers and startup code
• emlib/ – Silicon Labs peripheral abstractions (ADC, GPIO, USART, etc.)
• emusb/ – USB device stack
• inc/ & src/ – custom drivers for ADC, flash chip, radio, timer
• firmware_versions/<variant>/inc & src/ – application logic, USB descriptors, config
• firmware_versions/<variant>/build – linker script (.ld), Makefile
Core README insights
• Purpose: Provide standard firmware & an accelerometer-enabled variant
• Build: Arm GNU Toolchain + Makefiles + Linker script
• Flashing: via WebUSB or SWD, making use of generic USB messages & SnapperGPS-specific WebUSB protocol
Components
1. Build System
• Arm-GNU Toolchain, Make & Linker scripts
2. Source Modules
• shared_library
• CMSIS (core_cm0plus, startup)
• device headers & startup code
• EMLIB (peripheral abstraction)
• EMUSB (USB stack)
• Custom drivers (ADC, Flash, Radio, Timer)
• firmware_versions/<variant>
• USB descriptors & config
• Application logic (main.c, accelerometer.c)
3. Firmware Binary (.bin/.elf)
4. Target Hardware (EFM32HG310F64G MCU)
• On-chip: Flash (internal), SRAM, peripherals (ADC, TIMER, USB FS, USART)
• Off-chip: W25N512GV external flash, GNSS radio front-end, optional accelerometer
5. Runtime Interfaces
• USB WebUSB interface (generic + SnapperGPS messages)
• GNSS snapshot capture (radio → memory)
• Data storage (external flash)
• ADC measurements (battery, temperature)
• Timer interrupts / RTC
6. Host-side Web App (snappergps.info)
• Configuration/firmware-update UI communicating over WebUSB
• Build System → pulls in shared_library + firmware_version → produces Firmware Binary
• Firmware Binary → flashed onto MCU
• At runtime:
• MCU firmware ↔ Web Browser (WebUSB)
• MCU firmware → reads GNSS radio → stores snapshots → stores to external flash → serves to host on request
• MCU firmware → measures battery/temp via ADC driver → reports in GET_STATUS
• MCU firmware → uses timer/RTC for scheduling snapshots or shutdown
• Custom drivers ← layered on top of EMLIB ← layered on top of CMSIS
c. Architectural patterns & design principles
• Layered HAL: CMSIS → device startup → EMLIB → custom drivers → application logic
• Clear separation between shared/common code and firmware-specific code
• Single-image firmware with generic USB-bootloader compatibility
• Build-time configuration via Makefile and linker script
d. Key technologies/frameworks
• Arm GNU Toolchain (gcc, ld)
• Make, linker script (.ld)
• CMSIS, Silicon Labs EMLIB, EMUSB stacks
• WebUSB standard + custom USB descriptors
• W25N512GV external SPI-flash
• Silicon Labs Happy Gecko peripherals: ADC, TIMER, USART, USB FS