arduino / arduino/ArduinoCore-avr

STK500V2 hangs with active Serial 0 on boot. Patch Provided.

Open
#172 0 comments 0 reactions 1 assignee Claimed by @cmaglie View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

If you have an active serial device (eg gps) hooked up to Serial 0 during boot, it hangs the boot loader as it thinks it is getting a new sketch but it never comes. Other boot loaders have the fix already, but not this one, making Serial 0 unusable for a permanently connected serial device.

This is a simple fix that checks if the incoming serial stream is a new sketch or not, and if it is not, then it continues the boot process and loads the existing sketch.

regards,
Hayden.

```
--- stk500boot.c Sun Mar 30 12:51:46 2014
+++ stk500boot.c Wed May 28 14:11:19 2014
@@ -272,6 +272,7 @@
#define BOOTSIZE 2048
#endif

+#define MAX_ERR_COUNT 10
#define APP_END (FLASHEND -(2*BOOTSIZE) + 1)

/*
@@ -541,6 +542,7 @@
unsigned char msgBuffer[285];
unsigned char c, *p;
unsigned char isLeave = 0;
+ unsigned char errCnt = 0;

unsigned long boot_timeout;
unsigned long boot_timer;
@@ -712,6 +714,18 @@
{
msgParseState = ST_GET_SEQ_NUM;
checksum = MESSAGE_START^0;
+ }
+ else
+ {
+ errCnt++;
+ if(errCnt > MAX_ERR_COUNT)
+ {
+ msgParseState = 99; //* we dont want it do anything
+ isLeave = 1;
+ errCnt = 0;
+ boot_state = 2; // boot_state=2 bootloader timeout, jump to main 0x00000
+ goto ENTER_APP_CODE;
+ }
}
break;

@@ -1149,7 +1163,7 @@
delay_ms(100);
#endif

-
+ENTER_APP_CODE:
#ifndef REMOVE_BOOTLOADER_LED
PROGLED_DDR &= ~(1<

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.