cancel
Showing results for 
Search instead for 
Did you mean: 

Using STMCubeIDE and Micropython

Phil-Axiom
Associate

I want to add a USB thumb drive (mass storage) to a NUCLEO-144 F767ZI board. I see the STM32CubeIDE can be used to point GPIO lines PA8~PA12, PG6, PG7 to connector CN13 (USB Micro-AB) or to the Morpho connectors to realize a USB OTG (On the Go) interface suitable for thumb drives.

Three questions - 

1.  Is it possible to use the STM32CubeIDE to configure the NUCLEO for USB OTG **and** also have Micropython running for the main application code? 

This may be thought of as a 'hybrid software' solution leveraging parts of STM32CubeIDE (for USB OTG setup) and Micropython.  Preferably, I'd like to implement the USB thumb drive in Micropython exclusively, but I've not found a solution to do that.

2.  Any suggestions for a purely Micropython implementation of STM32 USB OTG interface to support a USB thumb drive?

3.  Any suggestions (is it even possible?) for a hybrid software solution that uses parts of STM32CubeIDE to configure hardware (with compiled C modules) and also allows Micropython to run for application software?  If so, any suggestions for implementing the hooks (register access, function calls, data sharing) between Micropython and features implemented in C and configured by STM32CubeIDE?

Thank you in advance for any insights or suggestions you may offer.

2 REPLIES 2
TDK
Guru

It's almost certainly possible, but examples are unlikely to exist and it's probably not worth the effort. If you set up the USB OTG in STM32CubeIDE, then jump to your python code, it should work, as USB is handled in interrupts. As long as you are careful about modifying the vector table. I doubt micropython is set up for this out of the box.

These are single threaded processors. Whatever code is running has access to the entire chip. Python can't access memory addresses directly. Might be a workaround in micropython similiar to ctypes in windows, but not sure.

If you feel a post has answered your question, please click "Accept as Solution".

Thank you for your reply. 

I have used ctypes in Micropython to access RP2040 ADC and SYSTEM CLK registers directly but it's not clear to me how the compiled "USB host mode" c-code from STM32CubeIDE would be accessible from Micropython. 

I'll keep hunting for examples.  Unfortunately the forum.micropython.org has been down for maintenance the last couple of days - Google search results list several posts there on the topic.

Any other pointers or examples of compiled c code coexisting with Micropython?

thanks!