STM32 Firmware Architecture DeepWiki
Complete reverse-engineered architectural reference for both STM32F105xC Flash images — the 48 KiB factory bootloader (stm32_bootloader.bin @ 0x08000000) and the 201 KiB main application (seg1.bin @ 0x0800C000) coordinating the AK7742 audio DSP, BridgeCo DM870-CE2 Wi-Fi/AirPlay module, RN52 Bluetooth module, capacitive touch/LED ring, and USB Host + FAT32 stack.
01 System Architecture Overview
The Harman Kardon Aura 1st-generation speaker is a three-processor embedded system packaged in a single HUI firmware container (5,093,444 bytes). The STM32F105xC (ARM Cortex-M3, 72 MHz, Connectivity Line) acts as the central system controller: it boots from the 48 KiB factory bootloader at 0x08000000 into the main application (seg1.bin) at 0x0800C000, owns all user I/O, power states, audio routing, and orchestrates two companion wireless modules plus a dedicated audio DSP.
Application Codebase Composition (1,404 Functions in seg1.bin)
02 Hardware Platform & Memory Map
The MCU is an STM32F105xC Connectivity Line device (256 KiB Flash, 64 KiB SRAM, USB OTG_FS, dual I2S PLLs via RCC_CFGR2, 68 external IRQs). Both bootloader and application were compiled with IAR EWARM using Thumb-2 instructions, LZ77-compressed .data initialization (__iar_lz77_init3 at 0x08038b44), and a 16 KiB static dlmalloc heap.
| Region | Address Range | Size | Contents & Notes |
|---|---|---|---|
| Factory Bootloader | 0x08000000 – 0x0800BFFF | 48 KiB | stm32_bootloader.bin (562 funcs, 634 labels). ST USBH MSC + ChaN FatFs USB HK_AURA.bin flasher. |
| App Vector Table | 0x0800C000 – 0x0800C14F | 336 B | Initial SP 0x2000FDC8, Reset 0x0803DCB1, 68 STM32F105 external IRQs. |
| App Code & RODATA | 0x0800C150 – 0x0803E3D3 | ~201 KiB | All 1,404 functions, AK7742 48k/96k DSP programs, RN52 AT table, region string CountryCodeUS @ 0x0803E2C3. |
| Persistent Config Flash | 0x0803F000 – 0x0803FFFF | 4 KiB | Boot/upgrade status word (1 = MCU upgrade requested), persisted volume/bass/EQ, 8-byte FireCast data, BT/Wi-Fi settings. |
| Static SRAM (.data/.bss) | 0x20000000 – 0x2000B8C7 | ~46.2 KiB | AK7742 coef RAM, HID instance (0x2000081C), USB DMA pool (0x20005160), FAT slots, CLI table, PCM ring buffers. |
| dlmalloc Dynamic Heap | 0x2000B8C8 – 0x2000F8C7 | 16 KiB | Returned by dlmalloc_get_initial_heap (0x0802e82c); serves XML parser, HTTP-MM, and 0x2C00 audio ring pool. |
| Main Stack (MSP) | 0x2000F8C8 – 0x2000FDC8 | ~1.25 KiB | Top of stack initialized from vector[0] = 0x2000FDC8. |
Key Peripheral & GPIO Assignments
| Peripheral | Base Address | Connected Hardware & Function |
|---|---|---|
USART2 | 0x40004400 | 115200 baud debug log & 48-command interactive serial CLI (g_debug_cli_table @ 0x20006970) |
UART4 | 0x40004C00 | 115200 baud RN52 Bluetooth module (PC10/PC11, reset/control PC12) — AT cmds, SPP, iAP, BCSP-DFU |
I2C1 | 0x40005400 | Top capacitive touch controller @ 8-bit addr 0xDA (reg 7 keys/slider, reg 9 Wi-Fi LED) |
I2C2 | 0x40005800 | AK7742 audio DSP @ 8-bit addr 0x30 (40 kHz polling master driver, PB10/PB11) |
SPI2 / I2S2 | 0x40003800 | USB iPod digital PCM output fed by DMA1_Channel5 (0x40020058, IRQ 15) |
Soft-I2C | GPIO bit-bang | 30-LED dome ring driver @ 8-bit addr 0xEA (register maps at 0x200006DC / 0x200006FC) |
Bit-bang SPI | GPIOC4 CS | S/PDIF optical receiver (AK4113/AK4114-class) register read/write & sample-rate detection |
USB OTG_FS | 0x50000000 | Full-speed Host mode (IRQ 67) for USB flash drives (FAT32) and Apple iPod UAC1/HID |
TIM2 / TIM3 / TIM7 | 0x40000000..1400 | TIM3: 1 ms system soft-timer & button hold tick. TIM2/TIM7: USB iPod audio SOF sync |
GPIOA / B / C / D | 0x40010800..1400 | PA0 Opt sense, PA1 Aux sense, PA5 Amp mute, PA6 Route sel, PA8 Power wake, PB2 AK7742 reset, PB14 HP amp en, PB15 HP sense, PC6/7/8 audio mux, PD2 DM870 reset |
03 STM32 Factory Bootloader (stm32_bootloader.bin, 48 KiB)
Residing at 0x08000000..0x0800BFFF (562 functions, 531 named, 634 labels in Ghidra), the STM32 factory bootloader is an independent IAR EWARM image that runs on every reset before jumping to seg1.bin at 0x0800C000.
Boot Decision & Handoff 0x0803F000
Checks the upgrade flag in persistent config Flash (0x0803F000) and validates the main application vector table at 0x0800C000. On normal boot, relocates SCB->VTOR = 0x0800C000, sets MSP, and jumps to seg1.bin Reset_Handler.
ST USBH MSC + ChaN FatFs USB Flash
Unlike the app's HCC stack, the bootloader uses ST's STM32_USB_OTG_Driver + USBH_MSC + ChaN FatFs (f_mount, f_open, f_read) to mount USB drives and read HK_AURA.bin.
HUI Container & Flash Programming Segment 1
Parses the HUI header, validates the 32-bit two's-complement checksum of Segment 1, unlocks STM32 Flash (FLASH_KEYR), erases pages 0x0800C000..0x0803EFFF, programs half-words, and clears the upgrade flag.
IAR DLib & LED Ring Status USART2 + 0xEA
Includes full IAR DLib _PrintfFull (0x08001320) logging over USART2 and drives the 30-LED ring over soft-I2C 0xEA to display flashing progress and failure states.
04 Application Boot & Cooperative Scheduler
There is no preemptive RTOS. After Reset_Handler (0x0803DCB0) runs IAR C runtime initialization (__iar_lz77_init3 decompressing .data and zeroing .bss), main() configures clocks (72 MHz HSE PLL), SysTick (10 ms tick counter g_systick_10ms_ticks), TIM3 (1 ms soft-timers), peripherals, and enters a deterministic super-loop dispatching 6 cooperative tasks connected via a lightweight event mailbox (g_task_event_masks @ 0x20008EEC, g_task_mailbox_slots @ 0x2000B6D4).
Task 1 — DSP, Audio & Flash Audio Core
Owns AK7742 initialization, 48k/96k program switching, source routing (Aux/BT/Opt/Wi-Fi/iPod), volume/bass/EQ curves, amp/headphone mute timing, and persistent Flash config writes.
Task 2 — System & Power Manager Supervisor
Coordinates power-on/standby/deep-sleep (WFI waking on PA8), auto-standby timers, factory reset (0x32), bypass mode (0x6E), and cross-subsystem event orchestration.
Task 3 — 30-LED Ring Controller Visual UI
Drives the 30-LED dome ring over soft-I2C 0xEA: volume/bass bar animations, clockwise Wi-Fi share sweep, upgrade spinner (2-LED rotating pair), and failure solid/blink states.
Task 4 — USB Upgrade & Button Events HUI / Input
Handles Power+Wi-Fi upgrade trigger (0x31), mounts USB flash via HCC FAT32, validates HK_AURA.bin, and sequences MCU/DM870/RN52 firmware updates.
Task 5 — Wi-Fi / DM870 / autosc.sp Network
Manages BridgeCo DM870-CE2 lifecycle over SPI/LAC, Wi-Fi AP/STA transitions, targeted/full scans, FireCast notifications, HTTP-MM XML remote control, and XMODEM segment-2 upgrades.
Task 6 — Bluetooth RN52 & iAP BT / MFi
Runs the RN52 ASCII AT state machine over UART4, dispatches HarmanSpp binary commands, handles Apple MFi/iAP authentication & Wi-Fi sharing, and executes CSR BCSP-DFU.
05 Audio Pipeline & AK7742 DSP
Every audio source passes through the Asahi Kasei AK7742 DSP (I2C2 address 0x30), integrating a 2-channel ADC (analog Aux), digital I2S/PCM inputs (DM870 Wi-Fi, RN52 Bluetooth, S/PDIF optical receiver, and STM32 SPI2/I2S2 USB iPod audio), and a 4-channel DAC feeding the woofer/tweeter power amp (mute GPIOA5) and headphone amp (enable GPIOB14, sense GPIOB15).
- Dual DSP Programs: Variant 0 (
g_ak7742_prog_v0_48k@0x0803694C, 3,837 B +0x16Ecoefs) runs for 44.1/48 kHz sources with 5 selectable bass filter sets. Variant 1 (g_ak7742_prog_v1_96k@0x0803784C, 3,562 B) loads automatically for 88.2/96 kHz optical S/PDIF streams. - Volume & Bass Tables: 31-step master volume table (
0x0000..0x2000, coeff0x04) and 9-step bass table (coeff0xA4). - USB iPod Digital Audio: Captured via HCC UAC1 ISO IN (
0x0802fbca) into a 100-slot PCM ring buffer, tracking clock drift viaOTG_FS->HFIR, and streamed out viaDMA1_Channel5toSPI2/I2S2(0x08030128).
06 Wi-Fi, BridgeCo DM870 & Network Protocols
AirPlay, DLNA, Spotify Connect, and the Setup AP (HK_Aura***** @ 192.168.1.1) run on the BridgeCo DM870-CE2 (AirPlay App Wiki • Bootloader L1 Wiki). The STM32 communicates with it over SPI via BridgeCo's LAC protocol (g_lac_rx_buf @ 0x2000A2A0).
BridgeCo LAC Layer SPI Transport
Bidirectional register/command packets carrying Wi-Fi state, sub-source (1=DLNA, 2=AirPlay, 3=Spotify), scan results, and AP/STA provisioning.
HTTP-MM XML Remote (Port 10025) LAN Control
HK Remote app XML commands (query-status, set_system_volume) parsed by the 19-function XML parser.
FireCast Protocol Binary Control
firecast_handle_command (0x0800daa8): LED ring control (cmd 0x0A), unsolicited status notifications, and 8-byte persistent private data.
Region Country Code 0x0803E2CE
g_region_country_code defaults to US (ch 1–11) and can be patched to EU (ch 1–13) or JP (ch 1–14) with segment-1 checksum recalculation.
07 Bluetooth (RN52), HarmanSpp & Apple MFi iAP
The Roving Networks RN52 (CSR BlueCore) connects over UART4 (115200 baud). Task 6 drives an ASCII AT state machine (g_rn52_at_cmd_table @ 0x08017958) and the HarmanSpp big-endian binary command dispatcher (0x08019816):
| Command ID | Meaning | Command ID | Meaning |
|---|---|---|---|
0x0001 | Query device capability | 0x0401 / 0x0403 | Get / set device name |
0x0101 / 0x0103 | Get / set EQ index | 0x0601 | Query firmware version |
0x0201 / 0x0203 / 0x0204 | Query / set volume & mute | 0x0802 / 0x0B01 / 0x0B03 | Key event / power status & off |
0x0301 | Scan wireless networks | 0x0C01 / 0x0D02 / 0x0D04 | Series ID / EQ & bass |
0x0304 / 0x0305 / 0x0307 | Join Wi-Fi / query IP / net count | 0x0E01 / 0x0E03 | Get / set audio source |
0x5304 | Targeted SSID Wi-Fi Share | other | Logs Unknown Spp Cmd, returns 0x63 |
08 HCC USB Host Stack & FAT32 Filesystem
Nearly 25% of seg1.bin (343 functions) is an HCC Embedded bare-metal USB Host + FAT12/16/32 stack on OTG_FS (0x50000000, IRQ 67): HCD core, UAC1 ISO audio (39 funcs), USB HID + Report Descriptor parser (29 funcs) for Apple iPod iAP, and MSC BOT + SCSI + VFAT LFN (124 funcs).
09 UI, Capacitive Touch & 30-LED Ring
| Key Mask | Buttons | Trigger | Action / Event |
|---|---|---|---|
0x01 | Power | Held 2.2 s / 5.0 s | Short power down (0x1F) / Long power down (0x21) |
0x02 | Wi-Fi | Tap / 2.2 s / 5.0 s | Wi-Fi status (0x22) / Setup AP (0x23) / Long Wi-Fi (0x24) |
0x03 | Power + Wi-Fi | Held 2.2 s | USB Firmware Upgrade (btnSendUpgradeDownFun → event 0x31) |
0x11 | Power + Source | Held 2.2 s | Factory reset / load defaults (0x32) |
0x12 | Wi-Fi + Source | Held 2.2 s | Enter bypass mode (0x6E) |
0x10 | Source | Tap / Held 2.2 s | Cycle source (0x6C) / Bluetooth pairing (0x6D) |
0x08 / 0x04 / 0x0C | Vol+ / Vol- / Both | Press / Repeat | Volume up/down (0x2B / 0x2C) & mute |
10 Multi-Target Firmware Upgrade Pipelines
Holding Power + Wi-Fi for 2.2 s (or running serial CLI upgrade) mounts FAT32 USB flash, opens HK_AURA.bin, parses the HUI header, verifies 32-bit checksums, and updates up to three targets: 1. DM870 Seg 2 via 133-byte XMODEM-CRC over SPI, 2. RN52 Bluetooth via CSR BCSP-DFU over UART4 (U-DONT*KNOW handshake), and 3. STM32 MCU Seg 1 by writing status 1 to 0x0803F000 and rebooting into the 48 KiB factory bootloader.
11 Interactive STM32 Function & Symbol Explorer
Browse all currently annotated Ghidra objects from both seg1.bin (1,404 functions, 754 labels) and stm32_bootloader.bin (562 functions, 634 labels). Press / anywhere to focus search.
| Address | Symbol Name | Subsystem | Description |
|---|