You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/07/09 15:37:41 UTC

[incubator-nuttx] 02/02: boards: add initial support for stm32l0538-disco

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit b3e11b605ad95e08b8e2b9acf05a30e8fd3b26b1
Author: raiden00pl <ra...@railab.me>
AuthorDate: Thu Jul 7 19:22:04 2022 +0200

    boards: add initial support for stm32l0538-disco
---
 boards/Kconfig                                     |  17 +-
 boards/arm/stm32f0l0g0/stm32l0538-disco/Kconfig    |   8 +
 boards/arm/stm32f0l0g0/stm32l0538-disco/README.txt |  15 ++
 .../stm32l0538-disco/configs/nsh/defconfig         |  50 ++++++
 .../stm32f0l0g0/stm32l0538-disco/include/board.h   | 193 +++++++++++++++++++++
 .../stm32f0l0g0/stm32l0538-disco/scripts/Make.defs |  41 +++++
 .../stm32f0l0g0/stm32l0538-disco/scripts/ld.script | 112 ++++++++++++
 .../arm/stm32f0l0g0/stm32l0538-disco/src/Makefile  |  39 +++++
 .../stm32l0538-disco/src/stm32_appinit.c           |  71 ++++++++
 .../stm32l0538-disco/src/stm32_autoleds.c          |  78 +++++++++
 .../stm32f0l0g0/stm32l0538-disco/src/stm32_boot.c  |  77 ++++++++
 .../stm32l0538-disco/src/stm32_bringup.c           |  85 +++++++++
 .../stm32l0538-disco/src/stm32_buttons.c           | 116 +++++++++++++
 .../stm32l0538-disco/src/stm32l0538-disco.h        | 102 +++++++++++
 14 files changed, 1002 insertions(+), 2 deletions(-)

diff --git a/boards/Kconfig b/boards/Kconfig
index 0cb6e5fed4..ce75222761 100644
--- a/boards/Kconfig
+++ b/boards/Kconfig
@@ -1880,6 +1880,15 @@ config ARCH_BOARD_STM3240G_EVAL
 		microcontroller (ARM Cortex-M4 with FPU).  This port uses a GNU Cortex-M4
 		toolchain (such as CodeSourcery).
 
+config ARCH_BOARD_STM32L0538_DISCO
+	bool "STMicro STM32L0538-Disco board"
+	depends on ARCH_CHIP_STM32L053C8
+	select ARCH_HAVE_LEDS
+	select ARCH_HAVE_BUTTONS
+	select ARCH_HAVE_IRQBUTTONS
+	---help---
+		STMicro STM32L0538-Disco board based on the STMicro STM32L053C8 MCU.
+
 config ARCH_BOARD_STM32F051_DISCOVERY
 	bool "STMicro STM32F051-Discovery board"
 	depends on ARCH_CHIP_STM32F051R8
@@ -1887,7 +1896,7 @@ config ARCH_BOARD_STM32F051_DISCOVERY
 	select ARCH_HAVE_BUTTONS
 	select ARCH_HAVE_IRQBUTTONS
 	---help---
-		STMicro STM32F051-Discovery board based on the STMicro ARCH_CHIP_STM32F051R8 MCU.
+		STMicro STM32F051-Discovery board based on the STMicro STM32F051R8 MCU.
 
 config ARCH_BOARD_STM32F072_DISCOVERY
 	bool "STMicro STM32F072-Discovery board"
@@ -1896,7 +1905,7 @@ config ARCH_BOARD_STM32F072_DISCOVERY
 	select ARCH_HAVE_BUTTONS
 	select ARCH_HAVE_IRQBUTTONS
 	---help---
-		STMicro STM32F072-Discovery board based on the STMicro ARCH_CHIP_STM32F072RB MCU.
+		STMicro STM32F072-Discovery board based on the STMicro STM32F072RB MCU.
 
 config ARCH_BOARD_STM32F3_DISCOVERY
 	bool "STMicro STM32F3-Discovery board"
@@ -2654,6 +2663,7 @@ config ARCH_BOARD
 	default "pnev5180b"                if ARCH_BOARD_PNEV5180B
 	default "stm32butterfly2"          if ARCH_BOARD_STM32_BUTTERFLY2
 	default "stm32_tiny"               if ARCH_BOARD_STM32_TINY
+	default "stm32l0538-disco"         if ARCH_BOARD_STM32L0538_DISCO
 	default "stm32f051-discovery"      if ARCH_BOARD_STM32F051_DISCOVERY
 	default "stm32f072-discovery"      if ARCH_BOARD_STM32F072_DISCOVERY
 	default "stm32f103-minimum"        if ARCH_BOARD_STM32F103_MINIMUM
@@ -3059,6 +3069,9 @@ endif
 if ARCH_BOARD_STM32F051_DISCOVERY
 source "boards/arm/stm32f0l0g0/stm32f051-discovery/Kconfig"
 endif
+if ARCH_BOARD_STM32L0538_DISCO
+source "boards/arm/stm32f0l0g0/stm32l0538-disco/Kconfig"
+endif
 if ARCH_BOARD_STM32F072_DISCOVERY
 source "boards/arm/stm32f0l0g0/stm32f072-discovery/Kconfig"
 endif
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/Kconfig b/boards/arm/stm32f0l0g0/stm32l0538-disco/Kconfig
new file mode 100644
index 0000000000..f7e10a7921
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/Kconfig
@@ -0,0 +1,8 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+if ARCH_BOARD_STM32L0538_DISCO
+
+endif
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/README.txt b/boards/arm/stm32f0l0g0/stm32l0538-disco/README.txt
new file mode 100644
index 0000000000..3a7c0da3b8
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/README.txt
@@ -0,0 +1,15 @@
+README
+======
+
+  This README discusses issues unique to NuttX configurations for the
+  STMicro STM32L0538-DISO development board.  The STM32L0538-DISO board
+  is based on the STM32L053C8 MCU (64Kbytes FLASH, 8Kbytes of SRAM and
+  6Kbytes of EEPROM).
+
+  The board features:
+
+    - An ST-LINK/V2-1 embedded debug tool interface,
+    - 2.13" E-paper display, 122×250 pixels
+    - USB 2.0 FS
+    - One linear touch sensor or four touchkeys
+    - IDD current measurement
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/configs/nsh/defconfig b/boards/arm/stm32f0l0g0/stm32l0538-disco/configs/nsh/defconfig
new file mode 100644
index 0000000000..a593c3b222
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/configs/nsh/defconfig
@@ -0,0 +1,50 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_LIBC_LONG_LONG is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="stm32l0538-disco"
+CONFIG_ARCH_BOARD_STM32L0538_DISCO=y
+CONFIG_ARCH_CHIP="stm32f0l0g0"
+CONFIG_ARCH_CHIP_STM32L053C8=y
+CONFIG_ARCH_CHIP_STM32L053XX=y
+CONFIG_ARCH_CHIP_STM32L0=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARD_LOOPSPERMSEC=2796
+CONFIG_BUILTIN=y
+CONFIG_DEBUG_FULLOPT=y
+CONFIG_DEBUG_SYMBOLS=y
+CONFIG_DEFAULT_TASK_STACKSIZE=1024
+CONFIG_DISABLE_ENVIRON=y
+CONFIG_DISABLE_MOUNTPOINT=y
+CONFIG_DISABLE_MQUEUE=y
+CONFIG_DISABLE_POSIX_TIMERS=y
+CONFIG_DISABLE_PSEUDOFS_OPERATIONS=y
+CONFIG_EXAMPLES_HELLO=y
+CONFIG_EXPERIMENTAL=y
+CONFIG_INIT_ENTRYPOINT="nsh_main"
+CONFIG_INTELHEX_BINARY=y
+CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NUNGET_CHARS=0
+CONFIG_PREALLOC_TIMERS=0
+CONFIG_PTHREAD_MUTEX_UNSAFE=y
+CONFIG_RAM_SIZE=8192
+CONFIG_RAM_START=0x20000000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_WAITPID=y
+CONFIG_START_DAY=19
+CONFIG_START_MONTH=5
+CONFIG_START_YEAR=2013
+CONFIG_STDIO_DISABLE_BUFFERING=y
+CONFIG_STM32F0L0G0_PWR=y
+CONFIG_STM32F0L0G0_USART1=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_TASK_NAME_SIZE=0
+CONFIG_TLS_NELEM=0
+CONFIG_USART1_SERIAL_CONSOLE=y
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/include/board.h b/boards/arm/stm32f0l0g0/stm32l0538-disco/include/board.h
new file mode 100644
index 0000000000..c21ae58ad1
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/include/board.h
@@ -0,0 +1,193 @@
+/****************************************************************************
+ * boards/arm/stm32f0l0g0/stm32l0538-disco/include/board.h
+ *
+ * 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 __BOARDS_ARM_STM32F0L0G0_STM32L0538_DISCO_INCLUDE_BOARD_H
+#define __BOARDS_ARM_STM32F0L0G0_STM32L0538_DISCO_INCLUDE_BOARD_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Clocking *****************************************************************/
+
+/* HSI - Internal 16 MHz RC Oscillator
+ * LSI - 32 KHz RC
+ * HSE - 8 MHz from MCO output of ST-LINK
+ * LSE - 32.768 kHz
+ */
+
+#define STM32_BOARD_XTAL        8000000ul
+
+#define STM32_HSEBYP_ENABLE
+#define STM32_HSI_FREQUENCY     16000000ul
+#define STM32_LSI_FREQUENCY     32000            /* Between 30kHz and 60kHz */
+#define STM32_HSE_FREQUENCY     STM32_BOARD_XTAL
+#define STM32_LSE_FREQUENCY     32768            /* X2 on board */
+
+/* PLL source is HSE/1, PLL multipler is 8:
+ *   PLL frequency is 8MHz (XTAL) x 8 = 64MHz
+ */
+
+#define STM32_CFGR_PLLSRC       RCC_CFGR_PLLSRC
+#define STM32_CFGR_PLLXTPRE     0
+#define STM32_CFGR_PLLMUL       RCC_CFGR_PLLMUL_CLKx8
+#define STM32_PLL_FREQUENCY     (8*STM32_BOARD_XTAL)
+
+/* Use the PLL and set the SYSCLK source to be the PLL/2 (32MHz) */
+
+#define STM32_SYSCLK_SW         RCC_CFGR_SW_PLL
+#define STM32_SYSCLK_SWS        RCC_CFGR_SWS_PLL
+#define STM32_CFGR_PLLDIV       RCC_CFGR_PLLDIV_2
+#define STM32_SYSCLK_FREQUENCY  STM32_PLL_FREQUENCY/2
+
+/* AHB clock (HCLK) is SYSCLK (32MHz) */
+
+#define STM32_RCC_CFGR_HPRE     RCC_CFGR_HPRE_SYSCLK
+#define STM32_HCLK_FREQUENCY    STM32_SYSCLK_FREQUENCY
+
+/* APB2 clock (PCLK2) is HCLK (32MHz) */
+
+#define STM32_RCC_CFGR_PPRE2    RCC_CFGR_PPRE2_HCLK
+#define STM32_PCLK2_FREQUENCY   STM32_HCLK_FREQUENCY
+#define STM32_APB2_CLKIN        (STM32_PCLK2_FREQUENCY)
+
+/* APB1 clock (PCLK1) is HCLK/2 (16MHz) */
+
+#define STM32_RCC_CFGR_PPRE1    RCC_CFGR_PPRE1_HCLKd2
+#define STM32_PCLK1_FREQUENCY   (STM32_HCLK_FREQUENCY/2)
+
+/* 48MHz clock configuration */
+
+#if defined(CONFIG_STM32F0L0G0_USB) || defined(CONFIG_STM32F0L0G0_RNG)
+#  define STM32_USE_CLK48       1
+#  define STM32_CLK48_SEL       RCC_CCIPR_CLK48SEL_HSI48
+#  define STM32_HSI48_SYNCSRC   SYNCSRC_NONE
+#endif
+
+/* TODO: timers */
+
+/* LED definitions **********************************************************/
+
+/* The STM32L0538-DISCO board has three LEDs.  Two of these are controlled by
+ * logic on the board and are not available for software control:
+ *
+ * LD1 COM:  LD1 default status is red.  LD1 turns to green to indicate that
+ *           communications are in progress between the PC and the
+ *           ST-LINK/V2-1.
+ * LD3 PWR:  red LED indicates that the board is powered.
+ *
+ * And one can be controlled by software:
+ *
+ * User LD2: green LED is a user LED connected to the I/O PA5 of the
+ *           STM32L053C8T6.
+ *
+ * If CONFIG_ARCH_LEDS is not defined, then the user can control the LED in
+ * any way.  The following definition is used to access the LED.
+ */
+
+/* LED index values for use with board_userled() */
+
+#define BOARD_LED1       0 /* User LD2 */
+#define BOARD_NLEDS      1
+
+/* LED bits for use with board_userled_all() */
+
+#define BOARD_LED1_BIT   (1 << BOARD_LED1)
+
+/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board
+ * the STM32L0538-DISCO.  The following definitions describe how NuttX
+ * controls the LED:
+ *
+ *   SYMBOL              Meaning                  LED1 state
+ *   ------------------  -----------------------  ----------
+ *   LED_STARTED         NuttX has been started   OFF
+ *   LED_HEAPALLOCATE    Heap has been allocated  OFF
+ *   LED_IRQSENABLED     Interrupts enabled       OFF
+ *   LED_STACKCREATED    Idle stack created       ON
+ *   LED_INIRQ           In an interrupt          No change
+ *   LED_SIGNAL          In a signal handler      No change
+ *   LED_ASSERTION       An assertion failed      No change
+ *   LED_PANIC           The system has crashed   Blinking
+ *   LED_IDLE            STM32 is is sleep mode   Not used
+ */
+
+#define LED_STARTED      0
+#define LED_HEAPALLOCATE 0
+#define LED_IRQSENABLED  0
+#define LED_STACKCREATED 1
+#define LED_INIRQ        2
+#define LED_SIGNAL       2
+#define LED_ASSERTION    2
+#define LED_PANIC        1
+
+/* Button definitions *******************************************************/
+
+/* The STM32L0538-DISCO supports two buttons; only one button is controllable
+ * by software:
+ *
+ *   B1 USER:  user button connected to the I/O PA0 of the STM32L053C8T6.
+ *   B2 RESET: push button connected to NRST is used to RESET the
+ *             STM32L053C8T6.
+ */
+
+#define BUTTON_USER      0
+#define NUM_BUTTONS      1
+
+#define BUTTON_USER_BIT  (1 << BUTTON_USER)
+
+/* Alternate function pin selections ****************************************/
+
+/* USART */
+
+/* By default the USART1 is connected to STLINK Virtual COM Port:
+ *   USART1_RX - PA10
+ *   USART1_TX - PA9
+ */
+
+#define GPIO_USART1_RX GPIO_USART1_RX_1 /* PA10 */
+#define GPIO_USART1_TX GPIO_USART1_TX_1 /* PA9 */
+
+/* SPI1 - E-papper display:
+ *   SPI1_MISO - not used
+ *   SPI1_MOSI - PB5
+ *   SPI1_SCK  - PB3
+ */
+
+#undef  GPIO_SPI1_MISO                  /* Not used */
+#define GPIO_SPI1_MOSI GPIO_SPI1_MOSI_3 /* PB5 */
+#define GPIO_SPI1_SCK  GPIO_SPI1_SCK_2  /* PB3 */
+
+/* SPI2 - NFC connector:
+ *   SPI2_MISO - PB14
+ *   SPI2_MOSI - PB15
+ *   SPI2_SCK  - PB13
+ */
+
+#define GPIO_SPI2_MISO GPIO_SPI2_MISO_1 /* PB14 */
+#define GPIO_SPI2_MOSI GPIO_SPI2_MOSI_1 /* PB15 */
+#define GPIO_SPI2_SCK  GPIO_SPI2_SCK_3  /* PB13 */
+
+#endif /* __BOARDS_ARM_STM32F0L0G0_STM32L0538_DISCO_INCLUDE_BOARD_H */
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/scripts/Make.defs b/boards/arm/stm32f0l0g0/stm32l0538-disco/scripts/Make.defs
new file mode 100644
index 0000000000..f00ff5ea9e
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/scripts/Make.defs
@@ -0,0 +1,41 @@
+############################################################################
+# boards/arm/stm32f0l0g0/stm32l0538-disco/scripts/Make.defs
+#
+# 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 $(TOPDIR)/.config
+include $(TOPDIR)/tools/Config.mk
+include $(TOPDIR)/arch/arm/src/armv6-m/Toolchain.defs
+
+LDSCRIPT = ld.script
+ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
+
+ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
+ARCHWARNINGSXX = -Wall -Wshadow -Wundef
+ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
+
+CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
+CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
+CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe
+CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
+CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS)
+AFLAGS := $(CFLAGS) -D__ASSEMBLY__
+
+NXFLATLDFLAGS1 = -r -d -warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
+LDNXFLATFLAGS = -e main -s 2048
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/scripts/ld.script b/boards/arm/stm32f0l0g0/stm32l0538-disco/scripts/ld.script
new file mode 100644
index 0000000000..b0ec49a950
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/scripts/ld.script
@@ -0,0 +1,112 @@
+/****************************************************************************
+ * boards/arm/stm32f0l0g0/stm32l0538-disco/scripts/ld.script
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/* The STM32L0538-DISCO has 64Kb of FLASH beginning at address 0x0800:0000.
+ * 8Kb of SRAM and 6Kb of EEPROM
+ *
+ * When booting from FLASH, FLASH memory is aliased to address 0x0000:0000
+ * where the code expects to begin execution by jumping to the entry point in
+ * the 0x0800:0000 address range.
+ */
+
+MEMORY
+{
+  flash (rx) : ORIGIN = 0x08000000, LENGTH = 64K
+  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 8K
+}
+
+OUTPUT_ARCH(arm)
+EXTERN(_vectors)
+ENTRY(_stext)
+SECTIONS
+{
+    .text : {
+        _stext = ABSOLUTE(.);
+        *(.vectors)
+        *(.text .text.*)
+        *(.fixup)
+        *(.gnu.warning)
+        *(.rodata .rodata.*)
+        *(.gnu.linkonce.t.*)
+        *(.glue_7)
+        *(.glue_7t)
+        *(.got)
+        *(.gcc_except_table)
+        *(.gnu.linkonce.r.*)
+        _etext = ABSOLUTE(.);
+    } > flash
+
+    .init_section : ALIGN(4) {
+        _sinit = ABSOLUTE(.);
+        *(.init_array .init_array.*)
+        _einit = ABSOLUTE(.);
+    } > flash
+
+    .ARM.extab : ALIGN(4) {
+        *(.ARM.extab*)
+    } > flash
+
+    .ARM.exidx : ALIGN(4) {
+        __exidx_start = ABSOLUTE(.);
+        *(.ARM.exidx*)
+        __exidx_end = ABSOLUTE(.);
+    } > flash
+
+    _eronly = ABSOLUTE(.);
+
+    /* The RAM vector table (if present) should lie at the beginning of SRAM */
+
+    .ram_vectors : {
+        *(.ram_vectors)
+    } > sram
+
+    .data : ALIGN(4) {
+        _sdata = ABSOLUTE(.);
+        *(.data .data.*)
+        *(.gnu.linkonce.d.*)
+        CONSTRUCTORS
+        . = ALIGN(4);
+        _edata = ABSOLUTE(.);
+    } > sram AT > flash
+
+    .bss : ALIGN(4) {
+        _sbss = ABSOLUTE(.);
+        *(.bss .bss.*)
+        *(.gnu.linkonce.b.*)
+        *(COMMON)
+        . = ALIGN(4);
+        _ebss = ABSOLUTE(.);
+    } > sram
+
+    /* Stabs debugging sections. */
+
+    .stab 0 : { *(.stab) }
+    .stabstr 0 : { *(.stabstr) }
+    .stab.excl 0 : { *(.stab.excl) }
+    .stab.exclstr 0 : { *(.stab.exclstr) }
+    .stab.index 0 : { *(.stab.index) }
+    .stab.indexstr 0 : { *(.stab.indexstr) }
+    .comment 0 : { *(.comment) }
+    .debug_abbrev 0 : { *(.debug_abbrev) }
+    .debug_info 0 : { *(.debug_info) }
+    .debug_line 0 : { *(.debug_line) }
+    .debug_pubnames 0 : { *(.debug_pubnames) }
+    .debug_aranges 0 : { *(.debug_aranges) }
+}
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/src/Makefile b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/Makefile
new file mode 100644
index 0000000000..4a3cbb6dc1
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/Makefile
@@ -0,0 +1,39 @@
+############################################################################
+# boards/arm/stm32f0l0g0/stm32l0538-disco/src/Makefile
+#
+# 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 $(TOPDIR)/Make.defs
+
+CSRCS = stm32_boot.c stm32_bringup.c
+
+ifeq ($(CONFIG_ARCH_LEDS),y)
+CSRCS += stm32_autoleds.c
+else
+CSRCS += stm32_userleds.c
+endif
+
+ifeq ($(CONFIG_ARCH_BUTTONS),y)
+CSRCS += stm32_buttons.c
+endif
+
+ifeq ($(CONFIG_BOARDCTL),y)
+CSRCS += stm32_appinit.c
+endif
+
+include $(TOPDIR)/boards/Board.mk
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_appinit.c b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_appinit.c
new file mode 100644
index 0000000000..3bae36e748
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_appinit.c
@@ -0,0 +1,71 @@
+/****************************************************************************
+ * boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_appinit.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+
+#include "stm32l0538-disco.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_app_initialize
+ *
+ * Description:
+ *   Perform application specific initialization.  This function is never
+ *   called directly from application code, but only indirectly via the
+ *   (non-standard) boardctl() interface using the command BOARDIOC_INIT.
+ *
+ * Input Parameters:
+ *   arg - The boardctl() argument is passed to the board_app_initialize()
+ *         implementation without modification.  The argument has no
+ *         meaning to NuttX; the meaning of the argument is a contract
+ *         between the board-specific initialization logic and the
+ *         matching application logic.  The value could be such things as a
+ *         mode enumeration value, a set of DIP switch switch settings, a
+ *         pointer to configuration data read from a file or serial FLASH,
+ *         or whatever you would like to do with it.  Every implementation
+ *         should accept zero/NULL as a default configuration.
+ *
+ * Returned Value:
+ *   Zero (OK) is returned on success; a negated errno value is returned on
+ *   any failure to indicate the nature of the failure.
+ *
+ ****************************************************************************/
+
+int board_app_initialize(uintptr_t arg)
+{
+#ifdef CONFIG_BOARD_LATE_INITIALIZE
+  /* Board initialization already performed by board_late_initialize() */
+
+  return OK;
+#else
+  /* Perform board-specific initialization */
+
+  return stm32_bringup();
+#endif
+}
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_autoleds.c b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_autoleds.c
new file mode 100644
index 0000000000..84d8e2a62d
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_autoleds.c
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_autoleds.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#include <nuttx/board.h>
+
+#include "stm32_gpio.h"
+#include "stm32l0538-disco.h"
+
+#include <arch/board/board.h>
+
+#ifdef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_autoled_initialize
+ ****************************************************************************/
+
+void board_autoled_initialize(void)
+{
+  /* Configure LED1 GPIO for output */
+
+  stm32_configgpio(GPIO_LED1);
+}
+
+/****************************************************************************
+ * Name: board_autoled_on
+ ****************************************************************************/
+
+void board_autoled_on(int led)
+{
+  if (led == BOARD_LED1)
+    {
+      stm32_gpiowrite(GPIO_LED1, true);
+    }
+}
+
+/****************************************************************************
+ * Name: board_autoled_off
+ ****************************************************************************/
+
+void board_autoled_off(int led)
+{
+  if (led == BOARD_LED1)
+    {
+      stm32_gpiowrite(GPIO_LED1, false);
+    }
+}
+
+#endif /* CONFIG_ARCH_LEDS */
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_boot.c b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_boot.c
new file mode 100644
index 0000000000..f92ae77cc8
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_boot.c
@@ -0,0 +1,77 @@
+/****************************************************************************
+ * boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_boot.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nuttx/board.h>
+#include <arch/board/board.h>
+
+#include "stm32l0538-disco.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_boardinitialize
+ *
+ * Description:
+ *   All STM32 architectures must provide the following entry point.  This
+ *   entry point is called early in the initialization -- after all memory
+ *   has been configured and mapped but before any devices have been
+ *   initialized.
+ *
+ ****************************************************************************/
+
+void stm32_boardinitialize(void)
+{
+#ifdef CONFIG_ARCH_LEDS
+  /* Configure on-board LEDs if LED support has been selected. */
+
+  board_autoled_initialize();
+#endif
+}
+
+/****************************************************************************
+ * Name: board_late_initialize
+ *
+ * Description:
+ *   If CONFIG_BOARD_LATE_INITIALIZE is selected, then an additional
+ *   initialization call will be performed in the boot-up sequence to a
+ *   function called board_late_initialize().  board_late_initialize() will
+ *   be called immediately after up_initialize() is called and just before
+ *   the initial application is started.  This additional initialization
+ *   phase may be used, for example, to initialize board-specific device
+ *   drivers.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_BOARD_LATE_INITIALIZE
+void board_late_initialize(void)
+{
+  /* Perform board-specific initialization */
+
+  stm32_bringup();
+}
+#endif
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_bringup.c b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_bringup.c
new file mode 100644
index 0000000000..5098c231df
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_bringup.c
@@ -0,0 +1,85 @@
+/****************************************************************************
+ * boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_bringup.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <sys/types.h>
+#include <syslog.h>
+
+#include "stm32l0538-disco.h"
+
+#ifdef CONFIG_INPUT_BUTTONS
+#  include <nuttx/input/buttons.h>
+#endif
+
+#ifdef CONFIG_USERLED
+#  include <nuttx/leds/userled.h>
+#endif
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_bringup
+ *
+ * Description:
+ *   Perform architecture-specific initialization
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=y :
+ *     Called from board_late_initialize().
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=n && CONFIG_BOARDCTL=y :
+ *     Called from the NSH library
+ *
+ ****************************************************************************/
+
+int stm32_bringup(void)
+{
+  int ret;
+
+#ifdef CONFIG_INPUT_BUTTONS
+  /* Register the BUTTON driver */
+
+  ret = btn_lower_initialize("/dev/buttons");
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: btn_lower_initialize() failed: %d\n", ret);
+    }
+#endif
+
+#ifdef CONFIG_USERLED
+  /* Register the LED driver */
+
+  ret = userled_lower_initialize(LED_DRIVER_PATH);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
+      return ret;
+    }
+#endif
+
+  UNUSED(ret);
+  return OK;
+}
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_buttons.c b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_buttons.c
new file mode 100644
index 0000000000..3d8b6b6cac
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_buttons.c
@@ -0,0 +1,116 @@
+/****************************************************************************
+ * boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32_buttons.c
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <errno.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/board.h>
+
+#include "stm32_gpio.h"
+#include "stm32l0538-disco.h"
+
+#include <arch/board/board.h>
+
+#ifdef CONFIG_ARCH_BUTTONS
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_button_initialize
+ *
+ * Description:
+ *   board_button_initialize() must be called to initialize button resources.
+ *   After that, board_buttons() may be called to collect the current state
+ *   of all buttons or board_button_irq() may be called to register button
+ *   interrupt handlers.
+ *
+ ****************************************************************************/
+
+uint32_t board_button_initialize(void)
+{
+  /* Configure the single button as an input.  NOTE that EXTI interrupts are
+   * also configured for the pin.
+   */
+
+  stm32_configgpio(GPIO_BTN_USER);
+  return NUM_BUTTONS;
+}
+
+/****************************************************************************
+ * Name: board_buttons
+ ****************************************************************************/
+
+uint32_t board_buttons(void)
+{
+  /* Check that state of each USER button. A LOW value means that the key is
+   * pressed.
+   */
+
+  bool released = stm32_gpioread(GPIO_BTN_USER);
+  return !released;
+}
+
+/****************************************************************************
+ * Button support.
+ *
+ * Description:
+ *   board_button_initialize() must be called to initialize button resources.
+ *   After that, board_buttons() may be called to collect the current state
+ *   of all buttons or board_button_irq() may be called to register button
+ *   interrupt handlers.
+ *
+ *   After board_button_initialize() has been called, board_buttons() may be
+ *   called to collect the state of all buttons.  board_buttons() returns an
+ *   32-bit bit set with each bit associated with a button.  See the
+ *   BUTTON_*_BIT definitions in board.h for the meaning of each bit.
+ *
+ *   board_button_irq() may be called to register an interrupt handler that
+ *   will be called when a button is depressed or released. The ID value is a
+ *   button enumeration value that uniquely identifies a button resource. See
+ *   the BUTTON_* definitions in board.h for the meaning of enumeration
+ *   value.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_ARCH_IRQBUTTONS
+int board_button_irq(int id, xcpt_t irqhandler, void *arg)
+{
+  int ret = -EINVAL;
+
+  if (id == BUTTON_USER)
+    {
+      ret = stm32_gpiosetevent(GPIO_BTN_USER, true, true, true,
+                               irqhandler, arg);
+    }
+
+  return ret;
+}
+#endif
+#endif /* CONFIG_ARCH_BUTTONS */
diff --git a/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32l0538-disco.h b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32l0538-disco.h
new file mode 100644
index 0000000000..e776f1dccf
--- /dev/null
+++ b/boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32l0538-disco.h
@@ -0,0 +1,102 @@
+/****************************************************************************
+ * boards/arm/stm32f0l0g0/stm32l0538-disco/src/stm32l0538-disco.h
+ *
+ * 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 __BOARDS_ARM_STM32F0L0G0_STM32L0538_DISCO_SRC_STM32L0538_DISCO_H
+#define __BOARDS_ARM_STM32F0L0G0_STM32L0538_DISCO_SRC_STM32L0538_DISCO_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* LED definitions **********************************************************/
+
+/* The STM32L0538-DISCO board has three LEDs.  Two of these are controlled by
+ * logic on the board and are not available for software control:
+ *
+ * LD1 COM:  LD1 default status is red.  LD1 turns to green to indicate that
+ *           communications are in progress between the PC and the
+ *           ST-LINK/V2-1.
+ * LD2 PWR:  red LED indicates that the board is powered.
+ *
+ * And one can be controlled by software:
+ *
+ * User LD3: green LED is a user LED connected to the I/O PB5 of the
+ *           STM32L053C8T6.
+ * User LD4: green LED is a user LED connected to the I/O PA5 of the
+ *           STM32L053C8T6.
+ *
+ * If CONFIG_ARCH_LEDS is not defined, then the user can control the LED in
+ * any way.  The following definition is used to access the LED.
+ */
+
+#define GPIO_LED1      (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_HIGH | \
+                        GPIO_OUTPUT_CLEAR | GPIO_PORTB | GPIO_PIN5)
+#define GPIO_LED2      (GPIO_OUTPUT | GPIO_PUSHPULL | GPIO_SPEED_HIGH | \
+                        GPIO_OUTPUT_CLEAR | GPIO_PORTA | GPIO_PIN5)
+
+#define LED_DRIVER_PATH "/dev/userleds"
+
+/* Button definitions *******************************************************/
+
+/* The STM32L0538-DISCO supports two buttons; only one button is controllable
+ * by software:
+ *
+ *   B1 USER:  user button connected to the I/O PA0 of the STM32L053C8T6.
+ *   B2 RESET: push button connected to NRST is used to RESET the
+ *             STM32L053C8T6 that EXTI interrupts are configured.
+ */
+
+#define MIN_IRQBUTTON  BUTTON_USER
+#define MAX_IRQBUTTON  BUTTON_USER
+#define NUM_IRQBUTTONS 1
+#define GPIO_BTN_USER  (GPIO_INPUT | GPIO_FLOAT | GPIO_EXTI | GPIO_PORTA | \
+                        GPIO_PIN0)
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_bringup
+ *
+ * Description:
+ *   Perform architecture-specific initialization
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=y :
+ *     Called from board_late_initialize().
+ *
+ *   CONFIG_BOARD_LATE_INITIALIZE=y && CONFIG_BOARDCTL=y :
+ *     Called from the NSH library
+ *
+ ****************************************************************************/
+
+int stm32_bringup(void);
+
+#endif /* __BOARDS_ARM_STM32F0L0G0_STM32L0538_DISCO_SRC_STM32L0538_DISCO_H */