Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

Can we use a higher address in flash for bootload memory ins

 
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR
View previous topic :: View next topic  
Author Message
sentinel

Bascom Member



Joined: 02 Feb 2009
Posts: 141
Location: Tasmania

australia.gif
PostPosted: Wed Dec 01, 2021 2:12 am    Post subject: Can we use a higher address in flash for bootload memory ins Reply with quote

I currently use a mega168 which is 90% full, and would like to add a firmware update capability with bootloader.

Instead of using an external memory chip, can I use the higher unused memory in a Mega328 to store the firmware update, then have the bootloader copy it down to the working area?

(BASCOM-AVR version : 2.0.8.2 , Latest : 2.0.8.4 )
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Dec 01, 2021 1:11 pm    Post subject: Reply with quote

If flash is 90% full, an one-to-one copy would use up the same space again, that's 180%.
Not a good idea, don't you think so?

The boot-loader must reside somewhere in flash between &h1C00 and &h1F80, depending on the boot-loader's size.
With 90% full you're at address &h1CCC, which means you can't even use the biggest boot-loader with 1024 words, instead you need one a bit smaller.

So I may miss where you see "higher unused memory".
Do you know at all how a bootloader works?
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5917
Location: Holland

blank.gif
PostPosted: Wed Dec 01, 2021 1:32 pm    Post subject: Reply with quote

he wanted to use a M328 which has double the space. and i think he means he want to use normal flash space.
but the problem is that you can only write normal flash in boot mode. so the load would need to do 2 things : get the data and store it in 'unused' space.
then move this data to the normal space. for example when a checksum indicates that all is received.

i used unused space to save a good copy so a user could go back in case of a problem.

_________________
Mark
Back to top
View user's profile Visit poster's website
sentinel

Bascom Member



Joined: 02 Feb 2009
Posts: 141
Location: Tasmania

australia.gif
PostPosted: Wed Dec 01, 2021 2:07 pm    Post subject: Reply with quote

Yes, the idea was to have the updated firmware received via Bluetooth and have the serial parser in the main code (not the bootloader) store the new firmware at a higher address.

If the checksum matches, then a flag would be set and the program would jump to the bootloader address, check the flag, then copy the new firmware over the old.

But if only the bootloader can overwrite flash memory, then this wouldn't work.

Since space is limited on the (small) PCB, I thought that the extra cost of the larger MCU would compare well with the cost of an external I2C memory chip.
Back to top
View user's profile
albertsm

Administrator



Joined: 09 Apr 2004
Posts: 5917
Location: Holland

blank.gif
PostPosted: Wed Dec 01, 2021 3:02 pm    Post subject: Reply with quote

that only works with an external memory. because of the protection you can not write to the normal flash when not in boot mode.
_________________
Mark
Back to top
View user's profile Visit poster's website
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 2262

blank.gif
PostPosted: Wed Dec 01, 2021 3:18 pm    Post subject: Reply with quote

albertsm wrote:
he wanted to use a M328 which has double the space.

You're right, I oversaw it.
Back to top
View user's profile
sentinel

Bascom Member



Joined: 02 Feb 2009
Posts: 141
Location: Tasmania

australia.gif
PostPosted: Wed Dec 01, 2021 11:31 pm    Post subject: Reply with quote

Understood. Thanks Mark.
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    www.mcselec.com Forum Index -> BASCOM-AVR All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum