I've done a lot of work with the MKL27 and its bootloader.
I have never encountered any 'timeout' and have never seen any documentation to enable such a timeout.
You really want to design your hardware so that asserting the BOOT pin gets you into the ROM bootloader of the chip. Not doing it this way can lead to bricking devices that then must be recovered using a SWD programming pod, such as J-Link or PE FX (which I use).
Place this code in your startup code in vectors.c (I've attached mine as example. This is the code executed right out of reset) or equivalent, the comments explain why:
static void vectors_bootloader_mr_setup( void ) __attribute__( ( used, __aligned__( 4U ), section( ".after_vectors" ) ) );
static void vectors_bootloader_mr_setup( void )
{
/*
* RCM_MR Indicates the boot source, the boot source remains set
* until the next System Reset or software can write logic one to
* clear the corresponding mode bit. While either bit is set the
* NMI input is disabled and the vector table is relocated to the
* ROM base address at 0x1C00_0000. These bits should be cleared by
* writing logic one before executing any code from either Flash or
* SRAM.
*
* A reset is forced to clear out anything that the ROM
* bootloader did, so we are sure we have the data sheet reset
* values.
* This method works around the buggy KL43/27/17 bootloaders as
* described in: "Problem Analysis and solutions for booting from
* ROM BOOTLOADER in KL series".
*/
if( 0U != ( RCM_MR & RCM_MR_BOOTROM_MASK ) )
{
RCM_MR = RCM_MR_BOOTROM_MASK; /* Clear the bits that indicated a bootloader boot via ROM */
RCM_FM = 0U; /* Boot from Flash not ROM on next reset */
SCB_AIRCR = ( SCB_AIRCR_VECTKEY( 0x05FAU ) | SCB_AIRCR_SYSRESETREQ_MASK ); /* Force a Software Reset */
}
}
This code when called from the application will force the bootloader to start, which answers your question about when to use RCM_FM. It is not a configuration thing nor directly related to the BOOT pin.
void __attribute__ ((noreturn)) reset_mcu( void )
{
/*
* A DSB is required before generating self-reset to ensure all
* outstanding transfers are completed. The use of the CPSID I
* instruction is optional.
*/
irq_disable();
sync_barrier_data();
SCB_AIRCR = (SCB_AIRCR_VECTKEY(0x05FAU) | SCB_AIRCR_SYSRESETREQ_MASK);
for(;;)
{
;
}
}
void boot_loader_start( void )
{
RCM_FM = RCM_FM_FORCEROM_MASK; /* Force next reset to jump to Bootloader ROM, */
reset_mcu(); /* now be the next reset */
for(;;) /* Pacify the compiler about returning from a no return function */
;
}
As I said previously, don't use I2C for the bootloader because the parts with double buffered I2C do not handle repeated start correctly. Use serial port or USB. See the KL27 manual for which specific serial port works with the bootloader.