From 94f0957e111ebd4a1643fc72f3be0258e1e0686f Mon Sep 17 00:00:00 2001 From: Jan Vos Date: Fri, 25 Sep 2026 22:54:13 +0200 Subject: [PATCH 1/2] fix SPI header memory issue --- src/dmdreader.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/dmdreader.cpp b/src/dmdreader.cpp index 13d5044..d65fe7f 100644 --- a/src/dmdreader.cpp +++ b/src/dmdreader.cpp @@ -35,6 +35,9 @@ typedef struct __attribute__((__packed__)) block_pix_header_t { uint16_t padding; // padding bits } block_pix_header_t __attribute__((aligned(4))); +block_header_t h = {}; +block_pix_header_t ph = {}; + DmdType dmd_type; // Line oversampling @@ -257,15 +260,6 @@ void spi_clean_exit() { * @param pixbuf a frame to send */ bool spi_send_pix(uint8_t *pixbuf, bool skip_when_busy) { - block_header_t h = {.block_type = SPI_BLOCK_PIX}; - block_pix_header_t ph = {}; - - // round length to 4-byte blocks - h.len = (((target_bytes + 3) / 4) * 4) + sizeof(h) + sizeof(ph); - ph.columns = source_width; - ph.rows = source_height; - ph.bitsperpixel = target_bitsperpixel; - if (skip_when_busy) { if (spi_busy()) return false; } @@ -1564,6 +1558,13 @@ void dmdreader_spi_init() { pinMode(SPI0_CS, OUTPUT); digitalWrite(SPI0_CS, LOW); + // Set up SPI header + h.len = (((target_bytes + 3) / 4) * 4) + sizeof(h) + sizeof(ph); + h.block_type = SPI_BLOCK_PIX; + ph.columns = source_width; + ph.rows = source_height; + ph.bitsperpixel = target_bitsperpixel; + // initialize SPI slave PIO dmdreader_error_blink(pio_claim_free_sm_and_add_program_for_gpio_range( &clocked_output_program, &spi_pio, &spi_sm, &spi_offset, SPI_BASE, 4, From 73cbc4a783726856b0d43960ebaa3b183165e263 Mon Sep 17 00:00:00 2001 From: Jan Vos Date: Fri, 25 Sep 2026 23:04:55 +0200 Subject: [PATCH 2/2] update to latest platform-raspberrypi --- platformio.ini | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/platformio.ini b/platformio.ini index db80727..70f9f54 100644 --- a/platformio.ini +++ b/platformio.ini @@ -2,14 +2,14 @@ default_envs = rp2040 [env:rp2040] -platform = https://github.com/maxgerhardt/platform-raspberrypi#79ce473e1a8010ed8096388690222fd2c94858a6 +platform = https://github.com/maxgerhardt/platform-raspberrypi/archive/5d4561a05e3b212660ac6fdd3fbfb328d1988aa1.tar.gz framework = arduino board = pico board_build.core = earlephilhower board_build.filesystem_size = 0.5m [env:rp2350] -platform = https://github.com/maxgerhardt/platform-raspberrypi#79ce473e1a8010ed8096388690222fd2c94858a6 +platform = https://github.com/maxgerhardt/platform-raspberrypi/archive/5d4561a05e3b212660ac6fdd3fbfb328d1988aa1.tar.gz framework = arduino board = rpipico2 board_build.core = earlephilhower