dbuezas / lgt8fx

Board Package for Logic Green LGT8F328P LGT8F328D and LGT8F88D
362 stars 87 forks source link

Problems with burning the bootloader #256

Closed wollewald closed 1 year ago

wollewald commented 1 year ago

I have tried to burn the bootloader on a Pro Mini type LGT8F328P board using a Nano type LGT8F328 board as programmer. I followed these instructions: https://github.com/dbuezas/lgt8fx/tree/master/lgt8f/libraries/LarduinoISP

No problem to upload the LarduinoISP sketch to the Nano type board.

Also no problem to upload sketches to the Pro Mini type board using the Nano type board (which makes me confident that I did not do things completely wrong) and this circuit:

lgt8f328p_nano_mini_isp_programming

These were the settings:

settings

Then I tried burning the bootloader with exactly the same settings. There were some error meassages:

avrdude: Version 6.3, compiled on Jun 22 2016 at 16:05:21 Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/ Copyright (c) 2007-2014 Joerg Wunsch

     System wide configuration file is "C:\Users\Ewald\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino2/etc/avrdude.conf"

     Using Port                    : COM27
     Using Programmer              : stk500v1
     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 : STK500
     Description     : Atmel STK500 Version 1.x firmware
     Hardware Version: 3
     Firmware Version: 5.1
     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

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: erasing chip
avrdude: reading input file "0x3f"
avrdude: writing lock (1 bytes):

Fehler beim Brennen des Bootloaders.
Writing | ################################################## | 100% 0.00s

avrdude: 1 bytes of lock written
avrdude: verifying lock memory against 0x3f:
avrdude: load data lock data from input file 0x3f:
avrdude: input file 0x3f contains 1 bytes
avrdude: reading on-chip lock data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: 1 bytes of lock verified
avrdude: reading input file "0x07"
avrdude: writing efuse (1 bytes):

Writing |  ***failed;  
################################################## | 100% 0.03s

avrdude: 1 bytes of efuse written
avrdude: verifying efuse memory against 0x07:
avrdude: load data efuse data from input file 0x07:
avrdude: input file 0x07 contains 1 bytes
avrdude: reading on-chip efuse data:

Reading | ################################################## | 100% 0.00s

avrdude: verifying ...
avrdude: verification error, first mismatch at byte 0x0000
         0xff != 0x07
avrdude: verification error; content mismatch

avrdude done.  Thank you.

After that procedure I was still able to upload programs to the Pro Mini type board using the Nano type board as a programmer, but strangely uploads to the Pro Mini type board with a USB-to-TTL adapter did not work anymore:

lgt8f328p_serial_programming

Error message: avrdude: stk500_recv(): programmer is not responding avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x65

I tried a fresh Pro Mini type board in parallel: no problem. So, no setting issue.

Any idea?

dbuezas commented 1 year ago

When you upload a sketch via an ISP, you get a program without bootloader. This means that uploading via serial is not possible anymore. To get back this back, upload the bootloader alone and then your sketch via serial

wollewald commented 1 year ago

Thanks for the quick response. But this is exactly what I tried. When I try to burn the bootloader, I get the error messages which I have shown above and no serial upload is possible anymore.

dbuezas commented 1 year ago

Interesting, I don't remember having issues with this, but i think I only tried it with a ssop20 as target. You could try this: https://github.com/SuperUserNameMan/LGTISP Or this guide: https://github.com/rickygai/arduino/blob/main/LGT8F328P.pdf

Please let me know if and which one worked :)

LaZsolt commented 1 year ago

The other interesting thing is the failed fuse bit wiring. In LGT8F328x has no fuse bits. It's emulated for the avrdude.

dbuezas commented 1 year ago

Maybe avrdude was updated?

wollewald commented 1 year ago

Or a different version of the LGT8F328P? I will try to burn the bootloader on an SSOP20 board, then we'll see if it's a general issue on my side. Boards with the SSOP20 version of the LGT8F328P are not so easy to get. It didn't get it on Amazon, AliExpress and ebay. Finally, I ordered them in a shop in UK. So might take a bit until they arrive in Germany. I will inform you after I have tried. Burning the bootloader is maybe not something I will need very often. But I am going to present the LGT8F328P in my blog in some weeks and that aspect would complete my post. But I can just say that this is work in progress and that there might be a certain risk currently.

dbuezas commented 1 year ago

Oh interesting, now there are qfp48 variants with usb c instead. I have some ssop20 boards still, I'll give it a try tonight too

dbuezas commented 1 year ago

Another test, another board with a burned usb diode 😡. Anyway I tried it on a ssop20 and lqfp32 and uploading the bootloader didn't work indeed. I now changed the extended fuses to 0xff, which according to the error message is the right thing to do when there are no fuses.

With that change, I can burn the bootloader and then upload via serial 🎉

Please try v2.0.1 (it's being released right now) and let me know if it worked.

If you are writing a blog post about this chip, let me suggest these two projects :)

Feel free to reopen if this doesn't fix it for you!

dbuezas commented 1 year ago

I made the ISP readme more clear too btw

wollewald commented 1 year ago

Yeeeeesssss - works perfect. Thank you so much for solving this issue in record time!

The blog post about the LGT8F328P will be published in about 5 weeks. Of course I will highlight the great work you did with this package! And I will put in links to the projects you mentioned. But going into details would make the post a bit too long. It's already quite comprehensive. Seems to be worth a separate post.

Btw, this is the link to the blog: https://wolles-elektronikkiste.de/en/

Most of the content of my post is covered by your board package and examples but maybe you still find some interesting aspects. E.g. I tested the reliability of the ADC and DAC.

So thanks again to you and of course also to all the contributors!

dwillmore commented 1 year ago

Would you like us to review your article before you publish it?

On Tue, Mar 28, 2023, 1:05 PM Wolfgang (Wolle) Ewald < @.***> wrote:

Yeeeeesssss - works perfect. Thank you so much for solving this issue in record time!

The blog post about the LGT8F328P will be published in about 5 weeks. Of course I will highlight the great work you did with this package! And I will put in links to the projects you mentioned. But going into details would make the post a bit too long. It's already quite comprehensive. Seems to be worth a separate post.

Btw, this is the link to the blog: https://wolles-elektronikkiste.de/en/

Most of the content of my post is covered by your board package and examples but maybe you still find some interesting aspects. E.g. I tested the reliability of the ADC and DAC.

So thanks again to you and of course also to all the contributors!

— Reply to this email directly, view it on GitHub https://github.com/dbuezas/lgt8fx/issues/256#issuecomment-1487295952, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACPEX7DTK43XTQJLJWM22ODW6MK4XANCNFSM6AAAAAAWJSN2TQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dbuezas commented 1 year ago

Very nice blog! Here's an unasked for board review suggestion: drv8833 super cheap and nice 3-10v dual h bridge. Perfect to make a wifi controlled car

I'll for sure find the article interesting, and probably many people here too :).

+1 @dwillmore 's suggestion, the contribuitors in this repo are seriously knowledgeable

wollewald commented 1 year ago

@dwillmore Thank you, that would be great. Still need a week or so to complete it. How to share without publishing it? I could make a pdf out of it. @dbuezas Thanks for another suggestion!

dwillmore commented 1 year ago

@LaZsolt @SuperUserNameMan Are either of you interested in reviewing @wollewald's article? Email me at gmail. My user name is my first name(which is the same as @dbuezas ) and my last name is everthing but the 'd' of my username here. So, my email is just my first name and my last name smooshed together with no puncuation.