EDIT2: Reflashed the yunshield but still no luck
EDIT1: I did some mods I also did on yun and They might be the root cause of the failure. I'll get back
Hi
I tested the yun shield with a due and I fail to upload.
I used
windows 10
Arduino IDE 1.6.9
sam package 1.6.8
yun firmware "This Yún runs a version of OpenWrt-Yun built on May 10, 2016"
The error I get is
Sketch uses 25,452 bytes (4%) of program storage space. Maximum is 524,288 bytes.
/usr/bin/run-bossac -i -d --port=ttyATH0 -U false -e -w -v -b /tmp/sketch.bin -R
Send auto-baud
Set binary mode
No device found on ttyATH0
done: Success
/usr/bin/run-bossac -i -d --port=ttyATH0 -U false -e -w -v -b /tmp/sketch.bin -R
Send auto-baud
Set binary mode
No device found on ttyATH0
done: Success
the Due is a special case because before uploading a new sketch you need to erase the flash (this is autmatically made in USB upload and there is an erase button on the board for fail safe operation).
For triggering the erase in remote upload with the Yun Shield you need to put as first instruction of the sketch a special function called "checkForRemoteSketchUpdate()"
As you can see in this example:
So I suggest you to upload this sketch using the USB port (either Native or Programming) then try again a remote upload of another sketch including the "checkForRemoteSketchUpdate()" function.
Thanks for the feedback, we are going to improve the documentation in the next hours.
Hey Jantje,
Is the checkForRemoteSketchUpdate() everything you changed?
I'm experiencing the same problem - bossac says "No device found on ttyATH0", even with checkForRemoteSketchUpdate().
I think it is successfully instructing the Due to delete the flash (the firmware seems to be gone afterwards), but still no luck getting bossac to flash the new one...
Once you uploaded a sketch without the checkForRemoteSketchUpdate() you no longer can upload remotely.
So you need to upload a sketch containing checkForRemoteSketchUpdate() directly via com port.
Note that if the bootloader is no longer on the due you will have to burn a bootloader to the due first.
Yeah, the sketch runs checkForRemoteSketchUpdate(), but I still get the "device not found" error.
root@Arduino:~# /usr/bin/run-bossac -i -d --port=ttyATH0 -U false -e -w -v -b /t
mp/firmware.bin -R
Send auto-baud
Set binary mode
No device found on ttyATH0
done: Success
It seems like the flash actually gets deleted, since the microcontroller doesn't seem to have any firmware afterwards. (I then flash it again via the programming port...)
Is there any way to tell if the bootloader is gone? I thought that's hardwired into the Due...
Is there any way to tell if the bootloader is gone?
If you can upload via com port the bootloader is there.
Unfortunately there are 2 usb ports on the due and I'm not so known with this part of the story.
The bootloader was indeed gone, so I had to restore the Arduino firmware via programming port. (subsequently, the native port worked again).
However, still no luck with bossac. The flash-wipe via pin7 / checkForRemoteSketchUpdate() works, but bossac still complains about not finding a device on /dev/ttyATH0
I already commented out the console line on inittab, and as far as I can see the run-bossac script kills any processes open on /dev/ttyATH0
Does this mean there is a console on ttyATH0 open after all that might interfere with bossac? Any ideas of how to close it?
I'm trying to establish communication between the shield and Due, e.g. just receiving Serial messages from the Arduino via cat < /dev/ttyATH0 - but also no results. (I'm using Serial class on the Arduino for that. Is that right? Or should it be SerialUSB / Bridge?)
Does the Yun Shield communicate via SPI or pins 0 / 1 (Tx / Rx)?
Some more thoughts:
Are you sure the bootloader on the Due is the issue? From the Due documentation:
"The bootloader is preburned in factory from Atmel and is stored in a dedicated ROM memory."
I believe that when the flash is erased I can upload via the programming port, but not via the native port. (Native port upload is restored, when a sketch runs)
The run-bossac script together with checkRemoteFirmwareUpdate() successfully deletes the flash.
Everything seems to be working, except that bossac can not find any device on /dev/ttyATH0... Seriously, not sure what to test / try next.
So simple Serial communication to / from Arduino Due with cat works now, thanks to changing the baud to 9600. (I also had the sketch Serial.begin still running at 9600...).
The only mysterious player is still bossac.
Sketch definitely successfully runs updateRemoteFirmwareUpdate() when instructed by run-bossac via pin7
normal communication to /dev/ttyATH0 works
but bossac consistently gives this output
root@Arduino:/usr/bin# run-bossac -i -d --port=ttyATH0 -U false -e -w -v -b /tmp/firmware.bin -R
Send auto-baud
Set binary mode
No device found on ttyATH0
done: Success
(The last done: Success comes from the reset-serial command in the run-bossac script). Very frustrating and strange.
is definitely in the sketch, as the first line in setup().
Indeed, that is why after running run-bossac, the flash is successfully erased, since the shell script sets pin 7. (Doesn't happen without checkFor...).
[On a side: It's a bit strange to me that it is indeed required, since you should also be able to read from the flash using bossac.]
This is the definition of checkForRemoteSketchUpdate:
#if defined(ARDUINO_ARCH_SAM)
void checkForRemoteSketchUpdate(uint8_t pin) {
// The host force pin LOW to signal that a new sketch is coming
pinMode(pin, INPUT_PULLUP);
delay(50);
if (digitalRead(pin) == LOW) {
initiateReset(1);
while (true)
; // Wait for reset to SAM-BA
}
// Restore in standard state
pinMode(pin, INPUT);
}
So the magical line is the "initateReset", but haven't found the declaration yet.
So the magical line is the "initateReset", but haven't found the declaration yet.
That is in core/Reset.cpp
I think the thing you are looking for is
void banzai() {
// Disable all interrupts
__disable_irq();
// Set bootflag to run SAM-BA bootloader at restart
const int EEFC_FCMD_CGPB = 0x0C;
const int EEFC_KEY = 0x5A;
while ((EFC0->EEFC_FSR & EEFC_FSR_FRDY) == 0);
EFC0->EEFC_FCR =
EEFC_FCR_FCMD(EEFC_FCMD_CGPB) |
EEFC_FCR_FARG(1) |
EEFC_FCR_FKEY(EEFC_KEY);
while ((EFC0->EEFC_FSR & EEFC_FSR_FRDY) == 0);
// From here flash memory is no more available.
// BANZAIIIIIII!!!
const int RSTC_KEY = 0xA5;
RSTC->RSTC_CR =
RSTC_CR_KEY(RSTC_KEY) |
RSTC_CR_PROCRST |
RSTC_CR_PERRST;
while (true);
}
I don't know how it does it but it forces a reset.
I am also trying to use the DUE with the Yun board, but I am not as far as you with the task.
I am still trying to figure out how to include the BOSSAC into my distribution for the yun.
I am using a Dragino Board, thats the same like the Yun Shield.
Can you please provide me a link for an installation package to run BOSSAC on the Yun shield.