It makes me a little uncomfortable, telling people, “go ye, change what code you will and flash then thine own firmware. Easy!”, when I haven’t done it myself.
Even though I theoretically know how, I had never actually worked with the output expander’s firmware.
So I’ve made a project based on @Wizard’s latest open source that builds alternate firmware for the Output Expander, and describes (here and in the README.MD) how I got there.
(Note that this is not intended as a contest entry, just a little handy information on a way-out-there fringe topic.)
The project lives here, on Github. Pre-built files of my “special” version, as well as a build of the original firmware can be found in the project’s “Releases” area.
The new firmware solves a problem discussed in this forum thread. It works with WS2812-protocol RGBW LEDs and allows the user to choose between normal RGBW operation and RGB-W operation, which disables the W channel and uses RGB values from Pixelblaze to produce white.
If you decide to use try this firmware, to choose your output mode:
- for RGB-W (no white channel) , choose a 3 element RGB option in the proper color order from the Pixelblaze’s expander board setup.
- for RGBW, choose the 4-element RGBW option you would normally use from the Pixelblaze’s expander board setup.
Note that 3-element RGB WS2812s will not work properly with this firmware. It only supports 4-element RGBW LEDs. Non-WS2812 protocol LEDs, like the APA-102, will work normally.
What you’ll need
- STM32CubeIDE from STM32CubeIDE - Integrated Development Environment for STM32 - STMicroelectronics
- STM32CubeProgrammer from STM32CubeProg - STM32CubeProgrammer software for all STM32 - STMicroelectronics
- An ST-Link V2 Programmer or emulator. I used this one: https://www.amazon.com/HiLetgo-Emulator-Downloader-Programmer-STM32F103C8T6/dp/B07SQV6VLZ
- Quite a lot of dupont wires or other small, easy-to-connect wiring.
- A soldering iron & lead-free solder
- A Pixelblaze
- A Pixelblaze Output Expander board, marked v2 (2019) or newer.
- a few RGBW LEDs to test
WARNING:
Modifying firmware can break your device and potentially other connected devices. If you attempt this, you are solely and completely responsible for the outcome. So go slowly and be careful. Triple check polarity, disconnect everything else from your output expander when programming and… try to keep the cat away
from your work area.
Building the firmware
From Scratch
- Clone or download the original OutputExpanderFirmware project from GitHub - simap/pixelblaze_output_expander.
- Create an empty directory for your project-to-be
- Create a project in your new empty directory by having STM32CubeIDE “Import an existing STM32CubeMX configuration file (.ioc)” from the expanderboard2.ioc file in pixelblaze_output_expander/firmware.
- Copy the Core and Drivers directories from pixelblaze_output_expander/firmware to your new project. Just drag each directory on over to the new location.
Try building your new project in STM32CubeIDE - you should now be able to successfully compile.
From OutputExpanderFlashTest
- Download or clone this project - GitHub - zranger1/OutputExpanderFlashTest: STM32CubeIDE project to flash alternate firmware to the Pixelblaze output expander
- Open it in STM32CubeIDE
- Select the .ioc file and build the project
Programming the Output Expander
Once you’ve successfully built the firmware, it is time to download it
to the Output Expander’s flash memory!
Connecting STM Programmer to Output Expander
You’ll be connecting the 5 SWD(Serial Wire Debug)pads on the bottom of the output expander to the corresponding 5 line on your STM programmer. The required lines are 3.3v, GND, Data, Clock and Reset. If you’re going to do this frequently, you might want to order some pogo pins, and 3D print or otherwise craft a programming jig for yourself.
I just soldered short wires to the pads.
Programming the Output Expander
With your STM Programmer wired to the Output Expander and plugged into a USB port in your computer, open the STM32CubeProgrammer application. On the right hand side, you’ll see the ST-Link configuration window. Set the configuration as follows:
-
Port to SWD
-
Frequency to 4000
-
Mode to Under reset
-
Access port to 0
-
Reset Mode to Hardware reset
-
Speed to Reliable
-
Shared to Enabled
-
Uncheck Debug in Low Power Mode
-
Now click the “Refresh” icon next to the Serial Number field. Your Programmer’s serial number should be displayed.
-
Click the “Connect” button. If all is working properly, you should see a bunch of information about the Output Expander’s CPU. Now you’re ready to download the new firmware.
On the left hand side of the application, you’ll see a column of icons for selecting tabs. Choose the “Erasing and Programming” tab (second from the top, not counting the hamburger menu).
Use the file path control to select your .elf file. Depending on which build configuration you’ve chosen it will be “pixelblaze_output_expander.elf” in either the Debug or Release subdirectory.
Once you’ve chosen the file, press the “Start Programming” button. A few seconds later, your new firmware will be successfully installed on your Output Expander.