Skip to content

Commit 57f5426

Browse files
committed
nRF52 DFU SDK17 update
1 parent dbf5e5f commit 57f5426

File tree

4 files changed

+313
-78
lines changed

4 files changed

+313
-78
lines changed
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**-------------------------------------------------------------------------
2+
@file board.h
3+
4+
@brief Board specific definitions
5+
6+
This file contains all I/O definitions for a specific board for the
7+
application firmware. This files should be located in each project and
8+
modified to suit the need for the application use case.
9+
10+
@author Hoang Nguyen Hoan
11+
@date Nov. 16, 2016
12+
13+
@license
14+
15+
Copyright (c) 2016, I-SYST inc., all rights reserved
16+
17+
Permission to use, copy, modify, and distribute this software for any purpose
18+
with or without fee is hereby granted, provided that the above copyright
19+
notice and this permission notice appear in all copies, and none of the
20+
names : I-SYST or its contributors may be used to endorse or
21+
promote products derived from this software without specific prior written
22+
permission.
23+
24+
For info or contributing contact : hnhoan at i-syst dot com
25+
26+
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
27+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
28+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
29+
DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
30+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
31+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
35+
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36+
37+
----------------------------------------------------------------------------*/
38+
39+
#ifndef __BOARD_H__
40+
#define __BOARD_H__
41+
42+
#include "blueio_board.h"
43+
44+
// IBK-NRF5x
45+
// Button 1
46+
#define BUT1_PORT BLUEIO_BUT1_PORT
47+
#define BUT1_PIN BLUEIO_BUT1_PIN
48+
#define BUT1_PINOP BLUEIO_BUT1_PINOP
49+
#define BUT1_SENSE IOPINSENSE_LOW_TRANSITION
50+
#define BUT1_SENSE_INT 0
51+
#define BUT1_INT_PRIO 6
52+
53+
// Button 2
54+
#define BUT2_PORT BLUEIO_BUT2_PORT
55+
#define BUT2_PIN BLUEIO_BUT2_PIN
56+
#define BUT2_PINOP BLUEIO_BUT2_PINOP
57+
#define BUT2_SENSE IOPINSENSE_LOW_TRANSITION
58+
#define BUT2_SENSE_INT BUT2_PIN
59+
#define BUT2_INT_PRIO 6
60+
61+
62+
#define LED1_PORT BLUEIO_LED1_PORT
63+
#define LED1_PIN BLUEIO_LED1_PIN
64+
#define LED1_PINOP BLUEIO_LED1_PINOP
65+
66+
#define LED2_PORT BLUEIO_LED2_PORT
67+
#define LED2_PIN BLUEIO_LED2_PIN
68+
#define LED2_PINOP BLUEIO_LED2_PINOP
69+
70+
#define LED3_PORT BLUEIO_LED3_PORT
71+
#define LED3_PIN BLUEIO_LED3_PIN
72+
#define LED3_PINOP BLUEIO_LED3_PINOP
73+
74+
#define LED4_PORT BLUEIO_LED4_PORT
75+
#define LED4_PIN BLUEIO_LED4_PIN
76+
#define LED4_PINOP BLUEIO_LED4_PINOP
77+
78+
#define BUT_N_LED_PINS_MAP { \
79+
{LED1_PORT, LED1_PIN, LED1_PINOP, IOPINDIR_OUTPUT, IOPINRES_NONE, IOPINTYPE_NORMAL}, \
80+
{LED2_PORT, LED2_PIN, LED2_PINOP, IOPINDIR_OUTPUT, IOPINRES_NONE, IOPINTYPE_NORMAL}, \
81+
{LED3_PORT, LED3_PIN, LED3_PINOP, IOPINDIR_OUTPUT, IOPINRES_NONE, IOPINTYPE_NORMAL}, \
82+
{LED4_PORT, LED4_PIN, LED4_PINOP, IOPINDIR_OUTPUT, IOPINRES_NONE, IOPINTYPE_NORMAL}, \
83+
{BUT1_PORT, BUT1_PIN, BUT1_PINOP, IOPINDIR_INPUT, IOPINRES_PULLDOWN, IOPINTYPE_NORMAL}, \
84+
{BUT2_PORT, BUT2_PIN, BUT2_PINOP, IOPINDIR_INPUT, IOPINRES_PULLDOWN, IOPINTYPE_NORMAL}, \
85+
}
86+
87+
#endif // __BOARD_H__
88+

ARM/Nordic/nRF52/exemples/dfu/src/main.c

100755100644
+19-20
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright (c) 2016 - 2019, Nordic Semiconductor ASA
2+
* Copyright (c) 2016 - 2020, Nordic Semiconductor ASA
33
*
44
* All rights reserved.
55
*
@@ -47,7 +47,7 @@
4747
*/
4848

4949
#include <stdint.h>
50-
#include "boards.h"
50+
//#include "boards.h"
5151
#include "nrf_mbr.h"
5252
#include "nrf_bootloader.h"
5353
#include "nrf_bootloader_app_start.h"
@@ -61,16 +61,16 @@
6161
#include "nrf_bootloader_info.h"
6262
#include "nrf_delay.h"
6363

64-
#include "coredev/iopincfg.h"
6564
#include "iopinctrl.h"
66-
#include "blueio_board.h"
65+
#include "board.h"
6766

68-
static const IOPINCFG s_IOPins[] = {
69-
// {BLUEIO_BUT2_PORT, BLUEIO_BUT2_PIN, BLUEIO_BUT2_PINOP, IOPINDIR_INPUT, IOPINRES_PULLUP, IOPINTYPE_NORMAL},
70-
{BLUEIO_LED1_PORT, BLUEIO_LED1_PIN, BLUEIO_LED1_PINOP, IOPINDIR_OUTPUT, IOPINRES_NONE, IOPINTYPE_NORMAL},
67+
static const IOPINCFG s_PinsCfg[] = {
68+
{LED1_PORT, LED1_PIN, LED1_PINOP, IOPINDIR_OUTPUT, IOPINRES_NONE, IOPINTYPE_NORMAL},
69+
{BUT1_PORT, BUT1_PIN, BUT1_PINOP, IOPINDIR_INPUT, IOPINRES_PULLDOWN, IOPINTYPE_NORMAL},
70+
{BUT2_PORT, BUT2_PIN, BUT2_PINOP, IOPINDIR_INPUT, IOPINRES_PULLDOWN, IOPINTYPE_NORMAL},
7171
};
7272

73-
static const int s_NbIOPins = sizeof(s_IOPins) / sizeof(IOPINCFG);
73+
static const int s_NbPins = sizeof(s_PinsCfg) / sizeof(IOPINCFG);
7474

7575
static void on_error(void)
7676
{
@@ -121,16 +121,16 @@ static void dfu_observer(nrf_dfu_evt_type_t evt_type)
121121
//bsp_board_led_on(BSP_BOARD_LED_0);
122122
//bsp_board_led_on(BSP_BOARD_LED_1);
123123
//bsp_board_led_off(BSP_BOARD_LED_2);
124+
IOPinClear(LED1_PORT, LED1_PIN);
124125
break;
125126
case NRF_DFU_EVT_TRANSPORT_ACTIVATED:
126127
//bsp_board_led_off(BSP_BOARD_LED_1);
127128
//bsp_board_led_on(BSP_BOARD_LED_2);
128129
break;
129130
case NRF_DFU_EVT_DFU_STARTED:
130-
IOPinClear(BLUEIO_LED1_PORT, BLUEIO_LED1_PIN);
131131
break;
132132
case NRF_DFU_EVT_DFU_COMPLETED:
133-
IOPinSet(BLUEIO_LED1_PORT, BLUEIO_LED1_PIN);
133+
IOPinSet(LED1_PORT, LED1_PIN);
134134
break;
135135
default:
136136
break;
@@ -143,13 +143,13 @@ int main(void)
143143
{
144144
uint32_t ret_val;
145145

146-
IOPinCfg(s_IOPins, s_NbIOPins);
147-
IOPinClear(BLUEIO_LED1_PORT, BLUEIO_LED1_PIN);
146+
// Must happen before flash protection is applied, since it edits a protected page.
147+
nrf_bootloader_mbr_addrs_populate();
148148

149149
// Protect MBR and bootloader code from being overwritten.
150-
ret_val = nrf_bootloader_flash_protect(0, MBR_SIZE, false);
150+
ret_val = nrf_bootloader_flash_protect(0, MBR_SIZE);
151151
APP_ERROR_CHECK(ret_val);
152-
ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, BOOTLOADER_SIZE, false);
152+
ret_val = nrf_bootloader_flash_protect(BOOTLOADER_START_ADDR, BOOTLOADER_SIZE);
153153
APP_ERROR_CHECK(ret_val);
154154

155155
(void) NRF_LOG_INIT(nrf_bootloader_dfu_timer_counter_get);
@@ -160,13 +160,12 @@ int main(void)
160160
ret_val = nrf_bootloader_init(dfu_observer);
161161
APP_ERROR_CHECK(ret_val);
162162

163-
// Either there was no DFU functionality enabled in this project or the DFU module detected
164-
// no ongoing DFU operation and found a valid main application.
165-
// Boot the main application.
166-
nrf_bootloader_app_start();
163+
NRF_LOG_FLUSH();
167164

168-
// Should never be reached.
169-
NRF_LOG_INFO("After main");
165+
NRF_LOG_ERROR("After main, should never be reached.");
166+
NRF_LOG_FLUSH();
167+
168+
APP_ERROR_CHECK_BOOL(false);
170169
}
171170

172171
/**
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/**
2+
* Copyright (c) 2019 - 2020, Nordic Semiconductor ASA
3+
*
4+
* All rights reserved.
5+
*
6+
* Redistribution and use in source and binary forms, with or without modification,
7+
* are permitted provided that the following conditions are met:
8+
*
9+
* 1. Redistributions of source code must retain the above copyright notice, this
10+
* list of conditions and the following disclaimer.
11+
*
12+
* 2. Redistributions in binary form, except as embedded into a Nordic
13+
* Semiconductor ASA integrated circuit in a product or a software update for
14+
* such product, must reproduce the above copyright notice, this list of
15+
* conditions and the following disclaimer in the documentation and/or other
16+
* materials provided with the distribution.
17+
*
18+
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
19+
* contributors may be used to endorse or promote products derived from this
20+
* software without specific prior written permission.
21+
*
22+
* 4. This software, with or without modification, must only be used with a
23+
* Nordic Semiconductor ASA integrated circuit.
24+
*
25+
* 5. Any software provided in binary form under this license must not be reverse
26+
* engineered, decompiled, modified and/or disassembled.
27+
*
28+
* THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
29+
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30+
* OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
31+
* DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
32+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
34+
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
35+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
37+
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38+
*
39+
*/
40+
#ifndef NRF_CRYPTO_ALLOCATOR_H__
41+
#define NRF_CRYPTO_ALLOCATOR_H__
42+
43+
#include "nrf_assert.h"
44+
45+
#ifdef __cplusplus
46+
extern "C" {
47+
#endif
48+
49+
/* Crypto library in bootloader case does not use dynamic allocation */
50+
#define NRF_CRYPTO_ALLOC(size) NULL; ASSERT(0)
51+
#define NRF_CRYPTO_ALLOC_ON_STACK(size) NULL; ASSERT(0)
52+
#define NRF_CRYPTO_FREE(ptr) (void)ptr;
53+
54+
#ifdef __cplusplus
55+
}
56+
#endif
57+
58+
#endif /* NRF_CRYPTO_ALLOCATOR_H__ */

0 commit comments

Comments
 (0)