UPDI Enable Sequence by 12V Programming (SOLVED)

Latest Firmware Documentation


I plan on using the ATtiny804 in a future project and have just started to "play" with an ATtiny1614/1604 dev board to get familiar with these new MCUs. I'm not sure if this is possible, but I'd like to program these MCUs in a way that automatically provides the 12V UPDI enable pulse as described in the datasheet using no jumpers or additional procedures to follow. I'll need to make a programmer board or breadboard circuit for this and could use a 5VDC to 12VDC charge pump IC and opto-isolator to inject the pulse.

I've modified the jtag2updi code so that the program mode LED output is enabled for mostly all of the transmission or signal activity with an Arduino Pro Mini as a UPDI programmer. As early as possible in the transmission, I was able to create a 406µs pulse that occurs 4.67ms prior to the first falling edge on the UPDI signal (double break). The datasheet states that the pulse needs to have 100µs to 1ms pulse width.

Here are the waveforms:

Complete transmission

RXI, UPDI, PULSE zoomed at start of transmission

Would injecting 12V on the UPDI 4.67ms early (prior to double break) create any problems?

I know there was a bunch of discussion of this on github somewhere - will try to find it. I know hansibul was working on a standalone programmer that would be able to do this; not sure if he ever got to the point of actually making the hardware for it - though I am pretty sure I saw a rendering of it, which I think means he had laid out the board.

Right now there is apparently only one Atmel programmer that supports the HV UPDI pulse ("Power Debugger", and there is some ambiguity in data sheets as to exact requirements, and we don't have many known-working examples.
People have reported that procedures as lax as "apply 12V to the pin manually, and then run normal UPDI" have worked WITH SOME CHIPS. Other reports are that some of the newer chips (esp tiny1) have tightened up on that a lot, since you don't want transients or noise to put the chips into UPDI mode. But it's not clear which chips have which requirements, either :frowning:
There was some discussion on avrfreaks.net

Thanks DrAzzy, That sounds familiar (I've been researching for a few days). BTW, I've been using your development board and it works fantastic!

westfw

There was some discussion on avrfreaks.net

Yea, I've seen that. I'm hoping to get something working that's compatible with all the 0 and 1 series ATtiny chips that work with the megaTinyCore.

Well, just now I've got to the point of using some spare parts on a breadboard to inject the 12V signal and testing if it affects normal programming. Tried 5 times with different sketches .. worked fine. No change in programming procedure was required, just "Upload Using Programmer".

The spare parts I used were an 814A optoisolator to inject the 12V pulse on the UPDI line. To protect the UPDI pin on the Arduino Pro Mini end, I used a signal diode and series 1K resistor.

The properties of the pulse at the ATtiny (labelled Channel 2):
Ramp 5µs, Width 0.52ms, Peak 11.8V

D6_UPDI is the waveform at the Arduino Pro Mini.

Here are the waveforms with progressing levels of zoom:



When I get some more time, I'll test this with the UPDI pin configured as a regular input and output. I'd like to use this in a noisy environment, so it would be good to program the UPDI as an digital output and drive it low if unused and to easily re-program if required. Also, a benefit would be having an additional input or (weak) output pin available.

Oh sick! Please keep me posted on this - if there's a way that this could be made to work without breaking functionality for normal uploads, I would love to roll this in. An "if you want to do HV programming, add these couple of parts to your nano-running-jtag2updi" type solution would be insanely great!

I have made a working 12V UPDI programming board. The first revision has some minor issues, but these were fixed in the next version. I'm currently waiting for PCBs from China for them.

The board looks like this. It uses the jtag2updi firmware and generates 12V using a voltage multiplier. IIRC it measures 24x42mm. I am able to do "regular programming" using UPDI, and I'm also able to use the board as a regular USB to serial adapter with auto-reset functionality. However, even though the hardware works as it should I have some work to do on the jtag2updi firmware side. I may need some help from the creator of the jtag2updi project.

Note that this is the schematic of the old revision. The main issue is that the 16 MHz crystal is attached to the wrong pins :-[

hansibull, nice looking board. In my revision of the firmware, I have the 12V pulse control signal self-generated a few bits after the first activity on RXI (generated once per complete programming transmission).

DrAzzy, even though I haven't tested this yet with UDPI programmed as output, I'll attach the firmware (below) to take a look at.
REMOVED - Would create a stretched pulse signal during power-up (will be fixed later)

Firmware Revisions:

● Added 12V pulse control signal to Arduino pin D12
● Changed the LED on pin D13 to remain on during transmission activity
(the LED output status is checked and used to disable any additional triggering of the pulse)
● check jtag2updi.cpp, jtag2.cpp, sys.cpp and sys.h for revisions

After I do some testing (hopefully I don't "brick" the MCU), I'll post the results.

Here's the circuit I used:

To generate the 12V supply, this part looks interesting.

hansibull, nice looking board. In my revision of the firmware, I have the 12V pulse control signal self-generated a few bits after the first activity on RXI (generated once per complete programming transmission).

I figured that a simple voltage multiplier using some BAT54S diodes works great. A 12V zener at the output makes the voltage quite stable. It takes up about as much space as the ST662, but is significantly cheaper. The multiplier is driven by a 50% duty cycle timer output from the microcontroller.

dlloyd send me a PM if you need an assembled board to test on. It would be great if we could have an open-source programmer that supported 12V UPDI programming!

hansibull, thanks, I'll let you know. Still have lots to learn yet with programming as I have more experience with hardware.

Did some further testing. At no point did UDPI programming fail, but I wasn't able to test the UDPI pin set as output as I was unable to configure it as GPIO. I've looked through boards.txt, pins_arduino.h and looked through some files in the optiboot_x folder.

I checked the status of FUSE_SYSCFG0 and would consistently return binary 11000101 after using both options for UPDI in the tools menu. What is the best way to clear the RSTPINCFG bits to enable GPIO?

Direct port manipulation or using Arduino commands worked fine on all other pins except with the UPDI pin. My board is the ATtiny1604 programmed with optiboot option (v1.15).

Thank you so much! Hopefully will have a chance to try in the next day or so.

If this works with just a nano, a couple of simple external parts (could use a stock boost module from ebay to get the 12v), and slightly modified firmware, that would be beyond awesome. More accessible than a specialized board as well (sorry Hans!)

dlloyd:
I checked the status of FUSE_SYSCFG0 and would consistently return binary 11000101 after using both options for UPDI in the tools menu. What is the best way to clear the RSTPINCFG bits to enable GPIO?

I would do "burn bootloader" with verbose upload output enabled in preferences. Scroll up in console to where it shows the avrdude command (this will also have all the paths to the the avrdude.conf and correct version of avrdude, too)

Then, copy this to notepad, change the fuse setting (check datasheet to convert fuse numbers to find the right fuse that has a bit that sets the reset pin config), modify the setting for that (you can change it to , and then open a command prompt and paste in your modified command from notepad.

As an aside - I opened an issue to add support for reset pin as GPIO to options. If this works, will also expand UPDI programmer building section, and add those options to non-optiboot board def as well. Add UPDI pin as GPIO to optiboot board definitions · Issue #150 · SpenceKonde/megaTinyCore · GitHub

Having some issues with avrdude where programming halts at:

Cannot locate "flash" and "boot" memories in description

No worries though, as I'm not trying to resolve this right now. I actually prefer to have an ATtiny chip or two that needs memory and/or fuses cleared and/or reset.

Next, I'll look into getting an Atmel Power Debugger (see reply#2) to continue development of 12V UPDI programming. Then, at some point, get the signals off the breadboard and on to a small pcb with smt components.

Cannot locate "flash" and "boot" memories in description

is a spurious error, it happens on successful uploads too. If uploads are failing, that message is a red herring. I think it's either an avrdude bug, or problem with avrdude.conf - but it doesn't indicate any problem for programming.

From various resources, I see a series resistor used for the UPDI pin. I would recommend lowering the value to 1K (I'm now using 470Ω). Here's why:

From the ATtiny3217/ATtiny1617 datasheet, Figure 38-31, the I/O Pin Input Threshold Voltage for Vil is about 36% of VDD (5V) which would be 1.8V. My saleae logic analyzer / scope has digital threshold settings of 1.2V, 1.8V and 3.3+V.

When set to 1.2V threshold, the digital waveform misses the higher frequency UPDI data bits. When set to 1.8V threshold (coincidentally the same as the ATtiny powered at 5V), the digital waveform is OK.

Note that the signal analog signal's minimum voltage gets "lifted" to 0.6V or higher at higher bit rates

EDIT: Use 1K
The 470Ω series resistor resolved the issue. Minimum voltage became 0.06V and the analog voltage had better response. This waveform was created using 1.2V threshold setting.

12V UPDI Programmer Status:

Making good progress. I've updated the firmware to replicate the tightened and better documented procedure in the ATtiny3217/ATtiny1617 datasheet. I'm awaiting delivery of one more part within the next few days, then should be able to begin testing.

Right now, I have one ATtiny1606 board that works fine as the UPDI/Reset pin is programmed for UPDI. My other ATtiny1604 board has the programming pin set as Reset and has unknown status. During power-up, this pin was subjected to an unwanted 12V signal lasting up to 3 seconds.

I also have an ATtiny817 Xplained Mini, an ATtiny817 Xplained Pro and an Atmel Power Debugger if needed (there will be a learning curve for me with this).

Couldn't wait for the power switch IC, so I made up a crude 5V power switch with a 2n3906 PNP and 2n2222 NPN transistor (controlled by the Arduino Pro Mini programmer). Note that he updated firmware now automatically provides a 5V power cycle to the target as POR/System Reset is now the initial stage of the 12V programming sequence. I'll post the details here later when ready.

Tested the ATiny1604 that had been abused with intermittent 12V power on the programming pin which was stuck being programmed as Reset. The very first try (and all others) worked perfectly!

Burned bootloader with and without optiboot and with "UPDI Reset: DANGER Read docs first" and with "UPDI (powercycle to enter bootloader)" Tested about 20 times where each test also involved successfully uploading a test sketch. I'll follow up later with details on the programming sequence and test circuit.

Remaining to test is the programming pin set as GPIO ... input, analog input? and output.

12V Programming Sequence Specifications and Measurements:

Reference document: ATtiny3217/ATtiny1617

Seq  Section Description                           Min   Max Unit  Measured
---------------------------------------------------------------------------
All 33.3.2.4 OE Timer Protection for GPIO Config   8.8    --   ms   3744 µs
 1  33.3.2.2 POR goes high imediately               --    --   --     -- --
 2        -- Delay to allow power switch turn on  2000    --   µs   2000 µs
 3  Fig 33.6 12V ramp                             0.01  4000   µs      3 µs
 3  33.3.2.2 12V Pulse (11.5-12.5V) duration       100  1000   µs    550 µs
 4  Fig 33.6 Debugger.txd = z                        1    10   µs      3 µs
 5     37.20 TRES, Break on RESET (double break)    10   200   µs    144 µs
 6     37.20 TDebZ, Duration of Debugger.txd=z     200 14000   µs   1000 µs
 7  Fig 33.6 SYNC (0X55) (autobaud)                 --    --   µs     44 µs

The complete 12V programming sequence takes 3.744 ms which is well within the output enable timer protection (8.8 ms) for GPIO configuration which begins after power on reset.

Here is the waveform:

Proposed circuit:


EDIT: Use 2.2K series resistor for UPDI (not 470 ohm)
Power switch symbol/pinout needs updating.
Power switch and 12V charge pump are untested.

Note:

The 12V sequence activates once on power-up ... the UPDI/RESET/GPIO pin automatically powers up in UPDI mode when connected to the Arduino programmer. The reset button can be used to send an additional sequence if ever required.

Testing GPIO configuration on ATtiny1604 UPDI pin:

Changed -Ufuse5:w:0b11001001:m to -Ufuse5:w:0b11000001:m resulting in this avrdude command run from Windows powershell:

C:\Users\dlloy\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude -CC:\Users\dlloy\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\1.1.5/avrdude.conf -v -pattiny1604 -cjtag2updi -PCOM4 -e -Ufuse0:w:0x00:m -Ufuse1:w:0b00000000:m -Ufuse2:w:0x01:m -Ufuse4:w:0x00:m -Ufuse5:w:0b11000001:m -Ufuse6:w:0x03:m -Ufuse7:w:0x00:m -Ufuse8:w:0x02:m -Uflash:w:C:\Users\dlloy\AppData\Local\Arduino15\packages\megaTinyCore\hardware\megaavr\1.1.5/bootloaders/optiboot_x/optiboot_txy4_rst.hex:i

This was successful, but then could not upload a test sketch. Used a 10K pullup on UPDI pin to resolve the problem. Successfully uploaded this sketch to check SYSCFG0 and "blink" the UPDI pin configured as an output:

void setup()
{
  pinMode(11, OUTPUT);  // Arduino pin 11, ATtiny1604 pin 10, PA0, UPDI
  Serial.begin(115200);
}

void loop() {
  digitalWrite(11, HIGH);
  delay(500);
  digitalWrite(11, LOW);
  delay(500);
  Serial.println(FUSE.SYSCFG0, BIN);
  }

This is the waveform ... not good on the baseline voltage, however the power switch part has just arrived.
Amazing this still worked!

Couldn't verify the "blink" with LED ... need to update the power circuit first.
However, I was able to verify the fuse setting on the serial monitor:

Now, I think the biggest challenge will be temporarily adapting a tiny SOT-23-5 part to be breadboard friendly.

I've read about this over at the Avrfreaks forum. I thought the only way to unlock a chip that has its UPDI pin turned into reset or GPIO was to send a 12V pulse on the UPDI pin followed by the NVMPROG key (4 bytes IIRC). Isn't this correct?

hansibull, I believe this is done within the firmware code later on, The 12V programming sequence just kicks the mode of the programming pin back to UPDI mode as long as power is available. The next POR (power-cycle) reloads the fuse configuration.

The power switch part number should be MIC2005A-1YM5-TR

Definition of insanity...

Great signals now for the target power (ATtiny1604).
This shows the signals just after releasing the proframmer's reset button
Rise to 5V by the power switch, 12V pulse, double-break, sync.

The LED circuit with 1K draws 2.78 mA ((4.48-1.70)/1000)
The LED was blinking quite brightly.
Crazy seeing this on the UPDI pin (quite usable as an output).