1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

b/c/particle-mesh: Add and enable usb_board_reset in monofirmware mode

This commit is contained in:
chrysn 2020-11-06 12:54:38 +01:00
parent 7582be6d5e
commit 51d4b6c7ff
3 changed files with 56 additions and 0 deletions

View File

@ -2,5 +2,9 @@ ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif
ifeq (1,$(PARTICLE_MONOFIRMWARE))
USEMODULE += usb_board_reset
endif
# include common nrf52 dependencies
include $(RIOTBOARD)/common/nrf52/Makefile.dep

View File

@ -18,6 +18,10 @@ ifeq (1,$(PARTICLE_MONOFIRMWARE))
FFLAGS = -d 0x2B04:0xD00E -a 0 -s 0x30000:leave -D $(FLASHFILE)
PROGRAMMER = dfu-util
include $(RIOTMAKE)/tools/dfu.inc.mk
# If CDC-ACM is *not* enabled, any pre-flash resets will just not work -- but
# then again nothing can be done in that case anyway, and the preflash
# routines fall through without erring.
include $(RIOTMAKE)/tools/usb_board_reset.mk
else
# This board uses a DAP-Link programmer
# Flashing support is provided through pyocd (default) and openocd.

View File

@ -0,0 +1,48 @@
/*
* Copyright (C) 2020 Christian Amsüss
*
* 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.
*/
/**
* @{
*
* @brief Management of bootloader resets
*
* This implements a reset procedure read from the code of the particle device
* OS at https://github.com/particle-iot/device-os/ (version
* c21d5b8f39c8a013e19f904800808673f369c6e3), primarily from
* hal/inc/syshealth_hal.h and its linker script.
*
* @file
* @author Christian Amsüss <chrysn@fsfe.org>
*
* @}
*/
#include <stdint.h>
#include "cpu.h"
/* from the eSystemHealth definition of hal/inc/syshealth_hal.h */
#define ENTER_DFU_APP_REQUEST (0xEDFA)
/* Start of the backup registers as per
* build/arm/linker/nrf52840/platform_ram.ld and hal/src/nRF52840/core_hal.c */
#define BACKUP_REGISTERS ((volatile int32_t*)0x2003f380)
void usb_board_reset_in_bootloader(void)
{
/* This *is* a write into an arbitrary memory location -- as RIOT does not
* use any of the Particle system interrupt handlers any more, it's not
* abiding by its RAM layout either. The write immediately preceding the
* reboot should not have any effect on being-restarted system, but leaves
* the flag in memory for the starting-up system to introspect.
* */
BACKUP_REGISTERS[0] = ENTER_DFU_APP_REQUEST;
/* Going with a hard reset rather than a pm_off, as that might be altered
* to do *anything* -- which is not safe any more now that we've forsaken
* the RAM content */
NVIC_SystemReset();
}