rioboot: add option to reset to riotboot
This commit is contained in:
parent
cabe639d04
commit
a05723e5cb
@ -625,10 +625,15 @@ endif
|
||||
ifneq (,$(filter riotboot_serial, $(USEMODULE)))
|
||||
FEATURES_REQUIRED += periph_flashpage
|
||||
FEATURES_REQUIRED += periph_uart
|
||||
USEMODULE += riotboot
|
||||
USEMODULE += riotboot_reset
|
||||
USEMODULE += checksum
|
||||
endif
|
||||
|
||||
ifneq (,$(filter riotboot_reset, $(USEMODULE)))
|
||||
USEMODULE += riotboot
|
||||
USEMODULE += usb_board_reset
|
||||
endif
|
||||
|
||||
ifneq (,$(filter riotboot_hdr, $(USEMODULE)))
|
||||
USEMODULE += checksum
|
||||
USEMODULE += riotboot
|
||||
|
||||
@ -141,7 +141,7 @@ ifneq (,$(filter prng,$(USEMODULE)))
|
||||
include $(RIOTBASE)/sys/random/Makefile.include
|
||||
endif
|
||||
|
||||
ifneq (,$(filter usbus_dfu,$(USEMODULE)))
|
||||
ifneq (,$(filter usbus_dfu riotboot_reset,$(USEMODULE)))
|
||||
CFLAGS += -DCPU_RAM_BASE=$(RAM_START_ADDR)
|
||||
CFLAGS += -DCPU_RAM_SIZE=$(RAM_LEN)
|
||||
endif
|
||||
|
||||
32
sys/riotboot/reset.c
Normal file
32
sys/riotboot/reset.c
Normal file
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Benjamin Valentin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser General
|
||||
* Public License v2.1. See the file LICENSE in the top level directory for more
|
||||
* details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup sys_riotboot_serial
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
* @brief Trigger reset to riotboot.
|
||||
*
|
||||
* @author Benjamin Valentin <benpicco@googlemail.com>
|
||||
* @}
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "periph/pm.h"
|
||||
#include "riotboot/magic.h"
|
||||
|
||||
__attribute__((weak))
|
||||
void usb_board_reset_in_bootloader(void)
|
||||
{
|
||||
uint32_t *magic = (void *)(uintptr_t)RIOTBOOT_MAGIC_ADDR;
|
||||
|
||||
irq_disable();
|
||||
*magic = RIOTBOOT_MAGIC;
|
||||
pm_reboot();
|
||||
}
|
||||
@ -27,6 +27,7 @@
|
||||
#include "unaligned.h"
|
||||
#include "checksum/crc8.h"
|
||||
#include "riotboot/serial.h"
|
||||
#include "riotboot/magic.h"
|
||||
|
||||
#include "board.h"
|
||||
|
||||
@ -55,6 +56,13 @@ static inline void uart_write_byte(uart_t uart, uint8_t data)
|
||||
/* send 'hello' byte until we get enter bootloader byte or timeout */
|
||||
static bool _bootdelay(unsigned tries, volatile bool *boot_default)
|
||||
{
|
||||
uint32_t *magic = (void *)(uintptr_t)RIOTBOOT_MAGIC_ADDR;
|
||||
|
||||
if (*magic == RIOTBOOT_MAGIC) {
|
||||
*magic = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (tries == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user