Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add nrf52840 HIC #1015

Open
wants to merge 15 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/hic/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Support for these HICs has been recently added.

| HIC | Core | Freq. | RAM | ROM | USB |
|-------------------------------|:----:|--------:|-------:|-------:|:---:|
| [nrf52840](nrf52840.md) | M4 | 64 MHz | 64 KB | 256 KB | FS |
| [stm32f072x8](stm32f072xx.md) | M0 | 48 Mhz | 16 KB | 64 KB | FS |
| [stm32f072xb](stm32f072xx.md) | M0 | 48 Mhz | 16 KB | 128 KB | FS |
| [stm32h743xx](stm32h743xx.md) | M7 | 480 Mhz | 1 MB | 2 MB | HS |
40 changes: 40 additions & 0 deletions docs/hic/nrf52840.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# nrf52840 HIC

Based on Nordic [nRF52840](https://www.nordicsemi.com/Products/nRF52840):
- Cortex-M4 64 MHz
- 1MB Flash (limited to 256 KB)
- 64 KB RAM
- Full-speed USB 2.0 device controller: up to 9 bi-directional endpoints including EP0 (*)
- aQFN73 or QFN48 packaging

(*) "Endpoints: 2 control (1 IN, 1 OUT) [...] 14 bulk/interrupt (7 IN, 7 OUT) [...] 2 isochronous (1 IN, 1 OUT)" (source: [Datasheet](https://infocenter.nordicsemi.com/pdf/nRF52840_PS_v1.7.pdf))

## Memory Map

| Region | Size | Start | End |
|----------|--------|-------------|-------------|
| Flash | 256 KB | 0x0000_0000 | 0x0004_0000 |
| SRAM | 64 KB | 0x2000_0000 | 0x2001_0000 |

Bootloader size is 64 KB

## DAPLink default pin assignment

| Signal | I/O | Symbol | Pin |
|-------------|:---:|---------|:---:|
| SWD |
| SWCLK | O | P0.13 | |
| SWDIO | I/O | P0.17 | |
| nRST | O | P0.09 | |
| UART |
| UART TX | I | P0.24 | |
| UART RX | O | P1.00 | |
| Button |
| F-RST But. | I | P1.06 | |
| LEDs |
| HID LED | O | P0.06 | |
| MSD LED | O | P0.08 | |
| CDC LED | O | P0.12 | |

Note:
- LEDs have active state low.
21 changes: 21 additions & 0 deletions projects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ module:
- records/hic_hal/nrf52820.yaml
- records/usb/usb-bulk.yaml
- records/usb/usb-hid.yaml
hic_nrf52840: &module_hic_nrf52840
- records/rtos/rtos-cm4.yaml
- records/hic_hal/nrf52840.yaml
- records/usb/usb-bulk.yaml
- records/usb/usb-hid.yaml
hic_sam3u2c: &module_hic_sam3u2c
- records/rtos/rtos-cm3.yaml
- records/hic_hal/sam3u2c.yaml
Expand Down Expand Up @@ -208,6 +213,14 @@ projects:
- *module_if
- *module_hic_nrf52820
- records/family/all_family.yaml
nrf52840_bl:
- *module_bl
- records/hic_hal/nrf52840.yaml
- records/board/nrf52840_bl.yaml
nrf52840_if:
- *module_if
- *module_hic_nrf52840
- records/family/all_family.yaml
sam3u2c_bl:
- *module_bl
- records/hic_hal/sam3u2c.yaml
Expand Down Expand Up @@ -608,6 +621,14 @@ projects:
- *module_if
- *module_hic_nrf52820
- records/board/microbitv2_nrf52820.yaml
nrf52840_dongle_if:
- *module_if
- *module_hic_nrf52840
- records/board/nrf52840_dongle.yaml
nrf52840_thingy91_if:
- *module_if
- *module_hic_nrf52840
- records/board/thingy91.yaml
sam3u2c_mkit_dk_dongle_nrf5x_if:
- *module_if
- *module_hic_sam3u2c
Expand Down
4 changes: 4 additions & 0 deletions records/board/nrf52840_bl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
common:
sources:
board:
- source/board/nrf52840_bl.c
3 changes: 3 additions & 0 deletions records/board/nrf52840_dongle.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
common:
macros:
- NRF_OPEN_BOOTLOADER
8 changes: 8 additions & 0 deletions records/board/thingy91.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
common:
macros:
- THINGY91
- NRF_SECURE_BOOTLOADER
- NRF_SECURE_BOOTLOADER_OFFSET=0x12200
sources:
board:
- source/board/thingy91.c
14 changes: 8 additions & 6 deletions records/hic_hal/nrf52820.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ common:
includes:
- source/hic_hal/nordic/nrf52820
- source/hic_hal/nordic/nrf52820/cmsis
- source/hic_hal/nordic/nrf52820/nrfx
- source/hic_hal/nordic/nrf52820/nrfx/drivers
- source/hic_hal/nordic/nrf52820/nrfx/drivers/include
- source/hic_hal/nordic/nrf52820/nrfx/hal
- source/hic_hal/nordic/nrf52820/nrfx/mdk
- source/hic_hal/nordic/nrfx
- source/hic_hal/nordic/nrfx/drivers
- source/hic_hal/nordic/nrfx/hal
- source/hic_hal/nordic/nrfx/mdk
- source/hic_hal/nordic/shared/nrf52
sources:
hic_hal:
- source/hic_hal/nordic/nrf52820
- source/hic_hal/nordic/nrf52820/cmsis
- source/hic_hal/nordic/nrf52820/nrfx/drivers
- source/hic_hal/nordic/nrfx/drivers
- source/hic_hal/nordic/shared
- source/hic_hal/nordic/shared/nrf52

tool_specific:
uvision:
Expand Down
53 changes: 53 additions & 0 deletions records/hic_hal/nrf52840.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
common:
target:
- Cortex-M4
core:
- Cortex-M4
macros:
- INTERFACE_NRF52840
- NRF52840_XXAA
- DAPLINK_HIC_ID=0x6E052840 # DAPLINK_HIC_ID_NRF52840
- OS_CLOCK=64000000
- __DAPLINK
## Uncomment one of the following defines to use alternate pinmap:
# - NRF52840_DK
# - SEEEDSTUDIO_XIAO_BLE
# - SSCI_ISP1807
includes:
- source/hic_hal/nordic/nrf52840
- source/hic_hal/nordic/nrfx
- source/hic_hal/nordic/nrfx/drivers
- source/hic_hal/nordic/nrfx/hal
- source/hic_hal/nordic/nrfx/mdk
- source/hic_hal/nordic/shared/nrf52
sources:
hic_hal:
- source/hic_hal/nordic/nrf52840
- source/hic_hal/nordic/nrf52820/cmsis
- source/hic_hal/nordic/nrfx/drivers
- source/hic_hal/nordic/shared
- source/hic_hal/nordic/shared/nrf52

tool_specific:
uvision:
misc:
ld_flags:
- --predefine="-I..\..\..\source\hic_hal\nordic\nrf52840"
sources:
hic_hal:
- source/hic_hal/nordic/nrf52840/arm
armcc:
sources:
hic_hal:
- source/hic_hal/nordic/nrf52840/arm
armclang:
misc:
common_flags:
- -mfpu=none
sources:
hic_hal:
- source/hic_hal/nordic/nrf52840/arm
gcc_arm:
sources:
hic_hal:
- source/hic_hal/nordic/nrf52840/gcc
65 changes: 65 additions & 0 deletions source/board/nrf52840_bl.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* @file nrf52840_bl.c
* @brief board ID and meta-data for HIC based on Nordic Semiconductor nRF52840
*
* DAPLink Interface Firmware
* Copyright (c) 2009-2021, Arm Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "target_config.h"
#include "daplink_addr.h"
#include "compiler.h"
#include "target_board.h"
#include "target_family.h"

// Warning - changing the interface start will break backwards compatibility
COMPILER_ASSERT(DAPLINK_ROM_IF_START == 0x00010000);
COMPILER_ASSERT(DAPLINK_ROM_IF_SIZE == KB(188));

/**
* List of start and size for each size of flash sector
* The size will apply to all sectors between the listed address and the next address
* in the list.
* The last pair in the list will have sectors starting at that address and ending
* at address start + size.
*/
static const sector_info_t sectors_info[] = {
{DAPLINK_ROM_IF_START, 0x1000},
};

// nrf52840 target information
target_cfg_t target_device = {
.sectors_info = sectors_info,
.sector_info_length = (sizeof(sectors_info))/(sizeof(sector_info_t)),
.flash_regions[0].start = DAPLINK_ROM_IF_START,
.flash_regions[0].end = DAPLINK_ROM_IF_START + DAPLINK_ROM_IF_SIZE,
.flash_regions[0].flags = kRegionIsDefault,
.ram_regions[0].start = DAPLINK_RAM_START,
.ram_regions[0].end = DAPLINK_RAM_START + DAPLINK_RAM_SIZE,
/* .flash_algo not needed for bootloader */
};

// bootloader has no family
const target_family_descriptor_t *g_target_family = NULL;

const board_info_t g_board_info = {
.info_version = kBoardInfoVersion,
.board_id = "0000",
.daplink_url_name = "HELP_FAQHTM",
.daplink_drive_name = "MAINTENANCE",
.daplink_target_url = "https://mbed.com/daplink",
.target_cfg = &target_device,
};
38 changes: 38 additions & 0 deletions source/board/thingy91.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @file thingy91.c
* @brief board ID for the BBC Microbit board
*
* DAPLink Interface Firmware
* Copyright (c) 2009-2019, ARM Limited, All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#include "IO_Config.h"
#include "DAP.h"
#include "target_family.h"
#include "target_board.h"
#include "nrf_nvmc.h"

extern target_cfg_t target_device_nrf51822_16;

const board_info_t g_board_info = {
.info_version = kBoardInfoVersion,
.family_id = kNordic_Nrf91_FamilyID,
.daplink_url_name = "THINGY91HTM",
.daplink_drive_name = "THINGY91 ",
.daplink_target_url = "https://nordicsemi.com/thingy91",
.board_vendor = "Nordic Semiconductor ASA",
.board_name = "Thingy:91",
};
4 changes: 4 additions & 0 deletions source/daplink/daplink.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ extern "C" {

// ROM check
COMPILER_ASSERT(DAPLINK_ROM_BL_START == DAPLINK_ROM_START);

#if !defined(NON_CONTIGUOUS_USER_CONFIG)
COMPILER_ASSERT(DAPLINK_ROM_IF_START + DAPLINK_ROM_IF_SIZE == DAPLINK_ROM_CONFIG_USER_START);
COMPILER_ASSERT(DAPLINK_ROM_CONFIG_USER_START + DAPLINK_ROM_CONFIG_USER_SIZE == DAPLINK_ROM_START + DAPLINK_ROM_SIZE);
#endif

// RAM check
COMPILER_ASSERT(DAPLINK_RAM_APP_START == DAPLINK_RAM_START);
Expand Down Expand Up @@ -74,6 +77,7 @@ COMPILER_ASSERT(DAPLINK_RAM_SHARED_START + DAPLINK_RAM_SHARED_SIZE == DAPLINK_RA
#define DAPLINK_HIC_ID_STM32H743II 0x97969940 // Newer STM HICs
#define DAPLINK_HIC_ID_PSOC5 0x2E127069
#define DAPLINK_HIC_ID_NRF52820 0x6E052820 // 'n\x05\x28\x20'
#define DAPLINK_HIC_ID_NRF52840 0x6E052840 // 'n\x05\x28\x40'
//@}

#define DAPLINK_INFO_OFFSET 0x20
Expand Down
2 changes: 2 additions & 0 deletions source/daplink/drag-n-drop/iap_flash_intf.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

#if ((DAPLINK_ROM_UPDATE_SIZE != 0) || defined(DAPLINK_BOOTLOADER_UPDATE))

#if !defined(DISABLE_FLASH_INTF_CHECKS)
// Application start must be aligned to page write
COMPILER_ASSERT(DAPLINK_ROM_APP_START % DAPLINK_MIN_WRITE_SIZE == 0);
// Application size must be a multiple of write size
Expand All @@ -46,6 +47,7 @@ COMPILER_ASSERT(DAPLINK_ROM_APP_START % DAPLINK_SECTOR_SIZE == 0);
COMPILER_ASSERT(DAPLINK_ROM_UPDATE_START % DAPLINK_SECTOR_SIZE == 0);
// Update size must be a multiple of sector size
COMPILER_ASSERT(DAPLINK_ROM_UPDATE_SIZE % DAPLINK_SECTOR_SIZE == 0);
#endif

typedef enum {
STATE_CLOSED,
Expand Down
2 changes: 2 additions & 0 deletions source/hic_hal/device.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@
#include "M480.h"
#elif defined (INTERFACE_NRF52820)
#include "nrf52820.h"
#elif defined (INTERFACE_NRF52840)
#include "nrf52840.h"
#else
#error "CMSIS core headers needed"
#endif
Expand Down
5 changes: 5 additions & 0 deletions source/hic_hal/nordic/nrf52820/DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,13 @@ Configures the DAP Hardware I/O pins for Serial Wire Debug (SWD) mode:
- TDI, nTRST to HighZ mode (pins are unused in SWD mode).
*/
__STATIC_INLINE void PORT_SWD_SETUP (void) {
#if defined (NRF52840_XXAA) || defined (DEVELOP_IN_NRF52840)
COMPILER_ASSERT(GPIO_CHECK_PRESENT_NRF52840(PIN_SWCLK));
COMPILER_ASSERT(GPIO_CHECK_PRESENT_NRF52840(PIN_SWDIO));
#else
COMPILER_ASSERT(GPIO_CHECK_PRESENT_NRF52820(PIN_SWCLK));
COMPILER_ASSERT(GPIO_CHECK_PRESENT_NRF52820(PIN_SWDIO));
#endif
gpio_cfg(GPIO_REG(PIN_SWCLK), GPIO_IDX(PIN_SWCLK),
NRF_GPIO_PIN_DIR_OUTPUT, NRF_GPIO_PIN_INPUT_DISCONNECT,
NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_S0S1, NRF_GPIO_PIN_NOSENSE);
Expand Down
Loading
Loading