Page 1 of 1

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

Posted: Fri Feb 22, 2019 8:19 pm
by JacquesC
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

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

Posted: Fri Feb 22, 2019 11:26 pm
by dhylands
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.

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

Posted: Sat Feb 23, 2019 9:46 am
by JacquesC
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 ?

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

Posted: Sat Feb 23, 2019 3:10 pm
by dhylands
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.

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

Posted: Wed Jul 17, 2019 7:33 am
by mcauser
Hi @JacquesC, @JohnLittle has had some success with the sdcard:
viewtopic.php?f=12&t=3086&start=90#p38142