STM32H562 + MicroPython frozen + PRODUCT_STATE=CLOSED: WS2812 / machine.bitstream hangs #19294
Replies: 1 comment 2 replies
-
|
I continued investigating the The issue turned out not to be related to GPIO or frozen code. Normal access to pin from machine import Pin
p = Pin("PE4", Pin.OUT)
p.value(0)
p.value(1)The problem is inside the STM32 implementation of In DWT->CYCCNT = 0;
*bsrr = high_mask;
while (DWT->CYCCNT < t[0]) {
;
}After import stm
DEMCR = 0xE000EDFC
DWT_CTRL = 0xE0001000
DWT_CYCCNT = 0xE0001004
stm.mem32[DEMCR] |= 1 << 24
stm.mem32[DWT_CYCCNT] = 0
stm.mem32[DWT_CTRL] |= 1
a = stm.mem32[DWT_CYCCNT]
for i in range(100000):
pass
b = stm.mem32[DWT_CYCCNT]
print("a =", a)
print("b =", b)
print("ctrl =", hex(stm.mem32[DWT_CTRL]))Result: So the enable bit is set, but I made a local patch in After that, the old Python code using I think it would be useful to add a similar check in one of the next MicroPython releases, so that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have a MicroPython project for an STM32H562. The project code is frozen into the firmware using
frozen/manifest.py.The main startup code is located in
main.pyon the SD card:While the MCU was in the open state, everything worked normally: SD card, frozen modules, telemetry, UART protocols, and RGB indicators.
After switching the STM32H5 to:
the firmware started hanging during startup.
At first, it looked like the problem might be related to the SD card or frozen modules. But after step-by-step testing, I found that the hang happens during initialization of the WS2812 RGB indicators.
The RGB chain is connected to pin
PE4.The old driver used:
In the open state, this worked.
After
PRODUCT_STATE = CLOSED, the code hangs exactly on themachine.bitstream()call.I separately tested normal GPIO access to the pin:
This works. So the GPIO itself is not blocked, and the pin is accessible.
I also tried replacing
machine.bitstream()with my own driver using@micropython.viper, direct GPIO register access, and IRQ blocking. But after freeze andPRODUCT_STATE = CLOSED, this approach also did not give a reliable result.As a temporary safe mode, I removed the physical WS2812 data output and left only this in
NeoPixel.write():After that, the firmware starts normally,
protolyx.run()runs, telemetry works, and the protocols work. But of course, the RGB LEDs do not light up.My current conclusions:
PE4;PRODUCT_STATE = CLOSED.I would like to understand whether anyone has seen similar behavior on STM32H5 with MicroPython.
I am interested in why
machine.bitstream()or a similar runtime driver may hang afterPRODUCT_STATE = CLOSED, even though normal GPIO access still works.What is the correct way to handle WS2812 in this situation so that it works reliably after freezing the code and closing the MCU?
Beta Was this translation helpful? Give feedback.
All reactions