Skip to content

Commit

Permalink
Add initial support for Nordic nRF54L15
Browse files Browse the repository at this point in the history
This adds initial support for Nordic nRF54L15.
GPIO, timers, GRTC and UART is implemented.
  • Loading branch information
m-gorecki committed Dec 13, 2024
1 parent 5f8038e commit 9e8715c
Show file tree
Hide file tree
Showing 33 changed files with 5,509 additions and 12 deletions.
26 changes: 26 additions & 0 deletions hw/bsp/nordic_pca10156/boot-nrf54.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
MEMORY
{
FLASH (rx) : ORIGIN = 0x00000000, LENGTH = 0x8000
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000
}

/* The bootloader does not contain an image header */
_imghdr_size = 0x0;
59 changes: 59 additions & 0 deletions hw/bsp/nordic_pca10156/bsp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

bsp.name: "nRF54L15 PDK"
bsp.url:
bsp.maker: "Nordic Semiconductor"
bsp.arch: cortex_m33
bsp.compiler: "@apache-mynewt-core/compiler/arm-none-eabi-m33"
bsp.linkerscript: autogenerated
bsp.downloadscript: "hw/scripts/download.sh"
bsp.debugscript: "hw/bsp/nordic_pca10156/nordic_pca10156_debug.sh"

bsp.flash_map:
areas:
# System areas.
FLASH_AREA_BOOTLOADER:
device: 0
offset: 0x00000000
size: 32kB
FLASH_AREA_IMAGE_0:
device: 0
offset: 0x0000c000
size: 722kB
FLASH_AREA_IMAGE_1:
device: 0
offset: 0x000C0800
size: 722kB
FLASH_AREA_IMAGE_SCRATCH:
device: 0
offset: 0x00175000
size: 16kB

# User areas.
FLASH_AREA_REBOOT_LOG:
user_id: 0
device: 0
offset: 0x00008000
size: 16kB
FLASH_AREA_NFFS:
user_id: 1
device: 0
offset: 0x00179000
size: 16kB
57 changes: 57 additions & 0 deletions hw/bsp/nordic_pca10156/include/bsp/bsp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/

#ifndef _BSP_H_
#define _BSP_H_

#include <inttypes.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Define special stackos sections */
#define sec_data_core __attribute__((section(".data.core")))
#define sec_bss_core __attribute__((section(".bss.core")))
#define sec_bss_nz_core __attribute__((section(".bss.core.nz")))

/* More convenient section placement macros. */
#define bssnz_t sec_bss_nz_core

extern uint8_t _ram_start;
#define RAM_SIZE 0x40000

/* LED pins */
#define LED_1 (73)
#define LED_2 (42)
#define LED_3 (71)
#define LED_4 (46)
#define LED_BLINK_PIN (LED_1)

/* Buttons */
#define BUTTON_1 (45)
#define BUTTON_2 (41)
#define BUTTON_3 (40)
#define BUTTON_4 (4)

#ifdef __cplusplus
}
#endif

#endif /* _BSP_H_ */
37 changes: 37 additions & 0 deletions hw/bsp/nordic_pca10156/nordic_pca10156_debug.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

# Called with following variables set:
# - CORE_PATH is absolute path to @apache-mynewt-core
# - BSP_PATH is absolute path to hw/bsp/bsp_name
# - BIN_BASENAME is the path to prefix to target binary,
# .elf appended to name is the ELF file
# - FEATURES holds the target features string
# - EXTRA_JTAG_CMD holds extra parameters to pass to jtag software
# - RESET set if target should be reset when attaching
# - NO_GDB set if we should not start gdb to debug
#

. $CORE_PATH/hw/scripts/jlink.sh

FILE_NAME=$BIN_BASENAME.elf
JLINK_DEV="Cortex-M33"

jlink_debug

26 changes: 26 additions & 0 deletions hw/bsp/nordic_pca10156/nrf54.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
MEMORY
{
FLASH (rx) : ORIGIN = 0x00008000, LENGTH = 0x171000
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 0x40000
}

/* This linker script is used for images and thus contains an image header */
_imghdr_size = 0x20;
45 changes: 45 additions & 0 deletions hw/bsp/nordic_pca10156/pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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.
#

pkg.name: hw/bsp/nordic_pca10156
pkg.type: bsp
pkg.description: BSP definition for the Nordic PCA10156 (nRF54L15-PDK)
pkg.author: "Apache Mynewt <dev@mynewt.apache.org>"
pkg.homepage: "http://mynewt.apache.org/"
pkg.keywords:
- nrf54
- nordic
- pca10156

pkg.cflags:
- '-DNRF54L15_XXAA'
- '-DNRF_APPLICATION'

pkg.cflags.HARDFLOAT:
- -mfloat-abi=hard -mfpu=fpv4-sp-d16

pkg.deps:
- "@apache-mynewt-core/hw/scripts"
- "@apache-mynewt-core/hw/mcu/nordic/nrf54lxx"
- "@apache-mynewt-core/libc/baselibc"
- "@apache-mynewt-core/sys/flash_map"
- "@apache-mynewt-core/boot/startup"

pkg.deps.SOFT_PWM:
- "@apache-mynewt-core/hw/drivers/pwm/soft_pwm"
82 changes: 82 additions & 0 deletions hw/bsp/nordic_pca10156/src/hal_bsp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 <stdint.h>
#include <stddef.h>
#include <assert.h>
#include <os/mynewt.h>
#include <nrfx.h>
#include <flash_map/flash_map.h>
#include <hal/hal_bsp.h>
#include <hal/hal_flash.h>
#include <hal/hal_system.h>
#include <mcu/nrf54l_hal.h>
#include <mcu/nrf54l_periph.h>
#include <bsp/bsp.h>

/*
* What memory to include in coredump.
*/
static const struct hal_bsp_mem_dump dump_cfg[] = {
[0] = {
.hbmd_start = &_ram_start,
.hbmd_size = RAM_SIZE
}
};

const struct hal_flash *
hal_bsp_flash_dev(uint8_t id)
{
/*
* Internal flash mapped to id 0.
*/
if (id == 0) {
return &nrf54l_flash_dev;
}

return NULL;
}

const struct hal_bsp_mem_dump *
hal_bsp_core_dump(int *area_cnt)
{
*area_cnt = sizeof(dump_cfg) / sizeof(dump_cfg[0]);
return dump_cfg;
}

int
hal_bsp_power_state(int state)
{
return 0;
}

void
hal_bsp_init(void)
{
/* Make sure system clocks have started */
hal_system_clock_start();

/* Create all available nRF54 peripherals */
nrf54l_periph_create();
}

void
hal_bsp_deinit(void)
{
}
60 changes: 60 additions & 0 deletions hw/bsp/nordic_pca10156/src/sbrk.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 <hal/hal_bsp.h>

/* put these in the data section so they are not cleared by _start */
static char *sbrkBase __attribute__ ((section (".data")));
static char *sbrkLimit __attribute__ ((section (".data")));
static char *brk __attribute__ ((section (".data")));

void
_sbrkInit(char *base, char *limit)
{
sbrkBase = base;
sbrkLimit = limit;
brk = base;
}

void *
_sbrk(int incr)
{
void *prev_brk;

if (incr < 0) {
/* Returning memory to the heap. */
incr = -incr;
if (brk - incr < sbrkBase) {
prev_brk = (void *)-1;
} else {
prev_brk = brk;
brk -= incr;
}
} else {
/* Allocating memory from the heap. */
if (sbrkLimit - brk >= incr) {
prev_brk = brk;
brk += incr;
} else {
prev_brk = (void *)-1;
}
}

return prev_brk;
}
Loading

0 comments on commit 9e8715c

Please sign in to comment.