From aee150e4e80da5b84523988380936d7ee6497c22 Mon Sep 17 00:00:00 2001 From: Andrew Scheller Date: Thu, 22 Aug 2024 10:34:17 +0100 Subject: [PATCH 1/4] Fix compilation for PICO_BOARD=pico_w when cyw43_arch is missing --- CMakeLists.txt | 10 +++++++++- adc/CMakeLists.txt | 12 ++++++++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 416ac6780..095077690 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,15 @@ function(add_subdirectory_exclude_platforms NAME) endfunction() # Add blink example -add_subdirectory_exclude_platforms(blink) +if (PICO_CYW43_SUPPORTED) # set by PICO_BOARD=pico_w + if (NOT TARGET pico_cyw43_arch) + message("Skipping blink for Pico W as support is not available") + else() + add_subdirectory_exclude_platforms(blink) + endif() +else() + add_subdirectory_exclude_platforms(blink) +endif() add_subdirectory_exclude_platforms(blink_simple) # Add hello world example diff --git a/adc/CMakeLists.txt b/adc/CMakeLists.txt index 71c423541..b628a4547 100644 --- a/adc/CMakeLists.txt +++ b/adc/CMakeLists.txt @@ -5,7 +5,15 @@ if (TARGET hardware_adc) add_subdirectory_exclude_platforms(joystick_display) add_subdirectory_exclude_platforms(onboard_temperature) add_subdirectory_exclude_platforms(microphone_adc) - add_subdirectory_exclude_platforms(read_vsys) + if (PICO_CYW43_SUPPORTED) # set by PICO_BOARD=pico_w + if (NOT TARGET pico_cyw43_arch) + message("Skipping read_vsys for Pico W as support is not available") + else() + add_subdirectory_exclude_platforms(read_vsys) + endif() + else() + add_subdirectory_exclude_platforms(read_vsys) + endif() else() message("Skipping ADC examples as hardware_adc is unavailable on this platform") -endif() \ No newline at end of file +endif() From 35bbfb508a29599331bfbc6f38991c5dbaf1b033 Mon Sep 17 00:00:00 2001 From: Peter Harper Date: Thu, 22 Aug 2024 18:36:14 +0100 Subject: [PATCH 2/4] Simplify things a bit --- CMakeLists.txt | 8 ++------ adc/CMakeLists.txt | 8 ++------ 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 095077690..f47a9029c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,12 +43,8 @@ function(add_subdirectory_exclude_platforms NAME) endfunction() # Add blink example -if (PICO_CYW43_SUPPORTED) # set by PICO_BOARD=pico_w - if (NOT TARGET pico_cyw43_arch) - message("Skipping blink for Pico W as support is not available") - else() - add_subdirectory_exclude_platforms(blink) - endif() +if (PICO_CYW43_SUPPORTED AND NOT TARGET pico_cyw43_arch) + message("Skipping blink for Pico W as support is not available") else() add_subdirectory_exclude_platforms(blink) endif() diff --git a/adc/CMakeLists.txt b/adc/CMakeLists.txt index b628a4547..5168ce2f3 100644 --- a/adc/CMakeLists.txt +++ b/adc/CMakeLists.txt @@ -5,12 +5,8 @@ if (TARGET hardware_adc) add_subdirectory_exclude_platforms(joystick_display) add_subdirectory_exclude_platforms(onboard_temperature) add_subdirectory_exclude_platforms(microphone_adc) - if (PICO_CYW43_SUPPORTED) # set by PICO_BOARD=pico_w - if (NOT TARGET pico_cyw43_arch) - message("Skipping read_vsys for Pico W as support is not available") - else() - add_subdirectory_exclude_platforms(read_vsys) - endif() + if (PICO_CYW43_SUPPORTED AND NOT TARGET pico_cyw43_arch) + message("Skipping read_vsys for Pico W as support is not available") else() add_subdirectory_exclude_platforms(read_vsys) endif() From b152b521869ca0f5b07e019b1e579702de9cc43b Mon Sep 17 00:00:00 2001 From: Peter Harper Date: Tue, 3 Sep 2024 14:10:54 +0100 Subject: [PATCH 3/4] Fix message displayed when cyw43-driver is missing --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f47a9029c..75412503b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,7 @@ endfunction() # Add blink example if (PICO_CYW43_SUPPORTED AND NOT TARGET pico_cyw43_arch) - message("Skipping blink for Pico W as support is not available") + message("Wi-Fi driver is not available") else() add_subdirectory_exclude_platforms(blink) endif() From 5114e617554bc66e4fd83d8da22d5566eb24ac3f Mon Sep 17 00:00:00 2001 From: Peter Harper Date: Sat, 23 Nov 2024 14:21:53 +0000 Subject: [PATCH 4/4] Fix review comments And address other build issues that occur if cyw43 is supported but the cyw43-driver does not exist. --- CMakeLists.txt | 6 +---- adc/CMakeLists.txt | 6 +---- adc/read_vsys/CMakeLists.txt | 5 +++++ binary_info/blink_any/CMakeLists.txt | 3 +++ blink/CMakeLists.txt | 5 +++++ freertos/hello_freertos/CMakeLists.txt | 28 +++++++++++++++++------- freertos/hello_freertos/hello_freertos.c | 11 ++++++---- pico_w/CMakeLists.txt | 4 ++-- pico_w/bt/CMakeLists.txt | 2 +- pico_w/wifi/CMakeLists.txt | 4 ++-- pico_w/wifi/blink/CMakeLists.txt | 4 ++++ pico_w/wifi/freertos/CMakeLists.txt | 2 +- 12 files changed, 52 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 75412503b..416ac6780 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,11 +43,7 @@ function(add_subdirectory_exclude_platforms NAME) endfunction() # Add blink example -if (PICO_CYW43_SUPPORTED AND NOT TARGET pico_cyw43_arch) - message("Wi-Fi driver is not available") -else() - add_subdirectory_exclude_platforms(blink) -endif() +add_subdirectory_exclude_platforms(blink) add_subdirectory_exclude_platforms(blink_simple) # Add hello world example diff --git a/adc/CMakeLists.txt b/adc/CMakeLists.txt index 5168ce2f3..bb478da39 100644 --- a/adc/CMakeLists.txt +++ b/adc/CMakeLists.txt @@ -5,11 +5,7 @@ if (TARGET hardware_adc) add_subdirectory_exclude_platforms(joystick_display) add_subdirectory_exclude_platforms(onboard_temperature) add_subdirectory_exclude_platforms(microphone_adc) - if (PICO_CYW43_SUPPORTED AND NOT TARGET pico_cyw43_arch) - message("Skipping read_vsys for Pico W as support is not available") - else() - add_subdirectory_exclude_platforms(read_vsys) - endif() + add_subdirectory_exclude_platforms(read_vsys) else() message("Skipping ADC examples as hardware_adc is unavailable on this platform") endif() diff --git a/adc/read_vsys/CMakeLists.txt b/adc/read_vsys/CMakeLists.txt index 67535bd72..003368e20 100644 --- a/adc/read_vsys/CMakeLists.txt +++ b/adc/read_vsys/CMakeLists.txt @@ -1,3 +1,8 @@ +if (PICO_CYW43_SUPPORTED AND NOT TARGET pico_cyw43_arch) + message("Skipping read_vsys as Wi-Fi driver is not available") + return() +endif() + add_library(power_status_adc INTERFACE) target_sources(power_status_adc INTERFACE ${CMAKE_CURRENT_LIST_DIR}/power_status.c diff --git a/binary_info/blink_any/CMakeLists.txt b/binary_info/blink_any/CMakeLists.txt index de0401993..246db0918 100644 --- a/binary_info/blink_any/CMakeLists.txt +++ b/binary_info/blink_any/CMakeLists.txt @@ -1,3 +1,6 @@ +if (PICO_CYW43_SUPPORTED AND NOT TARGET pico_cyw43_arch) + return() +endif() if (NOT PICO_CYW43_SUPPORTED) message("Only building blink_any for non W boards as PICO_CYW43_SUPPORTED is not set") endif() diff --git a/blink/CMakeLists.txt b/blink/CMakeLists.txt index 6308572d4..dfdf716ed 100644 --- a/blink/CMakeLists.txt +++ b/blink/CMakeLists.txt @@ -1,3 +1,8 @@ +if (PICO_CYW43_SUPPORTED AND NOT TARGET pico_cyw43_arch) + message("Skipping blink examples as Wi-Fi driver is not available") + return() +endif() + add_executable(blink blink.c ) diff --git a/freertos/hello_freertos/CMakeLists.txt b/freertos/hello_freertos/CMakeLists.txt index 1da0ce773..4f3ffb6e4 100644 --- a/freertos/hello_freertos/CMakeLists.txt +++ b/freertos/hello_freertos/CMakeLists.txt @@ -11,10 +11,16 @@ target_link_libraries(${TARGET_NAME} PRIVATE pico_stdlib ) if(PICO_CYW43_SUPPORTED) - # For led support on pico_w - target_link_libraries(${TARGET_NAME} PRIVATE - pico_cyw43_arch_none - ) + if (TARGET pico_cyw43_arch) + # For led support on Wi-Fi boards + target_link_libraries(${TARGET_NAME} PRIVATE + pico_cyw43_arch_none + ) + else() + target_compile_definitions(${TARGET_NAME} PRIVATE + USE_LED=0 + ) + endif() endif() target_compile_definitions(${TARGET_NAME} PRIVATE configNUMBER_OF_CORES=1 @@ -34,9 +40,15 @@ target_link_libraries(${TARGET_NAME} PRIVATE pico_stdlib ) if(PICO_CYW43_SUPPORTED) - # For led support on pico_w - target_link_libraries(${TARGET_NAME} PRIVATE - pico_cyw43_arch_none - ) + if (TARGET pico_cyw43_arch) + # For led support on Wi-Fi boards + target_link_libraries(${TARGET_NAME} PRIVATE + pico_cyw43_arch_none + ) + else() + target_compile_definitions(${TARGET_NAME} PRIVATE + USE_LED=0 + ) + endif() endif() pico_add_extra_outputs(${TARGET_NAME}) diff --git a/freertos/hello_freertos/hello_freertos.c b/freertos/hello_freertos/hello_freertos.c index 77a3c8490..b5bf488a8 100755 --- a/freertos/hello_freertos/hello_freertos.c +++ b/freertos/hello_freertos/hello_freertos.c @@ -9,9 +9,16 @@ #include "pico/stdlib.h" #include "pico/multicore.h" +// Whether to flash the led +#ifndef USE_LED +#define USE_LED 1 +#endif + +#if USE_LED #ifdef CYW43_WL_GPIO_LED_PIN #include "pico/cyw43_arch.h" #endif +#endif #include "FreeRTOS.h" #include "task.h" @@ -21,10 +28,6 @@ #define RUN_FREE_RTOS_ON_CORE 0 #endif -// Whether to flash the led -#ifndef USE_LED -#define USE_LED 1 -#endif // Whether to busy wait in the led thread #ifndef LED_BUSY_WAIT diff --git a/pico_w/CMakeLists.txt b/pico_w/CMakeLists.txt index f66c02e95..8dd84e331 100644 --- a/pico_w/CMakeLists.txt +++ b/pico_w/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.12) if (PICO_CYW43_SUPPORTED) # set by PICO_BOARD=pico_w if (NOT TARGET pico_cyw43_arch) - message("Skipping Pico W examples as support is not available") + message("Skipping Wi-Fi examples as support is not available") else() if (DEFINED ENV{WIFI_SSID} AND (NOT WIFI_SSID)) @@ -20,7 +20,7 @@ if (PICO_CYW43_SUPPORTED) # set by PICO_BOARD=pico_w add_subdirectory(wifi) if (NOT TARGET pico_btstack_base) - message("Skipping Pico W Bluetooth examples as support is not available") + message("Skipping Bluetooth examples as support is not available") else() add_subdirectory(bt) endif() diff --git a/pico_w/bt/CMakeLists.txt b/pico_w/bt/CMakeLists.txt index e14345398..b4676ccc1 100644 --- a/pico_w/bt/CMakeLists.txt +++ b/pico_w/bt/CMakeLists.txt @@ -6,7 +6,7 @@ set(BTSTACK_3RD_PARTY_PATH ${BTSTACK_ROOT}/3rd-party) set(BT_EXAMPLE_COMMON_DIR "${CMAKE_CURRENT_LIST_DIR}") if (NOT PICO_EXTRAS_PATH) - message("Skipping some Pico W BTstack examples that require pico-extras") + message("Skipping some BTstack examples that require pico-extras") else() add_library(pico_btstack_audio_example INTERFACE) target_sources(pico_btstack_audio_example INTERFACE diff --git a/pico_w/wifi/CMakeLists.txt b/pico_w/wifi/CMakeLists.txt index 8b6e2b9b5..d64194e9e 100644 --- a/pico_w/wifi/CMakeLists.txt +++ b/pico_w/wifi/CMakeLists.txt @@ -6,9 +6,9 @@ add_subdirectory_exclude_platforms(wifi_scan) add_subdirectory_exclude_platforms(access_point) if ("${WIFI_SSID}" STREQUAL "") - message("Skipping some Pico W examples as WIFI_SSID is not defined") + message("Skipping some Wi-Fi examples as WIFI_SSID is not defined") elseif ("${WIFI_PASSWORD}" STREQUAL "") - message("Skipping some Pico W examples as WIFI_PASSWORD is not defined") + message("Skipping some Wi-Fi examples as WIFI_PASSWORD is not defined") else() add_subdirectory_exclude_platforms(freertos) add_subdirectory_exclude_platforms(httpd) diff --git a/pico_w/wifi/blink/CMakeLists.txt b/pico_w/wifi/blink/CMakeLists.txt index 2b1e6bfd3..2beb40c8e 100644 --- a/pico_w/wifi/blink/CMakeLists.txt +++ b/pico_w/wifi/blink/CMakeLists.txt @@ -1,3 +1,7 @@ +if (PICO_CYW43_SUPPORTED AND NOT TARGET pico_cyw43_arch) + return() +endif() + add_executable(picow_blink picow_blink.c ) diff --git a/pico_w/wifi/freertos/CMakeLists.txt b/pico_w/wifi/freertos/CMakeLists.txt index b4057602f..ab223e272 100644 --- a/pico_w/wifi/freertos/CMakeLists.txt +++ b/pico_w/wifi/freertos/CMakeLists.txt @@ -1,5 +1,5 @@ if (NOT FREERTOS_KERNEL_PATH AND NOT DEFINED ENV{FREERTOS_KERNEL_PATH}) - message("Skipping Pico W FreeRTOS examples as FREERTOS_KERNEL_PATH not defined") + message("Skipping Wi-Fi FreeRTOS examples as FREERTOS_KERNEL_PATH not defined") else() include(FreeRTOS_Kernel_import.cmake)