ElektorLabs / Arduino

Elektor's Arduino compatible boards, including Elektor Uno R4 with ATmega328PB
21 stars 10 forks source link

Not working with ATmega328PB #2

Closed botletics closed 6 years ago

botletics commented 7 years ago

I am using an ATmega328PB with a 16MHz resonator and I flashed the standard ATmega328P bootloader to it successfully with Arduino IDE 1.6.11. However, when I try uploading the blink sketch to the chip with the ArduinoISP sketch loaded to my Arduino Uno R3 and a 10uF cap between RESET and GND, it gives me the following error:

avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: Send: 0 [30] [20] avrdude: Recv: . [e0] avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xe0 avrdude: Send: 0 [30] [20] avrdude: Recv: . [e0] avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xe0 avrdude: Send: 0 [30] [20] avrdude: Recv: . [e0] avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xe0 avrdude: Send: 0 [30] [20] avrdude: Recv: . [00] avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00 avrdude: Send: 0 [30] [20] avrdude: Recv: . [e0] avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xe0 avrdude: Send: 0 [30] [20] avrdude: Recv: . [e0] avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xe0 avrdude: Send: 0 [30] [20] avrdude: Recv: . [e0] avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xe0 avrdude: Send: 0 [30] [20] avrdude: Recv: . [00] avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00 avrdude: Send: 0 [30] [20] avrdude: Recv: . [e0] avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe0 avrdude: Send: 0 [30] [20] avrdude: Recv: . [e0] avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xe0

When I take away the 10uF cap, it gives me the following error:

avrdude: Device signature = 0x1e950f (probably m328p) avrdude: Expected signature for ATmega328PB is 1E 95 16 Double check chip, or use -F to override this check.

It seems like flashing the standard 328P bootloader changed the device signature (because I fooled avrdude by changing the signature in the avrdude.conf file). However, if I click Burn Bootloader, I get this error:

java.lang.NullPointerException at cc.arduino.packages.uploaders.SerialUploader.burnBootloader(SerialUploader.java:360) at processing.app.Editor.lambda$handleBurnBootloader$11(Editor.java:2752) at java.lang.Thread.run(Thread.java:745) Error while burning bootloader.

Any ideas?

edwin-oetelaar commented 6 years ago

As far as I know you can not change the signature by using a wrong boot-loader. Your cap, 10uF seems to be a bit large. The \reset pin is under control of the ISP and needs to change state quickly, using such a big cap prevents the \reset pin from changing. As an experiment just remove the cap use like 10nF and try again, from distant memory I seem to recall making the same mistake myself once, many years ago. The problem you have might also have to do with bad wiring, grounding and bad power supply, check all that too. Also verify using other (different board) to make sure your setup works without glitches, use elimination to zoom in on the real problem.

elektor-labs commented 6 years ago

First of all, this question doesn't concern this project. We don't maintain the standard ATmega328P bootloader (whatever that may be), and we don't produce the ATmega328PB. For questions arising from your experiments there are other places to seek help.

Then, I have heard about AVRs getting their ID reset to 0, but never encountered one. Accidentally changing the ATmega328PB (0x1e9516) ID to a ATmega328P ID (0x1e950f) with just a capacitor would be close to a miracle (change 0x0f in 0x16? But then again, what do I know?).

To answer your question, the Arduino optiboot bootloader contains the chip ID. So if you flash the wrong bootloader in the wrong chip then avrdude gets confused. Recompile the bootloader for the ATmega328PB (or use the one that you can find somewhere in this repository) and use that instead.