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

Change of EEPROM address for update check #19

Open
aviatorhh opened this issue Sep 26, 2022 · 2 comments
Open

Change of EEPROM address for update check #19

aviatorhh opened this issue Sep 26, 2022 · 2 comments

Comments

@aviatorhh
Copy link

aviatorhh commented Sep 26, 2022

I have changed the CS pin in asmfunc.S to get it running on the Ethernet Shield 2 where the CS pin for the SD access is 4 (PG5). I am happy about your work and the update process is functioning.
The EEPROM address seems to be hardcoded in stk500boot.c:1147.

    if(boot_state == 2){
        if(eeprom_read_byte(0x1FF) == 0xF0){
           pf_mount(&Fatfs);	/* Initialize file system */
           if(pf_open("firmware.bin") == FR_OK){
               DWORD fa;	/* Flash address */
               WORD br;	/* Bytes read */
               uint8_t i = 0;
               sendchar(0x0d);
               sendchar(0x0a);
               for (fa = 0; fa < 0x3E000; fa += SPM_PAGESIZE) {	/* Update all application pages */
                   PROGLED_PORT	^=	(1<<PROGLED_PIN);	// turn LED ON
                   delay_ms(50);
                   flash_erase(fa);					/* Erase a page */
                   memset(Buff, 0xFF, SPM_PAGESIZE);	/* Clear buffer */
                   pf_read(Buff, SPM_PAGESIZE, &br);	/* Load a page data */
                   if(br) flash_write(fa, Buff);		/* Write it if the data is available */
                }
               sendchar(0x0d);
               sendchar(0x0a);
               check = 0;
               eeprom_write_byte (0x1FF, 0xFF);

Suggest to use a #define for better control. Or is the EEPROM erased anyway?

@Mesger1
Copy link
Collaborator

Mesger1 commented Sep 26, 2022

stk500boot.c needs to be compiled and loaded as bootloader into your atmega2560. This way you can adjust to your liking. There is a short discription on how to compile.

@aviatorhh
Copy link
Author

I did already (see CS pin change), but I just wanted to point out the (easy) change of the EEPROM address as there sometimes is data in the EE.
Thank you

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

No branches or pull requests

2 participants