Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bugfix for garbage data coming from serial port after reset. (Arduino Due) #1267

Merged
merged 2 commits into from

6 participants

@cmaglie
Owner

After reset garbage may show up from Serial port due to a firmware bug on the atmega16u2.

Here the relevant forum topic:
http://arduino.cc/forum/index.php/topic,134847

Here the updated .hex for the 16u2:
https://github.com/arduino/Arduino/blob/976f7588b7f68bd3c5fce52c15ccfe738589085a/hardware/arduino/sam/firmwares/atmega16u2/Arduino-DUE-usbserial-prod-firmware-2013-02-05.hex

Please check if the updated firmware fix the issues and report back here.
Thanks.
C

@ghost

atmega16u2 is not known with latest macports package http://www.macports.org/install.php#pkg version 0.5.4 even if using latest Xcode 4.6 running with Mac OS Lion.

Maybe it is works on PC or Linux but right now, if really the DUE has the atmega16u2, can't erase it neither flash new firmware on the USB chip from a Macintosh.

Please communicate another erase and flash DFU programmer running on Macintosh.

@PeterVH

I tested the firmware with Albert's test program. I run linux 3.0.0. The test program seems indeed to work (per the description in the aforementioned thread) with the 2013-02-05 and not with the 2012-11-05 firmware.

If I slide any other then the two leftmost bars, the crc error led briefly lights up. But I guess that is normal, because I see the same behavior if I modify the sketch to use the native usb port. Albert, can you confirm this is normal? Can you also post the java code for the gui?

Speaking of which, on the native port (ide 1.5.2), after some time the crc err lights up. I will test with Stimmer's version that reportedly works correctly with this test.

@cmaglie: the fix seems to just reset the Due a little bit longer. Can you explain why this fixes this problem or the problem of garbage sent after reset?

@ghost

Hello PeterVH,

Thanks to have made these tests. I'm still waiting for ISP mega-due shield spec from arduino team so I could actually upload the new firmware.

I've created very lately a github account, made a fork from Alvaro initial SerPro and hopefully, will publish soon the IDE along with java sources, just need to verify some legal issues on java part since it is using USB libraries.

Wether you've my java sources or not, I can comment your results.

If you do not slide any GUI's sliders (two sliders on left of timer's check box or multiple sliders on right of timer's checkbox), the crc-LED should never light neither the Link-LED should never light. Only when you slide them, briefly the crc-LED or LinkUp-LED will briefly light per your your hand movement.

About stimmer test 1, namely to hold reset then stop, it does work on my side with old firmware but i do not consider fully working because the LinkUp-LED and CRC-LED do stay faintly light up even though i admit the java GUI correctly received some internal parameters from arduino (Full H-brdige PWM frequency, duty cycle, boost-buck parameters,...). This specific lighting is really faint, you need to look in front of LED's but again, they should NOT light up at all if no GUI sliders action.

As for using native USB after a while light-up crc-LED, this is not normal. Please remember that if you do NOT use any sliders, the crc-LED is a real 16-bit CRC inspecting any frame errors included in the HDLC protocol supporting the serial-deserail SerPro protocol. If it lights up then USB still has a problem for sure !

@cmaglie
Owner

@PeterVH
The old fimware asserts reset when ResetTimer is between 25 and 1. When DTR was detected the variable ResetTimer was set to 30 that leads to a little time with no reset (30 to 25) and a reset (25 to 1). This was not a problem if the DTS signal is set once, but for some strange reason the RXTX library toggles DTR many times during port setup. This has the side effect to assert reset many times due to the small time with no reset (30 to 25).

So the issue was not on the length of the reset, but on the fact that the reset sequence started from 30 and not 25.

I don't know if my explanation is clear, the issue was really tricky to solve...

@selfonlypath
The tutorial to reburn the 16u2 is almost ready!

C

@hektoven

Hello Everybody,

do anaone know if the same problem with garage data or old data on serial bus could happen on arduino mega too?

I still get old data in my serial bus from arduino after a few readlines the new datra arrives. Flush of inputbffer and outputbuffer on host side did not solve the problem....

best Kai

@Fede85
Collaborator

Hello, this is the tutorial for uploading the firmware on the 16U2 using an Arduino Uno/Mega as AVR-ISP programmer: http://arduino.cc/en/Hacking/Upgrading16U2Due

kind
F

@ghost

@hektoven
I happen to own and use mega 1280, mega 2560 rev 2, mega 2560 rev and due, all bought directly to arduino company so no 2nd source manufacturing with possible components issue.

Personally, I tend to suggest using my ElectroShaman SerPro GUI in RX/TX mode with any arduino because it covers so many cases of USB protocol since based on HDLC and so.

As of today, it works fine with all the arduino mega's revision wether 1280 or 2560 so I would rule out any USB garbage issue. I do notice much less efficiency with mega 1280 and sometimes freezing which do not occur with mega 2560's.

@Fede85
Thanks a lot for the tutorial, i'll make the firmware update soon and will let's know if it pass or fail ElectroShaman SerPro heavy duty testing.

Albert

@reppr

Thanks for the docu.

Typo in "The Arduino Due will took power from the Arduino Uno ...":
s/took/take/

@ghost

I'm starting to apply the firmware update between my mega and my due but noticed that http://arduino.cc/en/Hacking/Upgrading16U2Due requires pin 10 as SS to connect Due's ICSP.
Please confirm this pin allocation because I would taken instead pin 53 on mega ?
Thanks, Albert

@ghost

Another thing about locating avrdude then launch it from Terminal shell, I'm using a Macintosh where I only see arduino.app
Please be more specific, how can I find the avrdude because I can't get inside the arduino.app packet via Terminal shell

@ghost

OK I've found the trick to call from Terminal Shell avrdude from a Mac
/folder-hosting-arduino/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude

About mega SS-SPI signal, I really think the tutorial should mention pin 53 where for UNO, it is indeed pin 10

Will let you know the result of flashing the firmware

@ghost

aie aie aie... Something must have gone wrong, my Due's USB is not recognized or seen anymore by Arduino IDE :(

Here is what I did from a Terminal Shell where before launching that command, I did load arduinoISP sketch into my mega 1280 then connected the 6 wires per the tutorial...

new-host-3:desktop selfonlypath$ /Developer/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Developer/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -c arduino -P /dev/tty.usbserial-A6008igj -b 19200 -p m16u2 -Uflash:w:16u2.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9489
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "16u2.hex"
avrdude: writing flash (4314 bytes):

Writing | ################################################## | 100% 5.27s

avrdude: 4314 bytes of flash written
avrdude: verifying flash memory against 16u2.hex:
avrdude: load data flash data from input file 16u2.hex:
avrdude: input file 16u2.hex contains 4314 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 3.21s

avrdude: verifying ...
avrdude: 4314 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

new-host-3:desktop selfonlypath$

@PeterVH

It looks like it worked ok though.
Did you remove the wires? You should either remove the wires or also power the mega. Personally I power both the mega and the due via usb and leave away the connection between the 5V of both boards.

@ghost

Well glad to have confirmation the new firmware has been flashed correctly but hey guys, you need to help me because for whatever reason, my arduino DUE cannot download anything from the IDE !

About powering modes, i'm a bit new to these ISP stuff so just did per the arduino tutorial, namely connect both 5V and GND from my mega to the due, the mega receiving power from my Mac via USB.

Please note that I've not saved the previous firmware, in fact I would have not known how to do it so now I'm really stuck :(

@PeterVH

> ...so just did per the arduino tutorial, namely connect both 5V and GND from my mega to the due
That is ok. But I meant, afterwards, when you tried to upload sketches to the due, did you remove the connections to the mega? (sorry if this questions sounds obvious). If not, the atmega16u2 mght be kept in reset by the connections to the mega.

> ...Please note that I've not saved the previous firmware.
No problem. It is in your arduino-1.5.2 directory, here: hardware/arduino/sam/firmwares/atmega16u2/Arduino-DUE-usbserial.hex.

@ghost

Frankly i don't remember what I did withe wires after the avrdude flashing was done.

Maybe i can try again to flash the new firmware and you teach me precisely what wires disconnection, powering down has to be done, IDE disconnected... Maybe more details of the global procedure described in the tutorial.

P.S. Good to here I can recover the previous firmware but I guess in all cases, one has to teach me exactly all the steps to properly de-power, disconnect wires...

Thank you in advance

@PeterVH

Remove all 6 isp wires from the due (and remove everything else connected to the due).
Hook up the due to your pc via the usb programming port.
Can you upload sketches, now?

@ghost

When should I remove the USB generating power to mega then routing 5V and GND to due ?
What is still not clear to me, the wires removal and USB-power removal of mega and due to prevent any USB hang up

@PeterVH

The firmware upload succeeded. I think the due will work if you connect it to your pc with nothing else attached to it. I want to be sure about that before doing further trouble shooting.

@ghost

Please find my new attempt with details on each step, maybe i'm doing something wrong

Building the 6 wires between Due and mega...
ONLY powering mega via USB of my MacBook Air
Download ArduinoISP sketch using IDE 1.51. into mega NOT being connected to DUE
Quit IDE where mega still USB powered from MacBook Air
Disconnect USB so NO power on mega
Connect 6 wires between DUE and MEGA
Reconnect MacBook Air's USB to mega so now both mega has power and DUE receives power FROM mega
Open Terminal shell then launch avrdude to flash new firmware

new-host-3:desktop selfonlypath$ /Developer/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Developer/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -c arduino -P /dev/tty.usbserial-A6008igj -b 19200 -p m16u2 -Uflash:w:new-16u2.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9489
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "new-16u2.hex"
avrdude: writing flash (4314 bytes):

Writing | ################################################## | 100% 5.28s

avrdude: 4314 bytes of flash written
avrdude: verifying flash memory against new-16u2.hex:
avrdude: load data flash data from input file new-16u2.hex:
avrdude: input file new-16u2.hex contains 4314 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 3.22s

avrdude: verifying ...
avrdude: 4314 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

new-host-3:desktop selfonlypath$

Disconnect USB from MacBook Air so mega does not receive power implying DUE does not receive power from mega
Disconnect 6 wires between mega and DUE
Connect directly DUE to MacBook Air USB
Launch IDE 1.5.1
Arduino DUE is correctly powered but its serial USB is NOT shown on IDE so I cannot download anything

@ghost

OK here is the situation, i've recovered the OLD firmware per PeterVH instructions then applied same step by step above instructions and USB works from IDE again... See below firmware log so I think the new firmware has a BUG or something preventing USB to work

new-host-3:desktop selfonlypath$ /Developer/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/avrdude -C/Developer/Arduino.app/Contents/Resources/Java/hardware/tools/avr/etc/avrdude.conf -c arduino -P /dev/tty.usbserial-A6008igj -b 19200 -p m16u2 -Uflash:w:old-16u2.hex:i

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x1e9489
avrdude: NOTE: FLASH memory has been specified, an erase cycle will be performed
To disable this feature, specify the -D option.
avrdude: erasing chip
avrdude: reading input file "old-16u2.hex"
avrdude: writing flash (4352 bytes):

Writing | ################################################## | 100% 5.30s

avrdude: 4352 bytes of flash written
avrdude: verifying flash memory against old-16u2.hex:
avrdude: load data flash data from input file old-16u2.hex:
avrdude: input file old-16u2.hex contains 4352 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 3.23s

avrdude: verifying ...
avrdude: 4352 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done. Thank you.

new-host-3:desktop selfonlypath$

@ghost

OK finally great news, i've found why it did not work with new firmware and did work with old firmware.

It seems an issue with Apple's Textedit so I've noticed different encoding on old firmware as published by arduino team and how I constructed the new firmware, namely it made a RTF instead of Occidental (Mac OS Roman). So I took old-firmware.hex then copy pasted inside the new firmware, of course downloading firmware from Terminal shell did work, it does not care the encoding.

Now i've downloaded my ElectroShaman simplified IDE and simplified java GUI, the USB-SerPro link establishes correctly except a few details: RX and CRCerror LED's are BOTH faintly lighting

This seems to not affect the proper LED's response to GUI's sliders change but I suspect still an USB garbage issue because obviously, I've no problem of 5V or 3.3V or drivers feeding 1K resistor in serie with LED under sink mode.

Many thanks for your help and let me know if ElectroShaman can help confirm or infirm some remaining USB issues even though thanks to the new firmware, things work much better in my private lab using DUE. So I let you guys decide if the ElectroShaman and SerPro using HDLC and serializer-Deserializer higher protocol are reliable. I would conclude some USB data garbage still manifest once in a while because CRCerror computes a 16-bit error detection so some frames are corrupted then re-send and finally get through.

Albert

@PeterVH

Funny, if I add a a blank line anywhere in the hex file e.g at 10% or at 70% of the file, I get the same flash size reported by avrdude as in your first posts: "4314 bytes of flash verified".
Well, you're up and running again, that is what counts.

@PeterVH

> ...USB-SerPro link establishes correctly except a few details: RX and CRCerror LED's are BOTH faintly lighting
I see another behavior;
When sliding the two leftmost sliders: linkup led + rx + tx leds light up.
When slidng any other slider: crc error led + rx +tx leds light up.

In the latter case, I can't believe these are real crc errors (it happens every time). I'll have a look in the sketch.

> let me know if ElectroShaman can help confirm or infirm some remaining USB issues
I think a minimalist serpro sample (say with 1 slider) app that sends and receives some data and lights a led on crc errors is indeed a good tool to test serial communications.

@ghost

@PeterVH Let me clarify, there was clearly a firmware issue with so much USB data garbage that SerPro would never establish RX-TX link between ElectroShaman GUI and arduino. That part is now solved thanks to the new firmware provided by Cristian.

When you slide leftmost sliders or any other sliders on right, my IDE is setup in a way to reflect these actions with either LinkUp led or CRCerr led. This works fine now where of course, it is normal or functional to have faint lighting of Rx led and Tx led. These Rx and Tx just visualize some date communication, namely sliders value being transferred.

Now I can assure you that if you do NOT move any sliders then, the RX and TX led should stay OFF, that is the case if you port SerPro with arduino UNO, arduino MEGA and partially true on arduino DUE. With DUE, the RX and CRC led are faintly ON so this is result of small garbage USB data !!!

If you happen to have an arduino MEGA, please try my sketch and see by yourself !

Maybe there is another explanation because I've just used my tektronix tek2445 (4 channels at 150 MHz) to actually probe all the led's activity while sliding, not sliding GUI. It is true their voltage reflects what the SerPro protocol sees, namely even if CRCerr and RX led are faintly lighting ON, their respective arduino pin's acting as a sink indicates NO activity. Not sure about arduino pin's driver max mA or technology compared to arduino mega, maybe there is specific driver affecting pins 28 and 32 but not affecting pins 24 and 36 !

It would be interesting to understand why these 2 led's among the 4 are not correctly working or displaying the SerPro communication status, USB data garbage or just pin's output driver electronic effect !

@ghost

P.S. Just checked the DUE's pin document of Graynomad, obviously all pins 24-28-32-36 outputs can manage same sinking current (my led's are wired to +5V via 1K pullup resistor). I can't prove it, need to find special T&M method but we cannot prove or disprove some residual USB data garbage since the RX and CRC led's should not even faintly light ON when we do not move any GUI slider !

@ghost

P.S.2. Strange because when using my SEFRAM 4410 frequency generator in counter mode, if sliders are moving then I see glitching frequency when probing each LEDs which is correct but if no slider movement, no frequency so it tends to confirm what my tek 2445 scope already showed, namely arduino DUE not sinking any current to CRCerr and RX led's... Really wierd why they faintly light ON whereas they do not if loading same sketch in MEGA !!!

@PeterVH

>Now I can assure you that if you do NOT move any sliders then, the RX and TX led should stay OFF
They stay off on my due.

>my led's are wired to +5V via 1K pullup resistor
You should pull them up to 3V3.
The due tries to shut off the led by driving the kathode to 3V3, if you pull up the anode to 5V, current will flow.

@ghost

BRILLIANT analysis so my scope or freq counter were correct, NO more USB data garbage with this new firmware... Case closed I guess, many thanks ;)

@cmaglie cmaglie referenced this pull request from a commit
@cmaglie cmaglie Bugfix for garbage data coming from serial port after reset. (Arduino…
… Due)

Fixed #1267

Merge branch 'fix-usbserial-firmware-due' into ide-1.5.x
a58bea7
@cmaglie cmaglie merged commit 1e1fce8 into from
@cmaglie cmaglie deleted the branch
@PeterVH

@cmaglie : yes the explanation is clear, thanks. I did not spot the 25/30 difference myself.
@hektoven : I have no mega but I am sure you can have that with a mega too. It has the same usb2serial converter, just with a firmware that is a bit different.
I did some effort to modify the firmware (for the due) such that it discards data from the previous session. It did not work, it is difficult to distinguish which data to throw away and which one to send out. I let it go, I think it does not make not a lot of sense. Actually in many situations I think it is better if you open the serial port to not reset the mcu and just read in what the mcu sends...
@Fede85 wouldn't it be better to start advocating the wiring using the isp header of the programming arduino? It works on the leonardo too. See here

@ghost

As a reminder since i've been using arduino MEGA, the SS-SPI pin is 53 and not 10 as found in arduino UNO

@ghost

@PeterVH : hello please find a new release of the sketch and javas as requested 6 months ago where now the java GUI offers much more sliders, checkboxes as well as LOG console directly communicating with arduino MEGA or DUE being the client

http://www.tantratron.tk/Arduino-Java-SerPro/GUI_MEGA_DUE_v2.05.zip

ElectroShaman v2.0.5

A communication tool between a host (Windows/Mac/Linux) and Arduino (as client),
to have life update of operational parameters from host to control Arduino behaviour.
ElectroShaman is primary focused on updating pin status, PWM configurations, digital potentiometers, ...
ElectroShaman consists of 2 parts:
- GUI on the host (written in Java)
- interface embedded within Arduino sketch

Copyright (C) 2010-2013
    Dan Combine (protocol & GUI enhancements)
    Selfonlypath (ElectroShaman foundations)
    Alvaro Lopes (SerPro protocol)
www.tantratron.tk

for Windows/Mac/Linux
Open Source software

runs on Arduino MEGA and Arduino DUE
is used to control ZPE boards
requires ElectroShaman v2.0.5 on Win/MAC to manage operational parameters
@soundanalogous soundanalogous referenced this pull request in firmata/arduino
Closed

Update to new Arduino library specification #56

@soundanalogous

This issue does not appear to be resolved. After updating the ATMega16U2 firmware I'm still seeing garbage on the input line whenever an initial serial connection is made from an external application.

Try this sketch on a Due:

void setup() {
  Serial.begin(57600);
  Serial.println("begin");
}

void loop() {
  if (Serial.available() > 0) {
    // Due will print a garbage character before "begin" upon
    // serial connection from serial monitor or external application
    // such as screen (OS X). Once the external application is open
    // resetting the Due will not print garbage. It only happens upon
    // the initial serial connection from an external app.
    // This issue appears to be specific to Due.
    Serial.print(Serial.read());
  }
}

You'll see a garbage character each time you open the Serial Monitor application or each time you create a new connection from Screen (OS X) or any external application making a serial connection with the Due.

I'm not seeing this issue on an Uno, Mega or Leonardo. It seems to be Due specific.

The problem here is that the first transmission from an external application will be corrupt unless the serial input is flushed. In Firmata I had to add the following line to the end of the Firmata.begin method:

void FirmataClass::begin(long speed)
{
  Serial.begin(speed);
  FirmataSerial = &Serial;
  blinkVersion();
  printVersion();
  printFirmwareVersion();
  // clear any garbage in the input stream (this fixes an issue with Due)
  while (FirmataSerial->read() != -1);
}

The line cannot be flushed immediately after Serial.begin is called. Here blinkVersion creates a sufficient delay. If blinkVersion is not called, then a delay of at least 800ms must occur after Serial.begin before the serial input can be flushed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
0  ...am/firmwares/atmega16u2/Arduino-DUE-usbserial.hex → ...rduino-DUE-usbserial-prod-firmware-2012-11-05.hex
File renamed without changes
View
272 hardware/arduino/sam/firmwares/atmega16u2/Arduino-DUE-usbserial-prod-firmware-2013-02-05.hex
@@ -0,0 +1,272 @@
+:10000000A7C00000C0C00000BEC00000BCC000000F
+:10001000BAC00000B8C00000B6C00000B4C0000004
+:10002000B2C00000B0C00000AEC00000B8C4000004
+:100030007CC40000A8C00000A6C00000A4C000004E
+:10004000A2C00000A0C000009EC000009CC0000034
+:100050009AC0000098C0000096C0000021C10000B6
+:1000600092C0000090C000008EC000008CC0000054
+:100070008AC0000088C0000086C0000084C0000064
+:1000800082C0000080C000007EC000007CC0000074
+:100090007AC0000078C000001201100102000008C0
+:1000A00041233D0001000102DC0109023E00020182
+:1000B00000C0320904000001020201000524000111
+:1000C0001004240206052406000107058203080027
+:1000D000FF09040100020A000000070504024000B5
+:1000E00001070583024000010403090432034100B3
+:1000F00072006400750069006E006F002000280027
+:100100007700770077002E006100720064007500B0
+:1001100069006E006F002E0063006300290000007C
+:100120002E03410072006400750069006E006F00CC
+:1001300020004400750065002000500072006F0030
+:1001400067002E00200050006F0072007400000055
+:1001500011241FBECFEFD2E0DEBFCDBF11E0A0E083
+:10016000B1E0E2ECF0E102C005900D92A831B107D8
+:10017000D9F712E0A8E1B1E001C01D92A833B107A0
+:10018000E1F722D19CC73CCF9C01DC01AE57BF4FA9
+:10019000ED91FC91119741911196FC93EE9380584B
+:1001A0009F4FE817F90711F42D933C939FB7F894EC
+:1001B000F901EC57FF4F8081815080839FBF842FCE
+:1001C0000895882311F03F9A01C03F9847980895F9
+:1001D000882311F046980895469A0895DF92EF9289
+:1001E000FF920F931F93FC018489813019F08230B4
+:1001F00019F404C010E303C010E001C010E28389C9
+:10020000823009F418608589873031F0883031F008
+:10021000863029F4126003C0146001C01660109289
+:10022000C9001092C8001092CA000785F088E188C2
+:10023000D288202F3F2D4E2D5D2D10921E01203B88
+:1002400084E0380780E0480780E0580719F481E02F
+:1002500080931E01CA01B90122E030E040E050E085
+:1002600013D720583B47414E5F4FCA01B901202F99
+:100270003F2D4E2D5D2DE6D6215030403093CD00E0
+:100280002093CC001093CA0082E08093C80088E9D4
+:100290008093C9001F910F91FF90EF90DF90089518
+:1002A0001F920F920FB60F9211242F938F939F934B
+:1002B000EF93FF939091CE008EB38430F1F4E091F0
+:1002C000A201F091A3019083E091A201F091A3011A
+:1002D000CF0101969093A3018093A201825A91408D
+:1002E00021F482E291E0928381839FB7F894809118
+:1002F000A6018F5F8093A6019FBFFF91EF919F9111
+:100300008F912F910F900FBE0F901F901895FC01A9
+:1003100040911A0140931B0180911C0180931D01A3
+:100320008585282F30E02170307020931A01858553
+:1003300090E096958795817080931C0180911E01B5
+:10034000882339F088E790E0909319018093180191
+:100350000895442341F4222331F082E390E0909306
+:10036000190180931801089580E091E001C680E0B2
+:1003700091E0B4C51F9384B7877F84BF18E10FB69F
+:10038000F89410936000109260000FBE80E019DFB7
+:10039000469A3E9A87E690E09093CD008093CC00F9
+:1003A00086E08093CA001092C8001093C900539A47
+:1003B0005A9A8AB180638AB98BB180638BB9AAD209
+:1003C00084E085BD1F9108950F931F93CF93DF9312
+:1003D000D1DF2FB7F89487EA91E0909328028093B9
+:1003E000270290932A02809329022FBF2FB7F894F7
+:1003F00082E291E09093A3018093A2019093A501E2
+:100400008093A4012FBF7894C7EAD1E003E08FB7AF
+:10041000F89490912B028FBF903809F180E091E021
+:10042000D3D497FD1CC0E0912702F091280280836D
+:10043000E0912702F0912802CF01019690932802C3
+:10044000809327028752924011F4D283C1839FB7D1
+:10045000F89480912B028F5F80932B029FBF8FB700
+:10046000F8941091A6018FBFA89903C0113608F423
+:1004700056C0A89A8091A601882361F05D980093E8
+:100480001F0108C082E291E07FDE682F80E091E0EA
+:1004900001D511501123B1F780911F01882351F02C
+:1004A00080911F01815080931F0180911F0188233B
+:1004B00009F45D9A80912001882351F080912001F8
+:1004C00081508093200180912001882309F45C9A57
+:1004D000809118019091190118161906E4F4CC972F
+:1004E000CD9710F481E001C080E072DE80911801A8
+:1004F000909119010197C29710F481E001C080E04A
+:1005000060DE809118019091190101979093190173
+:100510008093180104C080E05BDE80E052DE8FB77C
+:10052000F89490912B028FBF992369F087EA91E0AC
+:100530002BDE982F8091C80085FFFCCF9093CE00D2
+:100540005C980093200180E091E095D42AD45FCF9D
+:10055000DA01923049F0933061F09130F9F4E8E932
+:10056000F0E022E130E01EC0EAEAF0E02EE330E005
+:1005700019C0813049F0813018F0823079F408C018
+:10058000E8EEF0E0849107C0ECEEF0E0849103C067
+:10059000E0E2F1E08491282F30E004C0E0E0F0E0F8
+:1005A00020E030E0ED93FC93C901089528E030E0AD
+:1005B00040E003C04F5F220F331F28173907D0F3E5
+:1005C000842F8295807F08958093E9008091EB00CD
+:1005D00081608093EB001092ED006093EC004093FB
+:1005E000ED008091EE00881F8827881F08951092E3
+:1005F000F40090E09093E9001092F0001092E8006F
+:100600001092ED008091EB008E7F8093EB009F5F56
+:10061000953081F708958091300288238CF403C0CF
+:100620008EB38823B1F08091E80082FFF9CF8091EA
+:10063000E8008B778093E80008958EB3882349F013
+:100640008091E80080FFF9CF8091E8008E77809359
+:10065000E800089594E68091EC0080FF05C0809149
+:10066000E80080FF05C023C08091E80082FD1FC024
+:100670008EB3882311F482E008958EB3853011F48F
+:1006800083E008958091EB0085FF02C081E008952A
+:100690008091E10082FFDFCF8091E1008B7F80932A
+:1006A000E100992311F484E008959150D4CF80E0C3
+:1006B00008959C0140913602509137024617570722
+:1006C00018F4F90120E038C06115710511F0AB0193
+:1006D000F8CF8091E8008E778093E80040E050E00A
+:1006E000F0CF8091E80083FF02C081E008958091FF
+:1006F000E80082FD2DC08EB3882381F18EB3853052
+:1007000079F18091E80080FF17C09091F20006C057
+:1007100081918093F100415050409F5F41155105F8
+:1007200011F09830A8F320E0983009F421E080918E
+:10073000E8008E778093E8004115510591F6222359
+:1007400081F606C08EB3882349F08EB3853041F020
+:100750008091E80082FFF6CF80E0089582E008955E
+:1007600083E008959C01409136025091370246176C
+:10077000570710F490E03BC06115710511F0AB0113
+:10078000F9CF8091E8008E778093E80040E050E058
+:10079000F1CF8091E80083FF02C081E0089580914D
+:1007A000E80082FD30C08EB3882399F18EB3853086
+:1007B00091F18091E80080FF1AC08091F20009C099
+:1007C000F9012F5F3F4FE491E093F1004150504019
+:1007D0008F5F4115510511F0883090F390E088301B
+:1007E00009F491E08091E8008E778093E80041154C
+:1007F000510579F6992369F606C08EB3882349F02E
+:100800008EB3853041F08091E80082FFF6CF80E022
+:10081000089582E0089583E008959C0161157105B3
+:1008200029F48091E8008B778093E800F90120C0DB
+:100830008091E80083FF02C081E008958EB3882391
+:1008400039F18EB3853031F18091E80082FFF0CF2D
+:1008500006C08091F10081936150704021F0809139
+:10086000F2008823B1F78091E8008B778093E8004D
+:1008700061157105E9F606C08EB3882349F08EB381
+:10088000853041F08091E80080FFF6CF80E0089548
+:1008900082E0089583E0089542D044D01EBA1092B9
+:1008A0002E0210922D0210922C0284E089BD89B58F
+:1008B000826089BD09B400FEFDCF8091D800982FD9
+:1008C0009F779093D80080688093D80080916300D0
+:1008D0008E7F809363008091D8008F7D8093D800B5
+:1008E0008091E0008E7F8093E0008091E1008E7F18
+:1008F0008093E1008091E20081608093E20080912A
+:10090000E100877F8093E1008091E200886080931E
+:10091000E2000895C1DF81E080932F0208951092D4
+:10092000E20008951092E10008951F920F920FB611
+:100930000F9211241F932F933F934F935F936F93C5
+:100940007F938F939F93AF93BF93EF93FF93E9EEC2
+:10095000F0E0108117701082E0EFF0E08081877F77
+:1009600080837894C3D0F894A9EEB0E01C92E0EFB5
+:10097000F0E08081886080831C93FF91EF91BF91AC
+:10098000AF919F918F917F916F915F914F913F9127
+:100990002F911F910F900FBE0F901F9018951F92CF
+:1009A0000F920FB60F9211242F933F934F935F93A3
+:1009B0006F937F938F939F93AF93BF93EF93FF9327
+:1009C0008091E10080FF1BC08091E20080FF17C092
+:1009D0008091E1008E7F8093E1008091E2008E7F24
+:1009E0008093E2008091E20080618093E200809138
+:1009F000D80080628093D80019BC1EBAD1D18091F2
+:100A0000E10084FF29C08091E20084FF25C084E0DA
+:100A100089BD89B5826089BD09B400FEFDCF809192
+:100A2000D8008F7D8093D8008091E1008F7E8093E5
+:100A3000E1008091E2008F7E8093E2008091E200ED
+:100A400081608093E20080912E02882311F481E07E
+:100A500001C084E08EBBA4D18091E10083FF27C058
+:100A60008091E20083FF23C08091E100877F809323
+:100A7000E10082E08EBB10922E028091E1008E7F19
+:100A80008093E1008091E2008E7F8093E20080916C
+:100A9000E20080618093E200AADD80E060E042E055
+:100AA00093DD8091F00088608093F00079D180918F
+:100AB000E10082FF0AC08091E20082FF06C08091BF
+:100AC000E1008B7F8093E1006BD1FF91EF91BF91AB
+:100AD000AF919F918F917F916F915F914F913F91D6
+:100AE0002F910F900FBE0F901F9018951F93DF93BB
+:100AF000CF93CDB7DEB7AC970FB6F894DEBF0FBE7D
+:100B0000CDBFE0E3F2E08091F100819322E0E83391
+:100B1000F207C9F78091300230913102353009F483
+:100B200087C0363040F43130C9F1313070F03330A5
+:100B300009F01DC133C0383009F4EFC0393009F471
+:100B4000FEC0363009F013C192C0803821F08238DF
+:100B500009F00DC108C090912C0280912D028823CC
+:100B600099F0926011C08091340287708093E900FF
+:100B70008091EB0090E025E0969587952A95E1F726
+:100B8000982F91701092E9008091E800877F809300
+:100B9000E8009093F1001092F100CAC0882319F088
+:100BA000823009F0E4C090E08F719070009721F0DE
+:100BB000029709F0DDC00CC080913202813009F04B
+:100BC000D7C010922D02333069F580932D022AC0D0
+:100BD00080913202882331F520913402277009F484
+:100BE000C7C02093E9008091EB0080FFC1C0333083
+:100BF00021F48091EB00806213C08091EB00806152
+:100C00008093EB0081E090E002C0880F991F2A9545
+:100C1000E2F78093EA001092EA008091EB0088608E
+:100C20008093EB001092E9008091E800877F83C0F9
+:100C3000882309F09CC0109132028091E800877FE0
+:100C40008093E800E8DC04C08EB3882309F490C0E8
+:100C50008091E80080FFF8CF812F8F7711F492E028
+:100C600001C093E09EBB80688093E30081C0805800
+:100C7000823008F07CC0809132029091330223E0F0
+:100C80008C3D920799F55FB7F894DE0115964EE01A
+:100C900020E030E061E2E42FF0E0609357008491BF
+:100CA00020FF03C082958F704F5F982F9F70892F10
+:100CB000805D8A3308F0895F8C9311961C9211979E
+:100CC0002F5F3F4F12962431310529F75FBF8AE22B
+:100CD0008B8383E08C838091E800877F8093E8009A
+:100CE000CE0103966AE270E0E4DC11C06091340248
+:100CF000AE014F5F5F4F2CDCBC010097C9F18091C2
+:100D0000E800877F8093E80089819A812BDD8091BC
+:100D1000E8008B778093E8002BC0803841F5809104
+:100D2000E800877F8093E80080912E028093F10095
+:100D30008091E8008E778093E8006DDC19C08823ED
+:100D4000B1F490913202923098F48091E800877F5C
+:100D50008093E80090932E025EDC80912E0288231F
+:100D600011F483E001C084E08EBB01DB01C0FCDA3A
+:100D70008091E80083FF0AC08091EB00806280933D
+:100D8000EB008091E800877F8093E800AC960FB677
+:100D9000F894DEBF0FBECDBFCF91DF911F910895B4
+:100DA00008951F938EB3882361F01091E90010928B
+:100DB000E9008091E80083FF01C098DE177010936E
+:100DC000E9001F9108950895FC018EB3843021F548
+:100DD00087859089A189B2890097A105B105E1F0C5
+:100DE00085818093E9008091E80082FF15C08091A1
+:100DF000F200882319F42FEF3FEF04C08091F10037
+:100E0000282F30E08091F200882341F48091E8009F
+:100E10008B778093E80002C02FEF3FEFC901089560
+:100E2000FC018EB3843011F587859089A189B28940
+:100E30000097A105B105D1F081818093E9008091EF
+:100E4000F2008823A9F09091E8008091E8008E7765
+:100E50008093E80095FD0CC0FDDB982F882349F4B2
+:100E60008091E8008E778093E80003C092E001C093
+:100E700090E0892F0895FC018EB3843051F487856A
+:100E80009089A189B2890097A105B10511F0CF0120
+:100E9000C7CF08951F93FC01162F8EB38430D9F469
+:100EA00087859089A189B2890097A105B10599F03C
+:100EB00081818093E9008091E80085FD08C08091E0
+:100EC000E8008E778093E800C5DB882329F410932F
+:100ED000F10080E001C082E01F9108950F931F93FD
+:100EE000CF93DF93EC010D96FC0189E0DF011D92A9
+:100EF0008A95E9F72A813B8109818C81882311F445
+:100F000010E001C014E0C90151DB182B1260802FE2
+:100F100061E8412F59DB882329F12E813F810D8122
+:100F20008885882311F410E001C014E0C9013EDB7C
+:100F3000182B1260802F60E8412F46DB882391F048
+:100F40002A853B8509858C85882311F410E001C032
+:100F500014E0C9012BDB182B1260802F61EC412FAC
+:100F600033DB01C080E0DF91CF911F910F91089595
+:100F7000CF93DF93EC018091E80083FF60C088810C
+:100F800090E020913402309135022817390709F09A
+:100F900056C080913102813261F0823220F4803279
+:100FA00009F04DC019C0823269F1833209F047C09F
+:100FB00038C080913002813A09F041C08091E80048
+:100FC000877F8093E800CE010F9667E070E071DBC9
+:100FD0008091E8008B7713C080913002813279F5DF
+:100FE0008091E800877F8093E800CE010F9667E04C
+:100FF00070E013DCCE01F2D88091E8008E77809308
+:10100000E8001DC0809130028132C9F48091E8006F
+:10101000877F8093E800809132028D87CE0177D957
+:101020000DC080913002813251F48091E800877FB9
+:101030008093E800CE0160913202C5DEECDADF91E8
+:10104000CF910895A1E21A2EAA1BBB1BFD010DC072
+:10105000AA1FBB1FEE1FFF1FA217B307E407F50768
+:1010600020F0A21BB30BE40BF50B661F771F881F44
+:10107000991F1A9469F760957095809590959B01DA
+:10108000AC01BD01CF01089597FB092E05260ED0B6
+:1010900057FD04D0D7DF0AD0001C38F45095409596
+:1010A000309521953F4F4F4F5F4F0895F6F790953C
+:1010B0008095709561957F4F8F4F9F4F0895F8945D
+:0210C000FFCF60
+:1010C200000340000004400000020800000000008D
+:0810D200000000000000140002
+:00000001FF
View
21 hardware/arduino/sam/firmwares/atmega16u2/arduino-usbserial/Arduino-usbserial.c
@@ -161,20 +161,17 @@ int main(void)
{
// SAM3X RESET/ERASE Sequence
// --------------------------
- if (ResetTimer == 95) {
+ // Between 60 and 120: do erase
+ if (ResetTimer >= 60 && ResetTimer <= 120) {
setErasePin(true);
- setResetPin(false);
- }
- if (ResetTimer == 35) {
+ } else {
setErasePin(false);
- setResetPin(false);
}
- if (ResetTimer == 25) {
- setErasePin(false);
+
+ // Between 1 and 50: do reset
+ if (ResetTimer >= 1 && ResetTimer <= 50) {
setResetPin(true);
- }
- if (ResetTimer == 1) {
- setErasePin(false);
+ } else {
setResetPin(false);
}
ResetTimer--;
@@ -303,10 +300,10 @@ void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const C
if (Selected1200BPS) {
/* Start Erase / Reset procedure when receiving the magic "1200" baudrate */
- ResetTimer = 95;
+ ResetTimer = 120;
} else if (!PreviousDTRState && CurrentDTRState) {
/* Reset on rising edge of DTR */
- ResetTimer = 30;
+ ResetTimer = 50;
}
}
Something went wrong with that request. Please try again.