Black STM32F407VE6 : access to the SD card and modify root files.

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
User avatar
JacquesC
Posts: 16
Joined: Sun Feb 17, 2019 5:04 am

Black STM32F407VE6 : access to the SD card and modify root files.

Post by JacquesC » Fri Feb 22, 2019 8:19 pm

Hello,
For several days I have been blocking on several issues:
I have to save the data of a sensor in a file on the SD card.
1 - How to access the SD card reader?
2 - On the same subject: how to modify files on the "partition" which contains Root.py and main.py. As for writing there is no problem but to delete a file it blocks! It remains visible in the file explorer of the computer but is no longer accessible!
For other problem I open another Topics ;-)

Thank you for your help.
See you

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Black STM32F407VE6 : access to the SD card and modify root files.

Post by dhylands » Fri Feb 22, 2019 11:26 pm

If you're going to write to the filesystem using micropython then you should disable USB Mass Storage or you'll get a corrupted filesystem.

Removing files from the internal filesystem can be done using os.remove(filename)

filename should be something like /flash/filename to access the internal filesystem from Micropython. You'd use /sd/filename to access the sdcard from Micropython.

User avatar
JacquesC
Posts: 16
Joined: Sun Feb 17, 2019 5:04 am

Re: Black STM32F407VE6 : access to the SD card and modify root files.

Post by JacquesC » Sat Feb 23, 2019 9:46 am

I anderstand the problem
But if I want to write to the SD card I ve got an error :

Code: Select all

>>> 
paste mode; Ctrl-C to cancel, Ctrl-D to finish
=== import pyb
=== import os
=== os.mount(pyb.SDCard(), '/sd')
=== os.chdir('/sd')
=== 
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
AttributeError: 'module' object has no attribute 'SDCard'
>>> 
and when I ask in a console

Code: Select all

>>> dir(pyb)
['__class__', '__name__', 'DAC', 'RTC', 'ADC', 'ADCAll', 'CAN', 'ExtInt', 'Flash', 'I2C', 'LED', 'Pin', 'SPI', 'Switch', 'Timer', 'UART', 'USB_HID', 'USB_VCP', 'bootloader', 'delay', 'dht_readinto', 'disable_irq', 'elapsed_micros', 'elapsed_millis', 'enable_irq', 'fault_debug', 'freq', 'hard_reset', 'have_cdc', 'hid', 'hid_keyboard', 'hid_mouse', 'info', 'main', 'micros', 'millis', 'mount', 'repl_info', 'repl_uart', 'rng', 'standby', 'stop', 'sync', 'udelay', 'unique_id', 'usb_mode', 'wfi']
>>> 
Is there an other module that allow me to access to the cardreader ?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Black STM32F407VE6 : access to the SD card and modify root files.

Post by dhylands » Sat Feb 23, 2019 3:10 pm

If the sdcard is configured then it should be mounted automatically at boot time. You shouldn't have to mount it yourself.

At least that's what used to happen on the pyboard. It's been a while since I tried the sdcard.

User avatar
mcauser
Posts: 507
Joined: Mon Jun 15, 2015 8:03 am

Re: Black STM32F407VE6 : access to the SD card and modify root files.

Post by mcauser » Wed Jul 17, 2019 7:33 am

Hi @JacquesC, @JohnLittle has had some success with the sdcard:
viewtopic.php?f=12&t=3086&start=90#p38142

Post Reply