Hello,
I'm working on a MKE18F ROM Bootloader project with MCUXpresso IDE. In this project I try to configure the Bootloader in order to update the μC firmware via CANbus.
During my test I solved some issues that have appeared and I updated the firmware successfully through UART and CANbus.
But there are some issues that may cause our system to "lock-up"/brick. To solve this, we need our system to enter the ROM Bootloader when exiting from any reset, and also we want it to exit the Bootloader after a defined timeout. (At the end, we would like to generate a .bin file that contains the Bootloader configuration (BCA); is there any chance to configure the BCA when programming the μC through a debugger that does not require modifying the Linker file?)
But now I am trying to solve some potential problems and... surprise! I discovered that I can't exit the Bootloader using peripheral detection timeout, and also it doesn't entry after reset (Software reset or Reset_b Pin).
I know I can't pretend to use timeout if I entered the Boot ROM with the API tree.
I have tried the next configurations:
1.- Enter at Start-up Process & Timeout exit:
1.1.- FOPT [7] is set to 1
"FOPT [7] is set to 1. This forces the ROM to run out of reset:"
__attribute__ ((used,section(".FlashConfig"))) const struct {
unsigned int word1;
unsigned int word2;
unsigned int word3;
unsigned int word4;
} Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFE};
These code lines can be found in the startup_mke18f16.c file.
The information about FOPT register is in these tables (FOPT address and FOPT register) in the KE1xFP100M168SF0RM document:


When I use this configuration, the MCU enters the Bootloader and I can establish communication via CANbus. But if I don't communicate and I let the five seconds pass (default config), it times-out and resets, but it enters the Bootloader over and over instead of jumping to flash user application. We can see the "timeout and reset every 5 seconds" in these oscilloscope captures:


1.2.- BOOTCFG() pin is asserted
"The pin must be configured as BOOTCFG0 by setting the BOOTPIN_OPT bit of FOPT to 0."
__attribute__ ((used,section(".FlashConfig"))) const struct {
unsigned int word1;
unsigned int word2;
unsigned int word3;
unsigned int word4;
} Flash_Config = {0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFF7DFE};
The information about BOOTCFG0 configuration is in this table in the KE1xFP100M168SF0RM document:

When I use this configuration, I force the BOOTCFG0 pin to GND then I power-on MCU. The MCU enters the Bootloader successfully but timeout is disabled, after five seconds pass it doesn't timeout. I don't know why this is happening, BCA has the default configuration. But nevertheless when I do a reset through the reset_b pin, it enters the Bootloader again but now, after five seconds, it times-out, resets and jumps into the flash user application (desired behaviour).
We keep in mind the next two flow chars and I think the problem is the two conditional blocks before "Disable Timeout" detection (in Figure 23-2- Kinetis bootloader Start-up Flowchart). We don't know what "Is user application valid?" block is checking.


I have tried these configurations segmenting the flash memory in order to add a manually configured BCA. After setting up the Linker file, the result has been the same. Both projects are attached at the end of the post (Bootloader_KE18f_Projects.zip).
I hope you can help me, thanks a lot in advance! 
Links:
https://www.nxp.com/docs/en/data-sheet/KL17P64M48SF2.pdf
https://www.nxp.com/docs/en/data-sheet/KE1xFP100M168SF0.pdf
Getting Started: ROM Bootloader on the NXP FRDM-KL03Z Board | MCU on Eclipse