CLionArduinoPlugin icon indicating copy to clipboard operation
CLionArduinoPlugin copied to clipboard

-mmcu not set properly when using Arduino Nano

Open TheAssassin opened this issue 6 years ago • 6 comments

I created a new project for the Nano. It seems like some variable was not initialized properly, as -mmcu= didn't receive a value. To resolve the issue, I quickly patched two places in Arduino.cmake as follows:

- set(COMPILE_FLAGS "${COMPILE_FLAGS} -DARDUINO=${ARDUINO_VERSION_DEFINE} -DARDUINO_${${BOARD_ID}.build.board} -DARDUINO_ARCH_AVR -mmcu=${${BOARD_ID}${ARDUINO_CPUMENU}.build.mcu}")
+ set(COMPILE_FLAGS "${COMPILE_FLAGS} -DARDUINO=${ARDUINO_VERSION_DEFINE} -DARDUINO_${${BOARD_ID}.build.board} -DARDUINO_ARCH_AVR -mmcu=atmega328p")
- set(LINK_FLAGS "-mmcu=${${BOARD_ID}${ARDUINO_CPUMENU}.build.mcu}")
+ set(LINK_FLAGS "-mmcu=atmega328p")

Not sure if it's an issue in your plugin (as in, doesn't set the right variable, e.g., due a typo), or rather Arduino.cmake.

TheAssassin avatar Jan 30 '19 18:01 TheAssassin

I think this is related to #7 I will revisit the code to validate initialization.

vsch avatar Feb 05 '19 23:02 vsch

Still hit by this issue.

CLion CMake log ends in:

Problems were encountered while collecting compiler information:
	avr-g++: error: missing device or architecture after '-mmcu='
	avr-gcc: error: missing device or architecture after '-mmcu='
	avr-g++: error: missing device or architecture after '-mmcu='

Build log aborts due to:

avr-g++: error: missing device or architecture after '-mmcu='

TheAssassin avatar Jan 31 '20 21:01 TheAssassin

Did you select cpu when create project?

In CMakeLists.txt file you must have for example:

set(${PROJECT_NAME}_BOARD nano) set(ARDUINO_CPU atmega328)

and all working OK.

Most of adrunio boards can use more than one cpu type, usually ATmega328, ATMega168, etc.

JedrzejczykRobert avatar Jan 31 '20 21:01 JedrzejczykRobert

Yep, chose (well, not really, it's the default) ATmega328 (old bootloader).

screenshot_2020-02-01_00-08-28

TheAssassin avatar Jan 31 '20 23:01 TheAssassin

I have such errors only if I don't choose CPU. Please check your CMakeLists.txt for:

set(${PROJECT_NAME}_BOARD nano) set(ARDUINO_CPU atmega328old) project(${PROJECT_NAME})

I use Win 10 + Arduino 1.8.10 + Clion 2019.3 + Arduino Plugin 1.5.2

JedrzejczykRobert avatar Feb 01 '20 04:02 JedrzejczykRobert

@TheAssassin Receipt for ubuntu below. In my case IDE stuck with 2 versions of arduino. I installed old one via apt-get and got error with 'mmcu' as above. I uninstalled it and removed folder /usr/shared/andruino at all. After removing, I got errors about ARDUINO_SDK_PATH and Board Id (nano). After long Investigation both errors disappeared if ARDUINO_SDK_PATH sets as absolute path set(ARDUINO_SDK_PATH "/home/some/path/adruino/ide") in ArduinoToolchain.cmake. Here folder '/ide' contains files downloaded from https://arduino.cc. If something goes wrong clear CMakeCache.txt until Cmake builds successful.

And after all above, select YOUR_PROJECT-upload setting from menu and build it.

ps: also, all paths to arduino in CMakeCache.txt stated as not found and I don't know why:

ARDUINO_BOOTLOADERS_PATH:FILEPATH=ARDUINO_BOOTLOADERS_PATH-NOTFOUND

Hope this helps.

dkchv avatar Feb 05 '20 23:02 dkchv