Using external flash for both application and file system storage

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

Using external flash for both application and file system storage

3,607 Views
BrendaCG616
Contributor I

Hi!!

My team and I are developing a project with the SLN-SVUI-IOT board. We're using the external flash memory to store the application, but we also want to use a part of it to store some files. We currently have a working application that uses WiFi, UART and LPSPI. Now, I'm trying to integrate the usage of the flash memory to read files. I'm using the sln_svui_local_demo example as a base, but the program keeps crashing in the FLEXSPI_Init function, so I guess there is something in the configurations I am missing.

Is there any tutorial for flash configuration so it can be used as described?

============================================================
Additionally, here is some context. This is my main function:

int main(void) {
/* Enable additional fault handlers */
 SCB->SHCSR |= (SCB_SHCSR_BUSFAULTENA_Msk
| /*SCB_SHCSR_USGFAULTENA_Msk |*/SCB_SHCSR_MEMFAULTENA_Msk);

/* Relocate Vector Table */
#if RELOCATE_VECTOR_TABLE
BOARD_RelocateVectorTableToRam();
#endif

/* Init board hardware. */
BOARD_ConfigMPU();
BOARD_InitBootPins();
BOARD_InitBootClocks();
#ifndef BOARD_INIT_DEBUG_CONSOLE_PERIPHERAL
/* Init FSL debug console. */
BOARD_InitDebugConsole();
#endif

/* Initialize Flash to allow writing */
SLN_Flash_Init();
if (SLN_FLASH_FS_OK != sln_flash_fs_ops_init(false)) {
 PRINTF(("ERROR: littlefs init failed!\r\n"));
}
xTaskCreate(read_file_task, "Read_Task", 512, NULL,
 configMAX_PRIORITIES - 4, &appTaskHandle);
/* Run RTOS */
vTaskStartScheduler();
while (1) {
}
return 0;
}

#endif

 

it crashes during SLN_Flash_Init();

I attached config files where are located the functions called before SLN_Flash_Init();

I also added these flags into compiler preprocessor settings:

XIP_EXTERNAL_FLASH=1
XIP_BOOT_HEADER_ENABLE=1
XIP_BOOT_HEADER_DCD_ENABLE=1

Labels (1)
0 Kudos
Reply
1 Reply

2,819 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi @BrendaCG616 ,

  Please note, the SLN-SVUI-IOT is also using the external flash, and the external flash can't support RWW. So, if you want in the external flash do the flash operation, eg, write, erase, you need to copy the flash operation to the internal RAM. So, you need to copy your used flash file to the internal RAM, and run in the internal RAM.

   You can check the SDK demo, flexspi_polling, you can find the flash operation file all in the internal RAM.

kerryzhou_0-1713761503791.png

 

Wish it helps you!

Best Regards,

Kerry

 

0 Kudos
Reply