armcm_reset: support canboot detection
When CanBoot is detected set its bypass signature when a reset is requested. Add a "try_request_canboot()" method that may be called from from USB and Canbus bootloader requests. Signed-off-by: Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
parent
04eb72dcd5
commit
8b1e3c3fb2
|
@ -6,10 +6,42 @@
|
|||
|
||||
#include "board/internal.h" // NVIC_SystemReset
|
||||
#include "command.h" // DECL_COMMAND_FLAGS
|
||||
#include "autoconf.h" // CONFIG_FLASH_START
|
||||
#include "irq.h" // irq_disable
|
||||
|
||||
#define CANBOOT_SIGNATURE 0x21746f6f426e6143
|
||||
#define CANBOOT_REQUEST 0x5984E3FA6CA1589B
|
||||
#define CANBOOT_BYPASS 0x7b06ec45a9a8243d
|
||||
|
||||
static void
|
||||
canboot_reset(uint64_t req_signature)
|
||||
{
|
||||
if (!(CONFIG_FLASH_START & 0x00FFFFFF))
|
||||
// No bootloader
|
||||
return;
|
||||
uint32_t *bl_vectors = (uint32_t *)(CONFIG_FLASH_START & 0xFF000000);
|
||||
uint64_t *boot_sig = (uint64_t *)(bl_vectors[1] - 9);
|
||||
uint64_t *req_sig = (uint64_t *)bl_vectors[0];
|
||||
if (boot_sig == (void *)ALIGN((size_t)boot_sig, 8) &&
|
||||
*boot_sig == CANBOOT_SIGNATURE &&
|
||||
req_sig == (void *)ALIGN((size_t)req_sig, 8))
|
||||
{
|
||||
irq_disable();
|
||||
*req_sig = req_signature;
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
try_request_canboot(void)
|
||||
{
|
||||
canboot_reset(CANBOOT_REQUEST);
|
||||
}
|
||||
|
||||
void
|
||||
command_reset(uint32_t *args)
|
||||
{
|
||||
canboot_reset(CANBOOT_BYPASS);
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
DECL_COMMAND_FLAGS(command_reset, HF_IN_SHUTDOWN, "reset");
|
||||
|
|
Loading…
Reference in New Issue