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

Add jtag2updi -xrtsdtr extended parameter #1425

Merged
merged 6 commits into from
Jun 28, 2023

Conversation

MCUdude
Copy link
Collaborator

@MCUdude MCUdude commented Jun 21, 2023

This PR lets the user control the RTS/DTR line on the UART line when using the jtag2updi programmer. This may be useful for controlling external hardware, such as switching between UPDI programming and UART mode. See #1408 for details

@MCUdude MCUdude linked an issue Jun 21, 2023 that may be closed by this pull request
@mcuee mcuee added the enhancement New feature or request label Jun 21, 2023
src/jtagmkII.c Outdated
@@ -1215,6 +1219,11 @@ static int jtagmkII_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
int ok;
const char *ifname;

if (PDATA(pgm)->rts_mode != RTS_MODE_DEFAULT) {
pmsg_warning("forcing serial DTR/RTS handshake lines %s\n",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this a running commentary pmsg_info() rather than a warning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I ended up using pmsg_warning because that's what the SerialUPDI programmer does. But it would make sense to use pmsg_info instead for both the jtag2updi and serialupdi programmer

@item serialupdi

The serialupdi programmer type accepts the following extended parameter:
The jtag2updi and serialupdi programmer types accepts the following extended parameters:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

types accept (not accepts)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! It's these things that always get me

@stefanrueger
Copy link
Collaborator

Looks good though cannot test functionality. I suspect there are going to be a number of conflicts with the previous PR #1324, which is an unfortunate coincidence, but lets cross that bridge when we come to it. I normally merge in batches but within batches in historic order (first PR gets merged first).

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jun 22, 2023

I assume you mean PR #1424? Merge that first, and I'll rebase upon that, no worries

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jun 23, 2023

@mcuee do you have a chance to test this PR with your hardware as well? You can use a multimeter or an oscilloscope and measure directly on the RTS or DTR line. It should stay high or low during the entire programming session (terminal mode as well), depending on the user-provided -xrtsdtr parameter.

@mcuee
Copy link
Collaborator

mcuee commented Jun 23, 2023

@MCUdude

It seems to me I do not have the right hardware to carry out the test.

Just one question about your setup of jtag2updi and target for this PR.

  1. For on-board jtag2updi programmer (Arduino Nano Every, or Nano 4808, with buggy jtag2updi implementation), I think we do not have the RTS/DTR lines available on the pins.

  2. For Arduino Uno (official or clone) based implementation, it seems to me DTR/RTS lines are not available for use.

Official Uno Rev 3:
https://content.arduino.cc/assets/UNO-TH_Rev3e_sch.pdf

Typical CH340x based clone
http://electronoobs.com/images/Arduino/tut_31/arduino_uno_scheamtic_ch340.png

arduino_uno_scheamtic_ch340

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jun 23, 2023

For on-board jtag2updi programmer (Arduino Nano Every, or Nano 4808, with buggy jtag2updi implementation), I think we do not have the RTS/DTR lines available on the pins.

For Arduino Uno (official or clone) based implementation, it seems to me DTR/RTS lines are not available for use.

You're absolutely correct. In order to utilize this functionality, one would have to design a dedicated jtag2updi programmer and construct it similar to the way the SerialUPDI programmer is constructed. Even though I'm not planning to sell a jtag2updi programmer that has this feature, it could be useful for future programmers. For instance, the Nano Every could have been using this feature to switch between UART and UPDI mode instead of the pesky 1200bps touch hack.

If you want to check if this works on your UNO, trace down the other side of the auto-reset capacitor (which is connected to the DTR or RTS pin) and see how it behaves.

@mcuee
Copy link
Collaborator

mcuee commented Jun 23, 2023

If you want to check if this works on your UNO, trace down the other side of the auto-reset capacitor (which is connected to the DTR or RTS pin) and see how it behaves.

I will test this next Monday when I have the access to the equipment.

@stefanrueger
Copy link
Collaborator

OK, so will leave this PR unmerged when I merge the other PRs, probably this (European) evening

@mcuee
Copy link
Collaborator

mcuee commented Jun 26, 2023

@stefanrueger and @MCUdude

If you want to check if this works on your UNO, trace down the other side of the auto-reset capacitor (which is connected to the DTR or RTS pin) and see how it behaves.

Somehow I do not get the desire results on my Arduino Uno clone. It could be due the pin-out is different. I will see if I can test with another Arduino Uno clone.

  1. The other side of the auto-reset capacitor keeps high (using a multimeter)
C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1425 -c jtag2updi -P COM8 -p m4808 -B10 -xrtsdtr=high -U flash:r:read.hex:i
avrdude_pr1425: forcing serial DTR/RTS handshake lines HIGH
avrdude_pr1425: AVR device initialized and ready to accept instructions
avrdude_pr1425: device signature = 0x1e9650 (probably m4808)

avrdude_pr1425: processing -U flash:r:read.hex:i
avrdude_pr1425: reading flash memory ...
Reading | ################################################## | 100% 9.84 s
avrdude_pr1425: writing output file read.hex
avrdude_pr1425: releasing DTR/RTS handshake lines

avrdude_pr1425 done.  Thank you.
  1. The other side of the auto-reset capacitor seems to go low for a short while but then goes back to high. (using a multimeter)
C:\work\avr\avrdude_test\avrdude_bin> .\avrdude_pr1425 -c jtag2updi -P COM8 -p m4808 -B10 -xrtsdtr=low -U flash:r:read.hex:i
avrdude_pr1425: forcing serial DTR/RTS handshake lines LOW
avrdude_pr1425: AVR device initialized and ready to accept instructions
avrdude_pr1425: device signature = 0x1e9650 (probably m4808)

avrdude_pr1425: processing -U flash:r:read.hex:i
avrdude_pr1425: reading flash memory ...
Reading | ################################################## | 100% 9.82 s
avrdude_pr1425: writing output file read.hex
avrdude_pr1425: releasing DTR/RTS handshake lines

avrdude_pr1425 done.  Thank you.

@mcuee
Copy link
Collaborator

mcuee commented Jun 26, 2023

@MCUdude

So I get another Arduino Clone which follows the official design (using ATmeag16U2 as the USB to Serial chip). And the results are the same as above.
https://content.arduino.cc/assets/UNO-TH_Rev3e_sch.pdf

Then I see why my testing is not good, the design is using CTS plus capacitor for the reset pin. not DTR or RTS. The RTS pin is not exposed so I can not probe it.

In the end, I do not have the right HW to carry out the test.

@mcuee
Copy link
Collaborator

mcuee commented Jun 26, 2023

Anyway this PR needs to be updated to resolve the conflicts. After that, maybe this PR can be merged if the test results from @MCUdude is positive and the review from @stefanrueger is positive.

@MCUdude
Copy link
Collaborator Author

MCUdude commented Jun 26, 2023

Merge conflict resolved 👍

@stefanrueger
Copy link
Collaborator

Looks good: ready to be merged. Also probably the last merge of code before v7.2 apart from fixes arising from tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add -xrtsdtr=low,high to the jtag2updi programmer
3 participants