Author Topic: 328PB board can't upload sketch  (Read 563 times)

0 Members and 1 Guest are viewing this topic.

Offline AndyNZTopic starter

  • Contributor
  • Posts: 18
  • Country: nz
328PB board can't upload sketch
« on: August 23, 2024, 03:02:06 am »
Hi all

I had to adapt a custom board to fit a 328PB instead of a 88PA, and I'm having trouble uploading the sketch via ArduinoIDE. Initially I've bricked two boards (schematics attached)  by burning the bootloader using the Atmega328PB 1.1.4 package, before going back to the Minicore 3.0.2 package. The bootloader burns OK with Minicore (see output below) with the 16MHz external clock set, and I can measure the 16 MHz clock signal, but when trying to upload a sketch via UART0 I get out of synch errors (see output below).

I used pretty much the same setup with the predecessor board with an Atmega88PA successfully with the internal clock, so I'm fairly confident that the wiring of the ISP and UART headers is OK, I followed the schematics published on the Minicore page. I did measure the reset signal and that was OK as well. I tried all possible iterations of clock parameters, internal and external, but I can't get the sketch to upload.

To burn the bootloader I'm using an Arduino Uno and the ArduinoasISP sketch, and to upload the sketch I'm using an FTDI FT232R clone.

I'm still very new to this, so any suggestion on how to systematically troubleshoot this would be great.

Andreas.



Bootloader output:

avrdude: Version 7.2-arduino.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\Users\1520004\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.2\avrdude.conf

         Using Port                    : COM8
         Using Programmer              : stk500v1
         Overriding Baud Rate          : 19200
         AVR Part                      : ATmega328PB
         Chip Erase delay              : 10500 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : possible i/o
         RETRY pulse                   : SCK
         Serial program mode           : yes
         Parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                           Block Poll               Page                       Polled
           Memory Type Alias    Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- -------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom                 65    20     4    0 no       1024    4      0  3600  3600 0x00 0x00
           flash                  65    10   128    0 yes     32768  128    256  4500  4500 0x00 0x00
           lfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           hfuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           efuse                   0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           lock                    0     0     0    0 no          1    1      0  4500  4500 0x00 0x00
           signature               0     0     0    0 no          3    1      0     0     0 0x00 0x00
           calibration             0     0     0    0 no          1    1      0     0     0 0x00 0x00

         Programmer Type : STK500
         Description     : Atmel STK500 version 1.x firmware
         Hardware Version: 2
         Firmware Version: 1.18
         Topcard         : Unknown
         Vtarget         : 0.0 V
         Varef           : 0.0 V
         Oscillator      : Off
         SCK period      : 0.1 us
avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e9516 (probably m328pb)
avrdude: Note: flash memory has been specified, an erase cycle will be performed.
         To disable this feature, specify the -D option.
avrdude: erasing chip

avrdude: processing -U flash:w:C:\Users\1520004\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.2/bootloaders/urboot/atmega328pb/watchdog_1_s/autobaud/uart0_rxd0_txd1/led+b5/urboot_atmega328pb_pr_ee_ce.hex:i
avrdude: reading input file C:\Users\1520004\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.2/bootloaders/urboot/atmega328pb/watchdog_1_s/autobaud/uart0_rxd0_txd1/led+b5/urboot_atmega328pb_pr_ee_ce.hex for flash
         with 368 bytes in 2 sections within [0x7e80, 0x7fff]
         using 3 pages and 16 pad bytes
avrdude: writing 368 bytes flash ...
Writing | ################################################## | 100% 0.08s
avrdude: 368 bytes of flash written
avrdude: verifying flash memory against C:\Users\1520004\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.2/bootloaders/urboot/atmega328pb/watchdog_1_s/autobaud/uart0_rxd0_txd1/led+b5/urboot_atmega328pb_pr_ee_ce.hex
Reading | ################################################## | 100% 0.00s
avrdude: 368 bytes of flash verified

avrdude: processing -U lock:w:0xff:m
avrdude: reading input file 0xff for lock
         with 1 byte in 1 section within [0, 0]
avrdude: writing 1 byte lock ...
avrdude: 1 byte of lock written
avrdude: verifying lock memory against 0xff
avrdude: 1 byte of lock verified

avrdude done.  Thank you.



programming output:

avrdude: Version 7.2-arduino.1
         Copyright the AVRDUDE authors;
         see https://github.com/avrdudes/avrdude/blob/main/AUTHORS

         System wide configuration file is C:\Users\1520004\AppData\Local\Arduino15\packages\MiniCore\hardware\avr\3.0.2\avrdude.conf

         Using Port                    : COM9
         Using Programmer              : urclock
         Overriding Baud Rate          : 115200
avrdude urclock_getsync() warning: attempt 1 of 10: not in sync
avrdude urclock_getsync() warning: attempt 2 of 10: not in sync
avrdude urclock_getsync() warning: attempt 3 of 10: not in sync
avrdude urclock_getsync() warning: attempt 4 of 10: not in sync
avrdude urclock_getsync() warning: attempt 5 of 10: not in sync
avrdude urclock_getsync() warning: attempt 6 of 10: not in sync
avrdude urclock_getsync() warning: attempt 7 of 10: not in sync
avrdude urclock_getsync() warning: attempt 8 of 10: not in sync
avrdude urclock_getsync() warning: attempt 9 of 10: not in sync
avrdude urclock_getsync() warning: attempt 10 of 10: not in sync
avrdude urclock_recv() warning: programmer is not responding; try -xstrict and/or vary -xdelay=100
avrdude main() error: unable to open programmer urclock on port COM9

avrdude done.  Thank you.

Failed uploading: uploading error: exit status 1


 

Offline mikerj

  • Super Contributor
  • ***
  • Posts: 3313
  • Country: gb
Re: 328PB board can't upload sketch
« Reply #1 on: August 23, 2024, 10:07:29 am »
Have you read this thread? https://forum.arduino.cc/t/minicore-atmega328-bootloader-burning-issue/1190856/31

Looks like there could be some relatively tight timing constraints if you are using manual reset prior to upload.
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 2028
  • Country: dk
Re: 328PB board can't upload sketch
« Reply #2 on: August 23, 2024, 10:26:35 am »

The only thing that stands out to me is that on the Nanov3 they apparently use a 1K from Reset to VCC
https://www.arduino.cc/en/uploads/Main/ArduinoNano30Schematic.pdf

 

Offline AndyNZTopic starter

  • Contributor
  • Posts: 18
  • Country: nz
Re: 328PB board can't upload sketch
« Reply #3 on: August 25, 2024, 09:30:56 pm »
Thanks for your replies, I've now got it working without bootloader via direct ISP programming.

I tried varying the -xdelay from -1000 to +1000 ms in 100 ms steps, which didn't help.
Regarding the 10k reset resistor on UART DTR, vs the 1K on the Nano, I took the value from the Mincore Github, which worked fine with the Atmega88PA, and I also tried using a manual reset, no luck, so I don't think this is the issue.

Anyway, if it works with direct ISP programming that's good enough for me.

Thanks again for your help,
Andreas
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf