raspberrypi / pico-sdk

BSD 3-Clause "New" or "Revised" License
3.71k stars 921 forks source link

Tests fail when using gcc 12 #840

Closed SuperNinja-4965 closed 2 years ago

SuperNinja-4965 commented 2 years ago

I ran cmake .. && make in a build directory on the pico-sdk using gcc 12 and the kitchen_sink test failed. I'm not sure if I have configured something incorrectly or not but i believe it is caused by the latest version of gcc as these tests did pass using an older version of gcc. I have attached the build log below so you can see where it went wrong.

PICO_SDK_PATH is MyPath/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
-- Defaulting build type to 'Release' since not specified.
PICO compiler is pico_arm_gcc
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
Build type is Release
Defaulting PICO target board to pico since not specified.
Using board configuration from MyPath/pico-sdk/src/boards/include/boards/pico.h
-- Found Python3: /usr/bin/python3.10 (found version "3.10.4") found components: Interpreter 
TinyUSB available at MyPath/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
-- Configuring done
-- Generating done
-- Build files have been written to: MyPath/pico-sdk/build
Scanning dependencies of target bs2_default
[  1%] Building ASM object src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[  1%] Linking ASM executable bs2_default.elf
[  1%] Built target bs2_default
[  1%] Creating directories for 'ELF2UF2Build'
[  1%] No download step for 'ELF2UF2Build'
[  1%] No update step for 'ELF2UF2Build'
[  1%] No patch step for 'ELF2UF2Build'
[  1%] Performing configure step for 'ELF2UF2Build'
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: MyPath/pico-sdk/build/elf2uf2
[  1%] Performing build step for 'ELF2UF2Build'
[ 50%] Building CXX object CMakeFiles/elf2uf2.dir/main.cpp.o
[100%] Linking CXX executable elf2uf2
[100%] Built target elf2uf2
[  1%] No install step for 'ELF2UF2Build'
[  1%] Completed 'ELF2UF2Build'
[  1%] Built target ELF2UF2Build
[  1%] Generating bs2_default.bin
[  1%] Generating bs2_default_padded_checksummed.S
[  1%] Built target bs2_default_padded_checksummed_asm
Scanning dependencies of target pico_stdlib_test
[  7%] Built target pico_stdlib_test
Scanning dependencies of target pico_time_test
[ 13%] Built target pico_time_test
Scanning dependencies of target pico_divider_test
[ 19%] Built target pico_divider_test
Scanning dependencies of target pico_divider_nesting_test_with_dirty_check
[ 25%] Built target pico_divider_nesting_test_with_dirty_check
Scanning dependencies of target pico_divider_nesting_test_with_disable_irq
[ 31%] Built target pico_divider_nesting_test_with_disable_irq
Scanning dependencies of target pico_float_test
[ 37%] Built target pico_float_test
Scanning dependencies of target pico_double_test
[ 43%] Built target pico_double_test
Scanning dependencies of target kitchen_sink
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/kitchen_sink.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_adc/adc.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_claim/claim.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/pico_platform/platform.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_sync/sync.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_clocks/clocks.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_gpio/gpio.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_irq/irq.c.obj
[ 44%] Building ASM object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_irq/irq_handler_chain.S.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/sem.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/lock_core.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_time/time.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_time/timeout_helper.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_timer/timer.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/datetime.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/pheap.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/queue.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/mutex.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/critical_section.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_pll/pll.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_vreg/vreg.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_watchdog/watchdog.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_xosc/xosc.c.obj
[ 46%] Building ASM object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_divider/divider.S.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_exception/exception.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_dma/dma.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_flash/flash.c.obj
In file included from MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:8:
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:69:91:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(ui[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/kitchen_sink.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_adc/adc.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_claim/claim.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/pico_platform/platform.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_sync/sync.c.obj
[ 43%] Building C object testnt16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:70:67:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:71:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:72:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:92:91:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:93:67:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:94:82:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:95:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:125:91:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:126:67:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:127:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:129:66: note: in expansion of macro 'rom_hword_as_ptr'
  129 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:120:59: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  120 | #define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
      |                                                          ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:130:41: note: in expansion of macro 'rom_hword_as_ptr'
  130 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [test/kitchen_sink/CMakeFiles/kitchen_sink.dir/build.make:438: test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_flash/flash.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:1796: test/kitchen_sink/CMakeFiles/kitchen_sink.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
kilograham commented 2 years ago

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578

it seems they may not have included the patch in 12.1 which is dumb.

Actually, i'm still surprised this doesn't work with the SDK 1.3.1 - are you sure you have the latest?

kilograham commented 2 years ago

oh, no, actually this looks like another new warning!

SuperNinja-4965 commented 2 years ago

See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99578

it seems they may not have included the patch in 12.1 which is dumb.

Actually, i'm still surprised this doesn't work with the SDK 1.3.1 - are you sure you have the latest?

yeah downloaded it fresh today.

kilograham commented 2 years ago

i don't see a GCC 12 from ARM directly yet, so I guess this came with some OS? or did you build yourself?

SuperNinja-4965 commented 2 years ago

I use Arch Linux (x86_64) which ships GCC 12

kilograham commented 2 years ago

I haven't tested it on GCC 12 myself, but you can try #842

SuperNinja-4965 commented 2 years ago

Ill run the tests now and share my results

SuperNinja-4965 commented 2 years ago

The tests still fail.

[Bash]$ git fetch && git pull && git checkout gcc12_fix
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 9 (delta 5), reused 9 (delta 5), pack-reused 0
Unpacking objects: 100% (9/9), 851 bytes | 6.00 KiB/s, done.
From https://github.com/raspberrypi/pico-sdk
 * [new branch]      gcc12_fix  -> origin/gcc12_fix
Already up to date.
branch 'gcc12_fix' set up to track 'origin/gcc12_fix'.
Switched to a new branch 'gcc12_fix'
[Bash]$ git submodule update --init
[Bash]$ git submodule update
[Bash]$ mkdir build
[Bash]$ cd build/
[Bash]$ cmake .. && make 
PICO_SDK_PATH is MyPath/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
-- Defaulting build type to 'Release' since not specified.
PICO compiler is pico_arm_gcc
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
Build type is Release
Defaulting PICO target board to pico since not specified.
Using board configuration from MyPath/pico-sdk/src/boards/include/boards/pico.h
-- Found Python3: /usr/bin/python3.10 (found version "3.10.4") found components: Interpreter 
TinyUSB available at MyPath/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
-- Configuring done
-- Generating done
-- Build files have been written to: MyPath/pico-sdk/build
Scanning dependencies of target bs2_default
[  1%] Building ASM object src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[  1%] Linking ASM executable bs2_default.elf
[  1%] Built target bs2_default
[  1%] Creating directories for 'ELF2UF2Build'
[  1%] No download step for 'ELF2UF2Build'
[  1%] No update step for 'ELF2UF2Build'
[  1%] No patch step for 'ELF2UF2Build'
[  1%] Performing configure step for 'ELF2UF2Build'
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: MyPath/pico-sdk/build/elf2uf2
[  1%] Performing build step for 'ELF2UF2Build'
[ 50%] Building CXX object CMakeFiles/elf2uf2.dir/main.cpp.o
[100%] Linking CXX executable elf2uf2
[100%] Built target elf2uf2
[  1%] No install step for 'ELF2UF2Build'
[  1%] Completed 'ELF2UF2Build'
[  1%] Built target ELF2UF2Build
[  1%] Generating bs2_default.bin
[  1%] Generating bs2_default_padded_checksummed.S
[  1%] Built target bs2_default_padded_checksummed_asm
Scanning dependencies of target pico_stdlib_test
[  7%] Built target pico_stdlib_test
Scanning dependencies of target pico_time_test
[ 13%] Built target pico_time_test
Scanning dependencies of target pico_divider_test
[ 19%] Built target pico_divider_test
Scanning dependencies of target pico_divider_nesting_test_with_dirty_check
[ 25%] Built target pico_divider_nesting_test_with_dirty_check
Scanning dependencies of target pico_divider_nesting_test_with_disable_irq
[ 31%] Built target pico_divider_nesting_test_with_disable_irq
Scanning dependencies of target pico_float_test
[ 37%] Built target pico_float_test
Scanning dependencies of target pico_double_test
[ 43%] Built target pico_double_test
Scanning dependencies of target kitchen_sink
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/kitchen_sink.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_adc/adc.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_claim/claim.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/pico_platform/platform.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_sync/sync.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_clocks/clocks.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_gpio/gpio.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_irq/irq.c.obj
[ 44%] Building ASM object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_irq/irq_handler_chain.S.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/sem.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/lock_core.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_time/time.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_time/timeout_helper.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_timer/timer.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/datetime.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/pheap.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/queue.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/mutex.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/critical_section.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_pll/pll.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_vreg/vreg.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_watchdog/watchdog.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_xosc/xosc.c.obj
[ 46%] Building ASM object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_divider/divider.S.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_exception/exception.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_dma/dma.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_flash/flash.c.obj
In file included from MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:8:
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:69:91:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:70:67:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:71:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:72:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:92:91:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:93:67:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:94:82:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:95:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:125:91:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:126:67:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:127:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [test/kitchen_sink/CMakeFiles/kitchen_sink.dir/build.make:438: test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_flash/flash.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:1796: test/kitchen_sink/CMakeFiles/kitchen_sink.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
kilograham commented 2 years ago

hmm; that's odd; for sanity can you comment out the ifdef in src/rp2_common/pico_bootrom/include/pico/bootrom.h

#if defined(__GNUC__) && (__GNUC__ >= 12)

SuperNinja-4965 commented 2 years ago

sure just let me do that now

SuperNinja-4965 commented 2 years ago

still fails im afraid

[Bash]$ nano ../src/rp2_common/pico_bootrom/include/pico/bootrom.h
[Bash]$ cat ../src/rp2_common/pico_bootrom/include/pico/bootrom.h
/*
 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#ifndef _PLATFORM_BOOTROM_H
#define _PLATFORM_BOOTROM_H

#include "pico.h"

/** \file bootrom.h
 * \defgroup pico_bootrom pico_bootrom
 * Access to functions and data in the RP2040 bootrom
 *
 * This header may be included by assembly code
 */

// ROM FUNCTIONS

#define ROM_FUNC_POPCOUNT32             ROM_TABLE_CODE('P', '3')
#define ROM_FUNC_REVERSE32              ROM_TABLE_CODE('R', '3')
#define ROM_FUNC_CLZ32                  ROM_TABLE_CODE('L', '3')
#define ROM_FUNC_CTZ32                  ROM_TABLE_CODE('T', '3')
#define ROM_FUNC_MEMSET                 ROM_TABLE_CODE('M', 'S')
#define ROM_FUNC_MEMSET4                ROM_TABLE_CODE('S', '4')
#define ROM_FUNC_MEMCPY                 ROM_TABLE_CODE('M', 'C')
#define ROM_FUNC_MEMCPY44               ROM_TABLE_CODE('C', '4')
#define ROM_FUNC_RESET_USB_BOOT         ROM_TABLE_CODE('U', 'B')
#define ROM_FUNC_CONNECT_INTERNAL_FLASH ROM_TABLE_CODE('I', 'F')
#define ROM_FUNC_FLASH_EXIT_XIP         ROM_TABLE_CODE('E', 'X')
#define ROM_FUNC_FLASH_RANGE_ERASE      ROM_TABLE_CODE('R', 'E')
#define ROM_FUNC_FLASH_RANGE_PROGRAM    ROM_TABLE_CODE('R', 'P')
#define ROM_FUNC_FLASH_FLUSH_CACHE      ROM_TABLE_CODE('F', 'C')
#define ROM_FUNC_FLASH_ENTER_CMD_XIP    ROM_TABLE_CODE('C', 'X')

/*! \brief Return a bootrom lookup code based on two ASCII characters
 * \ingroup pico_bootrom
 *
 * These codes are uses to lookup data or function addresses in the bootrom
 *
 * \param c1 the first character
 * \param c2 the second character
 * \return the 'code' to use in rom_func_lookup() or rom_data_lookup()
 */
#define ROM_TABLE_CODE(c1, c2) ((c1) | ((c2) << 8))

#ifndef __ASSEMBLER__

// ROM FUNCTION SIGNATURES

typedef uint32_t (*rom_popcount32_fn)(uint32_t);
typedef uint32_t (*rom_reverse32_fn)(uint32_t);
typedef uint32_t (*rom_clz32_fn)(uint32_t);
typedef uint32_t (*rom_ctz32_fn)(uint32_t);
typedef uint8_t *(*rom_memset_fn)(uint8_t *, uint8_t, uint32_t);
typedef uint32_t *(*rom_memset4_fn)(uint32_t *, uint8_t, uint32_t);
typedef uint32_t *(*rom_memcpy_fn)(uint8_t *, const uint8_t *, uint32_t);
typedef uint32_t *(*rom_memcpy44_fn)(uint32_t *, const uint32_t *, uint32_t);
typedef void __attribute__((noreturn)) (*rom_reset_usb_boot_fn)(uint32_t, uint32_t);
typedef rom_reset_usb_boot_fn reset_usb_boot_fn; // kept for backwards compatibility
typedef void (*rom_connect_internal_flash_fn)(void);
typedef void (*rom_flash_exit_xip_fn)(void);
typedef void (*rom_flash_range_erase_fn)(uint32_t, size_t, uint32_t, uint8_t);
typedef void (*rom_flash_range_program_fn)(uint32_t, const uint8_t*, size_t);
typedef void (*rom_flash_flush_cache_fn)(void);
typedef void (*rom_flash_enter_cmd_xip_fn)(void);

#ifdef __cplusplus
extern "C" {
#endif

/*! \brief Return a bootrom lookup code based on two ASCII characters
 * \ingroup pico_bootrom
 *
 * These codes are uses to lookup data or function addresses in the bootrom
 *
 * \param c1 the first character
 * \param c2 the second character
 * \return the 'code' to use in rom_func_lookup() or rom_data_lookup()
 */
static inline uint32_t rom_table_code(uint8_t c1, uint8_t c2) {
    return ROM_TABLE_CODE((uint32_t) c1, (uint32_t) c2);
}

/*!
 * \brief Lookup a bootrom function by code
 * \ingroup pico_bootrom
 * \param code the code
 * \return a pointer to the function, or NULL if the code does not match any bootrom function
 */
void *rom_func_lookup(uint32_t code);

/*!
 * \brief Lookup a bootrom address by code
 * \ingroup pico_bootrom
 * \param code the code
 * \return a pointer to the data, or NULL if the code does not match any bootrom function
 */
void *rom_data_lookup(uint32_t code);

/*!
 * \brief Helper function to lookup the addresses of multiple bootrom functions
 * \ingroup pico_bootrom
 *
 * This method looks up the 'codes' in the table, and convert each table entry to the looked up
 * function pointer, if there is a function for that code in the bootrom.
 *
 * \param table an IN/OUT array, elements are codes on input, function pointers on success.
 * \param count the number of elements in the table
 * \return true if all the codes were found, and converted to function pointers, false otherwise
 */
bool rom_funcs_lookup(uint32_t *table, unsigned int count);

// Bootrom function: rom_table_lookup
// Returns the 32 bit pointer into the ROM if found or NULL otherwise.
typedef void *(*rom_table_lookup_fn)(uint16_t *table, uint32_t code);

//#if defined(__GNUC__) && (__GNUC__ >= 12)
// Convert a 16 bit pointer stored at the given rom address into a 32 bit pointer
#define rom_hword_as_ptr(rom_address) \
    ({ \
       _Pragma("GCC diagnostic push") \
       _Pragma("GCC diagnostic ignored \"-Warray-bounds\"") \
       (void *)(uintptr_t)(*(uint16_t *)rom_address); \
       _Pragma("GCC diagnostic pop") \
    })
//#else
//#define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
//#endif

/*!
 * \brief Lookup a bootrom function by code. This method is forceably inlined into the caller for FLASH/RAM sensitive code usage
 * \ingroup pico_bootrom
 * \param code the code
 * \return a pointer to the function, or NULL if the code does not match any bootrom function
 */
static __force_inline void *rom_func_lookup_inline(uint32_t code) {
    rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
    uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
    return rom_table_lookup(func_table, code);
}

/*!
 * \brief Reboot the device into BOOTSEL mode
 * \ingroup pico_bootrom
 *
 * This function reboots the device into the BOOTSEL mode ('usb boot").
 *
 * Facilities are provided to enable an "activity light" via GPIO attached LED for the USB Mass Storage Device,
 * and to limit the USB interfaces exposed.
 *
 * \param usb_activity_gpio_pin_mask 0 No pins are used as per a cold boot. Otherwise a single bit set indicating which
 *                               GPIO pin should be set to output and raised whenever there is mass storage activity
 *                               from the host.
 * \param disable_interface_mask value to control exposed interfaces
 *  - 0 To enable both interfaces (as per a cold boot)
 *  - 1 To disable the USB Mass Storage Interface
 *  - 2 To disable the USB PICOBOOT Interface
 */
static inline void __attribute__((noreturn)) reset_usb_boot(uint32_t usb_activity_gpio_pin_mask,
                                                            uint32_t disable_interface_mask) {
    rom_reset_usb_boot_fn func = (rom_reset_usb_boot_fn) rom_func_lookup(ROM_FUNC_RESET_USB_BOOT);
    func(usb_activity_gpio_pin_mask, disable_interface_mask);
}

#ifdef __cplusplus
}
#endif

#endif // !__ASSEMBLER__
#endif
[Bash]$ rm -r ./*
[Bash]$ cmake .. && make
PICO_SDK_PATH is MyPath/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
-- Defaulting build type to 'Release' since not specified.
PICO compiler is pico_arm_gcc
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
Build type is Release
Defaulting PICO target board to pico since not specified.
Using board configuration from MyPath/pico-sdk/src/boards/include/boards/pico.h
-- Found Python3: /usr/bin/python3.10 (found version "3.10.4") found components: Interpreter 
TinyUSB available at MyPath/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
-- Configuring done
-- Generating done
-- Build files have been written to: MyPath/pico-sdk/build
Scanning dependencies of target bs2_default
[  1%] Building ASM object src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[  1%] Linking ASM executable bs2_default.elf
[  1%] Built target bs2_default
[  1%] Creating directories for 'ELF2UF2Build'
[  1%] No download step for 'ELF2UF2Build'
[  1%] No update step for 'ELF2UF2Build'
[  1%] No patch step for 'ELF2UF2Build'
[  1%] Performing configure step for 'ELF2UF2Build'
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: MyPath/pico-sdk/build/elf2uf2
[  1%] Performing build step for 'ELF2UF2Build'
[ 50%] Building CXX object CMakeFiles/elf2uf2.dir/main.cpp.o
[100%] Linking CXX executable elf2uf2
[100%] Built target elf2uf2
[  1%] No install step for 'ELF2UF2Build'
[  1%] Completed 'ELF2UF2Build'
[  1%] Built target ELF2UF2Build
[  1%] Generating bs2_default.bin
[  1%] Generating bs2_default_padded_checksummed.S
[  1%] Built target bs2_default_padded_checksummed_asm
Scanning dependencies of target pico_stdlib_test
[  7%] Built target pico_stdlib_test
Scanning dependencies of target pico_time_test
[ 13%] Built target pico_time_test
Scanning dependencies of target pico_divider_test
[ 19%] Built target pico_divider_test
Scanning dependencies of target pico_divider_nesting_test_with_dirty_check
[ 25%] Built target pico_divider_nesting_test_with_dirty_check
Scanning dependencies of target pico_divider_nesting_test_with_disable_irq
[ 31%] Built target pico_divider_nesting_test_with_disable_irq
Scanning dependencies of target pico_float_test
[ 37%] Built target pico_float_test
Scanning dependencies of target pico_double_test
[ 43%] Built target pico_double_test
Scanning dependencies of target kitchen_sink
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/kitchen_sink.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_adc/adc.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_claim/claim.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/pico_platform/platform.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_sync/sync.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_clocks/clocks.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_gpio/gpio.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_irq/irq.c.obj
[ 44%] Building ASM object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_irq/irq_handler_chain.S.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/sem.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/lock_core.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_time/time.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_time/timeout_helper.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_timer/timer.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/datetime.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/pheap.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/queue.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/mutex.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/critical_section.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_pll/pll.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_vreg/vreg.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_watchdog/watchdog.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_xosc/xosc.c.obj
[ 46%] Building ASM object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_divider/divider.S.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_exception/exception.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_dma/dma.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_flash/flash.c.obj
In file included from MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:8:
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:69:91:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:70:67:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:71:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_erase' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:72:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:92:91:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:93:67:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:94:82:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_range_program' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:95:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:125:91:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:126:67:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
In function 'rom_func_lookup_inline',
    inlined from 'flash_do_cmd' at MyPath/pico-sdk/src/rp2_common/hardware_flash/flash.c:127:76:
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:139:66: note: in expansion of macro 'rom_hword_as_ptr'
  139 |     rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
      |                                                                  ^~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:125:28: error: array subscript 0 is outside array bounds of 'uint16_t[0]' {aka 'short unsigned int[]'} [-Werror=array-bounds]
  125 |        (void *)(uintptr_t)(*(uint16_t *)rom_address); \
      |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~
MyPath/pico-sdk/src/rp2_common/pico_bootrom/include/pico/bootrom.h:140:41: note: in expansion of macro 'rom_hword_as_ptr'
  140 |     uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
      |                                         ^~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [test/kitchen_sink/CMakeFiles/kitchen_sink.dir/build.make:438: test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_flash/flash.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:1796: test/kitchen_sink/CMakeFiles/kitchen_sink.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
kilograham commented 2 years ago

Ok one last sanity check, can you try this (maybe something about _Pragma vs #pragma)

#if defined(__GNUC__) && (__GNUC__ >= 12)
// Convert a 16 bit pointer stored at the given rom address into a 32 bit pointer
static __force_inline void *rom_hword_as_ptr(uint32_t rom_address) {
    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Warray-bounds"
       return (void *)(uintptr_t)(*(uint16_t *)rom_address);
    #pragma GCC diagnostic pop
}
#else
static __force_inline void *rom_hword_as_ptr(uint32_t rom_address) {
    return (void *) (uintptr_t) (*(uint16_t *) rom_address);
}
#endif
SuperNinja-4965 commented 2 years ago

sure give me a few mins

SuperNinja-4965 commented 2 years ago

Good new and bad news. I'll let you see below:

[Bash]$ nano ../src/rp2_common/pico_bootrom/include/pico/bootrom.h
[Bash]$ cat ../src/rp2_common/pico_bootrom/include/pico/bootrom.h
/*
 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#ifndef _PLATFORM_BOOTROM_H
#define _PLATFORM_BOOTROM_H

#include "pico.h"

/** \file bootrom.h
 * \defgroup pico_bootrom pico_bootrom
 * Access to functions and data in the RP2040 bootrom
 *
 * This header may be included by assembly code
 */

// ROM FUNCTIONS

#define ROM_FUNC_POPCOUNT32             ROM_TABLE_CODE('P', '3')
#define ROM_FUNC_REVERSE32              ROM_TABLE_CODE('R', '3')
#define ROM_FUNC_CLZ32                  ROM_TABLE_CODE('L', '3')
#define ROM_FUNC_CTZ32                  ROM_TABLE_CODE('T', '3')
#define ROM_FUNC_MEMSET                 ROM_TABLE_CODE('M', 'S')
#define ROM_FUNC_MEMSET4                ROM_TABLE_CODE('S', '4')
#define ROM_FUNC_MEMCPY                 ROM_TABLE_CODE('M', 'C')
#define ROM_FUNC_MEMCPY44               ROM_TABLE_CODE('C', '4')
#define ROM_FUNC_RESET_USB_BOOT         ROM_TABLE_CODE('U', 'B')
#define ROM_FUNC_CONNECT_INTERNAL_FLASH ROM_TABLE_CODE('I', 'F')
#define ROM_FUNC_FLASH_EXIT_XIP         ROM_TABLE_CODE('E', 'X')
#define ROM_FUNC_FLASH_RANGE_ERASE      ROM_TABLE_CODE('R', 'E')
#define ROM_FUNC_FLASH_RANGE_PROGRAM    ROM_TABLE_CODE('R', 'P')
#define ROM_FUNC_FLASH_FLUSH_CACHE      ROM_TABLE_CODE('F', 'C')
#define ROM_FUNC_FLASH_ENTER_CMD_XIP    ROM_TABLE_CODE('C', 'X')

/*! \brief Return a bootrom lookup code based on two ASCII characters
 * \ingroup pico_bootrom
 *
 * These codes are uses to lookup data or function addresses in the bootrom
 *
 * \param c1 the first character
 * \param c2 the second character
 * \return the 'code' to use in rom_func_lookup() or rom_data_lookup()
 */
#define ROM_TABLE_CODE(c1, c2) ((c1) | ((c2) << 8))

#ifndef __ASSEMBLER__

// ROM FUNCTION SIGNATURES

typedef uint32_t (*rom_popcount32_fn)(uint32_t);
typedef uint32_t (*rom_reverse32_fn)(uint32_t);
typedef uint32_t (*rom_clz32_fn)(uint32_t);
typedef uint32_t (*rom_ctz32_fn)(uint32_t);
typedef uint8_t *(*rom_memset_fn)(uint8_t *, uint8_t, uint32_t);
typedef uint32_t *(*rom_memset4_fn)(uint32_t *, uint8_t, uint32_t);
typedef uint32_t *(*rom_memcpy_fn)(uint8_t *, const uint8_t *, uint32_t);
typedef uint32_t *(*rom_memcpy44_fn)(uint32_t *, const uint32_t *, uint32_t);
typedef void __attribute__((noreturn)) (*rom_reset_usb_boot_fn)(uint32_t, uint32_t);
typedef rom_reset_usb_boot_fn reset_usb_boot_fn; // kept for backwards compatibility
typedef void (*rom_connect_internal_flash_fn)(void);
typedef void (*rom_flash_exit_xip_fn)(void);
typedef void (*rom_flash_range_erase_fn)(uint32_t, size_t, uint32_t, uint8_t);
typedef void (*rom_flash_range_program_fn)(uint32_t, const uint8_t*, size_t);
typedef void (*rom_flash_flush_cache_fn)(void);
typedef void (*rom_flash_enter_cmd_xip_fn)(void);

#ifdef __cplusplus
extern "C" {
#endif

/*! \brief Return a bootrom lookup code based on two ASCII characters
 * \ingroup pico_bootrom
 *
 * These codes are uses to lookup data or function addresses in the bootrom
 *
 * \param c1 the first character
 * \param c2 the second character
 * \return the 'code' to use in rom_func_lookup() or rom_data_lookup()
 */
static inline uint32_t rom_table_code(uint8_t c1, uint8_t c2) {
    return ROM_TABLE_CODE((uint32_t) c1, (uint32_t) c2);
}

/*!
 * \brief Lookup a bootrom function by code
 * \ingroup pico_bootrom
 * \param code the code
 * \return a pointer to the function, or NULL if the code does not match any bootrom function
 */
void *rom_func_lookup(uint32_t code);

/*!
 * \brief Lookup a bootrom address by code
 * \ingroup pico_bootrom
 * \param code the code
 * \return a pointer to the data, or NULL if the code does not match any bootrom function
 */
void *rom_data_lookup(uint32_t code);

/*!
 * \brief Helper function to lookup the addresses of multiple bootrom functions
 * \ingroup pico_bootrom
 *
 * This method looks up the 'codes' in the table, and convert each table entry to the looked up
 * function pointer, if there is a function for that code in the bootrom.
 *
 * \param table an IN/OUT array, elements are codes on input, function pointers on success.
 * \param count the number of elements in the table
 * \return true if all the codes were found, and converted to function pointers, false otherwise
 */
bool rom_funcs_lookup(uint32_t *table, unsigned int count);

// Bootrom function: rom_table_lookup
// Returns the 32 bit pointer into the ROM if found or NULL otherwise.
typedef void *(*rom_table_lookup_fn)(uint16_t *table, uint32_t code);

#if defined(__GNUC__) && (__GNUC__ >= 12)
// Convert a 16 bit pointer stored at the given rom address into a 32 bit pointer
static __force_inline void *rom_hword_as_ptr(uint32_t rom_address) {
    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Warray-bounds"
       return (void *)(uintptr_t)(*(uint16_t *)rom_address);
    #pragma GCC diagnostic pop
}
#else
static __force_inline void *rom_hword_as_ptr(uint32_t rom_address) {
    return (void *) (uintptr_t) (*(uint16_t *) rom_address);
}
#endif

/*!
 * \brief Lookup a bootrom function by code. This method is forceably inlined into the caller for FLASH/RAM sensitive code usage
 * \ingroup pico_bootrom
 * \param code the code
 * \return a pointer to the function, or NULL if the code does not match any bootrom function
 */
static __force_inline void *rom_func_lookup_inline(uint32_t code) {
    rom_table_lookup_fn rom_table_lookup = (rom_table_lookup_fn) rom_hword_as_ptr(0x18);
    uint16_t *func_table = (uint16_t *) rom_hword_as_ptr(0x14);
    return rom_table_lookup(func_table, code);
}

/*!
 * \brief Reboot the device into BOOTSEL mode
 * \ingroup pico_bootrom
 *
 * This function reboots the device into the BOOTSEL mode ('usb boot").
 *
 * Facilities are provided to enable an "activity light" via GPIO attached LED for the USB Mass Storage Device,
 * and to limit the USB interfaces exposed.
 *
 * \param usb_activity_gpio_pin_mask 0 No pins are used as per a cold boot. Otherwise a single bit set indicating which
 *                               GPIO pin should be set to output and raised whenever there is mass storage activity
 *                               from the host.
 * \param disable_interface_mask value to control exposed interfaces
 *  - 0 To enable both interfaces (as per a cold boot)
 *  - 1 To disable the USB Mass Storage Interface
 *  - 2 To disable the USB PICOBOOT Interface
 */
static inline void __attribute__((noreturn)) reset_usb_boot(uint32_t usb_activity_gpio_pin_mask,
                                                            uint32_t disable_interface_mask) {
    rom_reset_usb_boot_fn func = (rom_reset_usb_boot_fn) rom_func_lookup(ROM_FUNC_RESET_USB_BOOT);
    func(usb_activity_gpio_pin_mask, disable_interface_mask);
}

#ifdef __cplusplus
}
#endif

#endif // !__ASSEMBLER__
#endif
[Bash]$ rm -r ./*
[Bash]$ cmake .. && make
PICO_SDK_PATH is MyPath/pico-sdk
Defaulting PICO_PLATFORM to rp2040 since not specified.
Defaulting PICO platform compiler to pico_arm_gcc since not specified.
-- Defaulting build type to 'Release' since not specified.
PICO compiler is pico_arm_gcc
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/arm-none-eabi-gcc
Build type is Release
Defaulting PICO target board to pico since not specified.
Using board configuration from MyPath/pico-sdk/src/boards/include/boards/pico.h
-- Found Python3: /usr/bin/python3.10 (found version "3.10.4") found components: Interpreter 
TinyUSB available at MyPath/pico-sdk/lib/tinyusb/src/portable/raspberrypi/rp2040; enabling build support for USB.
-- Configuring done
-- Generating done
-- Build files have been written to: MyPath/pico-sdk/build
Scanning dependencies of target bs2_default
[  1%] Building ASM object src/rp2_common/boot_stage2/CMakeFiles/bs2_default.dir/compile_time_choice.S.obj
[  1%] Linking ASM executable bs2_default.elf
[  1%] Built target bs2_default
[  1%] Creating directories for 'ELF2UF2Build'
[  1%] No download step for 'ELF2UF2Build'
[  1%] No update step for 'ELF2UF2Build'
[  1%] No patch step for 'ELF2UF2Build'
[  1%] Performing configure step for 'ELF2UF2Build'
-- The C compiler identification is GNU 12.1.0
-- The CXX compiler identification is GNU 12.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: MyPath/pico-sdk/build/elf2uf2
[  1%] Performing build step for 'ELF2UF2Build'
[ 50%] Building CXX object CMakeFiles/elf2uf2.dir/main.cpp.o
[100%] Linking CXX executable elf2uf2
[100%] Built target elf2uf2
[  1%] No install step for 'ELF2UF2Build'
[  1%] Completed 'ELF2UF2Build'
[  1%] Built target ELF2UF2Build
[  1%] Generating bs2_default.bin
[  1%] Generating bs2_default_padded_checksummed.S
[  1%] Built target bs2_default_padded_checksummed_asm
Scanning dependencies of target pico_stdlib_test
[  7%] Built target pico_stdlib_test
Scanning dependencies of target pico_time_test
[ 13%] Built target pico_time_test
Scanning dependencies of target pico_divider_test
[ 19%] Built target pico_divider_test
Scanning dependencies of target pico_divider_nesting_test_with_dirty_check
[ 25%] Built target pico_divider_nesting_test_with_dirty_check
Scanning dependencies of target pico_divider_nesting_test_with_disable_irq
[ 31%] Built target pico_divider_nesting_test_with_disable_irq
Scanning dependencies of target pico_float_test
[ 37%] Built target pico_float_test
Scanning dependencies of target pico_double_test
[ 43%] Built target pico_double_test
Scanning dependencies of target kitchen_sink
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/kitchen_sink.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_adc/adc.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_claim/claim.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/pico_platform/platform.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_sync/sync.c.obj
[ 43%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_clocks/clocks.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_gpio/gpio.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_irq/irq.c.obj
[ 44%] Building ASM object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_irq/irq_handler_chain.S.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/sem.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/lock_core.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_time/time.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_time/timeout_helper.c.obj
[ 44%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_timer/timer.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/datetime.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/pheap.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_util/queue.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/mutex.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/common/pico_sync/critical_section.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_pll/pll.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_vreg/vreg.c.obj
[ 45%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_watchdog/watchdog.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_xosc/xosc.c.obj
[ 46%] Building ASM object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_divider/divider.S.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_exception/exception.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_dma/dma.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_flash/flash.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/pico_bootrom/bootrom.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_i2c/i2c.c.obj
[ 46%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_interp/interp.c.obj
[ 47%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_pio/pio.c.obj
[ 47%] Building C object test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_rtc/rtc.c.obj
MyPath/pico-sdk/src/rp2_common/hardware_rtc/rtc.c: In function 'rtc_set_datetime':
MyPath/pico-sdk/src/rp2_common/hardware_rtc/rtc.c:68:23: error: conversion to 'io_rw_32' {aka 'long unsigned int'} from 'unsigned int' may change the sign of the result [-Werror=sign-conversion]
   68 |     rtc_hw->setup_0 = (((uint)t->year)  << RTC_SETUP_0_YEAR_LSB ) |
      |                       ^
MyPath/pico-sdk/src/rp2_common/hardware_rtc/rtc.c:71:23: error: conversion to 'io_rw_32' {aka 'long unsigned int'} from 'unsigned int' may change the sign of the result [-Werror=sign-conversion]
   71 |     rtc_hw->setup_1 = (((uint)t->dotw)  << RTC_SETUP_1_DOTW_LSB) |
      |                       ^
MyPath/pico-sdk/src/rp2_common/hardware_rtc/rtc.c: In function 'rtc_set_alarm':
MyPath/pico-sdk/src/rp2_common/hardware_rtc/rtc.c:151:27: error: conversion to 'io_rw_32' {aka 'long unsigned int'} from 'unsigned int' may change the sign of the result [-Werror=sign-conversion]
  151 |     rtc_hw->irq_setup_0 = ((t->year  < 0) ? 0 : (((uint)t->year)  << RTC_IRQ_SETUP_0_YEAR_LSB )) |
      |                           ^
MyPath/pico-sdk/src/rp2_common/hardware_rtc/rtc.c:154:27: error: conversion to 'io_rw_32' {aka 'long unsigned int'} from 'unsigned int' may change the sign of the result [-Werror=sign-conversion]
  154 |     rtc_hw->irq_setup_1 = ((t->dotw  < 0) ? 0 : (((uint)t->dotw)  << RTC_IRQ_SETUP_1_DOTW_LSB)) |
      |                           ^
cc1: all warnings being treated as errors
make[2]: *** [test/kitchen_sink/CMakeFiles/kitchen_sink.dir/build.make:508: test/kitchen_sink/CMakeFiles/kitchen_sink.dir/__/__/src/rp2_common/hardware_rtc/rtc.c.obj] Error 1
make[1]: *** [CMakeFiles/Makefile2:1796: test/kitchen_sink/CMakeFiles/kitchen_sink.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
SuperNinja-4965 commented 2 years ago

also incase you need it here is a git diff:

diff --git a/src/rp2_common/pico_bootrom/include/pico/bootrom.h b/src/rp2_common/pico_bootrom/include/pico/bootrom.h
index 94b27d5..a1b2a30 100644
--- a/src/rp2_common/pico_bootrom/include/pico/bootrom.h
+++ b/src/rp2_common/pico_bootrom/include/pico/bootrom.h
@@ -118,15 +118,16 @@ typedef void *(*rom_table_lookup_fn)(uint16_t *table, uint32_t code);

 #if defined(__GNUC__) && (__GNUC__ >= 12)
 // Convert a 16 bit pointer stored at the given rom address into a 32 bit pointer
-#define rom_hword_as_ptr(rom_address) \
-    ({ \
-       _Pragma("GCC diagnostic push") \
-       _Pragma("GCC diagnostic ignored \"-Warray-bounds\"") \
-       (void *)(uintptr_t)(*(uint16_t *)rom_address); \
-       _Pragma("GCC diagnostic pop") \
-    })
+static __force_inline void *rom_hword_as_ptr(uint32_t rom_address) {
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Warray-bounds"
+       return (void *)(uintptr_t)(*(uint16_t *)rom_address);
+    #pragma GCC diagnostic pop
+}
 #else
-#define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
+static __force_inline void *rom_hword_as_ptr(uint32_t rom_address) {
+    return (void *) (uintptr_t) (*(uint16_t *) rom_address);
+}
 #endif

 /*!
kilograham commented 2 years ago

That is weird too (not sure how it thinks casting from unsigned to unsigned can change the sign of anything!); we may be getting to the point where I will have to try it myself, but could you add

static_assert(sizeof(uint)==4, "uint should be 4 bytes");

somewhere at the top of rtc.c

SuperNinja-4965 commented 2 years ago

That is weird too (not sure how it thinks casting from unsigned to unsigned can change the sign of anything!); we may be getting to the point where I will have to try it myself, but could you add

static_assert(sizeof(uint)==4, "uint should be 4 bytes");

somewhere at the top of rtc.c

im wondering if this is perhaps an issue with my version of gcc as i just booted up my fedora laptop which claims to use gcc 12.1.1 (which confuses me a little because i dont think that version exists) and the tests ran fine so im going to do some more checks locally to see if my version of gcc is the cause.

Edit: This could just be fedora changing the version numbers as they apply patches or something but still strange how it builds there with no issues.

SuperNinja-4965 commented 2 years ago

That is weird too (not sure how it thinks casting from unsigned to unsigned can change the sign of anything!); we may be getting to the point where I will have to try it myself, but could you add

static_assert(sizeof(uint)==4, "uint should be 4 bytes");

somewhere at the top of rtc.c

i will try this and see if it addresses the issue

kilograham commented 2 years ago

Yeah that won't fix it, but I was wondering too if your compiler was a bit weird (seems like it might have the wrong int sizes)

SuperNinja-4965 commented 2 years ago

That is weird too (not sure how it thinks casting from unsigned to unsigned can change the sign of anything!); we may be getting to the point where I will have to try it myself, but could you add static_assert(sizeof(uint)==4, "uint should be 4 bytes"); somewhere at the top of rtc.c

im wondering if this is perhaps an issue with my version of gcc as i just booted up my fedora laptop which claims to use gcc 12.1.1 (which confuses me a little because i dont think that version exists) and the tests ran fine so im going to do some more checks locally to see if my version of gcc is the cause.

Edit: This could just be fedora changing the version numbers as they apply patches or something but still strange how it builds there with no issues.

ok so i was able to rule this out. fedora uses gcc v12 but the arm-none-eabi-gcc is still using v11 which is why compile works on the tests.

That is weird too (not sure how it thinks casting from unsigned to unsigned can change the sign of anything!); we may be getting to the point where I will have to try it myself, but could you add

static_assert(sizeof(uint)==4, "uint should be 4 bytes");

somewhere at the top of rtc.c

as for this. it didnt appear to work im afraid

kilograham commented 2 years ago

OK, i will have to play with it in a docker container; i'd just install the official ARM gcc 11 for now

SuperNinja-4965 commented 2 years ago

So i was actually able to get the tests to pass by using these changes but i will be honest i have no idea what effects these changes will have on the sdk:

diff --git a/src/rp2_common/hardware_rtc/rtc.c b/src/rp2_common/hardware_rtc/rtc.c
index 5429acd..8f9d3ba 100644
--- a/src/rp2_common/hardware_rtc/rtc.c
+++ b/src/rp2_common/hardware_rtc/rtc.c
@@ -65,13 +65,13 @@ bool rtc_set_datetime(datetime_t *t) {
     }

     // Write to setup registers
-    rtc_hw->setup_0 = (((uint)t->year)  << RTC_SETUP_0_YEAR_LSB ) |
-                      (((uint)t->month) << RTC_SETUP_0_MONTH_LSB) |
-                      (((uint)t->day)   << RTC_SETUP_0_DAY_LSB);
-    rtc_hw->setup_1 = (((uint)t->dotw)  << RTC_SETUP_1_DOTW_LSB) |
-                      (((uint)t->hour)  << RTC_SETUP_1_HOUR_LSB) |
-                      (((uint)t->min)   << RTC_SETUP_1_MIN_LSB)  |
-                      (((uint)t->sec)   << RTC_SETUP_1_SEC_LSB);
+    rtc_hw->setup_0 = (unsigned long)(((uint)t->year)  << RTC_SETUP_0_YEAR_LSB ) |
+                      (unsigned long)(((uint)t->month) << RTC_SETUP_0_MONTH_LSB) |
+                      (unsigned long)(((uint)t->day)   << RTC_SETUP_0_DAY_LSB);
+    rtc_hw->setup_1 = (unsigned long)(((uint)t->dotw)  << RTC_SETUP_1_DOTW_LSB) |
+                      (unsigned long)(((uint)t->hour)  << RTC_SETUP_1_HOUR_LSB) |
+                      (unsigned long)(((uint)t->min)   << RTC_SETUP_1_MIN_LSB)  |
+                      (unsigned long)(((uint)t->sec)   << RTC_SETUP_1_SEC_LSB);

     // Load setup values into rtc clock domain
     rtc_hw->ctrl = RTC_CTRL_LOAD_BITS;
@@ -148,13 +148,13 @@ void rtc_set_alarm(datetime_t *t, rtc_callback_t user_callback) {
     rtc_disable_alarm();

     // Only add to setup if it isn't -1
-    rtc_hw->irq_setup_0 = ((t->year  < 0) ? 0 : (((uint)t->year)  << RTC_IRQ_SETUP_0_YEAR_LSB )) |
-                          ((t->month < 0) ? 0 : (((uint)t->month) << RTC_IRQ_SETUP_0_MONTH_LSB)) |
-                          ((t->day   < 0) ? 0 : (((uint)t->day)   << RTC_IRQ_SETUP_0_DAY_LSB  ));
-    rtc_hw->irq_setup_1 = ((t->dotw  < 0) ? 0 : (((uint)t->dotw)  << RTC_IRQ_SETUP_1_DOTW_LSB)) |
-                          ((t->hour  < 0) ? 0 : (((uint)t->hour)  << RTC_IRQ_SETUP_1_HOUR_LSB)) |
-                          ((t->min   < 0) ? 0 : (((uint)t->min)   << RTC_IRQ_SETUP_1_MIN_LSB )) |
-                          ((t->sec   < 0) ? 0 : (((uint)t->sec)   << RTC_IRQ_SETUP_1_SEC_LSB ));
+    rtc_hw->irq_setup_0 = (unsigned long)((t->year  < 0) ? 0 : (((uint)t->year)  << RTC_IRQ_SETUP_0_YEAR_LSB )) |
+                          (unsigned long)((t->month < 0) ? 0 : (((uint)t->month) << RTC_IRQ_SETUP_0_MONTH_LSB)) |
+                          (unsigned long)((t->day   < 0) ? 0 : (((uint)t->day)   << RTC_IRQ_SETUP_0_DAY_LSB  ));
+    rtc_hw->irq_setup_1 = (unsigned long)((t->dotw  < 0) ? 0 : (((uint)t->dotw)  << RTC_IRQ_SETUP_1_DOTW_LSB)) |
+                          (unsigned long)((t->hour  < 0) ? 0 : (((uint)t->hour)  << RTC_IRQ_SETUP_1_HOUR_LSB)) |
+                          (unsigned long)((t->min   < 0) ? 0 : (((uint)t->min)   << RTC_IRQ_SETUP_1_MIN_LSB )) |
+                          (unsigned long)((t->sec   < 0) ? 0 : (((uint)t->sec)   << RTC_IRQ_SETUP_1_SEC_LSB ));

     // Set the match enable bits for things we care about
     if (t->year  >= 0) hw_set_bits(&rtc_hw->irq_setup_0, RTC_IRQ_SETUP_0_YEAR_ENA_BITS);
diff --git a/src/rp2_common/pico_bootrom/include/pico/bootrom.h b/src/rp2_common/pico_bootrom/include/pico/bootrom.h
index 94b27d5..a1b2a30 100644
--- a/src/rp2_common/pico_bootrom/include/pico/bootrom.h
+++ b/src/rp2_common/pico_bootrom/include/pico/bootrom.h
@@ -118,15 +118,16 @@ typedef void *(*rom_table_lookup_fn)(uint16_t *table, uint32_t code);

 #if defined(__GNUC__) && (__GNUC__ >= 12)
 // Convert a 16 bit pointer stored at the given rom address into a 32 bit pointer
-#define rom_hword_as_ptr(rom_address) \
-    ({ \
-       _Pragma("GCC diagnostic push") \
-       _Pragma("GCC diagnostic ignored \"-Warray-bounds\"") \
-       (void *)(uintptr_t)(*(uint16_t *)rom_address); \
-       _Pragma("GCC diagnostic pop") \
-    })
+static __force_inline void *rom_hword_as_ptr(uint32_t rom_address) {
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Warray-bounds"
+       return (void *)(uintptr_t)(*(uint16_t *)rom_address);
+    #pragma GCC diagnostic pop
+}
 #else
-#define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
+static __force_inline void *rom_hword_as_ptr(uint32_t rom_address) {
+    return (void *) (uintptr_t) (*(uint16_t *) rom_address);
+}
 #endif

 /*!
diff --git a/src/rp2_common/pico_platform/include/pico/platform.h b/src/rp2_common/pico_platform/include/pico/platform.h
index ffc7660..b6d7251 100644
--- a/src/rp2_common/pico_platform/include/pico/platform.h
+++ b/src/rp2_common/pico_platform/include/pico/platform.h
@@ -333,9 +333,18 @@ uint8_t rp2040_chip_version(void);
  *  \ingroup pico_platform
  * @return the RP2040 rom version number (1 for RP2040-B0, 2 for RP2040-B1, 3 for RP2040-B2)
  */
+#if defined(__GNUC__) && (__GNUC__ >= 12)
 static inline uint8_t rp2040_rom_version(void) {
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Warray-bounds"
     return *(uint8_t*)0x13;
+    #pragma GCC diagnostic pop
 }
+#else
+static inline uint8_t rp2040_rom_version(void) {
+    return *(uint8_t*)0x13;
+}
+#endif

 /*! \brief No-op function for the body of tight loops
  *  \ingroup pico_platform

Edit: These changes are based off the gcc12_fix branch

Edit 2: This is probably a better alternative but again idk if i did this correctly:

diff --git a/src/rp2_common/hardware_rtc/rtc.c b/src/rp2_common/hardware_rtc/rtc.c
index 5429acd..2bedcd6 100644
--- a/src/rp2_common/hardware_rtc/rtc.c
+++ b/src/rp2_common/hardware_rtc/rtc.c
@@ -64,6 +64,10 @@ bool rtc_set_datetime(datetime_t *t) {
         tight_loop_contents();
     }

+    #if defined(__GNUC__) && (__GNUC__ >= 12)
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Wsign-conversion"
+    #endif
     // Write to setup registers
     rtc_hw->setup_0 = (((uint)t->year)  << RTC_SETUP_0_YEAR_LSB ) |
                       (((uint)t->month) << RTC_SETUP_0_MONTH_LSB) |
@@ -72,6 +76,9 @@ bool rtc_set_datetime(datetime_t *t) {
                       (((uint)t->hour)  << RTC_SETUP_1_HOUR_LSB) |
                       (((uint)t->min)   << RTC_SETUP_1_MIN_LSB)  |
                       (((uint)t->sec)   << RTC_SETUP_1_SEC_LSB);
+    #if defined(__GNUC__) && (__GNUC__ >= 12)
+    #pragma GCC diagnostic pop
+    #endif

     // Load setup values into rtc clock domain
     rtc_hw->ctrl = RTC_CTRL_LOAD_BITS;
@@ -147,6 +154,10 @@ static bool rtc_alarm_repeats(datetime_t *t) {
 void rtc_set_alarm(datetime_t *t, rtc_callback_t user_callback) {
     rtc_disable_alarm();

+    #if defined(__GNUC__) && (__GNUC__ >= 12)
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Wsign-conversion"
+    #endif
     // Only add to setup if it isn't -1
     rtc_hw->irq_setup_0 = ((t->year  < 0) ? 0 : (((uint)t->year)  << RTC_IRQ_SETUP_0_YEAR_LSB )) |
                           ((t->month < 0) ? 0 : (((uint)t->month) << RTC_IRQ_SETUP_0_MONTH_LSB)) |
@@ -155,6 +166,9 @@ void rtc_set_alarm(datetime_t *t, rtc_callback_t user_callback) {
                           ((t->hour  < 0) ? 0 : (((uint)t->hour)  << RTC_IRQ_SETUP_1_HOUR_LSB)) |
                           ((t->min   < 0) ? 0 : (((uint)t->min)   << RTC_IRQ_SETUP_1_MIN_LSB )) |
                           ((t->sec   < 0) ? 0 : (((uint)t->sec)   << RTC_IRQ_SETUP_1_SEC_LSB ));
+    #if defined(__GNUC__) && (__GNUC__ >= 12)
+    #pragma GCC diagnostic pop
+    #endif

     // Set the match enable bits for things we care about
     if (t->year  >= 0) hw_set_bits(&rtc_hw->irq_setup_0, RTC_IRQ_SETUP_0_YEAR_ENA_BITS);
diff --git a/src/rp2_common/pico_bootrom/include/pico/bootrom.h b/src/rp2_common/pico_bootrom/include/pico/bootrom.h
index 94b27d5..a1b2a30 100644
--- a/src/rp2_common/pico_bootrom/include/pico/bootrom.h
+++ b/src/rp2_common/pico_bootrom/include/pico/bootrom.h
@@ -118,15 +118,16 @@ typedef void *(*rom_table_lookup_fn)(uint16_t *table, uint32_t code);

 #if defined(__GNUC__) && (__GNUC__ >= 12)
 // Convert a 16 bit pointer stored at the given rom address into a 32 bit pointer
-#define rom_hword_as_ptr(rom_address) \
-    ({ \
-       _Pragma("GCC diagnostic push") \
-       _Pragma("GCC diagnostic ignored \"-Warray-bounds\"") \
-       (void *)(uintptr_t)(*(uint16_t *)rom_address); \
-       _Pragma("GCC diagnostic pop") \
-    })
+static __force_inline void *rom_hword_as_ptr(uint32_t rom_address) {
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Warray-bounds"
+       return (void *)(uintptr_t)(*(uint16_t *)rom_address);
+    #pragma GCC diagnostic pop
+}
 #else
-#define rom_hword_as_ptr(rom_address) (void *)(uintptr_t)(*(uint16_t *)rom_address)
+static __force_inline void *rom_hword_as_ptr(uint32_t rom_address) {
+    return (void *) (uintptr_t) (*(uint16_t *) rom_address);
+}
 #endif

 /*!
diff --git a/src/rp2_common/pico_platform/include/pico/platform.h b/src/rp2_common/pico_platform/include/pico/platform.h
index ffc7660..b6d7251 100644
--- a/src/rp2_common/pico_platform/include/pico/platform.h
+++ b/src/rp2_common/pico_platform/include/pico/platform.h
@@ -333,9 +333,18 @@ uint8_t rp2040_chip_version(void);
  *  \ingroup pico_platform
  * @return the RP2040 rom version number (1 for RP2040-B0, 2 for RP2040-B1, 3 for RP2040-B2)
  */
+#if defined(__GNUC__) && (__GNUC__ >= 12)
 static inline uint8_t rp2040_rom_version(void) {
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Warray-bounds"
     return *(uint8_t*)0x13;
+    #pragma GCC diagnostic pop
 }
+#else
+static inline uint8_t rp2040_rom_version(void) {
+    return *(uint8_t*)0x13;
+}
+#endif

 /*! \brief No-op function for the body of tight loops
  *  \ingroup pico_platform
dhalbert commented 2 years ago

@tannewt has been using the Arch distribution, which keeps very current, and is at gcc12 for arm-none-eabi.

kilograham commented 2 years ago

So i was actually able to get the tests to pass by using these changes but i will be honest i have no idea what effects these changes will have on the sdk:

Yeah, that shouldn't be needed; but glad you are unblocked.

fivdi commented 2 years ago

OK, i will have to play with it in a docker container; i'd just install the official ARM gcc 11 for now

Assuming the official ARM gcc 11 is gcc11 for arm-none-eabi, how will this help resolving the problem? Isn't it gcc12 for arm-none-eabi that's needed?

kilograham commented 2 years ago

I meant I will play with GCC 12 in a docker container; I suggested using GCC 11 as a workaround.

kilograham commented 2 years ago

i can repro this in docker (once i figured out how to use pacman!)

SuperNinja-4965 commented 2 years ago

i can repro this in docker (once i figured out how to use pacman!)

Good to know that it wasn't my system causing the issue. (Yeah pacman can be a learning curve)

kilograham commented 2 years ago

ok, picio-sdk and examples now build with gcc12_fix branch

SuperNinja-4965 commented 2 years ago

ok, picio-sdk and examples now build with gcc12_fix branch

That's great. I've just run the tests on my computer and they are all now passing as expected. Thanks.

SuperNinja-4965 commented 2 years ago

Should i close this issue with #842 being merged into the develop branch?

kilograham commented 2 years ago

merged into develop :-)