-
Notifications
You must be signed in to change notification settings - Fork 136
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
Support for cross-platform "1200bps touch" using libserialport #1500
Comments
Sounds like a great idea and good improvement to avrdude. Existing discussion: |
The touch serial interface with specific baud rate seems to be a specific thing for some Arduino boards. Is that necessary for programming these boards irrespective of the programmer or is it tied to a specific way of programming (say, though a particular bootloader)? I am trying to figure out what the best way of specifying this peculiarity is in terms, eg, of
Using a new option |
It is tied to a specific type of bootloaders or programmers. It is basically to trigger the reset so that the bootloader or programmer can work. If you use the other programmers you do not really need the trick, when you have the access to the reset line.
Existing discussions: Background info: |
BTW, Arduino Nano ATmega4808 clone does not need this trick, unlike official Arduino Nano Every (ATmega4809).
|
@mcuee I can test the Arduino Nano Every on my Windows computer, but I've never built Avrdude on Windows before. You mentioned that you built using MinGW in order to get libserialport working. How did you install libserialport on Windows, and how did you manage to build Avrdude? I have a "stock" Windows 11 computer I'm using for this, so don't expect anything to be pre-installed. |
Here is the binary you can use. avrdude Windows binaries are static-linked so it should work for you under Windows 11.
I will update the Wiki to include libserialport support for most of the build, except MSVC for Windows. |
Wiki updated. If you want, you can install MSYS2 mingw64 and then see if you can build the mingw64 binaries under Windows by yourself. Installation of MSYS2. |
I have pushed two commits to MinGW32/64bit github actions so that you can get x86 and x64 version of avrdude binaries under Windows from now on, with libserialport and GNU Readline support. |
@mcuee I'll see what I can do. I'm currently installing minGW on a Windows computer in order to get the binaries from the CI to work. Since you already have a working Windows setup, can you try to reduce delay from then the port is closed until it's re-opened again? I tried the statically built binary you provide earlier, and it took quite a while for Avrdude to "give up" waiting for a new port to appear. It may be that the Nano Every times out in the mean time. |
I have tried that but it does not work. In my Windows 11 system, avrdude exits from the loop very fast. I have tried the default 400ms delay, 200ms delay, 100ms delay and no delay, as well as longer 800ms delay, all have the same results, which means the delay loop is not the issue. Example: 100ms initial delay
The output is the same for other delays I have tried, which means the for loop is immediately out. So this part of the codes is not the issue, rather somehow Arduino Nano Every is disturbed and becomes in a bad state, after this part of the codes.
|
It is strange that you mention avrdude tries quite a bit before finding new port, are you testing with Arduino Nano Every when you see this happening? I got my Arduino Nano Every back in the end of May 2022. But I can not find the date code on the board. Please help to post your debug log as well, thanks if you are using Arduino Nano Every and see different behavior under your Windows computer. Thanks. |
Binaries for you to try.
|
BTW, you can use github actions to build MinGW32/64 binaries with libserialport support. You may have to merge the git main changes to your branch. |
Thanks for trying older commits as well. It is strange that this is only an issue on Windows. Maybe you can look at the Nano Every jtag2updi source code to see if you can spot any obvious things? |
As mentioned in the above, I was very puzzled why this PR does not work, then I looked at the working method again closely, it is :
And actually the method mentioned before is actually:
Then I compare the codes in this PR and it only has
Change the line to the following fixed the issue for me.
|
The change is also good for Arduino Leonardo.
|
The change is also good for jtag2updi using Uno CH340 Clone.
|
Now that #1498 is pretty much complete and hopefully ready to be merged soon, the next step involving libserialport would be to finally support devices that require a serial port "touch" before communication can be established.
To perform "touch" (usually 1200 baud) is as simple as opening the serial port, and waiting a little, just to make sure that the decide in the other end has enough time to jump into "bootloader mode" and close it again.
Some boards, like the Arduino Leonardo or the Arduino Micro, will re-appear with a different USB VID/PID, which may on some OSes result in a new /dev path or COM port number. other boards, like the Arduino Nano Every will not appear as a new device.
Here's how I imagine it can be done if we add a new command line flag that specifies the "touch" baud rate, for instance
-r 1200
(please suggest a better-suited flag if you have one. -r just happens to be available).avrdude -c avr109 -p atmega32u4 -P usb:2341:0058 -b 57600 -r 1200
I doubt this would be very difficult to implement, now that #1498 contains some of the boilerplate code needed to implement this feature.
Any thoughts or ideas?
The text was updated successfully, but these errors were encountered: