Other Parts Discussed in Thread: SEGGER
Hello,
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello,
Code from Matt:
while (bytes_left > 0) {
if (isSectorStart((uint32_t) flash_address))
{
taskENTER_CRITICAL();
// make sure the FSM isn't busy before issuing erase command.
while (FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy);
//Data at start of a bank1 erase it first
Fapi_status = Fapi_issueAsyncCommandWithAddress(Fapi_EraseSector, (uint32_t *) flash_address);
while (FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy);
Fapi_status = (Fapi_StatusType) FAPI_GET_FSM_STATUS;
if (Fapi_status != Fapi_Status_Success) {
//HealthMonitor::SetFault(FLASH_PROGRAMMING_FAILURE);
BootMonitor::set_download_state(FLASH_FAILURE);
for (;;);
}
taskEXIT_CRITICAL();
}
/* If you want to use Fapi_AutoEccGeneration option, the data size to be programmed has to be
* either 8 or 16 bytes because ECC is calculated on 64bit (8 bytes) basis. */
uint32_t write_bytes = (bytes_left > FLASH_PAGE_SIZE ? FLASH_PAGE_SIZE : bytes_left);
taskENTER_CRITICAL();
Fapi_status = Fapi_issueProgrammingCommand((uint32_t *) flash_address,
source_ptr,
write_bytes,
0,
0,
Fapi_AutoEccGeneration);
flashLoader.num_bytes_written += write_bytes;
while (FAPI_CHECK_FSM_READY_BUSY == Fapi_Status_FsmBusy);
Fapi_status = (Fapi_StatusType) FAPI_GET_FSM_STATUS;
if (Fapi_status != Fapi_Status_Success) {
//HealthMonitor::SetFault(FLASH_PROGRAMMING_FAILURE);
BootMonitor::set_download_state(FLASH_FAILURE);
for (;;);
}
taskEXIT_CRITICAL();
bytes_left -= FLASH_PAGE_SIZE;
flash_address += FLASH_PAGE_SIZE;
source_ptr += FLASH_PAGE_SIZE;
if(bytes_left <= (byte_printout_count - (16 * 1024)))
{
_DEBUG.Syslog(LOG_INFO, "Flashed %d bytes at address %d. %d bytes left", write_bytes, flash_address, bytes_left);
xTaskDelay(10);
byte_printout_count = bytes_left;
}
//xTaskDelay(1);
}
bool FlashLoader::isSectorStart(uint32_t address)
{
uint32_t sec_size = 0x020000;
uint32_t small_sec_size = 0x08000;
if(address > 0x0001FFFF)
{
if(address % sec_size == 0)
{
return true;
}
}
else
{
if(address % small_sec_size == 0)
{
return true;
}
}
return false;
}
Thanks,
Gabe Garza
TI Support
Hello Again,
I have spoken with some of my co-workers and reviewed your answers as well as other users' post. I believe my issue is that I have not disabled interrupts.
Could this be a possible source of my problems (it seems that way since I am erasing 0x00 to 0x20)?
I have looked through some documentation, but I am not sure how to disable interrupts? Can you show me an example or relevant document to help with this?
Thanks,
Matt
At this point I am using your example code from bl_flash.c with no modifications, so I am pretty confident the flash code is fine (it still works at other addresses that don't include my bootloader).
I have attempted to disable interrupts, but have run into a roadblock
I noticed that despite calling _disable_FIQ_interrupt_ the associated bit in CPSR was not changing. I did some digging and it looks like it cannot be changed from software due to the NMFI bit being set in the SCTLR register. It appears that this bit is set via hardware and cannot be changed simply via code.
Do you know of any other way to disable Fast Interrupts? Do timer interrupts count as fast interrupts?
Also, I put break points in the exception vector to see what type of exceptions I was getting (this is after they were erased, so it would continually fail here).
It was stopping at 0x0C, which is the prefetch abort address. I attempted to disable aborts just to see what happens, but I also cannot change the abort bit in CPSR just like the FIQ bit.
Is it possible disabling aborts will work? How should I go about that?