Self-ISP on an Uno

If I use avrdude all I need to change is the at90usb162 and -c usbasp, do the fuses and upload that hex right? Id try it now but im repairing my 10 to 6pin connector and ran out of butane for my iron

That sounds right, but I'm unfamiliar with the usbasp programmer.

Ok so I think im successful with my uno r3 and the usbasp, however I don't have proper jumpers to actually test it
but this works with ide 1.0 right? All I should need to do is connect jumper and upload using arduino as isp?

To test the serial mode you don't need any jumpers - just use the board as if it were a totally normal Uno.
Running test_serial.bat will connect avrdude to the 328P's bootloader and report the Optiboot version number (amongst other things).

To try the ISP mode, connect the 8U2 to the 328p ISP header as follows:

  • MISO-16U2 to MISO-328p
  • SCK-16U2 to SCK-328p
  • MOSI-16U2 to MOSI-328p
  • PB7-16U2 to RST-328p
  • PB6-16U2 to PB4-16U2

Check the drawings in the docs folder of the zip file for the relevant pin locations.

In this mode the 16U2 chip will behave just like an ArduinoISP. Running test_isp.bat will connect avrdude to the 16U2's ISP code and report the arduino-usbisp version number (of which the minor version number is really the number of bytes of free memory).
With the jumpers in place you may update the 328p's bootloader with the IDE: Select "Board -> Uno", "Programmer -> Arduino as ISP", followed by "Burn bootloader".

I tested the serial uploading programs to a bootloaded 328 with the ide, I had to reinstall the driver I guess with different firmware it was a different version, still neeed to try the isp, unfortunately I gotta wait for some female-female jumpers to come, I dont have anything to bootleg to the pins other than female headers and that gets messy and wastes headers lol,
I haven't used arduino as isp before but would a 328 instead of a 328p cause problems with the signature?

Be Very careful of using 'mini' dip switches... they have a reputation for Failure when frequently or infrequently used.
Back in the day, before I retired I had occasion to use them (Dip Switches and hand soldering would 'kill them' regularly
if they were for example not all off or on, I can't remember now which but after 2 'failed, intermittent design's I quit
specifying them in my work.

Doc.

The programmer doesn't care about the chip signature, so you can use it to burn a bootloader to the 328(not-P) chip. You might not be able to do it with the IDE GUI, however -- AFAIK all the official Arduino boards use the 328P.

Here's a little script to write the Uno bootloader to a blank chip (change set BINARY= to point to your preferred bootloader). With the -F options it should ignore the chip signature and upload to a 328(not-P), although I don't have one of these chips myself. Paste the code into a .bat file inside the hardware\arduino\firmwares\arduino-usbisp directory. Let us know how you get on.

@echo off
REM 8U2 in ISP mode
REM Burn Optiboot bootloader

set TOOLS=..\..\..\tools
set AVRDUDE="%TOOLS%\avr\bin\avrdude"
set AVRCONF="%TOOLS%\avr\etc\avrdude.conf"
set BINARY=..\..\bootloaders\optiboot\optiboot_atmega328.hex
set BAUD=19200
set /p PORT=Enter port number:

"%AVRDUDE%" -C %AVRCONF% ^
  -p atmega328p -F -P COM%PORT% -b %BAUD% -c stk500v1 -e -u ^
  -U lock:w:0x3f:m ^
  -U efuse:w:0x05:m ^
  -U hfuse:w:0xDE:m ^
  -U lfuse:w:0xFF:m
"%AVRDUDE%" -C %AVRCONF% ^
  -p atmega328p -F -P COM%PORT% -b %BAUD% -c stk500v1 -v ^
  -U flash:w:%BINARY% ^
  -U lock:w:0x2f:m

pause

Yeah im actually using a mini non momemtary push button I found, I couldn't find a single dip switch, all I had was a quad and more
ill let you know how the chips go in a bit, just bought three 328p from digikey

How about taking this idea and making a board that could replace the FTDI Breakout Board with the additional feature of an on-board ISP? 2 functions for about the price of either. One of the vendors like Sparkfun or others might be interested.

The chips came in, and the jumpers of ebay
I already reprogrammed the 16u2 in my rev3 with a usbisp
I added a nonmomemtary push button across the right pins,
I selected arduino as isp in the ide, clicked burn bootloader
then uploaded a fresh blink sketch
100% perfect success, I think they should add this to rev.4
Then since it will come preloaded on the 16u2 just about anyone who buys an arduino can very easily burn bootloaders without any additional hardware or isp their own board for some extra space,
excellent and thank you for this project!

Ooof, first feedback! Thanks for the report and the kind comments.

In the meantime I've made an Arduino sketch to update the 8U2/16U2 (thanks to some neat work by Nick Gammon), so it is now possible to make an Uno update itself - no need for a second Arduino or other programmer. If any body fancies trying it I'll dig it out.

Are you planning on making a 16u2 version that retains the dfu programming? Or I guess its not really needed with the arduino sketch

It would be better to keep the DFU bootloader, to make subsequent reprogramming easier. I don't have an Uno R3 (yet), but I'll look into it.

tim7:
It would be better to keep the DFU bootloader, to make subsequent reprogramming easier. I don't have an Uno R3 (yet), but I'll look into it.

I have a Arduino UNO R3 (clone by EKitsZone). I self has interested to create ISP-programmer interface based on mega16u2. Simultaneously, these i did not want to lose the use of DFU. Memory size of 16u2 should allow cram two program block (serial&isp + dfu). I had to cast with source code, him compiling and tuning ... The result can offer a ready-made firmware for 16u2 - use please ... http://files.migera.ru/arduino/isp/16u2-uno-r3-dfu-isp.hex

PS. Burn to 16u2 through usbasp (example) and avrdude ...

JoeO:
Great idea!

Tim7 - Could you also reverse this? Could you download a program to the 328 that could then reprogram the 8U2? Are the signals available on pins to do this?
This would be something like what the optiLoader does?

Cool! If you get this working, will I be able to download a program to the 328 that reprograms the 8u2 via ICSP, which then reprograms the 328 via ICSP? :slight_smile:

Hi!!!!!!!!!!!

This is very exciting and ingenious. Could there be a HIDUINO mode, instead of a ISP mode?

Viral bootloaders have been around for a while in the AVR line... There may be earlier examples, but the first I remember taking notice of was the one by Bluebie used in the Attiny85 Digispark:
micronucleus

Ray

Wow! This is awesome. I am using a UNO R3 and it works(I think- I just fried my processor and ordered a new one). The serial works great!
A great idea! Karma for you!
I know this thread is dead, but it is just too cool.

The firmware doesn't work to upload to the Uno at 115200 baud.