FSL Kinetis Bootloader K80 Tools Example Problem

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.

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.

Comparing the list file for working and non-working firmware, every looks good, no alignment problems, entry points look good.

Tested the code on two FRDM-K82F boards, both result in same operation.

I have been powering the board using a bench PSU at 6V via J3 Pins 14/16 0V/Vin, holding a wire connected to J2 Pin 2 (PTB16 LPUART0_RX) the processor boots most of the time.

Powering the board from USB does result in the board booting most of the time.

I have been using plain text firmware sb files and loading these in to the K82F using the K82F ROM KBOOT. Changing to Encrypted firmware SB file, the processor boots and runs the application irrelevant of the number of NOP's.

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?

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:

Will the processor boot after programming the firmware?

Will the processor boot after pressing SW1 with serial dongle connected?

Will the processor boot after pressing SW1 without serial dongle connected?

Will the processor boot after power cycling with serial dongle connected?

Will the processor boot after power cyclingwithout serial dongle connected?

Observations:

1 Will the processor boot after programming the firmware:

Depending on the number of NOPs added to the code, either the processor would boot or not.

Sometimes the processor would boot using the non-encrypted and would not boot using the encrypted version of firmware using the same number of NOPs.

Sometimes the processor would not boot using the non-encrypted and would boot using the encrypted version of firmware using the same number of NOPs.

Sometimes the processor would boot using the non-encrypted and would boot using the encrypted version of firmware using the same number of NOPs.

Sometimes the processor would not boot using the non-encrypted and would not boot using the encrypted version of firmware using the same number of NOPs.

If the processor did not boot, removing the serial programming cable and touching the Rx pin of UART1 would make the processor boot.

When to processor did not boot, it was observed that the RESET Pin strobes every 2.5 seconds for 100us.

2 Will the processor boot after pressing SW1 with serial dongle connected?

The result of this test was the same as observation 1

3 Will the processor boot after pressing SW1 without serial dongle connected?

The result of this test was the same as observation 1

4 Will the processor boot after power cycling with serial dongle connected?

The result of this test was the same as observation 1

5 Will the processor boot after power cycling without serial dongle connected?

The result of this test showed that irrespective of if the firmware was encrypted or not encrypted, and irrelevant of the number of NOP's, the processor would not boot if the power was cycled with the serial dongle not connected. The processor would enter the bootloader state where by reconnecting the serial dongle, blhost can communicate with the bootloader.

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.

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.