chipKIT® Development Platform

Inspired by Arduino™

Working makefile on Mac OS X

Created Mon, 23 Jan 2012 21:44:23 +0000 by avenue33


Mon, 23 Jan 2012 21:44:23 +0000

[color=#FF0000]Please jump directly to this :arrow: post.[/color]


Is there a decent makefile for chipKIT around I could use with Xcode?

The two versions I started digging in throw an endless list of messages on my MacBook.



Mon, 23 Jan 2012 21:46:50 +0000

Hey there, what endless messages are you getting from the first Makefile? It's working fine in Ubuntu and OS X for me and my coworkers. If you want to file an issue on the GitHub project, perhaps I can help you and others who may have similar issues.



Mon, 23 Jan 2012 22:54:51 +0000


Thank for your answer. I'll try and pack the messages and post them tomorrow.

Main problem is, the file comes in a kit with another and specific folders and sub-folders.

Could you please zip a working example with the standard blink.pde sketch, assuming MPIDE is installed with all its tools inside?

Thank you!

About the ard-parse-boards requiring YAML: I wrote this functions instead

BOARDS_TXT = /Applications/

# result = $(call READ_BOARD_TXT, 'boardname.parameter', 'pathfileboards.txt')
nullstring  :=
spacestring := $(nullstring) # end of the line
equalstring := $(nullstring)=# end of the line
READ_BOARD_TXT = $(lastword $(subst $(equalstring),$(spacestring),$(shell grep -e$(1) $(2)))) 

# example
boardname = uno_pic32
parameter = build.f_cpu
F_CPU = $(call READ_BOARD_TXT, $(boardname).$(parameter), $(BOARDS_TXT))


Tue, 24 Jan 2012 16:36:05 +0000

Thanks for the Make function version of the ard-parse-boards Perl script - that's awesome! I've that to the project instead (with a thanks to you in the README).

I added an example Makefile to the README:

It's quite small, just 4 lines - I don't have much other documentation there because the original author has a pretty good walkthrough at (this is linked from the Github repository as well).

Regarding your main issue, if I understand correctly, you want to package the entire Makefile with your sketch? That's no problem, just copy the files over to your own folder. You can either leave them separate as is (I recommend that) and keep the "include" lines, or combine them all into one Makefile (just make sure you keep the order the same:, then your customizations).


Tue, 24 Jan 2012 18:39:59 +0000

You're welcome!

Thank you very much for the example.

Things are always more simple once understood!

My main purpose is to have a decent makefile I could use with Xcode for both Arduino and chipKIT boards just as MPIDE does, ... but with all the comfort Xcode could provide.


Wed, 25 Jan 2012 09:34:23 +0000

Everything works fine for an Arduino board, except a stty related [color=#FF0000]error[/color].

[color=#0000FF]• EDIT: alternative solution found. See message below.[/color]

for STTYF in 'stty --file' 'stty -f' 'stty <' ;
do $STTYF /dev/tty >/dev/null 2>/dev/null && break ;
done ;
$STTYF /dev/tty.usbmodem641 hupcl ;
(sleep 0.1 || sleep 1) ;
$STTYF /dev/tty.usbmodem641 -hupcl stty: stdin isn't a terminal stty: stdin isn't a terminal make: *** [reset] Error 1 stipulates

# stdin/out appears to work but generates a spurious error on MacOS at least.

Do you experience the same error :?: Have you tried screen instead :?:

Serial console parameters Makefile

MON_SPEED = 19200
MON_CMD   = screen 
MON_PORT  = $(wildcard /dev/tty.usbmodem*)

Close serial console before upload Makefile:

$(MON_CMD) -X kill
sleep 1


screen -X kill No screen session found. make: [upload] Error 1 (ignored) sleep 1

Open serial console after upload Makefile:

sleep 1


screen /dev/tty.usbmodem641 -b19200 Must be connected to a terminal. make: [upload] Error 1 (ignored)

How to make the connection with the terminal?

Thank you and best regards.


Wed, 25 Jan 2012 09:43:48 +0000

For a chipKIT board, make looks for Board_Defs.h and raises an [color=#FF0000]error[/color]

/Applications/ -c -mprocessor=32MX795F512L -DF_CPU=80000000L -I. -I/Applications/ -g -Os -w -Wall -ffunction-sections -fdata-sections -O2 -mno-smart-io -DARDUINO=22 -D_BOARD_MEGA_= -fno-exceptions build-cli/Blink.cpp -o build-cli/Blink.o In file included from /Applications/, from build-cli/Blink.cpp:1: /Applications/ fatal error: Board_Defs.h: No such file or directory compilation terminated. make: *** [build-cli/Blink.o] Error 1

Do you experience this error :?:

Board_Defs.h is in /Applications/[color=#0000FF]Max32[/color]/Board_Defs.h Folder [color=#0000FF]Max32[/color] is specified in /Applications/

I added to

BOARD_DEFS   = $(ARDUINO_DIR)/hardware/pic32/variants/$(VARIANT)/Board_Defs.h

I added to

ifndef VARIANT
VARIANT = $(call PARSE_BOARD,$(BOARD_TAG),build.variant)

But I don't know where to take the BOARD_DEFS parameter into account.

Thank you and best regards.


Wed, 25 Jan 2012 16:52:26 +0000

Here's the alternative solution I've found:

try this in your makefile for opening a serial terminal from XCode:

@echo " ---- open serial ---- "
osascript -e 'tell application "Terminal" to do script "screen /dev/tty.usbmodem* 9600"'
@echo " ---- close serial ---- "
osascript -e 'tell application "Terminal" to do script "screen -X quit"'

You can then add these rules after and before your upload if you want.


Sat, 28 Jan 2012 19:57:10 +0000

I forked the commit and then proceeded step-by-step, each step being pull-requested:

0- Fork from 1- Added files 2- Added Xcode project 3- Fixed [color=#0000FF]BOARD_MEGA[/color] hard-coded in 4- Serial port management 5- Debug comments on makefiles 6- Added [color=#0000FF]LDSCRIPT[/color] value search
7- Added [color=#0000FF]EXTRA_LDFLAGS[/color] for linker - linker issue fixed 8- Library issue solved

I hope this work could help you fixing / improving the chipKIT makefile.

The sketch is built and uploaded and the pin 13 LED does blink on both Arduino UNO and chipKIT UNO32.

The result is available at :arrow: rei-vilo/mpideXcode

To be continued...