← index #4058Issue #2949
Related · medium · value 0.765
QUERY · ISSUE

pyboard, swapping sd cards

openby rhubarbdogopened 2018-08-17updated 2024-09-29
port-stm32

hi,
in my /flash directory i have a SKIPSD file
i mount my SD card as follows os.mount(pyb.SDCard(),'/sd')
using screen i enter a REPL session
I issue the command os.umount("/sd")
os.listdir('/') proves it's safe to remove the disk.
I extract it and put a new SD Card in.
When i issuse the command os.mount(pyb.SDCard(),'/sd') i get an OSError , error 19 ENODEV.

is it possible to swap SD cards whilst the pyboard is running? or does in need to be hard reset?

CANDIDATE · ISSUE

Device Crashes Catastrophically when accessing SD in certain situations

closedby ryannathansopened 2017-03-10updated 2017-03-14

Steps to reproduce

  1. Make sure device has SD Card inserted.
  2. Make sure device has SKIPSD on internal flash
  3. Run the following in main.py on internal flash. This puts my device in a boot loop.

It seems os.listdir('/') in another module crashes the device after throwing an exception with a file on the SD card.

Some devices fail the listdir in test with memory allocation fail 7958574 bytes and some devices get stuck in a boot loop, immediately crashing and restarting without displaying an error.

Using STM32F439 on these devices

import os
import pyb

print(os.listdir('/'))

with open('/flash/test.py', 'wb') as file:
                file.write(b"import os\nos.listdir('/')\n")

if 'sd' not in os.listdir('/'):
                os.mount(pyb.SD, '/sd')
                print("os.mount() successful")

print(os.listdir('/'))

with open('/sd/test.txt', 'wb') as file:
                for i in range(10000):
                                file.write(b"This is twenty bytes.")

file = open('/sd/test.txt', 'rb')
try:
                a = file.read()
except MemoryError:
                print('Exception thrown as expected')

print(os.listdir('/'))
import test

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied