Go Down

Topic: 1284p Bootloader w/Arduino as ISP (Read 1 time) previous topic - next topic

DrAzzy

I would:

Show Verbose Upload, post output here, including that first line where it shows the avrdude invocation.

Watch while it uploads, does the LED give the optiboot blink (is there an LED on the pin that the core assumes?) - this is a very important debugging step, as it tells you whether the chip is getting correctly reset when DTR goes low. If it does, it should be working.

If not, does the LED blink when you press reset? If it does - it's the autoreset circuit - if not either there isn't an LED on that pin, or the bootloader isn't running at all.


If it "should be working" per above:
* If you're not using a professionally made cable with the correct pinout for DTR/TX/RX/Vcc/Gnd - if not, swap TX/RX in case you got that backwards (my success rate with TX/RX and SDA/SCL on first try is barely better than random), see if that fixes it :-P (switch it back the way you expect it to be if this doesn't work)
* You're using MightyCore to burn the bootloader - you're using MightyCore to upload right?
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

FedorAdarichev

#16
Jan 09, 2018, 06:51 pm Last Edit: Jan 09, 2018, 08:43 pm by FedorAdarichev
Here is my output:

Sketch uses 1216 bytes (0%) of program storage space. Maximum is 130048 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 16375 bytes for local variables. Maximum is 16384 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Users\ME\AppData\Local\Arduino15\packages\MightyCore\hardware\avr\1.0.6/avrdude.conf -v -patmega1284p -carduino -PCOM7 -b115200 -D -Uflash:w:C:\Users\ME\AppData\Local\Temp\arduino_build_83994/Blink.ino.hex:i

avrdude: Version 6.3, compiled on Jan 17 2017 at 12:00:53
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\ME\AppData\Local\Arduino15\packages\MightyCore\hardware\avr\1.0.6/avrdude.conf"

         Using Port                    : COM7
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0xff
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0xff
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0xff
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xff
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0xff
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0xff
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0xff
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0xff
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xff
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0xff

avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.



I soldered an LED to PB0 on the 1284p, and when I hooked up my FTDI adapter to the computer to upload the sketch (provided power to my clone board), that LED blinked three times.  When I hit upload on the sketch, the "TX" LED on the FTDI adapter blinked three times.  The LED on the MCU actually did different things.  It either didn't blink at all when trying to upload, or it actually did start blinking randomly. It also did not blink when I had power provided through the FTDI adapter and I hit the reset button. 

I tried to re-burn the bootloader, I am getting this error message now:

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

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.

I am for sure using MightyCore.  I switched the TX/RX wires on the FTDI, and it still gives me the same error.

kprims

"I can see your approach, but I can't even get any sketch to upload, that's the problem."

Using "Sketch/Upload Using Programmer"?

FedorAdarichev

#18
Jan 09, 2018, 08:49 pm Last Edit: Jan 09, 2018, 10:09 pm by FedorAdarichev
@kprims

When I try and upload using programmer (Arduino Uno), I get the following error:

An error occurred while uploading the sketch
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.


The LED on the 1284p board (on pin PB0) blinks repeatedly with double pulses while plugged in with the Arduino Uno.  There are no such pulses when I hit upload with the programmer, though.

DrAzzy

0x000000 signature indicates wiring mistake or that the clock is no longer running; That would explain why nothing else was working.

I think your replacement crystal loading cap is the problem here; a film cap really isn't appropriate for use as a loading cap (or a decoupling cap, for that matter, for the same reason - too much parasitic inductance) - you need a ceramic one - and that film cap also looks too big to be 22pf too; the loading cap must be the correct capacitance.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

ron_sutherland

#20
Jan 09, 2018, 09:56 pm Last Edit: Jan 09, 2018, 10:25 pm by ron_sutherland
You have an ATMEGA1284P-AU (44TQFP) package which has PB0 at pin 40, RX at pin 9, TX at pin 10. The DIP package has PB0 at pin 1, RX at pin 14, and TX at pin 15. Are you using the right pins? On an ATMEGA1284P-AU package pin 1 is MOSI and is also used for ISP which would explain why the bootloader no longer uploads with the ISP tool if it has an LED.

I see MightyCore has a lot of bootloaders to pick from.

https://github.com/MCUdude/MightyCore/blob/master/avr/bootloaders/optiboot_flash/makeall

Do the options show up in the IDE to allow selecting the bootloader to upload, e.g. one that matches the baud rate (BAUD_RATE=115200) and the crystal (AVR_FREQ=16000000L)?

Does the crystal have any markings, are you sure it is 16MHz?

Update: options do show up



Update+: wait I don't see a baud rate to click... hmmm

trungdn

@kprims

When I try and upload using programmer (Arduino Uno), I get the following error:

An error occurred while uploading the sketch
Reading | ################################################## | 100% 0.02s

avrdude: Device signature = 0x000000
avrdude: Yikes!  Invalid device signature.
         Double check connections and try again, or use -F to override
         this check.


avrdude done.  Thank you.


The LED on the 1284p board (on pin PB0) blinks repeatedly with double pulses while plugged in with the Arduino Uno.  There are no such pulses when I hit upload with the programmer, though.

http://www.instructables.com/id/Arduino-atmega6441284-clone/

I followed this instruction and it works pretty well to me.
I use FTDI to upload as well.

Try to use the libraries mention on this instruction. Make sure the connection is correct. It happened to me few times. Check clock, RX, TX connection.   

FedorAdarichev

#22
Jan 09, 2018, 11:31 pm Last Edit: Jan 09, 2018, 11:39 pm by FedorAdarichev
@DrAzzy

I want to confirm that yes I do have a 22pF capacitor on there, but it is film as you are indicating.  I replaced it with a 7pF and 15pF in parallel (producing 22pF).  I attached a photo as well, maybe that will reveal some problem I am not seeing.  I'm still getting the same avrdude: Device signature = 0x000000 when trying to burn the bootloader.

@ron_sutherland

Right now, I have RXI from the FTDI adapter going to pin 12 TXD1 on the 1284p, and TXD from the FTDI adapter going to pin 11 RXD1 on the 1284p.  This is according to MCUDude's "Standard" pinout, which is what I selected when I burned the bootloader (as opposed to Bobuino pinout). So, in this case, would my connections be correct? Does it have to be pins 9 and 10 instead of 11 and 12? And if it does have to be 9 and 10, is there a way I can edit this in the MightyCore software?

As far as baud rate options, there is nowhere in the IDE where I can select the baud rate, but I can select the MHz rating, and assuming my vendor supplied the right information and sent the right parts, I am using a 16 MHz oscillator.  It also has "16" written on top of it, you can see this in the photo as well.  Do you know how I can make a selection for the baud rate?

Thank you gentleman, I have a feeling we are close to finding a solution!


FedorAdarichev

@trungdn

What version of Arduino IDE are you using?

ron_sutherland

#24
Jan 10, 2018, 01:32 am Last Edit: Jan 10, 2018, 02:52 am by ron_sutherland
I think all the bootloaders in MightyCore are set to use UART0 so you need to use pin 9 and 10 (on the TQFP package) as the bootload port.

OP image


pinout of 1284p-au


Quote
is there a way I can edit this in the MightyCore software?
yes, but I only know how to do this on Linux.

ron_sutherland

Actually, Hans may want to add that option, if you want to start an issue on GitHub.

https://github.com/MCUdude/MightyCore/issues

ron_sutherland

#26
Jan 10, 2018, 09:27 am Last Edit: Jan 10, 2018, 09:32 am by ron_sutherland
Decided to have a look at the bootloader, so first make a fork

https://github.com/epccs/MightyCore/

I had problems building the serial bootloader on Ubuntu 17.10  so I tried 16.04 on a different machine which is what these notes are for

Github cloned it into my Samba file-share with has CR+LF on the scripts, it is the the everlasting line-ending gift from hell. Which was some of the issue I was having on 17.10.

Code: [Select]
make atmega1284p AVR_FREQ=16000000L BAUD_RATE=115200 UART=0 LED=B0 LED_START_FLASHES=2 -BIGBOOT
...
avr-gcc -g -Wall -Os -fno-split-wide-types -mrelax -fno-caller-saves -mmcu=atmega1284p -DF_CPU=16000000L  -DBAUD_RATE=115200 -DLED_START_FLASHES=2    -DLED=B0  -DBIGBOOT -DUART=0 -Wl,--section-start=.text=0x1fc00 -Wl,--section-start=.version=0x1fffe -Wl,--relax -nostartfiles -nostdlib -o atmega1284p/optiboot_flash_atmega1284p_115200_16000000L.elf optiboot_flash.o -lc
optiboot_flash.o: In function `appStart':
/home/rsutherland/Samba/git/MightyCore/avr/bootloaders/optiboot_flash/optiboot_flash.c:887: undefined reference to `eeprom_write_byte'
/home/rsutherland/Samba/git/MightyCore/avr/bootloaders/optiboot_flash/optiboot_flash.c:887: undefined reference to `eeprom_read_byte'
collect2: error: ld returned 1 exit status


Looking in the bootloader I see

Code: [Select]
#if defined(SUPPORT_EEPROM) || defined(BIGBOOT)
    case 'E': // EEPROM
 do {
    putch(eeprom_read_byte((uint8_t *)(address++)));
 } while (--length);
 break;
#endif


some how the SUPPORT_EEPROM flag is being set, but I don't want to waste time looking at the Makefile it is to full of cruft (would that be better in a readme, or a donotreadme).

anyway I am just going to comment that and build the bootloader.

ron_sutherland

#27
Jan 10, 2018, 09:28 am Last Edit: Jan 10, 2018, 09:41 am by ron_sutherland
I striped the other hex files to limit the confusion.

Anyway this is the bootloader image I ended up with that has UART = 1

https://github.com/epccs/MightyCore/tree/master/avr/bootloaders/optiboot_flash/atmega1284p

If you want to try it I guess you can replace the one you have in

Code: [Select]
C:\Users\<your_user>\AppData\Local\Arduino15\packages\MightyCore\hardware\avr\1.0.8\bootloaders\optiboot_flash\atmega1284p

Note: I will probably nuke the repo in a few weeks but wanted to have a look at the bootloader, I was using xboot on my 1284p board but would like to have options in case I have problems when I start working on it again.

FedorAdarichev

It works!

I replaced the oscillator on my board, and also shortened up the leads on the replacement 22pF capacitor I had.  With these changes, I was able to successfully burn the the UART1 version of the bootloader per ron's instruction as outlined above.  Now, after burning that version of the bootloader, I am able to still use the same PCB layout I currently have to upload sketches with my FTDI.

Big thanks to DrAzzy and ron_sutherland for helping me through this!

However, now that I have my sketch uploaded, I'm trying to debug using serial print, and I'm not seeing anything on my serial monitor, is this also some additional code in the bootloader that has to be included?

DrAzzy

However, now that I have my sketch uploaded, I'm trying to debug using serial print, and I'm not seeing anything on my serial monitor, is this also some additional code in the bootloader that has to be included?
Nope, it ought to just work - the fact that you can upload using serial instead of ISP indicates that you have the wiring correct.

I don't see a way it could be broken here unless you forgot Serial.begin() or something in the sketch... it would have to be a bug in the core, but I can't imagine such an unsubtle bug being in MightyCore; everyone uses Serial.
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up