Hello Team,
We are trying to write the Data Flash area(0x10000000U to 0x1001FFFFU), but while reading the Dflash memory region we are getting the below error,
BusFault: A precise (synchronous) data access error has occurred.
Possible BusFault location: 0x10000002.
HardFault: A fault has been escalated to a hard fault.
The bus fault is occurring while reading the D flash area as we can see in below thread snap,
Please help me to resolve the Bus fault.
Thanks & Regards,
Sachin N
Hi my friend, I also encountered the same problem, how did you solve it in the end?
Hello ,i have same question,how did you solve this problem?@sachin922185
Hello @sachin922185,
How do you write the DFlash?
Please make sure that the DFlash sector is erased before it is programmed.
Do you see any C40 error flags, or does the C40_Ip driver return any error when the DFlash is being programmed?
Can you read the DFlash data by the debugger?
Thank you,
BR, Daniel
Hello Daniel,
Thanks for your valuable reply!!!
We want to write the DFLASH in Dword aligned with induvial parameters as per our project need. So it will not work for us to erase sector. Please see the below function dflash_write_multiple from where we are writing the Dflash,
/**
* Hardware Abstraction Layer API for writing the multiple bytes value to Dflash memory locations
*
* @Param[in] address Dflash memory location address
* @Param[in] buffer Pointer for holding the Dflash write values
* @Param[in] no_of_bytes Number of bytes to be written to Dflash
* @retval hal_err_type_t Returns the status as <i>HAL_INIT_OK</i> or <i>HAL_GENERAL_ERROR</i>
*/
hal_err_type_t dflash_write_multiple(uint32_t address, uint8_t *buffer, uint8_t no_of_bytes)
{
hal_err_type_t ret = HAL_GENERAL_ERROR;
uint8_t domain_id = 0;
C40_Ip_VirtualSectorsType VirtualSector;
uint32_t total_bytes = 0;
uint32_t byte_pos_in_dword;
uint8_t buf16[16] = {0};
uint8_t buf128[128+16] = {0};
if(no_of_bytes > MAX_BYTES_ALLOWED)
{
return HAL_PARAM_MAX_ERROR;
}
if(address >= DFLASH_START_ADDRESS && address<= DFLASH_END_ADDRESS)
{
/* Get sector number */
VirtualSector = C40_Ip_GetSectorNumberFromAddress(address);
C40_Ip_ClearLock(VirtualSector,0);
if(no_of_bytes <= C40_WRITE_DOUBLE_WORD) /* Number bytes are 8 */
{
byte_pos_in_dword = address % C40_WRITE_DOUBLE_WORD; /* Check byte position in DWORD */
if((byte_pos_in_dword == 0) && (no_of_bytes == C40_WRITE_DOUBLE_WORD))
{
if(STATUS_C40_IP_SUCCESS == C40_Ip_MainInterfaceWrite(address, no_of_bytes, buffer, domain_id))
{
ret = HAL_OK;
while(STATUS_C40_IP_BUSY == C40_Ip_MainInterfaceWriteStatus());
}
}
else
{
if(STATUS_C40_IP_SUCCESS == C40_Ip_Read(address - byte_pos_in_dword, sizeof(buf16), buf16))
{
memcpy(&buf16[byte_pos_in_dword], buffer, no_of_bytes);
if(STATUS_C40_IP_SUCCESS == C40_Ip_MainInterfaceWrite(address - byte_pos_in_dword, sizeof(buf16), buf16, domain_id))
{
ret = HAL_OK;
while(STATUS_C40_IP_BUSY == C40_Ip_MainInterfaceWriteStatus());
}
}
}
}
else if(no_of_bytes > C40_WRITE_DOUBLE_WORD)
{
byte_pos_in_dword = address % C40_WRITE_DOUBLE_WORD; /* Check byte position in DWORD */
total_bytes = (no_of_bytes + byte_pos_in_dword) + \
(C40_WRITE_DOUBLE_WORD - byte_pos_in_dword) + \
(C40_WRITE_DOUBLE_WORD - (no_of_bytes%8));
if(STATUS_C40_IP_SUCCESS == C40_Ip_Read(address - byte_pos_in_dword, total_bytes, buf128))
{
memcpy(&buf128[byte_pos_in_dword], buffer, total_bytes);
if(STATUS_C40_IP_SUCCESS == C40_Ip_MainInterfaceWrite(address - byte_pos_in_dword, total_bytes, buf128, domain_id))
{
ret = HAL_OK;
while(STATUS_C40_IP_BUSY == C40_Ip_MainInterfaceWriteStatus());
}
}
}
}
return ret;
}
We are reading the Dflash in debug mode.
Thanks & Regards,
Sachin N
Hello Sachin N,
It is difficult to say what is the issue.
Can you please read the status that the functions return instead of just checking if the C40 module is busy. Does the function return STATUS_C40_IP_ERROR or STATUS_C40_IP_ERROR_BLANK_CHECK?
The phrases of the DFlash sector that you program must be erased, please make sure it is erased.
Thank you,
BR, Daniel