Skip to content
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

When PicoBoard or PicoPlatform build option were added, removed or changed, CMake print errors and fail to build #2

Open
demotomohiro opened this issue Nov 14, 2024 · 0 comments

Comments

@demotomohiro
Copy link
Owner

How to reproduce:

# Make sure blink.nim's nimcache directory is empty
$ cd picosdk4nim/examples
$ nim c blink.nim
# Suppose it compiles successfully

$ nim c -d:PicoBoard=pico2 blink.nim
...
Target board (PICO_BOARD) is 'pico2'.
Using board configuration from pico-sdk/src/boards/include/boards/pico2.h
CMake Error at pico-sdk/cmake/pico_pre_load_platform.cmake:111 (message):
  PICO_PLATFORM is specified to be 'rp2040', but PICO_BOARD='pico2' uses
  'rp2350' which is incompatible.  You need to delete the CMake cache or
  build directory and reconfigure to proceed.  The best practice is to use
  separate build directories for different platforms.
Call Stack (most recent call first):
  pico-sdk/pico_sdk_init.cmake:87 (include)
  CMakeLists.txt:6 (include)


-- Configuring incomplete, errors occurred!

$ nim c -d:PicoBoard=pico2 -d:PicoPlatform=rp2350-arm-s blink.nim
# No errors from cmake and it looks like compiles successfully.
# But C files are compiled with compile options for RP2040 not for RP2350
# and it likely doesn't work on Raspberry Pi Pico 2

When nim c blink.nim is executed without any cached files, CMake files in Pico SDK detects C compilers and set C compiler paths, C compiler options or other build parameters in cmakeBuildDir/CMakeCache.txt in the cache directory.
As Pico SDK builds binary for Raspberry Pi Pico in default, these build parameters are set for Raspberry Pi Pico.
For example, there is a line CMAKE_C_FLAGS:STRING=-mcpu=cortex-m0plus -mthumb in CMakeCache.txt that is the compile option to build binary for RP2040.
Also there is a line PICO_PLATFORM:STRING=rp2040.

When nim c -d:PicoBoard=pico2 blink.nim is ran, PICO_BOARD:STRING=pico2 in cmakeBuildDir/CMakeCache.txt is changed but PICO_PLATFORM:STRING=rp2040 is not changed.
As Raspberry Pi Pico 2 doesn't has RP2040, it fails to build.

When nim c -d:PicoBoard=pico2 -d:PicoPlatform=rp2350-arm-s blink.nim is ran, PICO_BOARD:STRING=pico2 and PICO_BOARD:STRING=pico2 are updated, but CMAKE_C_FLAGS:STRING=-mcpu=cortex-m0plus -mthumb is not.
It should be CMAKE_CXX_FLAGS:STRING=-mcpu=cortex-m33 -mthumb -march=armv8-m.main+fp+dsp -mfloat-abi=softfp -mcmse for RP2350 ARM core.

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

No branches or pull requests

1 participant