The Arduino bootloader is only active for a short period after a reset. You can force that by toggling one of the tty control lines, which is what the various loaders do before running avrdude.
For real arduino’s, hitting the reset button works fine. The Arduboy doesn’t have a reset button, so you have to power cycle - which also causes the USB devices to be reset, which can cause the serial port to change if the PC doesn’t shut down the old device before the new one is set up.
Personally, I power off the Arduboy, set up the command line, make sure the old serial device is gone, power on the arduboy and hit enter. That works pretty reliably for me.
I’ve tried with both the avrdude.exe the Arduino IDE uses in AppData and the avrdude.exe that comes bundled with the Arduino IDE.
(I suspect it’s just copying that one into AppData anyway, or something obscure. The Arduino IDE seems to use AppData as scratch space.)
And I’m glad you mentioned it because it seems using the reset button with proper timing got avrdude to work. Seems doing it too much in quick succession does leave the old COM port occupied, but it’s pretty predictable. On my computer at least, the Arduboy only ever occupies one of two COM ports.
It seems that setting up the command line, resetting the arduboy and then pressing enter does the trick (assuming the COM port is right).
It works for both the version bundled with the IDE and the one living in AppData.
I suspect the process on a Mac will be much the same.
Ah, so Windows apparently expands this stuff after the invocation instead of before. But I didn’t have the verbose output to look at.
It should be searching them in order, which - if you’ve got nothing else plugged in - means you get the first one, and sometimes the second one. The Mac tends to use long messy names; both my Arduboy and Leonardo show up as /dev/tty.usbmodemFD131; if I plug them both in at the same time the second one becomes /dev/tty.usbmodemFA121. Not sure what’s going on there.
BTW, another - possibly easier, depending on how hard it is to find the arduino command - way to get the command line if you’ve got Arduino installed is to run “arduino --upload --board arduino:avr:leonardo --verbose --port” followed by the serial port and a .ino file. Unfortunately, the command line doesn’t support just uploading a .hex file.
I think the IDE is purposely feeding it an absolute path, if it was splatting the %APPDATA% environment variable into the command line I think it would show up as %APPDATA% in the verbose output (I think, %APPDATA% is not exactly something I have to deal with often). I can’t be bothered to check the IDE’s source code to find out what’s actually happening. Whichever way round it is, the result is the same.
Theoretically, but if that is the case I don’t know what happened to COM1, COM2 and COM3 because they never get used by the Arduboy and they don’t register as being in use by anything else.
Good to know. I won’t add it to the list as this thread is aimed at specifically uploading .hex files. If there’s ever a thread on performing command line magic though, that’ll be a good one to bring up.
Or anything else, for that matter. I think it’s a compatibility thing - pretty much every early PC I used had COM1 & COM2 as motherboard serial, and COM3 as a modem. I recall cursing at DOS software that assumed that the first free COM port was COM4 on systems that had more than those 3 in them. Possibly those are still reserved for specific hardware ports, so not available virtual serial ports. MS has always been careful about backwards compatibility.
Closing then opening the port specifically at 1200 baud is what triggers USB based Arduinos to jump into the bootloader and await commands (normally to do an upload). (In actual fact, the Arduino is looking for the port to be set to 1200 baud and the DTR signal to be toggled.)
So yes, you have to reset the Arduboy by doing the above before you can use avrdude to perform an upload. Otherwise you have to manually reset the Arduboy using the reset button.
DTR is not relevant for Arduboy (and Leonardo, Micro and Pro Micro). Opening and closing a com port at 1200 baud is what resets it and causes the arduino to go into bootloader mode.
The com port also changes in bootloader mode on Windows (usually one port lower then in normal mode). This is because the bootloader uses a different USB VID (Vendor ID) and PID (Product ID) combo then in normal mode. (Windows registers and reserves a com port for a newly connected USB serial device based on its VID PID combo)
And what exactly is meant by “opening and closing” a serial port? It’s normally DTR being active or inactive that indicates a port is open or closed. That’s what the Arduino USB code looks for. See Arduino core file CDC.cpp
Not under Linux. On my Ubuntu system the port stays on /dev/ttyACM0 both before and after the reset.
I’ve actually started making a simple set of batch files to make uploading .hex files via avrdude easier. It’s fiddly because of batch’s weird quote mark rules, but I’ve got a basic version working where the command is reduced to UploadHex.bat COM5 file.hex (after running Setup.bat and telling it where avrdude.exe is and making sure avrdude.exe can find avrdude.conf).
It’d probably be easier in powershell, but I’m guessing most people don’t have that in their %PATH%, and I can always do that later.
I’m pretty sure I have one or two versions of Python somewhere either fully or partly installed (I tend not to get on very well with things that use makefiles). I could have done a version using Lua, but I opted for batch because all versions of Windows prior to 10 use batch for scripting by default so if anyone wants to use it they don’t have to worry about installing anything.
Only if it was installed by the installer though.
I used the zipped copy purposely to avoid registry changes.
I could make the script attempt to look for the key before asking though. I’ll put that on my todo list, but I probably won’t rush to do it yet, I have other more urgent projects.
Yep - it happened. I got my Kickstarter Ardventure download, but I have no way of uploading it from my Mac. After all of this, does anyone have a clear set of steps to follow to upload a .hex file to the Arduboy from a Mac?