sudar / Arduino-Makefile

Makefile for Arduino sketches. It defines the workflows for compiling code, flashing it to Arduino and even communicating through Serial.
http://hardwarefun.com/tutorials/compiling-arduino-sketches-using-makefile
GNU Lesser General Public License v2.1
2.02k stars 448 forks source link

Add support for Arduino 1.5 #45

Closed sudar closed 9 years ago

sudar commented 11 years ago

Arduino 1.5 has changed the directory structure.

Add an option to specify (or auto detect) Arduino version and then based on that change the directory paths.

Changes should be compatible with 1.0.x version of Arduino as well.

sudar commented 11 years ago

Soon, development in Arduino 1.0.x branch will stop and Arduino 1.5.x branch will come out of beta. https://groups.google.com/a/arduino.cc/d/msg/developers/KeFMqEDu4jA/j-m7WZivlaAJ

I quickly had a look to see what all changed in Arduino 1.5.x

I am thinking of creating a new branch to start development for 1.5.x. Once it becomes stable, we can merge it back to master.

sudar commented 11 years ago

Also, boards.txt can be present inside a submenu. This should be supported as well. See https://github.com/xxxajk/Arduino_Makefile_master/pull/2

xxxajk commented 11 years ago

Yes, I did an unclean fork. I also now auto detect libraries. :-) Please feel free to pull bits from mine.

sudar commented 11 years ago

@xxxajk I saw your repo the other day and made a note to steal code from you for library detection ;)

Jokes apart, would you be interested in merging both our repos?

xxxajk commented 11 years ago

Certainly, as long as my projects, and others still compile. But before we merge anything, I need to make the include scanner just a touch smarter. -- Meaning that I need to look at what the java code is doing. Currently what I do is a real lousy hack. On Oct 25, 2013 5:26 AM, "Sudar" notifications@github.com wrote:

@xxxajk https://github.com/xxxajk I saw your repo the other day and made a note to steal code from you for library detection ;)

Jokes apart, would you be interested in merging both our repos?

— Reply to this email directly or view it on GitHubhttps://github.com/sudar/Arduino-Makefile/issues/45#issuecomment-27076613 .

xxxajk commented 11 years ago

You are now welcome to check out what is new. I will be adding support for the Teensy series from pjrc.com very soon, hopefully today. You are (of course) welcome to pull in the bits from that as well, and do with them as you please. As far as merging the two, I don't see that as really possible because of the vast differences in installation and use. For one, my version does not depend on knowing where you sketchbook is located. It does not need to know, because it expect that you have all the needed bits in ../libraries. This allows for independent trees for various boards and private trees automatically. I am considering, however to do a scan of where Arduino IDE WOULD look between the current search and the Arduino home directories searches. Another thing that is really needed is to gather this information more logically by doing a normal dependency gathering via the C Pre Processor, this way, nothing not needed is not compiled, and includes that won't be seen in the include path, won't be included in the path. That will increase compile speeds. Still, one feature at a time :-)

sudar commented 11 years ago

You are now welcome to check out what is new. I will be adding support for the Teensy series from pjrc.com very soon, hopefully today. You are (of course) welcome to pull in the bits from that as well, and do with them as you please.

Sure will do that, as soon as I get some free time.

As far as merging the two, I don't see that as really possible because of the vast differences in installation and use.

After your last comment, I was wondering the same. May be it is too much work to merge them right now. But if at all at any point you wish to merge them, I would be happy to help out.

Meanwhile, I will be looking into your makefile to grab the code that works for Arduino 1.5.x branch :)

schmurfy commented 10 years ago

is there currently a branch somewhere which works with latest ide ? I just got a yun so I need the latest library which killed my current setup (inotool) :/

sudar commented 10 years ago

@schmurfy unfortunately, we don't have any code that is compatible with Arduino 1.5.x yet

sej7278 commented 10 years ago

just seen ide 1.5.6 go into debian unstable..... ah no its a mistake

do we know the basic 1.5 changes - from a quick glance it seems to be that the hardware directory is split into avr and sam, making the paths to bootloaders, variants, boards.txt different. boards.txt has what looks like cosmetic changes, preferences.txt is pretty different.....

sudar commented 10 years ago

@sej7278 Those are pretty much the important changes.

Also if we decide to support sam based boards, then we might have to provide a way to detect the proper compiler based on the architecture.

xxxajk commented 10 years ago

You may want to look at the additions made to mine for support. Ours already does it. On Apr 2, 2014 12:31 AM, "Sudar" notifications@github.com wrote:

@sej7278 https://github.com/sej7278 Those are pretty much the important changes.

Also if we decide to support sam based boards, then we might have to provide a way to detect the proper compiler based on the architecture.

— Reply to this email directly or view it on GitHubhttps://github.com/sudar/Arduino-Makefile/issues/45#issuecomment-39287941 .

schmurfy commented 10 years ago

I ended up making my own build script, one thing I noticed was how horrible the boards.txt was to parse xD

xxxajk commented 10 years ago

Easy to use sed, it is just java properties. On Apr 2, 2014 3:50 AM, "Julien Ammous" notifications@github.com wrote:

I ended up making my own build script, one thing I noticed was how horrible the boards.txt was to parse xD

— Reply to this email directly or view it on GitHubhttps://github.com/sudar/Arduino-Makefile/issues/45#issuecomment-39297397 .

schmurfy commented 10 years ago

yeah but the structure is pretty stupid with those .menu. items.

sej7278 commented 10 years ago

@schmurfy you can just use split() on '=' to make a nice array.

or awk:

awk -F= {'print $1'} /usr/share/arduino/hardware/arduino/boards.txt

or grep like we do in the makefile:

grep -v "^\#" boards.txt | grep leonardo.upload.speed | cut -d = -f 2

oh yes the new splitting of cpu/board into menu's is pretty naff as they're kind of defining how the gui looks within boards.txt, assuming people are using the IDE....

@xxxajk is that it? surely there's more to it? although that's not backwards-compatible with 1.0 is it - or is that worked around by defining THIRD_PARTY_HARDWARE and/or ARD_HOME?

sej7278 commented 10 years ago

I've just made a quick'n'dirty 1.5 proof-of-concept branch which just inserts the architecture anywhere the hardware folder is referenced. its not a full-blown build but it does work unmodified with 1.0.5 and only requires a single variable in the Makefile to build on 1.5.6, so its not going to be too hard to implement.

References: library spec / hardware spec

sudar commented 10 years ago

Wow!! this is definitely a great start :)

sej7278 commented 10 years ago

i've added a few more commits including one that replaces hardcoded "arduino" wit a $VENDOR variable,

i think we're going to have to replace the ALTERNATE_CORES routines though, as its kind of built into 1.5 with build.core etc.

sudar commented 10 years ago

@sej7278 While it is desirable to have support for both 1.0.x and 1.5.x in the same branch/release, I am even open to having separate branch/release, if it proves to be too much work to make them compatible.

But I will leave the decision to you.

sej7278 commented 10 years ago

yes, we'll see how it goes. you can't have 2 versions of the ide installed at the same time so it wouldn't hurt to split the makefile into 2 versions.

it certainly needs a different git branch, so we can continue with the odd patch to 1.3.3

my branch is just a test really, but if you want i can make a pull request if you create a branch to pull it into

sudar commented 10 years ago

you can't have 2 versions of the ide installed at the same time so it wouldn't hurt to split the makefile into 2 versions.

Actually we can run two versions of the IDE, at least in mac and linux :) I downloaded both the IDE's as zip files (not the installed) and extracted them into different folders. I change the PATH variable based on which version of the IDE I want to work with.

it certainly needs a different git branch, so we can continue with the odd patch to 1.3.3

I agree.

my branch is just a test really, but if you want i can make a pull request if you create a branch to pull it into

Let's wait a little more till your branch is slightly stable. After that I can pull in all your changes as a separate branch and maintain it till we merge it back to master.

Boobies commented 10 years ago

Here's what happened when I tried to make blink from @sej7278's repo:

Bogdan@Uranus ~/Arduino-Makefile/examples/blink
$ make ARDUINO_DIR=~/Arduino ARCHITECTURE=avr
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = WINDOWS
- [COMPUTED]           ARDMK_DIR = /home/Bogdan/Arduino-Makefile (relative to Common.mk)
- [USER]               ARDUINO_DIR = /home/Bogdan/Arduino
- [AUTODETECTED]       ARDUINO_VERSION = 156
- [USER]               ARCHITECTURE = avr
- [DEFAULT]            VENDOR = arduino
- [DEFAULT]            ARDUINO_SKETCHBOOK = /home/Bogdan/sketchbook
- [BUNDLED]            AVR_TOOLS_DIR = /home/Bogdan/Arduino/hardware/tools/avr (in Arduino distribution)
- [COMPUTED]           ARDUINO_LIB_PATH = /home/Bogdan/Arduino/libraries (from ARDUINO_DIR)
- [DEFAULT]            ARDUINO_CORE_PATH = /home/Bogdan/Arduino/hardware/arduino/avr/cores/arduino
- [COMPUTED]           ARDUINO_VAR_PATH = /home/Bogdan/Arduino/hardware/arduino/avr/variants (from ARDUINO_DIR)
- [COMPUTED]           BOARDS_TXT = /home/Bogdan/Arduino/hardware/arduino/avr/boards.txt (from ARDUINO_DIR)
- [DEFAULT]            USER_LIB_PATH = /home/Bogdan/sketchbook/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh
- [USER]               BOARD_TAG = uno
- [COMPUTED]           OBJDIR = build-uno (from BOARD_TAG)
- [ASSUMED]            MONITOR_BAUDRATE = 9600
- [DEFAULT]            OPTIMIZATION_LEVEL = s
- [DEFAULT]            MCU_FLAG_NAME = mmcu
- [DEFAULT]            CFLAGS_STD = -std=gnu99
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [COMPUTED]           BOOTLOADER_PARENT = /home/Bogdan/Arduino/hardware/arduino/avr/bootloaders (from ARDUINO_DIR)
-------------------------
mkdir -p build-uno
/home/Bogdan/Arduino/hardware/tools/avr/bin/avr-g++ -x c++ -include Arduino.h -MMD -c -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=156 -D__PROG_TYPES_COMPAT__ -I. -I/home/Bogdan/Arduino/hardware/arduino/avr/cores/arduino -I/home/Bogdan/Arduino/hardware/arduino/avr/variants/standard   -Wall -ffunction-sections -fdata-sections -Os -fno-exceptions   Blink.ino -o build-uno/Blink.o
cc1plus.exe: error: Arduino.h: No such file or directory
Blink.ino: In function 'void setup()':
Blink.ino:11: error: 'OUTPUT' was not declared in this scope
Blink.ino:11: error: 'pinMode' was not declared in this scope
Blink.ino: In function 'void loop()':
Blink.ino:15: error: 'HIGH' was not declared in this scope
Blink.ino:15: error: 'digitalWrite' was not declared in this scope
Blink.ino:16: error: 'delay' was not declared in this scope
Blink.ino:17: error: 'LOW' was not declared in this scope
../../Arduino.mk:1012: recipe for target 'build-uno/Blink.o' failed
make: *** [build-uno/Blink.o] Error 1
sej7278 commented 10 years ago

ah, according to #94 (and README.md !) you need to use a relative path for ARDUINO_DIR on cygwin, i guess something like ARDUINO_DIR=Arduino would work...?

Boobies commented 10 years ago

It did. :)

sej7278 commented 10 years ago

brilliant, so now we know the 1.5 branch also works on windows, to the same degree as linux anyway. could you post your results back if you do something more advanced with 1.5, e.g. use some libraries or an arm chip?

i've raised issue #201 to add a check for a relative ARDUINO_DIR on windows.

Boobies commented 10 years ago

Well, I tried building one of my projects from scratch, using two libraries (NewPing and Jeelib, the latter being rather big), and the building process has succeeded, although I didn't yet get around to actually uploading it to a board (hopefully, everything got compiled and linked).

Unfortunately, I don't have access to any ARM-based Arduino boards. I expect I will do more exhaustive testing tonight and during the following day.

sej7278 commented 10 years ago

ok great, i also merged in the windows check for ARDUINO_DIR being relative, so worth git pull'ing my repo again to update it.

jeelib works well with arduino 1.0.5 / makefile 1.3.3 despite being big, not tried 1.5.6 though

sej7278 commented 10 years ago

"menu" boards don't work yet

sej7278 commented 10 years ago

menu boards should work now

sudar commented 10 years ago

menu boards should work now

Wow!! cool :)

Boobies commented 10 years ago

Well, maybe, but now it looks for boards.txt in the old directory. (Yes, I tried the right branch of Arduino-Makefile.)

sej7278 commented 10 years ago

@Boobies - you sure you did a git pull today? where's your makefile and error message? you still using windoze (that may not like double slashes)?

you don't have to define ARCHITECTURE unless you're using sam, or VENDOR unless you're using someone other than arduino, and you shouldn't define either if you're using arduino 1.0.5

works fine for me:

$ cat Makefile 
BOARD_TAG  = diecimila
BOARD_SUB  = atmega168

include /home/simon/arduino-mk/my_git/Arduino-Makefile/Arduino.mk

$ make
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = LINUX 
- [COMPUTED]           ARDMK_DIR = /home/simon/arduino-mk/my_git/Arduino-Makefile (relative to Common.mk)
- [AUTODETECTED]       ARDUINO_DIR = /usr/share/arduino 
- [AUTODETECTED]       ARDUINO_VERSION = 156 
- [DEFAULT]            ARCHITECTURE = avr 
- [DEFAULT]            VENDOR = arduino 
- [DEFAULT]            ARDUINO_SKETCHBOOK = /home/simon/sketchbook 
- [BUNDLED]            AVR_TOOLS_DIR = /usr/share/arduino/hardware/tools/avr (in Arduino distribution)
- [COMPUTED]           ARDUINO_LIB_PATH = /usr/share/arduino/libraries (from ARDUINO_DIR)
- [DEFAULT]            ARDUINO_CORE_PATH = /usr/share/arduino/hardware/arduino/avr/cores/arduino 
- [COMPUTED]           ARDUINO_VAR_PATH = /usr/share/arduino/hardware/arduino/avr/variants (from ARDUINO_DIR)
- [COMPUTED]           BOARDS_TXT = /usr/share/arduino/hardware/arduino/avr/boards.txt (from ARDUINO_DIR)
- [DEFAULT]            USER_LIB_PATH = /home/simon/sketchbook/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh 
- [USER]               BOARD_SUB = atmega168 
- [USER]               BOARD_TAG = diecimila 
- [COMPUTED]           OBJDIR = build-diecimila (from BOARD_TAG)
- [ASSUMED]            MONITOR_BAUDRATE = 9600 
- [DEFAULT]            OPTIMIZATION_LEVEL = s 
- [DEFAULT]            MCU_FLAG_NAME = mmcu 
- [DEFAULT]            CFLAGS_STD = -std=gnu99 
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [COMPUTED]           BOOTLOADER_PARENT = /usr/share/arduino/hardware/arduino/avr/bootloaders (from ARDUINO_DIR)
$ cat Makefile 
BOARD_TAG = leonardo
MONITOR_PORT = /dev/ttyACM0

include /data3/useful_software/arduino/arduino-mk/my_git/Arduino-Makefile/Arduino.mk

$ make
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = LINUX 
- [COMPUTED]           ARDMK_DIR = /data3/useful_software/arduino/arduino-mk/my_git/Arduino-Makefile (relative to Common.mk)
- [AUTODETECTED]       ARDUINO_DIR = /usr/share/arduino 
- [AUTODETECTED]       ARDUINO_VERSION = 105 
- [DEFAULT]            ARCHITECTURE =  
- [DEFAULT]            VENDOR = arduino 
- [AUTODETECTED]       ARDUINO_PREFERENCES_PATH = /home/simon/.arduino/preferences.txt 
- [AUTODETECTED]       ARDUINO_SKETCHBOOK = /home/simon/programming/c++/arduino (from arduino preferences file)
- [BUNDLED]            AVR_TOOLS_DIR = /usr/share/arduino/hardware/tools/avr (in Arduino distribution)
- [COMPUTED]           ARDUINO_LIB_PATH = /usr/share/arduino/libraries (from ARDUINO_DIR)
- [DEFAULT]            ARDUINO_CORE_PATH = /usr/share/arduino/hardware/arduino//cores/arduino 
- [COMPUTED]           ARDUINO_VAR_PATH = /usr/share/arduino/hardware/arduino//variants (from ARDUINO_DIR)
- [COMPUTED]           BOARDS_TXT = /usr/share/arduino/hardware/arduino//boards.txt (from ARDUINO_DIR)
- [DEFAULT]            USER_LIB_PATH = /home/simon/programming/c++/arduino/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh 
- [USER]               BOARD_TAG = leonardo 
- [COMPUTED]           OBJDIR = build-leonardo (from BOARD_TAG)
- [ASSUMED]            MONITOR_BAUDRATE = 9600 
- [DEFAULT]            OPTIMIZATION_LEVEL = s 
- [DEFAULT]            MCU_FLAG_NAME = mmcu 
- [DEFAULT]            CFLAGS_STD = -std=gnu99 
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [COMPUTED]           BOOTLOADER_PARENT = /usr/share/arduino/hardware/arduino//bootloaders (from ARDUINO_DIR)
$ make show_boards
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = LINUX 
- [COMPUTED]           ARDMK_DIR = /home/simon/arduino-mk/my_git/Arduino-Makefile (relative to Common.mk)
- [AUTODETECTED]       ARDUINO_DIR = /usr/share/arduino 
- [AUTODETECTED]       ARDUINO_VERSION = 156 
- [DEFAULT]            ARCHITECTURE = avr 
- [DEFAULT]            VENDOR = arduino 
- [DEFAULT]            ARDUINO_SKETCHBOOK = /home/simon/sketchbook 
- [BUNDLED]            AVR_TOOLS_DIR = /usr/share/arduino/hardware/tools/avr (in Arduino distribution)
- [COMPUTED]           ARDUINO_LIB_PATH = /usr/share/arduino/libraries (from ARDUINO_DIR)
- [DEFAULT]            ARDUINO_CORE_PATH = /usr/share/arduino/hardware/arduino/avr/cores/arduino 
- [COMPUTED]           ARDUINO_VAR_PATH = /usr/share/arduino/hardware/arduino/avr/variants (from ARDUINO_DIR)
- [COMPUTED]           BOARDS_TXT = /usr/share/arduino/hardware/arduino/avr/boards.txt (from ARDUINO_DIR)
- [DEFAULT]            USER_LIB_PATH = /home/simon/sketchbook/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh 
- [USER]               BOARD_TAG = leonardo 
- [COMPUTED]           OBJDIR = build-leonardo (from BOARD_TAG)
- [DETECTED]           MONITOR_BAUDRATE = 38400  (in sketch)
- [DEFAULT]            OPTIMIZATION_LEVEL = s 
- [DEFAULT]            MCU_FLAG_NAME = mmcu 
- [DEFAULT]            CFLAGS_STD = -std=gnu99 
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [COMPUTED]           BOOTLOADER_PARENT = /usr/share/arduino/hardware/arduino/avr/bootloaders (from ARDUINO_DIR)
-------------------------
atmegang      Arduino NG or older
bt            Arduino BT
diecimila     Arduino Duemilanove or Diecimila
esplora       Arduino Esplora
ethernet      Arduino Ethernet
fio           Arduino Fio
leonardo      Arduino Leonardo
lilypad       LilyPad Arduino
LilyPadUSB    LilyPad Arduino USB
megaADK       Arduino Mega ADK
mega          Arduino Mega or Mega 2560
micro         Arduino Micro
mini          Arduino Mini
nano          Arduino Nano
pro           Arduino Pro or Pro Mini
robotControl  Arduino Robot Control
robotMotor    Arduino Robot Motor
uno           Arduino Uno
yun           Arduino Yún

interestingly enough, it looks like the arduino guys still need to do some work on the leonardo/promicro bootloader to get it to build on a gcc 4.7 system (pgmspace etc.) i guess in 1.5.6 they're still bundling that ancient gcc 4.3

ohh, they seem to have deprecated bootloader.path too, that is going to be a problem. as bootloader.file has changed syntax to include the bootloader.path e.g. what was:

BOOTLOADER_PATH   = caterina
BOOTLOADER_FILE   = Caterina-promicro16.hex

is now

BOOTLOADER_FILE   = caterina/Caterina-promicro16.hex
sej7278 commented 10 years ago

removing bootloader.path meant that caterina detection no longer worked, that's fixed now as i'm also looking in bootloader.file oh and also menu.cpu.blah.bootloader.file (ffs!)

Boobies commented 10 years ago

According to Github, your last commit was 5 days ago. I just downloaded the ZIP that Github has to offer---I don't really use git anymore. Even so, it's still strange since your branch did use to work for me. I believe something got screwed up when you did your relative path fix for Windows. Anyway, here's what I get when trying to build the Blink example (pay attention to where it's trying to look for boards.txt):

Bogdan@Uranus ~/arduino-makefile/examples/blink
$ make ARDUINO_DIR=../../../Arduino
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = WINDOWS
- [COMPUTED]           ARDMK_DIR = /cygdrive/d/muscle-online/Arduino-Makefile (relative to Common.mk)
- [USER]               ARDUINO_DIR = ../../../Arduino
- [AUTODETECTED]       ARDUINO_VERSION = 156
- [DEFAULT]            ARDUINO_SKETCHBOOK = /home/Bogdan/sketchbook
- [BUNDLED]            AVR_TOOLS_DIR = ../../../Arduino/hardware/tools/avr (in Arduino distribution)
- [COMPUTED]           ARDUINO_LIB_PATH = ../../../Arduino/libraries (from ARDUINO_DIR)
- [DEFAULT]            ARDUINO_CORE_PATH = ../../../Arduino/hardware/arduino/cores/arduino
- [COMPUTED]           ARDUINO_VAR_PATH = ../../../Arduino/hardware/arduino/variants (from ARDUINO_DIR)
- [COMPUTED]           BOARDS_TXT = ../../../Arduino/hardware/arduino/boards.txt (from ARDUINO_DIR)
- [DEFAULT]            USER_LIB_PATH = /home/Bogdan/sketchbook/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh
- [USER]               BOARD_TAG = uno
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
- [COMPUTED]           OBJDIR = build-uno (from BOARD_TAG)
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
- [ASSUMED]            MONITOR_BAUDRATE = 9600
- [DEFAULT]            OPTIMIZATION_LEVEL = s
- [DEFAULT]            MCU_FLAG_NAME = mmcu
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
- [DEFAULT]            CFLAGS_STD = -std=gnu99
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [COMPUTED]           BOOTLOADER_PARENT = ../../../Arduino/hardware/arduino/bootloaders (from ARDUINO_DIR)
-------------------------
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
mkdir -p build-uno
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
grep: ../../../Arduino/hardware/arduino/boards.txt: No such file or directory
../../../Arduino/hardware/tools/avr/bin/avr-g++ -x c++ -include Arduino.h -MMD -c -mmcu= -DF_CPU= -DARDUINO=156 -D__PROG_TYPES_COMPAT__ -I. -I../../../Arduino/hardware/arduino/cores/arduino -I../../../Arduino/hardware/arduino/variants/   -Wall -ffunction-sections -fdata-sections -Os -fno-exceptions   Blink.ino -o build-uno/Blink.o
cc1plus.exe: error: missing argument to "-mmcu="
../../Arduino.mk:994: recipe for target 'build-uno/Blink.o' failed
make: *** [build-uno/Blink.o] Error 1
sej7278 commented 10 years ago

@Boobies it looks like you're running arduino 1.5.6 with the 1.3.3 makefile again, that's not the output from my 1.5 branch which i updated two hours ago.

please check what you're doing before reporting bugs.

@sudar starting to think we should output the arduino-mk version in the build details, and maybe a check for arduino >= 1.5 with error message

Boobies commented 10 years ago

Jeez. I finally updated my bookmark. Sorry, long day. Menu boards don't work for this branch under Cygwin either. And neither does the new show_boards seem to be merged.

Bogdan@Uranus ~/arduino-makefile/src/device
$ make
-------------------------
Arduino.mk Configuration:
- [AUTODETECTED]       CURRENT_OS = WINDOWS
- [COMPUTED]           ARDMK_DIR = /cygdrive/d/muscle-online/Arduino-Makefile (relative to Common.mk)
- [USER]               ARDUINO_DIR = ../../../Arduino
- [AUTODETECTED]       ARDUINO_VERSION = 156
- [DEFAULT]            ARCHITECTURE = avr
- [DEFAULT]            VENDOR = arduino
- [DEFAULT]            ARDUINO_SKETCHBOOK = /home/Bogdan/sketchbook
- [BUNDLED]            AVR_TOOLS_DIR = ../../../Arduino/hardware/tools/avr (in Arduino distribution)
- [COMPUTED]           ARDUINO_LIB_PATH = ../../../Arduino/libraries (from ARDUINO_DIR)
- [DEFAULT]            ARDUINO_CORE_PATH = ../../../Arduino/hardware/arduino/avr/cores/arduino
- [COMPUTED]           ARDUINO_VAR_PATH = ../../../Arduino/hardware/arduino/avr/variants (from ARDUINO_DIR)
- [COMPUTED]           BOARDS_TXT = ../../../Arduino/hardware/arduino/avr/boards.txt (from ARDUINO_DIR)
- [DEFAULT]            USER_LIB_PATH = /home/Bogdan/sketchbook/libraries (in user sketchbook)
- [DEFAULT]            PRE_BUILD_HOOK = pre-build-hook.sh
- [USER]               BOARD_TAG = pro5v328
- [COMPUTED]           OBJDIR = build-pro5v328 (from BOARD_TAG)
- [ASSUMED]            MONITOR_BAUDRATE = 9600
- [DEFAULT]            OPTIMIZATION_LEVEL = s
- [DEFAULT]            MCU_FLAG_NAME = mmcu
- [DEFAULT]            CFLAGS_STD = -std=gnu99
- [AUTODETECTED]       Size utility: AVR-aware for enhanced output
- [COMPUTED]           BOOTLOADER_PARENT = ../../../Arduino/hardware/arduino/avr/bootloaders (from ARDUINO_DIR)
-------------------------
mkdir -p build-pro5v328
../../../Arduino/hardware/tools/avr/bin/avr-g++ -x c++ -include Arduino.h -MMD -c -mmcu= -DF_CPU= -DARDUINO=156 -D__PROG_TYPES_COMPAT__ -I. -I../../../Arduino/hardware/arduino/avr/cores/arduino -I../../../Arduino/hardware/arduino/avr/variants/   -Wall -ffunction-sections -fdata-sections -Os -fno-exceptions   device.ino -o build-pro5v328/device.o
cc1plus.exe: error: missing argument to "-mmcu="
../../Arduino.mk:1067: recipe for target 'build-pro5v328/device.o' failed
make: *** [build-pro5v328/device.o] Error 1
sej7278 commented 10 years ago

@Boobies looks like you're using a custom core as there's no such thing as a pro5v328 in arduino 1.5.6 boards.txt, that's why its failing, and that's why its not in make show_boards as it doesn't exist.

ah, perhaps you mean pro.menu.cpu.16MHzatmega328=ATmega328 (5V, 16 MHz) ? in which case you need to set:

BOARD_TAG=pro
BOARD_SUB=16MHzatmega328

you've got to understand that none of these features will be merged in sudar's main branch, its all just in my 1.5 branch at the moment.

sej7278 commented 10 years ago

some notes on this parsing boards.txt

this gets all 1.0-style boards/names, plus any 1.5 boards/subs/cpu names, but not the 1.5-style commented names:

(echo 'BOARD_TAG:BOARD_SUB:NAME' ; cat /usr/share/arduino/hardware/arduino/avr/boards.txt \
/usr/share/arduino/hardware/arduino/sam/boards.txt| \
grep -E '^[a-zA-Z0-9_]+(.name|.menu.cpu.[a-zA-Z0-9_]+)=' |sort -uf | \
sed 's/.menu.cpu./:/;s/.name/: :/;s/=/:/') | column -s: -t

BOARD_TAG          BOARD_SUB       NAME
arduino_due_x_dbg                  Arduino Due (Programming Port)
arduino_due_x                      Arduino Due (Native USB Port)
atmegang           atmega168       ATmega168
atmegang           atmega8         ATmega8
atmegang                           Arduino NG or older
bt                 atmega168       ATmega168
bt                 atmega328       ATmega328
bt                                 Arduino BT
diecimila          atmega168       ATmega168
diecimila          atmega328       ATmega328
diecimila                          Arduino Duemilanove or Diecimila
esplora                            Arduino Esplora
ethernet                           Arduino Ethernet
fio                                Arduino Fio
leonardo                           Arduino Leonardo
lilypad            atmega168       ATmega168
lilypad            atmega328       ATmega328
lilypad                            LilyPad Arduino
LilyPadUSB                         LilyPad Arduino USB
megaADK                            Arduino Mega ADK
mega               atmega1280      ATmega1280
mega               atmega2560      ATmega2560 (Mega 2560)
mega                               Arduino Mega or Mega 2560
micro                              Arduino Micro
mini               atmega168       ATmega168
mini               atmega328       ATmega328
mini                               Arduino Mini
nano               atmega168       ATmega168
nano               atmega328       ATmega328
nano                               Arduino Nano
pro                16MHzatmega168  ATmega168 (5V, 16 MHz)
pro                16MHzatmega328  ATmega328 (5V, 16 MHz)
pro                8MHzatmega168   ATmega168 (3.3V, 8 MHz)
pro                8MHzatmega328   ATmega328 (3.3V, 8 MHz)
pro                                Arduino Pro or Pro Mini
robotControl                       Arduino Robot Control
robotMotor                         Arduino Robot Motor
uno                                Arduino Uno
yun                                Arduino Yún

get all commented names from 1.5:

grep '## [^-]' /usr/share/arduino/hardware/arduino/avr/boards.txt | sort -uf

## Arduino BT w/ ATmega168
## Arduino BT w/ ATmega328
## Arduino Duemilanove or Diecimila w/ ATmega168
## Arduino Duemilanove or Diecimila w/ ATmega328
## Arduino Mega w/ ATmega1280
## Arduino Mega w/ ATmega2560
## Arduino Mini w/ ATmega168
## Arduino Mini w/ ATmega328
## Arduino Nano w/ ATmega168
## Arduino Nano w/ ATmega328
## Arduino NG or older w/ ATmega168
## Arduino NG or older w/ ATmega8
## Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega168
## Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328
## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega168
## Arduino Pro or Pro Mini (5V, 16 MHz) w/ ATmega328
## LilyPad Arduino w/ ATmega168
## LilyPad Arduino w/ ATmega328

so we need to substitute these commented names into the 3rd column above instead of the cpu names

cmalek commented 10 years ago

Thank you for writing this package! I'm excited to try to start using it.

Are the changes for Arduino 1.5.x merged into master currently, or is there a branch available to pull from? I've got Arduino-1.5.6-rc2 installed on my OS X Mavericks machine and the Makefile bombs trying to locate header files for the built in Servo library.

The Makefile is generates the avr-g++ line like so:

opt/local/bin/avr-g++ -MMD -c -I/opt/local/include -I/opt/local/include/sasl -I/opt/X11/include -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=156 -D__PROG_TYPES_COMPAT__ -I. -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/avr/variants/standard -I/Applications/Arduino.app/Contents/Resources/Java/libraries/Servo -I/Users/cmalek/src/robotics/libraries/ObstacleAvoider/lib/Bounce2 -I/Users/cmalek/src/robotics/libraries/ObstacleAvoider/lib/NewPing -I/Users/cmalek/src/robotics/libraries/ObstacleAvoider/lib/Rolley -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 ObstacleAvoider.cpp -o /Users/cmalek/src/robotics/libraries/ObstacleAvoider/bin/uno/ObstacleAvoider/ObstacleAvoider.o

expecting Servo.h to be in /Applications/Arduino.app/Contents/Resources/Java/libraries/Servo when in fact it is now in /Applications/Arduino.app/Contents/Resources/Java/libraries/Servo/src.

I fixed that in Arduino.mk only to get:

/opt/local/bin/avr-g++ -MMD -c -I/opt/local/include -I/opt/local/include/sasl -I/opt/X11/include -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=156 -D__PROG_TYPES_COMPAT__ -I. -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/avr/variants/standard -I/Applications/Arduino.app/Contents/Resources/Java/libraries/Servo/src -I/Users/cmalek/src/robotics/libraries/ObstacleAvoider/lib/Bounce2 -I/Users/cmalek/src/robotics/libraries/ObstacleAvoider/lib/NewPing -I/Users/cmalek/src/robotics/libraries/ObstacleAvoider/lib/Rolley -Wall -ffunction-sections -fdata-sections -Os -pedantic -Wall -Wextra -fno-exceptions -std=gnu++11 ObstacleAvoider.cpp -o /Users/cmalek/src/robotics/libraries/ObstacleAvoider/bin/uno/ObstacleAvoider/ObstacleAvoider.o
In file included from ./ObstacleAvoider.h:4:0,
                 from ObstacleAvoider.cpp:1:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Servo/src/Servo.h:67:2: error: #error "This library only supports boards with an AVR or SAM processor."
#error "This library only supports boards with an AVR or SAM processor."
  ^
make: *** [/Users/cmalek/src/robotics/libraries/ObstacleAvoider/bin/uno/ObstacleAvoider/ObstacleAvoider.o] Error 1
sudar commented 10 years ago

@cmalek The changes that we did for Arduino 1.5.x is merged into the master branch. But support for Arduino 1.5.x is still experimental and @sej7278 is leading the efforts on it.

Which board are you trying this code for and does that work with the Arduino IDE?

sej7278 commented 10 years ago

@cmalek are you using the Bare-Arduino-Project and not Arduino-Makefile, as this combination of flags is not a good idea:

-pedantic -Wall -Wextra -fno-exceptions -std=gnu++11

ladislas commented 10 years ago

@cmalek Bare-Arduino-Project only works with Arduino 1.0.5

cmalek commented 10 years ago

@sudar I'm using the uno.

@sej7278 I had copied Arduino-Makefile/examples/MakefileExample/Makefile-example.mk into my project and edited it accordingly. Should I not have done that?

I did get a little further last night in building my project. I added "-DARDUINO_ARCH_AVR" to my CPPFLAGS and a lot of the requisite files were compiled except for Servo.cpp, which wasn't even attempted to be compiled. Then the linking failed, of course.

I see that in the Arduino Servo system library, the code has been split into separate folders by architecture. So in /Applications/Arduino.app/Contents/Resources/Java/libraries/Servo, the directory structure looks like this:

Servo/
├── examples
│   ├── Knob
│   │   └── Knob.ino
│   └── Sweep
│       └── Sweep.ino
├── keywords.txt
├── library.properties
└── src
    ├── Servo.h
    ├── avr
    │   ├── Servo.cpp
    │   └── ServoTimers.h
    └── sam
        ├── Servo.cpp
        └── ServoTimers.h

so that the code to be compiled for the avr architecture is in Servo/src/avr/Servo.cpp. Ugh, looks like only Servo does this -- none of the other bundled libraries have per architecture code directories.

I see that you're already setting ARCHITECTURE appropriately on line 319 and then using it to get the correct ARDUINO_CORE_PATH, ARDUINO_VAR_PATH, BOARDS_TXT and BOOTLOADER_PARENT so you could reuse ARCHITECTURE in figuring out where the appropriate source for Servo is. Not sure what the right answer is here since Servo is a one-off.

sej7278 commented 10 years ago

@cmalek - the easiest thing is to use arduino 1.0.5 instead of 1.5.6, there really is little point in using the new ide if you're using an uno.

cmalek commented 10 years ago

@sej7278 thanks! I'll try that.

sej7278 commented 10 years ago

it seems in 1.5 there are additional hardware-dependant libraries, so ARDUINO_LIB_PATH would have to search:

/usr/share/arduino/hardware/arduino/avr/libraries (for Wire, SPI etc.)
/usr/share/arduino/hardware/arduino/sam/libraries (as above but for ARM not AVR)
/usr/share/arduino/libraries (for Servo, LiquidCrystal etc.)

and inside each library are 2 versions of the library:

$ ls /usr/share/arduino/libraries/Servo/src
Servo.h

avr:
Servo.cpp  ServoTimers.h

sam:
Servo.cpp  ServoTimers.h

this is getting silly now, 1.5 is totally different to 1.0 and cores, sketches, libraries are all going to have to be rewritten. crazy!

sej7278 commented 10 years ago

support for 1.5 layout libraries with src/ subdirectory added to 1.0.6:

https://github.com/arduino/Arduino/commit/567240236a614817f32a8dff8c5271f5d07a53f9

not that i've seen a 1.5-only library yet....

xxxajk commented 10 years ago

Actually, a lot is up coming for 1.5.x. Since I am a beta tester for the Arduino Zero, I actually know what is going to be happening before it happens... for once in my life, anyway. LOL :-)

ladislas commented 10 years ago

@xxxajk But you're tied by secret, right? :)