mirror of
https://github.com/oltaco/Adafruit_nRF52_Bootloader_OTAFIX.git
synced 2026-10-24 08:34:21 +00:00
clean up
This commit is contained in:
3 files changed
+133
-39
No files matched your search
@@ -0,0 +1,99 @@
|
||||
---
|
||||
Language: Cpp
|
||||
BasedOnStyle: LLVM
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: false
|
||||
AcrossComments: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: true
|
||||
AcrossComments: false
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: true
|
||||
AcrossEmptyLines: true
|
||||
AcrossComments: true
|
||||
AlignCaseColons: false
|
||||
AlignEscapedNewlines: LeftWithLastLine
|
||||
AlignOperands: true
|
||||
AlignTrailingComments:
|
||||
Kind: Always
|
||||
OverEmptyLines: 2
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllConstructorInitializersOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: Empty
|
||||
AllowShortCaseExpressionOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AlwaysBreakTemplateDeclarations: Yes
|
||||
BinPackArguments: true
|
||||
BreakBeforeBraces: Custom
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: false
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: false
|
||||
AfterNamespace: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
AfterExternBlock: false
|
||||
BeforeCatch: true
|
||||
BeforeElse: false
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BracedInitializerIndentWidth: 2
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakConstructorInitializers: AfterColon
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
ContinuationIndentWidth: 2
|
||||
ColumnLimit: 120
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
Cpp11BracedListStyle: true
|
||||
IncludeBlocks: Preserve
|
||||
IncludeCategories:
|
||||
- Regex: '^<.*'
|
||||
Priority: 1
|
||||
- Regex: '^".*'
|
||||
Priority: 2
|
||||
- Regex: '.*'
|
||||
Priority: 3
|
||||
IncludeIsMainRegex: '([-_](test|unittest))?$'
|
||||
IndentPPDirectives: BeforeHash
|
||||
InsertBraces: true
|
||||
IndentCaseLabels: true
|
||||
InsertNewlineAtEOF: true
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: All
|
||||
PenaltyBreakBeforeFirstCallParameter: 1000000
|
||||
PenaltyBreakOpenParenthesis: 1000000
|
||||
PPIndentWidth: 2
|
||||
QualifierAlignment: Custom
|
||||
QualifierOrder: ['static', 'const', 'volatile', 'restrict', 'type']
|
||||
SpaceAfterTemplateKeyword: false
|
||||
SpaceBeforeRangeBasedForLoopColon: false
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesInAngles: false
|
||||
SpacesInConditionalStatement: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SortIncludes: false
|
||||
TabWidth: 2
|
||||
...
|
||||
@@ -137,7 +137,7 @@ make BOARD=feather_nrf52840_express all
|
||||
For the list of supported boards, run `make` without `BOARD=` :
|
||||
|
||||
```
|
||||
$ make
|
||||
make
|
||||
You must provide a BOARD parameter with 'BOARD='
|
||||
Supported boards are: feather_nrf52840_express feather_nrf52840_express pca10056
|
||||
Makefile:90: *** BOARD not defined. Stop
|
||||
@@ -213,7 +213,7 @@ make BOARD=feather_nrf52840_express flash-mbr
|
||||
If you get the following error ...
|
||||
|
||||
```
|
||||
$ make BOARD=feather_nrf52840_express all
|
||||
make BOARD=feather_nrf52840_express all
|
||||
Compiling file: main.c
|
||||
/bin/sh: /usr/bin/arm-none-eabi-gcc: No such file or directory
|
||||
make: *** [_build/main.o] Error 127
|
||||
@@ -222,7 +222,7 @@ make: *** [_build/main.o] Error 127
|
||||
... you may need to pass the location of the GCC ARM toolchain binaries to `make` using
|
||||
the variable `CROSS_COMPILE` as below:
|
||||
```
|
||||
$ make CROSS_COMPILE=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- BOARD=feather_nrf52832 all
|
||||
make CROSS_COMPILE=/opt/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi- BOARD=feather_nrf52832 all
|
||||
```
|
||||
|
||||
For other compile errors, check the gcc version with `arm-none-eabi-gcc --version` to insure it is at least 9.x.
|
||||
|
||||
+31
-36
@@ -39,13 +39,8 @@
|
||||
#include <stddef.h>
|
||||
|
||||
#include "nrfx.h"
|
||||
#include "nrf_clock.h"
|
||||
#include "nrfx_power.h"
|
||||
#include "nrfx_pwm.h"
|
||||
|
||||
#include "nordic_common.h"
|
||||
#include "sdk_common.h"
|
||||
#include "dfu_transport.h"
|
||||
#include "bootloader.h"
|
||||
#include "bootloader_util.h"
|
||||
|
||||
@@ -53,10 +48,7 @@
|
||||
#include "nrf_soc.h"
|
||||
#include "nrf_nvic.h"
|
||||
#include "app_error.h"
|
||||
#include "nrf_gpio.h"
|
||||
#include "ble.h"
|
||||
#include "nrf.h"
|
||||
#include "ble_hci.h"
|
||||
#include "app_scheduler.h"
|
||||
#include "nrf_error.h"
|
||||
|
||||
@@ -64,13 +56,10 @@
|
||||
|
||||
#include "pstorage_platform.h"
|
||||
#include "nrf_mbr.h"
|
||||
#include "pstorage.h"
|
||||
#include "nrfx_nvmc.h"
|
||||
|
||||
#ifdef NRF_USBD
|
||||
|
||||
#include "uf2/uf2.h"
|
||||
#include "nrf_usbd.h"
|
||||
#include "tusb.h"
|
||||
|
||||
void usb_init(bool cdc_only);
|
||||
@@ -250,14 +239,17 @@ static void check_dfu_mode(void) {
|
||||
(((*dbl_reset_mem) == DFU_DBL_RESET_MAGIC) && reason_reset_pin);
|
||||
|
||||
// Clear GPREGRET if it is our values
|
||||
if (dfu_start || dfu_skip) NRF_POWER->GPREGRET = 0;
|
||||
if (dfu_start || dfu_skip) {
|
||||
NRF_POWER->GPREGRET = 0;
|
||||
}
|
||||
|
||||
// skip dfu entirely
|
||||
if (dfu_skip) return;
|
||||
if (dfu_skip) {
|
||||
return;
|
||||
}
|
||||
|
||||
/*------------- Determine DFU mode (Serial, OTA, FRESET or normal) -------------*/
|
||||
// DFU button pressed
|
||||
dfu_start = dfu_start || button_pressed(BUTTON_DFU);
|
||||
dfu_start = dfu_start || button_pressed(BUTTON_DFU); // DFU button pressed
|
||||
|
||||
// DFU + FRESET are pressed --> OTA
|
||||
_ota_dfu = _ota_dfu || (button_pressed(BUTTON_DFU) && button_pressed(BUTTON_FRESET));
|
||||
@@ -265,16 +257,16 @@ static void check_dfu_mode(void) {
|
||||
bool const valid_app = bootloader_app_is_valid();
|
||||
bool const just_start_app = valid_app && !dfu_start && (*dbl_reset_mem) == DFU_DBL_RESET_APP;
|
||||
|
||||
if (!just_start_app && APP_ASKS_FOR_SINGLE_TAP_RESET()) dfu_start = 1;
|
||||
if (!just_start_app && APP_ASKS_FOR_SINGLE_TAP_RESET()) {
|
||||
dfu_start = 1;
|
||||
}
|
||||
|
||||
// App mode: Double Reset detection or DFU startup for nrf52832
|
||||
if (!(just_start_app || dfu_start || !valid_app)) {
|
||||
#ifdef NRF52832_XXAA
|
||||
/* Even DFU is not active, we still force an 1000 ms dfu serial mode when startup
|
||||
* to support auto programming from Arduino IDE
|
||||
*
|
||||
* Note: Double Reset WONT work with nrf52832 since all its SRAM got cleared with GPIO reset.
|
||||
*/
|
||||
* Note: Double Reset WONT work with nrf52832 since all its SRAM got cleared with GPIO reset. */
|
||||
bootloader_dfu_start(false, DFU_SERIAL_STARTUP_INTERVAL, false);
|
||||
#else
|
||||
// Note: RESETREAS is not clear by bootloader, it should be cleared by application upon init()
|
||||
@@ -323,6 +315,10 @@ static void check_dfu_mode(void) {
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// BLE
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
// Initializes the SoftDevice by following SD specs section
|
||||
// "Master Boot Record and SoftDevice initializaton procedure"
|
||||
static uint32_t ble_stack_init(void) {
|
||||
@@ -389,23 +385,6 @@ static uint32_t ble_stack_init(void) {
|
||||
return NRF_SUCCESS;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Error Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) {
|
||||
volatile uint32_t* ARM_CM_DHCSR = ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */
|
||||
if ((*ARM_CM_DHCSR) & 1UL) __asm("BKPT #0\n"); /* Only halt mcu if debugger is attached */
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void assert_nrf_callback(uint16_t line_num, uint8_t const* p_file_name) {
|
||||
app_error_fault_handler(0xDEADBEEF, 0, 0);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* SoftDevice Event handler
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
// Process BLE event from SD
|
||||
uint32_t proc_ble(void) {
|
||||
__ALIGN(4) uint8_t ev_buf[BLE_EVT_LEN_MAX(BLEGATT_ATT_MTU_MAX)];
|
||||
@@ -479,6 +458,22 @@ void SD_EVT_IRQHandler(void) {
|
||||
app_sched_event_put(NULL, 0, proc_sd_task);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Error Handler
|
||||
//--------------------------------------------------------------------+
|
||||
void app_error_fault_handler(uint32_t id, uint32_t pc, uint32_t info) {
|
||||
volatile uint32_t *ARM_CM_DHCSR = ((volatile uint32_t *)0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */
|
||||
if ((*ARM_CM_DHCSR) & 1UL) {
|
||||
__asm("BKPT #0\n"); /* Only halt mcu if debugger is attached */
|
||||
}
|
||||
NVIC_SystemReset();
|
||||
}
|
||||
|
||||
void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name) {
|
||||
app_error_fault_handler(0xDEADBEEF, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// RTT printf retarget for Debug
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
Reference in new issue
Block a user