hackdoc://dc Hackerspace Datacenter Docs

STM32 Bluepill-based I2C Flasher

This is a Rust project that runs on an STM32F103C8T6 on a common bluepill board.

It acts as a USB device, exposing an interface to perform arbitrary I2C operations.

Hardware

You will need a buepill with an STM32103C8T6 and a way to flash ELFs on it. An ST-Link or BlackMagicProbe (potentially running on another Bluepill) are good choices.

For flashing the HBJ11 (or any other Dell M610 storage card) you will also need a PCIe x8 socket. The connections to make are as follows:

Bluepill/STM32 Function PCIe Slot
G/GND Ground B7
3.3/VCC 3.3V B10
B6 SCL B11
B7 SDA B12

Note: the PCIe slot pin numbering follows the same convention as Dell parts (they have A1-A49/B1-B49 markers) and as the Wikipedia article on PCIe.

Note: you will need to add pull up resistors for SCL and SDA. 4k7 is a good value to start with. Use a scope to make sure the open drain/pullup behaviour looks sensible.

Note: we run the I2C bus and EEPROM at 3.3V, even though it runs at 5V while in a server. This is fine for HBJ11 flashing, but might lead to issues when attempting to read/program Dell parts, like CERC6/i or the JM475.

Firmware

To build the firmware, you will need Rust with the thumbv7m-none-eabi target. We unfortunately don’t have Bazel integration yet, as rules_rust don’t integrate fully with Bazel’s toolchain/configurability system. This should be revisited at some point.

To get Rust with the right target, rustup is recommended (Nix users: nix-shell -p rustup):

$ rustup update
$ rustup default stable
$ rustup target add thumbv7m-none-eabi

Then, to build:

$ cargo build --release
$ file target/thumbv7m-none-eabi/release/hbj11-flasher-bluepill
target/thumbv7m-none-eabi/release/hbj11-flasher-bluepill: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, with debug_info, not stripped

Debug builds are also available, but they require a semihosting debugger attached - otherwise, they will immediately get stuck trying to log debug messages to the host.

Flashing Firmware

If using a BlackMagicProbe:

$ arm-none-eabi-gdb -x flash.gdb target/thumbv7m-none-eabi/release/hbj11-flasher-bluepill
[...]
Loading section .vector_table, size 0x130 lma 0x8000000
Loading section .text, size 0x3820 lma 0x8000130
Loading section .rodata, size 0xd88 lma 0x8003950
Start address 0x08000130, load size 18136
Transfer rate: 15 KB/sec, 906 bytes/write.

You can then C-c C-d and let the device run, or keep running it under the debugger. It should enumerate via USB:

$ lsusb -v | grep -A 4 0x16c0
  idVendor           0x16c0 Van Ooijen Technische Informatica
  idProduct          0x27d8 libusb-bound devices
  bcdDevice            0.10
  iManufacturer           1 Warsaw Hackerspace
  iProduct                2 Web I2C Programmer

We currently use an, uh, community VID/PID. This will change in the future as we apply for a pair from pid.codes or elsewhere.

Usage

The flasher is controller via WebI2C (through WebUSB).