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]
Hi!
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.
https://github.com/peplin/arduino.mk http://pastebin.com/31XXwmUV
Thanks!
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.
Chris
Mon, 23 Jan 2012 22:54:51 +0000
Chris,
Thank for your answer. I'll try and pack the messages and post them tomorrow.
Main problem is, the chipkit.mk file comes in a kit with another arduino.mk 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/Mpide.app/Contents/Resources/Java/hardware/pic32/boards.txt
# 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: https://github.com/peplin/arduino.mk
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 http://mjo.tc/atelier/2009/02/arduino-cli.html (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: Arduino.mk, chipKIT.mk 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
Arduino.mk 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
Result:
screen -X kill No screen session found. make: [upload] Error 1 (ignored) sleep 1
Open serial console after upload Makefile:
sleep 1
$(MON_CMD) $(MON_PORT) -b$(MON_SPEED)
Result:
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/Mpide.app/Contents/Resources/Java/hardware/pic32/compiler/pic32-tools/bin/pic32-g++ -c -mprocessor=32MX795F512L -DF_CPU=80000000L -I. -I/Applications/Mpide.app/Contents/Resources/Java/hardware/pic32/cores/pic32 -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/Mpide.app/Contents/Resources/Java/hardware/pic32/cores/pic32/WProgram.h:9:0, from build-cli/Blink.cpp:1: /Applications/Mpide.app/Contents/Resources/Java/hardware/pic32/cores/pic32/pins_arduino.h:128:24: 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/Mpide.app/Contents/Resources/Java/hardware/pic32/variants/[color=#0000FF]Max32[/color]/Board_Defs.h Folder [color=#0000FF]Max32[/color] is specified in /Applications/Mpide.app/Contents/Resources/Java//hardware/pic32/boards.txt
mega_pic32.build.variant=Max32
I added to chipKIT.mk
BOARD_DEFS = $(ARDUINO_DIR)/hardware/pic32/variants/$(VARIANT)/Board_Defs.h
I added to Arduino.mk
ifndef VARIANT
VARIANT = $(call PARSE_BOARD,$(BOARD_TAG),build.variant)
endif
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:
serial:
@echo " ---- open serial ---- "
osascript -e 'tell application "Terminal" to do script "screen /dev/tty.usbmodem* 9600"'
killserial:
@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 peplin-arduino.mk-d7bbeea commit and then proceeded step-by-step, each step being pull-requested:
0- Fork from peplin-arduino.mk-d7bbeea
1- Added files
2- Added Xcode project
3- Fixed [color=#0000FF]BOARD_MEGA[/color] hard-coded in chipKIT.mk
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...