Do you have flash read/write sample code with s32K144

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

Do you have flash read/write sample code with s32K144

1,176 Views
alice_thanks
Contributor III

Hello 

 s32k144 flash API don't support read ?

i find only below API FLASH_DRV_ReadResource can read data from flash , it only support 8bytes ?

if i want to support any length to read the data from, can i do it below ? or do you have example project or code ?

BTW,i need the flex_nvm data from data (addr:0x10000000U)

status_t hal_read_from_flash(uint32_t address, uint8_t* p_bufsrc,uint32_t length)
{
uint8_t data[8];
int i;
int ret;
for(i=0;i<length/8;i++)
{
memset(data,0,8);
FLASH_DRV_ReadResource(&ssdConfig,(address+8*i),data,0);
memcpy(p_bufsrc+i*8,data,8);
}
int remain_len = length%8;
ret = FLASH_DRV_ReadResource(&ssdConfig,(address+8*i),data,0);
memcpy(p_bufsrc+i*8+remain_len,data,remain_len);
return ret;
}

/*FUNCTION**********************************************************************
*
* Function Name : FLASH_DRV_ReadResource
* Description : Read data from special purpose memory in Flash memory module
* including P-Flash IFR, swap IFR, D-Flash IFR space and version ID.
*
*END**************************************************************************/
status_t FLASH_DRV_ReadResource(const flash_ssd_config_t * pSSDConfig,
uint32_t dest,
uint8_t * pDataArray,
uint8_t resourceSelectCode)

 

0 Kudos
Reply
4 Replies

1,147 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Alice,

There is no SDK API to read the flash, the FLASH_DRV_ReadResource() launches the FTFx_READ_RESOURCE command (FTFx_CMD 0x3) that is not supported on S32K1xx.

But the flash can be easily read by a pointer.

Or you can use the RTD Ftfc_Ip driver that has this API:

Ftfc_Fls_Ip_Read()

 

Regards,

Daniel

0 Kudos
Reply

1,143 Views
alice_thanks
Contributor III

ok, got it, thanks

another question is 

does this osif_IsIsrContext API is get current status in isr or task with freertos?

can i used it in printf/scanf ?

static inline bool osif_IsIsrContext(void)
{
    bool is_isr = false;
    uint32_t ipsr_code = (uint32_t)( (S32_SCB->ICSR & S32_SCB_ICSR_VECTACTIVE_MASK) >> S32_SCB_ICSR_VECTACTIVE_SHIFT );
    if (ipsr_code != 0u)
    {
        is_isr = true;
    }
 
    return is_isr;
}
 
 
int_t __read_console(__file_handle handle, uchar_t * buffer, size_t * count)
{
#ifdef rtos_version
    if(osif_IsIsrContext() == true)
        taskDISABLE_INTERRUPTS();
    else
    {
        taskENTER_CRITICAL();
    }
#endif
    
    uint32_t bytesRemain;
bool MsgDone=false;
uchar_t new_lin[]={"\n"};
int i=0;
while (MsgDone==false)
{
    LPUART_DRV_ReceiveData(INST_LPUART1, &buffer[i], 1);
    while(LPUART_DRV_GetReceiveStatus(INST_LPUART1, &bytesRemain) != STATUS_SUCCESS);
    LPUART_DRV_SendData(INST_LPUART1, &buffer[i], 1);
    while(LPUART_DRV_GetTransmitStatus(INST_LPUART1, &bytesRemain) != STATUS_SUCCESS);
    if(buffer[i++] == '\r')
{
   buffer[i-1]='\n';
   MsgDone = true;
}
   }
   LPUART_DRV_SendData(INST_LPUART1, new_lin, 1);
   while(LPUART_DRV_GetTransmitStatus(INST_LPUART1, &bytesRemain) != STATUS_SUCCESS);
   buffer[i]=0;
   *count = (size_t)i;
#ifdef rtos_version
   if(osif_IsIsrContext() == true)
        taskENABLE_INTERRUPTS();
    else
    {
        taskEXIT_CRITICAL();
    }
#endif
   return 0;
}
Tags (1)
0 Kudos
Reply

1,137 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Can you create a new thread for this question?

It has nothing to do with the flash.

 

Thank you,

Daniel

0 Kudos
Reply

1,166 Views
alice_thanks
Contributor III

BTW,i need read flash(addr:0x10000000U) data to ram with random length

0 Kudos
Reply