ITADN

Duplicate definitions between addressmap.h and CMSIS RP2040.h

#2893Closedmultiplemonomials 创建于 2026-04-08
It appears that the Pico SDK addressmap.h header contains some compile definitions with the same names and values as definitions from the CMSIS header RP2040.h. This causes warnings like the following if both headers are included by the same source file: ``` pico-sdk/src/rp2040/hardware_regs/include/hardware/regs/addressmap.h:29:9: warning: "XIP_CTRL_BASE" redefined 29 | #define XIP_CTRL_BASE _u(0x14000000) | ^~~~~~~~~~~~~ In file included from mbed-os/targets/TARGET_RASPBERRYPI/TARGET_RP2040/cmsis.h:4, from mbed-os/targets/TARGET_RASPBERRYPI/TARGET_RP2040/mbed_overrides.c:1: pico-sdk/src/rp2_common/cmsis/stub/CMSIS/Device/RP2040/Include/RP2040.h:2585:9: note: this is the location of the previous definition 2585 | #define XIP_CTRL_BASE 0x14000000UL ``` This was reported previously in #1996 , but that issue seems like it was resolved by just not including both headers from the same source file. However, for my use case (integrating RP2xxx support into Mbed OS), I need to include both RP2040.h and RPi Pico SDK headers which use addressmap.h, so this is a no go for me. I ended up patching addressmap.h on our end to have the following: ```cpp // Peripheral base addresses. These are defined in the CMSIS header so include it // if it's available (and we are not being included from assembly) #if __has_include(<RP2040.h>) && !defined(__ASSEMBLER__) #include <RP2040.h> #else #define XIP_CTRL_BASE _u(0x14000000) #define SYSINFO_BASE _u(0x40000000) #define SYSCFG_BASE _u(0x40004000) #define CLOCKS_BASE _u(0x40008000) #define RESETS_BASE _u(0x4000c000) #define PSM_BASE _u(0x40010000) #define IO_BANK0_BASE _u(0x40014000) #define IO_QSPI_BASE _u(0x40018000) #define PADS_BANK0_BASE _u(0x4001c000) #define PADS_QSPI_BASE _u(0x40020000) #define XOSC_BASE _u(0x40024000) #define PLL_SYS_BASE _u(0x40028000) #define PLL_USB_BASE _u(0x4002c000) #define BUSCTRL_BASE _u(0x40030000) #define UART0_BASE _u(0x40034000) #define UART1_BASE _u(0x40038000) #define SPI0_BASE _u(0x4003c000) #define SPI1_BASE _u(0x40040000) #define I2C0_BASE _u(0x40044000) #define I2C1_BASE _u(0x40048000) #define ADC_BASE _u(0x4004c000) #define PWM_BASE _u(0x40050000) #define TIMER_BASE _u(0x40054000) #define WATCHDOG_BASE _u(0x40058000) #define RTC_BASE _u(0x4005c000) #define ROSC_BASE _u(0x40060000) #define VREG_AND_CHIP_RESET_BASE _u(0x40064000) #define TBMAN_BASE _u(0x4006c000) #define DMA_BASE _u(0x50000000) #define PIO0_BASE _u(0x50200000) #define PIO1_BASE _u(0x50300000) #define SIO_BASE _u(0xd0000000) #define PPB_BASE _u(0xe0000000) #endif // Additional base addresses which are not defined in the CMSIS header #define ROM_BASE _u(0x00000000) #define XIP_BASE _u(0x10000000) #define XIP_MAIN_BASE _u(0x10000000) #define XIP_NOALLOC_BASE _u(0x11000000) #define XIP_NOCACHE_BASE _u(0x12000000) #define XIP_NOCACHE_NOALLOC_BASE _u(0x13000000) #define XIP_SRAM_BASE _u(0x15000000) #define XIP_SRAM_END _u(0x15004000) #define XIP_SSI_BASE _u(0x18000000) #define SRAM_BASE _u(0x20000000) #define SRAM_STRIPED_BASE _u(0x20000000) #define SRAM_STRIPED_END _u(0x20040000) #define SRAM4_BASE _u(0x20040000) #define SRAM5_BASE _u(0x20041000) #define SRAM_END _u(0x20042000) #define SRAM0_BASE _u(0x21000000) #define SRAM1_BASE _u(0x21010000) #define SRAM2_BASE _u(0x21020000) #define SRAM3_BASE _u(0x21030000) #define USBCTRL_DPRAM_BASE _u(0x50100000) #define USBCTRL_BASE _u(0x50100000) #define USBCTRL_REGS_BASE _u(0x50110000) #define XIP_AUX_BASE _u(0x50400000) ``` This should be a drop-in solution that will work whether or not the CMSIS header is available, but there are also other possible ways to solve this. However, it looks like addressmap.h is generated by something outside this repo, so I can't actually make a PR for this change. Would appreciate if someone could look into this!
关闭于 2026-04-08 2 条评论