Make mypy run with proper type stubs for micropython RP2.
Add basic structure for pytest testing.
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 utils.MBRPartition to implement basic partitioned device support.
Try to mount partition 1 of SDCard first, if that fails, try to mount
entire device as FAT file system.
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>
Change PlayerApp to new architecture
- depedencies injected via named tuple
- some initial type checking
- move on button press logic to PlayerApp
TODO: Adapt MP3 player
Copy and clean up test.py to main.py. Add app module (currently on
app.py, maybe make it a directory later) for application classes.
Implement app.TimerManager to allow scheduling of delayed events in the
micropython async framework.
Implement app.TagPlaybackManager which handles playing back MP3 files
based on the NFC tag reader. Currently, simply plays all MP3 files in a
folder, for which the folder name matches the tag id, in order. Resume,
random and other features not yet supported.
Upgrade and cherry-picks were necessary due to a compilation issue
introduced with gcc 15.1 regarding unterminated string literals. For more
details see https://github.com/micropython/micropython/pull/17269.
Still hot and untested...
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.
Rename the exising audiocore C module to _audiocore and create a new
Micropython wrapper module audiocore. This makes it easier to implement
async methods.
Add interrupt support to _audiocore that notifies core0 whenever data
has been consumed from the MP3 bitstream buffer.
Use this interrupt and an asyncio.ThreadSafeFlag to implement
audiocore.async_put which will play back the provided buffer, allowing
other async tasks to run while waiting for space in the bitstream
buffer.
- Use SD_SECTOR_SIZE define instead of magic number 512
- Replace uint8_t buf[1] with plain uint8_t
- Check sd_spi_read_dma precondition that sd_dma_context state has to be
DMA_IDLE explicitly and return false instead of relying on assert
- sd_spi_dma_isr is time critical
The builtin micropython SD card driver using the default micropython SPI
implementation suffered from very low read speeds. Add an optimized SD
card driver using rp2 PIO and DMA. Currently read only, write support to
be added later.
Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
Not as async as possible, and definately needs a future revisit. But
works for now, with acceptable delays, if the newly introduced
tocard_retries parameter of class MFRC522 is used and set to a
reasonable low value.