by Drew Owens
Open-source 15-DoF XL330 biped goose robot with Spine molecule PCB, 3D-printed chassis, and Isaac Lab to MuJoCo sim-to-real RL stack
main
Drew Owens
Publish Microgoose Rev A full-stack hardware, CAD, datasheet, and 7-stage RL stack
e843249
Microgoose Spine MCU Firmware (STM32G431CBT6)
Real-time 200 Hz (5.0 ms) bare-metal C11 firmware for the microgoose-spine board. The STM32G431CBT6 (U4, 170 MHz Cortex-M4F, 128 KB Flash, 32 KB SRAM, LQFP-48) bridges the Radxa Zero 3W Linux compute module to all 15 ROBOTIS XL330-M288-T actuators, the torso and head BMI270 6-axis IMUs, the VL53L5CX 8x8 multizone ToF ground sensor, and the INA226AIDGST power monitor.
Pin Map (include/board_pins.h)
| Pin(s) | Function | Bus / Connector | Connected Hardware |
|---|---|---|---|
PA2, PA3 |
USART2_TX, USART2_RX (AF7) |
J4 (BM05B-GHS-TBT, RADXA_LINK) |
Radxa Zero 3W 5V_BUS + host UART (1 Mbps default, 2 Mbps DMA supported) |
PB10, PB11, PB12 |
USART3_TX, USART3_RX (AF7), DXL_DIR (GPIO) |
J1, J2, J3 (BM03B-GHS-TBT) |
1 Mbps half-duplex TTL Dynamixel Protocol 2.0 bus via U6 (SN74LVC1G126DBVR, OE on PB12): J1 Left Leg (IDs 1..5), J2 Right Leg (IDs 6..10), J3 Neck/Head (IDs 11..14) + Beak (ID 15) |
PB6, PB7 |
I2C1_SCL, I2C1_SDA (AF4 open-drain) |
Onboard + J5 (BM05B-GHS-TBT, HEAD_I2C) |
400 kHz Fast-Mode I2C1: onboard BMI270 (U5, 0x68), INA226AIDGST (U3, 0x40, R20 Bourns CSS2H-2512R-L300F 0.30 mOhm shunt), head VL53L5CX (0x29), head BMI270 (0x69) |
PA0 |
ADC1_IN1 (VBAT_ADC) |
Onboard analog | VBAT battery voltage divider (R11 = 100 kOhm CQ03WAF1003T5E, R12 = 33 kOhm CQ03SAF3302T5E) |
PA1 |
TIM2_CH2 (AF1 LED_PWM_3V3) |
Onboard status | 800 kHz PWM via U7 (SN74AHCT1G125DBVR) and R19 (100 Ohm) into D2 (WS2812B-2020) |
PB0, PB1, PB2, PA8 |
GPIO digital inputs |
Onboard + J5.5 |
PB0 = BUCK_PG (U1.4), PB1 = IMU_INT1 (U5.4), PB2 = INA_ALERT (U3.3), PA8 = HEAD_INT (J5.5) |
PA13, PA14, PG10, PB8 |
SWDIO, SWCLK, NRST, BOOT0 |
Edge contacts MC6..MC8 |
SWD debug pads (MachineContactMedium) and R9 (10 kOhm) BOOT0 pulldown |
Source Layout
include/board_pins.h: Pin mux definitions,J1..J5connector mapping, I2C slave addresses,R11/R12voltage divider constants,R200.30 mOhmshunt calibration, and canonical Dynamixel IDs1..15.src/dxl_protocol2.c: Dynamixel Protocol 2.0 packet builder and parser with table-driven0x8005CRC-16,[FF FF FD]byte stuffing and unstuffing,89-byteSyncWriteGoal Position (0x83, address116), and29-byteSyncReadPresent Current/Velocity/Position (0x82, addresses126..135).src/host_frame.c:0x00-delimited COBS encoder/decoder with0x8005CRC-16 over194-byte telemetry frames (HOST_MSG_TELEMETRY) and38-byte command frames (HOST_MSG_CMD_JOINTS).src/ina226.c: Fixed-point driver forINA226AIDGST(U3,0x40) withCAL = 17067(0x42AB) for1 mA/LSBresolution over the0.30 mOhm(300 uOhm,0.0003 Ohm) BournsCSS2H-2512R-L300FshuntR20, plusPA012-bitVBAT_ADCconversion.src/bmi270_min.c: MinimalBMI270initialization,12-byte burst reader (0x0C..0x17), and complementary filter producing body-frameprojected_gravityfor both0x68and0x69.src/main.candsrc/startup_stm32g431.c:170 MHzRange 1 Boost PLL startup, peripheral configuration,50 msIWDGhardware watchdog, and200 HzSpine supervisor (100 mshost command timeout,< 6.10 Vbattery cutoff,BUCK_PG/INA_ALERTmonitoring, and> 4.20 Aovercurrent persistence trip after100 ms).ld/stm32g431cbt6.ld: Linker script mapping128 KBFlash at0x08000000and32 KBSRAM at0x20000000.tests/test_firmware_host.c: Nativegccverification suite covering Protocol 2.0 packets, ROBOTIS reference CRC vectors, COBS framing, fixed-point0.30 mOhmINA226math,PB0/PB1/PB2/PA8sense pins, and watchdog trips.
Build and Verify
Run the native gcc protocol and supervisor unit tests plus the bare-metal syntax check:
make -C firmware clean all
Cross-compile build/microgoose_spine.elf and build/microgoose_spine.bin when arm-none-eabi-gcc is installed on PATH:
make -C firmware firmware
# Microgoose Spine MCU Firmware (`STM32G431CBT6`)
Real-time 200 Hz (`5.0 ms`) bare-metal C11 firmware for the `microgoose-spine` board. The `STM32G431CBT6` (`U4`, `170 MHz` Cortex-M4F, `128 KB` Flash, `32 KB` SRAM, `LQFP-48`) bridges the Radxa Zero 3W Linux compute module to all 15 ROBOTIS `XL330-M288-T` actuators, the torso and head `BMI270` 6-axis IMUs, the `VL53L5CX` 8x8 multizone ToF ground sensor, and the `INA226AIDGST` power monitor.
## Pin Map (`include/board_pins.h`)
| Pin(s) | Function | Bus / Connector | Connected Hardware |
|---|---|---|---|
| `PA2`, `PA3` | `USART2_TX`, `USART2_RX` (`AF7`) | `J4` (`BM05B-GHS-TBT`, `RADXA_LINK`) | Radxa Zero 3W `5V_BUS` + host UART (`1 Mbps` default, `2 Mbps` DMA supported) |
| `PB10`, `PB11`, `PB12` | `USART3_TX`, `USART3_RX` (`AF7`), `DXL_DIR` (`GPIO`) | `J1`, `J2`, `J3` (`BM03B-GHS-TBT`) | `1 Mbps` half-duplex TTL Dynamixel Protocol 2.0 bus via `U6` (`SN74LVC1G126DBVR`, `OE` on `PB12`): `J1` Left Leg (`IDs 1..5`), `J2` Right Leg (`IDs 6..10`), `J3` Neck/Head (`IDs 11..14`) + Beak (`ID 15`) |
| `PB6`, `PB7` | `I2C1_SCL`, `I2C1_SDA` (`AF4` open-drain) | Onboard + `J5` (`BM05B-GHS-TBT`, `HEAD_I2C`) | `400 kHz` Fast-Mode `I2C1`: onboard `BMI270` (`U5`, `0x68`), `INA226AIDGST` (`U3`, `0x40`, `R20` Bourns `CSS2H-2512R-L300F` `0.30 mOhm` shunt), head `VL53L5CX` (`0x29`), head `BMI270` (`0x69`) |
| `PA0` | `ADC1_IN1` (`VBAT_ADC`) | Onboard analog | `VBAT` battery voltage divider (`R11 = 100 kOhm` `CQ03WAF1003T5E`, `R12 = 33 kOhm` `CQ03SAF3302T5E`) |
| `PA1` | `TIM2_CH2` (`AF1` `LED_PWM_3V3`) | Onboard status | `800 kHz` PWM via `U7` (`SN74AHCT1G125DBVR`) and `R19` (`100 Ohm`) into `D2` (`WS2812B-2020`) |
| `PB0`, `PB1`, `PB2`, `PA8` | `GPIO` digital inputs | Onboard + `J5.5` | `PB0 = BUCK_PG` (`U1.4`), `PB1 = IMU_INT1` (`U5.4`), `PB2 = INA_ALERT` (`U3.3`), `PA8 = HEAD_INT` (`J5.5`) |
| `PA13`, `PA14`, `PG10`, `PB8` | `SWDIO`, `SWCLK`, `NRST`, `BOOT0` | Edge contacts `MC6..MC8` | SWD debug pads (`MachineContactMedium`) and `R9` (`10 kOhm`) `BOOT0` pulldown |
## Source Layout
- `include/board_pins.h`: Pin mux definitions, `J1..J5` connector mapping, I2C slave addresses, `R11/R12` voltage divider constants, `R20` `0.30 mOhm` shunt calibration, and canonical Dynamixel IDs `1..15`.
- `src/dxl_protocol2.c`: Dynamixel Protocol 2.0 packet builder and parser with table-driven `0x8005` CRC-16, `[FF FF FD]` byte stuffing and unstuffing, `89`-byte `SyncWrite` Goal Position (`0x83`, address `116`), and `29`-byte `SyncRead` Present Current/Velocity/Position (`0x82`, addresses `126..135`).
- `src/host_frame.c`: `0x00`-delimited COBS encoder/decoder with `0x8005` CRC-16 over `194`-byte telemetry frames (`HOST_MSG_TELEMETRY`) and `38`-byte command frames (`HOST_MSG_CMD_JOINTS`).
- `src/ina226.c`: Fixed-point driver for `INA226AIDGST` (`U3`, `0x40`) with `CAL = 17067` (`0x42AB`) for `1 mA/LSB` resolution over the `0.30 mOhm` (`300 uOhm`, `0.0003 Ohm`) Bourns `CSS2H-2512R-L300F` shunt `R20`, plus `PA0` `12`-bit `VBAT_ADC` conversion.
- `src/bmi270_min.c`: Minimal `BMI270` initialization, `12`-byte burst reader (`0x0C..0x17`), and complementary filter producing body-frame `projected_gravity` for both `0x68` and `0x69`.
- `src/main.c` and `src/startup_stm32g431.c`: `170 MHz` Range 1 Boost PLL startup, peripheral configuration, `50 ms` `IWDG` hardware watchdog, and `200 Hz` Spine supervisor (`100 ms` host command timeout, `< 6.10 V` battery cutoff, `BUCK_PG` / `INA_ALERT` monitoring, and `> 4.20 A` overcurrent persistence trip after `100 ms`).
- `ld/stm32g431cbt6.ld`: Linker script mapping `128 KB` Flash at `0x08000000` and `32 KB` SRAM at `0x20000000`.
- `tests/test_firmware_host.c`: Native `gcc` verification suite covering Protocol 2.0 packets, ROBOTIS reference CRC vectors, COBS framing, fixed-point `0.30 mOhm` `INA226` math, `PB0/PB1/PB2/PA8` sense pins, and watchdog trips.
## Build and Verify
Run the native `gcc` protocol and supervisor unit tests plus the bare-metal syntax check:
```bash
make -C firmware clean all
```
Cross-compile `build/microgoose_spine.elf` and `build/microgoose_spine.bin` when `arm-none-eabi-gcc` is installed on `PATH`:
```bash
make -C firmware firmware
```