Hi
This technique is foreseen using the "BOOT_MAIL_BOX"
Example:
#define FORCE_BOOT() ((_READ_PORT_MASK(A, SWITCH_1) != 0) || (((SIM_SRSID & SIM_SRSID_SW) != 0) && (*(BOOT_MAIL_BOX) == RESET_TO_SERIAL_LOADER)))Either the standard GPIO input can be used to reset to the loader or else the application can write the value
RESET_TO_SERIAL_LOADER (0x89ac) to the BOOT_MAIL_BOX location (
#define BOOT_MAIL_BOX (unsigned short *)(RAM_START_ADDRESS + (SIZE_OF_RAM - 2))) and command a reset (using
fnResetBoard() - this is the Cortex System Reset command). The second is only recognised when it
was a reset command (SIM_SRSID is the "System reset and Status ID" register in the KE06 and SIM_SRSID_SW is set after a reset that was commanded as such). Note that the mailbox value is always cleared so that it can only be detected once (the line
_DELETE_BOOT_MAILBOX();).
You will note that the application (and loader) don't set the stack pointer to the top of SRAM but instead leave some space for such variables that are preserved across resets. This space is never used for anything else.
See kinetis.c:
const _RESET_VECTOR __vector_table
(void *)(RAM_START_ADDRESS + (SIZE_OF_RAM - NON_INITIALISED_RAM_SIZE)), // stack pointer to top of RAM
(void (*)(void))START_CODE, // start address
}The locations that are presently reserved are:
#define BOOT_MAIL_BOX (unsigned short *)(RAM_START_ADDRESS + (SIZE_OF_RAM - 2))
#define RANDOM_SEED_LOCATION (unsigned short *)(RAM_START_ADDRESS + (SIZE_OF_RAM - 4)) location of a short word which is never initialised and so has a random power on value
#define RTC_SECONDS_LOCATION (unsigned long *)(RAM_START_ADDRESS + (SIZE_OF_RAM - )
#define RTC_ALARM_LOCATION (unsigned long *)(RAM_START_ADDRESS + (SIZE_OF_RAM - 12))
#define RTC_VALID_LOCATION (unsigned short *)(RAM_START_ADDRESS + (SIZE_OF_RAM - 14))
#define RTC_PRESCALER_LOCATION (unsigned short *)(RAM_START_ADDRESS + (SIZE_OF_RAM - 16))and users can extend this with custom ones by adding a define called
PERSISTENT_RAM_SIZE with the additional space required.
If you try this technique (make the change in the
FORCE_BOOT() define and use *(BOOT_MAIL_BOX) and fnResetBoard() in the application) you should find that it solves all of the issues.
You are right about the mistake with the input that disables the watchdog! On the diagram this connector pin has the name PTG3_GPIO4. I think that the GPIO4 that they added to the name caused confusion.... I changed the pin on the FRDM-KE06Z page to J5-2 so that it matches with the reference SW there.
I don't know why the connectors were used for these functions and not the board's switches (the switches are usually used). Your changes are however good if these are preferred!
Regards
Mark