J-Link: program Flash and SDRAM at startup of a debug session

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

J-Link: program Flash and SDRAM at startup of a debug session

1,834 Views
giusloq
Contributor III

I have a board with LPC1788, an external SDRAM, an external SPI Flash (connected with a standard SPI peripheral, not SPIFI) and a TFT 480x272 display.

All the bimap images don't fit in the internal Flash, so my idea is to save them in the external SPI Flash and copy them at startup to SDRAM, from address 0xA008 0000. The framebuffer is at address 0xA000 0000, that is the initial address of SDRAM after initialization.

In the MCUXpresso MCU Settings window, I added a "fake" Flash memory section that starts at 0xA008 (it's fake, because it isn't a Flash, but a SDRAM). So the build process generates a .hex file with two areas: internal Flash (0x0000) and external SDRAM (0xA008).

I already have a USB bootloader that is able to read the .hex and write to internal Flash (0x0000...) and SPI Flash (0xA008...). This works good, but I can't use this approach for debugging, because USB bootloader is too slow.

I'm trying to find a way to instruct IDE to program 0xA008..., already present in the output file of the linking process. I know this isn't normally possible, because SDRAM isn't initialized at reset. Is there a way to initialize SDRAM and write it at debug startup, together with internal Flash?

Do you suggest another better approach?

Tags (1)
0 Kudos
9 Replies

1,562 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Giuseppe Modugno

I suggest you to take a look at chapter 17.15.2 "Configuring projects to span multiple Flash Devices", This may be useful for your application.  https://www.nxp.com/docs/en/user-guide/MCUXpresso_IDE_User_Guide.pdf

 

For examples, you may want to see this post https://community.nxp.com/docs/DOC-335283 Although it is not specific for multiple flash, it might be a starting point.

 

Regarding your question about initialize SDRAM and write it at debug startup, allow me some time so I can confirm if it is possible.

 

If you have more questions, do not hesitate to ask me.

Best regards,

Omar

0 Kudos

1,562 Views
giusloq
Contributor III

I suggest you to take a look at chapter 17.15.2 "Configuring projects to span multiple Flash Devices", This may be useful for your application.  https://www.nxp.com/docs/en/user-guide/MCUXpresso_IDE_User_Guide.pdf

For examples, you may want to see this post https://community.nxp.com/docs/DOC-335283 Although it is not specific for multiple flash, it might be a starting point.

Yes, I already know how to write source code to tell the linker to place things in different Flash devices.

Regarding your question about initialize SDRAM and write it at debug startup, allow me some time so I can confirm if it is possible.

Ok, I'm waiting for your reply.

0 Kudos

1,562 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Giuseppe Modugno

 

Unfortunately, it is not possible to initialize the SDRAM at startup. The SDRAM can't be initialized at reset in this device since the EMC module needs to be initialized.

 

I apologize for the inconvenience this may cause you. If you have more questions do not hesitate to ask me.

Best regards,

Omar

0 Kudos

1,562 Views
giusloq
Contributor III

Omar Anguiano ha scritto:

Unfortunately, it is not possible to initialize the SDRAM at startup. The SDRAM can't be initialized at reset in this device since the EMC module needs to be initialized.

I see. Do you think it's possible to write a startup script for J-Link to initialize the SDRAM before launching debug session?

Is it possible to assign a driver for SDRAM memory section, as for Flash devices, in order to program it at debug startup?

0 Kudos

1,562 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Giuseppe Modugno

 

This community post may be useful: https://community.nxp.com/message/921876?commentID=921876#comment-921876 

It says that the EMC setup can be initialized at the startup, specifically at ResetISR() function just before data_init() or bss_init() that are located inside the ResetISR().

 

Let me know if this is helpful.

 

Best Regards,

Omar

0 Kudos

1,562 Views
giusloq
Contributor III

I'd like to initialize EMC when a debug session starts, so the IDE is able to program Flash memory and external SDRAM, before launching the application.

So the initialization of EMC at ResetISR() is not useful here, because SDRAM must be programmed before code starts running.

0 Kudos

1,562 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Giuseppe Modugno

For this, I suggest you write a bootloader that allows you to program the SDRAM so it can be started before launching the application.

To do this the ResetISR() must be modified to prevent memory erase of the SDRAM initialization in bootloader.

 

If you have more questions, do not hesitate to ask me.

Best regards,

Omar

0 Kudos

1,562 Views
giusloq
Contributor III

I now see what you suggested. You think of:

- flash a custom bootloader that is able to program SDRAM at reset of MCU

- when a debug session starts, internal Flash is programmed with the application (bootloader is not erased)

- the debug session performs a reset, so the bootloader starts

- the bootloader programs the SDRAM (via UART/USB/...) and launch the application

- ResetISR() does not reset SDRAM

It is a good suggestion. I actually have a custom USB HID bootloader, but it is very slow. I don't know why and I have to study it. Could you suggest a ready-to-use bootloader for this purpose?

0 Kudos

1,562 Views
Omar_Anguiano
NXP TechSupport
NXP TechSupport

Hello Giuseppe Modugno

 

Unfortunately, we don't have a specific bootloader, however, you can refer to mcuboot to build a bootloader. Although it is for kinetis, it can be used as a reference for an LPC bootloader.

Also, this can be used as reference https://www.nxp.com/docs/en/nxp/application-notes/AN12407.pdf

 

Let me know if this is helpful

Best regards,

Omar

0 Kudos