I'm having issues implementing a bootloader update.
Specs: CPU: MKL15Z128VFT4
IDE: KDS 3.0.0
C90TFS Flash Driver
I'm fetching 1kB at a time from SPI flash and writing 1KB (1 sector) to uC program flash.
My bootloader is from 0x0000_0000 to 0x6C00
My appcode is from 0x0000_7200 to 0x0001_FFFF
I know this isn't the best use of space, right now I'm just trying to debug the process to see if I can get consistent reads from SPI flash and writes to the uC program memory location.
In the code process here's sequence
move C90TFS function FlashCommandSequence to RAM
//each read/write is for 1kB
for(i = 0; i < numReads; i++)
1. read 1 kB from SPI flash
2. Enter Critical section - shut off Interrupts (ie OSA_EnterCritical(kCriticalDisableInt))
3. Disable OSA interrupt (ie SysTick->CTRL = mask & 0xFFFD)
4. erase 1kB sector on uC app area starting at 0x0000_6C01
5. verify erase section
6 program 1 kB sector
7. program check 1kB sector
8. Enable OSA interrupt
9. Exit critical section
I've moved the C90TFS function FlashCommandSequence to RAM to avoid access violations. When I run through the loop I'm always able to get through 2 iterations and the program craps out when I try to do a SPI read on the 3rd iteration.
1st iteration: write to 0x7200 of uC program flash
2nd iteration: write to 0x7600 of uC program flash
3rd iteration: 0x7A00 target address - the program fails at the location where I set the baud rate in the SPI_HAL_SetBaud method of the SPI peripheral. This is part of the SPI_DRV_MasterTransferBlocking method of the SPI peripheral. All values of the equation look correct, but the debugger console shows the message WARNING: T-bit of XPSR is 0 but should be 1. The initial error is Cannot read register 15 (R15) while CPU is running. Target halted PC = 0x0000_0000
Does any one have any thoughts I what is going on that would cause this to happen? Am I having a memory access issue here? I had thought that the FlashCommandSequence method doesn't return until the CCIF bit is cleared, so I can't imagine a uC program flash write is occurring that this time.
Message was edited by: Jonathan Guinta Additional information: I've also added the code suggested by https://community.freescale.com/docs/DOC-103951 for the ESFC bit since I'm using an ARM M0+ https://community.freescale.com/thread/372923 and turned on and off the interrupts via OSA_EnterCritical and OSA_Exit critical right before and after the flash routines. To turn off the SysTick interrupt. I'm using this for the OSA_TimeDelay method. I'm now able to run the flash programming successfully for about 7 kB of flash and then it crashes again when I enter the SPI_TransferBlocking method where it crashes at the OSA_SemaWait (the semaphore wait routine). This problem still appears to be related to the SysTick timer issue. Does anyone have any suggestions on this one? I'm trying to switch between the flash programming and fetching the flash data from SPI flash, which I was using the SysTick timer for. Are the shutting on and off of (INT_SYS_DisableIRQGlobal and INT_SYS_EnableIRQGlobal) not consistent for the SysTick interrupt routine? Is there an issue with shutting on and off these Interrupts for every 1kB of programming? I know every time you turn on a critical section the context needs to be put on the stack. Any recommendations would be awesome, thanks!