Skip to content

Linker error: undefined reference to `spi_init' #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Bixilon opened this issue Apr 23, 2025 · 0 comments · Fixed by #101
Closed

Linker error: undefined reference to `spi_init' #100

Bixilon opened this issue Apr 23, 2025 · 0 comments · Fixed by #101

Comments

@Bixilon
Copy link

Bixilon commented Apr 23, 2025

Hi there,
I am trying to build my sample project, but it won't because ld is throwing an error:

Processing pico (platform: https://github.com/maxgerhardt/platform-raspberrypi.git; board: pico; framework: picosdk)
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/raspberrypi/pico.html
PLATFORM: Raspberry Pi RP2040 (1.16.0+sha.1f67f1e) > Raspberry Pi Pico
HARDWARE: RP2040 133MHz, 256KB RAM, 2MB Flash
DEBUG: Current (blackmagic) External (blackmagic, cmsis-dap, jlink, pico-debug, picoprobe, raspberrypi-swd)
PACKAGES: 
 - framework-picosdk @ 1.20000.0+sha.f943e7b 
 - tool-picotool-rp2040-earlephilhower @ 5.140200.240929 (14.2.0) 
 - toolchain-gccarmnoneeabi @ 1.90301.200702 (9.3.1)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 1 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Linking .pio/build/pico/firmware.elf
/home/moritz/.platformio/packages/toolchain-gccarmnoneeabi/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: .pio/build/pico/src/main.o: in function `main':
main.cpp:(.text.startup.main+0x10): undefined reference to `spi_init'
collect2: error: ld returned 1 exit status
*** [.pio/build/pico/firmware.elf] Error 1

The project is really minimal, the platformio.ini looks like this:

[env:pico]
platform = https://github.com/maxgerhardt/platform-raspberrypi.git
board = pico
framework = picosdk

And the main.c:

#include <hardware/spi.h>

int main() {
    spi_init(spi0, 123);
    return 0;
}

Is this a recent regression or do I somehow need to include the spi.h file in the build? If so, can you please tell me how?

Thank you.

Maybe related to #97

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant