Skip to content

Commit c5c2039

Browse files
committed
Add support for bootloader pin config data for Arcade
1 parent dd43e2a commit c5c2039

File tree

5 files changed

+159
-1
lines changed

5 files changed

+159
-1
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ C_SOURCE_FILES += $(SRC_PATH)/boards.c
115115
C_SOURCE_FILES += $(SRC_PATH)/flash_nrf5x.c
116116
C_SOURCE_FILES += $(SRC_PATH)/dfu_ble_svc.c
117117
C_SOURCE_FILES += $(SRC_PATH)/dfu_init.c
118+
C_SOURCE_FILES += $(SRC_PATH)/pinconfig.c
118119

119120
# nrfx
120121
C_SOURCE_FILES += $(NRFX_PATH)/drivers/src/nrfx_power.c
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* The MIT License (MIT)
3+
*
4+
* Copyright (c) 2018 Ha Thach for Adafruit Industries
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#ifndef _FEATHER_NRF52840_H
26+
#define _FEATHER_NRF52840_H
27+
28+
#define _PINNUM(port, pin) ((port)*32 + (pin))
29+
30+
/*------------------------------------------------------------------*/
31+
/* LED
32+
*------------------------------------------------------------------*/
33+
#define LEDS_NUMBER 2
34+
#define LED_PRIMARY_PIN _PINNUM(1, 15)
35+
#define LED_SECONDARY_PIN _PINNUM(1, 10)
36+
#define LED_STATE_ON 1
37+
38+
#define LED_NEOPIXEL _PINNUM(0, 16)
39+
#define NEOPIXELS_NUMBER 1
40+
#define BOARD_RGB_BRIGHTNESS 0x040404
41+
42+
/*------------------------------------------------------------------*/
43+
/* BUTTON
44+
*------------------------------------------------------------------*/
45+
#define BUTTONS_NUMBER 2
46+
#define BUTTON_1 _PINNUM(1, 02)
47+
#define BUTTON_2 _PINNUM(0, 10)
48+
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
49+
50+
/*------------------------------------------------------------------*/
51+
/* UART (only used by nRF52832)
52+
*------------------------------------------------------------------*/
53+
#define RX_PIN_NUMBER 8
54+
#define TX_PIN_NUMBER 6
55+
#define CTS_PIN_NUMBER 0
56+
#define RTS_PIN_NUMBER 0
57+
#define HWFC false
58+
59+
//--------------------------------------------------------------------+
60+
// BLE OTA
61+
//--------------------------------------------------------------------+
62+
#define BLEDIS_MANUFACTURER "Adafruit Industries"
63+
#define BLEDIS_MODEL "Feather nRF52840 Express"
64+
65+
//--------------------------------------------------------------------+
66+
// USB
67+
//--------------------------------------------------------------------+
68+
#define USB_DESC_VID 0x239A
69+
#define USB_DESC_UF2_PID 0x0029
70+
#define USB_DESC_CDC_ONLY_PID 0x002A
71+
72+
//------------- UF2 -------------//
73+
#define UF2_PRODUCT_NAME "Adafruit Feather nRF52840 Express"
74+
#define UF2_VOLUME_LABEL "ARCADE-N4"
75+
#define UF2_BOARD_ID "nRF52840-Feather-revD"
76+
#define UF2_INDEX_URL "https://www.adafruit.com/product/4062"
77+
78+
#ifdef DEFINE_BOOTLOADER_CONFIG
79+
#define BOOTLOADER_CONFIG_PRESENT 1
80+
__attribute__((used, section(".bootloaderConfig")))
81+
const uint32_t bootloaderConfig[] = {
82+
/* CF2 START */
83+
513675505, 539130489, // magic
84+
49, 100, // used entries, total entries
85+
4, 0x18, // PIN_BTN_A = PIN_RX
86+
5, 0xa, // PIN_BTN_B = PIN_D2
87+
13, 0x29, // PIN_LED = PIN_D13
88+
18, 0xf, // PIN_MISO = PA15
89+
19, 0xd, // PIN_MOSI = PA13
90+
20, 0x23, // PIN_NEOPIXEL = PB03
91+
21, 0x18, // PIN_RX = PA24
92+
23, 0xe, // PIN_SCK = PA14
93+
24, 0xb, // PIN_SCL = PA11
94+
25, 0xc, // PIN_SDA = PA12
95+
28, 0x19, // PIN_TX = PA25
96+
32, 0xe, // PIN_DISPLAY_SCK = PIN_SCK
97+
34, 0xd, // PIN_DISPLAY_MOSI = PIN_MOSI
98+
35, 0x1e, // PIN_DISPLAY_CS = PIN_A2
99+
36, 0x1c, // PIN_DISPLAY_DC = PIN_A3
100+
37, 0xa0, // DISPLAY_WIDTH = 160
101+
38, 0x80, // DISPLAY_HEIGHT = 128
102+
39, 0x80, // DISPLAY_CFG0 = 0x80
103+
40, 0x603, // DISPLAY_CFG1 = 0x603
104+
41, 0x20, // DISPLAY_CFG2 = 0x20
105+
43, 0x2, // PIN_DISPLAY_RST = PIN_A4
106+
44, 0x3, // PIN_DISPLAY_BL = PIN_A5
107+
47, 0x6, // PIN_BTN_LEFT = PIN_D11
108+
48, 0x1a, // PIN_BTN_RIGHT = PIN_D9
109+
49, 0x1b, // PIN_BTN_UP = PIN_D10
110+
50, 0x7, // PIN_BTN_DOWN = PIN_D6
111+
51, 0x8, // PIN_BTN_MENU = PIN_D12
112+
56, 0x2a, // PIN_LED2 = PB10
113+
60, 0x19, // PIN_JACK_TX = PIN_TX
114+
100, 0x4, // PIN_A0 = PA04
115+
101, 0x5, // PIN_A1 = PA05
116+
102, 0x1e, // PIN_A2 = PA30
117+
103, 0x1c, // PIN_A3 = PA28
118+
104, 0x2, // PIN_A4 = PA02
119+
105, 0x3, // PIN_A5 = PA03
120+
152, 0xa, // PIN_D2 = PA10
121+
155, 0x28, // PIN_D5 = PB08
122+
156, 0x7, // PIN_D6 = PA07
123+
159, 0x1a, // PIN_D9 = PA26
124+
160, 0x1b, // PIN_D10 = PA27
125+
161, 0x6, // PIN_D11 = PA06
126+
162, 0x8, // PIN_D12 = PA08
127+
163, 0x29, // PIN_D13 = PB09
128+
200, 0x1, // NUM_NEOPIXELS = 1
129+
204, 0x100000, // FLASH_BYTES = 0x100000
130+
205, 0x40000, // RAM_BYTES = 0x40000
131+
208, 0xd7688ea1, // BOOTLOADER_BOARD_ID = 0xd7688ea1
132+
209, 0xada52840, // UF2_FAMILY = 0xada52840
133+
210, 0x20, // PINS_PORT_SIZE = PA_32
134+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
135+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
136+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
137+
0, 0, 0, 0, 0, 0,
138+
/* CF2 END */
139+
};
140+
#endif
141+
142+
#endif // _FEATHER_NRF52840_H
143+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
MCU_SUB_VARIANT = nrf52840

src/linker/nrf52840_s140_v6.ld

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ MEMORY
1111
* those values do not match. The check is performed in main.c, see
1212
* APP_ERROR_CHECK_BOOL(*((uint32_t *)NRF_UICR_BOOT_START_ADDRESS) == BOOTLOADER_REGION_START);
1313
*/
14-
FLASH (rx) : ORIGIN = 0xF4000, LENGTH = 0xFE000-0xF4000 /* 40 KB */
14+
FLASH (rx) : ORIGIN = 0xF4000, LENGTH = 0xFE000-0xF4000-1024 /* 39 KB */
15+
16+
BOOTLOADER_CONFIG (r): ORIGIN = 0xFE000 - 1024, LENGTH = 1024
1517

1618
/** Location of mbr params page in flash. */
1719
MBR_PARAMS_PAGE (rw) : ORIGIN = 0xFE000, LENGTH = 0x1000
@@ -50,6 +52,11 @@ SECTIONS
5052
PROVIDE( __stop_fs_data = .);
5153
} = 0
5254

55+
.bootloaderConfig :
56+
{
57+
KEEP(*(.bootloaderConfig))
58+
} > BOOTLOADER_CONFIG
59+
5360
/* Place the bootloader settings page in flash. */
5461
.bootloaderSettings(NOLOAD) :
5562
{

src/pinconfig.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#define DEFINE_BOOTLOADER_CONFIG 1
2+
#include "boards.h"
3+
4+
#if defined(BOOTLOADER_CONFIG_PRESENT) && BOOTLOADER_CONFIG_PRESENT
5+
// nothing yet
6+
#endif

0 commit comments

Comments
 (0)