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

added optional copy_flash_pages function to load application from internal flash #269

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JAndrassy
Copy link

@JAndrassy JAndrassy commented Feb 17, 2019

the function is added to Optiboot only with build option COPY_FLASH_PAGES_FNC=1

Function copy_flash_pages uses do_spm() function to copy flash pages.
It is intended to be called by the application over the 'vector table' in pre_main().
It uses 32bit addresses for use on devices with more then 64 kB flash memory.
Additionally parameter reset_mcu activates an (almost) immediate watchdog reset of the MCU after pages are copied.

It was created to copy a new version of the application stored in the upper half of the flash memory to the beginning of the flash and then reset the MCU to run the new version.
It is used by ArduinoOTA library in InternalStorageAVR over utility/optiboot.h.

To fit into 1 kB, COPY_FLASH_PAGES_FNC excludes the version information section otherwise added to BIGBOOT builds.

and issue #265 with optiboot.h in examples/test_dospm is fixed too

@JAndrassy
Copy link
Author

JAndrassy commented May 24, 2019

MCUdude included copy_flash_pages() function into BIG_BOOT build of Optiboot in MegaCore

@rabbithat
Copy link

MCUdude included copy_flash_pages() function into BIG_BOOT build of Optiboot in MegaCore

Not sure where to ask this, but would you please add the copy_flash_pages() function to an Optiboot build for MightyCore as well?

@JAndrassy
Copy link
Author

MCUdude included copy_flash_pages() function into BIG_BOOT build of Optiboot in MegaCore

Not sure where to ask this, but would you please add the copy_flash_pages() function to an Optiboot build for MightyCore as well?

it is there. not in built binaries, but in source code of the Optiboot

@WestfW
Copy link
Member

WestfW commented May 30, 2020

Hmm. A bunch of chips with less than 128k of flash still define EIND, apparently because they belong to the same "family" as larger chips. This includes the ATmega640 and ATmega1280, but also some surprises like ATmega32u4...

Ditto for RAMPZ and 64k.

I guess it doesn't hurt much to set EIND/RAMPZ even when it's not necessary, but...

@JAndrassy
Copy link
Author

JAndrassy commented May 30, 2020

Hmm. A bunch of chips with less than 128k of flash still define EIND, apparently because they belong to the same "family" as larger chips. This includes the ATmega640 and ATmega1280, but also some surprises like ATmega32u4...

Ditto for RAMPZ and 64k.

I guess it doesn't hurt much to set EIND/RAMPZ even when it's not necessary, but...

As you can see I added EIND use the same way RAMPZ was already used.
We could test the size with FLASHEND additionally.

EDIT: there is no hurry with writiing to flash so some useless RAMZ or EIND instructions don't make a difference

@JAndrassy
Copy link
Author

I resolved the conflicts. The PR is up to date again.

The ArduinoOTA library is popular and many people use Arduino Mega with Optiboot 8 with 'copy_flash_pages' function to do OTA or OTEthernet. They usually use the Optiboot build from my_boards

@rabbithat
Copy link

I resolved the conflicts. The PR is up to date again.

The ArduinoOTA library is popular and many people use Arduino Mega with Optiboot 8 with 'copy_flash_pages' function to do OTA or OTEthernet. They usually use the Optiboot build from my_boards

Great!

@JAndrassy
Copy link
Author

MightyCore and MegaCore have now BIG_BOOT Optiboot binaries with the copy_flash_pages function included.
Thank you MCUdude

@rabbithat
Copy link

MightyCore and MegaCore have now BIG_BOOT Optiboot binaries with the copy_flash_pages function included.
Thank you MCUdude

Are there any simple examples showing how to use it?

@JAndrassy
Copy link
Author

MightyCore and MegaCore have now BIG_BOOT Optiboot binaries with the copy_flash_pages function included.
Thank you MCUdude

Are there any simple examples showing how to use it?

the purpose is to apply firmware update stored in flash with the do_spm function of Optiboot
https://github.com/jandrassy/ArduinoOTA/blob/master/src/InternalStorageAVR.cpp

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 this pull request may close these issues.

3 participants