Author Topic: Bootloader on SMD Atmega328P-AU  (Read 40556 times)

0 Members and 1 Guest are viewing this topic.

Offline IanJTopic starter

  • Supporter
  • ****
  • Posts: 1580
  • Country: scotland
  • Full time EE biz & Youtuber
    • IanJohnston.com
Bootloader on SMD Atmega328P-AU
« on: July 29, 2013, 06:34:18 am »
Hi all,

For a project I'm working on I am using an SMD Atmega328P-AU. I bought a few virgin 328P's and using a ZIF socket for the SMD 328P I built a small board with the ISP header on it and c/w crystal.

First things first though, I took an Arduino Nano (V3 with 328P = same chip) and hooked up my ATTINY and made sure I could upload the bootloader to the Nano from the Arduino IDE........worked no problem.

So then I tried my own 328P but got a device signature problem. Unfortunately, the Arduino IDE doesn't record what sig it found, it only responds with the sig it should be.

Browsing the web it seens that on ocassion the avrdude.conf file needs modified with a new sig, so this I did but still no joy.
So, I ran a command line session with avrdude and was able to get the sig that was found. I then modified the .cong file and voila was able to upload the bootloader to the 328P. I also verified that I could upload a sketch and it was able to run.

Next, I took a 328P off a working Arduino Nano and hooked it up to my board and tried uploading the bootloader, but again it failed and I needed to change the signature......wtf!

Existing original 328P sig = 1E 95 0F
Other folks have said change it to 1E 95 14 and it should work.
avrdude responded with - 00 01 02 (something like this, I'm typing from memory!)

Ok so I got it to work, but I just wonder why I am getting a different signature from the SAME 328P with my board compared to the Nano.

Ian.
Ian Johnston - Manufacturer of the PDVS2mini & author of the free WinGPIB app.
Website & Online Shop: www.ianjohnston.com
YT Channel (electronics repairs & projects): www.youtube.com/user/IanScottJohnston, Twitter (X): https://twitter.com/IanSJohnston
 

Offline c4757p

  • Super Contributor
  • ***
  • Posts: 7799
  • Country: us
  • adieu
Re: Bootloader on SMD Atmega328P-AU
« Reply #1 on: July 29, 2013, 06:40:58 am »
Signatures consisting of mostly zeros are often a sign of a poor connection or improperly configured fuses. Are you sure the upload was successful for the second chip?
No longer active here - try the IRC channel if you just can't be without me :)
 

Offline IanJTopic starter

  • Supporter
  • ****
  • Posts: 1580
  • Country: scotland
  • Full time EE biz & Youtuber
    • IanJohnston.com
Re: Bootloader on SMD Atmega328P-AU
« Reply #2 on: July 29, 2013, 06:50:51 am »
Signatures consisting of mostly zeros are often a sign of a poor connection or improperly configured fuses. Are you sure the upload was successful for the second chip?

The IDE reported the upload of the bootloader was successful. However, I'll upload a sketch to the 2nd chip tonight and see what happens. Come to think of it, the one I uploaded the sketch to was the one taken from the Nano so it's theoretically possible that although I was trying to overwrite the bootloader with a new copy, maybe it had actually failed (despite reporting upload success) and the original bootloader was still in place thus my test sketch worked. Hmmmm!
The proof I guess will be to try all this on the virgin chip.

Thanks for responding.

Ian.
Ian Johnston - Manufacturer of the PDVS2mini & author of the free WinGPIB app.
Website & Online Shop: www.ianjohnston.com
YT Channel (electronics repairs & projects): www.youtube.com/user/IanScottJohnston, Twitter (X): https://twitter.com/IanSJohnston
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8240
Re: Bootloader on SMD Atmega328P-AU
« Reply #3 on: July 29, 2013, 11:34:42 am »
The 328P has 1E 95 0F
The 328 (no P) has 1E 95 14

They're different.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9889
  • Country: nz
Re: Bootloader on SMD Atmega328P-AU
« Reply #4 on: July 29, 2013, 11:50:37 am »
Yes, signature 00 01 02 is a very common result when you have something wired or connected wrong.
I've personally seen it in the following situations.

1) The chip has MOSI/MISO/SCK/RESET/GND connected to a programmer but no 5V power is connected.
The MCU will often "run" as power will backflow from the programmer into the SPI pins and get onto the chips power rail through the clamping diodes. So the chip kind of answers ISP requests but is unable to actually read or write its own flash.

2) The cable between the programmer and chip is too long.  Anything over 1 meter and you can have issues.

3) A programming cycle has been aborted halfway through and the chip is now in a weird state. Most of the time if you abort a programming cycle everything is fine but occasionally the chip will get stuck.
A power cycle fixes this but you have to kill all power. Not just VCC because of the effect mentioned in 1) above. (pulling Reset low for a sec doesn't seem to work for this fault)
« Last Edit: July 29, 2013, 11:54:16 am by Psi »
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline A Hellene

  • Frequent Contributor
  • **
  • Posts: 602
  • Country: gr
Re: Bootloader on SMD Atmega328P-AU
« Reply #5 on: July 29, 2013, 01:43:34 pm »
The AVR line has two FLASH memory spaces: The firmware memory space, which is fully accessible by the User in R/W fashion, and the calibration memory space where the calibration/signature/etc. chip data is stored. That special memory space size is one page long (varying from 8..128 words for every chip family or FLASH size) and it is accessible through special undocumented programming instructions.

Now, if the ISP data cable is long enough (or poorly constructed) a programming instruction opcode can be corrupted and randomly match the opcode of an undocumented instruction, most commonly resulting in erasing the target chip calibration data space! That happens because the ISP protocol erase_cal_space instruction opcode is only four bytes long (just as the FLASH/EEPROM chip_erase instruction also is), and different in one bit only from the chip_erase opcode! The documented FLASH/EEPROM Memories Chip_Erase opcode is '0xAC 0x80 0x00 0x00' and the undocumented erase_cal_space opcode is '0xAC 0xC0 0x00 0x00'.

I have found out some of those undocumented opcodes by using a custom, fully configurable AVR programmer I designed back in 2002, that supports all the ISP/HVPP/HVSP modes, by later adding to its firmware some intelligent opcode searching/verification algorithms.


Custom AVR Programmer

Anyway, if the calibration data space is erased, then the chip signature will be reset and read FF.FF.FF! The signature will be read as 00.01.02 if the programming protocol is parallel (HVPP) and the target chip is missing, resulting in the programmer hardware reading back the address it has just sent to the missing target chip, since the same 8-bit data port of the target chip is used for data and for address transmission as well. The same also applies to the serial ISP programming protocol.

These are the contents of the first four data words (residing at the calibration address space 0x000..0x003) of the 64 data words stored at the calibration data space of a ATMega328-PU:

Custom AVR Programmer, m328 calibration space 0x000..0x003: The cursor points at the higher nybble of the [L]ow byte of the Word at 0x[000], according to the obscure '000L' information at the beginning of the first LCD line.
The User accessible data are the signature bytes (1E.95.14) and the 8 MHz oscillator calibration byte (0x8F).

This is the complete calibration space data dump of that specific chip above, as reported by the programmer through its UART line:
Code: [Select]
ATnega328
0x0000: 1E.8F 95.FF 14.D1 FF.26 FF.0B FF.17 FF.FF 4A.31
0x0008: 34.30 36.34 FF.03 1E.04 17.01 12.05 13.05 FF.FF
0x0010: FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF B8.87
0x0018: BC.55 53.63 AE.8F C3.46 B9.75 99.0F 57.0B D4.0E
0x0020: FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF
0x0028: FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF
0x0030: FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF
0x0038: FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF FF.FF 75.06

These are the signature bytes read with the m328 programming socket populated in the first picture, and with the socket empty in the second one:

Custom AVR Programmer, m328 signature read


Custom AVR Programmer, empty socket signature read


-George
« Last Edit: July 29, 2013, 02:57:58 pm by A Hellene »
Hi! This is George; and I am three and a half years old!
(This was one of my latest realisations, now in my early fifties!...)
 
The following users thanked this post: oPossum

Offline IanJTopic starter

  • Supporter
  • ****
  • Posts: 1580
  • Country: scotland
  • Full time EE biz & Youtuber
    • IanJohnston.com
Re: Bootloader on SMD Atmega328P-AU
« Reply #6 on: July 29, 2013, 05:26:04 pm »
Hi all,

Fixed.

Fitted a known good 328p (with bootloader) and FTDI wouldn't work (to upload a sketch), scoped the comms and found it was inactive. Schoolboy error, found I'd tied the pull up resistor on !RESET low instead of high! Dear oh dear!

So now, Avrdude command line check now reports proper signature, am able to upload the bootloader using the ISP header, and able to upload a sketch using the FTDI header. Job done.

Couple pics below if anyone is interested.

Ian.



Ian Johnston - Manufacturer of the PDVS2mini & author of the free WinGPIB app.
Website & Online Shop: www.ianjohnston.com
YT Channel (electronics repairs & projects): www.youtube.com/user/IanScottJohnston, Twitter (X): https://twitter.com/IanSJohnston
 

Offline joseignacio

  • Newbie
  • Posts: 1
Re: Bootloader on SMD Atmega328P-AU
« Reply #7 on: January 29, 2014, 02:55:11 pm »
Hello Ian,

I'm trying exactly the same as you did: I need flashing and uploading a sketch into a Atmega328p-AU before assembling it in the PCB. I want to make a shield using a TQFP32 adapter I bought in ebay and adding the resistences and capacitors needed. The shield will be placed on a arduino UNO working as ISP, and would do both things: burning the arduino bootloader into a new atmega328p-AU and programming a sketch.

Did you make any schematic of your design? I am a little with the connections needed between the new atmega and the arduino working as ISP.

Thank you!

Greetings from Spain.
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: Bootloader on SMD Atmega328P-AU
« Reply #8 on: February 04, 2014, 08:14:42 pm »
hi,

I just want to know if any of you know the device signature of the atmega328P-PU ? there are several imformations on the P and non-P version , but not on this "-PU"

thanks
 

Online Monkeh

  • Super Contributor
  • ***
  • Posts: 7990
  • Country: gb
Re: Bootloader on SMD Atmega328P-AU
« Reply #9 on: February 04, 2014, 08:54:33 pm »
-PU is the package. It is a 328P.

There are many 'informations' here: http://www.atmel.com/Images/doc8161.pdf
« Last Edit: February 04, 2014, 09:00:17 pm by Monkeh »
 

Offline paulie

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: Bootloader on SMD Atmega328P-AU
« Reply #10 on: February 04, 2014, 08:56:20 pm »
-PU and -AU refer to avr package type and have nothing to do with m328 or signature. 328p and 328 can both be programmed without resorting to conf file editing by using "-F" option. relatively safe for all operations unless changing fuses in which case you should be very careful.
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: Bootloader on SMD Atmega328P-AU
« Reply #11 on: February 05, 2014, 06:12:51 pm »
-PU is the package. It is a 328P.

There are many 'informations' here: http://www.atmel.com/Images/doc8161.pdf

thanks.It's odd. Avrdude (and studio6 when it was installed) doesn't recognize the chips as 328p . Both gave different device signature and therefore I can't program the chip. If it's matter of package , the signature should be correct.
 

Offline scientist

  • Frequent Contributor
  • **
  • !
  • Posts: 317
  • Country: 00
  • User banned.
Re: Bootloader on SMD Atmega328P-AU
« Reply #12 on: February 06, 2014, 05:09:39 am »
Hi all,

Fixed.

Fitted a known good 328p (with bootloader) and FTDI wouldn't work (to upload a sketch), scoped the comms and found it was inactive. Schoolboy error, found I'd tied the pull up resistor on !RESET low instead of high! Dear oh dear!

So now, Avrdude command line check now reports proper signature, am able to upload the bootloader using the ISP header, and able to upload a sketch using the FTDI header. Job done.

Couple pics below if anyone is interested.

Ian.





How much are those sockets, about?
 

Offline old gregg

  • Regular Contributor
  • *
  • Posts: 130
  • Country: 00
Re: Bootloader on SMD Atmega328P-AU
« Reply #13 on: February 06, 2014, 02:03:11 pm »
-PU is the package. It is a 328P.

There are many 'informations' here: http://www.atmel.com/Images/doc8161.pdf

thanks.It's odd. Avrdude (and studio6 when it was installed) doesn't recognize the chips as 328p . Both gave different device signature and therefore I can't program the chip. If it's matter of package , the signature should be correct.

my bad. I managed to get that thing working. Seems that those bloody dodgy wires were responsible.
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 8240
Re: Bootloader on SMD Atmega328P-AU
« Reply #14 on: February 08, 2014, 12:51:54 pm »
How much are those sockets, about?
That appears to be an IC51-0324-1498, which is about $45USD.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6189
  • Country: us
Re: Bootloader on SMD Atmega328P-AU
« Reply #15 on: March 19, 2014, 05:30:16 am »
Was this solved? If not, one difference between blank and programmed 328p's is that the blank ones needs slower programming speed. 250khz at most. If you are using avrdude, look for the -B flag. The reason is that the blank 328p's are programmed to use a 1Mhz clock and the programming clock can be at most 1/4 of that.

This is how I program blank 328p's to look like Arduino Pro Mini 16Mhz, 5V with my program.

https://github.com/zapta/linbus/blob/master/analyzer/firmware/icsp_program_all.sh
 

Offline paulie

  • Frequent Contributor
  • **
  • !
  • Posts: 849
  • Country: us
Re: Bootloader on SMD Atmega328P-AU
« Reply #16 on: March 20, 2014, 04:25:37 pm »
ive found modern cheapo chinese usbasp treat 1mhz and 16mhz the same without special commands. just another of the many advantages over the "real" programmers.
 

Offline moreab

  • Newbie
  • Posts: 7
  • Country: in
Re: Bootloader on SMD Atmega328P-AU
« Reply #17 on: July 03, 2016, 06:43:16 am »
Please Help,
     I am making standalone atmega328p-au smd version. I brought IC and soldered on my own board with reset and crystal ckt. The board is detected by AVR programmer by SPI protocol using avrdude but when I try to upload boot-loader or any sketch using avrdude it shows rc=-1 error and then after never detected. I also checked using Arduino UNO board as programmer but giving signature error.
What should I do??
 

Offline Neverther

  • Regular Contributor
  • *
  • Posts: 129
Re: Bootloader on SMD Atmega328P-AU
« Reply #18 on: July 03, 2016, 08:12:45 am »
Try reducing the clock first if you use avrdude. They ship with 8Mhz internal rc oscillator and DIV8, so running at 1Mhz.
In avrdude manual it says that by default the bitclock is for around 4Mhz devices.
Try with avrdude with "-B 255" or something and see if it responds.
If it doesnt work, your programmer cannot set bitclock or you have wrong clock source selected or you have connection issue.
 
The following users thanked this post: Kilrah

Offline moreab

  • Newbie
  • Posts: 7
  • Country: in
Re: Bootloader on SMD Atmega328P-AU
« Reply #19 on: July 03, 2016, 06:21:11 pm »
I downloaded all my project code on arduino nano board ( has bootloader ) and desoldered the atmega328p-au IC and placed on my own board(has proper reset and 16MHz clock) but still showing error

avrdude.exe: set SCK frequency to 1500000 Hz
avrdude.exe: error: programm enable: target doesn't answer. 1
avrdude.exe: initialization failed, rc=-1
             Double check connections and try again, or use -F to override
             this check.
what should I do?
 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3781
  • Country: de
Re: Bootloader on SMD Atmega328P-AU
« Reply #20 on: July 03, 2016, 10:12:52 pm »
-PU is the package. It is a 328P.

There are many 'informations' here: http://www.atmel.com/Images/doc8161.pdf

thanks.It's odd. Avrdude (and studio6 when it was installed) doesn't recognize the chips as 328p . Both gave different device signature and therefore I can't program the chip. If it's matter of package , the signature should be correct.

Careful - ATMega328 and ATMega328p are different silicon and both exist in the -AU (TQFP) and -PU (DIP) packages. So it is normal that the signature between normal 328 and 328p is different, regardless of the package - the latter is the PicoPower version that supports some extra low power stuff, if I remember correctly.

 

Offline janoc

  • Super Contributor
  • ***
  • Posts: 3781
  • Country: de
Re: Bootloader on SMD Atmega328P-AU
« Reply #21 on: July 03, 2016, 10:16:26 pm »
Was this solved? If not, one difference between blank and programmed 328p's is that the blank ones needs slower programming speed. 250khz at most. If you are using avrdude, look for the -B flag. The reason is that the blank 328p's are programmed to use a 1Mhz clock and the programming clock can be at most 1/4 of that.

This is how I program blank 328p's to look like Arduino Pro Mini 16Mhz, 5V with my program.

https://github.com/zapta/linbus/blob/master/analyzer/firmware/icsp_program_all.sh

Yep, got bitten by this recently too - you need to specify something like -B 10 or even -B 100 before it will program. A virgin ATMega is configured from the factory to run on the internal 8MHz RC oscillator but has the CLKDIV8 fuse programmed, dividing the clock by 8 = 1MHz system clock :(
« Last Edit: July 03, 2016, 10:18:56 pm by janoc »
 

Offline moreab

  • Newbie
  • Posts: 7
  • Country: in
Re: Bootloader on SMD Atmega328P-AU
« Reply #22 on: July 05, 2016, 09:27:34 am »
yesterday I tried burning Arduino uno bootloader in atmega328p-au it is downloaded successfully then I changed fuses according to UNO board from board.txt when I tried changing Lock Bit(LB)=0x0f it shown me
avrdude.exe: set SCK frequency to 1500000 Hz
avrdude.exe: error: programm enable: target doesn't answer. 1
avrdude.exe: initialization failed, rc=-1
             Double check connections and try again, or use -F to override
             this check.

After that IC is never detected
what should I do?
 

Offline sleemanj

  • Super Contributor
  • ***
  • Posts: 3020
  • Country: nz
  • Professional tightwad.
    • The electronics hobby components I sell.
Re: Bootloader on SMD Atmega328P-AU
« Reply #23 on: July 05, 2016, 09:51:16 am »
yesterday I tried burning Arduino uno bootloader in atmega328p-au it is downloaded successfully then I changed fuses according to UNO board from board.txt


Which sets the fuses to use an external Crystal.  If you do not have an external Crystal attached, then it's not going to work.  You can rescue it by attaching an external crystal, or injecting a clock signal into XTAL1 pin (8MHz is traditional) then reprogramming fuses to use the internal oscillator.
~~~
EEVBlog Members - get yourself 10% discount off all my electronic components for sale just use the Buy Direct links and use Coupon Code "eevblog" during checkout.  Shipping from New Zealand, international orders welcome :-)
 

Offline yamadanao

  • Newbie
  • Posts: 4
  • Country: am
Re: Bootloader on SMD Atmega328P-AU
« Reply #24 on: July 03, 2017, 09:19:37 am »
Thank you for your post,here is the date sheet of Atmega328P for your reference.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf