-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Hi, i'm importing my issue from the upstream fork to here ... basically I'm wishing I could get this toolchain working for the RP2040 core I'm using. The readme suggests that it's known to work on ESP32 and could in theory work with any other Arduino core. But if that's not even your goal, then I won't pursue this any further.
At the moment I'm not able to compile all of the examples, though I can compile some of them. The issues seem to be due to various components of the RP2040 core not being found.
This is my cmake command:
% mkdir build
% cd build
% cmake -D CMAKE_TOOLCHAIN_FILE=../Arduino-toolchain.cmake -DARDUINO_INSTALL_PATH=/Applications/Arduino\ +\ Teensy\ 1.8.16.app/Contents/Java -DARDUINO_SKETCHBOOK_PATH=$HOME/Documents/Arduino ../Examples
/Applications/Arduino + Teensy 1.8.16.app/Contents/Java
-- Found Arduino Platform: /Applications/Arduino + Teensy 1.8.16.app/Contents/Java/hardware/arduino/avr
-- Found Arduino Platform: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2
-- Found Arduino Platform: /Volumes/External/mykle/Library/Arduino15/packages/teensy/hardware/avr/1.59.0
-- Selected Arduino Board: Generic RP2040 [rp2040.generic]
-- Selected board option: "Flash Size" = "2MB (no FS)"
-- Selected board option: "CPU Speed" = "133 MHz"
-- Selected board option: "Optimize" = "Small (-Os) (standard)"
-- Selected board option: "RTTI" = "Disabled"
-- Selected board option: "Stack Protector" = "Disabled"
-- Selected board option: "C++ Exceptions" = "Disabled"
-- Selected board option: "Debug Port" = "Disabled"
-- Selected board option: "Debug Level" = "None"
-- Selected board option: "USB Stack" = "Adafruit TinyUSB"
-- Selected board option: "IP/Bluetooth Stack" = "IPv4 Only"
-- Selected board option: "Boot Stage 2" = "Generic SPI /2"
-- Selected board option: "Upload Method" = "Default (UF2)"
-- The C compiler identification is GNU 12.3.0
-- The CXX compiler identification is GNU 12.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/tools/pqt-gcc/2.2.0-d04e724/bin/arm-none-eabi-gcc - 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: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/tools/pqt-gcc/2.2.0-d04e724/bin/arm-none-eabi-g++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Arduino Library EEPROM: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2/libraries/EEPROM
-- Found Arduino Library Adafruit_TinyUSB: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2/libraries/Adafruit_TinyUSB_Arduino
-- Found Arduino Library SPI: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2/libraries/SPI
-- Found Arduino Library SdFat: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2/libraries/ESP8266SdFat
-- Found Arduino Library USB: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2/libraries/Adafruit_TinyUSB_Arduino
-- Found Arduino Library Stepper: /Volumes/External/mykle/Documents/Arduino/libraries/Stepper
-- Found Arduino Library local_lib: /Volumes/External/mykle/Documents/tmp/Arduino-CMake-Toolchain/Examples/02_arduino_lib/libraries/local_lib
-- Found Arduino Library Wire: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2/libraries/Wire
-- Found Arduino Library SD: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2/libraries/SD
-- Found Arduino Library FS: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2/libraries/LittleFS
-- Found Arduino Library SDFS: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2/libraries/SDFS
-- Found Arduino Library LittleFS: /Volumes/External/mykle/Library/Arduino15/packages/rp2040/hardware/rp2040/3.7.2/libraries/LittleFS
-- Configuring done
-- Generating done
-- Build files have been written to: /Volumes/External/mykle/Documents/tmp/Arduino-CMake-Toolchain/Examples_build
The options all appear correct to me.
The first problem I get when trying to make any of the targets is that the final link step fails, with this sort of error:
[100%] Linking CXX executable arduino_lib.elf
Executing recipe.hooks.linking.prelink.1.pattern hook
Executing recipe.hooks.linking.prelink.2.pattern hook
/Volumes/External/mykle/Library/Arduino15/packages/rp2040/tools/pqt-gcc/2.2.0-d04e724/bin/../lib/gcc/arm-none-eabi/12.3.0/../../../../arm-none-eabi/bin/ld: cannot open linker script file /Volumes/External/mykle/Documents/tmp/Arduino-CMake-Toolchain/Examples_build/memmap_default.ld: No such file or directory
collect2: error: ld returned 1 exit status
make[3]: *** [02_arduino_lib/arduino_lib.elf] Error 1
make[2]: *** [02_arduino_lib/CMakeFiles/arduino_lib.dir/all] Error 2
make[1]: *** [02_arduino_lib/CMakeFiles/arduino_lib.dir/rule] Error 2
make: *** [arduino_lib] Error 2
The build is looking for memmap_default.ld in the wrong place. It gets built, but it's in the example subdirectory, one directory under the main build directory where the build is searching. If I link that file from where it was built to where the build is searching, then I see the same problem with another file, boot2.o. If i link that file as well, then some of the examples finally appear to build correctly.
However I still can't build hello_world, because of another linker error:
[ 93%] Built target _arduino_lib_core
[ 93%] Linking CXX executable hello_world.elf
Executing recipe.hooks.linking.prelink.1.pattern hook
Executing recipe.hooks.linking.prelink.2.pattern hook
/Volumes/External/mykle/Library/Arduino15/packages/rp2040/tools/pqt-gcc/2.2.0-d04e724/bin/../lib/gcc/arm-none-eabi/12.3.0/../../../../arm-none-eabi/bin/ld: CMakeFiles/hello_world.dir/hello_world.cpp.o: in function `setup':
/Volumes/External/mykle/Documents/tmp/Arduino-CMake-Toolchain/Examples/01_hello_world/hello_world.cpp:7: undefined reference to `_ZN17Adafruit_USBD_CDC5beginEm'
/Volumes/External/mykle/Library/Arduino15/packages/rp2040/tools/pqt-gcc/2.2.0-d04e724/bin/../lib/gcc/arm-none-eabi/12.3.0/../../../../arm-none-eabi/bin/ld: /Volumes/External/mykle/Documents/tmp/Arduino-CMake-Toolchain/Examples/01_hello_world/hello_world.cpp:16: undefined reference to `Serial'
collect2: error: ld returned 1 exit status
make[3]: *** [01_hello_world/hello_world.elf] Error 1
make[2]: *** [01_hello_world/CMakeFiles/hello_world.dir/all] Error 2
make[1]: *** [01_hello_world/CMakeFiles/hello_world.dir/rule] Error 2
make: *** [hello_world] Error 2
This looks to me like the linker is not finding the compiled Adafruit_TinyUSB classes. (_ZN17Adafruit_USBD_CDC5beginEm looks to me like a GCC-encoded method name.) I'm not sure if it intends to be looking for the version included with the examples in 02_arduino_lib (which do appear to build correctly) or whether it's trying to find the version provided with the RP2040 core (which cmake found OK, as logged above.)
So all of this seems to come down to link-stage errors. Maybe the linker, or the compiler that calls it, needs to be provided with more library paths? I'm really not sure how to debug this further because it's running into the border between the cmake package and the rp2040 core & I don't know which side is responsible for these compiler invocations.
Any help would be much appreciated!