arduino-cmake / Arduino-CMake-NG

CMake-Based framework for Arduino platforms
MIT License
138 stars 39 forks source link

upload_arduino_target does not work (avrdude problem?) #69

Open ghost opened 5 years ago

ghost commented 5 years ago

Hello out there,

I am trying to upload my hex file via SPI - having the latest avrdude version and latest Arduino SDK version - sure this looks more like an avrdude problem ... But is there a way to specify an own configuration file for avrdude?

This works like a charme for me - how could I do this as upload target?

avrdude -c linuxspi -p m328p -P /dev/spidev1.0 -v -U flash:w:controller-arduino.hex

I am getting

-- Arduino SDK version 1.8.8: /opt/arduino/arduino-1.8.8
-- Determined Platform Header: /opt/arduino/arduino-1.8.8/hardware/arduino/avr/cores/arduino/Arduino.h
-- Arduino SDK version 1.8.8: /opt/arduino/arduino-1.8.8
-- Determined Platform Header: /opt/arduino/arduino-1.8.8/hardware/arduino/avr/cores/arduino/Arduino.h
-- Arduino SDK version 1.8.8: /opt/arduino/arduino-1.8.8
-- Determined Platform Header: /opt/arduino/arduino-1.8.8/hardware/arduino/avr/cores/arduino/Arduino.h
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/tmp.LL6xRi9W6k/build
[ 86%] Built target nano_atmega328_core_lib
[ 93%] Built target SPI
[ 96%] Linking CXX executable controller-arduino.elf
Generating EEP image
Generating HEX image
Calculating controller-arduino size
Firmware Size: [Program: 1922 bytes 5.9% ] [Data: 184 bytes 9.0% ] on atmega328p
EEPROM Size: [Program: 0 bytes 0.0% ] [Data: 0 bytes 0.0% ] on atmega328p

Uploading controller-arduino target

avrdude: Version 6.1-svn-20130917, compiled on Dec 31 2018 at 14:06:08
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2009 Joerg Wunsch

         System wide configuration file is "/opt/arduino/arduino-1.8.8/hardware/tools/avr/etc/avrdude.conf"
avrdude: syntax error at /opt/arduino/arduino-1.8.8/hardware/tools/avr/etc/avrdude.conf:1095
CMakeFiles/controller-arduino.dir/build.make:86: recipe for target 'controller-arduino.elf' failed
make[2]: *** [controller-arduino.elf] Error 1
make[2]: *** Deleting file 'controller-arduino.elf'
CMakeFiles/Makefile2:73: recipe for target 'CMakeFiles/controller-arduino.dir/all' failed
make[1]: *** [CMakeFiles/controller-arduino.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
cmake_minimum_required(VERSION 3.2)

#set(ARDUINO_SDK_PATH /opt/arduino/arduino-linux-1.8.5)
set(ARDUINO_SDK_PATH /opt/arduino/arduino-1.8.8)

set(CMAKE_TOOLCHAIN_FILE /opt/arduino/Arduino-Toolchain.cmake)
#set(ARDUINO_DEFAULT_PORT /dev/ttyUSB0)  # Default Port, when not specified
#set(ARDUINO_DEFAULT_BOARD pro)          # Default Board ID, when not specified
#
#set(ARDUINO_BOARD_NAME "ProMini3V328")

# fully optimize debug code
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O2")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O2")

set(CMAKE_CXX_FLAGS "-std=c++11")

project(controller-arduino C CXX ASM)

#generate_arduino_firmware(controller-arduino
#        SRCS src/main.cpp include/queue.h
#        include/com.h src/com.cpp
#        include/util.h src/util.cpp
#        include/process.h src/process.cpp
#        include/clock.h src/clock.cpp
#        BOARD mega)
#
get_board_id(board_id nano atmega328)
add_arduino_executable(controller-arduino ${board_id} src/main.cpp)
link_platform_library(controller-arduino SPI ${board_id})

upload_arduino_target(controller-arduino "${board_id}" SPI)
MrPointer commented 5 years ago

Umm I don't know why do you get this error, honestly - Have nothing to say about avrdude as I'm not really familiar with it (nor with the Arduino ecosystem... ironic right?) However, what I can tell from your attached CMakeLists.txt file is that you're doing some things wrong:

At last - Please state your configuration details as requested here.

After doing this we could investigate the issue further.

rileyrg commented 5 years ago

"Your ARDUINO_SDK_PATH shouldn't be set locally in the cmake file,"

Why is this? Doesn't sound right at all. You can set an ENV anywhere including on the cmake line. As a newbie to this (arduino cmake) and completely incapable of getting it working (upload_arduino_target not defined) I need educating. Thank!

MrPointer commented 5 years ago

@rileyrg Hi, I'm afraid you're referring to a completely different issue which is not related to this one. I believe that #77 is the place to talk about it.

maciejbanach commented 5 years ago

In my case I had a problem with avrdude installed from system repository (Ubuntu 18.04), as it was unable to parse configuration included in Arduino SDK:

avrdude: error at /home/user/Apps/arduino-1.8.9/hardware/tools/avr/etc/avrdude.conf:1133: programmer type jtagice3_updi not found

To fix this, I set cmake to use avrdude included in SDK and it uploaded successfully.

set(ARDUINO_CMAKE_AVRDUDE_PROGRAM $ENV{ARDUINO_SDK_PATH}/hardware/tools/avr/bin/avrdude)

@ghost - your's avrdude is older than version provided with sdk (6.1 vs 6.3-20171130) - I suspect that this causes that syntax error.