-
Notifications
You must be signed in to change notification settings - Fork 13
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
Support LGT8F328P #10
Comments
The vendor seems to point to their partner for development board. Schematics: |
BTW, I can see that picoboot is running on my Nano LGT8F328P clone (PB5+ LED glowing). Still I can not use But with The stock optiboot bootloader FW lights up the LED properly (short pulse LED). |
I am not convinced this is true! The LGT8F328P does not have eeprom and has different execution times for opcodes; so must use USART (not SWIO). Last time I checked the lgt8f328p was not supported by avr-gcc/avr-libc. So, out of necessity, need to choose from the atmega328p bootloaders. Choose a fixed baud rate urboot bootloader without eeprom support. If you have double F_CPU then the baud rate will be double. So if you use a 16 MHz/115200 baud urboot bootloader it will run at twice the baud rate (230400 baud) when F_CPU is 32 MHz instead of 16 MHz. Vice versa, if you do not know the F_CPU of your board after reset, just try different baud rates. You will need to take care of the fuse settings etc just as you would with a ATmega328P. Autobaud bootloaders require Lines 2323 to 2325 in 1c26c69
and choose a sync byte accordingly. Rumour has it the loop takes 3 cycles for the lgt8f328p.
Ensure avrdude.conf holds
with the autobaud urboot bootloader. This should work. You need to force If your board does not have an RTS/DTR reset mechanism, you need to press reset manually, release reset, then start avrdude (possibly with -xdelay=-110). If none of the above works
|
From what I read, with regard to the KB bootloader, you are right that only 1KB is for bootloader and the other 2KB is for EEPROM (using 2KB Flash to emulate 1KB EEPROM). From what I read, this is actually not the default, the default is 32KB Flash and no EEPROM emulation. Could you provide autobaud bootloader hex file with or wthout the EEPROM emulation? LED pin is PB5+. CPU frequency by default is 32MHz RC oscillator upon power up. The programmer LGTISP does not support EEPROM or Fuse settings. From my quick glance of the datasheet for the LGT8F328P, there is no fuse settings anyway. Reset vector is at 0x0000 (two bytes). WDT reset vector is at 0x000C |
Seeing as you have the part, the datasheet, ability to read Mandarin, and ability to compile your own (make F_CPU=32000000L ...), I am not sure how much I can help you. You are in a far better position than I am. If you want to move the bootloader to a different location than top flash that is a bit tricky, but can probably be done.
You could try to manually compile by dropping the start addresses by 2k, ie, use |
Thanks, I have build urboot with F_CPU=32000000L but it does not work. So I was thinking that the location of the bootloader is the issue. It will still be at the top of the flash, just that we need to pretend the bootloader is 3KB size. Or maybe I will try the 1KB bootloader option which is supposed to be the default upon power up (no EEPROM emulation). It seems to me the bootloader source code published does not match the hex file from the vendor. I will check if the fork here has newer source code. Let me try again later with your suggestion. |
autobaud should not need F_CPU. The .hex files should be the same irrespective of F_CPU. |
IMHO this ain't worth it. It's a poorly documented chip from a sketchbag vendor likely based on stolen silicon IP. And don't you dare get me started on that holtek serial chip it usually comes bundled with. That thing so bad, you don't want to throw it away in you own garbage cans, because if raccoons get into your trash and see the HT42B534s in your trash, and then they'll know your incompetent, and next time they see you with food, they'll attack, confident that if you bought that bridge from holtek, you're probably too clueless to fight a racoon. (speaking as someone with 100 of them kicking around. During the periods when they work, they really scream, they too often just choke. The windows CDC driver crashes when you do anything it doesn't like, it's only able to make a small limited selection of baud rates, and it's modem control input line start off all "off" until one changes, at which point all of them switch from active low to active high, and remain that way until next reset). I haven't thrown them out yet. I think I'm gonna put them in with my "$XX for a priority mail small flat rate box packed to the gills with bad PCB." so the local wildlife and can hobos doesn't know holtek ripped me off with bunk serial adapters. I've got like a whole xerox box worth of bad boards now. And the results of my last order with the board house. ah.. let's just say that order isn't preventing growth of the box of bad boards. |
I have a few boards with the LGT8F328P and they actually use CH340. But I agree this is not a priority. The factory optiboot bootloader is working. |
Reference in Optiboot as well. You can see that I can build the optiboot hex file but the hex files generated do not work, even though factory hex file works. |
I will give up for now. Hopefully someone else who is more familiar with the chip can chime in and help out. |
| even though factory hex file works The key will be to figure out how the manufacturer changed optiboot to make it work for their factory hex file... |
Yes, it seems to me the optiboot source codes provided might not match the factory hex file. Reverse engineering is needed in this case. Or maybe the source codes match the hex file but I need to use old version of compilers. Probably the lst file is the key. I have not really looked into it yet. For one thing it does match here why the bootloader starts at 0x7400.
|
These lines indicate initialisation of registers that the ATmega328P does not have: |
Finally I got it working by using WInAVR toolchain. I can reproduce exactly the same hex file and it works. It also works with Atmel toolchain based on avr-gcc 5.4.0, but not the Atmel toolchain based on avr-gcc 7.3.0. As for the header file, it is provided by the vendor here. |
From here. Here are some 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.
|
Too many undocumented changes for this to be currently tackled. As a fist step, the part ought to be supported by avr-libc and avr-gcc. For example, avr-gcc needs to take |
Totally agree with you here. I am happy to be able to build the factory bootloader hex file and that is about it. I may also try to remove the 2KB EEPROM support to see if it works (move the bootloader from 0x7400 to 0x7c00). EEPROM read/write is not working anyway.
|
I think it is probably not worth the efforts in the end. So I will close this for now. |
Ref: as of now urboot does not work for the LGT8F328P. It will be good to have the support.
-c urclock
avrdudes/avrdude#1193 (comment)More info about typical LGT8F328P board. It seems to me the most common one is the Nano style, followed by the Pro Mini style and the Uno style.
https://github.com/dbuezas/lgt8fx
So far only the vendor provided Optiboot bootloader firmware works on my Nano LGT8F328P board.
https://github.com/LGTMCU/Larduino_HSP/tree/master/hardware/LGT/avr/bootloaders/lgt8fx8p
https://github.com/dbuezas/lgt8fx/tree/master/lgt8f/bootloaders/lgt8fx8p (same as above)
For people who want to try different bootloaders, they can use Nano or Uno to burn the bootloaders with the following projects.
https://github.com/LGTMCU/LarduinoISP (from the vendor)
https://github.com/brother-yan/LGTISP
The text was updated successfully, but these errors were encountered: