diff --git a/test/kitchen_sink/CMakeLists.txt b/test/kitchen_sink/CMakeLists.txt index 60d97fd06..c2c88d9b3 100644 --- a/test/kitchen_sink/CMakeLists.txt +++ b/test/kitchen_sink/CMakeLists.txt @@ -2,23 +2,32 @@ add_library(kitchen_sink_libs INTERFACE) set(KITCHEN_SINK_LIBS hardware_adc + hardware_boot_lock + hardware_claim hardware_clocks + hardware_dcp hardware_divider hardware_dma hardware_exception hardware_flash hardware_gpio + hardware_hazard3 hardware_i2c hardware_interp hardware_irq hardware_pio - hardware_powman hardware_pll + hardware_powman hardware_pwm + hardware_rcp hardware_resets + hardware_riscv + hardware_riscv_platform_timer hardware_rtc + hardware_sha256 hardware_spi hardware_sync + hardware_sync_spin_lock hardware_ticks hardware_timer hardware_uart @@ -41,8 +50,12 @@ set(KITCHEN_SINK_LIBS pico_mem_ops pico_multicore pico_platform + pico_printf pico_rand + pico_runtime + pico_runtime_init pico_sha256 + pico_stdio pico_stdlib pico_sync pico_time @@ -50,16 +63,47 @@ set(KITCHEN_SINK_LIBS pico_util ) +set(KITCHEN_SINK_NO_HEADER_LIBS + hardware_dcp + pico_bootsel_via_double_reset + pico_int64_ops # currently empty, and only included by _pico variant + pico_mem_ops # currently empty, and only included by _pico variant +) + +set(KITCHEN_SINK_INCLUDES "#pragma once\n") foreach(LIB IN LISTS KITCHEN_SINK_LIBS) if (TARGET ${LIB}) target_link_libraries(kitchen_sink_libs INTERFACE ${LIB}) + string(REGEX MATCH "([a-z]+)_(.+)" HAS_MATCH ${LIB}) + if (HAS_MATCH AND NOT LIB IN_LIST KITCHEN_SINK_NO_HEADER_LIBS) + # these are few, so just hack fixing for now + if (LIB STREQUAL "pico_util") + string(APPEND KITCHEN_SINK_INCLUDES "#include \"pico/util/datetime.h\"\n") + string(APPEND KITCHEN_SINK_INCLUDES "#include \"pico/util/pheap.h\"\n") + string(APPEND KITCHEN_SINK_INCLUDES "#include \"pico/util/queue.h\"\n") + else() + if ("${CMAKE_MATCH_2}" STREQUAL "fix_rp2040_usb_device_enumeration") + set(CMAKE_MATCH_2 "fix/rp2040_usb_device_enumeration") + elseif ("${CMAKE_MATCH_2}" STREQUAL "sync_spin_lock") + set(CMAKE_MATCH_2 "sync/spin_lock") + endif() + string(APPEND KITCHEN_SINK_INCLUDES "#include \"${CMAKE_MATCH_1}/${CMAKE_MATCH_2}.h\"\n") + endif() + endif() endif() endforeach () +set(KITCHEN_SINK_INCLUDE_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kitchen_sink_includes.h") +file(GENERATE OUTPUT ${KITCHEN_SINK_INCLUDE_HEADER} CONTENT ${KITCHEN_SINK_INCLUDES}) add_library(kitchen_sink_options INTERFACE) -target_compile_options(kitchen_sink_options INTERFACE +if (NOT KITCHEN_SINK_NO_WERROR) + target_compile_options(kitchen_sink_options INTERFACE -Werror + ) +endif() + +target_compile_options(kitchen_sink_options INTERFACE -Wall -Wextra # -pedantic @@ -97,6 +141,7 @@ target_compile_definitions(kitchen_sink_libs INTERFACE PICO_FORBID_ARM_HEADERS_ON_RISCV=1 PARAM_ASSERTIONS_ENABLE_ALL=1 # want to check all the assertions for compilation warnings PICO_AUDIO_DMA_IRQ=1 + KITCHEN_SINK_INCLUDE_HEADER="${KITCHEN_SINK_INCLUDE_HEADER}" ) add_executable(kitchen_sink ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c) @@ -147,25 +192,27 @@ target_link_libraries(kitchen_sink_printf_none kitchen_sink_libs kitchen_sink_op pico_add_extra_outputs(kitchen_sink_printf_none) pico_set_printf_implementation(kitchen_sink_printf_none none) -add_executable(kitchen_sink_copy_to_ram ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c) -pico_set_binary_type(kitchen_sink_copy_to_ram copy_to_ram) -target_link_libraries(kitchen_sink_copy_to_ram kitchen_sink_libs kitchen_sink_options) -pico_add_extra_outputs(kitchen_sink_copy_to_ram) -target_compile_definitions(kitchen_sink_copy_to_ram PRIVATE KITCHEN_SINK_ID="copy-to-ram binary") - -add_executable(kitchen_sink_no_flash ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c) -pico_set_binary_type(kitchen_sink_no_flash no_flash) -target_link_libraries(kitchen_sink_no_flash kitchen_sink_libs kitchen_sink_options) -pico_add_extra_outputs(kitchen_sink_no_flash) -target_compile_definitions(kitchen_sink_no_flash PRIVATE KITCHEN_SINK_ID="no-flash binary") - -if (NOT PICO_RP2350) - # RP2350 does not have blocked ram - add_executable(kitchen_sink_blocked_ram ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c) - pico_set_binary_type(kitchen_sink_blocked_ram blocked_ram) - target_link_libraries(kitchen_sink_blocked_ram kitchen_sink_libs kitchen_sink_options) - pico_add_extra_outputs(kitchen_sink_blocked_ram) - target_compile_definitions(kitchen_sink_blocked_ram PRIVATE KITCHEN_SINK_ID="blocked-ram binary") +if (NOT KITCHEN_SINK_NO_BINARY_TYPE_VARIANTS) + add_executable(kitchen_sink_copy_to_ram ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c) + pico_set_binary_type(kitchen_sink_copy_to_ram copy_to_ram) + target_link_libraries(kitchen_sink_copy_to_ram kitchen_sink_libs kitchen_sink_options) + pico_add_extra_outputs(kitchen_sink_copy_to_ram) + target_compile_definitions(kitchen_sink_copy_to_ram PRIVATE KITCHEN_SINK_ID="copy-to-ram binary") + + add_executable(kitchen_sink_no_flash ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c) + pico_set_binary_type(kitchen_sink_no_flash no_flash) + target_link_libraries(kitchen_sink_no_flash kitchen_sink_libs kitchen_sink_options) + pico_add_extra_outputs(kitchen_sink_no_flash) + target_compile_definitions(kitchen_sink_no_flash PRIVATE KITCHEN_SINK_ID="no-flash binary") + + if (PICO_RP2040) + # RP2040 has blocked ram + add_executable(kitchen_sink_blocked_ram ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink.c) + pico_set_binary_type(kitchen_sink_blocked_ram blocked_ram) + target_link_libraries(kitchen_sink_blocked_ram kitchen_sink_libs kitchen_sink_options) + pico_add_extra_outputs(kitchen_sink_blocked_ram) + target_compile_definitions(kitchen_sink_blocked_ram PRIVATE KITCHEN_SINK_ID="blocked-ram binary") + endif() endif() add_executable(kitchen_sink_cpp ${CMAKE_CURRENT_LIST_DIR}/kitchen_sink_cpp.cpp) diff --git a/test/kitchen_sink/kitchen_sink.c b/test/kitchen_sink/kitchen_sink.c index 73417d5a5..7bc2bcd11 100644 --- a/test/kitchen_sink/kitchen_sink.c +++ b/test/kitchen_sink/kitchen_sink.c @@ -5,127 +5,18 @@ */ #include -// Include all headers to check for compiler warnings -#include "hardware/adc.h" -#include "hardware/claim.h" -#include "hardware/clocks.h" -#include "hardware/divider.h" + +#ifndef KITCHEN_SINK_INCLUDE_HEADER +// provided for backwards compatibility for non CMake build systems - just includes enough to compile #include "hardware/dma.h" -#include "hardware/exception.h" -#include "hardware/flash.h" -#include "hardware/gpio.h" -#include "hardware/i2c.h" -#include "hardware/interp.h" -#include "hardware/irq.h" -#include "hardware/pio.h" -#include "hardware/pio_instructions.h" -#include "hardware/pll.h" -#include "hardware/pwm.h" -#include "hardware/resets.h" -#if PICO_RP2040 -#include "hardware/rtc.h" -#endif -#if !PICO_RP2040 -#include "hardware/sha256.h" -#endif -#include "hardware/spi.h" -#include "hardware/sync.h" -#include "hardware/timer.h" -#include "hardware/ticks.h" -#include "hardware/uart.h" -#include "hardware/vreg.h" -#include "hardware/watchdog.h" -#include "hardware/xosc.h" -#include "pico/aon_timer.h" -#include "pico/binary_info.h" -#include "pico/bit_ops.h" -#include "pico/bootrom.h" -#if LIB_PICO_CYW43_ARCH -#include "pico/cyw43_arch.h" -#endif -#include "pico/divider.h" -// todo we should have this but right now double.h is only present with double_implementation == pico -#if PICO_RP2040 -#include "pico/double.h" -#endif -#include "pico/fix/rp2040_usb_device_enumeration.h" -#include "pico/flash.h" -// todo we should have this but right now float.h is only present with float_implementation == pico -#if PICO_RP2040 -#include "pico/float.h" -#endif -#include "pico/i2c_slave.h" -#if LIB_PICO_INT64_OPS_PICO -#include "pico/int64_ops.h" -#endif -#include "pico/malloc.h" -#include "pico/multicore.h" -#include "pico/platform.h" -#include "pico/printf.h" -#include "pico/rand.h" -#include "pico/runtime.h" -#if LIB_PICO_SHA256 -#include "pico/sha256.h" -#endif -#include "pico/stdio.h" -#include "pico/stdlib.h" #include "pico/sync.h" -#include "pico/time.h" -#include "pico/unique_id.h" -#include "pico/util/datetime.h" -#include "pico/util/pheap.h" -#include "pico/util/queue.h" - -#include "hardware/structs/adc.h" -#include "hardware/structs/busctrl.h" -#include "hardware/structs/clocks.h" -#include "hardware/structs/dma.h" -#include "hardware/structs/i2c.h" -#include "hardware/structs/interp.h" -#include "hardware/structs/io_bank0.h" -#include "hardware/structs/io_qspi.h" -#ifndef __riscv -#include "hardware/structs/mpu.h" -#include "hardware/structs/nvic.h" -#endif -#include "hardware/structs/pads_bank0.h" -#include "hardware/structs/pads_qspi.h" -#include "hardware/structs/pio.h" -#include "hardware/structs/pll.h" -#if PICO_RP2350 -#include "hardware/structs/powman.h" -#endif -#include "hardware/structs/psm.h" -#include "hardware/structs/pwm.h" -#include "hardware/structs/resets.h" -#include "hardware/structs/rosc.h" -#if PICO_RP2040 -#include "hardware/structs/rtc.h" -#endif -#ifndef __riscv -#include "hardware/structs/scb.h" -#endif -#include "hardware/structs/sio.h" -#if !PICO_RP2040 -#include "hardware/structs/sha256.h" -#endif -#include "hardware/structs/spi.h" -#if PICO_RP2040 -#include "hardware/structs/ssi.h" -#endif -#include "hardware/structs/syscfg.h" -#ifndef __riscv -#include "hardware/structs/systick.h" +#include "pico/stdlib.h" +#if LIB_PICO_BINARY_INFO +#include "pico/binary_info.h" #endif -#include "hardware/structs/timer.h" -#include "hardware/structs/uart.h" -#include "hardware/structs/usb.h" -#if PICO_RP2040 -#include "hardware/structs/vreg_and_chip_reset.h" +#else +#include KITCHEN_SINK_INCLUDE_HEADER #endif -#include "hardware/structs/watchdog.h" -#include "hardware/structs/xip_ctrl.h" -#include "hardware/structs/xosc.h" #if LIB_PICO_MBEDTLS #include "mbedtls/ssl.h" @@ -133,6 +24,7 @@ #include "lwip/altcp_tls.h" #endif +#if LIB_PICO_BINARY_INFO bi_decl(bi_block_device( BINARY_INFO_MAKE_TAG('K', 'S'), "foo", @@ -141,6 +33,7 @@ bi_decl(bi_block_device( NULL, BINARY_INFO_BLOCK_DEV_FLAG_READ | BINARY_INFO_BLOCK_DEV_FLAG_WRITE | BINARY_INFO_BLOCK_DEV_FLAG_PT_UNKNOWN)); +#endif uint32_t *foo = (uint32_t *) 200; @@ -167,7 +60,6 @@ float __attribute__((noinline)) foox(float x, float b) { return x * b; } - int main(void) { spiggle();