Author Topic: Avoid writing Flash pages  (Read 4854 times)

jashugan

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
    • Email
Avoid writing Flash pages
« on: October 22, 2015, 05:03:33 am »
Hello,
I'm using an LPC1114, and I have a program that simulates the flash as an EEprom. The four upper banks are reserved for this use. When I run the bootloader, I would like not to change the values in these four banks, is it possible? At the moment, the program writes entirely the flash.

Thank you,
Mattia Berton

Andy Ayre

  • ESAcademy Staff
  • Sr. Member
  • *****
  • Posts: 2190
    • View Profile
    • Embedded Systems Academy, Inc.
    • Email
Re: Avoid writing Flash pages
« Reply #1 on: October 27, 2015, 02:03:39 am »
If you look at chapter 26 of the LPC1100 user manual from NXP you will see that there isn't an ISP command for erasing pages. Therefore Flash Magic can't do it.

You can chose which blocks/sectors to erase individually in section 2 of the main window.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

jashugan

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
    • Email
Re: Avoid writing Flash pages
« Reply #2 on: October 27, 2015, 03:00:00 am »
Yes, you're correct, but if I try to upload the new firmware via bootloader, it overwrites the upper banks, used in the program as EEprom emulation, so I lose all information stored.
Is there any way (in the Flashmagic or in the LPCXpresso) to tell the bootloader not to write those banks? Perhaps via the linker file, I don't know. Just for help, I'm attaching the linker file.

Thank you,
Mattia

Andy Ayre

  • ESAcademy Staff
  • Sr. Member
  • *****
  • Posts: 2190
    • View Profile
    • Embedded Systems Academy, Inc.
    • Email
Re: Avoid writing Flash pages
« Reply #3 on: October 27, 2015, 03:11:14 am »
You can control the memory ranges your firmware uses in your linker configuration. You can control which blocks are erased in Flash Magic. However, you must always erase the blocks used by your firmware.

If you have done something like this:

unsigned char EEPROM[0x1000] _at_ 0xC000;

then your firmware will occupy the memory at 0xC000 to 0xCFFF, and Flash Magic will want to erase it. Instead do:

unsigned char *EEPROM = (unsigned char *)0xC000;

which uses the same memory location but it is unallocated. This is now into the area of programming rather than Flash Magic so for further help with that you might want to check the LPCware forums.

Andy
Embedded Systems Academy, Inc.
support at esacademy dot com

jashugan

  • Jr. Member
  • **
  • Posts: 8
    • View Profile
    • Email
Re: Avoid writing Flash pages
« Reply #4 on: October 27, 2015, 09:45:26 am »
Ok! I'll try to apply your advice! Thank you.