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

bootloader not erasing all usable flash on atmega2560 #7

Open
ellensp opened this issue Apr 19, 2020 · 0 comments · May be fixed by arduino/Arduino-stk500v2-bootloader#2
Open

bootloader not erasing all usable flash on atmega2560 #7

ellensp opened this issue Apr 19, 2020 · 0 comments · May be fixed by arduino/Arduino-stk500v2-bootloader#2

Comments

@ellensp
Copy link

ellensp commented Apr 19, 2020

On a atmega2560 the usable flash is meant to be 256k-8k bootloader. Ie 0-0x3E000 (253952 bytes.) but in the code is

#if FLASHEND > 0x0F000
	#define BOOTSIZE 8192
#else
	#define BOOTSIZE 2048
#endif

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

FLASHEND is 0x3FFFF on mega2560's so the the BOOTSIZE is set to 8192, but the APP_END is set to (0x3FFFF - (2*0x2000)) + 1 = 0x3C000

The code then uses "if (eraseAddress < APP_END )" so uploading over serial will only erase bytes from 0x00000 to 0x3C000. So 0x3C000--0x3E000 is not erased and can't be reused till a full erase is done.

This has been causing headaches for years.

Ancyker added a commit to Ancyker/Arduino-stk500v2-bootloader that referenced this issue Dec 1, 2022
Fixes msproul#7 and makes code compatible with avr-gcc.

Hex file compiled with avr-gcc 11.2.0 on FreeBSD.
Ancyker added a commit to Ancyker/Arduino-stk500v2-bootloader that referenced this issue Dec 1, 2022
Fixes msproul#7 and makes code compatible with avr-gcc.

Hex file compiled with avr-gcc 11.2.0 on FreeBSD.
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

Successfully merging a pull request may close this issue.

1 participant