Go Down

Topic: Found some ATMEGA8-16PU chips (Read 1 time) previous topic - next topic

pepelevamp

Hi guys! I need some help getting a chip working.

I found a couple of these chips marked ATMEGA8-16PU. They're in a DIP package & sit right into my Arduino UNO.


Only thing is - I don't know very much about standalone Atmel microcomputer chips.

Here's what I do know:

I understand Arduino IDE bakes a .HEX which avrdude then rubs into my Arduino's Flash (program) memory.

* I have successfully programmed via ICSP both the main CPU and the ATmega8u2.
* I have successfully put the ATmega8u2 (the USB chip) into DFU mode, and put on a new firmware that way.
* I have avrdude here and the atmel toolchain. I can compile things but nothing I've made works so far
* I'm only just starting to learn about the bootloader, the fuses (config bytes)
* I understand a little bit about saying use an internal clock vs external

What I don't understand is how the bootloader works in all this.
I'm confused by what is running at any given time. Is the bootloader responsible for making DFU mode happen? IE is DFU mode done in software?


If I were to put this ATMEGA8-16PU chip into the Arduino Uno's slot, what option would I select in the IDE?

Would I be able to use avrdude to program this thing? And if so, what settings would I use? What would I put as far as the fude bytes go?

Do I have to do the 'burn bootloader' thing? What does it do? Help.

I have here a second Uno working in ISP mode.

I looked to find a datasheet but I found this kinda generic ATMEGA8 one. I can't seem to use -pat8 option in avrdude. It doesn't like it.

Thoughts?

http://pdf1.alldatasheet.com/datasheet-pdf/view/171443/ATMEL/ATMEGA8-16PU.html
I like to spend a lot of time & money on finding ways to save time & money.

avr_fred

#1
Jun 27, 2017, 12:01 am Last Edit: Jun 27, 2017, 12:09 am by avr_fred
Quote
I'm confused by what is running at any given time. Is the bootloader responsible for making DFU mode happen? IE is DFU mode done in software?
Yes, a bootloader makes DFU mode possible. But, using that terminology may be what has you confused. DFU really doesn't apply to the Arduino sketch since there is no operating system. What O/S there is, gets replaced every time you upload a new sketch.

The bootloader only exists to allow updating replacement of the entire user program via a USB/serial connection. A board does not need a bootloader if you flash the unit using "Arduino as ISP" or other dedicated programming means (USBASP, etc).

If you have bootloader in memory - it only runs once, for each reset operation of the Arduino board. That reset can be a power cycle, a press of the manual reset button or in very rare cases, it can happen by design by jumping to address zero of the program or by way of a program crashing - that leads to execution of address zero. Most Arduino bootloaders will announce their presence by blinking an LED on the board rapidly three times when it executes after a reset.

Quote
If I were to put this ATMEGA8-16PU chip into the Arduino Uno's slot, what option would I select in the IDE?
There is no option for this in the base package. You could possibly create a new entry in the "boards.txt" file for different processor or you could just add a "core" that supports the processor directly. See this link for atMega8 support: https://github.com/MCUdude/MiniCore

Quote
Would I be able to use avrdude to program this thing?
Yes. Avrdude is your swiss-army-knife for programming Arduino. Whether you're programming directly with an ISP or through a bootloader, it's all done with avrdude.

Quote
I can't seem to use -pat8 option in avrdude. It doesn't like it.
Try the option "-p m8" omitting the quotes.

EDIT: Note that the only way you can flash a bootloader onto a new atMega is with an ISP device. In your case, it would be the second UNO in ISP mode.

IMO, I would wait until I had another ISP programmer on hand before doing any direct manipulation of fuses and other command line avrdude use. If you happen to accidently erase the bootloader or change fuses incorrectly and you don't have an ISP programmer, you're stuck. Invest $3 in one of the cheep-o USBASP's and you're in the ISP business without tying up the other Uno.

DrAzzy

I would suggest you install and use MiniCore (linked above), it's absolutely the right tool for working with atmega x8-series chips on breadboards. He also maintains a core for some of the other families of AVRs, and I maintain a core for most of the ATTiny line.

DFU mode specifically refers to a functionality of native USB parts (like the 16u2/8u2 used as a serial adapter on the Uno).

Burn bootloader does two things - it sets the fuses, and it programs a bootloader (if there is one for that chip) into the flash on the chip.

The function of the bootloader is to allow you to program the chip via the TX/RX serial pins, instead of by ICSP. It's located at the end of the flash, and when BOOTRST fuse is set, the chip knows to jump to the bootloader, and run that. The bootloader (in this case) listens on the serial port for certain commands - if it gets commands telling it to write the flash, it will do so, otherwise it jumps to the application code.

An Uno (or most other Arduinos) is a serial adapter (in this case, the 16u2 or 8u2 is programmed to act as a USB serial adapter), connected to the serial pins on the microcontroller.

Note that a "bootloader" doesn't specifically mean that it uses UART serial - it's a generic term for something that runs before the application code and has the function of being able to update the application code.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

pepelevamp

Hi guys thanks for ya replies.
So quick cap: The bootloader is code which runs on boot, then provided RX/TX serial stuff is not happening, it goes to execute my program.

So this means when I write a program from the Arduino IDE, and select 'upload' NOT 'upload using programmer' it is in effect writing the bootloader AND my application into the chip?

My understanding is if I had the bootloader on the chip, and then used the serial interface to upload a new sketch, the new program would overwrite the bootloader.

OR

Is the IDE / avrdude specifically saying 'upload the new application after the bootloader, so the bootloader can still execute on next boot'   ??
I like to spend a lot of time & money on finding ways to save time & money.

westfw

Quote
Is the IDE / avrdude specifically saying 'upload the new application after the bootloader, so the bootloader can still execute on next boot'   ??
This one.   technically, the application comes "before" the bootloader in memory, but the key point is that the bootloader has to be loaded into the chip first, and then it stays there and will try to load in a new application each time it sees a hardware reset (if there is no "new" app seen, it runs the application that is already loaded.)

The bootloader is never erased or replaced, unless you use the "upload using programmer" or "burn bootloader" commands (or some external process that does similar things.)


Go Up