Welcome to the MIDI Sprout forum

Author Topic: Help programming 328-PU series  (Read 2514 times)

Offline Dustin_E

  • Newbie
  • *
  • Posts: 5
    • View Profile
Help programming 328-PU series
« on: December 21, 2016, 04:50:19 PM »
Hello all,

So I have been struggling with uploading the midisprout sketch, or burning a bootloader due to the PU series chip used. I originally just purchased an UNO and didn't realize at first the blank ICs I bought did not have bootloaders burned (this is my first arduino based project). So I got an AVR Pocket Programmer to burn the bootloaders to the chips I have (for future projects), but the arduino IDE is giving me the following error. I have changed the signature files as instructed to match the PU series chip, but it seems as it is still looking for the old signature? I have updated any copy of avrdude.conf I can find, and still having no luck.

I have even tried just uploading the sketch via programmer through the UNO and directly via ISP on the midisprout board. Same error. I have spent the past few days researching on possible fixes, and have come up with nothing. The chips I purchased were via mouser ATMEGA328-PU. The boards being used were bought via the gerber link in the forum.

This midisprout I'm building is all soldered, mounted in the enclosure, and ready to go, but it just needs the BRAIN!!! Please any suggestions, insights, helpful links, etc would be greatly appreciated. This will be the first of two DIY midisprouts I will be building, and really am looking forward to sharing the final builds with you all!

Error code while burning the bootloader below, but the same signature related error comes up when uploading sketch via programmer:
Code: [Select]
Arduino: 1.6.13 (Windows 10), Board: "Arduino/Genuino Uno"

C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -cusbtiny -e -Ulock:w:0x3F:m -Uefuse:w:0x05:m -Uhfuse:w:0xDE:m -Ulfuse:w:0xFF:m

avrdude: Version 6.3, compiled on Sep 12 2016 at 17:24:16
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : usb
         Using Programmer              : usbtiny
avrdude: usbdev_open(): Found USBtinyISP, bus:device: bus-0:\\.\libusb0-0001--0x1781-0x0c9f
         AVR Part                      : ATmega328P
         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                 :

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

         Programmer Type : USBtiny
         Description     : USBtiny simple USB programmer, http://www.ladyada.net/make/usbtinyisp/
avrdude: programmer operation not supported

avrdude: Using SCK period of 10 usec
avrdude: AVR device initialized and ready to accept instructions

Error while burning bootloader.
Reading | ################################################## | 100% 0.01s

avrdude: Device signature = 0x1e9514 (probably m328)
avrdude: Expected signature for ATmega328P is 1E 95 0F
         Double check chip, or use -F to override this check.

avrdude done.  Thank you.
« Last Edit: December 21, 2016, 04:53:27 PM by Dustin_E »

Offline Dustin_E

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Help programming 328-PU series
« Reply #1 on: December 21, 2016, 05:03:39 PM »
aaaaaaaaaaaaaaaaaaaaaaaaaaaand

I literally figured it out moments after posting.....

for anyone else that has this problem, since I'm using the newest IDE, it seems they added an extra bit in the avrdude.conf for the "p series" chips. This was giving me the error, I changed it, and all has burned proper.

Below is the adjusted code for the AVRDUDE.CONF file. The only part that I changed was the final signature line for the "p series".

Code: [Select]
#------------------------------------------------------------
# ATmega328
#------------------------------------------------------------

part
    id = "m328";
    desc = "ATmega328";
    has_debugwire = yes;
    flash_instr = 0xB6, 0x01, 0x11;
    eeprom_instr = 0xBD, 0xF2, 0xBD, 0xE1, 0xBB, 0xCF, 0xB4, 0x00,
  0xBE, 0x01, 0xB6, 0x01, 0xBC, 0x00, 0xBB, 0xBF,
  0x99, 0xF9, 0xBB, 0xAF;
    stk500_devcode = 0x86;
    # avr910_devcode = 0x;
    signature = 0x1e 0x95 0x14;
    pagel = 0xd7;
    bs2 = 0xc2;
    chip_erase_delay = 9000;
    pgm_enable = "1 0 1 0 1 1 0 0 0 1 0 1 0 0 1 1",
"x x x x x x x x x x x x x x x x";

    chip_erase = "1 0 1 0 1 1 0 0 1 0 0 x x x x x",
"x x x x x x x x x x x x x x x x";

    timeout = 200;
    stabdelay = 100;
    cmdexedelay = 25;
    synchloops = 32;
    bytedelay = 0;
    pollindex = 3;
    pollvalue = 0x53;
    predelay = 1;
    postdelay = 1;
    pollmethod = 1;

    pp_controlstack =
0x0E, 0x1E, 0x0F, 0x1F, 0x2E, 0x3E, 0x2F, 0x3F,
0x4E, 0x5E, 0x4F, 0x5F, 0x6E, 0x7E, 0x6F, 0x7F,
0x66, 0x76, 0x67, 0x77, 0x6A, 0x7A, 0x6B, 0x7B,
0xBE, 0xFD, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00;
    hventerstabdelay = 100;
    progmodedelay = 0;
    latchcycles = 5;
    togglevtg = 1;
    poweroffdelay = 15;
    resetdelayms = 1;
    resetdelayus = 0;
    hvleavestabdelay = 15;
    resetdelay = 15;
    chiperasepulsewidth = 0;
    chiperasepolltimeout = 10;
    programfusepulsewidth = 0;
    programfusepolltimeout = 5;
    programlockpulsewidth = 0;
    programlockpolltimeout = 5;

    ocdrev              = 1;

    memory "eeprom"
paged = no;
page_size = 4;
size = 1024;
min_write_delay = 3600;
max_write_delay = 3600;
readback_p1 = 0xff;
readback_p2 = 0xff;
read = " 1 0 1 0 0 0 0 0",
       " 0 0 0 x x x a9 a8",
       " a7 a6 a5 a4 a3 a2 a1 a0",
       " o o o o o o o o";

write = " 1 1 0 0 0 0 0 0",
      " 0 0 0 x x x a9 a8",
" a7 a6 a5 a4 a3 a2 a1 a0",
" i i i i i i i i";

loadpage_lo = " 1 1 0 0 0 0 0 1",
      " 0 0 0 0 0 0 0 0",
      " 0 0 0 0 0 0 a1 a0",
      " i i i i i i i i";

writepage = " 1 1 0 0 0 0 1 0",
    " 0 0 x x x x a9 a8",
    " a7 a6 a5 a4 a3 a2 0 0",
    " x x x x x x x x";

mode = 0x41;
delay = 20;
blocksize = 4;
readsize = 256;
    ;

    memory "flash"
paged = yes;
size = 32768;
page_size = 128;
num_pages = 256;
min_write_delay = 4500;
max_write_delay = 4500;
readback_p1 = 0xff;
readback_p2 = 0xff;
read_lo = " 0 0 1 0 0 0 0 0",
  " 0 0 a13 a12 a11 a10 a9 a8",
  " a7 a6 a5 a4 a3 a2 a1 a0",
  " o o o o o o o o";

read_hi = " 0 0 1 0 1 0 0 0",
  " 0 0 a13 a12 a11 a10 a9 a8",
  " a7 a6 a5 a4 a3 a2 a1 a0",
  " o o o o o o o o";

loadpage_lo = " 0 1 0 0 0 0 0 0",
      " 0 0 0 x x x x x",
      " x x a5 a4 a3 a2 a1 a0",
      " i i i i i i i i";

loadpage_hi = " 0 1 0 0 1 0 0 0",
      " 0 0 0 x x x x x",
      " x x a5 a4 a3 a2 a1 a0",
      " i i i i i i i i";

writepage = " 0 1 0 0 1 1 0 0",
    " 0 0 a13 a12 a11 a10 a9 a8",
    " a7 a6 x x x x x x",
    " x x x x x x x x";

mode = 0x41;
delay = 6;
blocksize = 128;
readsize = 256;

    ;

    memory "lfuse"
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = "0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0",
       "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 0 0 0",
      "x x x x x x x x i i i i i i i i";
    ;

    memory "hfuse"
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = "0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0",
       "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 1 0 0 0",
      "x x x x x x x x i i i i i i i i";
    ;

    memory "efuse"
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
       "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";
    ;

    memory "lock"
size = 1;
min_write_delay = 4500;
max_write_delay = 4500;
read = "0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0",
       "x x x x x x x x x x o o o o o o";

write = "1 0 1 0 1 1 0 0 1 1 1 x x x x x",
      "x x x x x x x x 1 1 i i i i i i";
    ;

    memory "calibration"
size = 1;
read = "0 0 1 1 1 0 0 0 0 0 0 x x x x x",
       "0 0 0 0 0 0 0 0 o o o o o o o o";
    ;

    memory "signature"
size = 3;
read = "0 0 1 1 0 0 0 0 0 0 0 x x x x x",
       "x x x x x x a1 a0 o o o o o o o o";
    ;
;

part parent "m328"
    id = "m328p";
    desc = "ATmega328P";
    signature = 0x1e 0x95 0x14;

    ocdrev              = 1;
;

Offline Dustin_E

  • Newbie
  • *
  • Posts: 5
    • View Profile
Re: Help programming 328-PU series
« Reply #2 on: December 21, 2016, 05:10:28 PM »
For some reason I also had to change the P series info in AVRDUDE.conf back to "0f" from "14" when disconnecting and uploading via the UNO as normal.

Odd that it wanted it one way for the bootloader burn via the pocket programmer, but the other way when uploading the sketch simply via the UNO.


oh well time to power this thing up!!!!!!

Offline sam

  • Sam
  • Moderator
  • Full Member
  • *****
  • Posts: 188
  • Understand How Your Tools Work!
    • View Profile
    • Electricity for Progress
Re: Help programming 328-PU series
« Reply #3 on: January 06, 2017, 09:59:44 AM »
Dustin, thank you very much for documenting this process.  I as well had a confusing time with AVRdude and making new profiles for the non P series chips. I previously have customized versions of the Arduino IDE in order to make it easier to program the non P chips, but who wants to work in Arduino 1.3.x anymore ;)

And yes, when you get a 'bare' ATMEGA 328p, they usually come without a bootloader.  In fact, it doesn't look like the bootloader is present on the 'production' Sprouts, but it does appear on the P series chips in the Kits.  Just to make things a little bit better, I promise that all future Kits or Sprouts will have the P series chip.  I'm a big fan of the Arduino bootloader (well really i like optiboot), but since this device doesn't have USB we are pretty much stuck with ICSP programming which doesn't need a bootloader.

So in short, as a recommendation to all you Sprout tinkerers trying to roll your own or mod the code ...
1. grab yourself a 'fresh' 328p
2. pop it in a breadboard
3. use Arduino-as-ICSP setup to set the fuses for 16Mhz and program the chip
4. if you have the 'kickstarter' assembled sprout with a non P series chip, yer better off starting with a fresh 328p then messing with the AVRDUDE.conf (unless you are really into that kinda hackery, like myself and Dustin here!)

Offline CoraDias

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Help programming 328-PU series
« Reply #4 on: February 27, 2018, 11:27:03 AM »
Hi...i am a new user here. As per my knowledge when you get a  atmega 328p bootloader is there.  It doesn't look like the bootloader is present on the Sprouts, but it does appear on the P series chips in the Kits.

automated pcb assembly
« Last Edit: March 08, 2018, 04:33:38 PM by CoraDias »

Offline sam

  • Sam
  • Moderator
  • Full Member
  • *****
  • Posts: 188
  • Understand How Your Tools Work!
    • View Profile
    • Electricity for Progress
Re: Help programming 328-PU series
« Reply #5 on: February 28, 2018, 11:30:23 AM »
The Sprout does not have the bootloader pre-installed, you can program the chip on the Sprout using an ICSP programmer (or an arduino-as-isp).

Some of the Sprout kits have an arduino bootloader, but that's cause i manually flashed them.

-sam