Skip to content

About

No description, website, or topics provided.

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Repository files navigation

Powerblock

Powerblock is a USBTMC-controlled bench power supply with USB Power Delivery (USB-PD) input support, built on an STM32G0 microcontroller. It exposes a SCPI command interface over USBTMC or USB CDC for remote voltage/current control, measurement, protection, and calibration.

Cloning

Third-party libraries are included in the project as submodules. To initialize them, run the following command when cloning the repository:

git clone --recurse-submodules https://github.com/everypinio/PwrBlock-sw.git

If the repository already exists locally and the submodules need to be updated, run:

git submodule update --init --recursive

Submodule versions:

$ git submodule status
c7e7294e78a80be862340d8d50edd515ac3c41fd lib/cmsis_freertos (v11.2.0)
6f0a58d01aa9bd2feba212097f9afe7acd991d52 lib/hal/cmsis_6 (v6.2.0)
35e1201d4db3dbbd364b7decca957902f60bc5da lib/hal/cmsis_device_g0 (v1.4.4)
e194e5abc3a125ef08434f1ee122a2bc7b3d9af4 lib/hal/stm32g0xx_hal_driver (v1.4.6)
361fe25cb1fe4cacb4f7494944c5d4084eb07f61 lib/scpi_parser (v2.0-245-g361fe25)
66dab10c5f426c600aae1bac3908b9f4e279c0a4 lib/stm32_usbpd/core (v5.3.0)
f61249a45ee3903075d2a94ce8c7c9c0c49e029d lib/stm32_usbpd/devices/stm32g0xx (v3.5.2)
67786abc1e30941acec6666485c99b9326a33e08 lib/stm32_usbpd/tracer (V1.12.1)
331c263400dd5ccf77264cab1fa6bbd9f374b44e lib/tinyusb (0.19.0)

Building

Open the project in the container.

Build via the CMake Tools extension, the Build task in Task Explorer, or from the command line:

make build

Build configurations available:

  • Debug (TMC mode) — build with debug symbols for a USBTMC device.
  • Debug (CDC mode) — build with debug symbols for a CDC device (with extended WebUSB support).
  • Release (TMC mode) — optimized release build for a USBTMC device.
  • Release (CDC mode) — optimized release build for a CDC device (with extended WebUSB support).

CI and releases

GitHub Actions builds the release firmware automatically inside the repository Docker image on pushes to main, on pull requests, and on manual workflow runs. The workflow builds both release presets:

  • release-tmc
  • release-cdc

Build artifacts are uploaded as power_block-firmware and include generated .elf, .hex, .bin, .map, and SHA256SUMS files.

The default firmware version is stored in VERSION. Release builds created from tags use the tag value without the leading v as the firmware version reported by *IDN?.

To publish a GitHub Release, create and push a version tag:

git tag v0.1.0
git push origin v0.1.0

The tag workflow creates a release with autogenerated release notes and attaches the firmware artifacts. Pull request labels are used to group release notes into sections such as firmware changes, fixes, documentation, and maintenance.

Versioning rules and the release checklist are documented in docs/release_process.md. Release history is tracked in CHANGELOG.md.

Flash the firmware to the board via the Flash task in Task Explorer or from the command line:

make flash

Configuring

The main project configuration file is /src/bsp/periph_setup/periph_setup.ioc. The project is built using:

  • CubeMX: 6.15.0
  • CubeHAL: STM32Cube FW_G0 V1.6.2

Peripheral modifications can be made through it, keeping in mind the peripherals occupied by the stm32_usbpd library. Additional configuration (FreeRTOS, tinyUSB, TracerEMB) is located in /src/config. Occupied peripherals:

Library Peripherals
UCPD TIM1, DMA1_CH3, DMA1_CH4
TRACER_EMB USART3 (PB0, PB2), DMA1_CH2 (TX only)

After adding a peripheral in CubeMX and generating the project, run the cube_after_gen task or the following command:

make cube_after_gen

This is necessary to correctly format the sources and remove extra files generated by CubeMX.

Usage

USBCDC device

Any terminal program (PuTTY, moserial) will work to test the interface. The serial port speed configuration doesn't matter, since packets are sent at the maximum speed of the USB 2.0 device. The important setting is the line ending: CR (only). Communication with the device is done by sending requests as SCPI commands, as described above.

USBTMC device

The Python packages pyvisa, pyvisa-py, pyusb must be installed beforehand.

pip install pyvisa pyvisa-py pyusb

Sending commands and receiving data can be done from the pyvisa-shell console application; before starting work you need to get a list of devices:

Welcome to the VISA shell. Type help or ? to list commands.

(visa) list
( 0) USB0::0x1209::0x0002::0123456789ABCDEF::INSTR

Then open the corresponding port:

(visa) open 0
USB0::0x1209::0x0002::0123456789ABCDEF::INSTR has been opened.
You can talk to the device using "write", "read" or "query".
The default end of message is added to each message.

Queries are performed via the query command:

(open) query *IDN?
Response: EVERYPINIO,POWERBLOCK,0,0.1.0

Writing to the device is performed via the write command:

(open) write OUTPut ON
(open) query OUTPut?
Response: 1

An example script ./tools/usb_tmc_test.py for working with an SCPI device via Python is also implemented. Running the test:

python tools/usb_tmc_test.py

Permission issues on Linux

If needed, permissions on a block device of type usbtmc can be granted via the udev system. For a USBTMC device:

$ sudo echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="0002", GROUP="plugdev", MODE="0666"' > /etc/udev/rules.d/100-usbtmc.rules

For a CDC device with WebUSB support (required for Chrome device-connection notifications to work correctly):

$ sudo echo 'SUBSYSTEMS=="usb", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="0001", GROUP="plugdev", MODE="0666"' > /etc/udev/rules.d/100-usbtmc.rules

Reload the udev system without rebooting:

$ sudo udevadm control --reload-rules && sudo udevadm trigger

License

This project is licensed under the Apache License 2.0 — see LICENSE for the full text.

Third-party components

This firmware depends on several third-party libraries, included as git submodules under lib/. Each retains its own license, which continues to apply independently of this project's Apache 2.0 license.

Component License
tinyusb MIT
scpi-parser BSD 2-Clause
CMSIS_6 Apache 2.0
CMSIS-FreeRTOS Apache 2.0 + MIT
cmsis-device-g0 Apache 2.0
stm32g0xx-hal-driver BSD 3-Clause
stm32-util-usbpd-tracer-emb BSD 3-Clause
stm32-mw-usbpd-core SLA0044 (ST Ultimate Liberty)
stm32-mw-usbpd-device-g0 SLA0044 (ST Ultimate Liberty)

Notice on SLA0044 components

The USB-PD stack (lib/stm32_usbpd/core and lib/stm32_usbpd/devices/stm32g0xx) is distributed by STMicroelectronics under the SLA0044 Ultimate Liberty license, not an OSI-approved open-source license. Under its terms, this code:

  • may only be used and executed on or in combination with an STMicroelectronics microcontroller or microprocessor (which this project targets — STM32G0);
  • is provided by ST as a separate, independently licensed component and is not relicensed or covered by this repository's Apache 2.0 license.

These components are consumed as unmodified git submodules, each carrying its own LICENSE.md from ST. Anyone building or redistributing this firmware must comply with SLA0044 for those specific components in addition to the Apache 2.0 terms governing the rest of the codebase.

In addition, src/usbpd/ contains application/BSP glue code adapted from STMicroelectronics' x-cube-tcpp example project (Projects/NUCLEO-G071RB/Applications/USB_PD/SNK1M1_Sink), renamed and modified for this project. Unlike the submodules above, this code lives directly in the main tree rather than as an unmodified submodule. It remains under SLA0044 — see src/usbpd/LICENSE.md — and is not covered by this repository's Apache 2.0 license.

About

No description, website, or topics provided.

Resources

Contributing

Stars

3 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages