I have avoided the new internal loaders (disabling it so that it can't impact). Unless one is using the smallest chip where there wouldn't be enough space to keep a boot loader I don't consider the internal ones as beneficial:
- a bed of nails in production to the SWD and a good programming software is more practical
- in the field USB-MSD is 'by-far' the best updating method (rather than the USB-HID that the internal loader uses)
We differ there. Been using the bed of nails or getting the chips programmed by distributor in other products
May be a difference in quantity?
In some product lines we are doing 80,000 units per year.
Any built in bootloader is a benefit to us even if it is to just load our own bootloader.
Do you know of any KL43/KL27 Bare Metal USB-MSD bootloaders?
As to my original question:
In "6.3.3 Boot sequence" of the KL27RM it says that if BOOTPIN_OPT=0 then boot from ROM is forced.
To me that says that if BOOTCFG0 (NMI)# is not asserted then my code in flash will run.
Sadly that is not always the case.
With FOPT set thus:
[I'll also be really ticked if the forum software once again hoses my code. :-(]
/*
* FOPT:
* 7:BOOTSRC_SEL1 0x80U
* 6:BOOTSRC_SEL0 0x40U
* 00 = Flash, 01 = Reserved, 10/11 = ROM
*
* 5:NV_FOPT_FAST_INIT_MASK 0x20U
* 1 = Fast
*
* 4:NV_FOPT_LPBOOT1_MASK 0x10U
* See bit zero
*
* 3:NV_FOPT_RESET_PIN_CFG_MASK 0x08U
* 0 = Disabled Reset.
*
* 2:V_FOPT_NMI_DIS_MASK 0x04U
* 0 = Disable NMI
*
* 1:BOOTPIN_OPT 0x02U
* 0 = Force boot from ROM if BOOTCFG0 asserted.
*
* 0:NV_FOPT_LPBOOT0_MASK 0x01u
* 00 /8 VLPR on exit reset
* 01 /4 VLPR on exit reset
* 10 /2 RUN on exit
* 11 /1 RUN on exit
*
*/
0x38U, /**< Non-volatile Flash Option Register, offset: 0xD NV_FOPT Disable NMI pin. Boot from Flash not ROM */
At each reset the part still goes into the ROM bootloader after bootloading and after BOOTCFG0# has been set high before reseting.
I expect the part to just jump to my code when BOOTCFG0# is high at *ANY* reset.
What have I missed?
I added this to my vectors.c to get it to work after the initial reset after boot.
Still have to endure the five second wait after the software update. :-(
/*
* 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.
*/
if( 0U != (RCM_MR & RCM_FM_FORCEROM_MASK) )
{
RCM_FM = 0U;
RCM_MR = RCM_MR_BOOTROM_MASK;
}
To me it really seems like the chip did not read the documentation...