Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8142

C/C++ • Re: Included cyw43 lib now it doesnt compile

$
0
0
I haven't had time to do anything pico related for over 18months it seems. I did update the pico-sdk in August though. This still compiles..

Code:

foo@sdu:~/usr/src/rpi/pico/blink$ cat CMakeLists.txtcmake_minimum_required(VERSION 3.13)include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)if (NOT PICO_SDK_PATH)message(FATAL_ERROR "?PICO_SDK_PATH? (not set)")endif()set(APP picow_blink)project(${APP})pico_sdk_init()file(GLOB APP_S "*.cpp" "*.c")file(GLOB APP_H "*.hpp" "*.h")add_executable(${APP} ${APP_S} ${APP_H})target_include_directories(${APP} PRIVATE    ${CMAKE_CURRENT_LIST_DIR})target_link_libraries(${APP}pico_stdlibpico_cyw43_arch_none )pico_add_extra_outputs(${APP})

Code:

foo@sdu:~/usr/src/rpi/pico/blink$ cat picow_blink.c /** * Copyright (c) 2022 Raspberry Pi (Trading) Ltd. * * SPDX-License-Identifier: BSD-3-Clause */#include "pico/stdlib.h"#include "pico/cyw43_arch.h"int main() {    stdio_init_all();    if (cyw43_arch_init()) {        printf("WiFi init failed");        return -1;    }    while (true) {        cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);        sleep_ms(250);        cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 0);        sleep_ms(250);    }}

Code:

foo@sdu:~/usr/src/rpi/pico$ cat ~/.picorc : ${PICO_BOARD:=pico_w}: ${PICO_SDK_PATH:=$HOME/usr/src/rpi/pico/pico-sdk}: ${PICO_EXTRAS_PATH:=$HOME/usr/src/rpi/pico/pico-extras}: ${PICO_EXAMPLES_PATH:=$HOME/usr/src/rpi/pico/pico-examples}: ${PICO_PLAYGROUND_PATH:=$HOME/usr/src/rpi/pico/pico-playground}export PICO_SDK_PATH PICO_EXTRAS_PATH PICO_EXAMPLES_PATH PICO_PLAYGROUND_PATHexport PICO_BOARDexport PATH=/usr/local/qt/xgcc/arm-none-eabi/bin:$PATH#export PICO_BOARD=pico_w#export PICO_BOARD=pico: ${FREERTOS_KERNEL_PATH:=$HOME/usr/src/rpi/pico/freertos/FreeRTOS-Kernel}export FREERTOS_KERNEL_PATH: ${PIMORONI_PICO_PATH:=$HOME/usr/src/rpi/pico/pimoroni-pico}export PIMORONI_PICO_PATH
I don't expect you to understand the above of course. In fact, after 18 months a lot of it passes me by as well! ;-)

The important thing is you can look at it for reference. Don't copy it. It won't work for you. Forget your IDE for a moment, everything which is going on revolves around a tool called 'cmake'. The above was done on the command line on a linux PC. I can do it using an IDE. You use vscode. I use QtCreator. Trouble is, when those IDE "break" they often hide important details from you. Something has decided to pass a "-Werror" option to the compiler. This tells it to treat warnings as errors and abort the compilation.

Here's the code..

Code:

foo@sdu:~/usr/src/rpi/pico/blink$ lctotal 16-rw-r--r-- 1 foo foo 511 Oct 16 23:16 CMakeLists.txtlrwxrwxrwx 1 foo foo   6 Dec 25  2022 foo -> ../foo-rw-r--r-- 1 foo foo 466 Sep 12  2022 picow_blink.c
From the command line all I have to do is create a build folder..

Code:

foo@sdu:~/usr/src/rpi/pico/blink$ mkdir wibblefoo@sdu:~/usr/src/rpi/pico/blink$ cd wibble
Then tell 'cmake' to do its thing..

Code:

foo@sdu:~/usr/src/rpi/pico/blink/wibble$ cmake ..
If we get that far without an error we can try to build the project..

Code:

foo@sdu:~/usr/src/rpi/pico/blink/wibble$ cmake --build .
If there's no errors, you have your project..

Code:

foo@sdu:~/usr/src/rpi/pico/blink/wibble$ ls -ld picow_blink.*-rwxrwxr-x 1 foo foo 262972 Oct 16 23:33 picow_blink.bin-rw-rw-r-- 1 foo foo 663686 Oct 16 23:33 picow_blink.dis-rwxrwxr-x 1 foo foo 993328 Oct 16 23:33 picow_blink.elf-rw-rw-r-- 1 foo foo 502272 Oct 16 23:33 picow_blink.elf.map-rw-rw-r-- 1 foo foo 526336 Oct 16 23:33 picow_blink.uf2
There's a thing about 'cmake'. It creates a file called "CMakeCache.txt" (and a lot of other files) in the the build folder ("wibble" in this case). If you want it to start from scratch you have to 'cd' out of that folder and delete it. This is because 'cmake' has a nasty habit of remembering things you don't want it to. If my "CMakeCache.txt" ended up on your PC here's the compiler it would try to use..

Code:

foo@sdu:~/usr/src/rpi/pico/blink/wibble$ cat CMakeCache.txt | grep CMAKE_CXX_COMPILER:CMAKE_CXX_COMPILER:STRING=/usr/local/qt/xgcc/arm-none-eabi/bin/arm-none-eabi-g++
..which is unique to me. Won't even work for other linux users because I built that cross-compiler myself. It's why the "cmake .." step is required, for it to discover that and many other things.

tl;dr: all you need to upload to github is the source file hierarchy and "CMakeLists.txt".

I suspect the above is where you've gone wrong - uploading stuff which confuses 'cmake' and thus the IDE.

Statistics: Posted by swampdog — Wed Oct 16, 2024 10:59 pm



Viewing all articles
Browse latest Browse all 8142

Trending Articles