3

Running Ubuntu 12.04.4 LTS (64 bit) I try to upload my code to the Arduino Due through the Native port. I have tried both the bossac that ships with the Arduino IDE (which is a modified version of BOSSA), and the master BOSSA branch.

Running this command:

sudo ./bossac -p /dev/ttyACM0

I get this error:

No device found on /dev/ttyACM0

However, it works perfectly inside the Arduino IDE.

What can the problem be?

Friend of Kim
  • 1,493
  • 3
  • 16
  • 16

3 Answers3

5

from the IDE's menu you can activate the verbose upload (and compile) mode, that will print all the command executed; Probabibly what you miss is the necessity to open the serial at 1200baud, that will trigger the reboot and consequent bootloader's start ont DUE chip, and bossac need to find the bootloader. see autoReset

edit: i've now a pc with a physical Serial, so i've tryed to upload in verbose mode:

Sketch uses 10,380 bytes (1%) of program storage space. Maximum is 524,288 bytes.
Forcing reset using 1200bps open/close on port /dev/ttyS0
/home/xxx/arduino-1.5.6-r2/hardware/tools/bossac -i -d --port=ttyS0 -U false -e -w -v -b /tmp/build8035422101690460839.tmp/sketch_apr14a.cpp.bin -R 

as you can see he is resetting the board by opening the serial at 1200, forcing the bootloader to start. You have to do the same on your script befor launching bossac. How this can be done depends on your OS

Please note that the reset is triggered by the 8u2 chip used as USB to serial adapter on the arduino board, so bypassing it by connecting through tx/rx pin (like using your own conversor, like in my example with hardware serial) won't work unless you do a manual reset at the right time

Lesto
  • 761
  • 3
  • 10
  • I can't see what it's doing because there are too many lines outputted. The first lines where it's calling BOSSA are being clipped away. – Friend of Kim Apr 14 '14 at 19:01
  • I found a way. Press the upload-button while in the middle of uploading. It will fail, and will not output too many lines anymore. I'm going to try it out now. – Friend of Kim Apr 14 '14 at 19:03
  • you can also try with a non-due (or a physical serial port with nothing attached) – Lesto Apr 14 '14 at 19:10
  • I believe the problem was either the command line arguments, or that the board needed to be reset before connecting to it. I can't connect to it through the master bossash.exe, so it seems they've changed something on the Due rendering the master BOSSA useless. I don't quite know yet, but I'll try to leave a comment later when I've figured it all out. – Friend of Kim Apr 14 '14 at 19:14
  • edited my answer, as expected the reset opening theserial port with a baudrate of 1200 is a foundamental passage. Also please note that the bootload probably as a little timeout, so you have to script the execution of reset + upload to make it in the time slot. – Lesto Apr 14 '14 at 19:19
  • Does it reset when connecting with 1200 because of some code written by Arduino? If I were to program the Due without the Arduino library, would this method stop working? Is the Arduino Bootloader which runs automatically saved to a different memory than the code we normally flash to the chip? – Friend of Kim Apr 14 '14 at 23:10
  • no special code needed, just opening the serial at 1200baud is fine, and yes, bootloader live in a special area, like in the UNO! Util you get that reset working, you can program using wathever you want – Lesto Apr 14 '14 at 23:43
  • Hmm, how does it know the serial is opened at 1200 baud? Isn't this a number both parts have to know on before hand? – Friend of Kim Apr 15 '14 at 22:28
  • automatic baudrate discovering is possible. Btw you are forgetting that this is a virtual serial over USB, some trick may apply. see /hardware/arduino/sam/cores/arduino/USB/CDC.cpp – Lesto Apr 15 '14 at 22:34
  • Okay, I'm able to upload it now. The problem is just that after the upload, the Arduino doesn't restart, and it isn't possible to connect to it without rebooting the computer. – Friend of Kim Apr 16 '14 at 15:47
  • rebooting the computer?? just disconnect/reconnect the USB does not work? do you close the serial connection? – Lesto Apr 16 '14 at 15:51
  • My mistake. Rebooting the computer worked only once. Now even the Arduino IDE does not recognize it using the native port. It finds the Due on the programming port, but cannot upload code with it. Yes, I have closed the connection. – Friend of Kim Apr 16 '14 at 15:58
  • that's another kind of issue, i think. Developer usb works but not user? How are you compiling code? Des the pc detect the usb? – Lesto Apr 16 '14 at 16:06
  • The PC doesn't detect the USB when connected directly to the SAM (native), but is recognized when connected to the programming port. All using the Arduino IDE, it cannot upload code through the programming USB. Might there be something wrong with the Arduino Due? When connecting RESET to GND, nothing happens. – Friend of Kim Apr 16 '14 at 16:08
  • let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/13936/discussion-between-lesto-and-friend-of-kim) – Lesto Apr 16 '14 at 16:11
  • Sorry, but this answer is fundamentally mistaken. Opening the port at 1200 baud specifically **cannot do anything** for a true serial port as listed here. That's only "magic" with a USB serial device, where the baud rate is a parameter communicated to the hardware. But on many configurations, merely opening a (real or USB) serial port *will* change the state of control lines which can be wired to trigger a reset. – Chris Stratton Nov 11 '14 at 17:17
  • @ChrisStratton my answer stand as he is opening a ttyACM0 witch IS acm driver (virtual serial over usb), and the usb driver on the due has been scecifically written to use that as a reboot request. Strange but true: see the "programming" at http://arduino.cc/en/Main/arduinoBoardDue – Lesto Nov 11 '14 at 17:47
  • I'm aware of the special casing - but it does not apply here. Your answer is erroneous, as **in your answer** you are, by both description and quoted command, access a true serial port /dev/ttyS0, rather than a USB one. What you are proposing will not work for a true serial port. – Chris Stratton Nov 11 '14 at 18:12
  • I see. This is because that output is from arduino ide, and because i didn't had a Due i told the ide to use the hw port. I now i get what you say, and I'll point this out – Lesto Nov 11 '14 at 18:24
  • Your description and example command still references a hardware serial port where that trick will not work. – Chris Stratton Nov 11 '14 at 18:36
  • Fixed, i think. Feel free to edit if you dont like it – Lesto Nov 11 '14 at 18:46
3

Easiest way I've found to do this purely from the terminal:

stty -f /dev/cu.usbmodemfa121 1200;stty stop /dev/cu.usbmodemfa121;./bossac -i -d --port=tty.usbmodemfa121 -U false -e -w -v -b Blink.cpp.bin -R

Swap out the serial device for whatever /dev you are using; in Linux you may have to sudo to get direct access to the device. This is assuming you are in the directory where bossac lives and your .bin file is there too. Adjust to suit your needs. If using the native USB port you should change -U to true

Dana Coe
  • 31
  • 1
1

The Arduino CLI uses a slightly different version of bossa from the one that is on master:

https://github.com/shumatech/BOSSA/tree/arduino

On Linux, I was able to do the following:

$ git clone git@github.com:shumatech/BOSSA.git
$ cd BOSSA
$ make bin/bossac -j4
$ stty -F /dev/ttyACM0 1200
$ ./bin/bossac --port=/dev/ttyACM0 --force_usb_port=true -e -w -v -b /path/to/my/firmware.bin -R

(I got the answer from this Arduino forum thread.)

Adam F
  • 111
  • 3