How to build freertos as micropython library for Nucleo_H743ZI #17368
Replies: 4 comments
-
I personally think you can run real-time tasks within micropython already with the help of timers / interrupts / c-user-modules but it depends on how hard-real-time you need I guess. I don't use FreeRTOS myself though, it's much easier for me to stay within micropython. The only guidance I can give if you want to try freertos as a learning exercise is that the esp32 port already runs micropython as a task in the freertos platform that the esp idf supplies, so following that might be your best example |
Beta Was this translation helpful? Give feedback.
-
@parth-6 It would help if you described the application you have in mind. A key benefit of "bare metal" MicroPython ports (such as RP2 and STM) is minimal latency in response to external stimuli. This is precisely because there is no underlying OS which might be stealing cycles. If your application does not require microsecond-class latency there is A major MicroPython application domain is embedded code which usually involves a degree of realtime capability: I would investigate what MP already offers before considering a radical adaptation. |
Beta Was this translation helpful? Give feedback.
-
@parth-6 what kind of real-time tasks do you want to run? What are your requirements for average latency, latency jitter, and what else do you need to do that isn't quite real-time (communications, analysis, etc.)? @andrewleech and @peterhinch are both experts in both MicroPython and embedded systems, and their advice is spot on. The H743ZI is a very fast processor. I have used it with MicroPython in a motor control application where I was computing acceleration/deceleration curves for stepper motors on the fly in an interrupt handler (written as a loadable module in C). I was able to prototype the code in MicroPython, which greatly sped up the development process. When I wrote the C module, I used the same logic. This same C module worked without change on the H743ZI and the Pyboard. You can write "hard" interrupt handlers in MicroPython triggered by GPIO changes or timer interrupts. Handling of communications peripherals (I2C, SPI, UART, I2S, CAN, ENET, etc.) uses DMA for minimal processor loading. Refer to the MIcroPython documentation for the Pyboard for what's supported on your board. |
Beta Was this translation helpful? Give feedback.
-
Integrating a RTOS with MicroPython (or other way around) is a rather advanced task. I recommend checking the documentation on new ports. Apart from that you will likely need to get most of the information from reading the MicroPython code to see how existing ports are done, especially those that use RTOS - specifically the ESP32 (uses FreeRTOS via esp-idf) and Zephyr port. An alternative to writing custom integration would be to use Zephyr RTOS for the C level things on your STM32. Then you can reuse the Zephyr MicroPython port. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I'm a complete beginner to both MicroPython internals and FreeRTOS, and I'm working with the STM32 Nucleo-H743ZI board. I'm interested in integrating FreeRTOS with MicroPython to run real-time tasks alongside Python code.
My goal is to:
1.Build FreeRTOS as a static or standalone library.
2.Integrate that library into the MicroPython firmware for the Nucleo-H743ZI.
3.Understand the necessary modifications in the MicroPython source code and build system for this to work smoothly.
Specifically, I would appreciate help with:
1.What files I need to modify (e.g., mpconfigport.h, linker script, startup code, main.c, etc.),
2.How to adapt the MicroPython scheduler or main loop to run inside a FreeRTOS task,
3.Any changes needed for memory management or interrupt priority handling,
4.How to compile and link FreeRTOS with the existing MicroPython STM32 build system.
If there are any working examples, past discussions, or external resources that could help, I'd be really grateful if you could point me to them.
Thanks a lot for your time and support!
Beta Was this translation helpful? Give feedback.
All reactions