C/C++ Raspberry Pi Pico

arg

New Member

Reaction score: 3
Messages: 5

No, it's invoking the target g++ compiler and that is picking up the host includes. If I manually run what that makefile is doing:
Code:
% arm-none-eabi-g++ -c /home/arg/work/pico/pico-sdk/src/rp2_common/pico_standard_link/new_delete.cpp
In file included from /usr/include/c++/v1/cstdlib:84,
                 from /home/arg/work/pico/pico-sdk/src/rp2_common/pico_standard_link/new_delete.cpp:10:
/usr/include/c++/v1/__config:1132:6: error: #error "No thread API"
 #    error "No thread API"
and looking at line 10 of that file, it's just:
Code:
#include <cstdlib>
So the include path for the g++ in the arm-none-eabi-gcc port appears to be wrong.
 

arg

New Member

Reaction score: 3
Messages: 5

Deleting the arm-none-eabi package and replacing it with gcc-arm-embedded makes it work. Since gcc-arm-embedded installs in a separate directory rather than /usr/local/bin, you also need to set PICO_TOOLCHAIN_PATH=/usr/local/gcc-arm-embedded , but it then successfully builds all of the examples.
 

arg

New Member

Reaction score: 3
Messages: 5

Downloading executables by mounting the USB mass storage exposed by the Pico and copying UF2 images onto it works fine, but I find it a bit clunky:

Code:
# camcontrol devlist
… other drives here ….
<RPI RP2 2>                        at scbus8 target 0 lun 0 (da0,pass4)
# mount -t msdos /dev/da0s1 /mnt
# cp work/pico/pico-examples/build/blink/blink.uf2 /mnt
# umount /mnt

Picotool is nicer for a shell user, and it almost builds out-of-the-box (Appendix B in the 'getting started' guide), however the Cmake script fails to locate FreeBSD's libusb correctly because the library is called 'libusb' rather than 'libusb-1.0'. I'm not sure if this is a defect in FreeBSD's package description (/usr/libdata/pkgconfig/libusb-1.0.pc) or that pkgtool/cmake just can't handle this automatically, but it's easily fixed in the cmake script that comes in the picotool source:

Code:
% git diff
diff --git a/cmake/FindLIBUSB.cmake b/cmake/FindLIBUSB.cmake
index c8cc62c..560e023 100644
--- a/cmake/FindLIBUSB.cmake
+++ b/cmake/FindLIBUSB.cmake
@@ -20,7 +20,7 @@ else (LIBUSB_INCLUDE_DIR AND LIBUSB_LIBRARIES)
     ENDIF(NOT WIN32)
     FIND_PATH(LIBUSB_INCLUDE_DIR libusb.h
             PATHS ${PC_LIBUSB_INCLUDEDIR} ${PC_LIBUSB_INCLUDE_DIRS})
-    FIND_LIBRARY(LIBUSB_LIBRARIES NAMES usb-1.0
+    FIND_LIBRARY(LIBUSB_LIBRARIES NAMES usb-1.0 usb
             PATHS ${PC_LIBUSB_LIBDIR} ${PC_LIBUSB_LIBRARY_DIRS})
     include(FindPackageHandleStandardArgs)
     FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIR)

ie. just add "usb" after "usb-1.0" on the FIND_LIBRARY line.

The USB console examples work just fine with FreeBSD, popping up as /dev/ttyU0 etc.
 
OP
SirDice

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 12,675
Messages: 39,278

I'm going to have another go at this tonight. Thanks for the missing info, I was kind of stumped why it didn't work. I had a feeling it has something to do with the include directories (why was it trying to pull in include files from FreeBSD's /usr/include) but couldn't figure out why that happened.
 
Top