LowPowerLab Forum

Hardware support => Moteino => Topic started by: stewl on December 23, 2013, 03:29:53 PM

Title: Leo running a sketch - can't reset or change the sketch
Post by: stewl on December 23, 2013, 03:29:53 PM
Hi Felix -

I have two Leos. One is running a node sketch that sends data wirelessly to the gateway Leo.
The gateway Leo's sketch is running and returning an ACK to the node, and both units are flashing the LED, only when data is received or transmitted.
But something has happened to the gateway Leo:
It appears to be running as expected, except the serial monitor is not working as it was for this sketch - nothing is displayed.
It was working a few days ago, sending the received data to the serial monitor.
After it stopped showing the data, I tried resetting the Leo by connecting the reset pin to both the + 3.3V pin  and to the ground pin - (since I wasn't sure which was needed I tried each in sequence), both thru a 1K resistor, and held that connection for a long time. Afterwards, the sketch just resumed running.
I tried to upload a new simple test sketch to the unit to try just a Serial.print. It compiled OK, but ran into a problem when trying to upload:
Found programmer: Id = "Sxa"; type = p
    Software Version = v. ; Hardware Version = v.
avrdude: error: buffered memory access not supported. Maybe it isn't
a butterfly/AVR109 but a AVR910 device?

Also, there was some com port problem: the Arduino GUI gave me 2 choices for the port, COM1 & COM3,
but the laptop's device manager said the Leo was on COM4. I tried closing the GUI & restarting it with the same result.
I then uses the device manager to assign the device to com3. After that I received the above error message when attempting to upload the sketch.

I did remove & apply power the the Leo a few times.

I tried the working node unit, attaching it to the microUSB and it was fine, showing the expected output on the correct COM port in the serial monitor.

So is this Leo essentially dead, since resetting it had no effect,  and it can't be reprogrammed?

I am intrigued that it does continue to run a sketch, even though it will not reset, and can not be reprogrammed, and it does not send data to the serial monitor, it blinks and does send the ACK wirelessly to the node.

Stew


Title: Re: Leo running a sketch - can't reset or change the sketch
Post by: Felix on December 23, 2013, 03:55:09 PM
Stew,
This is not really a hardware problem. I've ran into this many times with the atmega32u4. I think the USB stack in the bootloader is not exactly stable and can be locked or corrupted depending how you program the device. I don't have an exact answer to what the issue is but this is one big reason why I stopped making the Leo based on the atmega32u4. The problem is that the caterina bootloader shares the USB stack with your program. So the hardware USB serial port uses CPU time which can be messed up depending on the loaded sketch. That's my best determination after many hours of trying to get to the bottom of this and giving up. Hence no more Leo. It's really not Leo's fault, but the Caterina bootloader USB implementation's fault as far as I can tell. Google this same issue or "Arduino Leonardo device not recognized" and you'll get thousands of results...

I am sure the unit is ok hardware wise. It can be erased & re-bootloaded with the original Caterina bootloader and those issues will go away. By the way reset has to be pulled LOW (gnd) to reset the unit, don't really need a resistor either.

Howevedr if the bootloader is still intact it should be able to reload a sketch. But you have to be very quick. Reset the unit - then after this reset it will show up as a COM port in your computer, but ONLY while in the bootloader (a few seconds at most). Then it craps out and disappears and you cannot load the sketch anymore. So in that split timeframe you can catch it in Arduino IDE, select the COM port and click upload (try a blinky sketch). To save time, precompile the sketch, and also try to select the COM port in a previous attempt - ie reset the unit and have the IDE ready to select the COM port. Then on a second reset (the COM port should be the same) quickly click upload. I was able to resurrect my Leos this way. On a few of the early attempts I didn't know what else to try and just erased and re-bootloaded the Leo and the issues went away.

Note - the COM port emulated in the bootloader != COM port that should be emulated outside of the bootloader.

Hope this helps...