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

Try to run ChipErase on UPDI even if return code is -67 #982

Closed
wants to merge 1 commit into from

Conversation

umbynos
Copy link
Contributor

@umbynos umbynos commented May 31, 2022

More details in arduino/ArduinoCore-megaavr#33 (comment)

Co-authored-by: Martino Facchin [email protected]

Related conversation with @MCUdude umbynos@b6d21d1#commitcomment-73387352

@MCUdude
Copy link
Collaborator

MCUdude commented May 31, 2022

Looks good to me! This has been incorporated in the Arduino flavored Avrdude version for a couple of years now and has not caused any issues AFAIK.

@MCUdude
Copy link
Collaborator

MCUdude commented Jun 1, 2022

For reference, 67 is documented in pyedbglib as

# avr8protocol.py
AVR8_FAILURE_CRC_FAILURE = 0x43  # CRC operation caused an error

@MCUdude
Copy link
Collaborator

MCUdude commented Jun 2, 2022

@umbynos slightly off-topic, but will Arduino's Avrdude fork be available on downloads.arduino.cc when you've finished working on your 7.0 fork?

@MCUdude
Copy link
Collaborator

MCUdude commented Jun 6, 2022

Thanks, @umbynos! I managed to get my boards manager file working with the links you provided.

After a bit of testing, I'm a bit bummed out that your dev branch lacks a few features. Most noticeably, I managed to get non-standard baud rates working with macOS through PR #898. However, this fix is not present in your branch. Is this something that's happened by accident, or is it left out on purpose?

@umbynos
Copy link
Contributor Author

umbynos commented Jun 6, 2022

My dev branch was there only for testing purposes. Well, #898 should be included, since the release workflow should check out tag v7.0 and then apply the patches present here. The commit 99f191a should be included in v7.0 tag. Are you sure that that commit is not included? The patches will be removed from there if they will be upstreamed.

@MCUdude
Copy link
Collaborator

MCUdude commented Jun 6, 2022

@umbynos sorry, I take it all back! It turned out to be some flakey hardware on my side

@MCUdude
Copy link
Collaborator

MCUdude commented Jun 15, 2022

@dl8dtl or @mariusgreuel can we merge this as it is?

@dl8dtl
Copy link
Contributor

dl8dtl commented Jun 15, 2022

@dl8dtl or @mariusgreuel can we merge this as it is?

Well, I don't particularly like those "magic numbers" – not only in the patch but also in the existing code.
Instead of adding a comment on top, why not use the respective names in the first place (and add a new name for code 67 as well)?
Now, that we are going to touch that piece of code anyway, it would be a good time now to correct all that.

Apart from that, it's fine.

@MCUdude
Copy link
Collaborator

MCUdude commented Jun 15, 2022

@dl8dtl AFAIK the reason why the magic number 68 was used in the first place is because it's defined in jtag3_private.h, and is not available in main.c.

We could either include jtag3_private.h in main.c, or add another comment.

      if (rc != 0) {
        // -67 == -(0x47) == -(RSP3_FAIL_CRC_FAILURE)
        // -68 == -(0x44) == -(RSP3_FAIL_OCD_LOCKED)
        if ((rc == -67 || rc == -68) && (p->flags & AVRPART_HAS_UPDI) && (attempt < 1)) {
``

@dl8dtl
Copy link
Contributor

dl8dtl commented Jun 15, 2022

The we'd better not pass that number straight into main() anyway.
Remember, the goal is that the code ought to be usable as a library, so all return values need to be documented (ultimately, yes, I know, we're quite a bit away from that).
So it would make sense to add some kind of soft failure error code to the public header file, and return that one in case either RSP3_FAIL_CRC_FAILURE or RSP3_FAIL_OCD_LOCKED is seen in the lower (library) layers.

Yes, it's a bit more of work, but a lot cleaner then.

@MCUdude
Copy link
Collaborator

MCUdude commented Jun 15, 2022

So it would make sense to add some kind of soft failure error code to the public header file, and return that one in case either RSP3_FAIL_CRC_FAILURE or RSP3_FAIL_OCD_LOCKED is seen in the lower (library) layers.

I'm not sure I follow you... Which public header; jtag.h?

@dl8dtl
Copy link
Contributor

dl8dtl commented Jun 15, 2022

Which public header; jtag.h?

libavrdude.h ought to document everything that is needed to describe the API to the underlying functions.

@dl8dtl
Copy link
Contributor

dl8dtl commented Jun 15, 2022

https://github.com/dl8dtl/avrdude/tree/jtag3_retcode

That's my proposal.

I can turn that into a PR if there's interest, but I don't think it makes sense to try merging it with the current PR.

@MCUdude
Copy link
Collaborator

MCUdude commented Jun 16, 2022

@dl8dtl even though I haven't tested your code, I agree that the idea is good. The code looks fine as well 🙂

@MCUdude
Copy link
Collaborator

MCUdude commented Jun 17, 2022

@dl8dtl would be great if you could submit your work as a PR 👍

@dl8dtl
Copy link
Contributor

dl8dtl commented Jun 17, 2022

@dl8dtl would be great if you could submit your work as a PR +1

#996

Would be great if in particular those who suffered from the original issue could test that.

@mcuee mcuee added the bug Something isn't working label Jun 20, 2022
dl8dtl added a commit that referenced this pull request Jun 28, 2022
Replace internal knowledge in jtag3.c by a public API

Supersedes #982
@dl8dtl
Copy link
Contributor

dl8dtl commented Jun 28, 2022

Superseded by #996

@dl8dtl dl8dtl closed this Jun 28, 2022
@umbynos umbynos deleted the chiperase_udpi branch June 29, 2022 08:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants