avr64 ISR issues causing reprogramming to fail #357
Replies: 2 comments
-
I don't think it is related to ISRs, It happens randomly no matter what you do. That was a bug that I tried for months to fix (and which resulted from a similar random bug which would result in the programmer simply becoming non-responsive, requiring powerdown and often letting it sit a while or shorting the power rails to drain the caps) or a hardware reset to resolve), whereas this one usually seems to work if you just keep trying. Despite months of intensely frustrating work and heated exchanges with the guy who owns the upstream repo and who IMHO wrote that thing to show off how good he was at C++, not to make a useful tool, was unableto resolve on jtag2updi. The experience was so traumatic that had to take a couple of months off away from modern AVRs to recover. jtag2updi is now deprecated and offered only for backwards compatibility with users who already have programmers built. Per the notice in my jtag2updi repo, I am performing no further maintenance on that horrible ball of shit. I would rather sand the skin off my arms with a power sander and walk barefoot through a field of broken glass than touch that code again. It is the most hostile to modification code I have ever encountered. If he dies before me, I expect I'll find him waiting outside the gates of hell, because Satan will have to build a new circle of hell to sufficiently punish him for inflicting that code on the world. And the contractors who wind up in hell are mostly there because they don't show up when they say they will, so construction down there takes ages. SerialUPDI is the recommended method for uploading to modern AVRs and has been for the past two years, and jtag2updi is deprecated. A serial UPDI programmer can be made from literally any TTL serial adapter, a resistor, and optionally a schottky diode - Serial adapters are about a buck for your bargain basement model, the diodes I use are SOT23 common cathode (this is an item that you get a massive china discount on, they're double-digit cents on digikey, and a penny a piece in lots of 100 on aliexpress), and resistors are dirt cheap. You either use a schottky diode between Rx and Tx (cathode to TX, so TX can pull RX low) or a 4.7k resistor (minus any resistance the adapter has on it between the TX pin of chip and the TX pin between Tx and RX. For adapters that aren't CH340G, higher speeds often don't work with just that setup, but putting a 10k resistor in series with the diode helps the rise times enough to make ir work. Total cost is like a $1.10/unit if you cheap out whenever you can. I'm going to be selling some nice serial adapters with s UPDI mode switch, and all the modem control liaison pins broken out so you get 2 GPIO outputs and 4 GPIO inputs that a good terminal program like hTerm will show on the screen. Since I've been trying to start the convention of putting UPDI on the rarely used CTS pin of the FTDI header (at least as a solder bridge option) It'll be a plug and play that will at the flip of a switch, allow you to switch between UPDI programming and acting as a serial adapter with no wires having to move any wires, for boards that support CTS-UPDI. And an optional rider-board to add an LED on all the modem liaison pins, and JST connectors instead of those bloody unreliable "dupont" connectors. These will use CH340G (better serial baud rate accuracy than the ones without ext. crystal), have 3.3v vs 5v controlled by a switch, not a jumper (the swtich will actuate FETs which are capable of handling a full USB load, unlike a certain green USB serial adapter made by an inexperienced hack - the switches are rated for 0.1A, and you just know people are going to put a AVR + ESP8266 on them or something, pulling 3-4 times that. And the connection will be mini-USB, not plug into your USB port directly. And the micro USB ports I use are the good kind - with 4 structural through hole pins so they can't get ripped off the board without so much force you'd snap the board in half first. These of course will cost a bit more than $1.10 ;-) ("dupont" = chinese clones of the harwin m20, which are slightly inferior to Harwin's product. Harwins M20 connector onthe other hand is a huge step down from real DuPont Mini PV connectors of which they were a clone (DuPont, prior to focusing on their core competence of manufacturing polluted drinking water, was for a time in the connector business. They spun that out as Berg, which was then bought by connector giant Amphenol. Which still makes them, and these DuPont connectors are still excellent. Nobody in hobby circles uses them though because they cost 30 cents per terminal and you have to crimp em on your self, which means you need a crimp tool that can handle them. I am aware of three that you don't have to scour used tool shops or ebay and $80+ for used: The SN-025 (can crimp only duponts, and 2 other weird connectors I've never seen), the Toozo TZ-4228, which crimps JST PH, XH, and VH (PH and XH are the most common connectors I see in use after dupont) and others around that size quite well, plus has a proper slot for dupont/DuPont, which requires a round rather than B-shaped insulation crimp., (those are both $20ish chinese ratchet crimpers) and the Japanese made Hozan P707, which costs like $75. The Hozan crimps every JST connector down to ZH, though it's slower to use (2 crimps per terminal) it gives exquisite control and is an absolutely beautifully made tool. I often do a first crimp with TZ-4228, and then tighten up with the Hozan if the wire is on the thin side. And for adverse conditions (multiple wires into on terminal), I do it with the Hozan from the start. DuPont connectors are rated for minimal increase in contact resistance after 1000 connection cycles followed by exposure to moist hydrogen sulfide gas to simulate a corrosive environment. Harwin's connectors are spec'ed for 100 cycles, half that for the non-gold plated ones. No corrosive atmosphere, no maximum resistance specified. . dupont connectors do not spec any sort of reliability numbers, but they're worse than Harwin's Chinese dupont line is made with the lowest quality terminals on undersized wire with the crimper adjusted to crimp less hard than it should to reduce wear on the die (or because the conductor is so thin that even at maximum force it barely holds the wire in place) frequently don't even pass the pull test unless you go over the crimps with a better tool, and are at best considered consumables. Some of the terrminals aren't even brass, but steel, and rust (when I discovered this I dragged a magnet over the dupont line I had and threw out everything that stuck - about half of what I had). I use JST-XH on the adapter end these days, and dupont on the other end mostly with the expectation that I will periodically have to clip the pins off put new terminals on them For smaller boards, I use "microJST 1.25" as aliexpress calls it (actually molex picoblade clones), and so I have a bunchof cables with JST-XH 6 pin on one end, and "microJST" 6-pin on the other (and I buy pre-crimped "microjst" terminal line, that stuff isimpossible to crimp. PH is easy, ZH is a little tricky. GH (the JST 1.25mm pitch connector - and a very nice one, albeit expensive) is not much harder than ZH because it's easier to hold (totally different design) and "micro JST" and JST-SH are very difficult to crimp. Cheapest source of terminal line for connectors smaller than jst zh, bizzarely, is buying cables with the housings on them, running a razor along the side of the housing to cut the clips off, and then discarding the chopped up housings. (basedon aliexpress prices) Apologies for the connector rant. About 25% of my working time has been wasted due to unreliable dupont connections over the past week. If you see any places in the docs that recommend jtag2updi, please create an issue to let me know so that I can correct the docs. jtag2updi is an awful piece of code. Too much of it says "I'm smarter than you, look at all this intricate C++" and not enough "I understand the jtag and updi protocols well enough to make things work, look at how reliably this works" |
Beta Was this translation helpful? Give feedback.
-
I'm having some issues when using ISRs in my code, it seems that occasionally, there's some kind of bug that makes it impossible to reprogram the part (avr64db64), this has happened to me only when using ISRs for timer1 and timer2. The programming error that occurs when attempting to upload code is RSP_ILLEGAL_MCU_STATE. I'm using the jtag2updi uploader running on atmega328.
Beta Was this translation helpful? Give feedback.
All reactions