2

Code works fine when tested on Arduino Uno, (editing delay(x) affects the led), but I get this error and Serial Port Monitor does not show anything.

Error in CLion Event Log is:

Error running Unnamed: Cannot run program "C:\Users\Nikhil Verma\.CLion12\system\cmake\generated\4b320303\4b320303\Debug\summer.elf" (in directory "C:\Users\Nikhil Verma\.CLion12\system\cmake\generated\4b320303\4b320303\Debug"): CreateProcess error=193, %1 is not a valid Win32 application

CMakeLists.txt

cmake_minimum_required(VERSION 2.8.4)
set(CMAKE_TOOLCHAIN_FILE ${CMAKE_SOURCE_DIR}/cmake/ArduinoToolchain.cmake)
set(PROJECT_NAME summer)
project(${PROJECT_NAME})

set(${CMAKE_PROJECT_NAME}_BOARD uno)
set(${CMAKE_PROJECT_NAME}_PORT COM1)
set(${CMAKE_PROJECT_NAME}_SKETCH summer.ino)
generate_arduino_firmware(${CMAKE_PROJECT_NAME})

summer.ino

 #include <Arduino.h>
  void setup() {
    pinMode(13, OUTPUT);
    Serial.begin(9600);
}

void loop() {
    Serial.println("Hi");
    digitalWrite(13, HIGH);
    delay(7000);
    digitalWrite(13, LOW);
    delay(1000);
}

Configuration:

enter image description here

Log of Messaged Build :

"C:\Program Files (x86)\JetBrains\CLion 1.2.4\bin\cmake\bin\cmake.exe" --build "C:\Users\Nikhil Verma\.CLion12\system\cmake\generated\4b320303\4b320303\Debug" --target upload -- -j 8
[ 89%] Built target uno_CORE
[100%] Built target summer

        avrdude.exe: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude.exe: Device signature = 0x1e950f
avrdude.exe: reading input file "C:/Users/Nikhil Verma/.CLion12/system/cmake/generated/4b320303/4b320303/Debug/summer.hex"
avrdude.exe: writing flash (2370 bytes):

Writing | ################################################## | 100% 0.54s

avrdude.exe: 2370 bytes of flash written
avrdude.exe: reading input file "C:/Users/Nikhil Verma/.CLion12/system/cmake/generated/4b320303/4b320303/Debug/summer.eep"
avrdude.exe: writing eeprom (0 bytes):

Writing | ################################################## | 100% -0.00s

avrdude.exe: 0 bytes of eeprom written

avrdude.exe done.  Thank you.

[100%] Built target summer-upload
[100%] Built target upload

"C:\Program Files (x86)\JetBrains\CLion 1.2.4\bin\cmake\bin\cmake.exe" --build "C:\Users\Nikhil Verma\.CLion12\system\cmake\generated\4b320303\4b320303\Debug" --target summer -- -j 8
[ 89%] Built target uno_CORE
[100%] Built target summer

CMake Toolchain:

enter image description here

Thanks.

Nikhil Verma
  • 1,777
  • 1
  • 20
  • 41

2 Answers2

3

I had the same issue. The solution was to not click on the run (green play) button, but to click on build on the top right to run upload.

AKJ
  • 950
  • 2
  • 13
  • 18
1

Apparently you have enabled the Debug configuration in your tool, and your tool is trying to execute the Arduino Binary directly on your machine:

Error running Unnamed: Cannot run program "C:\Users\Nikhil Verma\.CLion12\system\cmake\generated\4b320303\4b320303\Debug\summer.elf" (in directory "C:\Users\Nikhil Verma\.CLion12\system\cmake\generated\4b320303\4b320303\Debug"): CreateProcess error=193, %1 is not a valid Win32 application

I suggest you to modify your IDE configuration to skip this step, and upload the code to the device instead.

EDIT: I use this approach for setting up the Makefile of all my projects, though since you are on Windows the configuration might change.

Patrick Trentin
  • 7,126
  • 3
  • 23
  • 40