I currently am working on a project of a board designed by a coworker. The board contains a atmega328P 28 MLF, voltage regulator, serial to rs485 and several sensors. Now i have been asked to program the board but i am having some trouble with it.
I connected the wires to burn the bootloader through a arduino UNO with arduino ISP loaded into it.
Now i am trying to burn the bootloader but i am getting the following error:
avrdude: Expected signature for ATMEGA328P is 3E 95 2A
Double check chip, or use -F to override this check.
Now i did search for this error and as expected the signature is wrong. But i cannot figure out which signature is needed for the atmega i have. Anyone has a way of finding out what the signature is?
Thank you for your time,
Mark
Edit:
After a few attempts i got another error:
***failed;
avrdude: verification error, first mismatch at byte 0x0000
0x3f != 0x00
avrdude: verification error; content mismatch
If it got past the signature, it seems the signature changes but that seems unlikely. Or is that possible?
You need more information. You can't do this job, with a board and no information about it.
The board is not well designed. There is no GND connected to the ATmega chip in the schematic. Also no Vcc to 3.3V. And the AREF is connected to 3.3V, that is an error. The ATmega should not run at 16MHz at 3.3V, that is outside its specification.
You must know if it has a bootloader and which one or no bootloader.
When it doesn't have a bootloader, you need those ICSP signals like MOSI, MISO, SCK to burn a bootloader. There is no other way.
Sometimes you have to connect RX to TX, but sometimes RX to RX. The labels are not very clear. Can you try a few times to see if Arduino can communicate with a bootloader ? Start with the Uno board. If you can't connect to the bootloader, the board is useles.
I currently have Miso,Mosi, sck connected to a arduino UNO. I did manage to solder some small wires to the pins of the chip.
And trying the burn the bootloader gives me an error with the signature.
Can you read the text on the ATmega chip ?
Do you know the signature of that chip.
If avrdude reads only zeros, your wiring is not okay.
In the settings you can enable more output text. Perhaps you can try avrdude from the command line. Without any upload command and use -vvv for maximum output text.
Text on the chip is = A239 M328P HDB 2W5859
Avrdude is not returning any zeros, i did recheck my wiring and found out that one of the wires was not properly connected to the UNO. So i made sure they are connected now. And tried to burn a bootloader again.
But now i get the following:
avrdude: stk500_program_enable(): protocol error, expect=0x14, resp=0x50
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
It could be a timing error in the programmer, but I think the Uno as ISP should be allright.
Can you buy an USBasp for a few dollars, to have something extra.
Are you sure that an output pin of the Uno can toggle the reset of the target chip ?
The reset is part of the programming signals.
I suppose that M328P is the ATmega328P, so that is okay.
Keep in mind that the board could be broken. You were given something that is not very good, so what else is bad with it.
The long debug output of avrdude probably shows all the errors that it expects other data. I think you have to have some good data in the communication to make sense of that debug output.
I'm assuming the grounds on the chip is implicit so they don't show up but OP has hands and multimeter so go ahead and check.
I realized that for myself, I couldn't burn bootloader without first supplying the target chip a crystal and caps first.
Yes, as Peter_n said running 3.3V supply at 16MHz is over the limit. About 12MHz is all it can do at that voltage. Read the diagram.
Regarding MO and MI lines, MO goes to MO and MI goes to MI.
I've been using optiloader to bootload instead of using another arduino. It recognizes more signatures and has more helpful information.
I indeed suspect the board is broken at the moment, at least the atmega chip. But following your comments i will issue a new board for the final product.
I did check the board again. The ground is located beneath the chip and looking at the board layout i see that the ground is connected. And i see a line going to the vcc as well. So i think that is good, just someone forgot to add those to the schematic.
If you have any other tips for the new board i'll gladly take them with the new version.
The changes to the board at this moment are as followed:
A 8MHz crystal
ARef will no longer be connected to the 3.3v
Adding connector pins for SCK, MISO and MOSI
Are you sure that an output pin of the Uno can toggle the reset of the target chip ?
The reset is part of the programming signals.
Yes i think so, according to the guide of ArduinoISP, pin10 should be connected to Reset so i assume it is doing what its supposed to.
And i'll get an USBasp as well, it is indeed better to have 2 ways of burning the bootloader in case one of them indeed doesn't work.
Maybe i'll see if i can burn the bootloader before soldering the atmega to the board.
At least thank you for your replies, they helped me alot. It is my first time attempting to burn a bootloader and not being involved in the design of the board didn't help.
When you make it compatible with one of the Arduino boards, you don't have to create a special bootloader.
For example the Arduino Pro Mini has a 3.3V 8MHz version with external crystal. The schematics are available, so you can have a good look at that schematic.
If timing and the serial UART is not very critical, you can use the interal oscillator, there are also Arduio boards that have that. Scroll through the file 'boards.txt' and look for the 8 MHz boards.
When your board is compatible with an Arduino board, you can burn the bootloader with the Arduino IDE, and also the fuses will be set.
When you create your own bootloader, you have to get the fuses right, which is always the hardest part (for me).
Ok understood.
But then i have one last question the arduino pro mini has a atmega168 which as far as i know has half the data available for programming then a atmega328. Now i have found that the arduino mini has a ATMEGA328P-MU and when i look at the datasheet can perform at 3.3v just fine even though the mini itself runs at 5v. Would the difference in voltage give me problems burning the bootloader? When i select the mini with the atmega328 as board to burn the bootloader?
I am asking this because of the sensors i have on the board and when i look at the example programs of both i reach about 17kb worth of programming when compiled for a atmega168, which is too much. I know i can probably shave some off but i prefer having plenty of kb left then getting close to the max.
I see, the reference is still about the ATmega168 : http://arduino.cc/en/Main/ArduinoBoardProMini
But with the ATmega328p is the same. and the Arduino Pro is the same.
The Arduino Mini is only in 16MHz version.
When you select in the Arduino IDE the board "Arduino Pro or Pro Mini" you can select 4 options for the processor, also the ATmeg328p at 3.3V with external 8MHz crystal.
In boards.txt you can see which fuses and which bootloader are used.
arduino-1.5.8 \ hardware \ arduino \ avr \ boards.txt
The section : "Arduino Pro or Pro Mini (3.3V, 8 MHz) w/ ATmega328"
I prefer you use the ATmega328p, it is the most common chip for Arduino projects.
When using 8MHz you can use it at 3.3V and at 5V, but your sensors don't allow 5V.
Because of the sensors, when you program the bootloader or upload a sketch, you must have 3.3V signals. Some FTDI modules can switch between 5V and 3V and many usb-serial adapters (like the CP210x) supply 3.3V signals.
The bootloader doesn't know at what voltage it runs. The ATmega chip at 8MHz runs fine at 3.3V and 5V. You can even change the voltage while it is running. That is why an ATmega chip at 8MHz can run directly on a Li-ion battery.