Adding Custom Board Support to dingoPDM Firmware
Overview
This guide walks you through adding support for a custom PDM board to the dingoPDM firmware. By following these steps, you'll build the firmware to run on your custom hardware while reusing existing functionality.
Hardware
Pins
The pins you need depend on which Profets (switching devices) you're planning to use.
BTS7002-1EPP
| Pin Type | Count | Name | Purpose |
|---|---|---|---|
| Analog Input | 1 | IS |
Current feedback |
| Digital Output | 1 | IN |
Drive transistor ON/OFF (PWM-enabled) |
| Digital Output | 1 | DEN |
Enable current sensing |
BTS7008-2EPP Variant
| Pin Type | Count | Name | Purpose |
|---|---|---|---|
| Analog Input | 1 | IS |
Current feedback |
| Digital Output | 1 | IN |
Drive transistor ON/OFF (PWM-enabled) |
| Digital Output | 1 | DSEL |
Select which output's current is measured |
| Digital Output | 1 | DEN |
Enable current sensing |
Note: The BTS7008-2EPP uses a single shared current feedback channel with multiplexing via
DSEL, while the BTS7002-1EPP has a dedicated feedback pin. AllINpins must support PWM; other outputs can use regular GPIO.
PCB Design
To Do
Schematic recommendations and layout guidelines
Firmware
The dingoPDM firmware is modular—adding a new board requires minimal changes outside the boards/ folder. Follow these steps in order:
Overview
- Copy and rename an existing board folder
- Update the
.ldlinker script - Configure
board.mk - Define pins in
board.h - Set output count in
port.h - Declare outputs in
hw_devices.cpp - Update message handling in
msg.cpp - Update root
Makefile - Add PWM configuration in
port_pwm.h - Enable timers in
mcuconf.h(if needed)
Files
Linker Script (.ld)
Location: boards/your_board_name/
Changes needed:
- Rename the .ld file to match your board name exactly
Board Configuration (board.mk)
Location: boards/your_board_name/
Example
Pin Definitions (board.h)
Location: boards/your_board_name/
This file initializes all MCU pins and their configurations. Define each pin type with the settings below:
Note
Refer to ChibiOS documentation on board.h configuration
IN Pin Configuration
DEN Pin Configuration
DSEL Pin Configuration
IS Pin Configuration
Counts (port.h)
Location: boards/your_board_name/
Example
To Do
Setting up and using VarMap
Output Declarations (hw_devices.cpp)
Location: boards/your_board_name/
Key points:
- Only modify the #if PDM_TYPE == 2 section (match your PDM_TYPE value)
- Declare outputs in order: IN, DEN, DSEL, IS
- &PWMD specifies the timer module (must be unique per output)
- &pwmCfg references the PWM configuration (defined in port_pwm.h)
Example
CAN/USB Message Handling (msg.cpp)
Location: common/ (root-level modification)
Update this file to transmit the status of your new outputs in both CAN and USB streams. Check existing board implementations for the pattern.
Root Makefile
Location: Makefile (repository root)
PWM Configuration (port_pwm.h)
Location: boards/your_board_name/
Steps:
1. Copy an existing PWM configuration and rename it for your board
2. Declare the .callback member for each output
3. Add callback functions in two sections:
- Output PWM period callbacks – called when PWM period changes
- Output PWM duty cycle callbacks – called when duty cycle changes
Example callback pattern
Timer Configuration (mcuconf.h)
Location: boards/your_board_name/
When needed: - Enable new timer peripherals only if your PWM configuration uses timers not already enabled - Check existing boards to see which timers are already configured - If reusing timers from the reference board, no changes needed
Build and Flash
Once all files are configured:
-
Build the firmware
-
Flash to your STM32
- Follow the existing firmware flashing wiki
Validation Checklist
Before testing your custom board:
- All pin definitions in
board.hmatch your schematic -
PDM_NUM_OUTPUTSmatches your physical output count -
PDM_NUM_INPUTSmatches your physical input count -
PDM_TYPEis unique and consistent across all files - All PWM timer assignments are unique (no conflicts)
-
msg.cppincludes your outputs in CAN/USB telemetry -
.ldlinker script is renamed correctly - Firmware builds without errors:
make BOARD=your_board_name
Common Issues & Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| Linker errors | .ld file not renamed or path wrong |
Verify .ld filename matches board name exactly |
| Undefined PDM_TYPE | Inconsistent PDM_TYPE values across files |
Search all files and ensure consistency |
| PWM conflicts | Timer assigned to multiple outputs | Review hw_devices.cpp and use unique timers |
| Build fails: unknown board | Root Makefile not updated | Add board to ifeq block in root Makefile |
| Outputs not responding | Wrong pin configuration | Double-check board.h pin modes and alternate functions |
Reference: File Structure
DingoPDM_FW/
├── Makefile
├── boards/
│ ├── existing_board_1/
│ │ ├── board.c
│ │ ├── board.h
│ │ ├── board.mk
│ │ ├── board_name.ld
│ │ ├── hw_devices.cpp
│ │ ├── mcuconf.h
│ │ ├── port.h
│ │ └── port_pwm.h
│ └── your_board_name/ ← Copy here
│ ├── board.c
│ ├── board.h
│ ├── board.mk
│ ├── your_board_name.ld
│ ├── hw_devices.cpp
│ ├── mcuconf.h
│ ├── port.h
│ └── port_pwm.h
└── common/
├── msg.cpp ← Update here
└── ...
Next Steps
After building and flashing:
- Verify all outputs turn on/off correctly
- Monitor current feedback (
IS) pins via CAN/USB telemetry - Test PWM duty cycle control on
INpins - Validate multiplexing on
DSEL(BTS7008-2EPP only)
For questions, refer to the main dingoPDM GitHub repository
Note
Thanks to jabbarider for this write up