try to run Python on SD with STM32F405

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
ALTENTB
 
Posts: 2
Joined: Thu Sep 16, 2021 5:35 am

try to run Python on SD with STM32F405

Post by ALTENTB »

We're using a STM32F405 Express microcontroller in order to develop a machine learning algorithm. It consists in a python main code (315kB) and pyton libraries (about 1GB including 400MB tensoflow library).
Since there is no room enough to load sofware into microcontroller memory is it possible to use SD card ? If so can you explain us the procedure to run our code in SD card ?

Thank you for your help

B.R.

ALTENTB

User avatar
jerryn
 
Posts: 1869
Joined: Sat Sep 14, 2013 9:05 am

Re: try to run Python on SD with STM32F405

Post by jerryn »

Here is a code example that will mount the SDCard and add it to your path so you can just import modules from the SDCard.

Code: Select all

import os
import board
import sdioio
import storage
import sys
sd = sdioio.SDCard(clock=board.SDIO_CLOCK,command=board.SDIO_COMMAND,data=board.SDIO_DATA,frequency=25000000)
vfs = storage.VfsFat(sd)
storage.mount(vfs, '/sd')
sys.path.append("/sd")
sys.path.append("/sd/lib")

So if you put a file neame hello.py on the SDCard, you can now just use
import hello
You can also put files int a folder named "lib" on the SDCard and they will be found by "import"

However, I expect you will have trouble running code that complex since you will likely still run out of RAM.

Note: I do not represent Adafruit. Just trying to help.

User avatar
ALTENTB
 
Posts: 2
Joined: Thu Sep 16, 2021 5:35 am

Re: try to run Python on SD with STM32F405

Post by ALTENTB »

Thank you for your quick answer :)
We meet another issue : it seems MicroPython doesn't allow to use all libraries we need : we use python libraries which are not included in MicroPython. We Don't know if we can use a Full python workspaceon these boards.
B.R.

User avatar
jerryn
 
Posts: 1869
Joined: Sat Sep 14, 2013 9:05 am

Re: try to run Python on SD with STM32F405

Post by jerryn »

The above example was for CircuitPython, not MicroPython. I'm sorry if I misunderstood your request.
As I noted, the main limitation will be the amount of RAM available on the board. I doubt you'll be able to use may of the standard Python libraries.

User avatar
tannewt
 
Posts: 3304
Joined: Thu Oct 06, 2016 8:48 pm

Re: try to run Python on SD with STM32F405

Post by tannewt »

It sounds to me like you want a single board computer running CPython on Linux. Microcontrollers can't really do anything in the 10+ MB range.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”