Add support for CMD25 to write multiple sequential blocks in one go, in
an attempt to speed up uploads. It still needs to be benchmarked if this
actually results in a meaningful speedup.
Also fix logging from SD driver to be visible even when running under
micropython.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Apply the same pattern as in 6f155ebb55 ("audiocore: Fix small race
window in get_fifo_read_value_blocking") and 2a4033d3ca ("rp2_sd: Fix
race window in sd_spi_wait_complete") to the wait for interrupt in
i2s_stop too.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Similar to the fix in 6f155ebb55 ("audiocore: Fix small race window in
get_fifo_read_value_blocking"), a race and deadlock is possible when
calling __wfi with interrupts enabled. Fix it in sd_spi_wait_complete by
copying the fix from the above commit.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
The PIO has an internal synchronizer on each GPIO input which adds two
cycles of delay. This prevents metastabilities in the PIO logic (see
RP2040 datasheet p. 374f). For high speed synchronous interfaces such as
SPI this needs to be disabled to reduce input delay.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Spurious failures were observed with a SanDisk Ultra 32GB card that no
longer occur with the increased timeouts.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Move hardware-specifics (pin assignments, power management) to
hwconfig_*.py.
The build system will build a firmware image
firmware-filesystem-$variant.uf2 for all variants for which a
hwconfig_$variant.py file exits. Inside the filesystem image, the
selected variants hwconfig_$variant.py file will always be named
hwconfig.py.
At runtime, main.py will attempt to import hwconfig which will load the
configuration for the correct variant.
Currently, the hwconfig_* modules are expected to define the pin mapping
and implement a board_init method.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
- Old SDSC cards could have a native blocksize != 512 bytes, but they
should support the SET_BLOCKLEN command to set the blocksize to 512.
Use that so we can just assume 512 everywhere else.
- SDSC cards used byte addresses, not sector numbers, for the argument
of READ_BLOCK and WRITE_BLOCK. Check the card type and multiply the
sector number with 512 if necessary.
Tested with a noname chinese 128 MiB-ish card.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Migrated all patches from the previous version.
A change in the Findpicotool.cmake script in the pico-sdk led to a
downgrade of picotool, which incorporated mbedtls into the build, which
itself is not buildable with cmake versions < 3.5.
The commit which made this isolated change was reverted. Future versions
of micropython will use pico-sdk 2.2.0 or newer, where this problem is
fixed, and picotool is pinned to a release version.
In theory, the FIFO interrupt could occur after getting the
fifo_read_value and reenabling interrupts, but before __wfi is called,
causing a deadlock. Fix this by calling __wfi with interrupts still
disabled. It will return immediately if an interrupt is pending.
Add two __nop to ensure that the CPU has enough instructions between
enabling interrupts and disabling them again at the top of the loop.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Add write support to rp2_sd driver.
Cleanup standalone-mp3 test tool and add write test mode.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
The python and C modules that are supposed to be built into the firmware
image (i.e. those that are in manifest.py or in USER_C_MODULES) have
been moved to the software/modules directory.
The software/src directory should now only contain python scripts and
other files that should be installed to the Picos flash filesystem. The
idea is that these should be those scripts that implement the
application behaviour, as these are the ones that a user who does not
want to build the whole firmware themself wants to modify.