Open bmentink opened 7 months ago
Update: I wonder if I got some bad boards. I have 5 boards, 3 program ok, 2 won't.
You could try to use one of the working ones for attempting to burn the bootloader on one of the defective boards.
You could try to use one of the working ones for attempting to burn the bootloader on one of the defective boards.
Can you show me how to connect the SPI pins? It is not clear from the board which ones connect to MOSI and MISO, CLK etc, seems to have a pin missing. Cheers (can only see SWC and SWD)
Thanks, will give it a try.
I loaded up a good LGT board with the LGTISP.ino sketch ok. However, when I go to program the bootloader to another LGT board connected with SWC,SWD etc it gives error.
avrdude error: programmer is out of sync
***failed;
avrdude error: programmer is out of sync
***failed;
I am somewhat confused as the instructions say to use AVR ISP as programmer, even though there is an " LGTSWD markii as ISP" option ??
There is a LarduinoISP sketch amongst the examples. Did you compile and load that one? It also mentions how to wire it up. You need to look at the right column under LGT8FX8P:
The LGTSWD Mark II is this one. Probably not what you have.
You linked the github site, it only shows these files, no examples. Please be specific.
You show me an Arduino as ESP, in your example above, I am using LGT to program LGT. ARe the pin connections the same?
This is the example I mean. It comes with this core.
Right, you did not link that initially, now I understand. BUt the question remains, If I use LGT as ESP are the pin connections the same?
LGT as ISP has these connections. If that does not work, I will dig up my LGT's and hook them up. Has been a few years since I had to bootload one.
I don't have those examples .... maybe I have the wrong LGT library?
I got the library from here: https://raw.githubusercontent.com/dbuezas/lgt8fx/master/package_lgt8fx_index.json
LGT as ISP has these connections. If that does not work, I will dig up my LGT's and hook them up. Has been a few years since I had to bootload one.
I don't have those names, please give the corresponding D8,D10) etc ..
Well.... you are posting your question in the Github forum of the core I am using, so I assumed you will have the LarduinoISP as well. But apparently not
Here are the pins
I have added the core I am using above, is it incorrect?
That's the one I use.
That's the one I use.
So why no examples?
I honestly have no clue. Here is the LarduinoISP sketch
// 20 July 2020 David Buezas
// - Bundled and added menu utility
// * When uploading to the programmer,
// select in the menu: Tools/Arduino as ISP/SERIAL_RX_BUFFER_SIZE to 250)
// * Before using the ISP to program another board,
// connect (in the ISP board) the reset pin to gnd via a capacitor,
// or (at your own risk) short reset to vcc.
// https://github.com/dbuezas/lgt8fx/
//
// author : brother_yan (https://github.com/brother-yan/LGTISP)
//
// LarduinoISP for LGT8FX8P series
// Project fork from
// - ArduinoISP version 04m3
// Copyright (c) 2008-2011 Randall Bohn
// If you require a license, see
// http://www.opensource.org/licenses/bsd-license.php
//
// This sketch turns the Arduino into a AVRISP
// using the following arduino pins:
//
// pin name: Arduino: LGT8FX8P:
// slave reset: 10: PC6/RESET
// SWD: 12: PE2/SWD
// SWC: 13: PE0/SCK
// Make sure to
// Put an LED (with resistor) on the following pins:
// 9: Heartbeat - shows the programmer is running
// 8: Error - Lights up if something goes wrong (use red if that makes sense)
// 7: Programming - In communication with the slave
//
// 23 July 2011 Randall Bohn
// -Address Arduino issue 509 :: Portability of ArduinoISP
// http://code.google.com/p/arduino/issues/detail?id=509
//
// October 2010 by Randall Bohn
// - Write to EEPROM > 256 bytes
// - Better use of LEDs:
// -- Flash LED_PMODE on each flash commit
// -- Flash LED_PMODE while writing EEPROM (both give visual feedback of writing progress)
// - Light LED_ERR whenever we hit a STK_NOSYNC. Turn it off when back in sync.
// - Use pins_arduino.h (should also work on Arduino Mega)
//
// October 2009 by David A. Mellis
// - Added support for the read signature command
//
// February 2009 by Randall Bohn
// - Added support for writing to EEPROM (what took so long?)
// Windows users should consider WinAVR's avrdude instead of the
// avrdude included with Arduino software.
//
// January 2008 by Randall Bohn
// - Thanks to Amplificar for helping me with the STK500 protocol
// - The AVRISP/STK500 (mk I) protocol is used in the arduino bootloader
// - The SPI functions herein were developed for the AVR910_ARD programmer
// - More information at http://code.google.com/p/mega-isp
// LarduinoISP for LGTF8FX8P Series
#include "swd_lgt8fx8p.h"
#if SERIAL_RX_BUFFER_SIZE < 250 // 64 bytes的RX缓冲不够大
#error : Please change the macro SERIAL_RX_BUFFER_SIZE to 250 (In the menu: Tools/Arduino as ISP/SERIAL_RX_BUFFER_SIZE)
#endif
#define RESET 10
#define LED_HB 9
#define LED_ERR 8
#define LED_PMODE 7
#define PROG_FLICKER true
#define HWVER 3
#define SWMAJ 5
#define SWMIN 1
// STK Definitions
#define STK_OK 0x10
#define STK_FAILED 0x11
#define STK_UNKNOWN 0x12
#define STK_INSYNC 0x14
#define STK_NOSYNC 0x15
#define CRC_EOP 0x20 //ok it is a space...
void pulse(int pin, int times);
void setup()
{
SWD_init();
Serial.begin(115200);
//pinMode(LED_PMODE, OUTPUT);
//pulse(LED_PMODE, 2);
//pinMode(LED_ERR, OUTPUT);
//pulse(LED_ERR, 2);
//pinMode(LED_HB, OUTPUT);
//pulse(LED_HB, 2);
}
uint8_t error=0;
uint8_t pmode=0;
// address for reading and writing, set by 'U' command
int address;
uint8_t buff[256]; // global block storage
#define beget16(addr) (*addr * 256 + *(addr+1) )
typedef struct param {
uint8_t devicecode;
uint8_t revision;
uint8_t progtype;
uint8_t parmode;
uint8_t polling;
uint8_t selftimed;
uint8_t lockbytes;
uint8_t fusebytes;
uint8_t flashpoll;
uint16_t eeprompoll;
uint16_t pagesize;
uint16_t eepromsize;
uint32_t flashsize;
} parameter_t;
parameter_t param;
// this provides a heartbeat on pin 9, so you can tell the software is running.
uint8_t hbval=128;
uint8_t hbdelta=8;
void heartbeat()
{
if (hbval > 192) hbdelta = -hbdelta;
if (hbval < 32) hbdelta = -hbdelta;
hbval += hbdelta;
analogWrite(LED_HB, hbval);
delay(40);
}
void loop(void)
{
// is pmode active?
/*
if (pmode) digitalWrite(LED_PMODE, HIGH);
else digitalWrite(LED_PMODE, LOW);
// is taddress an error?
if (error) digitalWrite(LED_ERR, HIGH);
else digitalWrite(LED_ERR, LOW);
*/
// light the heartbeat LED
//heartbeat();
if (Serial.available())
avrisp();
}
uint8_t getch() {
while(!Serial.available());
return Serial.read();
}
void fill(int n)
{
for (int x = 0; x < n; x++) {
buff[x] = getch();
}
}
#define PTIME 30
void pulse(int pin, int times)
{
do {
digitalWrite(pin, HIGH);
delay(PTIME);
digitalWrite(pin, LOW);
delay(PTIME);
}
while (times--);
}
void prog_lamp(int state)
{
if (PROG_FLICKER)
digitalWrite(LED_PMODE, state);
}
void empty_reply()
{
if (CRC_EOP == getch()) {
Serial.print((char)STK_INSYNC);
Serial.print((char)STK_OK);
}
else {
error++;
Serial.print((char)STK_NOSYNC);
}
}
void breply(uint8_t b)
{
if (CRC_EOP == getch()) {
Serial.print((char)STK_INSYNC);
Serial.print((char)b);
Serial.print((char)STK_OK);
}
else {
error++;
Serial.print((char)STK_NOSYNC);
}
}
void get_version(uint8_t c)
{
switch(c) {
case 0x80:
breply(HWVER);
break;
case 0x81:
breply(SWMAJ);
break;
case 0x82:
breply(SWMIN);
break;
case 0x93:
breply('S'); // serial programmer
break;
default:
breply(0);
}
}
void set_parameters()
{
// call this after reading paramter packet into buff[]
param.devicecode = buff[0];
param.revision = buff[1];
param.progtype = buff[2];
param.parmode = buff[3];
param.polling = buff[4];
param.selftimed = buff[5];
param.lockbytes = buff[6];
param.fusebytes = buff[7];
param.flashpoll = buff[8];
// ignore buff[9] (= buff[8])
// following are 16 bits (big endian)
param.eeprompoll = beget16(&buff[10]);
param.pagesize = beget16(&buff[12]);
param.eepromsize = beget16(&buff[14]);
// 32 bits flashsize (big endian)
param.flashsize = buff[16] * 0x01000000
+ buff[17] * 0x00010000
+ buff[18] * 0x00000100
+ buff[19];
}
void start_pmode(uint8_t chip_erase)
{
digitalWrite(RESET, HIGH);
pinMode(RESET, OUTPUT);
delay(20);
digitalWrite(RESET, LOW);
SWD_init();
SWD_Idle(10);
pmode = SWD_UnLock(chip_erase);
if (!pmode)
pmode = SWD_UnLock(chip_erase);
}
void end_pmode()
{
SWD_exit();
pmode = 0;
digitalWrite(RESET, HIGH);
pinMode(RESET, INPUT);
}
void universal()
{
fill(4);
if(buff[0] == 0x30 && buff[1] == 0x00) {
switch(buff[2]) {
case 0x00:
breply(0x1e);
break;
case 0x01:
breply(0x95);
break;
case 0x02:
breply(0x0f);
break;
default:
breply(0xff);
break;
}
} else if(buff[0] == 0xf0) {
breply(0x00);
} else {
breply(0xff);
}
}
void write_flash(int length)
{
fill(length);
if (CRC_EOP == getch()) {
Serial.print((char) STK_INSYNC);
Serial.print((char) write_flash_pages(length));
}
else {
error++;
Serial.print((char) STK_NOSYNC);
}
}
uint8_t write_flash_pages(int length)
{
int addr = address / 2;
/*
lgt8fx8p的flash是按4字节编址的,而avr是按2字节编址的,avrdude传过来的是按2字节编址的address
avrisp()函数中也有证实:
case 'U': // set address (word)
*/
SWD_EEE_CSEQ(0x00, addr);
SWD_EEE_CSEQ(0x84, addr);
SWD_EEE_CSEQ(0x86, addr);
for (int i = 0; i < length; i += 4)
{
SWD_EEE_Write(*((uint32_t *)(&buff[i])), addr);
++addr;
}
SWD_EEE_CSEQ(0x82, addr - 1);
SWD_EEE_CSEQ(0x80, addr - 1);
SWD_EEE_CSEQ(0x00, addr - 1);
return STK_OK;
}
#define EECHUNK (32)
uint8_t write_eeprom(int length)
{
// address is a word address, get the byte address
int start = address * 2;
int remaining = length;
if (length > param.eepromsize) {
error++;
return STK_FAILED;
}
while (remaining > EECHUNK) {
write_eeprom_chunk(start, EECHUNK);
start += EECHUNK;
remaining -= EECHUNK;
}
write_eeprom_chunk(start, remaining);
return STK_OK;
}
// write (length) bytes, (start) is a byte address
uint8_t write_eeprom_chunk(int start, int length)
{
// this writes byte-by-byte,
// page writing may be faster (4 bytes at a time)
fill(length);
prog_lamp(LOW);
for (int x = 0; x < length; x++) {
int addr = start+x;
// do e2prom program here
// donothing for lgt8fx8d series
delay(45);
}
prog_lamp(HIGH);
return STK_OK;
}
void program_page()
{
char result = (char) STK_FAILED;
// get length
uint16_t length = getch() << 8;
length += getch();
char memtype = getch();
// flash memory @address, (length) bytes
if (memtype == 'F') {
write_flash(length);
return;
}
if (memtype == 'E') {
result = (char)write_eeprom(length);
if (CRC_EOP == getch()) {
Serial.print((char) STK_INSYNC);
Serial.print(result);
}
else {
error++;
Serial.print((char) STK_NOSYNC);
}
return;
}
Serial.print((char)STK_FAILED);
return;
}
char flash_read_page(int length)
{
int addr = address / 2;
/*
lgt8fx8p的flash是按4字节编址的,而avr是按2字节编址的,avrdude传过来的是按2字节编址的address
avrisp()函数中也有证实:
case 'U': // set address (word)
*/
SWD_EEE_CSEQ(0x00, 0x01);
uint32_t data;
for (int i = 0; i < length; ++i)
{
if (i % 4 == 0)
{
data = SWD_EEE_Read(addr);
++addr;
}
Serial.print((char)((uint8_t *)&data)[i % 4]);
}
SWD_EEE_CSEQ(0x00, 0x01);
return STK_OK;
}
char eeprom_read_page(uint16_t length)
{
// address again we have a word address
uint16_t start = address * 2;
for (int x = 0; x < length; x++) {
uint16_t addr = start + x;
// do ep2rom read here
// but donothing for lgt8fx8d series (by now...)
Serial.print((char) 0xff);
}
return STK_OK;
}
void read_page()
{
char result = (char)STK_FAILED;
uint16_t length = getch() << 8;
length += getch();
char memtype = getch();
if (CRC_EOP != getch()) {
error++;
Serial.print((char) STK_NOSYNC);
return;
}
Serial.print((char) STK_INSYNC);
if (memtype == 'F') result = flash_read_page(length);
if (memtype == 'E') result = eeprom_read_page(length);
Serial.print(result);
return;
}
void read_signature()
{
if (CRC_EOP != getch()) {
error++;
Serial.print((char) STK_NOSYNC);
return;
}
Serial.print((char) STK_INSYNC);
Serial.print((char) 0x1e);
Serial.print((char) 0x95);
Serial.print((char) 0x0a);
Serial.print((char) STK_OK);
}
//////////////////////////////////////////
//////////////////////////////////////////
////////////////////////////////////
////////////////////////////////////
volatile uint8_t chip_erased;
int avrisp()
{
uint8_t data, low, high;
uint8_t ch = getch();
switch (ch) {
case '0': // signon
error = 0;
empty_reply();
break;
case '1':
if (getch() == CRC_EOP) {
Serial.print((char) STK_INSYNC);
Serial.print("AVR ISP");
Serial.print((char) STK_OK);
} else {
error++;
Serial.print((char) STK_NOSYNC);
}
break;
case 'A':
get_version(getch());
break;
case 'B': // optional for lgt8fx8d series
fill(20);
set_parameters();
empty_reply();
break;
case 'E': // extended parameters - ignore for now
fill(5);
empty_reply();
break;
case 'P':
if (pmode) {
pulse(LED_ERR, 3);
} else {
start_pmode(0);
chip_erased = 0;
}
if (pmode)
empty_reply();
else
{
if (CRC_EOP == getch()) {
Serial.print((char)STK_INSYNC);
Serial.print((char)STK_FAILED);
}
else {
error++;
Serial.print((char)STK_NOSYNC);
}
}
break;
case 'U': // set address (word)
address = getch();
address += (getch() << 8);
empty_reply();
break;
case 0x60: //STK_PROG_FLASH
low = getch();
high = getch();
empty_reply();
break;
case 0x61: //STK_PROG_DATA
data = getch();
empty_reply();
break;
case 0x64: //STK_PROG_PAGE
if (!chip_erased)
{
error = 0;
end_pmode();
start_pmode(1);
chip_erased = 1;
}
program_page();
break;
case 0x74: //STK_READ_PAGE 't'
read_page();
break;
case 'V': //0x56
universal();
break;
case 'Q': //0x51
error=0;
end_pmode();
empty_reply();
break;
case 0x75: //STK_READ_SIGN 'u'
read_signature();
break;
// expecting a command, not CRC_EOP
// this is how we can get back in sync
case CRC_EOP:
error++;
Serial.print((char) STK_NOSYNC);
break;
// anything else we will return STK_UNKNOWN
default:
error++;
if (CRC_EOP == getch())
Serial.print((char)STK_UNKNOWN);
else
Serial.print((char)STK_NOSYNC);
}
}
THanks, these are the examples I have:
So just put the above code on the LGT board that has to act as ISP, right? In that case, what is the LGTISP.ino I put on from github do then?
LGTISP.ino may be a newer or older version. I have not used it myself as I usually grab my dedicated SWDICE programmer.
The sketch I just uploaded here I have used a while back. But I just found my box with LGT's so let me try if it still works.
Thanks will wait. Meantime I tried connecting the programming pins at the end of the board to the target board pins, but that did not work either. So Still unsure of pin connections.
Just tested and works fine
First burn the LarduinoISP.ino to your working Nano
Then hook it up like
// pin name: Programmer NANO Target LGT8FX8P:
// reset: 10: PC6/RESET
// SWD: 12: PE2/SWD
// SWC: 13: PE0/SCK
Keep AVRISP as programmer and press "burn Bootloader"
I burned it to a "promini style" LGT board, as my second Nano has no pinheaders yet. But you will select the board you have to get the bootloader that goes with your board.
First burn the LarduinoISP.ino to your working Nano
I keep teling you, I am not using an Arduino Nano as ISP, I am using LGT Nano, do I still use pins 10,12,13 on the ISP side ?
I also used LGT Nano
Well I get this using those pinouts:
avrdude error: programmer is not responding
avrdude warning: attempt 1 of 10: not in sync: resp=0x00
avrdude warning: ignoring mismatch in unused bits of lock
(device 0xff != input 0x3f); to prevent this warning set
unused bits to 1 when writing (double check with datasheet)
avrdude error: programmer is not responding
avrdude warning: attempt 1 of 10: not in sync: resp=0x00
avrdude warning: ignoring mismatch in unused bits of lock
(device 0xff != input 0x3f); to prevent this warning set
unused bits to 1 when writing (double check with datasheet)
I have to go out, will pick this up later. Thanks for the help.
This is how I wired it up
I have exactly that!
I'm back now if you have any more suggestions. I am using LarduinoISP.ino, but LGTISP.ino does not work either.
Have you seen the tutorial in this repo? https://github.com/dbuezas/lgt8fx/blob/master/lgt8f/libraries/LarduinoISP/readme.md
Well I get this using those pinouts:
avrdude error: programmer is not responding avrdude warning: attempt 1 of 10: not in sync: resp=0x00 avrdude warning: ignoring mismatch in unused bits of lock (device 0xff != input 0x3f); to prevent this warning set unused bits to 1 when writing (double check with datasheet) avrdude error: programmer is not responding avrdude warning: attempt 1 of 10: not in sync: resp=0x00 avrdude warning: ignoring mismatch in unused bits of lock (device 0xff != input 0x3f); to prevent this warning set unused bits to 1 when writing (double check with datasheet)
The only way how I can get your error is when I do not upload LarduinoISP to the LGT-Nano.
When I upload LarduinoISP to it and do not connect a target I get this error instead
Arduino: 1.8.19 (Windows 10), Board: "LGT8F328, 250 (to burn ISP), Internal 32MHz, 1, 328P-SSOP20 (e.g. green pseudo pro mini), 57600"
E:\Arduino\arduino-1.8.19\portable\packages\MiniCore\tools\avrdude\7.2-arduino.1/bin/avrdude -CE:\Arduino\arduino-1.8.19\portable\packages\MiniCore\tools\avrdude\7.2-arduino.1/etc/avrdude.conf -v -patmega328p -cstk500v1 -PCOM20 -e -Ulock:w:0x3f:m -Uefuse:w:0xff:m -Uhfuse:w:0xff:m -Ulfuse:w:0xff:m
<<<< snip - non informative part >>>>
avrdude stk500_program_enable() error: unable to enter programming mode
avrdude main() error: initialization failed, rc=-1
- double check the connections and try again
- use -B to set lower the bit clock frequency, e.g. -B 125kHz
- use -F to override this check
avrdude done. Thank you.
When I connect a target everything works 100%, even without the capacitor or disabled reset pin.
The only other difference I see is that I work on Arduino IDE V1.8.19 as I cannot upgrade to IDE V2 (it has no portable IDE anymore)
Ok, trying again. I uploaded LarduinoISP to a working LGT sucessfully. Then without connecting target, I try to burn bootloader, I get this error:
avrdude error: unable to enter programming mode
avrdude error: initialization failed, rc=-1
- double check the connections and try again
- use -B to set lower the bit clock frequency, e.g. -B 125kHz
- use -F to override this check
Failed chip erase: uploading error: exit status 1
Looks same as yours, except I am on MacOS not Windoze ...
And what happens if you now connect one of your known working and one of your known not working targets? The communication between the programmer and your Mac seems to be working.
I get the error above. Maybe it's just a dud board?
avrdude error: programmer is not responding
avrdude warning: attempt 1 of 10: not in sync: resp=0x00
avrdude warning: ignoring mismatch in unused bits of lock
(device 0xff != input 0x3f); to prevent this warning set
unused bits to 1 when writing (double check with datasheet)
avrdude error: programmer is not responding
avrdude warning: attempt 1 of 10: not in sync: resp=0x00
avrdude warning: ignoring mismatch in unused bits of lock
(device 0xff != input 0x3f); to prevent this warning set
unused bits to 1 when writing (double check with datasheet)
Edit, that's the non-working board, I will try a good board next.
Nope, new working board does the same thing.
I start to suspect faulty breadboard wires or some HW problem.
In my opinion the the communication speed is the source of the issue. The LarduinoISP.ino in line 88 set the speed to 115200, https://github.com/dbuezas/lgt8fx/blob/307d152b44f4b9f27a07c33ee7e40befbcc6bf80/lgt8f/libraries/LarduinoISP/examples/LarduinoISP/LarduinoISP.ino#L88 but the programmers.txt set the speed to 19200 baud. https://github.com/dbuezas/lgt8fx/blob/307d152b44f4b9f27a07c33ee7e40befbcc6bf80/lgt8f/programmers.txt#L13
With the old IDE (v1.8.19) the ISP works fine as is. It has happened to me that it failed to work, but the reason ended up being that the boards were fried.
I have to get involved in this topic now. I have exactly the same problem. I have an LGT Nano as target and also an LGT Nano as ISP programmer. I have installed the Larduino and also read the example, which I have also installed on my LGT ISP as prescribed and then connected the ISP to the target as specified. GND -> GND 5v -> VCC D10 -> RESET D12 -> SWD D13 -> SWC I have tried different variants and also set various build rates in code line 88. All without success. It always says Sync does not match or Target does not respond. It is devinitiv a sketch without bootloader on the target, now I have to load a bootloader again but it doesn't like it. Thats my Error:
avrdude: stk500_program_enable(): failed to enter programming mode
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.
Fehler beim Brennen des Bootloaders.
I have just tried again with a definitely working LGT EVB board, and come to the same result. I can't install the bootloader on this one either, with the same error message mentioned here.
OK guys I have found the error, even if I can't really explain it to myself. Maybe it concerns you too. I have noticed that in all explanations here always a "GREEN" LGT8 Nano with Micro USB is used. I tried all the time with a "PURPLE" LGT Nano whit USB-C and always failed. But I had one of the green ones and used it and did everything exactly as indicated... installed the LarduinoISP.ino and connected it to a MiniEVB as I did before with the purple LGT. But this time it worked immediately in 2-3 seconds. Then I connected the green LGT Nano to the purple LGT Nano and within 2-3 seconds the bootloader was on. And I was able to upload my sketch to the purple LGT via USB as normal. So in my case it was definitely the purple LGT Nano. In the meantime, I also tried using an Arduino Nano V3 as an ISP, which also only produced sync errors, but others. I think there should be a strong differentiation between purple and green in the instructions and I think these should also be strictly separated and named individually in further descriptions. Perhaps it is also due to the more precise setting, one difference between the two is that the purple LGT has an external 16MHz crystal while the green one works with the internal 32MHz crystal. I think this is where you should start. Please try it out for yourself.
The external crystal won't be used unless you specifically configure the board to use it. I made myself a connector with pogo pins and the reset cap and it has been a lot more reliable ever since. This leds me to believe that the ISP is particularly sensitive to bad connection issues (and also prone to them because of the temptation of "quickly" use jumper cables held with the hand)
Hi @Devilscave , I am keen to try myself. I understood that the combination of the purple lgt based board and the green does not work. But I am not sure which board you used as programmer and which as target. Can you tell me that detail?
Another point: you said you tried an Arduino Nano V3. This means a conventional one based on an ATmega328P? This is not a surprise that this does not work.
Which purple one, the LQFP48 (larger) or LQFP32?
Hi @Devilscave , I am keen to try myself. I understood that the combination of the purple lgt based board and the green does not work. But I am not sure which board you used as programmer and which as target. Can you tell me that detail?
Another point: you said you tried an Arduino Nano V3. This means a conventional one based on an ATmega328P? This is not a surprise that this does not work.
Didn't know that Atmega328 do not work. What about an ESP-12 Uno board?
Hi @lalo-uy , to be more precise: it possible to use a classic Arduino Nano but not if you follow the instructions here:
https://github.com/dbuezas/lgt8fx/tree/master/lgt8f/libraries/LarduinoISP
In oder to set the Serial RX Buffer to 250 Bytes you can't use the convenient way:
Since you have to choose the board on which you want to upload the LArduinoISP sketch, you won't see this setting. Therefore, you have to make this setting manually in HardwareSerial.h which you hould find here:
...\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino
If you should choose this way it works (I have tried beacuse I was curious), but I would recommend to spend little money for a second LGT8F328P based board instead..
With the ESP-12 Uno board it might work directly if the buffer is >= 250 bytes. Just check if the LArduinoISP sketch compiles. Done in a few seconds!
@Wollewald
Hallo@Devilscave, ich möchte es unbedingt selbst ausprobieren. Mir ist klar, dass die Kombination aus der violetten, LGT-basierten Platine und der grünen nicht funktioniert. Aber ich bin mir nicht sicher, welche Platine Sie als Programmierer und welche als Ziel verwendet haben. Können Sie mir das genauer erklären?
In my text it says exactly when I used which one. I only tried a purple LGT in my first post and that didn't work. In my second post where it worked, I used the green programmer as described in the text.
Noch ein Punkt: Du hast gesagt, du hättest es mit einem Arduino Nano V3 versucht. Meinst du damit einen konventionellen auf Basis eines ATmega328P? Es ist keine Überraschung, dass dieser nicht funktioniert.
I figured if it works with a UNO, why not. But I already encountered the error when programming that I can't make the bit settings at all, funnily enough the Nano eats the sketch anyway.
@dbuezas
Welches violette Modell, LQFP48 (größer) oder LQFP32?
LQFP32
Hi @Devilscave, I can reproduce the issue with the purple LQFP32. It does not work as a programmer, at least when following the standard procedure. I tried burning the bootloader on a green LQFP32 as well as on a purple LQFP32 using the purple LQFP32 as programmer. I also tried a purple LQFP48 as a programmer and that worked perfectly. So, it is a specific problem of the purple LQFP32.
I don't know what the problem is and how to fix it. My gut feel says it is related to the CH9340C USB-to-TTL Chip on the purple LQFP32 board and how it is wired. But I have no proof for that.
That's very odd. isp.zip I don't have a purple LQFP32 to test it my self, would you test this isp code with it? The only difference is that the pins change:
Since the pcb layout is different, I wonder if some pin is either not connected or has some unwanted pulldown or capacitive coupling with the xtal on PB6 and 7 (same port as the original isp code uses).
(I use the ISP like this so that the pins between programmer and programmed are aligned)
Regarding the USB to TTL chip, what is your hunch based on? the serial part should only affect pc <-> isp, and that obviously works if serial burning works.
Also, it may be worth trying setting the clock differently, e.g using the external one.
I have to try it again now, because yesterday I must have shot something on one of the purple LGTs, it works to load sketches on it, but runs much too fast and the sketches only make measurements, it almost seems to me as if the bootloader is wrong.
Hi @dbuezas , I have tried your sketch and get the same error like before:
In order to confirm that I have not wired something wrongly, I have done the same with green LQFP32 and it worked.
Then I found something interesting. I changed back to the purple LQFP32 and uploaded the standard LArduinoISP sketch. Then I connected the purple LQFP32 to a USB-to-TTL Adapter instead of the PC directly: VCC -> VCC GND -> GND RX -> TX TX -> RX
It looked like this:
All the rest is set up as one would do using the normal procedure. And it works! I was able to burn the the bootlader and to upload sketches using the purple LQFP32 as a programmer. I really think the problem is the CH9340C Chip.
There are also purple LQFP32 boards available which other USB-to-TTL Chips than the CH9340C. I have order some from China, so it will take a while until I can test. If anyone reads this and has such a board, it would be great to know if these can be used as programmer.
@Devilscave, can you check which chip you have on your board?
Hi, I am trying to program LGTBF328P - MiniEVB nano board. I get the following error:
Any idea's ?