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


The following commit(s) were added to refs/heads/master by this push:
     new fd46d7a  boards: added support for EMW3162 Wi-Fi board
fd46d7a is described below

commit fd46d7a74fda13d6b4eb5505bc0689f3a2b78d5e
Author: Alexander Lunev <[email protected]>
AuthorDate: Sat Jun 12 03:43:56 2021 +0300

    boards: added support for EMW3162 Wi-Fi board
---
 README.md                                          |   2 +
 boards/Kconfig                                     |  12 ++
 boards/README.txt                                  |   5 +
 boards/arm/stm32/emw3162/Kconfig                   |  12 ++
 boards/arm/stm32/emw3162/README.txt                |  82 ++++++++
 boards/arm/stm32/emw3162/configs/nsh/defconfig     |  45 +++++
 boards/arm/stm32/emw3162/configs/wlan/defconfig    |  86 +++++++++
 boards/arm/stm32/emw3162/include/board.h           | 206 +++++++++++++++++++++
 boards/arm/stm32/emw3162/scripts/Make.defs         |  63 +++++++
 boards/arm/stm32/emw3162/scripts/ld.script         | 116 ++++++++++++
 boards/arm/stm32/emw3162/src/Make.defs             |  42 +++++
 boards/arm/stm32/emw3162/src/emw3162.h             | 106 +++++++++++
 boards/arm/stm32/emw3162/src/stm32_appinit.c       |  75 ++++++++
 boards/arm/stm32/emw3162/src/stm32_autoleds.c      |  99 ++++++++++
 boards/arm/stm32/emw3162/src/stm32_boot.c          |  78 ++++++++
 boards/arm/stm32/emw3162/src/stm32_bringup.c       |  96 ++++++++++
 boards/arm/stm32/emw3162/src/stm32_userleds.c      |  72 +++++++
 boards/arm/stm32/emw3162/src/stm32_wlan.c          | 164 ++++++++++++++++
 boards/arm/stm32/emw3162/src/stm32_wlan_firmware.c |   1 +
 19 files changed, 1362 insertions(+)

diff --git a/README.md b/README.md
index fd09d45..7d40175 100644
--- a/README.md
+++ b/README.md
@@ -2092,6 +2092,8 @@ Below is a guide to the available README files in the 
NuttX source tree:
      |   |   |   |   `- README.txt
      |   |   |   |- cloudctrl/
      |   |   |   |   `- README.txt
+     |   |   |   |- emw3162/
+     |   |   |   |   `- README.txt
      |   |   |   |- fire-stm32v2/
      |   |   |   |   `- README.txt
      |   |   |   |- hymini-stm32v/
diff --git a/boards/Kconfig b/boards/Kconfig
index 396c48a..10b5074 100644
--- a/boards/Kconfig
+++ b/boards/Kconfig
@@ -193,6 +193,14 @@ config ARCH_BOARD_EKKLM3S9B96
                TI/Stellaris EKK-LM3S9B96 board.  This board is based on the
                an EKK-LM3S9B96 which is a Cortex-M3.
 
+config ARCH_BOARD_EMW3162
+       bool "EMW3162 Wi-Fi board"
+       depends on ARCH_CHIP_STM32F205RG
+       select ARCH_HAVE_LEDS
+       ---help---
+               EMW3162 board (https://www.waveshare.com/wiki/EMW3162). This 
board
+               features the STM32F205RGY6 MCU and BCM43362KUBG Wi-Fi chip.
+
 config ARCH_BOARD_QUICKFEATHER
        bool "EOS S3 QuickFeather"
        depends on ARCH_CHIP_EOSS3
@@ -2321,6 +2329,7 @@ config ARCH_BOARD
        default "efm32-g8xx-stk"           if ARCH_BOARD_EFM32G8XXSTK
        default "efm32gg-stk3700"          if ARCH_BOARD_EFM32GG_STK3700
        default "ekk-lm3s9b96"             if ARCH_BOARD_EKKLM3S9B96
+       default "emw3162"                  if ARCH_BOARD_EMW3162
        default "quickfeather"             if ARCH_BOARD_QUICKFEATHER
        default "esp32-devkitc"            if ARCH_BOARD_ESP32_DEVKITC
        default "esp32-ethernet-kit"       if ARCH_BOARD_ESP32_ETHERNETKIT
@@ -2924,6 +2933,9 @@ endif
 if ARCH_BOARD_CLOUDCTRL
 source "boards/arm/stm32/cloudctrl/Kconfig"
 endif
+if ARCH_BOARD_EMW3162
+source "boards/arm/stm32/emw3162/Kconfig"
+endif
 if ARCH_BOARD_FIRE_STM32
 source "boards/arm/stm32/fire-stm32v2/Kconfig"
 endif
diff --git a/boards/README.txt b/boards/README.txt
index b121aa1..aa57100 100644
--- a/boards/README.txt
+++ b/boards/README.txt
@@ -258,6 +258,11 @@ boards/arm/tiva/ekk-lm3s9b96
   TI/Stellaris EKK-LM3S9B96 board.  This board is based on the
   an EKK-LM3S9B96 which is a Cortex-M3.
 
+boards/arm/stm32/emw3162
+  A configuration for the EMW3162 Wi-Fi board
+  (https://www.waveshare.com/wiki/EMW3162). This board features
+  the STM32F205RGY6 MCU from STMicro.
+
 boards/xtensa/esp32/esp-core
   The ESP32 is a dual-core system from Espressif with two Harvard architecture
   Xtensa LX6 CPUs.  All embedded memory, external memory and peripherals are
diff --git a/boards/arm/stm32/emw3162/Kconfig b/boards/arm/stm32/emw3162/Kconfig
new file mode 100644
index 0000000..a8e91b1
--- /dev/null
+++ b/boards/arm/stm32/emw3162/Kconfig
@@ -0,0 +1,12 @@
+#
+# For a description of the syntax of this configuration file,
+# see the file kconfig-language.txt in the NuttX tools repository.
+#
+
+if ARCH_BOARD_EMW3162
+
+config EMW3162_WLAN
+       bool "Enable WLAN chip support"
+       depends on IEEE80211_BROADCOM_FULLMAC_SDIO
+
+endif
diff --git a/boards/arm/stm32/emw3162/README.txt 
b/boards/arm/stm32/emw3162/README.txt
new file mode 100644
index 0000000..7aaaa9c
--- /dev/null
+++ b/boards/arm/stm32/emw3162/README.txt
@@ -0,0 +1,82 @@
+README
+======
+
+  EMW3162 board (https://www.waveshare.com/EMW3162.htm) features the
+  STM32F205RG MCU and Broadcom BCM43362KUBG Wi-Fi chip.
+  The STM32F205RG is a 120 MHz Cortex-M3 operation with 1Mbit Flash
+  memory and 128kbytes.
+
+Contents
+========
+
+  - Configuring NuttX for the EMW3162 board
+  - Configuring NuttX to use your Wireless Router (aka Access Point)
+  - Programming Flash
+  - NSH via telnet
+  - Serial console configuration
+
+Configuring NuttX for the EMW3162 board
+=======================================
+
+     $ cd nuttx
+     $ make apps_distclean
+     $ make distclean
+     $ ./configure.sh emw3162:wlan
+
+Configuring NuttX to use your Wireless Router (aka Access Point)
+================================================================
+
+  $ make menuconfig
+
+  Browse the menus this way:
+
+  Application Configuration  --->
+      NSH Library  --->
+          Networking Configuration  --->
+              WAPI Configuration  --->
+                  (myApSSID) SSID
+                  (mySSIDpassphrase) Passprhase
+
+  Replace the SSID from myApSSID with your wireless router name and
+  the Passprhase with your WiFi password.
+
+  Exit and save.
+
+  Finally just compile NuttX:
+
+    $ make
+
+Programming Flash
+=================
+
+  Flash memory can be programmed by stlink toolset
+  (https://github.com/stlink-org/stlink) and ST-LINK V2 programmer
+  (via SWD interface) as follows:
+
+    $ sudo st-flash write nuttx.bin 0x8000000
+
+NSH via telnet
+==============
+
+  After you successfully downloaded nuttx.bin, reset the board and it
+  automatically connects to the corresponding wifi AP. You may login
+  your router to see its IP address. Assume that it's 192.168.1.111
+
+  Open a terminal on your computer and telnet your EMW3162 board:
+
+    $ telnet 192.168.1.111
+    Trying 192.168.1.111...
+    Connected to 192.168.1.111.
+    Escape character is '^]'
+
+    NuttShell (NSH) NuttX-10.1.0-RC1
+    nsh>
+
+Serial console configuration
+============================
+
+  Connect a USB/Serial 3.3V dongle to GND, TXD and RXD pins of EMW3162 board.
+  Then use some serial console client (minicom, picocom, teraterm, etc) confi-
+  gured to 115200 8n1 without software or hardware flow control.
+
+  Reset the board and you should see NuttX starting in the serial.
diff --git a/boards/arm/stm32/emw3162/configs/nsh/defconfig 
b/boards/arm/stm32/emw3162/configs/nsh/defconfig
new file mode 100644
index 0000000..1b5bd45
--- /dev/null
+++ b/boards/arm/stm32/emw3162/configs/nsh/defconfig
@@ -0,0 +1,45 @@
+#
+# 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_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+# CONFIG_NSH_CMDPARMS is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="emw3162"
+CONFIG_ARCH_BOARD_EMW3162=y
+CONFIG_ARCH_CHIP="stm32"
+CONFIG_ARCH_CHIP_STM32=y
+CONFIG_ARCH_CHIP_STM32F205RG=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARD_LOOPSPERMSEC=16717
+CONFIG_BUILTIN=y
+CONFIG_FS_PROCFS=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_INTELHEX_BINARY=y
+CONFIG_MAX_TASKS=16
+CONFIG_MM_REGIONS=2
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_LINELEN=64
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_RAM_SIZE=114688
+CONFIG_RAM_START=0x20000000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_WAITPID=y
+CONFIG_SDCLONE_DISABLE=y
+CONFIG_START_DAY=6
+CONFIG_START_MONTH=12
+CONFIG_START_YEAR=2011
+CONFIG_STM32_JTAG_SW_ENABLE=y
+CONFIG_STM32_USART1=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_USART1_SERIAL_CONSOLE=y
+CONFIG_USER_ENTRYPOINT="nsh_main"
diff --git a/boards/arm/stm32/emw3162/configs/wlan/defconfig 
b/boards/arm/stm32/emw3162/configs/wlan/defconfig
new file mode 100644
index 0000000..277749e
--- /dev/null
+++ b/boards/arm/stm32/emw3162/configs/wlan/defconfig
@@ -0,0 +1,86 @@
+#
+# 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_IEEE80211_BROADCOM_FWFILES is not set
+# CONFIG_MMCSD_HAVE_CARDDETECT is not set
+# CONFIG_MMCSD_MMCSUPPORT is not set
+# CONFIG_NSH_ARGCAT is not set
+# CONFIG_NSH_CMDOPT_HEXDUMP is not set
+# CONFIG_NSH_CMDPARMS is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="emw3162"
+CONFIG_ARCH_BOARD_EMW3162=y
+CONFIG_ARCH_CHIP="stm32"
+CONFIG_ARCH_CHIP_STM32=y
+CONFIG_ARCH_CHIP_STM32F205RG=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_BOARD_LOOPSPERMSEC=16717
+CONFIG_BUILTIN=y
+CONFIG_DRIVERS_IEEE80211=y
+CONFIG_DRIVERS_WIRELESS=y
+CONFIG_EMW3162_WLAN=y
+CONFIG_FS_PROCFS=y
+CONFIG_HAVE_CXX=y
+CONFIG_HAVE_CXXINITIALIZE=y
+CONFIG_IEEE80211_BROADCOM_BCM43362=y
+CONFIG_IEEE80211_BROADCOM_FULLMAC_SDIO=y
+CONFIG_INTELHEX_BINARY=y
+CONFIG_LIBM=y
+CONFIG_MAX_TASKS=16
+CONFIG_MMCSD=y
+CONFIG_MMCSD_SDIO=y
+CONFIG_MM_REGIONS=2
+CONFIG_NET=y
+CONFIG_NETDB_DNSCLIENT=y
+CONFIG_NETDEVICES=y
+CONFIG_NETDEV_LATEINIT=y
+CONFIG_NETDEV_WIRELESS_IOCTL=y
+CONFIG_NETINIT_DHCPC=y
+CONFIG_NETINIT_DRIPADDR=0xc0a80001
+CONFIG_NETUTILS_DHCPC=y
+CONFIG_NETUTILS_TELNETD=y
+CONFIG_NET_BROADCAST=y
+CONFIG_NET_ETH_PKTSIZE=800
+CONFIG_NET_GUARDSIZE=32
+CONFIG_NET_ICMP=y
+CONFIG_NET_ICMP_SOCKET=y
+CONFIG_NET_PKT=y
+CONFIG_NET_TCP=y
+CONFIG_NET_UDP=y
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_LINELEN=64
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_RAM_SIZE=114688
+CONFIG_RAM_START=0x20000000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_RTC_DATETIME=y
+CONFIG_SCHED_HPWORK=y
+CONFIG_SCHED_WAITPID=y
+CONFIG_SDCLONE_DISABLE=y
+CONFIG_SDIO_BLOCKSETUP=y
+CONFIG_START_DAY=6
+CONFIG_START_MONTH=12
+CONFIG_START_YEAR=2011
+CONFIG_STM32_DMA2=y
+CONFIG_STM32_JTAG_SW_ENABLE=y
+CONFIG_STM32_PWR=y
+CONFIG_STM32_RTC=y
+CONFIG_STM32_SDIO=y
+CONFIG_STM32_SDIO_CARD=y
+CONFIG_STM32_USART1=y
+CONFIG_SYSLOG_CHAR=y
+CONFIG_SYSLOG_DEVPATH="/dev/ttyS0"
+CONFIG_SYSTEM_NSH=y
+CONFIG_SYSTEM_PING=y
+CONFIG_USART1_SERIAL_CONSOLE=y
+CONFIG_USER_ENTRYPOINT="nsh_main"
+CONFIG_WIRELESS_WAPI=y
+CONFIG_WIRELESS_WAPI_CMDTOOL=y
diff --git a/boards/arm/stm32/emw3162/include/board.h 
b/boards/arm/stm32/emw3162/include/board.h
new file mode 100644
index 0000000..cfddfd9
--- /dev/null
+++ b/boards/arm/stm32/emw3162/include/board.h
@@ -0,0 +1,206 @@
+/****************************************************************************
+ * boards/arm/stm32/emw3162/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_STM32_EMW3162_INCLUDE_BOARD_H
+#define __BOARDS_ARM_STM32_EMW3162_INCLUDE_BOARD_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#ifndef __ASSEMBLY__
+#  include <stdbool.h>
+#endif
+
+#include "stm32_rcc.h"
+#include "stm32.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* Clocking *****************************************************************/
+
+/* The EMW3162 board features a single 26MHz crystal.
+ *
+ * This is the canonical configuration:
+ *   System Clock source           : PLL (HSE)
+ *   SYSCLK(Hz)                    : 120000000    Determined by PLL
+ *                                                    configuration
+ *   HCLK(Hz)                      : 120000000    (STM32_RCC_CFGR_HPRE)
+ *   AHB Prescaler                 : 1            (STM32_RCC_CFGR_HPRE)
+ *   APB1 Prescaler                : 4            (STM32_RCC_CFGR_PPRE1)
+ *   APB2 Prescaler                : 2            (STM32_RCC_CFGR_PPRE2)
+ *   HSE Frequency(Hz)             : 26000000     (STM32_BOARD_XTAL)
+ *   PLLM                          : 26           (STM32_PLLCFG_PLLM)
+ *   PLLN                          : 240          (STM32_PLLCFG_PLLN)
+ *   PLLP                          : 2            (STM32_PLLCFG_PLLP)
+ *   PLLQ                          : 5            (STM32_PLLCFG_PLLQ)
+ *   Main regulator output voltage : Scale1 mode  Needed for high speed
+ *                                                       SYSCLK
+ *   Flash Latency(WS)             : 3
+ *   Prefetch Buffer               : OFF
+ *   Instruction cache             : ON
+ *   Data cache                    : ON
+ *   Require 48MHz for USB OTG HS  : Enabled
+ *   SDIO and RNG clock
+ */
+
+/* HSI - 16 MHz RC factory-trimmed
+ * LSI - 32 KHz RC
+ * HSE - On-board crystal frequency is 26MHz
+ * LSE - 32.768 kHz
+ */
+
+#define STM32_BOARD_XTAL        26000000ul
+
+#define STM32_HSI_FREQUENCY     16000000ul
+#define STM32_LSI_FREQUENCY     32000
+#define STM32_HSE_FREQUENCY     STM32_BOARD_XTAL
+#define STM32_LSE_FREQUENCY     32768
+
+/* Main PLL Configuration.
+ *
+ * PLL source is HSE
+ * PLL_VCO = (STM32_HSE_FREQUENCY / PLLM) * PLLN
+ *         = (26,000,000 / 26) * 240
+ *         = 240,000,000
+ * SYSCLK  = PLL_VCO / PLLP
+ *         = 240,000,000 / 2 = 120,000,000
+ * USB OTG FS, SDIO and RNG Clock
+ *         =  PLL_VCO / PLLQ
+ *         = 48,000,000
+ */
+
+#define STM32_PLLCFG_PLLM       RCC_PLLCFG_PLLM(26)
+#define STM32_PLLCFG_PLLN       RCC_PLLCFG_PLLN(240)
+#define STM32_PLLCFG_PLLP       RCC_PLLCFG_PLLP_2
+#define STM32_PLLCFG_PLLQ       RCC_PLLCFG_PLLQ(5)
+
+#define STM32_SYSCLK_FREQUENCY  120000000ul
+
+/* AHB clock (HCLK) is SYSCLK (120MHz) */
+
+#define STM32_RCC_CFGR_HPRE     RCC_CFGR_HPRE_SYSCLK  /* HCLK  = SYSCLK / 1 */
+#define STM32_HCLK_FREQUENCY    STM32_SYSCLK_FREQUENCY
+
+/* APB1 clock (PCLK1) is HCLK/4 (30MHz) */
+
+#define STM32_RCC_CFGR_PPRE1    RCC_CFGR_PPRE1_HCLKd4     /* PCLK1 = HCLK / 4 
*/
+#define STM32_PCLK1_FREQUENCY   (STM32_HCLK_FREQUENCY/4)
+
+/* APB2 clock (PCLK2) is HCLK/2 (60MHz) */
+
+#define STM32_RCC_CFGR_PPRE2    RCC_CFGR_PPRE2_HCLKd2     /* PCLK2 = HCLK / 2 
*/
+#define STM32_PCLK2_FREQUENCY   (STM32_HCLK_FREQUENCY/2)
+
+/* LED definitions **********************************************************/
+
+/* LED index values for use with board_userled() */
+
+#define BOARD_LED1        0
+#define BOARD_NLEDS       1
+
+/* LED bits for use with board_userled_all() */
+
+#define BOARD_LED1_BIT    (1 << BOARD_LED1)
+
+/* These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
+ * defined.  In that case, the usage by the board port is defined in
+ * include/board.h and src/sam_autoleds.c. The LEDs are used to encode
+ * OS-related events as follows:
+ *
+ *   ------------------- ---------------------------- ------
+ *   SYMBOL                  Meaning                  LED
+ *   ------------------- ---------------------------- ------
+ */
+
+#define LED_STARTED      0 /* NuttX has been started  OFF      */
+#define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF      */
+#define LED_IRQSENABLED  0 /* Interrupts enabled      OFF      */
+#define LED_STACKCREATED 1 /* Idle stack created      ON       */
+#define LED_INIRQ        2 /* In an interrupt         N/C      */
+#define LED_SIGNAL       2 /* In a signal handler     N/C      */
+#define LED_ASSERTION    2 /* An assertion failed     N/C      */
+#define LED_PANIC        3 /* The system has crashed  FLASH    */
+#undef  LED_IDLE           /* MCU is is sleep mode    Not used */
+
+/* Thus if LED is statically on, NuttX has successfully  booted and is,
+ * apparently, running normally.  If LED is flashing at approximately
+ * 2Hz, then a fatal error has been detected and the system has halted.
+ */
+
+/* Alternate function pin selections ****************************************/
+
+/* UART1 */
+
+#ifdef CONFIG_STM32_USART1
+#  define GPIO_USART1_RX GPIO_USART1_RX_1
+#  define GPIO_USART1_TX GPIO_USART1_TX_1
+#endif
+
+/* SDIO definitions *********************************************************/
+
+/* Note that slower clocking is required when DMA is disabled in order
+ * to avoid RX overrun/TX underrun errors due to delayed responses
+ * to service FIFOs in interrupt driven mode.
+ *
+ * These values have not been tuned!!!
+ *
+ * SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(118+2)=400 KHz
+ */
+
+#define SDIO_INIT_CLKDIV        (118 << SDIO_CLKCR_CLKDIV_SHIFT)
+
+/* DMA ON:  SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)=16 MHz
+ * DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz
+ */
+
+#ifdef CONFIG_SDIO_DMA
+#  define SDIO_MMCXFR_CLKDIV    (1 << SDIO_CLKCR_CLKDIV_SHIFT)
+#else
+#  define SDIO_MMCXFR_CLKDIV    (2 << SDIO_CLKCR_CLKDIV_SHIFT)
+#endif
+
+/* DMA ON:  SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(1+2)=16 MHz
+ * DMA OFF: SDIOCLK=48MHz, SDIO_CK=SDIOCLK/(2+2)=12 MHz
+ */
+
+#ifdef CONFIG_SDIO_DMA
+#  define SDIO_SDXFR_CLKDIV     (1 << SDIO_CLKCR_CLKDIV_SHIFT)
+#else
+#  define SDIO_SDXFR_CLKDIV     (2 << SDIO_CLKCR_CLKDIV_SHIFT)
+#endif
+
+/* DMA Channel/Stream Selections ********************************************/
+
+/* Stream selections are arbitrary for now but might become important in the
+ * future if we set aside more DMA channels/streams.
+ *
+ * SDIO DMA
+ *   DMAMAP_SDIO_1 = Channel 4, Stream 3
+ *   DMAMAP_SDIO_2 = Channel 4, Stream 6
+ */
+
+#define DMAMAP_SDIO DMAMAP_SDIO_1
+
+#endif /* __BOARDS_ARM_STM32_EMW3162_INCLUDE_BOARD_H */
diff --git a/boards/arm/stm32/emw3162/scripts/Make.defs 
b/boards/arm/stm32/emw3162/scripts/Make.defs
new file mode 100644
index 0000000..7187575
--- /dev/null
+++ b/boards/arm/stm32/emw3162/scripts/Make.defs
@@ -0,0 +1,63 @@
+############################################################################
+# boards/arm/stm32/emw3162/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/armv7-m/Toolchain.defs
+
+LDSCRIPT = ld.script
+
+ifeq ($(CONFIG_CYGWIN_WINTOOL),y)
+  ARCHSCRIPT = -T "${shell cygpath -w 
$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)}"
+else
+  ARCHSCRIPT = -T$(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT)
+endif
+
+ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
+  ARCHOPTIMIZATION = -g
+endif
+
+ifneq ($(CONFIG_DEBUG_NOOPT),y)
+  ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing 
-fno-strength-reduce -fomit-frame-pointer
+endif
+
+ARCHCFLAGS = -fno-builtin
+ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
+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 -Wl,-d -Wl,-warn-common
+NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) 
-T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -Wl,-no-check-sections
+LDNXFLATFLAGS = -e main -s 2048
+
+ifneq ($(CROSSDEV),arm-nuttx-elf-)
+  LDFLAGS += -nostartfiles -nodefaultlibs
+endif
+ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
+  LDFLAGS += -g
+endif
diff --git a/boards/arm/stm32/emw3162/scripts/ld.script 
b/boards/arm/stm32/emw3162/scripts/ld.script
new file mode 100644
index 0000000..eb3611a
--- /dev/null
+++ b/boards/arm/stm32/emw3162/scripts/ld.script
@@ -0,0 +1,116 @@
+/****************************************************************************
+ * boards/arm/stm32/emw3162/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 STM32F205RG has 1024Kb of FLASH beginning at address 0x0800:0000 and
+ * 112Kb of SRAM in main SRAM1 and 16 Kb in auxiliary SRAM2.
+ *
+ * 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 = 1024K
+  sram (rwx) : ORIGIN = 0x20000000, LENGTH = 112K
+}
+
+OUTPUT_ARCH(arm)
+EXTERN(_vectors)
+ENTRY(_stext)
+SECTIONS
+{
+    .text : {
+        _stext = ABSOLUTE(.);
+        *(.vectors)
+        *(.text .text.*)
+        *(.fixup)
+        *(.gnu.warning)
+
+        . = ALIGN(0x4);
+        wlan_firmware_image_location = .;
+        *(.wlan_firmware_image .wlan_firmware_image.*)
+        wlan_firmware_image_end = .;
+        . = ALIGN(0x4);
+        wlan_nvram_image_location = .;
+        *(.wlan_nvram_image .wlan_nvram_image.*)
+        wlan_nvram_image_end = .;
+
+        *(.rodata .rodata.*)
+        *(.gnu.linkonce.t.*)
+        *(.glue_7)
+        *(.glue_7t)
+        *(.got)
+        *(.gcc_except_table)
+        *(.gnu.linkonce.r.*)
+        _etext = ABSOLUTE(.);
+    } > flash
+
+    .init_section : {
+        _sinit = ABSOLUTE(.);
+        *(.init_array .init_array.*)
+        _einit = ABSOLUTE(.);
+    } > flash
+
+    .ARM.extab : {
+        *(.ARM.extab*)
+    } > flash
+
+    __exidx_start = ABSOLUTE(.);
+    .ARM.exidx : {
+        *(.ARM.exidx*)
+    } > flash
+    __exidx_end = ABSOLUTE(.);
+
+    _eronly = ABSOLUTE(.);
+
+    .data : {
+        _sdata = ABSOLUTE(.);
+        *(.data .data.*)
+        *(.gnu.linkonce.d.*)
+        CONSTRUCTORS
+        . = ALIGN(4);
+        _edata = ABSOLUTE(.);
+    } > sram AT > flash
+
+    .bss : {
+        _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/stm32/emw3162/src/Make.defs 
b/boards/arm/stm32/emw3162/src/Make.defs
new file mode 100644
index 0000000..9fa6e5d
--- /dev/null
+++ b/boards/arm/stm32/emw3162/src/Make.defs
@@ -0,0 +1,42 @@
+############################################################################
+# boards/arm/stm32/emw3162/src/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)/Make.defs
+
+CSRCS = stm32_boot.c stm32_bringup.c
+
+ifeq ($(CONFIG_LIB_BOARDCTL),y)
+CSRCS += stm32_appinit.c
+endif
+
+ifeq ($(CONFIG_ARCH_LEDS),y)
+CSRCS += stm32_autoleds.c
+else
+CSRCS += stm32_userleds.c
+endif
+
+ifeq ($(CONFIG_EMW3162_WLAN),y)
+CSRCS += stm32_wlan.c
+CSRCS += stm32_wlan_firmware.c
+endif
+
+DEPPATH += --dep-path board
+VPATH += :board
+CFLAGS += $(shell $(INCDIR) "$(CC)" 
$(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)
diff --git a/boards/arm/stm32/emw3162/src/emw3162.h 
b/boards/arm/stm32/emw3162/src/emw3162.h
new file mode 100644
index 0000000..d9189cf
--- /dev/null
+++ b/boards/arm/stm32/emw3162/src/emw3162.h
@@ -0,0 +1,106 @@
+/****************************************************************************
+ * boards/arm/stm32/emw3162/src/emw3162.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_STM32_EMW3162_SRC_EMW3162_H
+#define __BOARDS_ARM_STM32_EMW3162_SRC_EMW3162_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/compiler.h>
+#include <arch/stm32/chip.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* LEDs */
+
+#define GPIO_LED1       (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
+                         GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN0)
+
+#define GPIO_LED2       (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
+                         GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN1)
+
+/* WLAN chip */
+
+#define SDIO_WLAN0_SLOTNO 0 /* EMW3162 board has only one sdio device */
+#define SDIO_WLAN0_MINOR  0 /* Register "wlan0" device */
+
+#define GPIO_WLAN0_RESET (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
+                          GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN5)
+
+#define GPIO_WLAN0_PWRDN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
+                          GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN1)
+
+#define GPIO_WLAN0_32K_CLK (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\
+                            GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN8)
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#ifndef __ASSEMBLY__
+
+/****************************************************************************
+ * Public Functions Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_bringup
+ *
+ * Description:
+ *   Called either by board_initialize() if CONFIG_BOARD_LATE_INITIALIZE or
+ *   by board_app_initialize if CONFIG_LIB_BOARDCTL is selected.  This
+ *   function initializes and configures all on-board features appropriate
+ *   for the selected configuration.
+ *
+ ****************************************************************************/
+
+#if defined(CONFIG_LIB_BOARDCTL) || defined(CONFIG_BOARD_LATE_INITIALIZE)
+int stm32_bringup(void);
+#endif
+
+/****************************************************************************
+ * Name: emw3162_wlan_initialize
+ *
+ * Description:
+ *   Initialize wlan hardware and driver for EMW3162 board.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_EMW3162_WLAN
+int emw3162_wlan_initialize(void);
+#endif
+
+#endif /* __ASSEMBLY__ */
+#endif /* __BOARDS_ARM_STM32_EMW3162_SRC_EMW3162_H */
diff --git a/boards/arm/stm32/emw3162/src/stm32_appinit.c 
b/boards/arm/stm32/emw3162/src/stm32_appinit.c
new file mode 100644
index 0000000..1b49e15
--- /dev/null
+++ b/boards/arm/stm32/emw3162/src/stm32_appinit.c
@@ -0,0 +1,75 @@
+/****************************************************************************
+ * boards/arm/stm32/emw3162/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 <nuttx/board.h>
+
+#include "emw3162.h"
+
+#ifdef CONFIG_LIB_BOARDCTL
+
+/****************************************************************************
+ * 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)
+{
+#ifndef CONFIG_BOARD_LATE_INITIALIZE
+  /* Perform board initialization */
+
+  return stm32_bringup();
+#else
+  return OK;
+#endif
+}
+
+#endif /* CONFIG_LIB_BOARDCTL */
diff --git a/boards/arm/stm32/emw3162/src/stm32_autoleds.c 
b/boards/arm/stm32/emw3162/src/stm32_autoleds.c
new file mode 100644
index 0000000..e331446
--- /dev/null
+++ b/boards/arm/stm32/emw3162/src/stm32_autoleds.c
@@ -0,0 +1,99 @@
+/****************************************************************************
+ * boards/arm/stm32/emw3162/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.
+ *
+ ****************************************************************************/
+
+/* LEDs
+ *
+ * These LEDs are not used by the board port unless CONFIG_ARCH_LEDS is
+ * defined.  In that case, the usage by the board port is defined in
+ * include/board.h and src/sam_autoleds.c. The LEDs are used to encode
+ * OS-related events as follows:
+ *
+ *   ------------------- ----------------------- ------
+ *   SYMBOL              Meaning                 LED
+ *   ------------------- ----------------------- ------
+ *   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         N/C
+ *   LED_SIGNAL          In a signal handler     N/C
+ *   LED_ASSERTION       An assertion failed     N/C
+ *   LED_PANIC           The system has crashed  FLASH
+ *
+ * Thus is LED is statically on, NuttX has successfully  booted and is,
+ * apparently, running normally.  If LED is flashing at approximately
+ * 2Hz, then a fatal error has been detected and the system has halted.
+ */
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <debug.h>
+
+#include <nuttx/board.h>
+#include <arch/board/board.h>
+
+#include "stm32_gpio.h"
+#include "emw3162.h"
+
+#ifdef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_autoled_initialize
+ ****************************************************************************/
+
+void board_autoled_initialize(void)
+{
+  /* Configure EMW3162 LED gpio as output */
+
+  stm32_configgpio(GPIO_LED1);
+}
+
+/****************************************************************************
+ * Name: board_autoled_on
+ ****************************************************************************/
+
+void board_autoled_on(int led)
+{
+  if (led == 1 || led == 3)
+    {
+      stm32_gpiowrite(GPIO_LED1, true);
+    }
+}
+
+/****************************************************************************
+ * Name: board_autoled_off
+ ****************************************************************************/
+
+void board_autoled_off(int led)
+{
+  if (led == 3)
+    {
+      stm32_gpiowrite(GPIO_LED1, false);
+    }
+}
+
+#endif /* CONFIG_ARCH_LEDS */
diff --git a/boards/arm/stm32/emw3162/src/stm32_boot.c 
b/boards/arm/stm32/emw3162/src/stm32_boot.c
new file mode 100644
index 0000000..b1a0462
--- /dev/null
+++ b/boards/arm/stm32/emw3162/src/stm32_boot.c
@@ -0,0 +1,78 @@
+/****************************************************************************
+ * boards/arm/stm32/emw3162/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 "arm_arch.h"
+#include "emw3162.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_intitialize() 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 initialization */
+
+  stm32_bringup();
+}
+#endif /* CONFIG_BOARD_LATE_INITIALIZE */
diff --git a/boards/arm/stm32/emw3162/src/stm32_bringup.c 
b/boards/arm/stm32/emw3162/src/stm32_bringup.c
new file mode 100644
index 0000000..eead0c2
--- /dev/null
+++ b/boards/arm/stm32/emw3162/src/stm32_bringup.c
@@ -0,0 +1,96 @@
+/****************************************************************************
+ * boards/arm/stm32/emw3162/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 <nuttx/leds/userled.h>
+#include <nuttx/board.h>
+#include <nuttx/fs/fs.h>
+
+#include <arch/board/board.h>
+
+#include "emw3162.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: stm32_bringup
+ *
+ * Description:
+ *   Called either by board_initialize() if CONFIG_BOARD_LATE_INITIALIZE or
+ *   by board_app_initialize if CONFIG_LIB_BOARDCTL is selected.
+ *   This function initializes and configures all on-board features
+ *   appropriate for the selected configuration.
+ *
+ ****************************************************************************/
+
+int stm32_bringup(void)
+{
+  int ret = OK;
+
+#ifdef CONFIG_FS_PROCFS
+  /* Mount the procfs file system */
+
+  ret = nx_mount(NULL, "/proc", "procfs", 0, NULL);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR, "ERROR: Failed to mount procfs at /proc: %d\n", ret);
+    }
+#endif
+
+#if defined(CONFIG_USERLED) && !defined(CONFIG_ARCH_LEDS)
+#ifdef CONFIG_USERLED_LOWER
+  /* Register the LED driver */
+
+  ret = userled_lower_initialize("/dev/userleds");
+  if (ret != OK)
+    {
+      syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret);
+      return ret;
+    }
+#else
+  /* Enable USER LED support for some other purpose */
+
+  board_userled_initialize();
+#endif /* CONFIG_USERLED_LOWER */
+#endif /* CONFIG_USERLED && !CONFIG_ARCH_LEDS */
+
+#ifdef CONFIG_EMW3162_WLAN
+  /* Initialize wlan driver and hardware */
+
+  ret = emw3162_wlan_initialize();
+  if (ret != OK)
+    {
+      syslog(LOG_ERR, "Failed to initialize wlan: %d\n", ret);
+      return ret;
+    }
+#endif
+
+  return ret;
+}
diff --git a/boards/arm/stm32/emw3162/src/stm32_userleds.c 
b/boards/arm/stm32/emw3162/src/stm32_userleds.c
new file mode 100644
index 0000000..c159a4a
--- /dev/null
+++ b/boards/arm/stm32/emw3162/src/stm32_userleds.c
@@ -0,0 +1,72 @@
+/****************************************************************************
+ * boards/arm/stm32/emw3162/src/stm32_userleds.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 <debug.h>
+
+#include <arch/board/board.h>
+#include "emw3162.h"
+
+#include "stm32_gpio.h"
+
+#ifndef CONFIG_ARCH_LEDS
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: board_userled_initialize
+ ****************************************************************************/
+
+uint32_t board_userled_initialize(void)
+{
+  /* Configure EMW3162 LED gpio as output */
+
+  stm32_configgpio(GPIO_LED1);
+  return BOARD_NLEDS;
+}
+
+/****************************************************************************
+ * Name: board_userled
+ ****************************************************************************/
+
+void board_userled(int led, bool ledon)
+{
+  if (led == BOARD_LED1)
+    {
+      stm32_gpiowrite(GPIO_LED1, ledon);
+    }
+}
+
+/****************************************************************************
+ * Name: board_userled_all
+ ****************************************************************************/
+
+void board_userled_all(uint32_t ledset)
+{
+  stm32_gpiowrite(GPIO_LED1, !!(ledset & BOARD_LED1_BIT));
+}
+
+#endif /* !CONFIG_ARCH_LEDS */
diff --git a/boards/arm/stm32/emw3162/src/stm32_wlan.c 
b/boards/arm/stm32/emw3162/src/stm32_wlan.c
new file mode 100644
index 0000000..15c2abe
--- /dev/null
+++ b/boards/arm/stm32/emw3162/src/stm32_wlan.c
@@ -0,0 +1,164 @@
+/****************************************************************************
+ * boards/arm/stm32/emw3162/src/stm32_wlan.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 <debug.h>
+
+#include <nuttx/wireless/ieee80211/bcmf_sdio.h>
+#include <nuttx/wireless/ieee80211/bcmf_board.h>
+
+#include <arch/board/board.h>
+
+#include "stm32_gpio.h"
+#include "stm32_sdio.h"
+
+#include "emw3162.h"
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct sdio_dev_s *g_sdio_dev;
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: bcmf_board_reset
+ ****************************************************************************/
+
+void bcmf_board_reset(int minor, bool reset)
+{
+  if (minor != SDIO_WLAN0_MINOR)
+    {
+      return;
+    }
+
+  stm32_gpiowrite(GPIO_WLAN0_RESET, !reset);
+}
+
+/****************************************************************************
+ * Name: bcmf_board_power
+ ****************************************************************************/
+
+void bcmf_board_power(int minor, bool power)
+{
+  if (minor != SDIO_WLAN0_MINOR)
+    {
+      return;
+    }
+
+  stm32_gpiowrite(GPIO_WLAN0_PWRDN, !power);
+}
+
+/****************************************************************************
+ * Name: bcmf_board_initialize
+ ****************************************************************************/
+
+void bcmf_board_initialize(int minor)
+{
+  if (minor != SDIO_WLAN0_MINOR)
+    {
+      return;
+    }
+
+  /* Configure MCO1 output to drive EXT_SLEEP_CLK input pin of BCM43362 */
+
+  stm32_configgpio(GPIO_MCO1);
+  stm32_mco1config(RCC_CFGR_MCO1_LSE, RCC_CFGR_MCO1PRE_NONE);
+
+  /* Configure PowerDown pin */
+
+  stm32_configgpio(GPIO_WLAN0_PWRDN);
+
+  /* Shutdown wlan chip */
+
+  bcmf_board_power(minor, false);
+
+  /* Configure reset pin */
+
+  stm32_configgpio(GPIO_WLAN0_RESET);
+
+  /* Put wlan chip in reset state */
+
+  bcmf_board_reset(minor, true);
+}
+
+/****************************************************************************
+ * Name: bcmf_board_setup_oob_irq
+ ****************************************************************************/
+
+void bcmf_board_setup_oob_irq(int minor, int (*func)(void *), void *arg)
+{
+  if (minor != SDIO_WLAN0_MINOR)
+    {
+      return;
+    }
+
+  /* Configure SDIO card in-band interrupt callback */
+
+  if (g_sdio_dev != NULL)
+    {
+      sdio_set_sdio_card_isr(g_sdio_dev, func, arg);
+    }
+}
+
+/****************************************************************************
+ * Name: emw3162_wlan_initialize
+ ****************************************************************************/
+
+int emw3162_wlan_initialize()
+{
+  int ret;
+
+  /* Initialize sdio interface */
+
+  wlinfo("Initializing SDIO slot %d\n", SDIO_WLAN0_SLOTNO);
+
+  g_sdio_dev = sdio_initialize(SDIO_WLAN0_SLOTNO);
+
+  if (!g_sdio_dev)
+    {
+      wlerr("ERROR: Failed to initialize SDIO with slot %d\n",
+             SDIO_WLAN0_SLOTNO);
+      return ERROR;
+    }
+
+  /* Bind the SDIO interface to the bcmf driver */
+
+  ret = bcmf_sdio_initialize(SDIO_WLAN0_MINOR, g_sdio_dev);
+
+  if (ret != OK)
+    {
+      wlerr("ERROR: Failed to bind SDIO to bcmf driver\n");
+
+      /* FIXME deinitialize sdio device */
+
+      return ERROR;
+    }
+
+  return OK;
+}
diff --git a/boards/arm/stm32/emw3162/src/stm32_wlan_firmware.c 
b/boards/arm/stm32/emw3162/src/stm32_wlan_firmware.c
new file mode 120000
index 0000000..2d4fef1
--- /dev/null
+++ b/boards/arm/stm32/emw3162/src/stm32_wlan_firmware.c
@@ -0,0 +1 @@
+../../photon/src/stm32_wlan_firmware.c
\ No newline at end of file

Reply via email to