Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

To support LGT8F328P #359

Open
mcuee opened this issue Dec 20, 2022 · 10 comments
Open

To support LGT8F328P #359

mcuee opened this issue Dec 20, 2022 · 10 comments

Comments

@mcuee
Copy link

mcuee commented Dec 20, 2022

The following bootloader works fine but I think the source code in the repo does not match the bootloader hex file.
https://github.com/LGTMCU/Larduino_HSP/tree/master/hardware/LGT/avr/bootloaders/lgt8fx8p

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c urclock -P COM20 -b 57600 -p lgt8f328p -xbootsize=3072 -qqt
avrdude> dump flash 0x7400
7400  11 24 8f ef 98 e0 9e bf  8d bf 94 b7 14 be 89 2f  |.$............./|
7410  8d 70 11 f0 89 2f ec d1  90 e8 90 93 f2 00 83 e9  |.p.../..........|
7420  80 93 f2 00 90 93 61 00  81 e0 80 93 61 00 96 bf  |......a.....a...|
7430  8c e4 86 bf 85 e0 80 93  81 00 88 e1 80 93 c1 00  |................|
7440  86 e0 80 93 c2 00 80 e1  80 93 c4 00 8d e0 ba d1  |................|
7450  25 9a 96 e0 20 e3 3c ef  51 e0 40 e2 30 93 85 00  |%... .<[email protected]...|
7460  20 93 84 00 56 bb b0 9b  fe cf 85 b1 84 27 85 b9  | ...V........'..|
7470  a8 95 91 50 99 f7 88 24  99 24 54 01 cc 24 dd 24  |...P...$.$T..$.$|
7480  64 e9 66 2e 51 e0 25 2e  31 2c 41 2c 51 2c 89 d1  |d.f.Q.%.1,A,Q,..|
7490  81 34 61 f4 86 d1 18 2f  9b d1 12 38 29 f1 11 38  |.4a..../...8)..8|
74a0  11 f4 85 e0 01 c0 83 e0  74 d1 70 c1 82 34 11 f4  |........t.p..4..|
74b0  84 e1 03 c0 85 34 19 f4  85 e0 92 d1 67 c1 85 35  |.....4......g..5|
74c0  79 f4 6f d1 e8 2e ff 24  6c d1 08 2f 10 e0 10 2f  |y.o....$l../.../|
74d0  00 27 0e 29 1f 29 00 0f  11 1f 7a d1 68 01 56 c1  |.'.).)....z.h.V.|
74e0  86 35 21 f4 84 e0 7c d1  80 e0 de cf 84 36 09 f0  |.5!...|......6 .|
74f0  d1 c0 57 d1 90 e0 f8 2e  ee 24 53 d1 e8 0e f1 1c  |..W......$S.....|

avrdude> dump flash
7500  50 d1 78 2e e7 01 00 e0  11 e0 4b d1 f8 01 81 93  |P.x.......K.....|
7510  8f 01 21 97 d1 f7 11 bc  8d 2d 99 27 82 bd 82 b5  |..!......-.'....|
7520  86 95 86 95 28 2f d5 01  c4 01 02 2e 04 c0 b6 95  |....(/..........|
7530  a7 95 97 95 87 95 0a 94  d2 f7 80 fd 19 c0 f6 e4  |...... .........|
7540  7f 16 b1 f4 d2 01 c1 01  04 c0 88 0f 99 1f aa 1f  |................|
7550  bb 1f 2a 95 d2 f7 88 2a  99 2a aa 2a bb 2a 82 b5  |..*....*.*.*.*..|
7560  8c 77 84 37 29 f0 6f ba  82 e9 8f bb 00 00 00 00  |.w.7).o.........|
7570  2f d1 e5 e4 7e 16 d1 f4  96 01 14 c0 21 bd 2f 5f  |/...~.......!./_|
7580  3f 4f 83 2f 99 27 82 bd  c0 50 df 4f 88 81 c0 50  |?O./.'...P.O...P|
7590  d1 40 80 bd 82 b5 88 37  20 f0 f4 e0 ff bb 82 e0  |[email protected] .......|
75a0  8f bb 21 96 ce 15 df 05  48 f3 df c0 82 b5 84 37  |..!.....H......7|
75b0  08 f0 ec c0 c1 14 d1 04  09 f0 4e c0 60 91 00 01  |........ .N.`...|
75c0  70 91 01 01 87 2f 90 e0  98 2f 88 27 26 2f 30 e0  |p..../.../.'&/0.|
75d0  82 2b 93 2b 90 93 85 01  80 93 84 01 40 91 02 01  |.+.+........@...|
75e0  50 91 03 01 85 2f 90 e0  98 2f 88 27 24 2f 30 e0  |P..../.../.'$/0.|
75f0  82 2b 93 2b 90 93 87 01  80 93 86 01 20 91 18 01  |.+.+........ ...|

avrdude> dump flash
7600  80 91 19 01 90 e0 98 2f  88 27 30 e0 82 2b 93 2b  |......./.'0..+.+|
7610  90 93 89 01 80 93 88 01  20 91 1a 01 80 91 1b 01  |........ .......|
7620  90 e0 98 2f 88 27 30 e0  82 2b 93 2b 90 93 8b 01  |.../.'0..+.+....|
7630  80 93 8a 01 60 93 18 01  70 93 19 01 40 93 1a 01  |....`...p...@...|
7640  50 93 1b 01 8c e0 80 93  00 01 60 92 01 01 10 92  |P.........`.....|
7650  02 01 ea e3 e0 93 03 01  e0 e0 f1 e0 11 bc 80 81  |................|
7660  80 bd 81 e0 81 bd 81 81  80 bd 82 e0 81 bd 82 81  |................|
7670  80 bd 83 e0 81 bd 83 81  80 bd 8e 2f 8c 0d 81 bd  |.........../. ..|
7680  84 ea 8f bb 82 ea 8f bb  34 96 81 e0 e0 38 f8 07  |........4....8..|
7690  29 f7 7c c0 84 37 09 f0  6b c0 83 d0 90 e0 f8 2e  |).|..7 .k.......|
76a0  ee 24 7f d0 e8 0e f1 1c  7c d0 18 2f 91 d0 15 34  |.$......|../...4|
76b0  89 f4 e6 01 87 01 c1 bd  21 96 8d 2f 99 27 82 bd  |........!../.'..|
76c0  e1 e0 ef bb 00 00 00 00  80 b5 63 d0 01 50 10 40  |..........c..P.@|
76d0  91 f7 4b c0 e6 01 87 01  20 97 29 f4 80 91 84 01  |..K..... .).....|
76e0  90 91 85 01 3c c0 c1 30  d1 05 29 f4 80 91 84 01  |....<..0..).....|
76f0  90 91 85 01 0f c0 c2 30  d1 05 29 f4 80 91 86 01  |.......0..).....|

avrdude> dump flash
7700  90 91 87 01 2c c0 c3 30  d1 05 39 f4 80 91 86 01  |....,..0..9.....|
7710  90 91 87 01 89 2f 99 27  22 c0 c8 31 d1 05 29 f4  |...../.'"..1..).|
7720  80 91 88 01 90 91 89 01  1a c0 c9 31 d1 05 29 f4  |...........1..).|
7730  80 91 88 01 90 91 89 01  ed cf ca 31 d1 05 29 f4  |...........1..).|
7740  80 91 8a 01 90 91 8b 01  0a c0 cb 31 d1 05 29 f4  |........ ..1..).|
7750  80 91 8a 01 90 91 8b 01  dd cf fe 01 84 91 21 96  |..............!.|
7760  18 d0 01 50 10 40 09 f0  b7 cf ce 0c df 1c 0e c0  |...P.@ .... ....|
7770  85 37 39 f4 2d d0 8e e1  0c d0 85 e9 0a d0 8f e0  |.79.-... ... ...|
7780  93 ce 81 35 11 f4 8c e0  1d d0 22 d0 80 e1 01 d0  |...5......".....|
7790  7e ce 98 2f 80 91 c0 00  85 ff fc cf 90 93 c6 00  |~../............|
77a0  08 95 80 91 c0 00 87 ff  fc cf 80 91 c0 00 84 fd  |................|
77b0  01 c0 a8 95 80 91 c6 00  08 95 9a e2 9a 95 f1 f7  |................|
77c0  08 95 08 95 e0 e6 f0 e0  98 e1 90 83 80 83 08 95  |................|
77d0  e8 df 80 32 19 f0 8d e0  f5 df ff cf 84 e1 d9 cf  |...2............|
77e0  1f 93 18 2f de df 11 50  e9 f7 f2 df 1f 91 08 95  |.../...P........|
77f0  28 2e 80 e0 e7 df ec e0  ff 27 09 94 ff ff 00 05  |(........' .....|

avrdude> dump flash
7800  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
7810  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
7820  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
7830  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
7840  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
7850  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
7860  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
7870  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
7880  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
7890  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
78a0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
78b0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
78c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
78d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
78e0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
78f0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
@WestfW
Copy link
Member

WestfW commented Dec 22, 2022

Not impressed that they're not paying attention to the license.
Even removed the copyrights!

@mcuee
Copy link
Author

mcuee commented Dec 22, 2022

Not impressed that they're not paying attention to the license. Even removed the copyrights!

Indeed.

@mcuee
Copy link
Author

mcuee commented Dec 22, 2022

Somehow the factory hex file wokes but none my build hex file work.

I use a Nano and follow the following instruction to build LGTISP which seems to work fine.
https://github.com/dbuezas/lgt8fx/tree/master/lgt8f/libraries/LarduinoISP

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c avrisp -P COM12 -p lgt8f328p -U .\optiboot_lgt8f328p.hex

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably lgt8f328p)
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: reading input file .\optiboot_lgt8f328p.hex for flash
         with 1002 bytes in 3 sections within [0, 0x77ff]
         using 9 pages and 150 pad bytes
avrdude: writing 1002 bytes flash ...

Writing | ################################################## | 100% 0.38 s

avrdude: 1002 bytes of flash written
avrdude: verifying flash memory against .\optiboot_lgt8f328p.hex

Reading | ################################################## | 100% 0.06 s

avrdude: 1002 bytes of flash verified

avrdude done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c arduino -P COM19 -b 57600 -p lgt8f328p

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably lgt8f328p)

avrdude done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c avrisp -P COM12 -p lgt8f328p
 -U .\optiboot_lgt8f328p_build1.hex -qq && echo OK
OK

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c arduino -P COM19 -b 57600 -p lgt8f328p
avrdude error: programmer is not responding
avrdude warning: attempt 1 of 10: not in sync: resp=0x00

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c avrisp -P COM12 -p lgt8f328p 
-U .\optiboot_lgt8f328p_build2.hex -qq && echo OK
OK

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c arduino -P COM19 -b 57600 -p lgt8f328p
avrdude error: programmer is not responding
avrdude warning: attempt 1 of 10: not in sync: resp=0x00

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c avrisp -P COM12 -p lgt8f328p
 -U .\optiboot_lgt8f328p_build3.hex -qq && echo OK
OK

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c arduino -P COM19 -b 57600 -p lgt8f328p
avrdude error: programmer is not responding
avrdude warning: attempt 1 of 10: not in sync: resp=0x00

@mcuee
Copy link
Author

mcuee commented Dec 22, 2022

I found a mistake in my build that frequency should be 16MHz. But it still does not work.

I will give up for now. Hopefully someone else who is more familiar with the chip can chime in and help out.

@mcuee
Copy link
Author

mcuee commented Dec 23, 2022

This is with WinAVR.

$ avr-gcc -v
Using built-in specs.
Target: avr
Configured with: ../gcc-4.3.3/configure --enable-win32-registry=WinAVR-20100110 --with-gmp=/usr/local --with-mpfr=/usr/local --prefix=/c/WinAVR --target=avr --enable-languages=c,c++,objc --with-dwarf2 --enable-doc --disable-shared --disable-libada --disable-libssp --disable-nls --with-pkgversion='WinAVR 20100110' --with-bugurl='URL:http://sourceforge.net/tracker/?atid=520074&group_id=68108&func=browse'
Thread model: single
gcc version 4.3.3 (WinAVR 20100110)

$ make lgt8f328p
BAUD RATE CHECK: Desired: 57600, Real: 57142, UBRRL = 34, Error=0.7%
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=16000000L   -DBAUD_RATE=57600 -DLED_START_FLASHES=3      -DEXT_OSC=0 '-DVIRTUAL_BOOT_PARTITION'   -c -o optiboot.o optiboot.c
avr-gcc -g -Wall -Os -fno-inline-small-functions -fno-split-wide-types -mshort-calls -mmcu=atmega328p -DF_CPU=16000000L   -DBAUD_RATE=57600 -DLED_START_FLASHES=3      -DEXT_OSC=0 '-DVIRTUAL_BOOT_PARTITION' -Wl,--section-start=.bootv=0x0 -Wl,--section-start=.text=0x7400 -Wl,--section-start=.version=0x77fe -Wl,--relax -nostartfiles -nostdlib -o optiboot_lgt8f328p.elf optiboot.o
avr-size optiboot_lgt8f328p.elf
   text    data     bss     dec     hex filename
    996       0       0     996     3e4 optiboot_lgt8f328p.elf
avr-objcopy -j .bootv -j .text -j .data -j .version --set-section-flags .version=alloc,load --set-section-flags .bootv=alloc,load -O ihex optiboot_lgt8f328p.elf optiboot_lgt8f328p.hex
avr-objdump -h -S optiboot_lgt8f328p.elf > optiboot_lgt8f328p.lst

$ cat optiboot_lgt8f328p.hex
:040000000C94003A22
:1074000011248FEF98E09EBF8DBF94B714BE892FD3
:107410008D7011F0892FE0D190E89093F20083E90C
:107420008093F2009093610081E08093610096BFA9
:107430008CE486BF85E08093810088E18093C10061
:1074400086E08093C20080E18093C4008DE0AED1DD
:10745000259A96E020E33CEF51E040E2309385002E
:107460002093840056BBB09BFECF85B1842785B99D
:10747000A895915099F7662477244301CC24DD2404
:1074800064E9A62E51E0252E312C412C512C7DD1C2
:10749000813461F47AD1182F8FD1123829F1113843
:1074A00011F485E001C083E068D164C1823411F435
:1074B00084E103C0853419F485E086D15BC185354C
:1074C00079F463D1E82EFF2460D1082F10E0102F4B
:1074D00000270E291F29000F111F6ED168014AC114
:1074E000863521F484E070D180E0DECF843609F067
:1074F000C5C04BD190E0F82EEE2447D1E80EF11C28
:1075000044D1B82EE70100E011E03FD1F8018193AA
:107510008F012197D1F711BC8D2D992782BD82B59E
:1075200086958695282FD401C301022E04C0B695F6
:10753000A795979587950A94D2F780FD15C0F6E434
:10754000BF1691F4D201C10104C0880F991FAA1F70
:10755000BB1F2A95D2F7682A792A8A2A9B2AAFBAB2
:1075600082E98FBB0000000027D1E5E4BE16B1F42C
:10757000960110C021BD2F5F3F4F832F992782BDF9
:10758000C050DF4F888180BDF4E0FFBB82E08FBB3D
:10759000CF5FD040CE15DF0568F3DBC0C114D10446
:1075A00009F04EC06091000170910101872F90E0B9
:1075B000982F8827262F30E0822B932B90938501DC
:1075C000809384014091020150910301852F90E046
:1075D000982F8827242F30E0822B932B90938701BC
:1075E00080938601209118018091190190E0982FD5
:1075F000882730E0822B932B909389018093880118
:1076000020911A0180911B0190E0982F882730E08B
:10761000822B932B90938B0180938A0160931801A6
:107620007093190140931A0150931B018CE08093D1
:107630000001A092010110920201EAE3E09303012C
:10764000E0E0F1E011BC808180BD81E081BD8181FD
:1076500080BD82E081BD828180BD83E081BD838168
:1076600080BD8E2F8C0D81BD84EA8FBB82EA8FBBDB
:10767000349681E0E038F80729F77CC0843709F0B8
:107680006BC083D090E0F82EEE247FD0E80EF11C82
:107690007CD0182F91D0153489F4E6018701C1BD43
:1076A00021968D2F992782BDE1E0EFBB00000000FD
:1076B00080B563D00150104091F74BC0E6018701BF
:1076C000209729F480918401909185013CC0C130BC
:1076D000D10529F480918401909185010FC0C230B9
:1076E000D10529F480918601909187012CC0C33087
:1076F000D10539F48091860190918701892F9927CE
:1077000022C0C831D10529F4809188019091890166
:107710001AC0C931D10529F480918801909189015D
:10772000EDCFCA31D10529F480918A0190918B0166
:107730000AC0CB31D10529F480918A0190918B0147
:10774000DDCFFE018491219618D00150104009F040
:10775000B7CFCE0CDF1C0EC0853739F42DD08EE1AB
:107760000CD085E90AD08FE09FCE813511F48CE0F2
:107770001DD022D080E101D08ACE982F8091C00008
:1077800085FFFCCF9093C60008958091C00087FFCD
:10779000FCCF8091C00084FD01C0A8958091C600F7
:1077A00008959AE29A95F1F708950895E0E6F0E0D9
:1077B00098E1908380830895E8DF803219F08DE0AE
:1077C000F5DFFFCF84E1D9CF1F93182FDEDF1150F3
:1077D000E9F7F2DF1F910895282E80E0E7DFECE063
:0477E000FF270994E2
:0277FE00000584
:040000030000740085
:00000001FF

The above seems to be the same as factory hex file.
https://github.com/LGTMCU/Larduino_HSP/blob/master/hardware/LGT/avr/bootloaders/lgt8fx8p/optiboot_lgt8f328p.hex

:040000000C94003A22
:1074000011248FEF98E09EBF8DBF94B714BE892FD3
:107410008D7011F0892FE0D190E89093F20083E90C
:107420008093F2009093610081E08093610096BFA9
:107430008CE486BF85E08093810088E18093C10061
:1074400086E08093C20080E18093C4008DE0AED1DD
:10745000259A96E020E33CEF51E040E2309385002E
:107460002093840056BBB09BFECF85B1842785B99D
:10747000A895915099F7662477244301CC24DD2404
:1074800064E9A62E51E0252E312C412C512C7DD1C2
:10749000813461F47AD1182F8FD1123829F1113843
:1074A00011F485E001C083E068D164C1823411F435
:1074B00084E103C0853419F485E086D15BC185354C
:1074C00079F463D1E82EFF2460D1082F10E0102F4B
:1074D00000270E291F29000F111F6ED168014AC114
:1074E000863521F484E070D180E0DECF843609F067
:1074F000C5C04BD190E0F82EEE2447D1E80EF11C28
:1075000044D1B82EE70100E011E03FD1F8018193AA
:107510008F012197D1F711BC8D2D992782BD82B59E
:1075200086958695282FD401C301022E04C0B695F6
:10753000A795979587950A94D2F780FD15C0F6E434
:10754000BF1691F4D201C10104C0880F991FAA1F70
:10755000BB1F2A95D2F7682A792A8A2A9B2AAFBAB2
:1075600082E98FBB0000000027D1E5E4BE16B1F42C
:10757000960110C021BD2F5F3F4F832F992782BDF9
:10758000C050DF4F888180BDF4E0FFBB82E08FBB3D
:10759000CF5FD040CE15DF0568F3DBC0C114D10446
:1075A00009F04EC06091000170910101872F90E0B9
:1075B000982F8827262F30E0822B932B90938501DC
:1075C000809384014091020150910301852F90E046
:1075D000982F8827242F30E0822B932B90938701BC
:1075E00080938601209118018091190190E0982FD5
:1075F000882730E0822B932B909389018093880118
:1076000020911A0180911B0190E0982F882730E08B
:10761000822B932B90938B0180938A0160931801A6
:107620007093190140931A0150931B018CE08093D1
:107630000001A092010110920201EAE3E09303012C
:10764000E0E0F1E011BC808180BD81E081BD8181FD
:1076500080BD82E081BD828180BD83E081BD838168
:1076600080BD8E2F8C0D81BD84EA8FBB82EA8FBBDB
:10767000349681E0E038F80729F77CC0843709F0B8
:107680006BC083D090E0F82EEE247FD0E80EF11C82
:107690007CD0182F91D0153489F4E6018701C1BD43
:1076A00021968D2F992782BDE1E0EFBB00000000FD
:1076B00080B563D00150104091F74BC0E6018701BF
:1076C000209729F480918401909185013CC0C130BC
:1076D000D10529F480918401909185010FC0C230B9
:1076E000D10529F480918601909187012CC0C33087
:1076F000D10539F48091860190918701892F9927CE
:1077000022C0C831D10529F4809188019091890166
:107710001AC0C931D10529F480918801909189015D
:10772000EDCFCA31D10529F480918A0190918B0166
:107730000AC0CB31D10529F480918A0190918B0147
:10774000DDCFFE018491219618D00150104009F040
:10775000B7CFCE0CDF1C0EC0853739F42DD08EE1AB
:107760000CD085E90AD08FE09FCE813511F48CE0F2
:107770001DD022D080E101D08ACE982F8091C00008
:1077800085FFFCCF9093C60008958091C00087FFCD
:10779000FCCF8091C00084FD01C0A8958091C600F7
:1077A00008959AE29A95F1F708950895E0E6F0E0D9
:1077B00098E1908380830895E8DF803219F08DE0AE
:1077C000F5DFFFCF84E1D9CF1F93182FDEDF1150F3
:1077D000E9F7F2DF1F910895282E80E0E7DFECE063
:0477E000FF270994E2
:0277FE00000584
:040000030000740085
:00000001FF

@mcuee
Copy link
Author

mcuee commented Dec 23, 2022

And finaly it works.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c avrisp -P COM12 -p lgt8f328p -U .\optiboot_lgt8f328p_winavr.hex

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably lgt8f328p)
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: reading input file .\optiboot_lgt8f328p_winavr.hex for flash
         with 1002 bytes in 3 sections within [0, 0x77ff]
         using 9 pages and 150 pad bytes
avrdude: writing 1002 bytes flash ...

Writing | ################################################## | 100% 0.38 s

avrdude: 1002 bytes of flash written
avrdude: verifying flash memory against .\optiboot_lgt8f328p_winavr.hex

Reading | ################################################## | 100% 0.06 s

avrdude: 1002 bytes of flash verified

avrdude done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c urclock -P COM19 -b 57600 -p lgt8f328p -xshowall -xbootsize=3072

avrdude: AVR device initialized and ready to accept instructions
0 0000-00-00 00.00  application 0 store 0 meta 0 boot 3072 x0.0 ......... vector 0 (RESET) LGT8F328P

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c urclock -P COM19 -b 57600 -p lgt8f328p -U .\Blink.ino.lgt8fx8p.hex -xbootsize=3072

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably lgt8f328p)
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: reading input file .\Blink.ino.lgt8fx8p.hex for flash
         with 1052 bytes in 1 section within [0, 0x41b]
         using 9 pages and 100 pad bytes
avrdude: preparing flash input for device bootloader
avrdude: writing 1052 bytes flash ...

Writing | ################################################## | 100% 0.37 s

avrdude: 1052 bytes of flash written
avrdude: verifying flash memory against .\Blink.ino.lgt8fx8p.hex

Reading | ################################################## | 100% 0.28 s

avrdude: 1052 bytes of flash verified

avrdude done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c urclock -P COM19 -b 57600 -p lgt8f328p -xshowall -xbootsize=3072

avrdude: AVR device initialized and ready to accept instructions
0 2022-06-04 20.56 Blink.ino.lgt8fx8p.hex 1052 store 28610 meta 34 boot 3072 x0.0 ......... vector 0 (RESET) LGT8F328P

@mcuee
Copy link
Author

mcuee commented Dec 23, 2022

I have also build the hex file with Atmel toolchain based on avr-gcc 5.4.0 and 7.3.0, as well as MSYS2 avr-gcc 8.5.0, only the avr-gcc 5.4.0 based version works.

PS C:\work\avr\avrdude_test\avrdude_bin> cat .\optiboot_lgt8f328p_gcc540.hex
:040000000C94003A22
:1074000000D01F92CDB7DEB711248FEF98E09EBF5A
:107410008DBF84B714BE982F9D7009F006D280E806
:107420008093F20093E99093F2008093610091E0E1
:107430009093610086BF8CE486BF85E080938100D5
:1074400088E18093C10096E09093C20090E1909310
:10745000C400809360008DE080936000259A86E0F0
:1074600040E35CEF31E020E25093850040938400DC
:1074700036BBB09BFECF95B1922795B9A8958150A8
:1074800099F71B821A82812C912C54012224239477
:1074900022E0322E412C512C320143949CD1813474
:1074A00061F499D1182FA8D1123811F1113811F4C3
:1074B00085E001C083E088D184C1823411F484E185
:1074C00003C0853419F485E0A3D17BC1853561F40F
:1074D00082D1898380D13981232F30E0382B220F4C
:1074E000331F3B832A836CC1863521F484E090D11D
:1074F00080E0E1CF843609F0C9C06DD1C82E6BD1D0
:10750000D12CDC2CCC24C80ED11C65D189838601FA
:10751000E12CFF24F3945FD1F70181937F010150A7
:107520001109C9F711BC2A813B81832F992782BD9C
:1075300082B586958695B501A401082E04C076957E
:107540006795579547950A94D2F740FD16C0398143
:10755000363499F4A301920104C0220F331F441F53
:10756000551F8A95D2F7822A932AA42AB52A84E93C
:107570008FBB82E98FBB000000003ED139813534DA
:10758000F9F44A815B81C40ED51EE0E0F1E04A8146
:107590005B814C155D0509F414C18A819B810196BC
:1075A0009B838A838A81815081BD2A813B81832F7D
:1075B000992782BD819180BD34E03FBB3FBAE7CFC0
:1075C0008A819B81892B09F045C040910101842F5C
:1075D00090E0982F882750910001852B909385018A
:1075E0008093840120910301822F90E0982F8827B7
:1075F00030910201832B90938701809386018091C3
:10760000190190E0982F882760911801862B90939C
:1076100089018093880180911B0190E0982F882731
:1076200060911A01862B90938B0180938A0150936D
:1076300018014093190130931A0120931B018CE02B
:107640008093000184E980930101109202018AE392
:1076500080930301E0E0F1E011BC808180BD21BC9A
:10766000818180BD31BC828180BD93E091BD8381E9
:1076700080BD8A818E0F81BD24EA2FBB32EA3FBBD9
:107680003496E03841E0F40739F79BC0843709F0BD
:1076900086C0A1D0082F10E0102F00279CD0080F23
:1076A000111D99D0F82EA8D055E46801F5121BC021
:1076B000EA80FB808FEFE81AF80A8FEF8E0D81BD0C
:1076C0008F2D992782BD2FBA0000000080B57CD095
:1076D00091E0C91AD10871F7EA81FB81E00FF11F2F
:1076E000FB83EA836EC0EA80FB80E114F10429F495
:1076F000809184019091850142C0F1E0EF16F10480
:1077000029F4809184019091850111C022E0E21654
:10771000F10429F4809186019091870130C033E013
:10772000E316F10431F48091860190918701892F4D
:1077300026C048E1E416F10429F480918801909173
:1077400089011DC059E1E516F10429F480918801F1
:1077500090918901ECCF8AE1E816F10429F4809137
:107760008A0190918B010BC09BE1E916F10429F489
:1077700080918A0190918B01DACFF7018491FFEF1C
:10778000EF1AFF0A21D021E0C21AD10809F0ADCFCB
:107790004A815B81400F511F5B834A8312C085374A
:1077A00039F42AD08EE110D085E90ED08FE083CE57
:1077B000813531F488E1809360008CE08093600033
:1077C0001BD080E101D06ACE9091C00095FFFCCF24
:1077D0008093C60008958091C00087FFFCCF809100
:1077E000C00084FD01C0A8958091C60008959AE26A
:1077F0009A95F1F708950895EEDF803239F088E127
:10780000809360008DE080936000FFCF84E1DCCF47
:10781000CF93C82FE0DFC150E9F7CF91EDCFE0E67D
:10782000F0E098E1908380830895282EE0E6F0E070
:0C78300088E180831082ECE0FF270994BF
:0277FE00000584
:040000030000740085
:00000001FF

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c avrisp -P COM12 -p lgt8f328p -U .\optiboot_lgt8f328p_gcc540.hex

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably lgt8f328p)
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: reading input file .\optiboot_lgt8f328p_gcc540.hex for flash
         with 1088 bytes in 2 sections within [0, 0x783b]
         using 10 pages and 192 pad bytes
avrdude: writing 1088 bytes flash ...

Writing | ################################################## | 100% 0.38 s

avrdude: 1088 bytes of flash written
avrdude: verifying flash memory against .\optiboot_lgt8f328p_gcc540.hex

Reading | ################################################## | 100% 0.06 s

avrdude: 1088 bytes of flash verified

avrdude done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c arduino -P COM19 -b 57600 -p lgt8f328p -D -U .\Blink.ino.lgt8fx8p.hex

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably lgt8f328p)
avrdude: reading input file .\Blink.ino.lgt8fx8p.hex for flash
         with 1052 bytes in 1 section within [0, 0x41b]
         using 9 pages and 100 pad bytes
avrdude: writing 1052 bytes flash ...

Writing | ################################################## | 100% 0.40 s

avrdude: 1052 bytes of flash written
avrdude: verifying flash memory against .\Blink.ino.lgt8fx8p.hex

Reading | ################################################## | 100% 0.28 s

avrdude: 1052 bytes of flash verified

avrdude done.  Thank you.

@mcuee
Copy link
Author

mcuee commented Dec 23, 2022

Here are the major changes by the vendor from an older version of optiboot (v5.0). There are also quite some changes if you compare the source codes.
https://code.google.com/archive/p/optiboot/downloads
https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/optiboot/optiboot-v5.0.zip

  1. the header file is provided by the vendor here.
    https://github.com/LGTMCU/Larduino_HSP/blob/master/hardware/LGT/avr/bootloaders/lgt8fx8p/lgtx8p.h

  2. initialization sequences
    https://github.com/LGTMCU/Larduino_HSP/blob/master/hardware/LGT/avr/bootloaders/lgt8fx8p/optiboot.c#L458-L468

  // WDT clock by 32KHz IRC
  PMCR = 0x80;
  PMCR = 0x93;

  // system clock: 16MHz system clock
  CLKPR = 0x80;
  CLKPR = 0x01;

  // enable 1KB E2PROM (for LGT8F328P)
  ECCR = 0x80;
  ECCR = 0x4C;
  1. Makefile changes here.
    https://github.com/LGTMCU/Larduino_HSP/blob/master/hardware/LGT/avr/bootloaders/lgt8fx8p/Makefile#L336-L354
# LGT8F328P
#
lgt8f328p: EXT_OSC ?= 0
lgt8f328p: TARGET = lgt8f328p
lgt8f328p: MCU_TARGET = atmega328p
lgt8f328p: CFLAGS += $(COMMON_OPTIONS)
#lgt8f328p: CFLAGS += $(COMMON_OPTIONS) '-DSOFT_UART'
lgt8f328p: CFLAGS += '-DVIRTUAL_BOOT_PARTITION'
lgt8f328p: AVR_FREQ ?= 16000000L 
lgt8f328p: LDSECTIONS = -Wl,--section-start=.bootv=0x0
lgt8f328p: LDSECTIONS += -Wl,--section-start=.text=0x7400 -Wl,--section-start=.version=0x77fe
lgt8f328p: $(PROGRAM)_lgt8f328p.elf
lgt8f328p: $(PROGRAM)_lgt8f328p.hex
lgt8f328p: $(PROGRAM)_lgt8f328p.lst

lgt8f328p_isp: lgt8f328p
lgt8f328p_isp: TARGET = lgt8f328p
lgt8f328p_isp: MCU_TARGET = atmega323p
lgt8f328p_isp: isp
  1. Watchdog related changes.

  2. GUID

  3. EEPROM related changes

@mcuee
Copy link
Author

mcuee commented Dec 24, 2022

BTW, even though 2KB EEPROM are reserved, the bootloader does not support EEPROM read/write.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c urclock -P COM19 -b 57600 -p lgt8f328p
 -U .\Blink.ino.lgt8fx8p.hex -xbootsize=3072

avrdude: AVR device initialized and ready to accept instructions
avrdude: device signature = 0x1e950f (probably lgt8f328p)
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: reading input file .\Blink.ino.lgt8fx8p.hex for flash
         with 1052 bytes in 1 section within [0, 0x41b]
         using 9 pages and 100 pad bytes
avrdude: preparing flash input for device bootloader
avrdude: writing 1052 bytes flash ...

Writing | ################################################## | 100% 0.37 s

avrdude: 1052 bytes of flash written
avrdude: verifying flash memory against .\Blink.ino.lgt8fx8p.hex

Reading | ################################################## | 100% 0.29 s

avrdude: 1052 bytes of flash verified

avrdude done.  Thank you.

PS C:\work\avr\avrdude_test\avrdude_bin> .\avrdude -c urclock -P COM19 -b 57600 -p lgt8f328p -qqt
avrdude> dump eeprom 0 0x10
avrdude error: bootloader might not have paged EEPROM read; try -xeepromrw if it has
avrdude error: bootloader might not have EEPROM access; try -xeepromrw if it has
avrdude error: unable to read eeprom page at addr 0x0000
avrdude error: (dump) error reading eeprom address 0x00000 of part LGT8F328P
               read operation not supported on memory type eeprom
avrdude> dump flash 0 0x10
0000  0c 94 66 00 0c 94 78 00  0c 94 78 00 0c 94 78 00  | .f. .x. .x. .x.|

avrdude> dump flash 0x7400 0x10
7400  11 24 8f ef 98 e0 9e bf  8d bf 94 b7 14 be 89 2f  |.$............./|

avrdude> dump flash 0x73c0 0x40
73c0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
73d0  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff 42 6c  |..............Bl|
73e0  69 6e 6b 2e 69 6e 6f 2e  6c 67 74 38 66 78 38 70  |ink.ino.lgt8fx8p|
73f0  2e 68 65 78 00 e6 07 06  04 14 38 1c 04 c2 6f 17  |.hex......8...o.|

avrdude> quit

@L10N37
Copy link

L10N37 commented Jan 9, 2023

https://github.com/L10N37/tehUberChip_Another_PSX_Modchip/tree/main/UberNee/FlashingGuide

Try my flashing guide here for this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants