Using:
KDS 3.2.0
FSL_Kinetis_Bootloader_K80_Tools_1_0_0
FRDM K82F
Kinetis Bootloader QuadSPI User's Guide.pdf Rev0
Issue Summary:
Using led_demo_qspi example, adding simple code to the example will prevent the device from booting from external flash memory
Issue Detail:
I have followed the QuadSPI User Guide and built the led_demo_qspi example using KDS 3.2.0 GCC. I have encrypted the file and programmed the external flash with the encrypted image and the LED flashes as per the example. All good.
I have added code to the main function after the clocks have been switched and the hardware has been initialised.
The code I have added is multiple lines of __asm("nop"); to simplify the issue I am having, same occurs with any other code.
Depending on the number of NOP's added will effect if the processor will successfully boot from external flash.
So you will see in the following code snippet that I am executing 8 NOP instructions, this results in the boot sequence resetting the processor as seen by the reset LED on the FRDM board momentarily flashing. If I add no NOP's the processor boots and correctly flashes the LED's. If I add 10 NOP's the processor correctly boot's.
Again, the is an example project found in the FSL_Kinetis_Bootloader_K80_Tools_1_0_0, the only code I have added is NOP's. The linker and project settings are all from the example.
I have included my project as an attachment.
If any one can help with this I would be very grateful.
John
<code>
int main(void)
{
copy_to_ram();
clock_change();
hardware_init();
milliseconds_delay_init();
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Not working
__asm("nop"); //Not working
__asm("nop"); //Not working (reset LED flash)
/*__asm("nop"); //Not working (reset LED flash)
__asm("nop"); //Not working
__asm("nop"); //Not working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Not working
__asm("nop"); //Not working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Not working (no reset LED flash)
__asm("nop"); //Not working (no reset LED flash)
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Not working (reset LED flash)
__asm("nop"); //Not working (reset LED flash)
__asm("nop"); //Not working (no reset LED flash)
__asm("nop"); //Not working (no reset LED flash)
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Working
__asm("nop"); //Not working (no reset LED flash)
__asm("nop"); //Not working (no reset LED flash)
__asm("nop"); //Working
/* */
uint32_t led_idx = LED0;
while(1)
{
led_toggle(led_idx);
milliseconds_delay(1000);
led_toggle(led_idx);
led_idx <<= 1;
if(led_idx > MAX_LED_IDX)
{
led_idx = LED0;
}
// Re-enter bootloader if the bootloader pin is asserted.
if (is_bootloader_pin_asserted())
{
app_enter_bootloader();
}
}
}
</code>
Original Attachment has been moved to: led_demo_qspi_project_export_from_KDS.zip
The clock_change function was to blame.
I copied the clock_change function from:
NXP_Kinetis_Bootloader_2_0_0.zip\NXP_Kinetis_Bootloader_2_0_0\apps\demo_qspi\led_demo\src\led_demo_qspi.c
Everything ok in non-encrypted and encrypted, no NOPs -> 100's of NOP's.
I wonder if this is related to the clock_change function. The reason I ask is that I have out of desparation, commented out the clock_change function and tried upto 12 NOP's, every time the processor boots after programming.
The processor will still not boot from turning on the power supply.
Ideas???
Ok, I have the same issues with the board I designed.
So going back to the FRDM-K82F board, I have performed some more testing to determine what is happening with each added NOP.
I have looked at the boot behaviour whilst adding more NOP's into the vanilla led_demo_qspi demo included with the FSL_Kinetis_Bootloader_K80_Tools_1_0_0
The NOP's am adding are as follows:
int main(void)
{
copy_to_ram();
clock_change();
hardware_init();
milliseconds_delay_init();
__asm("nop"); //Add multiple NOP's
uint32_t led_idx = LED0;
while(1)
{
led_toggle(led_idx);
milliseconds_delay(1000);
led_toggle(led_idx);
led_idx <<= 1;
if(led_idx > MAX_LED_IDX)
{
led_idx = LED0;
}
// Re-enter bootloader if the bootloader pin is asserted.
if (is_bootloader_pin_asserted())
{
app_enter_bootloader();
}
}
}
For every NOP I add, I recompile and regenerate a SB file both encrypted and plain text:
I am programming the K82F on the FRDM board via the J24, the BlueTooth Header. The BlueTooth header uses PTC3 and PTC4 (UART1). I have moved J23 jumper to position 2-3 so I can use SW1 to reset the processor.
The boot scenarios I have tested are as follows:
Observations:
1 Will the processor boot after programming the firmware:
2 Will the processor boot after pressing SW1 with serial dongle connected?
3 Will the processor boot after pressing SW1 without serial dongle connected?
4 Will the processor boot after power cycling with serial dongle connected?
5 Will the processor boot after power cycling without serial dongle connected?
A pattern has emerged based on the number of NOPs added. See the following table:
Summary
Due to the behaviour of the processor during boot and the fact that touching the Rx pin of bootloader UART1 (UART0 and UART2 do the same), I think there is possibly an issue with the K82F ROM bootloader. I think it would be useful for an NXP to look at this and try and reproduce on the same silicon version 1N03P. It is possible by touching the Rx pin I am inducing mains hum and effecting the bootloader state machine?
I have seen in the errata for the K82F processor that SPI has an issue with the bootloader, I have disabled SPI in my BCA (.enabledPeripherals = 0x1) and therefore the problem should only isolated to the UART.
The fact that when the FRDM-K82F is powered from a lab power supply (I have tried 2 different ones) and it enters the ROM bootloader when the power is turn on suggests the bootloader peripheral detect has an anomaly during power on or it's a power sequencing of the K82F and External QuadSPI flash. Perhaps the QuadSPI flash does not initilise in time for the K82F to read the BCA?
I don't think I have made a mistake in the code as the code is straight from an example provided with the FSL_Kinetis_Bootloader_K80_Tools_1_0_0, it would be very much appreciated if someone who has experience of this processor and booting from external QuadSPI flash could take a look at my project to see if I have made any obvious mistakes.
If any one has a project that they know to work using the FRDM-K82F and QuadSPI that can be built using KDS 3.2.0 that they could send to me so I can verify my hardware, that too would be much appreciated.
John
So I have investigated this further. These are my findings:
I have designed my own board using the K82F processor and I have not experienced (YET) any issues with booting.
I am very confused with the FRDM-K82F, has anyone else had booting issues?
Well I would expect that the entry point is changing as the number of NOPs changes. You could check this in the plain-text SREC or the map file: create one working image and find out the entry point. Then create a non-working version. Is the entry point the same? The transfer from the bootloader to the application is likely failing.