MCUdude / MegaCore

Arduino hardware package for ATmega64, ATmega128, ATmega165, ATmega169, ATmega325, ATmega329, ATmega640, ATmega645, ATmega649, ATmega1280, ATmega1281, ATmega2560, ATmega2561, ATmega3250, ATmega3290, ATmega6450, ATmega6490, AT90CAN32, AT90CAN64 and AT90CAN128
Other
374 stars 115 forks source link

stk500v2 bootloader potential issues #201

Closed mcuee closed 7 months ago

mcuee commented 1 year ago

Reference:

Other than the EEPROM read issue fixed in this repo, there are also other issues reported in Arduino. https://github.com/arduino/ArduinoCore-avr/issues?q=is%3Aissue+is%3Aopen+stk500v2

And there are other isues reported here. https://github.com/msproul/Arduino-stk500v2-bootloader/issues

mcuee commented 1 year ago

@MCUdude

I have not checked the details of the other issues reported here. https://github.com/msproul/Arduino-stk500v2-bootloader/issues

mcuee commented 1 year ago

The following mod will still run (LED is blinking), SendSTR_P(check) works as well. https://github.com/arduino/Arduino-stk500v2-bootloader/blob/master/test/bigprogram/bigprogram.ino

But pgm_read_byte does not wotk due to the following issue.

const char check[] PROGMEM = "A nice string!\n";

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
}

void SendSTR_P(const char *pFlashSTR) {
  uint8_t i;  
  for (i = 0; pgm_read_byte(&pFlashSTR[i]); i++)
    Serial.print(pgm_read_byte(&pFlashSTR[i]));
  ;
}

void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // set the LED off
  delay(1000);              // wait for a second
  digitalWrite(LED_BUILTIN, HIGH);    // set the LED on
  delay(1000);              // wait for a second
  if (millis()<1000) {
    SendSTR_P(aa);
    SendSTR_P(bb);
//    SendSTR_P(cc);
//    SendSTR_P(dd);
//    SendSTR_P(ee);
//    SendSTR_P(ff);
//    SendSTR_P(gg);
 //   SendSTR_P(hh);
 //   SendSTR_P(ii);
  }
  SendSTR_P(check);
}

Sketch uses 66782 bytes (26%) of program storage space. Maximum is 253952 bytes.
Global variables use 184 bytes (2%) of dynamic memory, leaving 8008 bytes for local variables. Maximum is 8192 bytes.
mcuee commented 1 year ago

This mod will make the LED blinking no longer works, even though SendSTR_P(check) still works.

const char check[] PROGMEM = "A nice string!\n";

void setup() {                
  // initialize the digital pin as an output.
  // Pin 13 has an LED connected on most Arduino boards:
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(115200);
}

void SendSTR_P(const char *pFlashSTR) {
  uint8_t i;  
  for (i = 0; pgm_read_byte(&pFlashSTR[i]); i++)
    Serial.print(pgm_read_byte(&pFlashSTR[i]));
  ;
}

void loop() {
  digitalWrite(LED_BUILTIN, LOW);   // set the LED off
  delay(1000);              // wait for a second
  digitalWrite(LED_BUILTIN, HIGH);    // set the LED on
  delay(1000);              // wait for a second
  if (millis()<1000) {
    SendSTR_P(aa);
    SendSTR_P(bb);
    SendSTR_P(cc);
//    SendSTR_P(dd);
//    SendSTR_P(ee);
//    SendSTR_P(ff);
//    SendSTR_P(gg);
 //   SendSTR_P(hh);
 //   SendSTR_P(ii);
  }
  SendSTR_P(check);
}

Sketch uses 98542 bytes (38%) of program storage space. Maximum is 253952 bytes.
Global variables use 184 bytes (2%) of dynamic memory, leaving 8008 bytes for local variables. Maximum is 8192 bytes.
MCUdude commented 7 months ago

I decided to abandon the stk500v2 bootloader and instead go all in with Urboot.