← index #15647PR #4349
Related · medium · value 0.712
QUERY · ISSUE

mimxrt boot automounts sd card without adding /lib to path, breaking imports

openby allieumopened 2024-08-13updated 2025-03-03
bugport-mimxrt

Port, board and/or hardware

mimxrt, teensy 4.1

MicroPython version

MicroPython v1.23.0 on 2024-06-02; Teensy 4.1 with MIMXRT1062DVJ6A

Reproduction

in https://github.com/micropython/micropython/blob/288a03625327b025f81bb6d4e7fb76d56343172c/ports/mimxrt/modules/_boot.py#L34 an sd card is automounted to /sdcard and then os.chdir makes this the working directory. However, /sdcard/lib is not added to the import paths so code located there will not be found by import statements.

Ran into this when using the mpr xrun tool, because the underlying mpremote commands work relative to the working directory, ended up in a state where .mpy files are copied over to /sdcard/lib but the when the program runs it can't find them.

Expected behaviour

Not sure the appropriate behavior here, but the issue would maybe have been avoided if either

  1. /sdcard/lib were added to the path, like /flash/lib is a few lines above, or
  2. if there were no os.chdir to the automounted sd card. this would allow mpr/mpremote to continue to use /flash as working directory, per usual without breaking the handy mpr xrun command. I hadn't initially expected that /sdcard would become the working directory which caused confusion in tracking down this behavior.

as a workaround I am using the functionality where creating the file /flash/SKIPSD skips the SD card auto-mount.

Observed behaviour

n/a

Additional Information

No, I've provided everything above.

Code of Conduct

Yes, I agree

CANDIDATE · PULL REQUEST

stm32/main: Add boardconfig option to enable/disable booting from sdcard

closedby andrewleechopened 2018-12-13updated 2018-12-21

With this PR MICROPY_HW_BOOT_SDCARD can be defined to (0) in mpconfigboard.h to allow SD hardware to be enabled but not auto-mounted at boot.

Previously, if an SD card is enabled in hardware it is also used to boot from.

While booting from SD card can be disabled with a SKIPSD file on internal flash, this wont be available at first boot after flashing or if the internal flash gets corrupted.

We're working on a product that uses an SD card for bulk storage, however we don't want code to be stored or run from the card. This PR allows us to enforce this from first boot of a fresh DFU image.

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