An alternative: to load binary data to some external device (here SPI RAM) then you could simply store that binary data directly on the filesystem as a binary file, then copy it to the external SPI RAM device using a simple loop, eg:
Code: Select all
buf = bytearray(1024)
with open('/assets/data.bin', 'rb') as f:
while True:
n = f.readinto(buf)
if n == 0:
break
spi.write(memoryview(buf)[:n])
Code: Select all
python3 tools/dfu.py -b 0x08080000:asset_data.bin asset.dfu
Then use uctypes.bytes_at(0x08080000, asset_len) to access the data directly.