Lopy sd card
-
Hello, I read on this forums that you can not boot the SD card with a LoPy (https://forum.pycom.io/topic/701/lopy-doesn-t-boot-from-sd-card). Is it true? And how to write and read on the sd card, I found some codes but they use a "from machine import SD" library which is not available on the LoPy (it generates an error when I try to Include it).
-
@bessonf
If you look at my sample in that post you found how to "boot" from SD card
You must mout your SD card inboot.pyand then exec file from sd cardfor file operation use help in python
https://docs.python.org/3/tutorial/inputoutput.htmle.g.: https://docs.pycom.io/pycom_esp32/library/machine.SD.html
from machine import SD import os sd = SD() os.mount(sd, '/sd') # check the content os.listdir('/sd') # try some standard file operations f = open('/sd/test.txt', 'w') f.write('Testing SD card write operations') f.close() f = open('/sd/test.txt', 'r') f.readall() f.close() -
No it doesn't work ... In fact the execution of the file fails when loading the SD library, it doesn't recognize it. I use the LoPy , do I need to upgrade the LoPy or something else ?
-
- What is your SD card size?
- And what error do you got and on which line of code?
- Do you use expansion board or direct connect?
-
-
@bessonf
strange
but try this and back with results - i have only Wipy and can not check this on Lopy:import machine help(machine) sd = machine.SD()and what is your firmware?
os.uname() -
For help(machine) :
help(machine) <module 'umachine'>object is of type module __name__ -- umachine mem8 -- <8-bit memory> mem16 -- <16-bit memory> mem32 -- <32-bit memory> reset -- <function> freq -- <function> unique_id -- <function> main -- <function> rng -- <function> idle -- <function> sleep -- <function> deepsleep -- <function> reset_cause -- <function> wake_reason -- <function> disable_irq -- <function> enable_irq -- <function> Pin -- <class 'Pin'> UART -- <class 'UART'> SPI -- <class 'SPI'> I2C -- <class 'I2C'> PWM -- <class 'PWM'> ADC -- <class 'ADC'> DAC -- <class 'DAC'> PWRON_RESET -- 0 SOFT_RESET -- 4And for os.uname() :
>>> os.uname() (sysname='LoPy', nodename='LoPy', release='1.0.0.b1', version='v1.8.6-237-g9d21f17 on 2016-12-15', machine='LoPy with ESP32') -
@bessonf
you must upgrade your board firmware
current version is
release='1.6.9.b1'
https://www.pycom.io/resources/you have really old one :release='1.0.0.b1
-
@livius
It works thank you very much. I work on the LoPy for 2 weeks and I completely missed this ... -
Hi @livius said in Lopy sd card:
You must mout your SD card in boot.py
you mean that we put in boot.py this:from machine import SD import os sd = SD() os.mount(sd, '/sd')and in the main.py we put the rest ?
because i try it but it does not work i get an OSError in :f = open('/sd/test.csv', 'a')my main.py is in /flash and i have a csv file in /sd that I want to fill it every time.
thanks
-
@assia
Which error do you get?
And what you get after:os.listdir('/sd') -
-
@assia
What's the storage size of the SD card?Larger cards tend to be pre-formatted as exFAT which is not enabled in the default Micropython configuration (as Microsoft demands a patent license)
-
Hi @jmarcelino the storage size is 2 Go and i had formatted it as FAT32.
I have already managed to write in this card by executing the commands directly into the pycom console in pymakr but now as I want to execute it in main.py I do not succeed.
thanks -
-
@jmarcelino
I put the code in main.py :from machine import SD import os sd = SD() os.mount(sd, '/sd') f = open('/sd/test.csv', 'a')it worked but just the first time also in REPL and when I restart my lopy I get:
OSError in os.mount(sd, '/sd') like:
OSError: the requested operation is not possibleI suppose that the SDcard remains mounted and we can not mount it a second time in this case we must check if it is already mounted and then writing on it
-
This post is deleted!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login