/** @(#)bootldrstart.c <18-Nov-2015 08:13:50 bob p> * \date Last Time-stamp: <11-Jun-2019 11:19:57 bob p> * * \file bootldrstart.c * \brief Jump to Boot Loader. * * Note: * You may not even convert a void * to a function pointer by * explicit casting (6.3.2.3|1). * * C's abstract machine does not assume that code and data are * addressed the same way, so as far as C is concerned function * pointers and data pointers have nothing to do with each other * (they could have different widths). */ /*lint -save */ #include "includes.h" #include "reset_mcu.h" #define DEFINE_SPACE_BOOTLDRSTART_H (1) #include "bootldrstart.h" /* * With the Watchdog enabled it is impossible to jump to the * Bootloader (think about it) so must get there via reset. */ #if 0 /* Function Pointer returning void, passed void pointer: */ void (*_boot_loader_start)( void * arg ); void boot_loader_start( void ) { /* Read the function address from the ROM API tree: */ uint32_t const _boot_loader_start_address = **(uint32_t **)(0x1C00001CUL); /* Turn address in to a function pointer: */ _boot_loader_start = (void (*)(void * arg))_boot_loader_start_address; _boot_loader_start( NULL ); /* Call the function. Will not return from here */ for(;;) /* Pacify the compiler about returning from a no return function */ ; } #endif 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 */ ; }