2020-07-01T15:43:00

P ≠ PB

Got ATmega328PB which is (nearly) pin compatible with ATmega328P, but the microcontroller it self is different and the tool chain does not work out of the box. My current status is that I did not managed to load bootloader and will simply revert to use P version. Still here is a summary of links and things that I've tried.

Tried Arduino as ISP that worked for me and it does not work out of the box. Here some links that claim to be working:

Tried programming from command line, setting fuses after updating avrdude.conf went through:

$ diff -Naur avrdude.conf-backup /etc/avrdude.conf
--- avrdude.conf-backup	2020-07-01 12:22:58.966995406 +0200
+++ /etc/avrdude.conf	2020-07-01 12:43:42.037885327 +0200
@@ -8726,7 +8726,7 @@
 	       "x x x x x x x x o o o o o o o o";
 
 	write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
-	      	"x x x x x x x x x x x x x i i i";
+	      	"x x x x x x x x x x x x i i i i";
     ;
 
     memory "lock"
$ /usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328pb -cstk500v1 -P/dev/ttyUSB1 -b19200 -e -Ulock:w:0xff:m -Uefuse:w:0xfd:m -Uhfuse:w:0xde:m -Ulfuse:w:0xff:m
                    

Managed to compile optiboot_m328pb.hex after getting ATmega Series Device files

cd Atmel.ATmega_DFP.1.4.351
sudo cp ./gcc/dev/atmega328pb/avr5/libatmega328pb.a ./gcc/dev/atmega328pb/avr5/crtatmega328pb.o /usr/lib/avr/lib/
sudo cp ./include/avr/iom328pb.h /usr/lib/avr/include/avr/

Then tried to program it but ended-up with programming/safemode verification errors:

$ /usr/share/arduino/hardware/tools/avrdude -C/usr/share/arduino/hardware/tools/avrdude.conf -v -v -v -v -patmega328pb -cstk500v1 -P/dev/ttyUSB1 -b19200 -Uflash:w:/usr/share/arduino/hardware/arduino/bootloaders/optiboot/optiboot_m328pb.hex:i -Ulock:w:0xcf:m\
avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/usr/share/arduino/hardware/tools/avrdude.conf"
         User configuration file is "/home/jozef/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/ttyUSB1
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 
         AVR Part                      : ATmega328PB
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :
…
avrdude: Recv: . [10] 
avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x7e00
         0x00 != 0x1f
avrdude: verification error; content mismatch

avrdude: Send: V [56] P [50] . [00] . [00] . [00]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
…
avrdude: Recv: . [14] 
avrdude: Recv: . [00] 
avrdude: Recv: . [10] 
avrdude: safemode read 3, efuse value: 0
avrdude: safemode: efuse reads as 0
avrdude: safemode: lfuse changed! Was ff, and is now 0
Would you like this fuse to be changed back? [y/n] 
avrdude: safemode: hfuse changed! Was de, and is now 0
Would you like this fuse to be changed back? [y/n] 
avrdude: safemode: efuse changed! Was fd, and is now 0
Would you like this fuse to be changed back? [y/n] 
avrdude: safemode: Fuses OK (E:FD, H:DE, L:FF)
avrdude: Send: Q [51]   [20] 
avrdude: Recv: . [14] 
avrdude: Recv: . [10] 

avrdude done.  Thank you.
                    

Not sure what to try next, don't want to recompile the whole tool-chain just to win two extra pins, capacitive sense and extra IO interfaces.

comments powered by Disqus