hardware_pio: fix pio_encode_mov(pio_pindirs, ...) on RP2350 #2946
No reviewers
Labels
No labels
bazel
bluetooth
board settings
boot_stage2
bug
build
c++
can't reproduce
clang
clib-interface
cmsis
code cleanliness
code size
compiler version issues
cyw43_driver
debug
discussion
documentation
duplicate
dynamic_clock
elf2uf2
enhancement
errata
filesystem
flash layout
floating point
FreeRTOS
hardware_adc
hardware_claim
hardware_clocks
hardware_dma
hardware_exception
hardware_flash
hardware_gpio
hardware_i2c
hardware_irq
hardware_pio
hardware_pwm
hardware_rcp
hardware_rtc
hardware_spi
hardware_sync
hardware_uart
hardware_vreg
hardware_watchdog
hardware_xosc
help wanted
host
IAR
installation
invalid
linker scripts
lto
lwip
mbedtls
missing API
needs reporter detail
networking
newlib
newlib-multicore
non-c
non-cmake
non-gcc
openocd
orphan PR
OS integration
pico_async_context
pico_base
pico_binary_info
pico_flash
picolibc
pico_lwip
pico_malloc
pico_multicore
pico_printf
pico_runtime
pico_stdio
pico_stdio_usb
pico_sync
pico_time
pico_util
pioasm
port
question
review
review2
rtos interop
runtime init
static library
svd
test
tinyusb
vscode
wifi integration
wontfix
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-raspberrypi/pico-sdk!2946
Loading…
Reference in a new issue
No description provided.
Delete branch "fix-pio-mov-pindirs"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes #2754. On RP2350,
pio_encode_mov(pio_pindirs, pio_x)returned0xA081(which isMOV EXEC, X) instead of the correct0xA061(MOV PINDIRS, X).The PIO MOV destination encoding for PINDIRS differs from the SET/IN/OUT encoding:
The
pio_src_destenum collapses bothpio_pindirsandpio_exec_movto low-3-bits = 4 because the SET/IN/OUT encoder is the original consumer. The MOV encoder needs to remap PINDIRS to 3 — but only for PINDIRS, not for EXEC. In release builds (NDEBUG),pio_pindirsandpio_exec_movare numerically identical (the_PIO_INVALID_*flag bits are all zero), so a naive "dest == 4 → 3" remap would also breakpio_encode_mov(pio_exec_mov, ...).This PR adds a non-
NDEBUG-gated marker bit (_PIO_MARKER_PINDIRS = 0x100) carried only bypio_pindirs. The new_pio_mov_dest_bits()helper checks the marker onPICO_PIO_VERSION > 0and remaps to 3. All existing encoders already mask with& 7ubefore emitting the destination field, so the marker bit is discarded everywhere it isn't being checked — no other encoder is affected. The debug-mode_PIO_INVALID_MOV_DESTassertion is also dropped frompio_pindirson RP2350.Test plan
Host-side verification of the constant-folded encoding emitted by each
pio_encode_*:mov pindirs, xmov exec_mov, xmov pc, xmov y, y(NOP)set pindirs, 1out pindirs, 1in pins, 1mov_not pindirs, xmov_reverse pindirs, xPICO_PLATFORM=rp2040 PICO_BOARD=pico.PICO_PLATFORM=rp2350 PICO_BOARD=pico2.Force-pushed to drop the
Co-Authored-Bytrailer. New HEAD:6a990bbb.closed in favor of #2958
Pull request closed