Behaviour of reading/writing to addr in flash space

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Behaviour of reading/writing to addr in flash space

345件の閲覧回数
ignacio
Contributor II

Hi, I'm currently working on 2 routines to perform generic read/writes on the memory of the S32K144. These will be commanded externaly.

The read routine is quite simple:

 

uint32_t request_addr = 0x0000C000;
uint8_t* data = (uint8_t*)request_addr;
memcpy(response_buffer, data, 1);

 

It works as expected and I can read data stored in flash. However, if I try to implement a similar routine for writing:

 

 

uint32_t destination_addr = 0x0000C000;
memcpy((uint8_t*)destination_addr , &request_data, 1);

 

 
I get a BusFault:
BusFault: An imprecise (asynchronous) data access error has occurred.
HardFault: A fault has been escalated to a hard fault.
 
For the write routine, I tried something similar, but to an addr of a variable in ram space:
 

 

volatile static uint8_t validation_value = 0;

validation_value = 0xBA;
uint32_t addr = &validation_value;
uint8_t newValue = 0xFF;

memcpy((uint8_t*)addr, &newValue, 1);

 

This works fine.

 

My question here is what's the behaviour when reading/writing to memory spaces in flash? Are reads fine but writes protected in some way? Do I need to use the flash_drv for writes? Am I missing something here?

Thanks!


         
                    
0 件の賞賛
返信
1 返信

325件の閲覧回数
VaneB
NXP TechSupport
NXP TechSupport

Hi @ignacio 

Before a program operation Flash memory needs to be erased. For more information about recommendations for flash programming of S32K1 devices refer to the application note AN12130: Production Flash Programming Best Practices for S32K1xx MCUs.

 

B.R.

VaneB

0 件の賞賛
返信