diff --git a/hw/bsp/lpcxpresso55s28/bsp.yml b/hw/bsp/lpcxpresso55s28/bsp.yml new file mode 100644 index 0000000000..d189a3de69 --- /dev/null +++ b/hw/bsp/lpcxpresso55s28/bsp.yml @@ -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 diff --git a/hw/bsp/lpcxpresso55s28/debug.sh b/hw/bsp/lpcxpresso55s28/debug.sh new file mode 100755 index 0000000000..fa069cecb5 --- /dev/null +++ b/hw/bsp/lpcxpresso55s28/debug.sh @@ -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 diff --git a/hw/bsp/lpcxpresso55s28/include/bsp/bsp.h b/hw/bsp/lpcxpresso55s28/include/bsp/bsp.h new file mode 100644 index 0000000000..a364005665 --- /dev/null +++ b/hw/bsp/lpcxpresso55s28/include/bsp/bsp.h @@ -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 +#include + +#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 */ diff --git a/hw/bsp/lpcxpresso55s28/pkg.yml b/hw/bsp/lpcxpresso55s28/pkg.yml new file mode 100644 index 0000000000..1c0aee8330 --- /dev/null +++ b/hw/bsp/lpcxpresso55s28/pkg.yml @@ -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" + diff --git a/hw/bsp/lpcxpresso55s28/src/hal_bsp.c b/hw/bsp/lpcxpresso55s28/src/hal_bsp.c new file mode 100644 index 0000000000..1e3953dee8 --- /dev/null +++ b/hw/bsp/lpcxpresso55s28/src/hal_bsp.c @@ -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 +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#if MYNEWT_VAL(TIMER_0) +#include +#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 +#include +#include +#endif +#include +#include +#include +#include +#include +#include + +#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) +{ +} diff --git a/hw/bsp/lpcxpresso55s28/syscfg.yml b/hw/bsp/lpcxpresso55s28/syscfg.yml new file mode 100644 index 0000000000..4aabbc0ef0 --- /dev/null +++ b/hw/bsp/lpcxpresso55s28/syscfg.yml @@ -0,0 +1,71 @@ +# +# 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. +# + +syscfg.defs: + BSP_LPCXPRESSO55S28: + description: 'Set to indicate that BSP has NXP LPCXpresso55s28' + value: 1 + +syscfg.vals: + MCU_LPC55S28: 1 + PYOCD_TARGET: lpc55s28 + JLINK_TARGET: LPC55S28 + MYNEWT_DOWNLOADER: pyocd + MCU_RAM_START: 0x20000000 + MCU_RAM_SIZE: 0x30000 + # UART0 PINS on CMSIS-DAP Interface + UART_0: 1 + UART_0_PIN_TX: P0_30_FC0_TXD_SCL_MISO + UART_0_PIN_RX: P0_29_FC0_RXD_SDA_MOSI + + # PINS conflict with SPI0 must choose 1 + UART_1: 0 + UART_1_PORT: PORTC + UART_1_PORT_CLOCK: kCLOCK_PortC + UART_1_PIN_TX: 3 + UART_1_PIN_RX: 4 + + # PINS conflict with SPI0 must choose 1 + UART_2: 0 + UART_2_PORT: PORTD + UART_2_PIN_TX: 2 + UART_2_PIN_RX: 3 + + # PINS conflict with ENET0 must choose 1 + UART_3: 0 + UART_3_PORT: PORTC + UART_3_PIN_TX: 16 + UART_3_PIN_RX: 17 + + # PINS conflict with ENET0 must choose 1 + UART_4: 0 + UART_4_PORT: PORTC + UART_4_PIN_TX: 14 + UART_4_PIN_RX: 15 + + # PINS conflict with I2S0 must choose 1 + UART_5: 0 + UART_5_PORT: PORTE + UART_5_PIN_TX: 9 + UART_5_PIN_RX: 8 + + CONFIG_FCB_FLASH_AREA: FLASH_AREA_NFFS + REBOOT_LOG_FLASH_AREA: FLASH_AREA_REBOOT_LOG + NFFS_FLASH_AREA: FLASH_AREA_NFFS + COREDUMP_FLASH_AREA: FLASH_AREA_IMAGE_1