Closed NinjaNymo closed 7 years ago
Are you sure you are using the correct port ?
Off the top of my head, the ports should be in the form /dev/tty.usb*
.
Yes. The Nano board I have uses a different USB chip, so I had to install drivers for that. The port then shows up in the Arduino IDE as cu.wchusbserial plus some number. It uploads fine using the Arduino IDE using that port, but not from Xcode...
I've been debugging for a while now, and I thought it might be useful to see the avrdude output from the successful Arduino IDE build. Maybe you could help me set something in the xavr makefile to make this work in Xcode as well?
avrdude: Version 6.3, compiled on Dec 16 2016 at 13:32:25
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2014 Joerg Wunsch
System wide configuration file is "/Applications/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
User configuration file is "/Users/nikolainymo/.avrduderc"
User configuration file does not exist or is not a regular file, skipping
Using Port : /dev/cu.wchusbserial1420
Using Programmer : arduino
Overriding Baud Rate : 57600
AVR Part : ATmega328P
Chip Erase delay : 9000 us
PAGEL : PD7
BS2 : PC2
RESET disposition : dedicated
RETRY pulse : SCK
serial program mode : yes
parallel program mode : yes
Timeout : 200
StabDelay : 100
CmdexeDelay : 25
SyncLoops : 32
ByteDelay : 0
PollIndex : 3
PollValue : 0x53
Memory Detail :
Block Poll Page Polled
Memory Type Mode Delay Size Indx Paged Size Size #Pages MinW MaxW ReadBack
----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
eeprom 65 20 4 0 no 1024 4 0 3600 3600 0xff 0xff
flash 65 6 128 0 yes 32768 128 256 4500 4500 0xff 0xff
lfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
hfuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
efuse 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
lock 0 0 0 0 no 1 0 0 4500 4500 0x00 0x00
calibration 0 0 0 0 no 1 0 0 0 0 0x00 0x00
signature 0 0 0 0 no 3 0 0 0 0 0x00 0x00
Programmer Type : Arduino
Description : Arduino
Hardware Version: 2
Firmware Version: 1.16
Vtarget : 0.0 V
Varef : 0.0 V
Oscillator : Off
SCK period : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
Reading | ################################################## | 100% 0.02s
avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "/var/folders/kz/x8wvz4pj0yg_lk6555l4xxnm0000gn/T/arduino_build_923243/Blink.ino.hex"
avrdude: writing flash (926 bytes):
Writing | ################################################## | 100% 0.62s
avrdude: 926 bytes of flash written
avrdude: verifying flash memory against /var/folders/kz/x8wvz4pj0yg_lk6555l4xxnm0000gn/T/arduino_build_923243/Blink.ino.hex:
avrdude: load data flash data from input file /var/folders/kz/x8wvz4pj0yg_lk6555l4xxnm0000gn/T/arduino_build_923243/Blink.ino.hex:
avrdude: input file /var/folders/kz/x8wvz4pj0yg_lk6555l4xxnm0000gn/T/arduino_build_923243/Blink.ino.hex contains 926 bytes
avrdude: reading on-chip flash data:
Reading | ################################################## | 100% 0.55s
avrdude: verifying ...
avrdude: 926 bytes of flash verified
avrdude done. Thank you.
Ayy, I fixed it! I noticed that the Arduino IDE overrode the baud rate, so I added -b 57600
to AVR_DUDEFLAGS
in the makefile:
AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -b 57600 -c $(AVRDUDE_PROGRAMMER)
AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY)
AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE)
AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER)
Perhaps you could consider adding a baud rate override option in the makefiles?
@NinjaNymo Glad you fixed the issue !
Good suggestion about the overridable baud-rate. If you feel up to it, maybe you could throw together a quick PR for this ? It would be greatly appreciated 👍
I stil have this problem could it be that I use a Arduino MEGA 2560. It might be that I use the wrong port. The Arduino IDE reports Errors about not finding the port but it stil works. how do i find the port and know the baud rate of my arduino?
First, let me make it clear what I try to do here as I might not have understood how xavr should be used.
I'm trying to program an Arduino Nano from Xcode. I haven't done anything to the Arduino it self, and it works using the Arduino IDE (I had to install some drivers for the USB chip on the third party Nano board).
However, when trying to upload a very simple C program (basically the blink example) from Xcode, it builds, but does not upload. I get the following error:
Programmer is set to Arduino in the makefile:
AVRDUDE_PROGRAMMER = arduino
Do I need to do anything to the Arduino to be able to program it from Xcode over USB? Like change the bootloader or something. If not any ideas on how I can resolve this issue?