Programming ATmega4809 with UPDI from R-Pi

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The other day I was sorting through some ideas for interfacing an R-Pi to an AVR so it could program.  That got me thinking about UPDI; I have been looking at ElTangas/jtag2updi and mraardvark/pyupdi.

 

I have decided to try pyupdi with an R-Pi; I will have the R-Pi enable some buffers depending on if I want a standard UART or UPDI.

 

Schematic

 

Part labels: K38 is NMOS BSS138, K84 is PMOS BSS84, DMB is PMOS DMP3098L, Z4 is buffer 74LVC2G07.

 

The 74LVC2G07 is a buffer with IOFF; it is Hi-Z when its power is off (both input and output). So, in theory, I can power the +5V (the SMPS is optional), and that will run the AVR. I can push the button to start (and latch) the R-Pi power; then I can do programming (or whatever). I can also halt (shutdown) the R-Pi with the other switch and then kill the power to clear the R-Pi power latch. It is a bit hacky.

 

For programming, I plan to have a Makefile set the R-Pi BCM24 pin before running pyupdi and then clear it after. When other programs connect to the serial, they are attached to the UART on PA0 and PA1.

 

https://github.com/epccs/PiUpdi/tree/master/Hardware

 

Eagle files

 

https://github.com/epccs/Eagle/tree/master/PiUpdi

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Ron,

Here is an interesting topic cheeky I was playing around theses days with pyupdi on an OrangePi, but I could'nt make it work properley. I got stuck on the issue#27.

Have you managed to make it work ? I thought using one the UARTs for programming, but if you can make use on only BCM24, it would be great !

 

Currently I can make use bitbang the Raspberry GPIOs for ICSProgramming an ATTiny84, but it is so much pin consumming, and I would prefer to go on the new tiny3216/3217. The tiny84 is more than 10 years old and quite limited.

 

Anyway, thank you for starting this project !

Nico

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

On an R-Pi, avrdude -c linuxspi needs some updates, but it does work for ICSP. I have not used avrdude -c linuxgpio. The R-Pi also bootloads over the hardware UART perfectly (with CTS/RTS enabled, and RTS used to start the bootloader). I have no experience with OrangePi (thought on that issue it said R-Pi). I am confident that the R-Pi UART works since I have been using it. Here is a link to my last toy that does some of that.

 

https://github.com/epccs/Driver/tree/master/ICSP

 

If UPDI works on this board, I may add it on some future spin of that ICSP board (I will probably remove the spring probes, they need to be on a separate little board).

 

I will order the board soon for testing. It has four transistors, two IC's and a hand full of passives, so I am 100% sure there is not more than a few mistakes.

 

There should be a better option for enabling IOFF buffers, but some hacks are good enough, I say test it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ron_sutherland wrote:
There should be a better option for enabling IOFF buffers, ...
or alternatives

  • mega4809 Curiosity Nano, multiple 1-bit dual-supply bus transceivers (direction pin)
  • Arduino Nano Every, common level translator (there's one power source via USB Vbus or a buck converter module)
  • bi-directional dual-supply level translators (no direction pin, nFET with well control so no reverse current, active pull-ups for edge speed then usually a bus-hold)

ron_sutherland wrote:
... but some hacks are good enough, I say test it.
Will be close to correct given your success with the ICSP board.

There are Raspberry Pi protoboards.

 


ATmega4809_Curiosity_Nano (page 3, center, UPDI + RESET + UART to USB CDC ACM + two GPIO) via ATmega4809 Curiosity Nano

NANOEveryV3.0.sch via Arduino Nano Every

NLSX4373: Level Translator, 2-Bit, 20 Mbps, Dual-Supply

MPM3610 | Power Modules | 21V Input, 1A Module Synchronous Step-down Converter with Integrated Inductor | MPS | Monolithic Power Systems

https://schmartboard.com/search.php?search_query=Raspberry

edit : 710-0010-01 SchmartBoard | Mouser

 

"Dare to be naïve." - Buckminster Fuller

Last Edited: Fri. Sep 27, 2019 - 12:48 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This board has not been a priority, but I did manage to get a compile to work with the MC 3.6.2 toolchain, also VScode. It needs some tuning, but the listing showed instructions that at least seem reasonable (progress).

 

https://www.microchip.com/mplab/avr-support/avr-and-arm-toolchains-c-compilers

 

I put the toolchain on a local file share (Samba). The Makefile is done to run those programs rather than the ones found with the packaged toolchain (which I will keep using for other projects). I think the important thing to notice is how the -I option is used to help the compiler and linker find the sideloaded files before looking elsewhere. I would expect this to be fragile, so it is probably not much more than a hack.

 

https://github.com/epccs/PiUpdi/blob/master/Uart0_hello/Makefile

 

VS Code and Intelasense also worked.

 

https://github.com/epccs/PiUpdi/tree/master/.vscode

 

I guess it is time to order some parts and build one.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Still not a priority, but I think I will try to keep its licenses on the BSD(ish) side. With that said, my first hack at an IO Library using enum has been added (but not tested).

 

https://github.com/epccs/PiUpdi/blob/master/lib/io_enum_bsd.h

 

I thought VScode would be able to present the enum list if I used them for function parameters, but not as well as I hoped. Anyway, a blink with it looks like this.

 

#include <util/delay.h>
#include <avr/io.h>
#include <stdbool.h>
#include "../lib/io_enum_bsd.h"

int main(void)
{
    ioCntl(AIN0, PORT_ISC_INTDISABLE_gc, PORT_PULLUP_DISABLE, PORT_INVERT_NORMAL);
    ioDir(AIN0,OUTPUT);
    ioWrite(AIN0,HIGH);

    while (1)
    {
	    _delay_ms(500);
	    ioToggle(AIN0);
    }
}

 

 

This also lacks any sort of checking so a bad enum value will build, but I think that is what I want.