ShubhamTaple opened a new pull request, #22111:
URL: https://github.com/apache/nuttx/pull/22111
## Summary
`up_disable_irq()` had two bugs:
1. The range check was `irq - RP23XX_IRQ_EXTINT >= RP23XX_IRQ_EXTINT`, which
simplifies to `irq >= 32`, silently skipping NuttX IRQs 16–31 (external IRQs
0–15). The correct condition is `irq >= RP23XX_IRQ_EXTINT`.
2. The NVIC register selection tested the **NuttX** IRQ number (`irq < 32`)
instead of the **external** IRQ number (`irq - RP23XX_IRQ_EXTINT < 32`).
`up_prioritize_irq()` had two bugs:
1. The range check used `irq < RP23XX_IRQ_EXTINT + 32`, which only covered
external IRQs 0–31. External IRQs 32–51 (NuttX IRQs 48–67) fell through to
`return ERROR` and could not be reprioritized.
2. `NVIC_IRQ_PRIORITY()` was passed the NuttX IRQ number instead of the
external IRQ number. For example, `up_prioritize_irq(RP23XX_TIMER0_IRQ_0, ...)`
wrote IPR4 (external IRQs 16–19) instead of IPR0 (external IRQs 0–3).
Also remove stale handler names from the comment block above the exception
handlers: `rp23xx_busfault`, `rp23xx_usagefault` and `rp23xx_dbgmonitor` are
not defined in this file, and `rp23xx_pendsv` was listed twice.
## Impact
- **Users**: Fixes `up_disable_irq()` for external IRQs 0–15 (NuttX 16–31),
which previously could not be disabled. Fixes undefined behavior when disabling
external IRQs 16–31 (NuttX 32–47). Fixes `up_prioritize_irq()` so all 52
external interrupts can be reprioritized correctly when `CONFIG_ARCH_IRQPRIO=y`.
- **Build process**: No change. The patch is a pure bug fix; no new Kconfig
options or build dependencies are introduced.
- **Hardware**: Affects all `arch/arm/src/rp23xx` targets (RP2350,
Cortex-M33). Code size is unchanged apart from a few arithmetic instructions.
- **Documentation**: None. No public API or configuration options change.
- **Security**: None.
- **Compatibility**: No API breakage. The function signatures and behavior
for valid inputs are preserved; invalid inputs now behave correctly instead of
silently doing the wrong thing.
## Testing
**Host**: Linux x86_64, arm-none-eabi-gcc (15:13.2.rel1-2) 13.2.1 20231009
**Target**: `raspberrypi-pico-2:nsh` (ARM Cortex-M33, RP2350) - build-only.
**What was verified**:
1. **Baseline build** — the configuration builds cleanly before and after
the patch:
```bash
make distclean
./tools/configure.sh raspberrypi-pico-2:nsh
make menuconfig # with Prioritized interrupt support enabled
make -j$(nproc)
```
```bash
make -j$(nproc)
CPP:
/workspaces/nuttx/boards/arm/rp23xx/raspberrypi-pico-2/scripts/memmap_default.ld->
/workspaces/nuttx/boards/arm/rp23xx/raspberrypi-pico-2/scriptsLD: nuttx
Memory region Used Size Region Size %age Used
FLASH: 170768 B 4 MB 4.07%
RAM: 13192 B 512 KB 2.52%
SCRATCH_X: 0 B 4 KB 0.00%
SCRATCH_Y: 0 B 4 KB 0.00%
Generating: nuttx.uf2
Done.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]