Skip to content

Commit

Permalink
hw/bsp: Add lpcxpresso55s28 BSP
Browse files Browse the repository at this point in the history
This adds support for NXP LPCXPRESSO55S28 board.
  • Loading branch information
kasjer committed Aug 19, 2024
1 parent 88bbce1 commit 7fb2d0d
Show file tree
Hide file tree
Showing 7 changed files with 452 additions and 0 deletions.
1 change: 1 addition & 0 deletions .rat-excludes
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ boot-MK82FN256xxx15_flash.ld
startup_MK82F25615.S
system_MK82F25615.c
fsl_ftfx_controller.c
startup_LPC55S28.S

# LWIP - BSD License.
lwip_base
Expand Down
59 changes: 59 additions & 0 deletions hw/bsp/lpcxpresso55s28/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: "LPCXpresso55s28: Freedom Development Platform"
bsp.url: https://www.nxp.com/design/development-boards/lpcxpresso-boards/lpcxpresso55s28-development-board:LPC55S28-EVK
bsp.maker: "NXP"
bsp.arch: cortex_m33
bsp.compiler: compiler/arm-none-eabi-m33
bsp.linkerscript: autogenerated
bsp.downloadscript: "@apache-mynewt-core/hw/scripts/download.sh"
bsp.debugscript: "@apache-mynewt-core/hw/bsp/lpcxpresso55s28/debug.sh"

bsp.flash_map:
areas:
# System areas.
FLASH_AREA_BOOTLOADER:
device: 0
offset: 0x00000000
size: 40kB
FLASH_AREA_IMAGE_SCRATCH:
device: 0
offset: 0x0000A000
size: 8kB
FLASH_AREA_IMAGE_0:
device: 0
offset: 0x0000C000
size: 216kB
FLASH_AREA_IMAGE_1:
device: 0
offset: 0x00042000
size: 216kB

# User areas
FLASH_AREA_REBOOT_LOG:
user_id: 0
device: 0
offset: 0x00078000
size: 16kB
FLASH_AREA_NFFS:
user_id: 1
device: 0
offset: 0x0007C000
size: 16kB
37 changes: 37 additions & 0 deletions hw/bsp/lpcxpresso55s28/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/pyocd.sh

FILE_NAME=$BIN_BASENAME.elf
TARGET=lpc55s28
EXTRA_GDB_CMDS="mem 0x20030000 0xffffffff rw nocache"

pyocd_debug
61 changes: 61 additions & 0 deletions hw/bsp/lpcxpresso55s28/include/bsp/bsp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* 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 H_BSP_H
#define H_BSP_H

#include <stdint.h>
#include <mcu/mcu.h>

#ifdef __cplusplus
extern "C" {
#endif

extern uint8_t __DATA_ROM;
#define SRAM0_BASE 0x20000000
#define SRAM1_BASE 0x20010000
#define SRAM2_BASE 0x20020000
#define SRAM4_BASE 0x20040000
#define SRAM0_SIZE 0x10000
#define SRAM1_SIZE 0x10000
#define SRAM2_SIZE 0x10000
#define SRAM4_SIZE 0x4000
#define SRAMX_BASE 0x04000000
#define SRAMX_SIZE 0x8000

#define RAM_SIZE (SRAM0_SIZE + SRAM1_SIZE + SRAM2_SIZE)
extern uint8_t _ram_start[];

/* LED pins */
#define LED_1 MCU_GPIO_PORT1(6)
#define LED_2 MCU_GPIO_PORT1(7)
#define LED_3 MCU_GPIO_PORT1(4)
#define LED_RED LED_1
#define LED_GREEN LED_2
#define LED_BLUE LED_3
#define LED_BLINK_PIN LED_BLUE

/* Button pin */
#define BUTTON_1 MCU_GPIO_PORT0(5)
#define BUTTON_2 MCU_GPIO_PORT1(9)

#ifdef __cplusplus
}
#endif

#endif /* H_BSP_H */
38 changes: 38 additions & 0 deletions hw/bsp/lpcxpresso55s28/pkg.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#
# 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/lpcxpresso55s28"
pkg.type: bsp
pkg.description: BSP definition for NXP LPCXpresso55S28.
pkg.keywords:
- LPCXpresso55S28
- nxp

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

pkg.deps:
- "@apache-mynewt-core/hw/mcu/nxp/lpc55xx"
- "@apache-mynewt-core/hw/scripts"
- "@apache-mynewt-core/libc/baselibc"
- "@apache-mynewt-core/boot/startup"

185 changes: 185 additions & 0 deletions hw/bsp/lpcxpresso55s28/src/hal_bsp.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
/*
* 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 <stddef.h>
#include <stdint.h>
#include <errno.h>
#include <sys/types.h>
#include <stdio.h>
#include <os/mynewt.h>
#include <bsp/bsp.h>
#include <hal/hal_bsp.h>
#include <hal/hal_flash_int.h>
#include <flash_map/flash_map.h>
#include <hal/hal_flash.h>
#include <fsl_iap.h>
#include <fsl_iap_ffr.h>
#if MYNEWT_VAL(TIMER_0)
#include <hal/hal_timer.h>
#endif
#if MYNEWT_VAL(UART_0) || MYNEWT_VAL(UART_1) || MYNEWT_VAL(UART_2) || \
MYNEWT_VAL(UART_3) || MYNEWT_VAL(UART_4) || MYNEWT_VAL(UART_5)
#include <uart/uart.h>
#include <uart_hal/uart_hal.h>
#include <hal/hal_uart.h>
#endif
#include <mcu/cmsis_nvic.h>
#include <fsl_device_registers.h>
#include <fsl_common.h>
#include <fsl_clock.h>
#include <clock_config.h>
#include <mcu/mcux_hal.h>

#if MYNEWT_VAL(UART_0)
static struct uart_dev os_bsp_uart0;
#endif
#if MYNEWT_VAL(UART_1)
static struct uart_dev os_bsp_uart1;
#endif
#if MYNEWT_VAL(UART_2)
static struct uart_dev os_bsp_uart2;
#endif
#if MYNEWT_VAL(UART_3)
static struct uart_dev os_bsp_uart3;
#endif
#if MYNEWT_VAL(UART_4)
static struct uart_dev os_bsp_uart4;
#endif
#if MYNEWT_VAL(UART_5)
static struct uart_dev os_bsp_uart5;
#endif

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

const struct hal_flash *
hal_bsp_flash_dev(uint8_t id)
{
if (id == 0) {
return &mcux_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;
}

/**
* Returns the configured priority for the given interrupt. If no priority
* configured, return the priority passed in
*
* @param irq_num
* @param pri
*
* @return uint32_t
*/
uint32_t
hal_bsp_get_nvic_priority(int irq_num, uint32_t pri)
{
/* Add any interrupt priorities configured by the bsp here */
return pri;
}

static flash_config_t config;

void
hal_bsp_init(void)
{
int rc = 0;

(void)rc;

FFR_Init(&config);

#if MYNEWT_VAL(TIMER_0)
rc = hal_timer_init(0, NULL);
assert(rc == 0);
#endif

#if MYNEWT_VAL(UART_0)
rc = os_dev_create((struct os_dev *) &os_bsp_uart0, "uart0",
OS_DEV_INIT_PRIMARY, 0, uart_hal_init, NULL);
assert(rc == 0);
#endif
#if MYNEWT_VAL(UART_1)
rc = os_dev_create((struct os_dev *) &os_bsp_uart1, "uart1",
OS_DEV_INIT_PRIMARY, 0, uart_hal_init, NULL);
assert(rc == 0);
#endif
#if MYNEWT_VAL(UART_2)
rc = os_dev_create((struct os_dev *) &os_bsp_uart2, "uart2",
OS_DEV_INIT_PRIMARY, 0, uart_hal_init, NULL);
assert(rc == 0);
#endif
#if MYNEWT_VAL(UART_3)
rc = os_dev_create((struct os_dev *) &os_bsp_uart3, "uart3",
OS_DEV_INIT_PRIMARY, 0, uart_hal_init, NULL);
assert(rc == 0);
#endif
#if MYNEWT_VAL(UART_4)
rc = os_dev_create((struct os_dev *) &os_bsp_uart4, "uart4",
OS_DEV_INIT_PRIMARY, 0, uart_hal_init, NULL);
assert(rc == 0);
#endif
#if MYNEWT_VAL(UART_5)
rc = os_dev_create((struct os_dev *) &os_bsp_uart5, "uart5",
OS_DEV_INIT_PRIMARY, 0, uart_hal_init, NULL);
assert(rc == 0);
#endif
}

int
hal_bsp_hw_id_len(void)
{
return 16;
}

int
hal_bsp_hw_id(uint8_t *id, int max_len)
{
if (max_len < 16) {
return -1;
}
status_t status = FFR_GetUUID(&config, id);
return status == kStatus_Success ? 16 : -1;
}



void
hal_bsp_deinit(void)
{
}
Loading

0 comments on commit 7fb2d0d

Please sign in to comment.