Skip to content

Commit

Permalink
Merge #19769 #19782
Browse files Browse the repository at this point in the history
19769: cpu/nrf53: add initial support with nRF5340DK-APP board r=benpicco 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 <dylan.laduranty@mesotic.com>
Co-authored-by: Hugues Larrive <hlarrive@pm.me>
  • Loading branch information
3 people committed Jul 4, 2023
3 parents 852e9c5 + 9fd48a0 + 453b08f commit 44ca416
Show file tree
Hide file tree
Showing 36 changed files with 38,743 additions and 48 deletions.
18 changes: 18 additions & 0 deletions boards/nrf5340dk-app/Kconfig
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)
3 changes: 3 additions & 0 deletions boards/nrf5340dk-app/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = board

include $(RIOTBASE)/Makefile.base
7 changes: 7 additions & 0 deletions boards/nrf5340dk-app/Makefile.features
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
2 changes: 2 additions & 0 deletions boards/nrf5340dk-app/Makefile.include
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
38 changes: 38 additions & 0 deletions boards/nrf5340dk-app/doc.txt
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
```

*/
98 changes: 98 additions & 0 deletions boards/nrf5340dk-app/include/board.h
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 <dylan.laduranty@mesotic.com>
*/

#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 */
/** @} */
83 changes: 83 additions & 0 deletions boards/nrf5340dk-app/include/periph_conf.h
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 <dylan.laduranty@mesotic.com>
*
*/

#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 */
/** @} */
17 changes: 0 additions & 17 deletions cpu/nrf52/include/periph_cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,23 +201,6 @@ typedef struct {
} pwm_conf_t;
#endif

#if !defined(CPU_MODEL_NRF52832XXAA)
/**
* @brief Structure for UART configuration data
*/
typedef struct {
NRF_UARTE_Type *dev; /**< UART with EasyDMA device base
* register address */
gpio_t rx_pin; /**< RX pin */
gpio_t tx_pin; /**< TX pin */
#ifdef MODULE_PERIPH_UART_HW_FC
gpio_t rts_pin; /**< RTS pin */
gpio_t cts_pin; /**< CTS pin */
#endif
uint8_t irqn; /**< IRQ channel */
} uart_conf_t;
#endif

/**
* @brief Size of the UART TX buffer for non-blocking mode.
*/
Expand Down
43 changes: 43 additions & 0 deletions cpu/nrf53/Kconfig
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"
7 changes: 7 additions & 0 deletions cpu/nrf53/Makefile
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
4 changes: 4 additions & 0 deletions cpu/nrf53/Makefile.dep
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
4 changes: 4 additions & 0 deletions cpu/nrf53/Makefile.features
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
8 changes: 8 additions & 0 deletions cpu/nrf53/Makefile.include
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
Loading

0 comments on commit 44ca416

Please sign in to comment.