All, this was strange. I had worked with the dma/channel-irq example with SDK 1.5 and I had renamed the source file from pio_serialiser.pio to dma-channel-irq.pio. Within the pio source file the .program name was unchanged from pio_serialiser. Then in the C source file I simply loaded:
There was no problem having a .program <name> within the pio file that differed from the <source-file-name>.pio. However, after updating the SDK to 2.0, the header is no longer generated - even starting with a fresh directory containing only the source/CMakeLists.txt files.
I scratched my head for a while and then renamed all files to remove the hyphens and replace with underscores and made the pio .program <name> match the <source-file-name>.pio and updated the CMakeLists.txt to generate the pio header under the new name, e.g.
Files Renamed:
pio .program name updated in pio file
C source file update from pio_serialiser
The code then built fine, the pio header was generated under the new name, but why was the renaming necessary? Did the SDK 2.0 change something related to pioasm and header-generation in this regard?
When last built in 2022 under the SDK 1.5 version, there was no need to do anything special as far a syncing the pio .program <name> and the pio source file name. Here is the header generated by the 1.5 SDK version using "dma-channel-irq.c" and "dma-channel-irq.pio" source files retaining the original ".program pio_serialiser" program name for the pio routine:
No problems at all in 2022 with the earlier SDK, but this clearly would no longer build under SDK 2.0. Is there a new requirement in naming that now must be followed in SDK 2.0 for pio programs?
Code:
// Set up a PIO state machine to serialise our bits uint offset = pio_add_program(pio0, &pio_serialiser_program); pio_serialiser_program_init(pio0, 0, offset, PICO_DEFAULT_LED_PIN, PIO_SERIAL_CLKDIV);I scratched my head for a while and then renamed all files to remove the hyphens and replace with underscores and made the pio .program <name> match the <source-file-name>.pio and updated the CMakeLists.txt to generate the pio header under the new name, e.g.
Files Renamed:
Code:
CMakeLists.txtdma_channel_irq.cdma_channel_irq.pioCode:
.program dma_channel_irq; Just serialise a stream of bits. Take 32 bits from each FIFO record. LSB-first..wrap_target out pins, 1.wrap% c-sdk {static inline void dma_channel_irq_program_init(PIO pio, uint sm, uint offset, uint data_pin, float clk_div) { pio_gpio_init(pio, data_pin); pio_sm_set_consecutive_pindirs(pio, sm, data_pin, 1, true); pio_sm_config c = dma_channel_irq_program_get_default_config(offset); ...Code:
#include "dma_channel_irq.pio.h"... // Set up a PIO state machine to serialise our bits uint offset = pio_add_program(pio0, &dma_channel_irq_program); dma_channel_irq_program_init(pio0, 0, offset, PICO_DEFAULT_LED_PIN, PIO_SERIAL_CLKDIV);When last built in 2022 under the SDK 1.5 version, there was no need to do anything special as far a syncing the pio .program <name> and the pio source file name. Here is the header generated by the 1.5 SDK version using "dma-channel-irq.c" and "dma-channel-irq.pio" source files retaining the original ".program pio_serialiser" program name for the pio routine:
Code:
// -------------------------------------------------- //// This file is autogenerated by pioasm; do not edit! //// -------------------------------------------------- //#pragma once#if !PICO_NO_HARDWARE#include "hardware/pio.h"#endif// -------------- //// pio_serialiser //// -------------- //#define pio_serialiser_wrap_target 0#define pio_serialiser_wrap 0static const uint16_t pio_serialiser_program_instructions[] = { // .wrap_target 0x6001, // 0: out pins, 1 // .wrap};#if !PICO_NO_HARDWAREstatic const struct pio_program pio_serialiser_program = { .instructions = pio_serialiser_program_instructions, .length = 1, .origin = -1,};static inline pio_sm_config pio_serialiser_program_get_default_config(uint offset) { pio_sm_config c = pio_get_default_sm_config(); sm_config_set_wrap(&c, offset + pio_serialiser_wrap_target, offset + pio_serialiser_wrap); return c;}static inline void pio_serialiser_program_init(PIO pio, uint sm, uint offset, uint data_pin, float clk_div) { pio_gpio_init(pio, data_pin); pio_sm_set_consecutive_pindirs(pio, sm, data_pin, 1, true); pio_sm_config c = pio_serialiser_program_get_default_config(offset); sm_config_set_out_pins(&c, data_pin, 1); sm_config_set_fifo_join(&c, PIO_FIFO_JOIN_TX); sm_config_set_clkdiv(&c, clk_div); sm_config_set_out_shift(&c, true, true, 32); pio_sm_init(pio, sm, offset, &c); pio_sm_set_enabled(pio, sm, true);}#endifStatistics: Posted by drankinatty — Fri Jul 25, 2025 9:40 am