-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
19769: cpu/nrf53: add initial support with nRF5340DK-APP board r=maribu a=dylad ### Contribution description This PR adds support for nRF5340 MCU and its associated Nordic development board, nRF5340DK. This MCU provides a dual Cortex-M33, one application core running at up to 128MHz, and one network core running at up to 64MHz. Peripherals are inherited from others Nordic MCUs families so it shouldn't be hard to add more of them in followup PRs. For now, only the minimal set of peripherals is supported: - GPIO / GPIO_IRQ - UART - TIMER ### Testing procedure Build the usual test application for the supported peripherals and flash the board. nRF5340DK provides two serial ports on its embedded debugger. RIOT's shell should be available on the first one (/dev/ttyACM0) ### Issues/PRs references #18576 #19267 19782: cpu/msp430: fix for ti's msp430-gcc-opensource package ld version r=maribu a=hugueslarrive ### Contribution description My msp430 toolchain (https://www.ti.com/tool/MSP430-GCC-OPENSOURCE) was broken by #19484: ``` hugues@p700:~/github/cpu_msp430_common/RIOT$ BOARD=msb-430 make -j64 -C examples/hello-world make : on entre dans le répertoire « /home/hugues/github/cpu_msp430_common/RIOT/examples/hello-world » Building application "hello-world" for "msb-430" with MCU "msp430fxyz". "make" -C /home/hugues/github/cpu_msp430_common/RIOT/boards/common/init "make" -C /home/hugues/github/cpu_msp430_common/RIOT/boards/msb-430 "make" -C /home/hugues/github/cpu_msp430_common/RIOT/core "make" -C /home/hugues/github/cpu_msp430_common/RIOT/core/lib "make" -C /home/hugues/github/cpu_msp430_common/RIOT/cpu/msp430fxyz "make" -C /home/hugues/github/cpu_msp430_common/RIOT/drivers "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys "make" -C /home/hugues/github/cpu_msp430_common/RIOT/boards/common/msb-430 "make" -C /home/hugues/github/cpu_msp430_common/RIOT/drivers/periph_common "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/auto_init "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/div "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/libc "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/malloc_thread_safe "make" -C /home/hugues/github/cpu_msp430_common/RIOT/cpu/msp430_common "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/newlib_syscalls_default "make" -C /home/hugues/github/cpu_msp430_common/RIOT/cpu/msp430fxyz/periph "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/preprocessor "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/stdio_uart "make" -C /home/hugues/github/cpu_msp430_common/RIOT/cpu/msp430_common/periph /opt/ti/msp430-gcc/bin/../lib/gcc/msp430-elf/9.3.1/../../../../msp430-elf/bin/ld: .rodata not found for insert collect2: error: ld returned 1 exit status make: *** [/home/hugues/github/cpu_msp430_common/RIOT/examples/hello-world/../../Makefile.include:761 : /home/hugues/github/cpu_msp430_common/RIOT/examples/hello-world/bin/msb-430/hello-world.elf] Erreur 1 make : on quitte le répertoire « /home/hugues/github/cpu_msp430_common/RIOT/examples/hello-world » hugues@p700:~/github/cpu_msp430_common/RIOT$ /opt/ti/msp430-gcc/msp430-elf/bin/ld --version GNU ld (Mitto Systems Limited - msp430-gcc 9.3.1.11) 2.34 Copyright (C) 2020 Free Software Foundation, Inc. This program is free software; you may redistribute it under the terms of the GNU General Public License version 3 or (at your option) a later version. This program has absolutely no warranty. hugues@p700:~/github/cpu_msp430_common/RIOT$ /opt/ti/msp430-gcc/msp430-elf/bin/ld --version | grep -Eo '[0-9]\.[0-9]+' 9.3 1.11 2.34 hugues@p700:~/github/cpu_msp430_common/RIOT$ /opt/ti/msp430-gcc/msp430-elf/bin/ld --version | grep -Eo '[0-9]\.[0-9]+$' 2.34 ``` ### Testing procedure ``` hugues@p700:~/github/cpu_msp430_common/RIOT$ BOARD=msb-430 make -j64 -C examples/hello-world make : on entre dans le répertoire « /home/hugues/github/cpu_msp430_common/RIOT/examples/hello-world » Building application "hello-world" for "msb-430" with MCU "msp430fxyz". "make" -C /home/hugues/github/cpu_msp430_common/RIOT/boards/common/init "make" -C /home/hugues/github/cpu_msp430_common/RIOT/boards/msb-430 "make" -C /home/hugues/github/cpu_msp430_common/RIOT/core "make" -C /home/hugues/github/cpu_msp430_common/RIOT/core/lib "make" -C /home/hugues/github/cpu_msp430_common/RIOT/cpu/msp430fxyz "make" -C /home/hugues/github/cpu_msp430_common/RIOT/drivers "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys "make" -C /home/hugues/github/cpu_msp430_common/RIOT/boards/common/msb-430 "make" -C /home/hugues/github/cpu_msp430_common/RIOT/drivers/periph_common "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/auto_init "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/div "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/libc "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/malloc_thread_safe "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/newlib_syscalls_default "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/preprocessor "make" -C /home/hugues/github/cpu_msp430_common/RIOT/cpu/msp430_common "make" -C /home/hugues/github/cpu_msp430_common/RIOT/sys/stdio_uart "make" -C /home/hugues/github/cpu_msp430_common/RIOT/cpu/msp430fxyz/periph "make" -C /home/hugues/github/cpu_msp430_common/RIOT/cpu/msp430_common/periph text data bss dec hex filename 8612 722 866 10200 27d8 /home/hugues/github/cpu_msp430_common/RIOT/examples/hello-world/bin/msb-430/hello-world.elf make : on quitte le répertoire « /home/hugues/github/cpu_msp430_common/RIOT/examples/hello-world » ``` ### Issues/PRs references Introduced by #19484, highlighted in #16727. Co-authored-by: Dylan Laduranty <[email protected]> Co-authored-by: Hugues Larrive <[email protected]>
- Loading branch information
Showing
36 changed files
with
38,743 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Copyright (c) 2023 Mesotic SAS | ||
# | ||
# 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. | ||
|
||
config BOARD | ||
default "nrf5340dk-app" if BOARD_NRF5340DK_APP | ||
|
||
config BOARD_NRF5340DK_APP | ||
bool | ||
default y | ||
select CPU_MODEL_NRF5340_APP | ||
select HAS_PERIPH_TIMER | ||
select HAS_PERIPH_UART | ||
select HAS_PERIPH_UART_HW_FC | ||
|
||
# Put other features for this board (in alphabetical order) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = board | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CPU_MODEL = nrf5340_app | ||
CPU = nrf53 | ||
|
||
# Put defined MCU peripherals here (in alphabetical order) | ||
FEATURES_PROVIDED += periph_timer | ||
FEATURES_PROVIDED += periph_uart | ||
FEATURES_PROVIDED += periph_uart_hw_fc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# include this module into the build | ||
INCLUDES += -I$(RIOTBOARD)/nrf5340dk-app/include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
@defgroup boards_nrf5340dk-app nRF5340DK | ||
@ingroup boards | ||
@brief Support for the nRF5340DK-app board | ||
|
||
### General information | ||
|
||
The nRF5340DK is a devboard based on nRF5340 MCU which offers a dual core | ||
Cortex-M33 with one application core and one network core. | ||
The network core is able to handle Bluetooth 5.3, BLE, mesh, NFC, Thread and | ||
Zigbee connectivity. | ||
Currently only the application core can be used with RIOT-OS. | ||
|
||
The board features four LEDs, four user buttons/switches and a reset button. | ||
|
||
### Links | ||
|
||
- [nRF5340DK web page](https://infocenter.nordicsemi.com/topic/ug_nrf5340_dk/UG/dk/intro.html) | ||
- [documentation and hardware description](https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_nrf53%2Fstruct%2Fnrf5340.html) | ||
|
||
### Flash the board | ||
|
||
The board is flashed using JLink or nrfjprog software. Programs needs to | ||
be installed. | ||
|
||
The process is automated in the usual `make flash` target. | ||
|
||
### Accessing STDIO via UART | ||
|
||
The STDIO is directly accessible via the USB port. On a Linux host, it's | ||
generally mapped to `/dev/ttyACM0`. | ||
|
||
Use the `term` target to connect to the board serial port<br/> | ||
``` | ||
make BOARD=nrf5340dk-app -C examples/hello-world term | ||
``` | ||
|
||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/* | ||
* Copyright (C) 2023 Mesotic SAS | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @ingroup boards_nrf5340dk-app | ||
* @{ | ||
* | ||
* @file | ||
* @brief Board configuration for the nRF5340DK-app board | ||
* | ||
* @author Dylan Laduranty <[email protected]> | ||
*/ | ||
|
||
#ifndef BOARD_H | ||
#define BOARD_H | ||
|
||
#include "cpu.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief System core clock speed, for all NRF53 Application core. | ||
*/ | ||
#define CLOCK_CORECLOCK MHZ(128) | ||
|
||
/** | ||
* @name HF Clock configuration | ||
* | ||
* | ||
* @{ | ||
*/ | ||
|
||
/* CLOCK_HFCLKSRC_SRC_HFXO to use external 32MHz crystal | ||
* CLOCK_HFCLKSRC_SRC_HFINT to use internal crystal */ | ||
#define CLOCK_HFCLK (CLOCK_HFCLKSRC_SRC_HFXO) /**< HFCLK Source selection */ | ||
#define CLOCK_LFCLK (3) /**< LFCLK Source selection */ | ||
/** @} */ | ||
|
||
/** | ||
* @name LED pin configuration | ||
* @{ | ||
*/ | ||
#define LED0_PIN GPIO_PIN(0, 28) /**< LED0 pin definition */ | ||
#define LED1_PIN GPIO_PIN(0, 29) /**< LED1 pin definition */ | ||
#define LED2_PIN GPIO_PIN(0, 30) /**< LED2 pin definition */ | ||
#define LED3_PIN GPIO_PIN(0, 31) /**< LED3 pin definition */ | ||
|
||
#define LED0_MASK (1 << 28) /**< LED0 PORT bitmask */ | ||
#define LED1_MASK (1 << 29) /**< LED1 PORT bitmask */ | ||
#define LED2_MASK (1 << 30) /**< LED2 PORT bitmask */ | ||
#define LED3_MASK (1 << 31) /**< LED3 PORT bitmask */ | ||
|
||
#define LED_PORT (NRF_P0_S) /**< Default LED PORT */ | ||
|
||
#define LED0_ON (LED_PORT->OUTCLR = LED0_MASK) /**< LED0 ON macro */ | ||
#define LED0_OFF (LED_PORT->OUTSET = LED0_MASK) /**< LED0 OFF macro */ | ||
#define LED0_TOGGLE (LED_PORT->OUT ^= LED0_MASK) /**< LED0 toggle macro */ | ||
|
||
#define LED1_ON (LED_PORT->OUTCLR = LED1_MASK) /**< LED1 ON macro */ | ||
#define LED1_OFF (LED_PORT->OUTSET = LED1_MASK) /**< LED1 OFF macro */ | ||
#define LED1_TOGGLE (LED_PORT->OUT ^= LED1_MASK) /**< LED1 toggle macro */ | ||
|
||
#define LED2_ON (LED_PORT->OUTCLR = LED2_MASK) /**< LED2 ON macro */ | ||
#define LED2_OFF (LED_PORT->OUTSET = LED2_MASK) /**< LED2 OFF macro */ | ||
#define LED2_TOGGLE (LED_PORT->OUT ^= LED2_MASK) /**< LED2 toggle macro */ | ||
|
||
#define LED3_ON (LED_PORT->OUTCLR = LED3_MASK) /**< LED3 ON macro */ | ||
#define LED3_OFF (LED_PORT->OUTSET = LED3_MASK) /**< LED3 OFF macro */ | ||
#define LED3_TOGGLE (LED_PORT->OUT ^= LED3_MASK) /**< LED3 toggle macro */ | ||
/** @} */ | ||
|
||
/** | ||
* @name Button pin configuration | ||
* @{ | ||
*/ | ||
#define BTN0_PIN GPIO_PIN(0, 23) /**< BTN0 pin definition */ | ||
#define BTN0_MODE GPIO_IN_PU /**< BTN0 default mode */ | ||
#define BTN1_PIN GPIO_PIN(0, 24) /**< BTN1 pin definition */ | ||
#define BTN1_MODE GPIO_IN_PU /**< BTN1 default mode */ | ||
#define BTN2_PIN GPIO_PIN(0, 8) /**< BTN2 pin definition */ | ||
#define BTN2_MODE GPIO_IN_PU /**< BTN2 default mode */ | ||
#define BTN3_PIN GPIO_PIN(0, 9) /**< BTN3 pin definition */ | ||
#define BTN3_MODE GPIO_IN_PU /**< BTN3 default mode */ | ||
/** @} */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* BOARD_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* Copyright (C) 2023 Mesotic SAS | ||
* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @ingroup boards_nrf5340dk-app | ||
* @{ | ||
* | ||
* @file | ||
* @brief Peripheral configuration for the nRF5340DK-app | ||
* | ||
* @author Dylan Laduranty <[email protected]> | ||
* | ||
*/ | ||
|
||
#ifndef PERIPH_CONF_H | ||
#define PERIPH_CONF_H | ||
|
||
#include "periph_cpu.h" | ||
|
||
#include "board.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @name Timer configuration | ||
* @{ | ||
*/ | ||
static const timer_conf_t timer_config[] = { | ||
{ | ||
.dev = NRF_TIMER0_S, | ||
.channels = 5, | ||
.bitmode = TIMER_BITMODE_BITMODE_32Bit, | ||
.irqn = TIMER0_IRQn | ||
}, | ||
{ | ||
.dev = NRF_TIMER1_S, | ||
.channels = 5, | ||
.bitmode = TIMER_BITMODE_BITMODE_32Bit, | ||
.irqn = TIMER1_IRQn | ||
}, | ||
}; | ||
|
||
#define TIMER_0_ISR isr_timer0 /**< Timer0 IRQ*/ | ||
#define TIMER_1_ISR isr_timer1 /**< Timer1 IRQ */ | ||
|
||
#define TIMER_NUMOF ARRAY_SIZE(timer_config) /**< Timer configuration NUMOF */ | ||
/** @} */ | ||
|
||
/** | ||
* @name UART configuration | ||
* @{ | ||
*/ | ||
static const uart_conf_t uart_config[] = { | ||
{ | ||
.dev = NRF_UARTE0_S, | ||
.rx_pin = GPIO_PIN(1, 0), | ||
.tx_pin = GPIO_PIN(1, 1), | ||
#ifdef MODULE_PERIPH_UART_HW_FC | ||
.rts_pin = GPIO_UNDEF, | ||
.cts_pin = GPIO_UNDEF, | ||
#endif | ||
.irqn = SERIAL0_IRQn, | ||
}, | ||
}; | ||
|
||
#define UART_0_ISR (isr_serial0) /**< SERIAL0_IRQn */ | ||
|
||
#define UART_NUMOF ARRAY_SIZE(uart_config) /**< UART configuration NUMOF */ | ||
/** @} */ | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* PERIPH_CONF_H */ | ||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# Copyright (c) 2023 Mesotic SAS | ||
# | ||
# 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. | ||
|
||
# For now, define all features here | ||
# We will rely on nrf5x_common later when we support more peripherals | ||
config CPU_FAM_NRF53 | ||
bool | ||
select HAS_CPU_NRF53 | ||
select HAS_PERIPH_CPUID | ||
select HAS_PERIPH_GPIO | ||
select HAS_PERIPH_GPIO_IRQ | ||
select HAS_PERIPH_TIMER_PERIODIC | ||
select HAS_PERIPH_UART_MODECFG | ||
|
||
## CPU Models | ||
config CPU_MODEL_NRF5340_APP | ||
bool | ||
select CPU_CORE_CORTEX_M33 | ||
select CPU_FAM_NRF53 | ||
|
||
## CPU common symbols | ||
config CPU_FAM | ||
default "nrf53" if CPU_FAM_NRF53 | ||
|
||
config CPU_MODEL | ||
default "nrf5340_app" if CPU_MODEL_NRF5340_APP | ||
|
||
|
||
config CPU | ||
default "nrf53" if CPU_FAM_NRF53 | ||
|
||
## Definition of specific features | ||
config HAS_CPU_NRF53 | ||
bool | ||
help | ||
Indicates that the current cpu is 'nrf53'. | ||
|
||
rsource "vectors/Kconfig" | ||
|
||
source "$(RIOTCPU)/nrf5x_common/Kconfig" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# define the module that is build | ||
MODULE = cpu | ||
|
||
# add a list of subdirectories, that should also be build | ||
DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/nrf5x_common vectors | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
USEMODULE += nrf53_vectors | ||
|
||
include $(RIOTCPU)/nrf5x_common/Makefile.dep | ||
include $(RIOTCPU)/cortexm_common/Makefile.dep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CPU_CORE = cortex-m33 | ||
CPU_FAM = nrf53 | ||
|
||
include $(RIOTCPU)/nrf5x_common/Makefile.features |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ROM_LEN ?= 0x100000 | ||
RAM_LEN ?= 0x80000 | ||
|
||
PROGRAMMER ?= jlink | ||
JLINK_DEVICE = NRF5340_XXAA_APP | ||
|
||
include $(RIOTCPU)/nrf5x_common/Makefile.include | ||
include $(RIOTMAKE)/arch/cortexm.inc.mk |
Oops, something went wrong.