mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sys/riotboot: move magic address to common file
This commit is contained in:
parent
a82d4e6683
commit
cabe639d04
@ -14,7 +14,7 @@ At startup, the DFU mode is entered when either
|
|||||||
|
|
||||||
- the first button was pressed when the board started (configurable at board level using @ref BTN_BOOTLOADER_PIN), or
|
- the first button was pressed when the board started (configurable at board level using @ref BTN_BOOTLOADER_PIN), or
|
||||||
|
|
||||||
- the last running firmware asked the bootloader to go to DFU mode by using a magic number (see @ref RIOTBOOT_DFU_ADDR).
|
- the last running firmware asked the bootloader to go to DFU mode by using a magic number (see @ref RIOTBOOT_MAGIC_ADDR).
|
||||||
|
|
||||||
# Prerequisites
|
# Prerequisites
|
||||||
|
|
||||||
|
47
sys/include/riotboot/magic.h
Normal file
47
sys/include/riotboot/magic.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2020 Mesotic SAS
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup sys_riotboot_magic Magic values for riotboot
|
||||||
|
* @ingroup sys
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief USB DFU/serial initialization constants for riotboot
|
||||||
|
*
|
||||||
|
* @author Dylan Laduranty <dylan.laduranty@mesotic.com>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef RIOTBOOT_MAGIC_H
|
||||||
|
#define RIOTBOOT_MAGIC_H
|
||||||
|
|
||||||
|
#include "riotboot/hdr.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name USB RAM information for riotboot
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
#ifndef RIOTBOOT_MAGIC_ADDR
|
||||||
|
#define RIOTBOOT_MAGIC_ADDR (CPU_RAM_BASE + CPU_RAM_SIZE - 4) /**< default magic address */
|
||||||
|
#endif
|
||||||
|
#ifndef RIOTBOOT_MAGIC_NUMBER
|
||||||
|
#define RIOTBOOT_MAGIC_NUMBER RIOTBOOT_MAGIC /**< default magic value */
|
||||||
|
#endif
|
||||||
|
/** @} */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* RIOTBOOT_MAGIC_H */
|
@ -29,18 +29,6 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
|
||||||
* @name USB DFU RAM information for riotboot
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
#ifndef RIOTBOOT_DFU_ADDR
|
|
||||||
#define RIOTBOOT_DFU_ADDR (CPU_RAM_BASE + CPU_RAM_SIZE - 4) /**< DFU default magic address */
|
|
||||||
#endif
|
|
||||||
#ifndef RIOTBOOT_MAGIC_NUMBER
|
|
||||||
#define RIOTBOOT_MAGIC_NUMBER RIOTBOOT_MAGIC /**< DFU default magic value */
|
|
||||||
#endif
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @name USB DFU Default slots name
|
* @name USB DFU Default slots name
|
||||||
* @{
|
* @{
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "usb/usbus.h"
|
#include "usb/usbus.h"
|
||||||
#include "usb/dfu.h"
|
#include "usb/dfu.h"
|
||||||
#include "usb/usbus/dfu.h"
|
#include "usb/usbus/dfu.h"
|
||||||
|
#include "riotboot/magic.h"
|
||||||
#include "riotboot/usb_dfu.h"
|
#include "riotboot/usb_dfu.h"
|
||||||
|
|
||||||
static usbus_dfu_device_t dfu;
|
static usbus_dfu_device_t dfu;
|
||||||
@ -32,7 +33,7 @@ static usbus_t usbus;
|
|||||||
|
|
||||||
void riotboot_usb_dfu_init(unsigned forced)
|
void riotboot_usb_dfu_init(unsigned forced)
|
||||||
{
|
{
|
||||||
uint32_t *reset_addr = (uint32_t *)RIOTBOOT_DFU_ADDR;
|
uint32_t *reset_addr = (uint32_t *)RIOTBOOT_MAGIC_ADDR;
|
||||||
|
|
||||||
if (forced == 1 || *reset_addr == RIOTBOOT_MAGIC_NUMBER) {
|
if (forced == 1 || *reset_addr == RIOTBOOT_MAGIC_NUMBER) {
|
||||||
*reset_addr = 0;
|
*reset_addr = 0;
|
||||||
|
@ -23,13 +23,13 @@ config USB_DFU_DETACH_TIMEOUT_MS
|
|||||||
the host USB. Host USB should abort the pending operation if
|
the host USB. Host USB should abort the pending operation if
|
||||||
device doesn't detach after this timeout.
|
device doesn't detach after this timeout.
|
||||||
|
|
||||||
config CUSTOM_RIOTBOOT_DFU_ADDR
|
config CUSTOM_RIOTBOOT_MAGIC_ADDR
|
||||||
bool "Use custom DFU magic address"
|
bool "Use custom DFU magic address"
|
||||||
help
|
help
|
||||||
Say n to use the default address, which is the last in RAM.
|
Say n to use the default address, which is the last in RAM.
|
||||||
|
|
||||||
config RIOTBOOT_DFU_ADDR
|
config RIOTBOOT_MAGIC_ADDR
|
||||||
int "DFU magic address"
|
int "DFU magic address"
|
||||||
depends on CUSTOM_RIOTBOOT_DFU_ADDR
|
depends on CUSTOM_RIOTBOOT_MAGIC_ADDR
|
||||||
|
|
||||||
endif # KCONFIG_USEMODULE_USBUS_DFU
|
endif # KCONFIG_USEMODULE_USBUS_DFU
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include "usb/usbus.h"
|
#include "usb/usbus.h"
|
||||||
#include "usb/usbus/control.h"
|
#include "usb/usbus/control.h"
|
||||||
#include "usb/usbus/dfu.h"
|
#include "usb/usbus/dfu.h"
|
||||||
|
#include "riotboot/magic.h"
|
||||||
#include "riotboot/usb_dfu.h"
|
#include "riotboot/usb_dfu.h"
|
||||||
#ifdef MODULE_RIOTBOOT_USB_DFU
|
#ifdef MODULE_RIOTBOOT_USB_DFU
|
||||||
#include "xtimer.h"
|
#include "xtimer.h"
|
||||||
@ -169,7 +170,7 @@ static void _dfu_class_control_req(usbus_t *usbus, usbus_dfu_device_t *dfu, usb_
|
|||||||
/* Detach USB bus */
|
/* Detach USB bus */
|
||||||
usbdev_set(usbus->dev, USBOPT_ATTACH, &disable, sizeof(usbopt_enable_t));
|
usbdev_set(usbus->dev, USBOPT_ATTACH, &disable, sizeof(usbopt_enable_t));
|
||||||
/* Restart and jump into the bootloader */
|
/* Restart and jump into the bootloader */
|
||||||
uint32_t *reset_addr = (uint32_t *)RIOTBOOT_DFU_ADDR;
|
uint32_t *reset_addr = (uint32_t *)RIOTBOOT_MAGIC_ADDR;
|
||||||
*reset_addr = RIOTBOOT_MAGIC_NUMBER;
|
*reset_addr = RIOTBOOT_MAGIC_NUMBER;
|
||||||
pm_reboot();
|
pm_reboot();
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user