France
Offline
Sr. Member
Karma: 7
Posts: 441
|
 |
« on: January 26, 2011, 12:37:51 pm » |
Hello! This is the continuation of the thread initiated by Robert aka. Ratkins in the now read-only old forum. I've the same problem woth Arduino Uno on Xcode  Please find what I've found so far: On his blog, Robert Carlsen was pretty close to a solution. But as the last two comments suggest, the Arduino Uno differs from the Duemilanove. Robert Atkins Says: January 3rd, 2011 at 7:41 I’m trying to get this working on a Uno, which I believe has different USB/serial hardware than previous Arduino models? Anyhow, I’ve changed the makefile to say: PORT = /dev/tty.usbmodem* … but I’m getting a whole series of error messages: avrdude: stk500_2_ReceiveMessage(): timeout And it doesn’t look like the sketch is uploading to the board (rx/tx LEDs aren’t flashing.) Anybody got any hints?
Davide Says: January 9th, 2011 at 23:39 Also I am trying to work with Xcode ArduinoUno but gives me this error —- “rm -f main.hex main.eep main.cof main.elf \ main.map main.sym main.lss core.a \ make: *** No rule to make target `/Applications/Arduino.app/Contents/Resources/Java/hardware/cores/arduino//pins_arduino.o’, needed by `core.a’. Stop. — someone managed to make it work? Also, Mattias Gunneras posted on Twitter but didn't explain how @mattiasgunneras Mattias Gunneras Finally got Xcode working with the Arduino UNO. I'm looking forward to a productivity gain of about 318%. 9 Jan via Twitter for Mac Favorite Undo Retweet Reply Good luck!
|
|
|
|
« Last Edit: January 25, 2012, 08:53:52 am by avenue33 »
|
Logged
|
avenue33
|
|
|
|
SF Bay Area (USA)
Offline
Faraday Member
Karma: 78
Posts: 5454
Strongly opinionated, but not official!
|
 |
« Reply #1 on: January 29, 2011, 04:14:50 am » |
Anyhow, I’ve changed the makefile to say: PORT = /dev/tty.usbmodem* minimally, you would also have to change the bitrate to 115200...
|
|
|
|
|
Logged
|
|
|
|
|
France
Offline
Sr. Member
Karma: 7
Posts: 441
|
 |
« Reply #2 on: February 13, 2011, 11:47:32 am » |
Hello, I tried Nick’s modified version of ArduinoOnXcode template plus all the following hints - on Makefile, set values for the MCU, upload speed and the protocol according to file located at Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/boards.txt
- on Makefile, add $(ARDUINO)/WString.cpp to line 73 before $(ARDUINO)/Print.cpp
- on Makefile, change line 67 from PORT = /dev/tty.usbserial* to PORT = /dev/tty.usbmodem*
It works fine  on my Arduino Uno with Arduino 0022 IDE and Xcode 3.2.5 on Mac OS X 10.6.6 for small projects, as LED blinking and "Hello World". However, I can't manage to use libraries  previously developed with Arduino 0022 IDE. Probable cause might be a mismatch between C and C++ but I don't know how to fix it. Any idea ?
|
|
|
|
|
Logged
|
avenue33
|
|
|
|
France
Offline
Sr. Member
Karma: 7
Posts: 441
|
 |
« Reply #3 on: February 16, 2011, 07:59:27 am » |
Hi! Here are two working  projects - Arduino-1: very basic
- Arduino-3: with a class for the LED
and one non-working  project - Arduino-4: the LED class is on a library
I'm sure it's something trivial  but I can't find it. /usr/local/CrossPack-AVR/bin//avr-gcc -mmcu=atmega328p -I. -gstabs -DF_CPU=16000000L -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -Os -Wall -Wstrict-prototypes -std=gnu99 -o main.elf main.cpp -L. core.a -lm cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++ cc1plus: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++ /var/folders/gA/gAXpDd7ZEBG06Owk-4lV4++++TI/-Tmp-//cc1xTugb.o: In function `global constructors keyed to myLed': main.cpp:9: undefined reference to `LED::LED()' /var/folders/gA/gAXpDd7ZEBG06Owk-4lV4++++TI/-Tmp-//cc1xTugb.o: In function `loop': main.cpp:31: undefined reference to `LED::blink(int, int)' /var/folders/gA/gAXpDd7ZEBG06Owk-4lV4++++TI/-Tmp-//cc1xTugb.o: In function `setup': main.cpp:18: undefined reference to `LED::begin(int)' main.cpp:24: undefined reference to `LED::on()' make: *** [main.elf] Error 1
Warning! Before compiling, always launch Build > Clean or Shift-Command-K. Any idea? Thank you for your help!
|
|
|
|
« Last Edit: February 16, 2011, 09:35:02 am by avenue33 »
|
Logged
|
avenue33
|
|
|
|
France
Offline
Sr. Member
Karma: 7
Posts: 441
|
 |
« Reply #4 on: February 16, 2011, 09:39:10 am » |
Hi! After some research, it seems to be related to the link options. The library LED.h LED.cpp doesn't figure on the compile line: /usr/local/CrossPack-AVR/bin//avr-gcc -mmcu=atmega328p -I. -gstabs -DF_CPU=16000000L -I/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino -Os -Wall -Wstrict-prototypes -std=gnu99 -o main.elf main.cpp -L. core.a -lm
Enclosed: Makefile, full build log report What are the parameters to be changed on the Makefile, not only for this specific project for any future projects? Thank you and best regards,
|
|
|
|
|
Logged
|
avenue33
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 25
Arduino rocks
|
 |
« Reply #5 on: May 08, 2011, 03:32:26 am » |
Good news, using the Makefile supplied by avenue33 I've successfully uploaded the Blink script to my Uno!
Xcode4 still won't acknowledge the existence of the template, but I guess that's just an afternoon of manual-digging. I'll post here when I have anything more to report.
Cheers, Robert.
|
|
|
|
|
Logged
|
|
|
|
|
France
Offline
Sr. Member
Karma: 7
Posts: 441
|
 |
« Reply #6 on: June 07, 2011, 12:17:32 pm » |
Hi Robert, On Xcode 3.2.5, I select File > New Project and then a window pops-up with the following options:  Choose Other > ArduinoOnXcode. I don't know how it runs on Xcode 4 but I guess it's similar. I still don't manage to get my own libraries compiled, as Example-4 attached in a previous post. There's no problem with standard Arduino libraries. Nice to hear from your progress 
|
|
|
|
|
Logged
|
avenue33
|
|
|
|
France
Offline
Sr. Member
Karma: 7
Posts: 441
|
 |
« Reply #7 on: November 04, 2011, 12:48:12 pm » |
Hi! Please find on this GitHub repository a Xcode project for Arduino UNO. - Xcode 4 on Mac OS X.7
- MPIDE 0022 based on Arduino IDE 0022
I tested it successfully with the Arduino UNO and the chipKIT UNO32 platforms. The Xcode 3 template is no longer valid because Xcode 4 has changed everything about the templates. More details on my website. I'd greatly appreciate some help on Xcode 4 about templates and libraries linking.
|
|
|
|
« Last Edit: November 04, 2011, 04:21:45 pm by avenue33 »
|
Logged
|
avenue33
|
|
|
|
Antwerp, Belgium
Offline
Jr. Member
Karma: 2
Posts: 60
|
 |
« Reply #8 on: November 11, 2011, 08:11:30 pm » |
Hi, I have been struggling to get Arduino to work with XCode for the longest time. Finally, it is working. even with libraries ( but for some reason not the SD library... I'm not really sure why. ) I have been recycling makefiles that other people posted on the web, but none that I found could make libraries link correctly or even include extra .cpp files in my project's src folder. So I have been adjusting and changing makefiles so many times I have no clue where my original source came from :-s Here is the makefile that I'm using now for working with a Makerbot Sanguino based board: ARDUINO = /Applications/Arduino.app/Contents/Resources/Java/hardware/Sanguino/cores/arduino LIBRARIES = /Applications/Arduino.app/Contents/Resources/Java/libraries AVRDUDE_DIR = /usr/local/CrossPack-AVR/bin SIZE = $(AVRDUDE_DIR)/avr-size SOURCES = $(wildcard src/*.cpp)
#loading libraries STEPPER = $(LIBRARIES)/Stepper SERVO = $(LIBRARIES)/Servo EEPROM = $(LIBRARIES)/EEPROM SD_UTIL = $(LIBRARIES)/SD/utility INCLUDE_LIBRARIES = -I$(STEPPER) -I$(SERVO) -I$(EEPROM) CPP_LIBRARIES = $(wildcard $(STEPPER)/*.cpp) $(wildcard $(SERVO)/*.cpp) \ $(wildcard $(EEPROM)/*.cpp)
PORT = /dev/tty.usbserial* TARGET = main SRC = $(ARDUINO)/pins_arduino.c $(ARDUINO)/wiring.c \ $(ARDUINO)/wiring_analog.c $(ARDUINO)/wiring_digital.c \ $(ARDUINO)/wiring_pulse.c \ $(ARDUINO)/wiring_shift.c $(ARDUINO)/WInterrupts.c CXXSRC = $(ARDUINO)/HardwareSerial.cpp $(ARDUINO)/WMath.cpp $(ARDUINO)/Print.cpp \ $(CPP_LIBRARIES) $(SOURCES) MCU = atmega644p F_CPU = 16000000 FORMAT = ihex UPLOAD_RATE = 38400
# Name of this Makefile (used for "make depend"). MAKEFILE = Makefile
# Debugging format. # Native formats for AVR-GCC's -g are stabs [default], or dwarf-2. # AVR (extended) COFF requires stabs, plus an avr-objcopy run. DEBUG = stabs
OPT = s
# Place -D or -U options here CDEFS = -DF_CPU=$(F_CPU) CXXDEFS = -DF_CPU=$(F_CPU)
# Place -I options here : include libraries CINCS = -I$(ARDUINO) $(INCLUDE_LIBRARIES) CXXINCS = -I$(ARDUINO) $(INCLUDE_LIBRARIES)
# Compiler flag to set the C Standard level. # c89 - "ANSI" C # gnu89 - c89 plus GCC extensions # c99 - ISO C99 standard (not yet fully implemented) # gnu99 - c99 plus GCC extensions CSTANDARD = -std=gnu99 CDEBUG = -g$(DEBUG) CWARN = -Wall -Wstrict-prototypes CTUNING = -funsigned-char -funsigned-bitfields -fpack-struct -fshort-enums -ffunction-sections -fdata-sections -Wl,-gc-sections
CFLAGS = $(CDEBUG) $(CDEFS) $(CINCS) -O$(OPT) $(CWARN) $(CSTANDARD) $(CEXTRA) $(CTUNING) CXXFLAGS = $(CDEFS) $(CXXINCS) -O$(OPT) $(CTUNING) LDFLAGS = -lm -Wl,-gc-sections -mmcu=$(MCU)
# Programming support using avrdude. Settings and variables. AVRDUDE_PROGRAMMER = stk500v1 AVRDUDE_PORT = $(PORT) AVRDUDE_WRITE_FLASH = -U flash:w:bin/$(TARGET).hex AVRDUDE_FLAGS = -F -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) \ -b $(UPLOAD_RATE) -D
# Program settings CC = $(AVRDUDE_DIR)/avr-gcc CXX = $(AVRDUDE_DIR)/avr-g++ OBJCOPY = $(AVRDUDE_DIR)/avr-objcopy OBJDUMP = $(AVRDUDE_DIR)/avr-objdump AR = $(AVRDUDE_DIR)/avr-ar SIZE = $(AVRDUDE_DIR)/avr-size NM = $(AVRDUDE_DIR)/avr-nm AVRDUDE = $(AVRDUDE_DIR)/avrdude REMOVE = rm -f MV = mv -f
# Define all object files. OBJ = $(SRC:.c=.o) $(CXXSRC:.cpp=.o) $(ASRC:.S=.o)
# Define all listing files. LST = $(ASRC:.S=.lst) $(CXXSRC:.cpp=.lst) $(SRC:.c=.lst)
# Combine all necessary flags and optional flags. # Add target processor to flags. ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) ALL_CXXFLAGS = -mmcu=$(MCU) -I. $(CXXFLAGS) ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target. all: sizebefore clean build sizeafter
build: info folder elf hex
elf: bin/$(TARGET).elf hex: bin/$(TARGET).hex eep: bin/$(TARGET).eep lss: bin/$(TARGET).lss sym: bin/$(TARGET).sym
# print info info: @echo "compiling sources: " $(SOURCES); @echo "compiling libraries sources: " $(CPP_LIBRARIES); @echo "----------";
# create the bin folder if it doesn't exist folder: mkdir -p bin
# Program the device. upload: bin/$(TARGET).hex $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)
# Display size of file. HEXSIZE = $(SIZE) --target=$(FORMAT) bin/$(TARGET).hex ELFSIZE = $(SIZE) bin/$(TARGET).elf sizebefore: @echo "size before: "; @if [ -f bin/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_BEFORE); $(HEXSIZE); echo; fi
sizeafter: @echo "size after:"; @if [ -f bin/$(TARGET).elf ]; then echo; echo $(MSG_SIZE_AFTER); $(HEXSIZE); echo; fi
# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. COFFCONVERT=$(OBJCOPY) --debugging \ --change-section-address .data-0x800000 \ --change-section-address .bss-0x800000 \ --change-section-address .noinit-0x800000 \ --change-section-address .eeprom-0x810000
coff: bin/$(TARGET).elf $(COFFCONVERT) -O coff-avr bin/$(TARGET).elf $(TARGET).cof
extcoff: $(TARGET).elf $(COFFCONVERT) -O coff-ext-avr bin/$(TARGET).elf $(TARGET).cof
.SUFFIXES: .elf .hex .eep .lss .sym
.elf.hex: $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@
.elf.eep: -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ --change-section-lma .eeprom=0 -O $(FORMAT) $< $@
# Create extended listing file from ELF output file. .elf.lss: $(OBJDUMP) -h -S $< > $@
# Create a symbol table from ELF output file. .elf.sym: $(NM) -n $< > $@
bin/core.a: $(OBJ) @for i in $(OBJ); do echo $(AR) rcs bin/core.a $$i; $(AR) rcs bin/core.a $$i; done
# Link: create ELF output file from library. bin/$(TARGET).elf: bin/core.a $(CC) $(ALL_CFLAGS) -o $@ src/$(TARGET).cpp -L. bin/core.a $(LDFLAGS)
# Compile: create object files from C++ source files. .cpp.o: $(CXX) -c $(ALL_CXXFLAGS) $< -o $@
# Compile: create object files from C source files. .c.o: $(CC) -c $(ALL_CFLAGS) $< -o $@
# Compile: create assembler files from C source files. .c.s: $(CC) -S $(ALL_CFLAGS) $< -o $@
# Assemble: create object files from assembler source files. .S.o: $(CC) -c $(ALL_ASFLAGS) $< -o $@
# Target: clean project. clean: $(REMOVE) bin/$(TARGET).hex bin/$(TARGET).eep bin/$(TARGET).cof bin/$(TARGET).elf \ bin/$(TARGET).map bin/$(TARGET).sym bin/$(TARGET).lss bin/core.a \ $(OBJ) $(LST) $(SRC:.c=.s) $(SRC:.c=.d) $(CXXSRC:.cpp=.s) $(CXXSRC:.cpp=.d)
depend: if grep '^# DO NOT DELETE' $(MAKEFILE) >/dev/null; \ then \ sed -e '/^# DO NOT DELETE/,$$d' $(MAKEFILE) > \ $(MAKEFILE).$$$$ && \ $(MV) $(MAKEFILE).$$$$ $(MAKEFILE); \ fi echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' \ >> $(MAKEFILE); \ $(CC) -M -mmcu=$(MCU) $(CDEFS) $(CINCS) $(SRC) $(ASRC) >> $(MAKEFILE)
.PHONY: all build elf hex eep lss sym program coff extcoff clean depend
I'm using this with XCode 3.2, I have attached a zip file of a working sample project. hope this helps someone, I for one got a little bit balder trying to get this to work :-) best, tim.
|
|
|
|
« Last Edit: November 12, 2011, 07:07:48 am by timKnapen »
|
Logged
|
|
|
|
|
Antwerp, Belgium
Offline
Jr. Member
Karma: 2
Posts: 60
|
 |
« Reply #9 on: November 12, 2011, 10:36:12 am » |
I have create a project on Github where I've put the XCode project templates: https://github.com/timknapen/Arduino-With-XCodeWith a little help from people who know about makefiles and compilers, I'm sure we can get decent XCode support for Arduino. best, tim.
|
|
|
|
|
Logged
|
|
|
|
|
Antwerp, Belgium
Offline
Jr. Member
Karma: 2
Posts: 60
|
 |
« Reply #10 on: November 14, 2011, 07:30:10 am » |
Hi all, I don't know if this is the right place for this, but I've updated my XCode projects on Github. It has now been updated to work with the UNO. I did a quick test and it seems to work fine. Still only XCode 3.2 because I'm not running Lion yet.. go get it here: https://github.com/timknapen/Arduino-With-XCodebest, tim.
|
|
|
|
|
Logged
|
|
|
|
|
Antwerp, Belgium
Offline
Jr. Member
Karma: 2
Posts: 60
|
 |
« Reply #11 on: November 14, 2011, 07:41:14 am » |
Hey anyone doing the same sort of thing, Shouldn't we create a specific thread for Arduino + XCode (both XCode3.2 and XCode4) so that everybody who know how to write proper C++ can benefit from our efforts? It seems that all the information is now spread over multiple blogs, github repositories etc.. And even on the playgrond: http://arduino.cc/playground/Main/DevelopmentTools there is no mention. anyone? best, tim.
|
|
|
|
|
Logged
|
|
|
|
|
France
Offline
Sr. Member
Karma: 7
Posts: 441
|
 |
« Reply #12 on: November 14, 2011, 08:59:45 am » |
I fully agree with you. I find here an extensive list of Arduino-related makefiles. What we need: • Actions: Build and Upload • Boards choice: Arduino UNO, ... , chipKIT UNO32 • #include libraries compiled and linked • Xcode template I could easily close my repository and point to yours. Is there an Xcode specialist around? Please! Best regards,
|
|
|
|
« Last Edit: November 15, 2011, 03:50:38 am by avenue33 »
|
Logged
|
avenue33
|
|
|
|
Antwerp, Belgium
Offline
Jr. Member
Karma: 2
Posts: 60
|
 |
« Reply #13 on: November 14, 2011, 11:14:29 am » |
I fully agree with you. I'll find here an extensive list of Arduino-related makefiles. What we need: • Actions: Build and Upload • Boards choice: Arduino UNO, ... , chipKIT UNO32 • #include libraries compiled and linked • Xcode template I could easily close my repository and point to yours. Is there an Xcode specialist around? Please! Best regards, That list of makefiles is very interesting for learning, thanks! I don't want to come in and take over the show, so I don't think you should close your repository, but a central place for working on this would be great. Like maybe a XCode + Arduino thread on this forum where we discuss the progress and one github repository where multiple people can work on this project. I'm very new to git and github, so I don't really know how to do this. Do you? I'm just starting to learn about makefiles so we could use someone that really is fluent with these thing. It would be great that people who download the templates don't have to go into the makefile and change a bunch of parameters just to add a library. Right now I'm trying to have the choice of Board in the build settings of the project instead of in the makefile. I'm fairly close, but I can't find how to make a drowdown list in the build settings like the ones you have in a Cocoa project when selecting the "Base SDK"... Avenue33, did you try my project template with XCode 4? I think you can just open it as a normal project with XCode4. I don't have a computer that runs Lion yet, so I can't test this. best, tim
|
|
|
|
|
Logged
|
|
|
|
|
SF Bay Area (USA)
Offline
Faraday Member
Karma: 78
Posts: 5454
Strongly opinionated, but not official!
|
 |
« Reply #14 on: November 14, 2011, 11:44:24 am » |
What we "need" is a command-line mode of the Arduino app that does the Arduino-style preprocessing on a set of .pde (or .ino) files. Having to figure out exactly what it does (slightly differently) with each Arduino release is a pain, and makes implementing Arduino program builds in other IDEs an exercise in chasing not-fully-documented behaviors. :-(
|
|
|
|
|
Logged
|
|
|
|
|
|