- C++ 79.1%
- Python 16.2%
- Linker Script 3.9%
- Shell 0.8%
The buck shelf is now its own part. A 5 mm flange bolts to the back of the U from behind with four M3 screws into heat-set inserts: two in the top wall, two in bosses inside the back wall. The screws are outside the regulator's footprint, so the shelf and regulator come off without removing the PCB. The STL is rotated to print with the shelf flat on the bed, so the layers run along the cantilever. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> |
||
|---|---|---|
| 3d | ||
| external | ||
| firmware | ||
| hardware | ||
| scripts | ||
| .gitignore | ||
| .gitmodules | ||
| LICENSE | ||
| README.md | ||
Power distribution V2.0
A 1U, 19" board that takes 24 V in and splits it into fused 24 V and 12 V outputs for a rack: 5 XT60 and 10 XT30 at 24 V, the same again at 12 V from an external DC-DC module, and an XT60 passthrough before the main fuse. An STM32F103 measures the input voltage, the total load current and the 12 V rail, shows them on a 4-digit display, and reports them over CAN.
The firmware speaks the Briefcase
CAN protocol as board 9, pdu. It is not in the briefcase. It sits on the rack's
bus next to the rack's control board (control-rack), which shows it in its web UI,
MQTT and Lua like any briefcase board, and updates its firmware over CAN.
State: the firmware builds and its host tests pass. It has not run on a board yet. See Check on the first board.
Repo layout
| Path | What |
|---|---|
hardware/ |
KiCad project, production files, and the board facts the firmware relies on |
firmware/pdu/ |
the app |
firmware/bootloader/ |
the CAN bootloader, for the F103 |
firmware/shared/ |
the display font and number formatting, used by both |
firmware/common.ini |
settings both builds share, including the probe |
external/Briefcase/ |
submodule: briefcase-can, the boot protocol and the build scripts |
Clone with the submodule:
git clone --recurse-submodules https://forgejo.vratk0529.com/vratk0529/power-distribution-2.0.git
# or, in an existing clone
git submodule update --init
Building and flashing
cd firmware/pdu
pio run # build
pio run -t upload # flash over the Black Magic probe
pio test -e native # host tests: the display formatting
upload_port is pinned to /dev/ttyBmpGdb7FC67A9A in firmware/common.ini, the
probe the briefcase is flashed with. Do not change it: the other Black Magic
probe on this machine is a custom DSP, and uploading to it would overwrite its
firmware. If that probe is not plugged in, the upload fails rather than going
anywhere else.
NRST is not on the PROG header (J37), so a hung board is recovered by power-cycling it while the probe connects. The firmware never disables SWD.
On the bus
250 kbit/s, board id 9, pdu. Channels, outputs and flags are in
bus-map.h (busmap::pdu), with
everything else in the briefcase protocol
(docs/can-protocol.md).
| Channel | Name | What | Error | Warning |
|---|---|---|---|---|
| 0 | vin_volt |
24 V input, after the main fuse | < 20.0, > 29.0 V | < 22.0, > 28.0 V |
| 1 | load_curr |
everything on the 24 V outputs plus the 12 V module's input | > 30 A (the main fuse) | > 25 A |
| 2 | v12_volt |
the 12 V module's output | < 11.0, > 13.2 V | < 11.5, > 12.8 V |
load_curr does not include the J32 passthrough or the board's own 3.3 V. The
limits can be changed from the control board (SET_THRESHOLD) without reflashing.
An over-voltage on either rail latches until it is cleared, as on the briefcase.
| Output | Value |
|---|---|
0 OUT_DISPLAY |
what the display shows: 0 24 V, 1 current, 2 power, 3 12 V |
1 OUT_DISPLAY_BRIGHTNESS |
0..255, 0 = dark |
Heartbeat flags: FLAG_12V_PRESENT (12 V rail above 9 V), FLAG_DISPLAY_ON.
The board switches nothing, so it has no faults of its own beyond the two every
board has (controller_lost, watchdog_reset). The CAN transceiver is powered from
the bus cable's 5 V: without it the board still measures and shows, it is just
silent.
The front
The button cycles what the display shows. The LED next to it says which:
| LED | Shows | As |
|---|---|---|
| Voltage | 24 V input | 24.13 |
| Current | total load current | 12.50 |
| Power | 24 V × current | 301.6 (watts) |
| 12V Voltage | 12 V rail | 12.04 |
Holding the button for a second turns the display off; a press turns it back on.
---- means the value could not be read. If the value shown is in error, the
digits blink; if another value is, its LED blinks. At power-up every segment and
LED lights for 0.4 s, so a dead one shows.
The selected value and brightness are not kept across a reset: the backup registers are all taken by the bootloader.
Updating over CAN
The briefcase's satellite bootloader, ported to the F103: same frames, same image
header, same trial and boot decisions
(boot-logic.h), so the
control board's Firmware tab updates this board like any briefcase satellite. The
design is in the Briefcase docs/bootloader.md.
Flash layout (128 KB, 1 KB pages)
| Pages | Address | What |
|---|---|---|
| 0 to 7 | 0x08000000 |
the loader, 8 KB (it is about 4 KB) |
| 8, 9 | 0x08002000 |
trial log |
| 10 onwards | 0x08002800 |
the app, up to 118 KB (it is about 42 KB) |
Installing the loader, over SWD, once
cd firmware/bootloader && pio run -t upload
cd ../pdu && pio run -e pdu-can -t upload
The loader's upload covers pages 0 to 9, so it also erases the trial log. The
pdu-can upload starts at 0x08002800 and leaves the loader alone. Uploading the
plain pdu env over SWD overwrites the loader; the board then works as before,
it just cannot be updated over CAN until the loader goes back on.
Updating from the web UI
cd firmware/pdu && pio run -e pdu-can
Upload .pio/build/pdu-can/pdu-can-<commit>.bin on the rack control board's
Firmware tab and press Flash pdu. That control board has to run Briefcase
firmware that knows board 9.
In the loader
The display says what the loader is doing, and the four LEDs blink fast throughout:
| Display | Means |
|---|---|
boot |
waiting, with a good app (it goes back to it after a minute alone) |
noAP |
no usable app: an update was cut short, or the image is damaged |
FAIL |
the new app reset 3 times without confirming; Start app gives it 3 more |
U 42 |
receiving, 42 % written |
donE |
written and checked, waiting to be started |
The display goes dark while flash is being erased or written.
A new image is on trial until it has run 10 s with the control board heard. The board's only power is the 24 V input, so an app that runs but has stopped answering on the bus is caught by power-cycling the board while the control board is asking.
The F103's differences from the briefcase loader: 1 KB pages and half-word programming, a 16-bit TIM2 extended in software, 16-bit backup registers used in pairs, the AFIO remap for CAN on PB8/PB9, 250 kbit/s from the 8 MHz HSI with prescaler 2, and a filter bank without CAN2.
Check on the first board
None of this has run on hardware yet. In order:
- Digit order. G1 is taken as the leftmost digit, from the SR440281N pinout.
If the number reads backwards, reverse
seg::GATESinfirmware/shared/segments.h(the first four entries). - The lamp test at power-up lights every segment and all four LEDs.
- Current sign. With a load on,
load_currshould be positive. - 12 V reading against a meter. The divider scale is in
main.cpp(V12_PER_COUNT) and assumes VDDA is exactly 3.3 V. - CAN at 250 kbit/s next to a briefcase board, from the HSI.
- The loader: install it, then do one update from the web UI and check the board confirms itself (the Firmware tab shows its commit and loader v1).
Hardware
KiCad project in hardware/. hardware/README.md
is the board summary the firmware is written against: power tree, pin map, the
INA226 and the display.
The files in hardware/production/ were generated on 2026-11-01 and the PCB has
changed since (2026-11-14). Regenerate them before ordering.
License
- Firmware (
firmware/): MIT. - Hardware (
hardware/): CERN-OHL-P v2. external/Briefcaseis a separate repository under its own (MIT) license.- Fetched at build time and not included: pazi88/STM32_CAN, the STM32duino core and the CMSIS device headers, under their own licenses.