Closed benjamind closed 10 years ago
Could you post the content of your Makefile? Have you tried running avrdude directly and determined the correct command-line to work your way back from.
I program a lot of ATmega uCs directly from the Pi's GPIO header and found that Arduino-Makefile has a lot of configuration variables to sift through.
Sure, its pretty simple though:
BOARD_TAG = micro256
ARDUINO_PORT = /dev/ttyACM0
ARDUINO_LIBS = Adafruit_NeoPixel
ARDUINO_LIB_PATH = /home/pi/sketchbook/lib
ARDUINO_DIR = /home/pi/arduino-1.0.5
ARDMK_PATH=/home/pi/Arduino-Makefile/bin
ARDMK_DIR=/home/pi/Arduino-Makefile
AVR_TOOLS_DIR=/usr
include ../Arduino.mk
As you can see I pulled down the latest Arduino-Makefile from git, and the 1.0.5 version of the Arduino for linux distribution. Compilation works great, though I've yet to figure out how to use a custom core (I'll figure that out later).
I have the Micro connected to the Raspberry Pi via USB only, do I have to use GPIO for programming? Ino seems to work through USB ok.
I tried the following avrdude
command:
/usr/bin/avrdude -q -V -D -p atmega32u4 -c a vr109 -b 57600 -P /dev/ttyACM0 -U flash:w:build-micro/fled.hex:i
With the same result. I haven't really used avrdude much so I'm at a bit of a loss what to alter next. I have confirmed the Arduino is definitely on /dev/ttyACM0
using dmesg
.
I just tried doing make reset
and could not see any kind of reset of the connected Arduino despite the process reporting that it was successful.
/home/pi/Arduino-Makefile/bin/ard-reset-arduino --caterina /dev/ttyACM0
I think the arduino is not being properly reset by this code. I've tried altering it to more closely match the way ino does this but I've still not had any luck.
Try pressing the reset button on your Arduino as you upload and see if it makes a difference. Alternatively, try holding it down. Does this work?
The script that Arduino Makefile uses to reset can be overridden with a config variable, if you can find a specific method for resetting it. For me, the reset was handled by avrdude itself.
I'll attempt that tomorrow. Problem is the arduino and the pi are inside a case that is really hard to access so I'm doing all this remotely right now so pressing the reset button isn't really possible today.
Really regretting using the Arduino Micro now, might swap it out for an Uno or Mega when I open it all up as I've been having so many problems with the Micro its just not worth it anymore.
I have an extensive guide in the works for programming the Trinket from the Pi, if the ATtiny85 is suitable for your purposes ( it's not even close to a Micro ). Otherwise you can find ATmega328 guides on my blog.
I currently use an ATmega328 circuit built out onto a Pi proto-plate and pushed onto my Pi's GPIO header. That way I can also use a direct I2C or UART connection.
Ah to have the time to actually build something properly ;-)
Unfortunately this is all a big hack with whatever I had on hand given time pressures that meant I couldn't order parts online. Next time...
@benjamind There seems to be some problem with avrdude and caterina type Arduinos. Sometimes just unpluging and pluging back will solve the issue. I am not sure why this is happening though. There is a huge debug thread about it at #30
@Gadgetoid
I program a lot of ATmega uCs directly from the Pi's GPIO header and found that Arduino-Makefile has a lot of configuration variables to sift through.
Can you share this? It would be nice to note this in the readme.
@sudar yes it appears to be the same issue. I actually got it to program once by running a basic python script to reset the arduino first then doing the make upload
. This seemed to do the trick, but its not reliable in that the second time I tried it it didn't work again.
Yeah I suspected this. Unfortunately there is no solution for this yet :(
@sudar I've got a GitHub repo in the works which has examples and whatnot, see it here: https://github.com/pimoroni/programming-trinket-with-raspberry-pi/tree/Development
It relies heavily on Arduino-Makefile, which I have come to love! Thanks for your awesome work.
@benjamind I have found that my 'duinos get into a bad state occasionally and the only way to get them flashable again is to power cycle them. This makes little to no sense to me, because they're bleedin' Microcontrollers... but the old adage: "have you tried turning it off and on again," still stands.
My solution for anything I want to remain stable in the long run would be to add a transistor on the power or gnd connection of the ATmega, and use a GPIO pin on the Pi to switch it on/off. Then I can power-cycle remotely to my hearts content.
If you can feed your 'duino power through a pin, you could do the same I suspect!
@Gadgetoid I had a look at your repo and noticed you're installing arduino-mk manually but using apt/dpkg to install arduino/avrdude. I've just tested my unofficial rebuild of the debian arduino-mk package on my pi and it works ok. i've not tried make upload/reset, but make all/clean/disasm certainly work for the blink example.
Might be worth poking the debian packagers to update based on our work over here (they did start) i don't know how raspbian pulls in upstream packages as there should have been version 0.8.5 in raspbian wheezy already.
My builds of 1.1.0 are here which is ok for your testing but not redistribution.
Makefile:
ARDUINO_DIR = /usr/share/arduino
ARDMK_DIR = /usr/share/arduino
ARDMK_PATH = /usr/bin
AVR_TOOLS_DIR = /usr
BOARD_TAG = mega2560
ARDUINO_PORT = /dev/ttyACM0
include /usr/share/arduino/Arduino.mk
ino apparently has the same problem as us with the leonardo reset: https://github.com/amperka/ino/pull/110
horrible workaround in that pull request, but interestingly mentions that even the arduino ide has a problem sometimes.
lol, trying to buy a leonardo/micro to debug their various reset issues, but can't seem to find them for sale anymore, i guess people got fed up!
interestingly you can buy a "mini pro nano" with a 328p for £2 or a pro micro with 32u4 for £3 on ebay, cheaper and smaller than official arduino boards, or even a DIP '328p chip alone!
interestingly mentions that even the arduino ide has a problem sometimes.
I did face the reset issue with Arduino IDE and Leonardo once. Did give much thought to it at that time.
i've bought some sparkfun pro micro's and have had a bit of a play and can't get ard-reset-arduino
to work reliably, i managed to get about 50% success by switching to 57600, then 1200 then 115200 baud.
i noticed the ide always finishes at 115200 baud, and somehow bypasses the 8sec bootloader delay in the caterina firmware.
the old ard-reset-leonardo
script does better when called via make reset
but still fails when called via make upload
due to the way the 32u4 switches usb device and waits 8secs. so going back to python isn't going to be the quick fix we expected.
I've added the regular arduino (DTR) functionality from ard-reset-arduino into the old python ard-reset-leonardo and tweaked it a bit. it now seems to work on my pro micro and mega2560.
could people please test it on a few platforms/boards please? its on gist
sorry i posted to #30 which has been closed it seems.
so going back to python isn't going to be the quick fix we expected.
Oops :(
could people please test it on a few platforms/boards please? its on gist
Thanks for this. Unfortunately, I am currently travelling and will not have access to my Arduino's for another week. Will test them once I am get home.
no problem, hope you're going somewhere nice!
i've tested with a breadboard 328p with usb uart and it works fine there too, so should be the same as an uno.
i've made a new branch with the new python reset script and the changes to docs/packaging for people to test:
@sej7278 Wow! Thanks. Can't wait to get back home to test this.
In exaactly one year before that last post from "sudar" I'm facing the same problem: I need to reset the board by hand while the command sudo make upload is starting. I made it work in that way, and the code was uploaded. However the led is not blinking.
I'm using arduino-core and Arduino.mk from the official repositories from Linux Mint 17.1. for the Leonardo's board.
Any ideas?
Connecting to programmer: . Found programmer: Id = "CATERIN"; type = S Software Version = 1.0; No Hardware Version given. Programmer supports auto addr increment. Programmer supports buffered memory access with buffersize=128 bytes.
Programmer supports the following devices: Device code: 0x44
avrdude: AVR device initialized and ready to accept instructions avrdude: Device signature = 0x1e9587 avrdude: reading input file "build-leonardo/CortinasArd.hex" avrdude: writing flash (1060 bytes): avrdude: 1060 bytes of flash written
avrdude: safemode: Fuses OK (H:CB, E:D8, L:FF)
avrdude done. Thank you.
@fjrg76mx need much more info than that - like the full arduino-mk output and your Makefile.
also have you tried using arduino-mk from git, what version is in mint 17.1 - if its based on ubuntu 14.04 then its 1.3.1 which is over a year old, if you look at the comments above, you'll see that we didn't even merge the fix until 1.3.2
if you want a (debian) package then try this, build of 1.3.4-2, its only a few weeks old, or get 1.3.4-1 from the ubuntu utopic or debian jessie repositories.
i still find i get reset problems with atmega32u4 chips, even with the official ide, often a reboot helps, i think dbus or something gets confused with all the unplugging of usb devices.
p.s. just add your user to the dialout group, you shouldn't be using sudo just to upload to a serial device.
When I try and upload to an Arduino Micro from a Raspberry Pi I get the following error:
I have poked around as much as I can and I'm not sure whats going on here. Other programmers such as ino work fine, but I'd rather using the Arduino-Makefile project if I can since it seems easier to update and manage.
Any ideas?