Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve ArduinoISP sketch #3500

Merged
merged 25 commits into from
Oct 7, 2015
Merged

Improve ArduinoISP sketch #3500

merged 25 commits into from
Oct 7, 2015

Conversation

PeterVH
Copy link

@PeterVH PeterVH commented Jul 10, 2015

This is the pull request for issue 3321

More info on this change request is here.

I will update the progress of testing effort in the table below:

Test report for linux (Kubuntu 14.04 LTS):

Test Duemilanove UNO Leonardo Due Mega
No target OK OK OK OK OK
Burn UNO bootloader todo todo todo todo todo
Burn Arduino Mega bootloader OK OK OK todo OK
Program an attiny85 (Chaucer4K) todo OK OK OK OK
Program an attiny2313 (TinyBlink) OK OK OK OK OK
Program an attiny841 (TinyBlink) todo OK OK OK OK
Program an at89s52 OK OK OK FAIL(1) OK
Chaucer112K to 1284p OK OK todo OK OK
Chaucer112K to Mega todo OK todo todo todo
LongStoryShort todo todo todo todo todo

(1) an at89s52 works out of spec at 3V3. Downloading hex files, signature etc works but flashing a new hex file requires at least 4V. With a shield containing a 5V buffer this could work...

Test report for windows:

Test Duemilanove UNO Leonardo(3) Due(3) Mega
No target OK OK(4) OK OK OK(4)
Burn UNO bootloader OK OK OK OK OK
Burn Arduino Mega bootloader OK OK OK OK todo (5)
Program an attiny85 (Chaucer4K) OK OK OK OK OK
Program an attiny2313 OK OK OK OK OK
Program an attiny841 OK OK OK OK OK
Program an at89s52 OK OK OK(1) FAIL(2) OK
Chaucer112K to 1284p todo todo OK OK todo
Chaucer112K to Mega todo OK OK OK todo (5)

(1) used pre compiled hex files, available in the ArduinoISP-test repo.
(2) an at89s52 works out of spec at 3V3. Downloading hex files, signature etc works but flashing a new hex file requires at least 4V. With a shield containing a 5V buffer this could work...
(3) requires the changes to CDC.cpp proposed in #1182.
(4) the error led flashes briefly because the 16u2 sends a bogus byte when changing the baud rate, this is harmless, stk500v1 recovers from it
(5) only big spenders have two mega's

@ffissore
Copy link
Contributor

It doesn't merge. Can you please rebase the code on top of latest master?

@facchinm
Copy link
Member

Thank you @PeterVH ! Unfortunately a recent change moved the sketch from ArduinoISP folder to 11.ArduinoISP/ArduinoISP to be coherent with the rest of the examples.

Could you rebase upon the current master branch?
Thank you very much

@facchinm facchinm assigned facchinm and unassigned cmaglie Jul 10, 2015
@facchinm facchinm added the Examples: ArduinoISP The ArduinoISP example sketch label Jul 10, 2015
@facchinm facchinm changed the title Issue 3321 Improve ArduinoISP sketch Jul 10, 2015
@PeterVH
Copy link
Author

PeterVH commented Jul 13, 2015

@facchinm: Done. But this forced me to push -f again.

@facchinm
Copy link
Member

@PeterVH no problem at all, thank you very much! I'm launching the PR builder to get a complete IDE image with your sketch so anyone interested can test it!

Peter Van Hoyweghen added 2 commits July 14, 2015 21:20
@q2dg
Copy link

q2dg commented Jul 18, 2015

@PeterVH Maybe it's a sillyness, but do you know https://github.com/adafruit/ArduinoISP ?? For gathering some ideas...

@PeterVH
Copy link
Author

PeterVH commented Jul 23, 2015

I am afraid I introduced some regression. Some tests, e.g. the at89s52 fail (burning works but verifying fails...) Will have to check this out.
B.t.w. there is partial information on the tests here

@NicoHood
Copy link
Contributor

@PeterVH the mega and the uno have a 16u2 as USB-Serial bridge.

I have two questions regarding this:

  • Does the Uno behave the same with the garbage input?
  • Could you test the same settup with HoodLoader2 (not as ISP, as bridge only). Because I might have fixed this garbage byte in my bootloader. If not maybe we can correct this error (at least for hoodloader2 since many people start using it)

Also I do not really understand what you mean with

so avrdude has to set the correct baud rate on the fly.

Does the ISP now work with the Micro/Leonardo?

@PeterVH
Copy link
Author

PeterVH commented Aug 27, 2015

Does the Uno behave the same with the garbage input?

Yes. I just tried it out.

Also I do not really understand what you mean with:
so avrdude has to set the correct baud rate on the fly.

Well, avrdude sets the baudrate when it starts programming, this causes a baud rate change in the u2 and this causes the Uno or Mega receive a garbage byte.

Could you test the same setup with HoodLoader2

Sure. Will first read about hood loader. I intend to use it as a more convenient way to disable autoreset (instead of the capa) on Mega and Uno. (Currently on the Mega and Due I use a modified u2 firmware that disables autoreset if a jumper is placed over a pair of the 4 broken out gpios)

Does the ISP now work with the Micro/Leonardo?

Yes. See the test report I maintain at the top of this thread. (Be it that on windows you still have to do -carduino).

@PeterVH
Copy link
Author

PeterVH commented Aug 30, 2015

@NicoHood: I can confirm that the problem of the garbage byte does not occur when using HoodLoader2 as bridge.
I added pin configuration for hoodloader2 and tested it.

B.t.w, it is a nice concept you worked out. I plan to keep it installed on my Uno. Though for my use case I'd like the inverse the logic: reset twice => sketch mode, press once or powerup => bootloader mode. That way I could leave ArduinoISP in the u2 and when I want to program something, I would activate the sketch by resetting twice. I'll have a look in the code whether that is easy to do...

@NicoHood
Copy link
Contributor

So its a problem of the firmware, good to know.

This line fixes this (i think)
https://github.com/NicoHood/HoodLoader2/blob/dev/avr/bootloaders/HoodLoader2/HoodLoader2.c#L852
https://github.com/NicoHood/HoodLoader2/blob/dev/avr/bootloaders/HoodLoader2/HoodLoader2.c#L921

I could invert the logic, but by default it doesnt make sense to me.
What you can do is:

So maybe its time to update the firmware? The Leonardo bootloader also has some things that can be improved. The Arduino team should think about updating the unos firmware/bootloader and the leonardos bootloader as well.

@PeterVH
Copy link
Author

PeterVH commented Sep 21, 2015

@facchinm: Hi Martino.I ran the bulk of the tests again, this time on Windows. Everything worked fine on this os as well, (see table at the top). Also in the forum, the sketch was able to solve various problems. (this one being the most enthousiastic one :-) ). So I am now confident this is ready to be merged.

On windows I still need the fixes from #1182 for leonardo and due. I should make a separate pull resuest for that.

@cmaglie: you reported success on the Zero. I bought an Arduino M0 (not Pro) to be able to run that kind of tests myself. (You know I don't have access to Zero from Europe). I run with the arduino.org bootloader and use of coarse the arduino.cc ide and core. I adapted the .cc linker script so that the FLASH addresses match what the bootloader expects. The sketch runs: heartbeat led fades in out. But the communication over SerialUSB does not work correctly (see here). I see no a-priory reason why the behavior of an M0 would be different than on a Zero (but I may overlook something essential, any ideas?). The symptoms look like problems in the USB driver. Are you sure the sketch (still) works correctly on the Zero?

@facchinm
Copy link
Member

Hi Peter, I'm really happy to hear such good news!

The Zero issue is probably related with SerialUSB code being quite problematic, but it was solved in arduino/ArduinoCore-samd#27 ; that PR will be merged soon but you can test it via Board Manager before release 😉

Anyway, I'm going to test the actual code (you to make sure, I'm totally convinced it works great) and merge it soon.

@NicoHood
Copy link
Contributor

You may want to try if this works for you:
#3839

@PeterVH
Copy link
Author

PeterVH commented Sep 22, 2015

@fachinm: you were right about the usb problems, with the pr you mentioned I can now happily test ArduinoISP on my M0. Thanks! (This also proves ArduinoISP is a good test case for new cores. In the past it already brought problems in the Leonardo and Due cores to the surface)

There is another detail I wanted to bring to your attention. Someone in the forum brought up that it is confusing having to upload a sketch called 'ArduinoISP' whilst having to specify 'Arduino as ISP' as a programmer. He suggested to rename the sketch to ArduinoAsISP. I don't know. It is true more and more people in the forum start to refer to this programming method as 'Arduino as ISP'. I'll leave this matter to the Arduino devs...

BTW. the info about ArduinoISP on the new examples web site is inaccurate and adds more confusion (with a link to the ArduinoISP board).

@NicoHood: that would work for me. Some comments:

  • Could you also modify the Due core? Will test it if needed.
  • Could you also adapt the comment, it does not hold anymore
  • The configured flag is not cleared upon disconnection, but that might not be that important right now.

@PeterVH PeterVH closed this Sep 26, 2015
@PeterVH PeterVH reopened this Sep 26, 2015
@NicoHood
Copy link
Contributor

It is not cleared on disconnect? Where do we have to handle this? (this is very important)
I only found this:

https://github.com/NicoHood/Arduino/blob/patch-8/hardware/arduino/avr/cores/arduino/USBCore.cpp#L724

In the lufa code are several parts where this variable is changed:
https://github.com/abcminiuser/lufa/blob/master/LUFA/Drivers/USB/Core/AVR8/USBInterrupt_AVR8.c#L127

@PeterVH
Copy link
Author

PeterVH commented Sep 26, 2015

I have found my way to your pr #3839, will comment over there

facchinm added a commit that referenced this pull request Oct 7, 2015
@facchinm facchinm merged commit 651ae04 into arduino:master Oct 7, 2015
@facchinm
Copy link
Member

facchinm commented Oct 7, 2015

Time for merge 😄 😄 Thanks a lot Peter!

@ffissore ffissore modified the milestone: Release 1.6.6 Oct 7, 2015
@PeterVH
Copy link
Author

PeterVH commented Oct 7, 2015

Thanks Martino!
Fyi, here is a recent testimony I liked from someone using the sketch to burn a bootloader to an atmega 2560, which failed with an usbasp. I would really enjoy people coming back to using ArduinoISP for burning bootloaders and tiny firmware...

@NicoHood
Copy link
Contributor

The leonardo windows bug is still not solved, correct?
Just gave it a quick test with HoodLoader2, burned a uno bootloader. Ultra fast. Pin selection is also correct, good job Peter!

@q2dg
Copy link

q2dg commented Oct 19, 2015

Why there is a "Programmer->ArduinoISP" menu option and a "Programmer->Arduino as ISP" whereas there is only one "Examples->ArduinoISP" example sketch?? Which programmer is the good one?? It's very confusing.

@PeterVH
Copy link
Author

PeterVH commented Oct 19, 2015

"Arduino as ISP"
see above : (#3500 (comment))

@q2dg
Copy link

q2dg commented Oct 19, 2015

Thanks. I've seen "ArduinoISP" programmer refers to https://www.arduino.cc/en/Guide/ArduinoISP . In this case, I think this should be marked in menu as "retired" or something similar, but I'm not sure.
Sorry for bother you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Examples: ArduinoISP The ArduinoISP example sketch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants