EmbeddedRelated.com
Forums

Write Flash via Firmware

Started by marcos_r_r May 11, 2012
How do I write to flash memory through firmware via C code?
LPCXpresso LPC1114.

An Engineer's Guide to the LPC2100 Series

Il 11/05/2012 18:39, marcos_r_r ha scritto:
>
>
> How do I write to flash memory through firmware via C code?
> LPCXpresso LPC1114.
>
There is chapter 26 in the user manual specifying how to write internal
flash. You must study 26.7 IAP commands but should be better all the
chapter.
>



The manual that I had only had up to chapter 23, but updated the manual on the link below and found what I was looking for.
http://www.nxp.com/documents/user_manual/UM10398.pdf
Thank you for your help.
Marcos

From: M. Manca
Sent: Friday, May 11, 2012 2:10 PM
To: l...
Subject: Re: [lpc2000] Write Flash via Firmware

Il 11/05/2012 18:39, marcos_r_r ha scritto:
> How do I write to flash memory through firmware via C code?
> LPCXpresso LPC1114.
>
There is chapter 26 in the user manual specifying how to write internal
flash. You must study 26.7 IAP commands but should be better all the
chapter.
>





Il 11/05/2012 22:00, m...@smartcar.ind.br ha scritto:
>
>
> The manual that I had only had up to chapter 23, but updated the
> manual on the link below and found what I was looking for.
> http://www.nxp.com/documents/user_manual/UM10398.pdf
> Thank you for your help.
> Marcos
>
Yes, time to time it is better check to see if there is an updated user
manual, data sheet and errata.
NXP updated this user manual some times, if I remember well mine is v. 8.0
I suspected you had this type of problem because we as engineers are
people used to read user manuals so I give you the chapter number. :-)
Good work.
> From: M. Manca
> Sent: Friday, May 11, 2012 2:10 PM
> To: l...
> Subject: Re: [lpc2000] Write Flash via Firmware
>
> Il 11/05/2012 18:39, marcos_r_r ha scritto:
> >
> >
> > How do I write to flash memory through firmware via C code?
> > LPCXpresso LPC1114.
> >
> There is chapter 26 in the user manual specifying how to write internal
> flash. You must study 26.7 IAP commands but should be better all the
> chapter.
> >
> >
> >
>
>



As it does to write the code thru C (lpcxpresso) at address 0x00007000 in flash such as an example "test"? And how to read this data via C code?

Best Regards
Marcos
From: M. Manca
Sent: Friday, May 11, 2012 5:48 PM
To: l...
Subject: Re: [lpc2000] Write Flash via Firmware

Il 11/05/2012 22:00, mailto:marcos%40smartcar.ind.br ha scritto:
> The manual that I had only had up to chapter 23, but updated the
> manual on the link below and found what I was looking for.
> http://www.nxp.com/documents/user_manual/UM10398.pdf
> Thank you for your help.
> Marcos
>
Yes, time to time it is better check to see if there is an updated user
manual, data sheet and errata.
NXP updated this user manual some times, if I remember well mine is v. 8.0
I suspected you had this type of problem because we as engineers are
people used to read user manuals so I give you the chapter number. :-)
Good work.
> From: M. Manca
> Sent: Friday, May 11, 2012 2:10 PM
> To: mailto:lpc2000%40yahoogroups.com
> Subject: Re: [lpc2000] Write Flash via Firmware
>
> Il 11/05/2012 18:39, marcos_r_r ha scritto:
> >
> >
> > How do I write to flash memory through firmware via C code?
> > LPCXpresso LPC1114.
> >
> There is chapter 26 in the user manual specifying how to write internal
> flash. You must study 26.7 IAP commands but should be better all the
> chapter.
> >
> >
> >
>
>





Il 12/05/2012 02:44, m...@smartcar.ind.br ha scritto:
>
>
> As it does to write the code thru C (lpcxpresso) at address 0x00007000
> in flash such as an example "test"? And how to read this data via C code?
>
I didn't understand but I will try to explain what to do.
Suppose that you have to manage some setup or calibration data that you
don't need to update very frequently.
Then you have to locate them on a 256 boundary in some flash sector
(sector size is mcu model dependent) reserved to them.
When you need to write them you have to setup a twin memory structure on
ram filled with wanted values then you have to erase and write the flash
area with ram prepared content. To do this you have to use IAP commands
by user code taking care that when you are erasing and writing the flash
is mandatory to disable all interrupts. If I remember well there are
some examples around NXP site and also in the lpcxpresso example code.
So the main idea is erase the flash block, wait until finished and then
copy from ram to flash your data and wait until finished. May be good to
provide something like a 128 bit signature using the internal signature
peripheral to check if all goes well.
> Best Regards
> Marcos
>
> From: M. Manca
> Sent: Friday, May 11, 2012 5:48 PM
> To: l...
> Subject: Re: [lpc2000] Write Flash via Firmware
>
> Il 11/05/2012 22:00, mailto:marcos%40smartcar.ind.br ha scritto:
> >
> >
> > The manual that I had only had up to chapter 23, but updated the
> > manual on the link below and found what I was looking for.
> > http://www.nxp.com/documents/user_manual/UM10398.pdf
> > Thank you for your help.
> > Marcos
> >
> Yes, time to time it is better check to see if there is an updated user
> manual, data sheet and errata.
> NXP updated this user manual some times, if I remember well mine is v. 8.0
> I suspected you had this type of problem because we as engineers are
> people used to read user manuals so I give you the chapter number. :-)
> Good work.
> >
> >
> > From: M. Manca
> > Sent: Friday, May 11, 2012 2:10 PM
> > To: mailto:lpc2000%40yahoogroups.com
> > Subject: Re: [lpc2000] Write Flash via Firmware
> >
> > Il 11/05/2012 18:39, marcos_r_r ha scritto:
> > >
> > >
> > > How do I write to flash memory through firmware via C code?
> > > LPCXpresso LPC1114.
> > >
> > There is chapter 26 in the user manual specifying how to write internal
> > flash. You must study 26.7 IAP commands but should be better all the
> > chapter.
> > >
> > >
> > >
> >
> >
> >
> >
> >
> >
>
>



There are a few Application notes that show this. The one below is for the LPC1102 but there is IAP code that can be used for the LPC1114.

http://www.lpcware.com/content/nxpfile/an10995-lpc1100-secondary-bootloader-software-v13

Also it is worth referring to this one as well:
http://www.lpcware.com/content/nxpfile/an11008-flash-based-non-volatile-storage-software

--- In l..., "marcos_r_r" wrote:
>
> How do I write to flash memory through firmware via C code?
> LPCXpresso LPC1114.
>

I had already understood this well, my doubt is another.
What is the statement in C that writes to a given address of the flash, but not via firmware, but saw lpcxpresso.
In the PIC instução is this:
ORG 0X210D //address
DE "test123"; //DE = instruction test123=text to be written
How is this statement for ARM.

From: M. Manca
Sent: Saturday, May 12, 2012 3:49 AM
To: l...
Subject: Re: [lpc2000] Write Flash via Firmware


Il 12/05/2012 02:44, mailto:marcos%40smartcar.ind.br ha scritto:
>
>
> As it does to write the code thru C (lpcxpresso) at address 0x00007000
> in flash such as an example "test"? And how to read this data via C code?
>
I didn't understand but I will try to explain what to do.
Suppose that you have to manage some setup or calibration data that you
don't need to update very frequently.
Then you have to locate them on a 256 boundary in some flash sector
(sector size is mcu model dependent) reserved to them.
When you need to write them you have to setup a twin memory structure on
ram filled with wanted values then you have to erase and write the flash
area with ram prepared content. To do this you have to use IAP commands
by user code taking care that when you are erasing and writing the flash
is mandatory to disable all interrupts. If I remember well there are
some examples around NXP site and also in the lpcxpresso example code.
So the main idea is erase the flash block, wait until finished and then
copy from ram to flash your data and wait until finished. May be good to
provide something like a 128 bit signature using the internal signature
peripheral to check if all goes well.
> Best Regards
> Marcos
>
> From: M. Manca
> Sent: Friday, May 11, 2012 5:48 PM
> To: mailto:lpc2000%40yahoogroups.com
> Subject: Re: [lpc2000] Write Flash via Firmware
>
> Il 11/05/2012 22:00, mailto:marcos%40smartcar.ind.br ha scritto:
> >
> >
> > The manual that I had only had up to chapter 23, but updated the
> > manual on the link below and found what I was looking for.
> > http://www.nxp.com/documents/user_manual/UM10398.pdf
> > Thank you for your help.
> > Marcos
> >
> Yes, time to time it is better check to see if there is an updated user
> manual, data sheet and errata.
> NXP updated this user manual some times, if I remember well mine is v. 8.0
> I suspected you had this type of problem because we as engineers are
> people used to read user manuals so I give you the chapter number. :-)
> Good work.
> >
> >
> > From: M. Manca
> > Sent: Friday, May 11, 2012 2:10 PM
> > To: mailto:lpc2000%40yahoogroups.com
> > Subject: Re: [lpc2000] Write Flash via Firmware
> >
> > Il 11/05/2012 18:39, marcos_r_r ha scritto:
> > >
> > >
> > > How do I write to flash memory through firmware via C code?
> > > LPCXpresso LPC1114.
> > >
> > There is chapter 26 in the user manual specifying how to write internal
> > flash. You must study 26.7 IAP commands but should be better all the
> > chapter.
> > >
> > >
> > >
> >
> >
> >
> >
> >
> >
>
>
>
>





On 5/13/2012 11:21 AM, m...@smartcar.ind.br wrote:
> I had already understood this well, my doubt is another.
> What is the statement in C that writes to a given address of the flash, but not via firmware, but saw lpcxpresso.
> In the PIC instução is this:
> ORG 0X210D //address
> DE "test123"; //DE = instruction test123=text to be written

You are mistaken about what DE does.

From Microchips manual
http://ww1.microchip.com/downloads/en/devicedoc/33014j.pdf

de – DECLARE EEPROM DATA BYTE

It does not write to anywhere. It simply sets up a value in the image
that is downloaded to the device.

The equivalent in C is

const int c#0;

It's not ARM specific, although some compilers on some processors
provide extensions to C to allow placement in different memory areas.

To place it at a specific address requires either assembly, some work
with the linker or a compiler specific extension. And there are few
occasions when it is necessary to fix a constants location in memory.

Robert

--

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live....
we currently have stock."
How do to fix the value in memory flash ARM via code in C LPCXpresso?

From: Robert Adsett
Sent: Sunday, May 13, 2012 12:38 PM
To: l...
Subject: Re: [lpc2000] Write Flash via Firmware


On 5/13/2012 11:21 AM, mailto:marcos%40smartcar.ind.br wrote:
> I had already understood this well, my doubt is another.
> What is the statement in C that writes to a given address of the flash, but not via firmware, but saw lpcxpresso.
> In the PIC instução is this:
> ORG 0X210D //address
> DE "test123"; //DE = instruction test123=text to be written

You are mistaken about what DE does.

From Microchips manual
http://ww1.microchip.com/downloads/en/devicedoc/33014j.pdf

de – DECLARE EEPROM DATA BYTE

It does not write to anywhere. It simply sets up a value in the image
that is downloaded to the device.

The equivalent in C is

const int c=230;

It's not ARM specific, although some compilers on some processors
provide extensions to C to allow placement in different memory areas.

To place it at a specific address requires either assembly, some work
with the linker or a compiler specific extension. And there are few
occasions when it is necessary to fix a constants location in memory.

Robert

--

From the Divided by a Common Language File (Edited to protect the guilty)
ME - "I'd like to get Price and delivery for connector Part # XXXXX"
Dist./Rep - "$X.XX Lead time 37 days"
ME - "Anything we can do about lead time? 37 days seems a bit high."
Dist./Rep - "that is the lead time given because our stock is live....
we currently have stock."