EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

USB Bootloader for internal and external flash memory. LPC2478

Started by eremitic193 September 15, 2009
Hello

I have implimented a USB Bootloader based on NXP AN10764. I am attempting to expand this bootloader to flash an application into internal and external flash memory. I am using an LPC2478 cpu and Spansion S29GL128N Flash memory. I have an application for my device which does use the external and internal flash. (But does not use the Bootloader) So I have verified that my hardware functions correctly. My concern is configuring the flash in the bootloader.

-If I configure the flash in the bootloader (as flash) I cannot write to it because I will get an abort. (As Per the LPC manual). Which is understandable. A co-worker had suggested that the flash could be configured as RAM and be written to with a programming algorithm similar to one used when programming via JTAG.

Does anyone have any suggestions as to what might be the best way to do this?

Thanks

An Engineer's Guide to the LPC2100 Series

Hi,

You can not write flash when you are executing from flash. There are two alternatives to the problem:
1 Copy/place flash access routines in the RAM and execute the same from RAM itself and rest of the program executes from flash itself.
2 On power on, copy entire boot loader to RAM and execute from the RAM.

You can decide based on availability of the RAM.

Regards,

Himanshu Patel

--- On Tue, 9/15/09, eremitic193 wrote:
From: eremitic193
Subject: [lpc2000] USB Bootloader for internal and external flash memory. LPC2478
To: l...
Date: Tuesday, September 15, 2009, 6:38 PM


Hello

I have implimented a USB Bootloader based on NXP AN10764. I am attempting to expand this bootloader to flash an application into internal and external flash memory. I am using an LPC2478 cpu and Spansion S29GL128N Flash memory. I have an application for my device which does use the external and internal flash. (But does not use the Bootloader) So I have verified that my hardware functions correctly. My concern is configuring the flash in the bootloader.

-If I configure the flash in the bootloader (as flash) I cannot write to it because I will get an abort. (As Per the LPC manual). Which is understandable. A co-worker had suggested that the flash could be configured as RAM and be written to with a programming algorithm similar to one used when programming via JTAG.

Does anyone have any suggestions as to what might be the best way to do this?

Thanks




Hi,

Please check whether LCP2478 has IAP functionality. If yes then you can make use of the same when running boot loader from internal flash memory.

Regards,

Himanshu Patel

--- On Wed, 9/16/09, Himanshu Patel wrote:
From: Himanshu Patel
Subject: Re: [lpc2000] USB Bootloader for internal and external flash memory. LPC2478
To: l...
Date: Wednesday, September 16, 2009, 8:36 AM


Hi,

You can not write flash when you are executing from flash. There are two alternatives to the problem:
1 Copy/place flash access routines in the RAM and execute the same from RAM itself and rest of the program executes from flash itself.
2 On power on, copy entire boot loader to RAM and execute from the RAM.

You can decide based on availability of the RAM.

Regards,

Himanshu Patel

--- On Tue, 9/15/09, eremitic193 wrote:

From: eremitic193
Subject: [lpc2000] USB Bootloader for internal and external flash memory. LPC2478
To: lpc2000@yahoogroups .com
Date: Tuesday, September 15, 2009, 6:38 PM



Hello

I have implimented a USB Bootloader based on NXP AN10764. I am attempting to expand this bootloader to flash an application into internal and external flash memory. I am using an LPC2478 cpu and Spansion S29GL128N Flash memory. I have an application for my device which does use the external and internal flash. (But does not use the Bootloader) So I have verified that my hardware functions correctly. My concern is configuring the flash in the bootloader.

-If I configure the flash in the bootloader (as flash) I cannot write to it because I will get an abort. (As Per the LPC manual). Which is understandable. A co-worker had suggested that the flash could be configured as RAM and be written to with a programming algorithm similar to one used when programming via JTAG.

Does anyone have any suggestions as to what might be the best way to do this?

Thanks






The LPC2478 does have IAP functionality which I am already using for flashing the internal flash.(from Ram) My bootloader functions correctly for programming internal flash only. We have been doing some research and I believe I know how to configure the external flash to avoid the abort. (Only while in the bootloader) based on an example from NXP for NOR Flashes. In this example it appears that the EMC is configured so that the external device is not write protected. (In my case that device corresponds with CS0). The example was found in a code bundle for lpc23xx and lpc24xx on NXPs website. I am going to hack up some tests as soon as I can and will post again after that.

-Eremitic193
(Zach)

--- In l..., Himanshu Patel wrote:
>
> Hi,
>
> Please check whether LCP2478 has IAP functionality. If yes then you can make use of the same when running boot loader from internal flash memory.
>
> Regards,
>
> Himanshu Patel
>
> --- On Wed, 9/16/09, Himanshu Patel wrote:
>
>
> From: Himanshu Patel
> Subject: Re: [lpc2000] USB Bootloader for internal and external flash memory. LPC2478
> To: l...
> Date: Wednesday, September 16, 2009, 8:36 AM
>
>
>
>
>
>
> Hi,
>
> You can not write flash when you are executing from flash. There are two alternatives to the problem:
> 1 Copy/place flash access routines in the RAM and execute the same from RAM itself and rest of the program executes from flash itself.
> 2 On power on, copy entire boot loader to RAM and execute from the RAM.
>
> You can decide based on availability of the RAM.
>
> Regards,
>
> Himanshu Patel
>
> --- On Tue, 9/15/09, eremitic193 wrote:
>
> From: eremitic193
> Subject: [lpc2000] USB Bootloader for internal and external flash memory. LPC2478
> To: lpc2000@yahoogroups .com
> Date: Tuesday, September 15, 2009, 6:38 PM
>
>
>
> Hello
>
> I have implimented a USB Bootloader based on NXP AN10764. I am attempting to expand this bootloader to flash an application into internal and external flash memory. I am using an LPC2478 cpu and Spansion S29GL128N Flash memory. I have an application for my device which does use the external and internal flash. (But does not use the Bootloader) So I have verified that my hardware functions correctly. My concern is configuring the flash in the bootloader.
>
> -If I configure the flash in the bootloader (as flash) I cannot write to it because I will get an abort. (As Per the LPC manual). Which is understandable. A co-worker had suggested that the flash could be configured as RAM and be written to with a programming algorithm similar to one used when programming via JTAG.
>
> Does anyone have any suggestions as to what might be the best way to do this?
>
> Thanks
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
The example in the code bundle was exactly what I needed. (EXTMEM). There is obviously some changes that have to be made for a particular flash but the basic idea was really helpful. So far I have been able to Read the mnf id and the device id from the flash. Do a full chip erase on the flash and write some patterns to the flash. (Although when writing the pattern to the flash every other 16 bit word does not appear to be written to. The NORFlash example only writes a single word write at a time so I will be implimenting a page write version. So writing to the flash doesn't seem to be a huge problem. Now I just have to decide what I am going to do about handling multiple BIN files. For those that don't know the example this bootloader works by acting as a mass storage device over the usb interface. The user copies a .bin file to the "drive" and flashing begins. I will have to modify the loader to know where to put which bin file (either use IAP for internal flash or programming algorithm for external flash). Will keep the forum posted with any progress.

-Zach

--- In l..., "eremitic193" wrote:
>
> The LPC2478 does have IAP functionality which I am already using for flashing the internal flash.(from Ram) My bootloader functions correctly for programming internal flash only. We have been doing some research and I believe I know how to configure the external flash to avoid the abort. (Only while in the bootloader) based on an example from NXP for NOR Flashes. In this example it appears that the EMC is configured so that the external device is not write protected. (In my case that device corresponds with CS0). The example was found in a code bundle for lpc23xx and lpc24xx on NXPs website. I am going to hack up some tests as soon as I can and will post again after that.
>
> -Eremitic193
> (Zach)
>
>
>
> --- In l..., Himanshu Patel wrote:
> >
> > Hi,
> >
> > Please check whether LCP2478 has IAP functionality. If yes then you can make use of the same when running boot loader from internal flash memory.
> >
> > Regards,
> >
> > Himanshu Patel
> >
> > --- On Wed, 9/16/09, Himanshu Patel wrote:
> >
> >
> > From: Himanshu Patel
> > Subject: Re: [lpc2000] USB Bootloader for internal and external flash memory. LPC2478
> > To: l...
> > Date: Wednesday, September 16, 2009, 8:36 AM
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> > You can not write flash when you are executing from flash. There are two alternatives to the problem:
> > 1 Copy/place flash access routines in the RAM and execute the same from RAM itself and rest of the program executes from flash itself.
> > 2 On power on, copy entire boot loader to RAM and execute from the RAM.
> >
> > You can decide based on availability of the RAM.
> >
> > Regards,
> >
> > Himanshu Patel
> >
> > --- On Tue, 9/15/09, eremitic193 wrote:
> >
> > From: eremitic193
> > Subject: [lpc2000] USB Bootloader for internal and external flash memory. LPC2478
> > To: lpc2000@yahoogroups .com
> > Date: Tuesday, September 15, 2009, 6:38 PM
> >
> >
> >
> > Hello
> >
> > I have implimented a USB Bootloader based on NXP AN10764. I am attempting to expand this bootloader to flash an application into internal and external flash memory. I am using an LPC2478 cpu and Spansion S29GL128N Flash memory. I have an application for my device which does use the external and internal flash. (But does not use the Bootloader) So I have verified that my hardware functions correctly. My concern is configuring the flash in the bootloader.
> >
> > -If I configure the flash in the bootloader (as flash) I cannot write to it because I will get an abort. (As Per the LPC manual). Which is understandable. A co-worker had suggested that the flash could be configured as RAM and be written to with a programming algorithm similar to one used when programming via JTAG.
> >
> > Does anyone have any suggestions as to what might be the best way to do this?
> >
> > Thanks
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>


The 2024 Embedded Online Conference