diff --git a/.gitignore b/.gitignore index 4095c1a294f..8052befe0fd 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ core /.config /.config.old /.version +/defconfig /Make.defs /nuttx /nuttx.* diff --git a/Documentation/NuttX.html b/Documentation/NuttX.html index cd617cb8843..8b812bed2e2 100644 --- a/Documentation/NuttX.html +++ b/Documentation/NuttX.html @@ -8,7 +8,7 @@

NuttX RTOS

-

Last Updated: June 5, 2017

+

Last Updated: July 8, 2017

@@ -796,6 +796,14 @@

+ +
+ +

+

  • IP Forwarding.
  • +

    + +
    diff --git a/Makefile.unix b/Makefile.unix index cca3c1cd6c2..4df0773eb9c 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -515,6 +515,14 @@ do_gconfig: dirlinks apps_preconfig gconfig: do_gconfig clean_context +do_savedefconfig: dirlinks apps_preconfig + +savedefconfig: do_savedefconfig + $(Q) APPSDIR=${CONFIG_APPS_DIR} kconfig-conf --savedefconfig defconfig Kconfig + $(Q) sed -i -e "/CONFIG_APPS_DIR=/d" defconfig + $(Q) grep "CONFIG_ARCH=" .config >> defconfig + $(Q) grep "CONFIG_ARCH_BOARD=" .config >> defconfig + # export # # The export target will package the NuttX libraries and header files into diff --git a/Makefile.win b/Makefile.win index 91a6e66f914..06a0d9aa277 100644 --- a/Makefile.win +++ b/Makefile.win @@ -501,6 +501,14 @@ do_menuconfig: dirlinks configenv apps_preconfig menuconfig: do_menuconfig clean_context +do_savedefconfig: dirlinks apps_preconfig + +savedefconfig: do_savedefconfig + $(Q) set APPSDIR=$(patsubst "%",%,${CONFIG_APPS_DIR})& kconfig-conf --savedefconfig defconfig Kconfig + $(Q) sed -i -e "/CONFIG_APPS_DIR=/d" defconfig + $(Q) grep "CONFIG_ARCH=" .config >> defconfig + $(Q) grep "CONFIG_ARCH_BOARD=" .config >> defconfig + # export # # The export target will package the NuttX libraries and header files into diff --git a/README.txt b/README.txt index 301fdf72d80..88c1a9d82b4 100644 --- a/README.txt +++ b/README.txt @@ -19,6 +19,8 @@ README - Reveal Hidden Configuration Options - Make Sure that You on on the Right Platform - Comparing Two Configurations + - Making defconfig Files + - Configuring with "Compressed" defconfig Files - Incompatibilities with Older Configurations - NuttX Configuration Tool under DOS o Toolchains @@ -41,7 +43,7 @@ ENVIRONMENTS NuttX requires a POSIX development environment such as you would find under Linux or OSX. NuttX may be also be installed and built on Windows system - if you also provde such a POSIX development environment. Options for a + if you also provide such a POSIX development environment. Options for a POSIX development environment under Windows include: - An installation of Linux on a virtual machine (VM) in Windows. I have @@ -55,7 +57,7 @@ ENVIRONMENTS - The Cygwin environment. Instructions for installation of Cygwin on a Windows system are provided in the following paragraph, "Installing Cygwin". Cygwin is a mature, well-tested, and very convenient - environment. It is especially expecially convenient if you need to + environment. It is especially especially convenient if you need to integrate with Windows tools and files. Downsides are that the installation time is very long and the compile times are slow. @@ -71,7 +73,7 @@ ENVIRONMENTS and that configuration will not be discussed in this README file. See http://www.mingw.org/wiki/MSYS if you are interested in using MSYS. People report to me that they have used MSYS - successfully. I suppose that the advantages of the MSYS environemnt + successfully. I suppose that the advantages of the MSYS environment is that it is closer to a native Windows environment and uses only a minimal of add-on POSIX-land tools. @@ -124,7 +126,7 @@ Installing Cygwin instructions assume that you are at a bash command line prompt in either Linux or in Cygwin shell. - UPDATE: The last time I installed EVERTHING, the download was + UPDATE: The last time I installed EVERYTHING, the download was about 5GiB. The server I selected was also very slow so it took over a day to do the whole install! @@ -179,7 +181,7 @@ Ubuntu Bash under Windows 10 Accessing Windows Files from Ubuntu ----------------------------------- - File sysems will be mounted under "/mnt" so for example "C:\Program Files" + File systems will be mounted under "/mnt" so for example "C:\Program Files" appears at "/mnt/c/Program Files". This is as opposed to Cgwin where the same directory would appear at "/cygdrive/c/Program Files". @@ -270,7 +272,7 @@ Ubuntu Bash under Windows 10 The Ubuntu version support by Microsoft is a command-line only version. There is no support for Linux graphics utilities. - This limititation is not a limitation of Ubuntu, however, only in what + This limitation is not a limitation of Ubuntu, however, only in what Microsoft is willing to support. If you install a X-Server, then you can also use basic graphics utilities. See for example: @@ -491,7 +493,7 @@ Notes about Header Files Certain header files, such as setjmp.h, stdarg.h, and math.h, may still be needed from your toolchain and your compiler may not, however, be able to find these if you compile NuttX without using standard header files - (ie., with -nostdinc). If that is the case, one solution is to copy + (i.e., with -nostdinc). If that is the case, one solution is to copy those header file from your toolchain into the NuttX include directory. Duplicated Header Files. @@ -513,7 +515,7 @@ Notes about Header Files been tuned for your CPU. Sometimes such such tuned math libraries are bundled with your toolchain. - The math libary header file, math.h, is a then special case. If you do + The math library header file, math.h, is a then special case. If you do nothing, the standard math.h header file that is provided with your toolchain will be used. @@ -583,7 +585,7 @@ Instantiating "Canned" Configurations included in the build and what is not. This file is also used to generate a C configuration header at include/nuttx/config.h. - Copy other, environment-specic files to ${TOPDIR + Copy other, environment-specific files to ${TOPDIR This might include files like .gdbinit or IDE configuration files like .project or .cproject. @@ -652,10 +654,10 @@ Refreshing Configurations NuttX Configuration Tool ------------------------ - An automated tool has been incorported to support re-configuration + An automated tool has been incorporated to support re-configuration of NuttX. This automated tool is based on the kconfig-frontends application available at http://ymorin.is-a-geek.org/projects/kconfig-frontends - (A snapshot of this tool is also available fromo the tools repository at + (A snapshot of this tool is also available from the tools repository at https://bitbucket.org/nuttx/tools). This application provides a tool called 'kconfig-mconf' that is used by the NuttX top-level Makefile. The following make target is provided: @@ -731,7 +733,7 @@ NuttX Configuration Tool make gconfig - Some keyboard shortcus supported by kconfig-mconf, the tool that runs + Some keyboard shortcuts supported by kconfig-mconf, the tool that runs when you do 'make menuconfig': - '?' will bring up the mconfig help display. @@ -752,7 +754,7 @@ Finding Selections in the Configuration Menus narrow things down. But if you know exactly what configuration setting you want to select, - say CONFIG_XYZ, but not where to find it, then the 'make memconfig' + say CONFIG_XYZ, but not where to find it, then the 'make menuconfig' version of the tool offers some help: By pressing the '/' key, the tool will bring up a menu that will allow you to search for a configuration item. Just enter the string CONFIG_XYZ and press 'ENTER'. @@ -849,6 +851,78 @@ Comparing Two Configurations manual configurations to the current configurations based on the kconfig-frontends tools. See the following paragraph. +Making defconfig Files +---------------------- + + The minimum defconfig file is simply the generated .config file with + CONFIG_APPS_DIR setting removed or commented out. That setting provides + the name and location of the apps/ directory relative to the nuttx build + directory. The default is ../apps/, however, the apps directory may be + any other location and may have a different name. For example, the name + of versioned NuttX releases are always in the form apps-xx.yy where xx.yy + is the version number. + + When the default configuration is installed using on of the scripts or + programs in the NuttX tools directory, there will be an option to provide + the path to the apps/ directory. If not provided, then the configure tool + will look around and try to make a reasonable decision about where the + apps/ directory is located. + + The Makefile also supports an option to generate very small defconfig + files. The .config files are quite large and complex. But most of the + settings in the .config file simply have the default settings from the + Kconfig files. These .config files can be converted into small defconfig + file: + + make savedefconfig + + That make target will generate a defconfig file in the top-level + directory. The size reduction is really quite remarkable: + + $ wc -l .config defconfig + 1085 .config + 82 defconfig + 1167 total + + In order to be usable, the .config file installed from the compressed + defconfig file must be reconstituted using: + + make olddefconfig + + CAUTION: There is only one caution. This size reduction was + accomplished by removing all setting from the .config file that were at + the default value. 'make olddefconfig' can regenerate the original + .config file by simply restoring those default settings. The underlying + assumption here is, of course, that the default settings do not change. + If the default settings change, and they often do, then the original + .config may not be reproducible. + +Configuring with "Compressed" defconfig Files +--------------------------------------------- + + 2017-07-08: Currently all defconfig files are in .config form. However, + in the long term I would hope that the defconfig files will eventual + all be converted to the "compressed" defconfig format. This would be + a great savings in the total size of the NuttX files. + + As described in the previous section, "Making defconfig Files," defconfig + files may be "compressed" using 'make savedeconfig'. These compressed + defconfig files may not be fully usable and may not build the target + binaries that you want because the compression process removed all of the + default settings from the defconfig file. To restore the default + settings, you should run the following after configuring: + + make olddefconfig + + That will restore the the missing defaulted values. + + Using this command after configuring is generally a good practice anyway: + Even if the defconfig files are not "compressed" in this fashion, the + defconfig file may be old and the only way to assure that the installed + .config is is uptodate is via 'make oldconfig' or 'make olddefconfig'. + See the paragraph above entitled ""Refreshing Configurations" for + additional information. + Incompatibilities with Older Configurations ------------------------------------------- @@ -924,7 +998,7 @@ NuttX Configuration Tool under DOS directly in the Windows console window. In this case, you do not have to modify the .config file, but there are other complexities: - a. You need to temporarily set the Cgywin directories in the PATH + a. You need to temporarily set the Cygwin directories in the PATH variable then run kconfig-mconf manually like: kconfig-mconf Kconfig @@ -957,7 +1031,7 @@ Cross-Development Toolchains tools and development environments for use with your board. In any case, the PATH environment variable will need to be updated to - include the loction where the build can find the toolchain binaries. + include the location where the build can find the toolchain binaries. NuttX Buildroot Toolchain ------------------------- @@ -1064,7 +1138,7 @@ Re-building build is still using the version of the file in the copied directory, not your modified file! - Older versions of NuttX did not support dependiencies in this + Older versions of NuttX did not support dependencies in this configuration. So a simple work around this annoying behavior in this case was the following when you re-build: @@ -1075,7 +1149,7 @@ Re-building However, more recent versions of NuttX do support dependencies for the Cygwin build. As a result, the above command will cause everything to be - rebuilt (beause it removes and will cause recreating the + rebuilt (because it removes and will cause recreating the include/nuttx/config.h header file). A much less gracefully but still effective command in this case is the following for the ARM configuration: @@ -1310,7 +1384,7 @@ Window Native Toolchain Issues There are many popular Windows native toolchains that may be used with NuttX. Examples include CodeSourcery (for Windows), devkitARM, and several vendor- - provied toolchains. There are several limitations with using a and Windows + provided toolchains. There are several limitations with using a and Windows based toolchain in a Cygwin environment. The three biggest are: 1. The Windows toolchain cannot follow Cygwin paths. Path conversions are @@ -1392,7 +1466,7 @@ Building Original Linux Boards in Cygwin be used in each configuration. It is possible to change the default setup. Here, for example, is what you must do in order to compile a default Linux configuration in the Cygwin environment using the - CodeSourceery for Windows toolchain. After instantiating a "canned" + CodeSourcery for Windows toolchain. After instantiating a "canned" NuttX configuration, run the target 'menuconfig' and set the following items: diff --git a/arch/sim/src/up_netdriver.c b/arch/sim/src/up_netdriver.c index 99eaf73dbe3..bdd39ff2bca 100644 --- a/arch/sim/src/up_netdriver.c +++ b/arch/sim/src/up_netdriver.c @@ -310,7 +310,7 @@ void netdriver_loop(void) else #endif { - nwarn("WARNING: Unsupported Ethernet type %u\n", eth->type) + nwarn("WARNING: Unsupported Ethernet type %u\n", eth->type); } } } diff --git a/configs/Kconfig b/configs/Kconfig index fd5fb80c5e2..c7f8704765d 100644 --- a/configs/Kconfig +++ b/configs/Kconfig @@ -1166,6 +1166,15 @@ config ARCH_BOARD_STM32F746_WS ---help--- Waveshare STM32F746 development board featuring the STM32F746IG MCU. +config ARCH_BOARD_B_L475E_IOT01A + bool "STMicro IoT Discovery kit" + depends on ARCH_CHIP_STM32L475VG + select ARCH_HAVE_LEDS + ---help--- + STMicro IoT development board featuring the STM32L475VG + MCU. The STM32L475VG is a Cortex-M4 optimised for low-power operation + at up to 80MHz operation with 1024Kb Flash memory and 96+32Kb SRAM. + config ARCH_BOARD_STM32L476VG_DISCO bool "STMicro STM32L476VG -Discovery board" depends on ARCH_CHIP_STM32L476RG @@ -1613,6 +1622,7 @@ config ARCH_BOARD default "stm32f429i-disco" if ARCH_BOARD_STM32F429I_DISCO default "stm32f746g-disco" if ARCH_BOARD_STM32F746G_DISCO default "stm32f746-ws" if ARCH_BOARD_STM32F746_WS + default "b-l475e-iot01a" if ARCH_BOARD_B_L475E_IOT01A default "stm32l476vg-disco" if ARCH_BOARD_STM32L476VG_DISCO default "stm32l476-mdk" if ARCH_BOARD_STM32L476_MDK default "stm32ldiscovery" if ARCH_BOARD_STM32L_DISCOVERY @@ -2004,6 +2014,9 @@ endif if ARCH_BOARD_STM32F746G_DISCO source "configs/stm32f746g-disco/Kconfig" endif +if ARCH_BOARD_B_L475E_IOT01A +source "configs/b-l475e-iot01a/Kconfig" +endif if ARCH_BOARD_STM32F746_WS source "configs/stm32f746-ws/Kconfig" endif diff --git a/configs/b-l475e-iot01a/Kconfig b/configs/b-l475e-iot01a/Kconfig new file mode 100644 index 00000000000..60da88320ad --- /dev/null +++ b/configs/b-l475e-iot01a/Kconfig @@ -0,0 +1,10 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +# if ARCH_BOARD_B_L475E_IOT01A + +# TODO + +# endif \ No newline at end of file diff --git a/configs/b-l475e-iot01a/include/b-l475e-iot01a_clock.h b/configs/b-l475e-iot01a/include/b-l475e-iot01a_clock.h new file mode 100644 index 00000000000..98d789327ec --- /dev/null +++ b/configs/b-l475e-iot01a/include/b-l475e-iot01a_clock.h @@ -0,0 +1,509 @@ +/************************************************************************************ + * configs/b-l475e-iot01a/include/b-l475e-iot01a_clock.h + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +#ifndef __CONFIG_B_L475E_IOT01A_INCLUDE_B_L475E_IOT01A_CLOCK_H +#define __CONFIG_B_L475E_IOT01A_INCLUDE_B_L475E_IOT01A_CLOCK_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include +#ifndef __ASSEMBLY__ +# include +#endif + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +#if 1 +# define HSI_CLOCK_CONFIG /* HSI-16 clock configuration */ +#elif 0 +/* Make sure you installed one! */ + +# define HSE_CLOCK_CONFIG /* HSE with 8 MHz xtal */ +#else +# define MSI_CLOCK_CONFIG /* MSI @ 4 MHz autotrimmed via LSE */ +#endif + +/* Clocking *************************************************************************/ + +#if defined(HSI_CLOCK_CONFIG) +/* The STMicro IoT board supports both HSE and LSE crystals. As shipped, the HSE + * crystal (X1) is not populated. Therefore the STMicro IoT board will need to run off the + * 16MHz HSI clock, or the 32khz-synced MSI, unless you install the HSE xtal. + * + * System Clock source : PLL (HSI) + * SYSCLK(Hz) : 80000000 Determined by PLL configuration + * HCLK(Hz) : 80000000 (STM32L4_RCC_CFGR_HPRE) (Max 80 MHz) + * AHB Prescaler : 1 (STM32L4_RCC_CFGR_HPRE) (Max 80 MHz) + * APB1 Prescaler : 1 (STM32L4_RCC_CFGR_PPRE1) (Max 80 MHz) + * APB2 Prescaler : 1 (STM32L4_RCC_CFGR_PPRE2) (Max 80 MHz) + * HSI Frequency(Hz) : 16000000 (nominal) + * PLLM : 1 (STM32L4_PLLCFG_PLLM) + * PLLN : 10 (STM32L4_PLLCFG_PLLN) + * PLLP : 0 (STM32L4_PLLCFG_PLLP) + * PLLQ : 0 (STM32L4_PLLCFG_PLLQ) + * PLLR : 2 (STM32L4_PLLCFG_PLLR) + * PLLSAI1N : 12 + * PLLSAI1Q : 4 + * Flash Latency(WS) : 4 + * Prefetch Buffer : OFF + * 48MHz for USB OTG FS, : Doable if required using PLLSAI1 or MSI + * SDIO and RNG clock + */ + +/* HSI - 16 MHz RC factory-trimmed + * LSI - 32 KHz RC (X2) + * MSI - variable up to 48 MHz, synchronized to LSE + * HSE - not installed (X1) + * LSE - 32.768 kHz installed + */ + +#define STM32L4_HSI_FREQUENCY 16000000ul +#define STM32L4_LSI_FREQUENCY 32000 +#define STM32L4_LSE_FREQUENCY 32768 + +#define STM32L4_BOARD_USEHSI 1 + +/* XXX sysclk mux = pllclk */ + +/* XXX pll source mux = hsi */ + +/* REVISIT: Trimming of the HSI and MSI is not yet supported. */ + +/* Main PLL Configuration. + * + * Formulae: + * + * VCO input frequency = PLL input clock frequency / PLLM, 1 <= PLLM <= 8 + * VCO output frequency = VCO input frequency × PLLN, 8 <= PLLN <= 86, frequency range 64 to 344 MHz + * PLL output P (SAI3) clock frequency = VCO frequency / PLLP, PLLP = 7, or 17, or 0 to disable + * PLL output Q (48M1) clock frequency = VCO frequency / PLLQ, PLLQ = 2, 4, 6, or 8, or 0 to disable + * PLL output R (CLK) clock frequency = VCO frequency / PLLR, PLLR = 2, 4, 6, or 8, or 0 to disable + * + * PLL output P is used for SAI + * PLL output Q is used for OTG FS, SDMMC, RNG + * PLL output R is used for SYSCLK + * PLLP = 0 (not used) + * PLLQ = 0 (not used) + * PLLR = 2 + * PLLN = 10 + * PLLM = 1 + * + * We will configure like this + * + * PLL source is HSI + * + * PLL_REF = STM32L4_HSI_FREQUENCY / PLLM + * = 16,000,000 / 1 + * = 16,000,000 + * + * PLL_VCO = PLL_REF * PLLN + * = 16,000,000 * 10 + * = 160,000,000 + * + * PLL_CLK = PLL_VCO / PLLR + * = 160,000,000 / 2 = 80,000,000 + * PLL_48M1 = disabled + * PLL_SAI3 = disabled + * + * ---------------------------------------- + * + * PLLSAI1 Configuration + * + * The clock input and M divider are identical to the main PLL. + * However the multiplier and postscalers are independent. + * The PLLSAI1 is configured only if CONFIG_STM32L4_SAI1PLL is defined + * + * SAI1VCO input frequency = PLL input clock frequency + * SAI1VCO output frequency = SAI1VCO input frequency × PLLSAI1N, 8 <= PLLSAI1N <= 86, frequency range 64 to 344 MHz + * SAI1PLL output P (SAI1) clock frequency = SAI1VCO frequency / PLLSAI1P, PLLP = 7, or 17, or 0 to disable + * SAI1PLL output Q (48M2) clock frequency = SAI1VCO frequency / PLLSAI1Q, PLLQ = 2, 4, 6, or 8, or 0 to disable + * SAI1PLL output R (ADC1) clock frequency = SAI1VCO frequency / PLLSAI1R, PLLR = 2, 4, 6, or 8, or 0 to disable + * + * We will configure like this + * + * PLLSAI1 disabled + * + * ---------------------------------------- + * + * PLLSAI2 Configuration + * + * The clock input and M divider are identical to the main PLL. + * However the multiplier and postscalers are independent. + * The PLLSAI2 is configured only if CONFIG_STM32L4_SAI2PLL is defined + * + * SAI2VCO input frequency = PLL input clock frequency + * SAI2VCO output frequency = SAI2VCO input frequency × PLLSAI2N, 8 <= PLLSAI1N <= 86, frequency range 64 to 344 MHz + * SAI2PLL output P (SAI2) clock frequency = SAI2VCO frequency / PLLSAI2P, PLLP = 7, or 17, or 0 to disable + * SAI2PLL output R (ADC2) clock frequency = SAI2VCO frequency / PLLSAI2R, PLLR = 2, 4, 6, or 8, or 0 to disable + * + * We will configure like this + * + * PLLSAI2 disabled + * + * ---------------------------------------- + * + * TODO: The STM32L is a low power peripheral and all these clocks should be configurable at runtime. + * + * ---------------------------------------- + * + * TODO These clock sources can be configured in Kconfig (this is not a board feature) + * USART1 + * USART2 + * USART3 + * UART4 + * UART5 + * LPUART1 + * I2C1 + * I2C2 + * I2C3 + * LPTIM1 + * LPTIM2 + * SAI1 + * SAI2 + * CLK48 + * ADC + * SWPMI + * DFSDM + */ + +/* prescaler common to all PLL inputs; will be 1 (XXX source is implicitly + as per comment above HSI) */ + +#define STM32L4_PLLCFG_PLLM RCC_PLLCFG_PLLM(1) + +/* 'main' PLL config; we use this to generate our system clock via the R + * output. We set it up as 16 MHz / 1 * 10 / 2 = 80 MHz + * + * XXX NOTE: currently the main PLL is implicitly turned on and is implicitly + * the system clock; this should be configurable since not all applications may + * want things done this way. + */ + +#define STM32L4_PLLCFG_PLLN RCC_PLLCFG_PLLN(10) +#define STM32L4_PLLCFG_PLLP 0 +#undef STM32L4_PLLCFG_PLLP_ENABLED +#define STM32L4_PLLCFG_PLLQ RCC_PLLCFG_PLLQ_2 +#define STM32L4_PLLCFG_PLLQ_ENABLED +#define STM32L4_PLLCFG_PLLR RCC_PLLCFG_PLLR(2) +#define STM32L4_PLLCFG_PLLR_ENABLED + +/* 'SAIPLL1' is used to generate the 48 MHz clock, since we can't + * do that with the main PLL's N value. We set N = 12, and enable + * the Q output (ultimately for CLK48) with /4. So, + * 16 MHz / 1 * 12 / 4 = 48 MHz + * + * XXX NOTE: currently the SAIPLL /must/ be explicitly selected in the + * menuconfig, or else all this is a moot point, and the various 48 MHz + * peripherals will not work (RNG at present). I would suggest removing + * that option from Kconfig altogether, and simply making it an option + * that is selected via a #define here, like all these other params. + */ + +#define STM32L4_PLLSAI1CFG_PLLN RCC_PLLSAI1CFG_PLLN(12) +#define STM32L4_PLLSAI1CFG_PLLP 0 +#undef STM32L4_PLLSAI1CFG_PLLP_ENABLED +#define STM32L4_PLLSAI1CFG_PLLQ RCC_PLLSAI1CFG_PLLQ_4 +#define STM32L4_PLLSAI1CFG_PLLQ_ENABLED +#define STM32L4_PLLSAI1CFG_PLLR 0 +#undef STM32L4_PLLSAI1CFG_PLLR_ENABLED + +/* 'SAIPLL2' is not used in this application */ + +#define STM32L4_PLLSAI2CFG_PLLN RCC_PLLSAI2CFG_PLLN(8) +#define STM32L4_PLLSAI2CFG_PLLP 0 +#undef STM32L4_PLLSAI2CFG_PLLP_ENABLED +#define STM32L4_PLLSAI2CFG_PLLR 0 +#undef STM32L4_PLLSAI2CFG_PLLR_ENABLED + +#define STM32L4_SYSCLK_FREQUENCY 80000000ul + +/* CLK48 will come from PLLSAI1 (implicitly Q) */ + +#define STM32L4_USE_CLK48 +#define STM32L4_CLK48_SEL RCC_CCIPR_CLK48SEL_PLLSAI1 + +/* enable the LSE oscillator, used automatically trim the MSI, and for RTC */ + +#define STM32L4_USE_LSE 1 + +/* AHB clock (HCLK) is SYSCLK (80MHz) */ + +#define STM32L4_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK /* HCLK = SYSCLK / 1 */ +#define STM32L4_HCLK_FREQUENCY STM32L4_SYSCLK_FREQUENCY +#define STM32L4_BOARD_HCLK STM32L4_HCLK_FREQUENCY /* Same as above, to satisfy compiler */ + +/* APB1 clock (PCLK1) is HCLK/1 (80MHz) */ + +#define STM32L4_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLK /* PCLK1 = HCLK / 1 */ +#define STM32L4_PCLK1_FREQUENCY (STM32L4_HCLK_FREQUENCY/1) + +/* Timers driven from APB1 will be twice PCLK1 */ +/* REVISIT : this can be configured */ + +#define STM32L4_APB1_TIM2_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM3_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM4_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM5_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM6_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM7_CLKIN (2*STM32L4_PCLK1_FREQUENCY) + +/* APB2 clock (PCLK2) is HCLK (80MHz) */ + +#define STM32L4_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLK /* PCLK2 = HCLK / 1 */ +#define STM32L4_PCLK2_FREQUENCY (STM32L4_HCLK_FREQUENCY/1) + +/* Timers driven from APB2 will be twice PCLK2 */ +/* REVISIT : this can be configured */ + +#define STM32L4_APB2_TIM1_CLKIN (2*STM32L4_PCLK2_FREQUENCY) +#define STM32L4_APB2_TIM8_CLKIN (2*STM32L4_PCLK2_FREQUENCY) + +/* Timer Frequencies, if APBx is set to 1, frequency is same to APBx + * otherwise frequency is 2xAPBx. + * Note: TIM1,8 are on APB2, others on APB1 + */ +/* REVISIT : this can be configured */ + +/* TODO SDMMC */ + +#elif defined(HSE_CLOCK_CONFIG) + +/* Use the HSE */ + +#define STM32L4_BOARD_USEHSE 1 + +/* XXX sysclk mux = pllclk */ + +/* XXX pll source mux = hse */ + +/* Prescaler common to all PLL inputs */ + +#define STM32L4_PLLCFG_PLLM RCC_PLLCFG_PLLM(1) + +/* 'main' PLL config; we use this to generate our system clock */ + +#define STM32L4_PLLCFG_PLLN RCC_PLLCFG_PLLN(20) +#define STM32L4_PLLCFG_PLLP 0 +#undef STM32L4_PLLCFG_PLLP_ENABLED +#define STM32L4_PLLCFG_PLLQ 0 +#undef STM32L4_PLLCFG_PLLQ_ENABLED +#define STM32L4_PLLCFG_PLLR RCC_PLLCFG_PLLR_2 +#define STM32L4_PLLCFG_PLLR_ENABLED + +/* 'SAIPLL1' is used to generate the 48 MHz clock */ + +#define STM32L4_PLLSAI1CFG_PLLN RCC_PLLSAI1CFG_PLLN(12) +#define STM32L4_PLLSAI1CFG_PLLP 0 +#undef STM32L4_PLLSAI1CFG_PLLP_ENABLED +#define STM32L4_PLLSAI1CFG_PLLQ RCC_PLLSAI1CFG_PLLQ_2 +#define STM32L4_PLLSAI1CFG_PLLQ_ENABLED +#define STM32L4_PLLSAI1CFG_PLLR 0 +#undef STM32L4_PLLSAI1CFG_PLLR_ENABLED + +/* 'SAIPLL2' is not used in this application */ + +#define STM32L4_PLLSAI2CFG_PLLN RCC_PLLSAI2CFG_PLLN(8) +#define STM32L4_PLLSAI2CFG_PLLP 0 +#undef STM32L4_PLLSAI2CFG_PLLP_ENABLED +#define STM32L4_PLLSAI2CFG_PLLR 0 +#undef STM32L4_PLLSAI2CFG_PLLR_ENABLED + +#define STM32L4_SYSCLK_FREQUENCY 80000000ul + +/* Enable CLK48; get it from PLLSAI1 */ + +#define STM32L4_USE_CLK48 +#define STM32L4_CLK48_SEL RCC_CCIPR_CLK48SEL_PLLSAI1 + +/* Enable LSE (for the RTC) */ + +#define STM32L4_USE_LSE 1 + +/* Configure the HCLK divisor (for the AHB bus, core, memory, and DMA */ + +#define STM32L4_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK /* HCLK = SYSCLK / 1 */ +#define STM32L4_HCLK_FREQUENCY STM32L4_SYSCLK_FREQUENCY +#define STM32L4_BOARD_HCLK STM32L4_HCLK_FREQUENCY /* Same as above, to satisfy compiler */ + +/* Configure the APB1 prescaler */ + +#define STM32L4_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLK /* PCLK1 = HCLK / 1 */ +#define STM32L4_PCLK1_FREQUENCY (STM32L4_HCLK_FREQUENCY/1) + +#define STM32L4_APB1_TIM2_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM3_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM4_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM5_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM6_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM7_CLKIN (2*STM32L4_PCLK1_FREQUENCY) + +/* Configure the APB2 prescaler */ + +#define STM32L4_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLK /* PCLK2 = HCLK / 1 */ +#define STM32L4_PCLK2_FREQUENCY (STM32L4_HCLK_FREQUENCY/1) + +#define STM32L4_APB2_TIM1_CLKIN (2*STM32L4_PCLK2_FREQUENCY) +#define STM32L4_APB2_TIM8_CLKIN (2*STM32L4_PCLK2_FREQUENCY) + +#elif defined(MSI_CLOCK_CONFIG) + +/* Use the MSI; frequ = 4 MHz; autotrim from LSE */ + +#define STM32L4_BOARD_USEMSI 1 +#define STM32L4_BOARD_MSIRANGE RCC_CR_MSIRANGE_4M + +/* XXX sysclk mux = pllclk */ + +/* XXX pll source mux = msi */ + +/* prescaler common to all PLL inputs */ + +#define STM32L4_PLLCFG_PLLM RCC_PLLCFG_PLLM(1) + +/* 'main' PLL config; we use this to generate our system clock */ + +#define STM32L4_PLLCFG_PLLN RCC_PLLCFG_PLLN(40) +#define STM32L4_PLLCFG_PLLP 0 +#undef STM32L4_PLLCFG_PLLP_ENABLED +#define STM32L4_PLLCFG_PLLQ 0 +#undef STM32L4_PLLCFG_PLLQ_ENABLED +#define STM32L4_PLLCFG_PLLR RCC_PLLCFG_PLLR_2 +#define STM32L4_PLLCFG_PLLR_ENABLED + +/* 'SAIPLL1' is used to generate the 48 MHz clock */ + +#define STM32L4_PLLSAI1CFG_PLLN RCC_PLLSAI1CFG_PLLN(24) +#define STM32L4_PLLSAI1CFG_PLLP 0 +#undef STM32L4_PLLSAI1CFG_PLLP_ENABLED +#define STM32L4_PLLSAI1CFG_PLLQ RCC_PLLSAI1CFG_PLLQ_2 +#define STM32L4_PLLSAI1CFG_PLLQ_ENABLED +#define STM32L4_PLLSAI1CFG_PLLR 0 +#undef STM32L4_PLLSAI1CFG_PLLR_ENABLED + +/* 'SAIPLL2' is not used in this application */ + +#define STM32L4_PLLSAI2CFG_PLLN RCC_PLLSAI2CFG_PLLN(8) +#define STM32L4_PLLSAI2CFG_PLLP 0 +#undef STM32L4_PLLSAI2CFG_PLLP_ENABLED +#define STM32L4_PLLSAI2CFG_PLLR 0 +#undef STM32L4_PLLSAI2CFG_PLLR_ENABLED + +#define STM32L4_SYSCLK_FREQUENCY 80000000ul + +/* Enable CLK48; get it from PLLSAI1 */ + +#define STM32L4_USE_CLK48 +#define STM32L4_CLK48_SEL RCC_CCIPR_CLK48SEL_PLLSAI1 + +/* Enable LSE (for the RTC) */ + +#define STM32L4_USE_LSE 1 + +/* Configure the HCLK divisor (for the AHB bus, core, memory, and DMA */ + +#define STM32L4_RCC_CFGR_HPRE RCC_CFGR_HPRE_SYSCLK /* HCLK = SYSCLK / 1 */ +#define STM32L4_HCLK_FREQUENCY STM32L4_SYSCLK_FREQUENCY +#define STM32L4_BOARD_HCLK STM32L4_HCLK_FREQUENCY /* Same as above, to satisfy compiler */ + +/* Configure the APB1 prescaler */ + +#define STM32L4_RCC_CFGR_PPRE1 RCC_CFGR_PPRE1_HCLK /* PCLK1 = HCLK / 1 */ +#define STM32L4_PCLK1_FREQUENCY (STM32L4_HCLK_FREQUENCY/1) + +#define STM32L4_APB1_TIM2_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM3_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM4_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM5_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM6_CLKIN (2*STM32L4_PCLK1_FREQUENCY) +#define STM32L4_APB1_TIM7_CLKIN (2*STM32L4_PCLK1_FREQUENCY) + +/* Configure the APB2 prescaler */ + +#define STM32L4_RCC_CFGR_PPRE2 RCC_CFGR_PPRE2_HCLK /* PCLK2 = HCLK / 1 */ +#define STM32L4_PCLK2_FREQUENCY (STM32L4_HCLK_FREQUENCY/1) + +#define STM32L4_APB2_TIM1_CLKIN (2*STM32L4_PCLK2_FREQUENCY) +#define STM32L4_APB2_TIM8_CLKIN (2*STM32L4_PCLK2_FREQUENCY) + +#endif + +/* Timer Frequencies, if APBx is set to 1, frequency is same to APBx + * otherwise frequency is 2xAPBx. + * Note: TIM1,8,15,16,17 are on APB2, others on APB1 + */ + +#define BOARD_TIM1_FREQUENCY STM32L4_HCLK_FREQUENCY +#define BOARD_TIM2_FREQUENCY (STM32L4_HCLK_FREQUENCY / 2) +#define BOARD_TIM3_FREQUENCY (STM32L4_HCLK_FREQUENCY / 2) +#define BOARD_TIM4_FREQUENCY (STM32L4_HCLK_FREQUENCY / 2) +#define BOARD_TIM5_FREQUENCY (STM32L4_HCLK_FREQUENCY / 2) +#define BOARD_TIM6_FREQUENCY (STM32L4_HCLK_FREQUENCY / 2) +#define BOARD_TIM7_FREQUENCY (STM32L4_HCLK_FREQUENCY / 2) +#define BOARD_TIM8_FREQUENCY STM32L4_HCLK_FREQUENCY +#define BOARD_TIM15_FREQUENCY STM32L4_HCLK_FREQUENCY +#define BOARD_TIM16_FREQUENCY STM32L4_HCLK_FREQUENCY +#define BOARD_TIM17_FREQUENCY STM32L4_HCLK_FREQUENCY +#define BOARD_LPTIM1_FREQUENCY (STM32L4_HCLK_FREQUENCY / 2) +#define BOARD_LPTIM2_FREQUENCY (STM32L4_HCLK_FREQUENCY / 2) + +/************************************************************************************ + * Public Data + ************************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/************************************************************************************ + * Public Function Prototypes + ************************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __CONFIG_B_L475E_IOT01A_INCLUDE_B_L475E_IOT01A_CLOCK */ diff --git a/configs/b-l475e-iot01a/include/board.h b/configs/b-l475e-iot01a/include/board.h new file mode 100644 index 00000000000..6c10a3aab9b --- /dev/null +++ b/configs/b-l475e-iot01a/include/board.h @@ -0,0 +1,149 @@ +/************************************************************************************ + * configs/b-l475e-iot01a/include/board.h + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Simon Piriou + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +#ifndef __CONFIG_B_L475E_IOT01A_INCLUDE_BOARD_H +#define __CONFIG_B_L475E_IOT01A_INCLUDE_BOARD_H + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#ifndef __ASSEMBLY__ +# include +#endif + +#include + +/************************************************************************************ + * Pre-processor Definitions + ************************************************************************************/ + +/* Clocking *************************************************************************/ + +#include + +/* LED definitions ******************************************************************/ +/* LEDs + * + * Two user LEDs are available on pins PA5 and PB14. + */ + +/* LED index values for use with board_userled() */ + +#define BOARD_LED1 0 +#define BOARD_LED2 1 +#define BOARD_NLEDS 2 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) +#define BOARD_LED2_BIT (1 << BOARD_LED2) + +/* 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 ************************************************/ + +/* USART1: Connected to STLink Debug via PB6, PB7 */ + +#define GPIO_USART1_RX GPIO_USART1_RX_2 +#define GPIO_USART1_TX GPIO_USART1_TX_2 + +/* UART4: Connected to arduino compatible pins DO/D1 via PA0, PA1 */ + +#define GPIO_UART4_RX GPIO_UART4_RX_1 +#define GPIO_UART4_TX GPIO_UART4_TX_1 + +/************************************************************************************ + * Public Data + ************************************************************************************/ + +#ifndef __ASSEMBLY__ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/************************************************************************************ + * Public Function Prototypes + ************************************************************************************/ + +/************************************************************************************ + * 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); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __CONFIG_B_L475E_IOT01A_INCLUDE_BOARD_H */ diff --git a/configs/b-l475e-iot01a/nsh/Make.defs b/configs/b-l475e-iot01a/nsh/Make.defs new file mode 100644 index 00000000000..899cfeb22fb --- /dev/null +++ b/configs/b-l475e-iot01a/nsh/Make.defs @@ -0,0 +1,118 @@ +############################################################################ +# configs/b-l475e-iot01a/nsh/Make.defs +# +# Copyright (C) 2017 Gregory Nutt. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include ${TOPDIR}/.config +include ${TOPDIR}/tools/Config.mk +include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs + +# TODO add stm32 bootloader support +LDSCRIPT = flash.ld + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/copydir.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mkwindeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT) + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(ARCROSSDEV)ar rcs +NM = $(ARCROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +# See http://dfu-util.sourceforge.net/ + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +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 +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +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 + +ASMEXT = .S +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-nuttx-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe +HOSTLDFLAGS = + +define DOWNLOAD + $(Q) echo "Download firmware $(1).bin" + $(Q) st-flash write $(1).bin 0x08000000 +endef \ No newline at end of file diff --git a/configs/b-l475e-iot01a/nsh/defconfig b/configs/b-l475e-iot01a/nsh/defconfig new file mode 100644 index 00000000000..ecbe88986cd --- /dev/null +++ b/configs/b-l475e-iot01a/nsh/defconfig @@ -0,0 +1,1179 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set +# CONFIG_DEFAULT_SMALL is not set +CONFIG_HOST_LINUX=y +# CONFIG_HOST_OSX is not set +# CONFIG_HOST_WINDOWS is not set +# CONFIG_HOST_OTHER is not set + +# +# Build Configuration +# +CONFIG_BUILD_FLAT=y +# CONFIG_BUILD_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +CONFIG_INTELHEX_BINARY=y +# CONFIG_MOTOROLA_SREC is not set +CONFIG_RAW_BINARY=y +# CONFIG_UBOOT_UIMAGE is not set +# CONFIG_DFU_BINARY is not set + +# +# Customize Header Files +# +# CONFIG_ARCH_STDINT_H is not set +# CONFIG_ARCH_STDBOOL_H is not set +# CONFIG_ARCH_MATH_H is not set +# CONFIG_ARCH_FLOAT_H is not set +# CONFIG_ARCH_STDARG_H is not set +# CONFIG_ARCH_DEBUG_H is not set + +# +# Debug Options +# +CONFIG_DEBUG_ALERT=y +# CONFIG_DEBUG_FEATURES is not set +CONFIG_ARCH_HAVE_STACKCHECK=y +# CONFIG_STACK_COLORATION is not set +CONFIG_ARCH_HAVE_HEAPCHECK=y +# CONFIG_HEAP_COLORATION is not set +# CONFIG_DEBUG_SYMBOLS is not set +CONFIG_ARCH_HAVE_CUSTOMOPT=y +# CONFIG_DEBUG_NOOPT is not set +# CONFIG_DEBUG_CUSTOMOPT is not set +CONFIG_DEBUG_FULLOPT=y + +# +# System Type +# +CONFIG_ARCH_ARM=y +# CONFIG_ARCH_AVR is not set +# CONFIG_ARCH_HC is not set +# CONFIG_ARCH_MIPS is not set +# CONFIG_ARCH_MISOC is not set +# CONFIG_ARCH_RENESAS is not set +# CONFIG_ARCH_RISCV is not set +# CONFIG_ARCH_SIM is not set +# CONFIG_ARCH_X86 is not set +# CONFIG_ARCH_XTENSA is not set +# CONFIG_ARCH_Z16 is not set +# CONFIG_ARCH_Z80 is not set +CONFIG_ARCH="arm" + +# +# ARM Options +# +# CONFIG_ARCH_CHIP_A1X is not set +# CONFIG_ARCH_CHIP_C5471 is not set +# CONFIG_ARCH_CHIP_DM320 is not set +# CONFIG_ARCH_CHIP_EFM32 is not set +# CONFIG_ARCH_CHIP_IMX1 is not set +# CONFIG_ARCH_CHIP_IMX6 is not set +# CONFIG_ARCH_CHIP_KINETIS is not set +# CONFIG_ARCH_CHIP_KL is not set +# CONFIG_ARCH_CHIP_LM is not set +# CONFIG_ARCH_CHIP_TIVA is not set +# CONFIG_ARCH_CHIP_LPC11XX is not set +# CONFIG_ARCH_CHIP_LPC17XX is not set +# CONFIG_ARCH_CHIP_LPC214X is not set +# CONFIG_ARCH_CHIP_LPC2378 is not set +# CONFIG_ARCH_CHIP_LPC31XX is not set +# CONFIG_ARCH_CHIP_LPC43XX is not set +# CONFIG_ARCH_CHIP_MOXART is not set +# CONFIG_ARCH_CHIP_NUC1XX is not set +# CONFIG_ARCH_CHIP_SAMA5 is not set +# CONFIG_ARCH_CHIP_SAMD is not set +# CONFIG_ARCH_CHIP_SAML is not set +# CONFIG_ARCH_CHIP_SAM34 is not set +# CONFIG_ARCH_CHIP_SAMV7 is not set +# CONFIG_ARCH_CHIP_STM32 is not set +# CONFIG_ARCH_CHIP_STM32F0 is not set +# CONFIG_ARCH_CHIP_STM32F7 is not set +CONFIG_ARCH_CHIP_STM32L4=y +# CONFIG_ARCH_CHIP_STR71X is not set +# CONFIG_ARCH_CHIP_TMS570 is not set +# CONFIG_ARCH_CHIP_XMC4 is not set +# CONFIG_ARCH_ARM7TDMI is not set +# CONFIG_ARCH_ARM926EJS is not set +# CONFIG_ARCH_ARM920T is not set +# CONFIG_ARCH_CORTEXM0 is not set +# CONFIG_ARCH_CORTEXM23 is not set +# CONFIG_ARCH_CORTEXM3 is not set +# CONFIG_ARCH_CORTEXM33 is not set +CONFIG_ARCH_CORTEXM4=y +# CONFIG_ARCH_CORTEXM7 is not set +# CONFIG_ARCH_CORTEXA5 is not set +# CONFIG_ARCH_CORTEXA8 is not set +# CONFIG_ARCH_CORTEXA9 is not set +# CONFIG_ARCH_CORTEXR4 is not set +# CONFIG_ARCH_CORTEXR4F is not set +# CONFIG_ARCH_CORTEXR5 is not set +# CONFIG_ARCH_CORTEXR5F is not set +# CONFIG_ARCH_CORTEXR7 is not set +# CONFIG_ARCH_CORTEXR7F is not set +CONFIG_ARCH_FAMILY="armv7-m" +CONFIG_ARCH_CHIP="stm32l4" +# CONFIG_ARMV7M_USEBASEPRI is not set +CONFIG_ARCH_HAVE_CMNVECTOR=y +CONFIG_ARMV7M_CMNVECTOR=y +# CONFIG_ARMV7M_LAZYFPU is not set +CONFIG_ARCH_HAVE_FPU=y +# CONFIG_ARCH_HAVE_DPFPU is not set +CONFIG_ARCH_FPU=y +# CONFIG_ARCH_HAVE_TRUSTZONE is not set +CONFIG_ARM_HAVE_MPU_UNIFIED=y +# CONFIG_ARM_MPU is not set + +# +# ARMV7M Configuration Options +# +# CONFIG_ARMV7M_HAVE_ICACHE is not set +# CONFIG_ARMV7M_HAVE_DCACHE is not set +# CONFIG_ARMV7M_HAVE_ITCM is not set +# CONFIG_ARMV7M_HAVE_DTCM is not set +# CONFIG_ARMV7M_TOOLCHAIN_IARL is not set +# CONFIG_ARMV7M_TOOLCHAIN_BUILDROOT is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODEREDL is not set +# CONFIG_ARMV7M_TOOLCHAIN_CODESOURCERYL is not set +CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIL=y +# CONFIG_ARMV7M_TOOLCHAIN_CLANGL is not set +CONFIG_ARMV7M_HAVE_STACKCHECK=y +# CONFIG_ARMV7M_STACKCHECK is not set +# CONFIG_ARMV7M_ITMSYSLOG is not set +# CONFIG_SERIAL_TERMIOS is not set +# CONFIG_UART4_RS485 is not set +# CONFIG_SERIAL_DISABLE_REORDERING is not set + +# +# STM32L4 Configuration Options +# +# CONFIG_ARCH_CHIP_STM32L432KB is not set +# CONFIG_ARCH_CHIP_STM32L432KC is not set +# CONFIG_ARCH_CHIP_STM32L442KC is not set +# CONFIG_ARCH_CHIP_STM32L433CB is not set +# CONFIG_ARCH_CHIP_STM32L433CC is not set +# CONFIG_ARCH_CHIP_STM32L433RB is not set +# CONFIG_ARCH_CHIP_STM32L433RC is not set +# CONFIG_ARCH_CHIP_STM32L433VC is not set +# CONFIG_ARCH_CHIP_STM32L443CC is not set +# CONFIG_ARCH_CHIP_STM32L443RC is not set +# CONFIG_ARCH_CHIP_STM32L443VC is not set +# CONFIG_ARCH_CHIP_STM32L451CC is not set +# CONFIG_ARCH_CHIP_STM32L451CE is not set +# CONFIG_ARCH_CHIP_STM32L451RC is not set +# CONFIG_ARCH_CHIP_STM32L451RE is not set +# CONFIG_ARCH_CHIP_STM32L451VC is not set +# CONFIG_ARCH_CHIP_STM32L451VE is not set +# CONFIG_ARCH_CHIP_STM32L452CC is not set +# CONFIG_ARCH_CHIP_STM32L452CE is not set +# CONFIG_ARCH_CHIP_STM32L452RC is not set +# CONFIG_ARCH_CHIP_STM32L452RE is not set +# CONFIG_ARCH_CHIP_STM32L452VC is not set +# CONFIG_ARCH_CHIP_STM32L452VE is not set +# CONFIG_ARCH_CHIP_STM32L462CE is not set +# CONFIG_ARCH_CHIP_STM32L462RE is not set +# CONFIG_ARCH_CHIP_STM32L462VE is not set +# CONFIG_ARCH_CHIP_STM32L475RG is not set +# CONFIG_ARCH_CHIP_STM32L475RE is not set +# CONFIG_ARCH_CHIP_STM32L475RC is not set +CONFIG_ARCH_CHIP_STM32L475VG=y +# CONFIG_ARCH_CHIP_STM32L475VE is not set +# CONFIG_ARCH_CHIP_STM32L475VC is not set +# CONFIG_ARCH_CHIP_STM32L476RG is not set +# CONFIG_ARCH_CHIP_STM32L476RE is not set +# CONFIG_ARCH_CHIP_STM32L486 is not set +# CONFIG_ARCH_CHIP_STM32L496ZE is not set +# CONFIG_ARCH_CHIP_STM32L496ZG is not set +# CONFIG_ARCH_CHIP_STM32L4A6 is not set +# CONFIG_STM32L4_STM32L4X1 is not set +# CONFIG_STM32L4_STM32L4X2 is not set +# CONFIG_STM32L4_STM32L4X3 is not set +CONFIG_STM32L4_STM32L4X5=y +# CONFIG_STM32L4_STM32L4X6 is not set +# CONFIG_STM32L4_STM32L431XX is not set +# CONFIG_STM32L4_STM32L432XX is not set +# CONFIG_STM32L4_STM32L433XX is not set +# CONFIG_STM32L4_STM32L442XX is not set +# CONFIG_STM32L4_STM32L443XX is not set +# CONFIG_STM32L4_STM32L451XX is not set +# CONFIG_STM32L4_STM32L452XX is not set +# CONFIG_STM32L4_STM32L462XX is not set +# CONFIG_STM32L4_STM32L471XX is not set +CONFIG_STM32L4_STM32L475XX=y +# CONFIG_STM32L4_STM32L476XX is not set +# CONFIG_STM32L4_STM32L486XX is not set +# CONFIG_STM32L4_STM32L496XX is not set +# CONFIG_STM32L4_STM32L4A6XX is not set +CONFIG_STM32L4_FLASH_OVERRIDE_DEFAULT=y +# CONFIG_STM32L4_FLASH_OVERRIDE_B is not set +# CONFIG_STM32L4_FLASH_OVERRIDE_C is not set +# CONFIG_STM32L4_FLASH_OVERRIDE_E is not set +# CONFIG_STM32L4_FLASH_OVERRIDE_G is not set +# CONFIG_STM32L4_FLASH_CONFIG_C is not set +# CONFIG_STM32L4_FLASH_CONFIG_E is not set +CONFIG_STM32L4_FLASH_CONFIG_G=y +# CONFIG_STM32L4_IO_CONFIG_K is not set +# CONFIG_STM32L4_IO_CONFIG_C is not set +CONFIG_STM32L4_IO_CONFIG_R=y +# CONFIG_STM32L4_IO_CONFIG_J is not set +# CONFIG_STM32L4_IO_CONFIG_M is not set +# CONFIG_STM32L4_IO_CONFIG_V is not set +# CONFIG_STM32L4_IO_CONFIG_Q is not set +# CONFIG_STM32L4_IO_CONFIG_Z is not set +# CONFIG_STM32L4_IO_CONFIG_A is not set + +# +# STM32L4 SRAM2 Options +# +# CONFIG_STM32L4_SRAM2_HEAP is not set +# CONFIG_STM32L4_SRAM2_INIT is not set + +# +# STM32L4 Peripherals +# + +# +# STM32L4 Peripheral Support +# +CONFIG_STM32L4_HAVE_ADC2=y +CONFIG_STM32L4_HAVE_ADC3=y +# CONFIG_STM32L4_HAVE_AES is not set +# CONFIG_STM32L4_HAVE_CAN2 is not set +CONFIG_STM32L4_HAVE_COMP=y +CONFIG_STM32L4_HAVE_DAC2=y +# CONFIG_STM32L4_HAVE_DCMI is not set +CONFIG_STM32L4_HAVE_DFSDM1=y +# CONFIG_STM32L4_HAVE_DMA2D is not set +CONFIG_STM32L4_HAVE_FSMC=y +# CONFIG_STM32L4_HAVE_HASH is not set +# CONFIG_STM32L4_HAVE_I2C4 is not set +# CONFIG_STM32L4_HAVE_LCD is not set +# CONFIG_STM32L4_HAVE_LTDC is not set +CONFIG_STM32L4_HAVE_LPTIM1=y +CONFIG_STM32L4_HAVE_LPTIM2=y +CONFIG_STM32L4_HAVE_OTGFS=y +CONFIG_STM32L4_HAVE_SAI1=y +CONFIG_STM32L4_HAVE_SAI2=y +CONFIG_STM32L4_HAVE_SDMMC1=y +CONFIG_STM32L4_HAVE_TIM3=y +CONFIG_STM32L4_HAVE_TIM4=y +CONFIG_STM32L4_HAVE_TIM5=y +CONFIG_STM32L4_HAVE_TIM7=y +CONFIG_STM32L4_HAVE_TIM8=y +CONFIG_STM32L4_HAVE_TIM17=y +# CONFIG_STM32L4_ADC is not set +# CONFIG_STM32L4_CAN is not set +# CONFIG_STM32L4_DAC is not set +# CONFIG_STM32L4_DMA is not set +# CONFIG_STM32L4_I2C is not set +# CONFIG_STM32L4_SAI is not set +# CONFIG_STM32L4_SPI is not set +CONFIG_STM32L4_USART=y +# CONFIG_STM32L4_LPTIM is not set + +# +# AHB1 Peripherals +# +# CONFIG_STM32L4_DMA1 is not set +# CONFIG_STM32L4_DMA2 is not set +# CONFIG_STM32L4_CRC is not set +# CONFIG_STM32L4_TSC is not set + +# +# AHB2 Peripherals +# +# CONFIG_STM32L4_OTGFS is not set +# CONFIG_STM32L4_ADC1 is not set +# CONFIG_STM32L4_ADC2 is not set +# CONFIG_STM32L4_ADC3 is not set +# CONFIG_STM32L4_RNG is not set + +# +# AHB3 Peripherals +# +# CONFIG_STM32L4_FSMC is not set +# CONFIG_STM32L4_QSPI is not set + +# +# APB1 Peripherals +# +# CONFIG_STM32L4_PWR is not set +# CONFIG_STM32L4_TIM2 is not set +# CONFIG_STM32L4_TIM3 is not set +# CONFIG_STM32L4_TIM4 is not set +# CONFIG_STM32L4_TIM5 is not set +# CONFIG_STM32L4_TIM6 is not set +# CONFIG_STM32L4_TIM7 is not set +# CONFIG_STM32L4_SPI2 is not set +# CONFIG_STM32L4_SPI3 is not set +# CONFIG_STM32L4_USART2 is not set +# CONFIG_STM32L4_USART3 is not set +CONFIG_STM32L4_UART4=y +# CONFIG_STM32L4_UART5 is not set +# CONFIG_STM32L4_I2C1 is not set +# CONFIG_STM32L4_I2C2 is not set +# CONFIG_STM32L4_I2C3 is not set +# CONFIG_STM32L4_CAN1 is not set +# CONFIG_STM32L4_DAC1 is not set +# CONFIG_STM32L4_DAC2 is not set +# CONFIG_STM32L4_OPAMP is not set +# CONFIG_STM32L4_LPTIM1 is not set +# CONFIG_STM32L4_LPUART1 is not set +# CONFIG_STM32L4_SWPMI is not set +# CONFIG_STM32L4_LPTIM2 is not set + +# +# APB2 Peripherals +# +CONFIG_STM32L4_SYSCFG=y +CONFIG_STM32L4_FIREWALL=y +# CONFIG_STM32L4_SDMMC1 is not set +# CONFIG_STM32L4_TIM1 is not set +# CONFIG_STM32L4_SPI1 is not set +# CONFIG_STM32L4_TIM8 is not set +# CONFIG_STM32L4_USART1 is not set +# CONFIG_STM32L4_TIM15 is not set +# CONFIG_STM32L4_TIM16 is not set +# CONFIG_STM32L4_TIM17 is not set +# CONFIG_STM32L4_COMP is not set +# CONFIG_STM32L4_SAI1 is not set +# CONFIG_STM32L4_SAI2 is not set +# CONFIG_STM32L4_DFSDM1 is not set + +# +# Other Peripherals +# +# CONFIG_STM32L4_BKPSRAM is not set +# CONFIG_STM32L4_IWDG is not set +# CONFIG_STM32L4_WWDG is not set +CONFIG_STM32L4_FLASH_PREFETCH=y +# CONFIG_STM32L4_DISABLE_IDLE_SLEEP_DURING_DEBUG is not set +# CONFIG_ARCH_BOARD_STM32L4_CUSTOM_CLOCKCONFIG is not set +# CONFIG_STM32L4_SAI1PLL is not set +# CONFIG_STM32L4_SAI2PLL is not set + +# +# Timer Configuration +# +# CONFIG_STM32L4_ONESHOT is not set +# CONFIG_STM32L4_FREERUN is not set +# CONFIG_STM32L4_TIM3_CAP is not set +# CONFIG_STM32L4_TIM4_CAP is not set +# CONFIG_STM32L4_TIM5_CAP is not set +# CONFIG_STM32L4_TIM8_CAP is not set +CONFIG_STM32L4_HAVE_USART1=y +CONFIG_STM32L4_HAVE_USART2=y +CONFIG_STM32L4_HAVE_USART3=y +CONFIG_STM32L4_HAVE_UART4=y +CONFIG_STM32L4_HAVE_UART5=y + +# +# U[S]ART Configuration +# +# CONFIG_STM32L4_FLOWCONTROL_BROKEN is not set +# CONFIG_STM32L4_USART_BREAKS is not set +# CONFIG_ARCH_TOOLCHAIN_IAR is not set +CONFIG_ARCH_TOOLCHAIN_GNU=y + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_VECNOTIRQ is not set +# CONFIG_ARCH_DMA is not set +CONFIG_ARCH_HAVE_IRQPRIO=y +# CONFIG_ARCH_L2CACHE is not set +# CONFIG_ARCH_HAVE_COHERENT_DCACHE is not set +# CONFIG_ARCH_HAVE_ADDRENV is not set +# CONFIG_ARCH_NEED_ADDRENV_MAPPING is not set +# CONFIG_ARCH_HAVE_MULTICPU is not set +CONFIG_ARCH_HAVE_VFORK=y +# CONFIG_ARCH_HAVE_MMU is not set +CONFIG_ARCH_HAVE_MPU=y +# CONFIG_ARCH_NAND_HWECC is not set +# CONFIG_ARCH_HAVE_EXTCLK is not set +# CONFIG_ARCH_HAVE_POWEROFF is not set +CONFIG_ARCH_HAVE_RESET=y +# CONFIG_ARCH_HAVE_RTC_SUBSECONDS is not set +# CONFIG_ARCH_USE_MPU is not set +# CONFIG_ARCH_IRQPRIO is not set +CONFIG_ARCH_STACKDUMP=y +# CONFIG_ENDIAN_BIG is not set +# CONFIG_ARCH_IDLE_CUSTOM is not set +# CONFIG_ARCH_HAVE_RAMFUNCS is not set +CONFIG_ARCH_HAVE_RAMVECTORS=y +# CONFIG_ARCH_RAMVECTORS is not set +# CONFIG_ARCH_MINIMAL_VECTORTABLE is not set + +# +# Board Settings +# +CONFIG_BOARD_LOOPSPERMSEC=16717 +# CONFIG_ARCH_CALIBRATION is not set + +# +# Interrupt options +# +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +CONFIG_ARCH_INTERRUPTSTACK=0 +CONFIG_ARCH_HAVE_HIPRI_INTERRUPT=y +# CONFIG_ARCH_HIPRI_INTERRUPT is not set + +# +# Boot options +# +# CONFIG_BOOT_RUNFROMEXTSRAM is not set +CONFIG_BOOT_RUNFROMFLASH=y +# CONFIG_BOOT_RUNFROMISRAM is not set +# CONFIG_BOOT_RUNFROMSDRAM is not set +# CONFIG_BOOT_COPYTORAM is not set + +# +# Boot Memory Configuration +# +CONFIG_RAM_START=0x20000000 +CONFIG_RAM_SIZE=114688 +# CONFIG_ARCH_HAVE_SDRAM is not set + +# +# Board Selection +# +CONFIG_ARCH_BOARD_B_L475E_IOT01A=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="b-l475e-iot01a" + +# +# Common Board Options +# +CONFIG_ARCH_HAVE_LEDS=y +CONFIG_ARCH_LEDS=y + +# +# Board-Specific Options +# +# CONFIG_BOARD_CRASHDUMP is not set +CONFIG_LIB_BOARDCTL=y +# CONFIG_BOARDCTL_RESET is not set +# CONFIG_BOARDCTL_UNIQUEID is not set +# CONFIG_BOARDCTL_TSCTEST is not set +# CONFIG_BOARDCTL_GRAPHICS is not set +# CONFIG_BOARDCTL_IOCTL is not set + +# +# RTOS Features +# +CONFIG_DISABLE_OS_API=y +# CONFIG_DISABLE_POSIX_TIMERS is not set +# CONFIG_DISABLE_PTHREAD is not set +# CONFIG_DISABLE_SIGNALS is not set +# CONFIG_DISABLE_MQUEUE is not set +# CONFIG_DISABLE_ENVIRON is not set + +# +# Clocks and Timers +# +CONFIG_ARCH_HAVE_TICKLESS=y +# CONFIG_SCHED_TICKLESS is not set +CONFIG_USEC_PER_TICK=10000 +# CONFIG_SYSTEM_TIME64 is not set +# CONFIG_CLOCK_MONOTONIC is not set +# CONFIG_ARCH_HAVE_TIMEKEEPING is not set +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2011 +CONFIG_START_MONTH=12 +CONFIG_START_DAY=6 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=16 +CONFIG_WDOG_INTRESERVE=4 +CONFIG_PREALLOC_TIMERS=4 + +# +# Tasks and Scheduling +# +# CONFIG_SPINLOCK is not set +# CONFIG_INIT_NONE is not set +CONFIG_INIT_ENTRYPOINT=y +# CONFIG_INIT_FILEPATH is not set +CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_RR_INTERVAL=200 +# CONFIG_SCHED_SPORADIC is not set +CONFIG_TASK_NAME_SIZE=31 +CONFIG_MAX_TASKS=16 +# CONFIG_SCHED_HAVE_PARENT is not set +CONFIG_SCHED_WAITPID=y + +# +# Pthread Options +# +# CONFIG_PTHREAD_MUTEX_TYPES is not set +CONFIG_PTHREAD_MUTEX_ROBUST=y +# CONFIG_PTHREAD_MUTEX_UNSAFE is not set +# CONFIG_PTHREAD_MUTEX_BOTH is not set +CONFIG_NPTHREAD_KEYS=4 +# CONFIG_PTHREAD_CLEANUP is not set +# CONFIG_CANCELLATION_POINTS is not set + +# +# Performance Monitoring +# +# CONFIG_SCHED_CPULOAD is not set +# CONFIG_SCHED_INSTRUMENTATION is not set + +# +# Files and I/O +# +CONFIG_DEV_CONSOLE=y +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +# CONFIG_PRIORITY_INHERITANCE is not set + +# +# RTOS hooks +# +# CONFIG_BOARD_INITIALIZE is not set +# CONFIG_SCHED_STARTHOOK is not set +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set + +# +# Signal Numbers +# +CONFIG_SIG_SIGUSR1=1 +CONFIG_SIG_SIGUSR2=2 +CONFIG_SIG_SIGALARM=3 +CONFIG_SIG_SIGCONDTIMEDOUT=16 + +# +# POSIX Message Queue Options +# +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +# CONFIG_MODULE is not set + +# +# Work queue support +# +# CONFIG_SCHED_WORKQUEUE is not set +# CONFIG_SCHED_HPWORK is not set +# CONFIG_SCHED_LPWORK is not set + +# +# Stack and heap information +# +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=2048 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 +# CONFIG_LIB_SYSCALL is not set + +# +# Device Drivers +# +CONFIG_DISABLE_POLL=y +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_DEV_URANDOM is not set +# CONFIG_DEV_LOOP is not set + +# +# Buffering +# +# CONFIG_DRVR_WRITEBUFFER is not set +# CONFIG_DRVR_READAHEAD is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_ARCH_HAVE_PWM_PULSECOUNT is not set +# CONFIG_ARCH_HAVE_PWM_MULTICHAN is not set +# CONFIG_PWM is not set +CONFIG_ARCH_HAVE_I2CRESET=y +# CONFIG_I2C is not set +# CONFIG_ARCH_HAVE_SPI_CRCGENERATION is not set +# CONFIG_ARCH_HAVE_SPI_CS_CONTROL is not set +CONFIG_ARCH_HAVE_SPI_BITORDER=y +# CONFIG_SPI is not set +# CONFIG_I2S is not set + +# +# Timer Driver Support +# +# CONFIG_TIMER is not set +# CONFIG_ONESHOT is not set +# CONFIG_RTC is not set +CONFIG_WATCHDOG=y +CONFIG_WATCHDOG_DEVPATH="/dev/watchdog0" +# CONFIG_ANALOG is not set +# CONFIG_AUDIO_DEVICES is not set +# CONFIG_VIDEO_DEVICES is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set + +# +# IO Expander/GPIO Support +# +# CONFIG_IOEXPANDER is not set +# CONFIG_DEV_GPIO is not set + +# +# LCD Driver Support +# +# CONFIG_LCD is not set +# CONFIG_SLCD is not set + +# +# LED Support +# +# CONFIG_USERLED is not set +# CONFIG_RGBLED is not set +# CONFIG_PCA9635PW is not set +# CONFIG_NCP5623C is not set +# CONFIG_MMCSD is not set +# CONFIG_MODEM is not set +# CONFIG_MTD is not set +# CONFIG_EEPROM is not set +# CONFIG_PIPES is not set +# CONFIG_PM is not set +# CONFIG_POWER is not set +# CONFIG_SENSORS is not set +CONFIG_SERIAL=y +# CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_SERIAL_REMOVABLE is not set +CONFIG_SERIAL_CONSOLE=y +# CONFIG_16550_UART is not set +# CONFIG_UART_SERIALDRIVER is not set +# CONFIG_UART0_SERIALDRIVER is not set +# CONFIG_UART1_SERIALDRIVER is not set +# CONFIG_UART2_SERIALDRIVER is not set +# CONFIG_UART3_SERIALDRIVER is not set +CONFIG_UART4_SERIALDRIVER=y +# CONFIG_UART5_SERIALDRIVER is not set +# CONFIG_UART6_SERIALDRIVER is not set +# CONFIG_UART7_SERIALDRIVER is not set +# CONFIG_UART8_SERIALDRIVER is not set +# CONFIG_SCI0_SERIALDRIVER is not set +# CONFIG_SCI1_SERIALDRIVER is not set +# CONFIG_USART0_SERIALDRIVER is not set +# CONFIG_USART1_SERIALDRIVER is not set +# CONFIG_USART2_SERIALDRIVER is not set +# CONFIG_USART3_SERIALDRIVER is not set +# CONFIG_USART4_SERIALDRIVER is not set +# CONFIG_USART5_SERIALDRIVER is not set +# CONFIG_USART6_SERIALDRIVER is not set +# CONFIG_USART7_SERIALDRIVER is not set +# CONFIG_USART8_SERIALDRIVER is not set +# CONFIG_OTHER_UART_SERIALDRIVER is not set +CONFIG_MCU_SERIAL=y +CONFIG_STANDARD_SERIAL=y +# CONFIG_SERIAL_IFLOWCONTROL is not set +# CONFIG_SERIAL_OFLOWCONTROL is not set +# CONFIG_SERIAL_DMA is not set +CONFIG_ARCH_HAVE_SERIAL_TERMIOS=y +CONFIG_UART4_SERIAL_CONSOLE=y +# CONFIG_OTHER_SERIAL_CONSOLE is not set +# CONFIG_NO_SERIAL_CONSOLE is not set + +# +# UART4 Configuration +# +CONFIG_UART4_RXBUFSIZE=256 +CONFIG_UART4_TXBUFSIZE=256 +CONFIG_UART4_BAUD=115200 +CONFIG_UART4_BITS=8 +CONFIG_UART4_PARITY=0 +CONFIG_UART4_2STOP=0 +# CONFIG_UART4_IFLOWCONTROL is not set +# CONFIG_UART4_OFLOWCONTROL is not set +# CONFIG_UART4_DMA is not set +# CONFIG_PSEUDOTERM is not set +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_USBMISC is not set +# CONFIG_HAVE_USBTRACE is not set +# CONFIG_DRIVERS_WIRELESS is not set +# CONFIG_DRIVERS_CONTACTLESS is not set + +# +# System Logging +# +# CONFIG_ARCH_SYSLOG is not set +CONFIG_SYSLOG_WRITE=y +# CONFIG_RAMLOG is not set +# CONFIG_SYSLOG_BUFFER is not set +# CONFIG_SYSLOG_INTBUFFER is not set +# CONFIG_SYSLOG_TIMESTAMP is not set +CONFIG_SYSLOG_SERIAL_CONSOLE=y +# CONFIG_SYSLOG_CHAR is not set +CONFIG_SYSLOG_CONSOLE=y +# CONFIG_SYSLOG_NONE is not set +# CONFIG_SYSLOG_FILE is not set +# CONFIG_SYSLOG_CHARDEV is not set + +# +# Networking Support +# +# CONFIG_ARCH_HAVE_NET is not set +# CONFIG_ARCH_HAVE_PHY is not set +# CONFIG_NET is not set + +# +# Crypto API +# +# CONFIG_CRYPTO is not set + +# +# File Systems +# + +# +# File system configuration +# +# CONFIG_DISABLE_MOUNTPOINT is not set +# CONFIG_FS_AUTOMOUNTER is not set +# CONFIG_DISABLE_PSEUDOFS_OPERATIONS is not set +# CONFIG_PSEUDOFS_SOFTLINKS is not set +CONFIG_FS_READABLE=y +# CONFIG_FS_WRITABLE is not set +# CONFIG_FS_NAMED_SEMAPHORES is not set +CONFIG_FS_MQUEUE_MPATH="/var/mqueue" +# CONFIG_FS_RAMMAP is not set +# CONFIG_FS_FAT is not set +# CONFIG_FS_NXFFS is not set +# CONFIG_FS_ROMFS is not set +# CONFIG_FS_TMPFS is not set +# CONFIG_FS_SMARTFS is not set +# CONFIG_FS_BINFS is not set +CONFIG_FS_PROCFS=y +# CONFIG_FS_PROCFS_REGISTER is not set + +# +# Exclude individual procfs entries +# +# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set +# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set +# CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set +# CONFIG_FS_UNIONFS is not set + +# +# Graphics Support +# +# CONFIG_NX is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=2 +# CONFIG_ARCH_HAVE_HEAP2 is not set +# CONFIG_GRAN is not set + +# +# Common I/O Buffer Support +# +# CONFIG_MM_IOB is not set + +# +# Audio Support +# +# CONFIG_AUDIO is not set + +# +# Wireless Support +# +# CONFIG_WIRELESS is not set + +# +# Binary Loader +# +# CONFIG_BINFMT_DISABLE is not set +# CONFIG_BINFMT_EXEPATH is not set +# CONFIG_NXFLAT is not set +# CONFIG_ELF is not set +CONFIG_BUILTIN=y +# CONFIG_PIC is not set +# CONFIG_SYMTAB_ORDEREDBYNAME is not set + +# +# Library Routines +# + +# +# Standard C Library Options +# + +# +# Standard C I/O +# +# CONFIG_STDIO_DISABLE_BUFFERING is not set +CONFIG_STDIO_BUFFER_SIZE=64 +CONFIG_STDIO_LINEBUFFER=y +CONFIG_NUNGET_CHARS=2 +# CONFIG_NOPRINTF_FIELDWIDTH is not set +# CONFIG_LIBC_FLOATINGPOINT is not set +CONFIG_LIBC_LONG_LONG=y +# CONFIG_LIBC_SCANSET is not set +# CONFIG_EOL_IS_CR is not set +# CONFIG_EOL_IS_LF is not set +# CONFIG_EOL_IS_BOTH_CRLF is not set +CONFIG_EOL_IS_EITHER_CRLF=y +# CONFIG_MEMCPY_VIK is not set +# CONFIG_LIBM is not set + +# +# Architecture-Specific Support +# +CONFIG_ARCH_LOWPUTC=y +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_LIBC_ARCH_MEMCPY is not set +# CONFIG_LIBC_ARCH_MEMCMP is not set +# CONFIG_LIBC_ARCH_MEMMOVE is not set +# CONFIG_LIBC_ARCH_MEMSET is not set +# CONFIG_LIBC_ARCH_STRCHR is not set +# CONFIG_LIBC_ARCH_STRCMP is not set +# CONFIG_LIBC_ARCH_STRCPY is not set +# CONFIG_LIBC_ARCH_STRNCPY is not set +# CONFIG_LIBC_ARCH_STRLEN is not set +# CONFIG_LIBC_ARCH_STRNLEN is not set +# CONFIG_LIBC_ARCH_ELF is not set +# CONFIG_ARMV7M_MEMCPY is not set + +# +# stdlib Options +# +CONFIG_LIB_RAND_ORDER=1 +CONFIG_LIB_HOMEDIR="/" + +# +# Program Execution Options +# +# CONFIG_LIBC_EXECFUNCS is not set +CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=1024 +CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=2048 + +# +# errno Decode Support +# +# CONFIG_LIBC_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set + +# +# memcpy/memset Options +# +# CONFIG_MEMSET_OPTSPEED is not set +# CONFIG_LIBC_DLLFCN is not set +# CONFIG_LIBC_MODLIB is not set +# CONFIG_LIBC_WCHAR is not set +# CONFIG_LIBC_LOCALE is not set + +# +# Time/Time Zone Support +# +# CONFIG_LIBC_LOCALTIME is not set +# CONFIG_TIME_EXTENDED is not set +CONFIG_ARCH_HAVE_TLS=y + +# +# Thread Local Storage (TLS) +# +# CONFIG_TLS is not set + +# +# Network-Related Options +# +# CONFIG_LIBC_IPv4_ADDRCONV is not set +# CONFIG_LIBC_IPv6_ADDRCONV is not set +# CONFIG_LIBC_NETDB is not set + +# +# NETDB Support +# +# CONFIG_NETDB_HOSTFILE is not set +# CONFIG_LIBC_IOCTL_VARIADIC is not set +CONFIG_LIB_SENDFILE_BUFSIZE=512 + +# +# Non-standard Library Support +# +# CONFIG_LIB_CRC64_FAST is not set +# CONFIG_LIB_KBDCODEC is not set +# CONFIG_LIB_SLCDCODEC is not set +# CONFIG_LIB_HEX2BIN is not set + +# +# Basic CXX Support +# +# CONFIG_C99_BOOL8 is not set +CONFIG_HAVE_CXX=y +# CONFIG_CXX_NEWLONG is not set + +# +# LLVM C++ Library (libcxx) +# +# CONFIG_LIBCXX is not set + +# +# uClibc++ Standard C++ Library +# +# CONFIG_UCLIBCXX is not set + +# +# Application Configuration +# + +# +# NxWidgets/NxWM +# + +# +# Built-In Applications +# +CONFIG_BUILTIN_PROXY_STACKSIZE=1024 + +# +# CAN Utilities +# + +# +# Examples +# +# CONFIG_EXAMPLES_CCTYPE is not set +# CONFIG_EXAMPLES_CHAT is not set +# CONFIG_EXAMPLES_CONFIGDATA is not set +# CONFIG_EXAMPLES_CXXTEST is not set +# CONFIG_EXAMPLES_DHCPD is not set +# CONFIG_EXAMPLES_ELF is not set +# CONFIG_EXAMPLES_FTPC is not set +# CONFIG_EXAMPLES_FTPD is not set +# CONFIG_EXAMPLES_HELLO is not set +# CONFIG_EXAMPLES_HELLOXX is not set +# CONFIG_EXAMPLES_HIDKBD is not set +# CONFIG_EXAMPLES_IGMP is not set +# CONFIG_EXAMPLES_JSON is not set +# CONFIG_EXAMPLES_MEDIA is not set +# CONFIG_EXAMPLES_MM is not set +# CONFIG_EXAMPLES_MODBUS is not set +# CONFIG_EXAMPLES_MOUNT is not set +CONFIG_EXAMPLES_NSH=y +# CONFIG_EXAMPLES_NSH_CXXINITIALIZE is not set +# CONFIG_EXAMPLES_NULL is not set +# CONFIG_EXAMPLES_NX is not set +# CONFIG_EXAMPLES_NXFFS is not set +# CONFIG_EXAMPLES_NXHELLO is not set +# CONFIG_EXAMPLES_NXIMAGE is not set +# CONFIG_EXAMPLES_NXLINES is not set +# CONFIG_EXAMPLES_NXTERM is not set +# CONFIG_EXAMPLES_NXTEXT is not set +# CONFIG_EXAMPLES_OSTEST is not set +# CONFIG_EXAMPLES_PCA9635 is not set +# CONFIG_EXAMPLES_POSIXSPAWN is not set +# CONFIG_EXAMPLES_PPPD is not set +# CONFIG_EXAMPLES_RFID_READUID is not set +# CONFIG_EXAMPLES_RGBLED is not set +# CONFIG_EXAMPLES_SENDMAIL is not set +# CONFIG_EXAMPLES_SERIALBLASTER is not set +# CONFIG_EXAMPLES_SERIALRX is not set +# CONFIG_EXAMPLES_SERLOOP is not set +# CONFIG_EXAMPLES_SLCD is not set +# CONFIG_EXAMPLES_SMART is not set +# CONFIG_EXAMPLES_SMART_TEST is not set +# CONFIG_EXAMPLES_SMP is not set +# CONFIG_EXAMPLES_STAT is not set +# CONFIG_EXAMPLES_TCPECHO is not set +# CONFIG_EXAMPLES_TIFF is not set +# CONFIG_EXAMPLES_TOUCHSCREEN is not set +# CONFIG_EXAMPLES_USBSERIAL is not set +# CONFIG_EXAMPLES_WATCHDOG is not set +# CONFIG_EXAMPLES_WEBSERVER is not set +# CONFIG_EXAMPLES_XBC_TEST is not set + +# +# File System Utilities +# +# CONFIG_FSUTILS_INIFILE is not set +# CONFIG_FSUTILS_PASSWD is not set + +# +# GPS Utilities +# +# CONFIG_GPSUTILS_MINMEA_LIB is not set + +# +# Graphics Support +# +# CONFIG_TIFF is not set +# CONFIG_GRAPHICS_TRAVELER is not set + +# +# Interpreters +# +# CONFIG_INTERPRETERS_BAS is not set +# CONFIG_INTERPRETERS_FICL is not set +# CONFIG_INTERPRETERS_MICROPYTHON is not set +# CONFIG_INTERPRETERS_MINIBASIC is not set +# CONFIG_INTERPRETERS_PCODE is not set + +# +# FreeModBus +# +# CONFIG_MODBUS is not set + +# +# Network Utilities +# +# CONFIG_NETUTILS_CODECS is not set +# CONFIG_NETUTILS_ESP8266 is not set +# CONFIG_NETUTILS_FTPC is not set +# CONFIG_NETUTILS_JSON is not set +# CONFIG_NETUTILS_SMTP is not set + +# +# NSH Library +# +CONFIG_NSH_LIBRARY=y +# CONFIG_NSH_MOTD is not set + +# +# Command Line Configuration +# +CONFIG_NSH_READLINE=y +# CONFIG_NSH_CLE is not set +CONFIG_NSH_LINELEN=64 +# CONFIG_NSH_DISABLE_SEMICOLON is not set +# CONFIG_NSH_CMDPARMS is not set +CONFIG_NSH_MAXARGUMENTS=6 +# CONFIG_NSH_ARGCAT is not set +CONFIG_NSH_NESTDEPTH=3 +# CONFIG_NSH_DISABLEBG is not set +CONFIG_NSH_BUILTIN_APPS=y + +# +# Disable Individual commands +# +# CONFIG_NSH_DISABLE_ADDROUTE is not set +# CONFIG_NSH_DISABLE_BASENAME is not set +# CONFIG_NSH_DISABLE_CAT is not set +# CONFIG_NSH_DISABLE_CD is not set +# CONFIG_NSH_DISABLE_CP is not set +# CONFIG_NSH_DISABLE_CMP is not set +CONFIG_NSH_DISABLE_DATE=y +# CONFIG_NSH_DISABLE_DD is not set +# CONFIG_NSH_DISABLE_DF is not set +# CONFIG_NSH_DISABLE_DELROUTE is not set +# CONFIG_NSH_DISABLE_DIRNAME is not set +# CONFIG_NSH_DISABLE_ECHO is not set +# CONFIG_NSH_DISABLE_EXEC is not set +# CONFIG_NSH_DISABLE_EXIT is not set +# CONFIG_NSH_DISABLE_FREE is not set +# CONFIG_NSH_DISABLE_GET is not set +# CONFIG_NSH_DISABLE_HELP is not set +# CONFIG_NSH_DISABLE_HEXDUMP is not set +# CONFIG_NSH_DISABLE_IFCONFIG is not set +# CONFIG_NSH_DISABLE_IFUPDOWN is not set +# CONFIG_NSH_DISABLE_KILL is not set +# CONFIG_NSH_DISABLE_LOSETUP is not set +CONFIG_NSH_DISABLE_LOSMART=y +# CONFIG_NSH_DISABLE_LS is not set +# CONFIG_NSH_DISABLE_MB is not set +# CONFIG_NSH_DISABLE_MKDIR is not set +# CONFIG_NSH_DISABLE_MKRD is not set +# CONFIG_NSH_DISABLE_MH is not set +# CONFIG_NSH_DISABLE_MOUNT is not set +# CONFIG_NSH_DISABLE_MV is not set +# CONFIG_NSH_DISABLE_MW is not set +CONFIG_NSH_DISABLE_PRINTF=y +# CONFIG_NSH_DISABLE_PS is not set +# CONFIG_NSH_DISABLE_PUT is not set +# CONFIG_NSH_DISABLE_PWD is not set +# CONFIG_NSH_DISABLE_RM is not set +# CONFIG_NSH_DISABLE_RMDIR is not set +# CONFIG_NSH_DISABLE_SET is not set +# CONFIG_NSH_DISABLE_SH is not set +# CONFIG_NSH_DISABLE_SLEEP is not set +# CONFIG_NSH_DISABLE_TIME is not set +# CONFIG_NSH_DISABLE_TEST is not set +# CONFIG_NSH_DISABLE_TELNETD is not set +# CONFIG_NSH_DISABLE_UMOUNT is not set +# CONFIG_NSH_DISABLE_UNAME is not set +# CONFIG_NSH_DISABLE_UNSET is not set +# CONFIG_NSH_DISABLE_USLEEP is not set +# CONFIG_NSH_DISABLE_WGET is not set +# CONFIG_NSH_DISABLE_XD is not set +CONFIG_NSH_MMCSDMINOR=0 + +# +# Configure Command Options +# +# CONFIG_NSH_CMDOPT_DF_H is not set +# CONFIG_NSH_CMDOPT_DD_STATS is not set +CONFIG_NSH_CODECS_BUFSIZE=128 +# CONFIG_NSH_CMDOPT_HEXDUMP is not set +CONFIG_NSH_PROC_MOUNTPOINT="/proc" +CONFIG_NSH_FILEIOSIZE=512 + +# +# Scripting Support +# +# CONFIG_NSH_DISABLESCRIPT is not set +# CONFIG_NSH_DISABLE_ITEF is not set +# CONFIG_NSH_DISABLE_LOOPS is not set + +# +# Console Configuration +# +CONFIG_NSH_CONSOLE=y +# CONFIG_NSH_ALTCONDEV is not set +CONFIG_NSH_ARCHINIT=y +# CONFIG_NSH_LOGIN is not set +# CONFIG_NSH_CONSOLE_LOGIN is not set + +# +# Platform-specific Support +# +# CONFIG_PLATFORM_CONFIGDATA is not set +CONFIG_HAVE_CXXINITIALIZE=y + +# +# System Libraries and NSH Add-Ons +# +# CONFIG_SYSTEM_CLE is not set +# CONFIG_SYSTEM_CUTERM is not set +# CONFIG_SYSTEM_FREE is not set +# CONFIG_SYSTEM_HEX2BIN is not set +# CONFIG_SYSTEM_HEXED is not set +# CONFIG_SYSTEM_INSTALL is not set +# CONFIG_SYSTEM_RAMTEST is not set +CONFIG_READLINE_HAVE_EXTMATCH=y +CONFIG_SYSTEM_READLINE=y +CONFIG_READLINE_ECHO=y +# CONFIG_READLINE_TABCOMPLETION is not set +# CONFIG_READLINE_CMD_HISTORY is not set +# CONFIG_SYSTEM_SUDOKU is not set +# CONFIG_SYSTEM_SYSTEM is not set +# CONFIG_SYSTEM_TEE is not set +# CONFIG_SYSTEM_UBLOXMODEM is not set +# CONFIG_SYSTEM_VI is not set +# CONFIG_SYSTEM_ZMODEM is not set + +# +# Wireless Libraries and NSH Add-Ons +# + +# +# IEEE 802.15.4 applications +# +# CONFIG_IEEE802154_LIBMAC is not set +# CONFIG_IEEE802154_LIBUTILS is not set +# CONFIG_IEEE802154_I8SAK is not set diff --git a/configs/b-l475e-iot01a/scripts/flash.ld b/configs/b-l475e-iot01a/scripts/flash.ld new file mode 100644 index 00000000000..1812d08126c --- /dev/null +++ b/configs/b-l475e-iot01a/scripts/flash.ld @@ -0,0 +1,120 @@ +/**************************************************************************** + * configs/b-l475e-iot01a/scripts/flash.ld + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* The STM32L475VG has 1024Kb of FLASH beginning at address 0x0800:0000 and + * 128Kb of SRAM. SRAM is split up into three blocks: + * + * 1) 96Kb of SRAM beginning at address 0x2000:0000 + * 2) 32Kb of SRAM beginning at address 0x2001:8000 + * + * 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 = 128K +} + +OUTPUT_ARCH(arm) +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 : { + _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 + _edata = ABSOLUTE(.); + } > sram AT > flash + + .bss : { + _sbss = ABSOLUTE(.); + *(.bss .bss.*) + *(.gnu.linkonce.b.*) + *(COMMON) + _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/configs/b-l475e-iot01a/src/.gitignore b/configs/b-l475e-iot01a/src/.gitignore new file mode 100644 index 00000000000..726d936e1e3 --- /dev/null +++ b/configs/b-l475e-iot01a/src/.gitignore @@ -0,0 +1,2 @@ +/.depend +/Make.dep diff --git a/configs/b-l475e-iot01a/src/Makefile b/configs/b-l475e-iot01a/src/Makefile new file mode 100644 index 00000000000..1eb8cab4da8 --- /dev/null +++ b/configs/b-l475e-iot01a/src/Makefile @@ -0,0 +1,50 @@ +############################################################################ +# configs/b-l475e-iot01a/src/Makefile +# +# Copyright (C) 2017 Gregory Nutt. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +ASRCS = +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 + +include $(TOPDIR)/configs/Board.mk diff --git a/configs/b-l475e-iot01a/src/b-l475e-iot01a.h b/configs/b-l475e-iot01a/src/b-l475e-iot01a.h new file mode 100644 index 00000000000..390becb9df1 --- /dev/null +++ b/configs/b-l475e-iot01a/src/b-l475e-iot01a.h @@ -0,0 +1,88 @@ +/**************************************************************************** + * configs/b-l475e-iot01a/src/b-l475e-iot01a.h + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Simon Piriou + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __CONFIGS_B_L475E_IOT01A_SRC_B_L475E_IOT01A_H +#define __CONFIGS_B_L475E_IOT01A_SRC_B_L475E_IOT01A_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* LEDs */ + +#define GPIO_LED1 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ + GPIO_OUTPUT_CLEAR|GPIO_PORTA|GPIO_PIN5) +#define GPIO_LED2 (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_50MHz|\ + GPIO_OUTPUT_CLEAR|GPIO_PORTB|GPIO_PIN14) + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/**************************************************************************** + * Public data + ****************************************************************************/ + +#ifndef __ASSEMBLY__ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32_bringup + * + * Description: + * Called either by board_intialize() if CONFIG_BOARD_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_INITIALIZE) +int stm32l4_bringup(void); +#endif + +#endif /* __ASSEMBLY__ */ +#endif /* __CONFIGS_B_L475E_IOT01A_SRC_B_L475E_IOT01A_H */ diff --git a/configs/b-l475e-iot01a/src/stm32_appinit.c b/configs/b-l475e-iot01a/src/stm32_appinit.c new file mode 100644 index 00000000000..cbb2f010439 --- /dev/null +++ b/configs/b-l475e-iot01a/src/stm32_appinit.c @@ -0,0 +1,90 @@ +/**************************************************************************** + * config/b-l475e-iot01a/src/stm32_appinit.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#include "b-l475e-iot01a.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 initalization logic and the + * matching application logic. The value cold 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_INITIALIZE + /* Perform board initialization */ + + return stm32l4_bringup(); +#else + return OK; +#endif +} + +#endif /* CONFIG_LIB_BOARDCTL */ diff --git a/configs/b-l475e-iot01a/src/stm32_autoleds.c b/configs/b-l475e-iot01a/src/stm32_autoleds.c new file mode 100644 index 00000000000..ecf8b5f7137 --- /dev/null +++ b/configs/b-l475e-iot01a/src/stm32_autoleds.c @@ -0,0 +1,116 @@ +/**************************************************************************** + * configs/b-l475e-iot01a/src/stm32_autoleds.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/* LEDs + * + * A single LED is available driven by PA13. + * + * 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 +#include + +#include +#include + +#include "stm32l4_gpio.h" +#include "b-l475e-iot01a.h" + +#ifdef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + /* Configure LED gpio as output */ + + stm32l4_configgpio(GPIO_LED2); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + if (led == 1 || led == 3) + { + stm32l4_gpiowrite(GPIO_LED2, true); + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + if (led == 3) + { + stm32l4_gpiowrite(GPIO_LED2, false); + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/configs/b-l475e-iot01a/src/stm32_boot.c b/configs/b-l475e-iot01a/src/stm32_boot.c new file mode 100644 index 00000000000..a4a1b3cf58f --- /dev/null +++ b/configs/b-l475e-iot01a/src/stm32_boot.c @@ -0,0 +1,91 @@ +/************************************************************************************ + * configs/b-l475e-iot01a/src/stm32_boot.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Simon Piriou + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ************************************************************************************/ + +/************************************************************************************ + * Included Files + ************************************************************************************/ + +#include + +#include +#include + +#include "up_arch.h" +#include "b-l475e-iot01a.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 stm32l4_boardinitialize(void) +{ +#ifdef CONFIG_ARCH_LEDS + /* Configure on-board LEDs if LED support has been selected. */ + + board_autoled_initialize(); +#endif +} + +/**************************************************************************** + * Name: board_initialize + * + * Description: + * If CONFIG_BOARD_INITIALIZE is selected, then an additional + * initialization call will be performed in the boot-up sequence to a + * function called board_initialize(). board_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_INITIALIZE +void board_initialize(void) +{ + /* Perform board initialization */ + + (void)stm32_bringup(); +} +#endif /* CONFIG_BOARD_INITIALIZE */ diff --git a/configs/b-l475e-iot01a/src/stm32_bringup.c b/configs/b-l475e-iot01a/src/stm32_bringup.c new file mode 100644 index 00000000000..55bb4d41b37 --- /dev/null +++ b/configs/b-l475e-iot01a/src/stm32_bringup.c @@ -0,0 +1,101 @@ +/**************************************************************************** + * config/b-l475e-iot01a/src/stm32_bringup.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Simon Piriou + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include +#include + +#include + +#include "b-l475e-iot01a.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: stm32l4_bringup + * + * Description: + * Called either by board_intialize() if CONFIG_BOARD_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 stm32l4_bringup(void) +{ + int ret = OK; + +#ifdef CONFIG_FS_PROCFS + /* Mount the procfs file system */ + + ret = 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 */ + + return ret; +} diff --git a/configs/b-l475e-iot01a/src/stm32_userleds.c b/configs/b-l475e-iot01a/src/stm32_userleds.c new file mode 100644 index 00000000000..c509015b36d --- /dev/null +++ b/configs/b-l475e-iot01a/src/stm32_userleds.c @@ -0,0 +1,92 @@ +/**************************************************************************** + * configs/b-l475e-iot01a/src/stm32_userleds.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Simon Piriou + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include + +#include +#include "b-l475e-iot01a.h" + +#include "stm32l4_gpio.h" + +#ifndef CONFIG_ARCH_LEDS + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_userled_initialize + ****************************************************************************/ + +void board_userled_initialize(void) +{ + /* Configure LED gpio as output */ + + stm32l4_configgpio(GPIO_LED1); + stm32l4_configgpio(GPIO_LED2); +} + +/**************************************************************************** + * Name: board_userled + ****************************************************************************/ + +void board_userled(int led, bool ledon) +{ + if (led == BOARD_LED1) + { + stm32l4_gpiowrite(GPIO_LED1, ledon); + } + else if (led == BOARD_LED2) + { + stm32l4_gpiowrite(GPIO_LED2, ledon); + } +} + +/**************************************************************************** + * Name: board_userled_all + ****************************************************************************/ + +void board_userled_all(uint8_t ledset) +{ + stm32l4_gpiowrite(GPIO_LED1, !!(ledset & BOARD_LED1_BIT)); + stm32l4_gpiowrite(GPIO_LED2, !!(ledset & BOARD_LED2_BIT)); +} + +#endif /* !CONFIG_ARCH_LEDS */ diff --git a/configs/sim/README.txt b/configs/sim/README.txt index c4a86191beb..20f76fbf294 100644 --- a/configs/sim/README.txt +++ b/configs/sim/README.txt @@ -481,6 +481,34 @@ cxxtest postpone running C++ static initializers until NuttX has been initialized. +ipforward + + This is an NSH configuration that includes a simple test of the NuttX + IP forwarding logic using apps/examples/ipforward. That example uses + two TUN network devices to represent two networks. The test then sends + packets from one network destined for the other network. The NuttX IP + forwarding logic will recognize that the received packets are not destined + for it and will forward the logic to the other TUN network. The + application logic then both sends the packets on one network and receives + and verifies the forwarded packet recieved on the other network. The + received packets differ from the sent packets only in that the hop limit + (TTL) has been decremented. + + Be default, this test will forward TCP packets. The test can be modified + to support forwarding of ICMPv6 multicast packets with these changes to + the .config file: + + -CONFIG_EXAMPLES_IPFORWARD_TCP=y + +CONFIG_EXAMPLES_IPFORWARD_ICMPv6=y + + +CONFIG_NET_ICMPv6=y + +CONFIG_NET_ICMPv6_PING=y + +CONFIG_NET_ETHERNET=y + +CONFIG_NET_IPFORWARD_BROADCAST=y + + Additional required settings will also be selected when you manually + select the above via 'make menuconfig'. + minibasic This configuration was used to test the Mini Basic port at diff --git a/configs/sim/ipforward/defconfig b/configs/sim/ipforward/defconfig index 312519a65ff..fa50f6111e9 100644 --- a/configs/sim/ipforward/defconfig +++ b/configs/sim/ipforward/defconfig @@ -106,9 +106,7 @@ CONFIG_HOST_X86_64=y CONFIG_SIM_X8664_SYSTEMV=y # CONFIG_SIM_X8664_MICROSOFT is not set CONFIG_SIM_WALLTIME=y -CONFIG_SIM_NETDEV=y -CONFIG_SIM_NET_HOST_ROUTE=y -# CONFIG_SIM_NET_BRIDGE is not set +# CONFIG_SIM_NETDEV is not set # CONFIG_SIM_FRAMEBUFFER is not set # CONFIG_SIM_SPIFLASH is not set # CONFIG_SIM_QSPIFLASH is not set @@ -808,6 +806,7 @@ CONFIG_BUILTIN_PROXY_STACKSIZE=1024 # CONFIG_EXAMPLES_HIDKBD is not set # CONFIG_EXAMPLES_IGMP is not set CONFIG_EXAMPLES_IPFORWARD=y +CONFIG_EXAMPLES_IPFORWARD_TCP=y CONFIG_EXAMPLES_IPFORWARD_PRIORITY=100 CONFIG_EXAMPLES_IPFORWARD_STACKSIZE=8192 # CONFIG_EXAMPLES_JSON is not set diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 33fd566307a..cf5ce5101ee 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c @@ -171,10 +171,8 @@ static void tun_poll_expiry(int argc, wdparm_t arg, ...); static int tun_ifup(FAR struct net_driver_s *dev); static int tun_ifdown(FAR struct net_driver_s *dev); static int tun_txavail(FAR struct net_driver_s *dev); -#if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) -static int tun_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac); -#endif #ifdef CONFIG_NET_IGMP +static int tun_addmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac); static int tun_rmmac(FAR struct net_driver_s *dev, FAR const uint8_t *mac); #endif #ifdef CONFIG_NET_ICMPv6 @@ -780,7 +778,7 @@ static int tun_txavail(struct net_driver_s *dev) * ****************************************************************************/ -#if defined(CONFIG_NET_IGMP) || defined(CONFIG_NET_ICMPv6) +#ifdef CONFIG_NET_IGMP static int tun_addmac(struct net_driver_s *dev, FAR const uint8_t *mac) { /* Add the MAC address to the hardware multicast routing table */ diff --git a/include/nuttx/net/netdev.h b/include/nuttx/net/netdev.h index 7c34217ae9b..cc6034c4726 100644 --- a/include/nuttx/net/netdev.h +++ b/include/nuttx/net/netdev.h @@ -318,12 +318,13 @@ struct net_driver_s * * There are two lists associated with each device: * - * 1) d_pktcb - For connection/port oriented events for certain + * 1) d_conncb - For connection/port oriented events for certain * socket-less packet transfers. There events include: * - * ICMP data receipt: ICMP_NEWDATA, ICMPv6_NEWDATA - * ICMP ECHO replies: ICMP_ECHOREPLY, ICMPv6_ECHOREPLY + * ICMP data receipt: ICMP_NEWDATA, ICMPv6_NEWDATA + * ICMP ECHO replies: ICMP_ECHOREPLY, ICMPv6_ECHOREPLY * Driver Tx poll events: ARP_POLL, ICMP_POLL. ICMPv6_POLL + * IP Forwarding: IPFWD_POLL * * 2) d_devcb - For non-data, device related events that apply to all * transfers or connections involving this device: diff --git a/net/devif/devif.h b/net/devif/devif.h index 99b389c9b1d..3a2215bf940 100644 --- a/net/devif/devif.h +++ b/net/devif/devif.h @@ -148,6 +148,14 @@ * is set differently * OUT: Not used * + * IPFWD_POLL IN: Used for polling for forwarded packets layer. This + * is provided periodically from the drivers to support + * to check if there is a packet waiting to be forward + * on the device. This is a device oriented event, + * not associated with a socket. The appdata pointer + * The appdata pointer is not used in this case. + * OUT: Not used + * * ICMP_ECHOREPLY IN: An ICMP Echo Reply has been received. Used to support * ICMP ping from the socket layer. (ICMPv4 only) * OUT: Cleared (only) by the socket layer logic to indicate @@ -164,7 +172,7 @@ * OUT: Not used */ -/* Connection specific events */ +/* Bits 0-9: Connection specific event bits */ #define TCP_ACKDATA (1 << 0) #define TCP_NEWDATA (1 << 1) @@ -178,23 +186,33 @@ #define UDP_POLL TCP_POLL #define PKT_POLL TCP_POLL #define WPAN_POLL TCP_POLL -#define IPFWD_POLL TCP_POLL #define TCP_BACKLOG (1 << 5) #define TCP_CLOSE (1 << 6) #define TCP_ABORT (1 << 7) #define TCP_CONNECTED (1 << 8) #define TCP_TIMEDOUT (1 << 9) -/* Device specific events */ +/* Bits 10-12: Device specific event bits */ #define ICMP_NEWDATA TCP_NEWDATA #define ICMPv6_NEWDATA TCP_NEWDATA -#define ARP_POLL (1 << 10) -#define ICMP_POLL (1 << 11) -#define ICMPv6_POLL (1 << 12) -#define ICMP_ECHOREPLY (1 << 13) -#define ICMPv6_ECHOREPLY (1 << 14) -#define NETDEV_DOWN (1 << 15) +#define ICMP_ECHOREPLY (1 << 10) +#define ICMPv6_ECHOREPLY (1 << 11) +#define NETDEV_DOWN (1 << 12) + +/* Bits 13-15: Encoded device specific poll events. Unlike connection + * oriented poll events, device related poll events must distinguish + * between what is being polled for since the callbacks all reside in + * the same list in the network device structure. + */ + +#define DEVPOLL_SHIFT (13) +#define DEVPOLL_MASK (7 << DEVPOLL_SHIFT) +# define DEVPOLL_NONE (0 << DEVPOLL_SHIFT) +# define ARP_POLL (1 << DEVPOLL_SHIFT) +# define ICMP_POLL (2 << DEVPOLL_SHIFT) +# define ICMPv6_POLL (3 << DEVPOLL_SHIFT) +# define IPFWD_POLL (4 << DEVPOLL_SHIFT) /* The set of events that and implications to the TCP connection state */ diff --git a/net/devif/devif_callback.c b/net/devif/devif_callback.c index bb8867b73ff..c88dda744c3 100644 --- a/net/devif/devif_callback.c +++ b/net/devif/devif_callback.c @@ -41,6 +41,7 @@ #if defined(CONFIG_NET) #include +#include #include #include #include @@ -162,6 +163,45 @@ static void devif_callback_free(FAR struct net_driver_s *dev, } } +/**************************************************************************** + * Name: devif_event_trigger + * + * Description: + * Return true if the current set of events should trigger a callback to + * occur. + * + * Input paramters: + * events - The set of events that has occurred. + * triggers - The set of events that will trigger a callback. + * + ****************************************************************************/ + +static bool devif_event_trigger(uint16_t events, uint16_t triggers) +{ + /* The events are divided into a set of individual bits that may be ORed + * together PLUS a field that encodes a single poll event. + * + * First check if any of the individual event bits will trigger the + * callback. + */ + + if ((events & triggers & ~DEVPOLL_MASK) != 0) + { + return true; + } + + /* No... check the encoded device event. */ + + if ((events & DEVPOLL_MASK) == (triggers & DEVPOLL_MASK)) + { + return true; + } + + /* No.. this event set will not generate the callback */ + + return false; +} + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -335,7 +375,7 @@ void devif_dev_callback_free(FAR struct net_driver_s *dev, * was allocated and the time when the callback was freed. */ - if (dev && netdev_verify(dev)) + if (dev != NULL && netdev_verify(dev)) { /* The device reference is valid.. the use the list pointer in the * device structure as well. @@ -400,7 +440,7 @@ uint16_t devif_conn_event(FAR struct net_driver_s *dev, void *pvconn, /* Check if this callback handles any of the events in the flag set */ - if (list->event && (flags & list->flags) != 0) + if (list->event != NULL && devif_event_trigger(flags, list->flags)) { /* Yes.. perform the callback. Actions perform by the callback * may delete the current list entry or add a new list entry to @@ -464,7 +504,7 @@ uint16_t devif_dev_event(FAR struct net_driver_s *dev, void *pvconn, /* Check if this callback handles any of the events in the flag set */ - if (cb->event && (flags & cb->flags) != 0) + if (cb->event != NULL && devif_event_trigger(flags, cb->flags)) { /* Yes.. perform the callback. Actions perform by the callback * may delete the current list entry or add a new list entry to diff --git a/net/devif/devif_forward.c b/net/devif/devif_forward.c index 4f93ee3cbbb..8a1a1bd855c 100644 --- a/net/devif/devif_forward.c +++ b/net/devif/devif_forward.c @@ -41,6 +41,7 @@ #include #include +#include #include #include "ipforward/ipforward.h" diff --git a/net/devif/devif_poll.c b/net/devif/devif_poll.c index 73c5050f588..d5ebe1bac22 100644 --- a/net/devif/devif_poll.c +++ b/net/devif/devif_poll.c @@ -56,6 +56,7 @@ #include "icmp/icmp.h" #include "icmpv6/icmpv6.h" #include "igmp/igmp.h" +#include "ipforward/ipforward.h" #include "sixlowpan/sixlowpan.h" /**************************************************************************** @@ -106,6 +107,12 @@ systime_t g_polltime; * IEEE802.15.4 MAC network driver. Under those conditions, 6LoWPAN * logic will be called to create the IEEE80215.4 frames. * + * All outgoing ICMPv6 messages come through one of two mechanisms: + * + * 1. The output from internal ICMPv6 message passing. These outgoing + * messages will use device polling and will be handled here. + * 2. ICMPv6 output resulting from TX or timer polling. + * * Assumptions: * The network is locked. * @@ -123,17 +130,25 @@ static void devif_packet_conversion(FAR struct net_driver_s *dev, if (dev->d_len > 0) #endif { + FAR struct ipv6_hdr_s *ipv6 = (FAR struct ipv6_hdr_s *)dev->d_buf; + +#ifdef CONFIG_NET_IPv4 + if ((ipv6->vtc & IP_VERSION_MASK) != IPv6_VERSION) + { + nerr("ERROR: IPv6 version error: %02x... Packet dropped\n", + ipv6->vtc); + } + else +#endif #ifdef CONFIG_NET_TCP if (pkttype == DEVIF_TCP) { - FAR struct ipv6_hdr_s *ipv6 = (FAR struct ipv6_hdr_s *)dev->d_buf; - /* This packet came from a response to TCP polling and is directed * to an IEEE802.15.4 device using 6LoWPAN. Verify that the outgoing * packet is IPv6 with TCP protocol. */ - if (ipv6->vtc == IPv6_VERSION && ipv6->proto == IP_PROTO_TCP) + if (ipv6->proto == IP_PROTO_TCP) { /* Let 6LoWPAN convert IPv6 TCP output into IEEE802.15.4 frames. */ @@ -141,17 +156,40 @@ static void devif_packet_conversion(FAR struct net_driver_s *dev, } else { - nerr("ERROR: IPv6 version or protocol error. Packet dropped\n"); - nerr(" IP version: %02x proocol: %u\n", - ipv6->vtc, ipv6->proto); + nerr("ERROR: TCP protocol error: %u... Packet dropped\n", + ipv6->proto); + } + } + else +#endif +#ifdef CONFIG_NET_ICMPv6 + if (pkttype == DEVIF_ICMP6) + { + /* This packet came from a response to TCP polling and is directed + * to an IEEE802.15.4 device using 6LoWPAN. Verify that the outgoing + * packet is IPv6 with TCP protocol. + */ + + if (ipv6->proto == IP_PROTO_ICMP6) + { + /* Let 6LoWPAN convert IPv6 ICMPv6 output into IEEE802.15.4 frames. */ + + sixlowpan_icmpv6_send(dev, dev, ipv6); + } + else + { + nerr("ERROR: ICMPv6 protocol error: %u... Packet dropped\n", + ipv6->proto); } } else #endif { - nerr("ERROR: Non-TCP packet dropped. Packet type: %u\n", pkttype); + nerr("ERROR: Unhandled packet dropped. pkttype=%u protocol=%u\n", + pkttype, ipv6->proto); } + UNUSED(ipv6); dev->d_len = 0; } } @@ -166,8 +204,8 @@ static void devif_packet_conversion(FAR struct net_driver_s *dev, * Poll all packet connections for available packets to send. * * Assumptions: - * This function is called from the MAC device driver and may be called - * from the timer interrupt/watchdog handle level. + * This function is called from the MAC device driver with the network + * locked. * ****************************************************************************/ @@ -259,13 +297,18 @@ static inline int devif_poll_icmpv6(FAR struct net_driver_s *dev, * ****************************************************************************/ -#if defined(CONFIG_NET_IPFORWARD) || defined(CONFIG_NETDEV_MULTINIC) +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) static inline int devif_poll_forward(FAR struct net_driver_s *dev, devif_poll_callback_t callback) { - /* Perform the ICMPv6 poll */ + /* Perform the forwarding poll */ - devif_dev_event(dev, NULL, IPFWD_POLL); + ipfwd_poll(dev); + + /* NOTE: that 6LoWPAN packet conversions are handled differently for + * forwarded packets. That is because we don't know what the packet + * type is at this point; not within peeking into the device's d_buf. + */ /* Call back into the driver */ @@ -280,8 +323,8 @@ static inline int devif_poll_forward(FAR struct net_driver_s *dev, * Poll all IGMP connections for available packets to send. * * Assumptions: - * This function is called from the MAC device driver and may be called - * from the timer interrupt/watchdog handle level. + * This function is called from the MAC device driver with the network + * locked. * ****************************************************************************/ @@ -310,8 +353,8 @@ static inline int devif_poll_igmp(FAR struct net_driver_s *dev, * Poll all UDP connections for available packets to send. * * Assumptions: - * This function is called from the MAC device driver and may be called - * from the timer interrupt/watchdog handle level. + * This function is called from the MAC device driver with the network + * locked. * ****************************************************************************/ @@ -350,8 +393,8 @@ static int devif_poll_udp_connections(FAR struct net_driver_s *dev, * Poll all UDP connections for available packets to send. * * Assumptions: - * This function is called from the MAC device driver and may be called - * from the timer interrupt/watchdog handle level. + * This function is called from the MAC device driver with the network + * locked. * ****************************************************************************/ @@ -393,8 +436,8 @@ static inline int devif_poll_tcp_connections(FAR struct net_driver_s *dev, * TCP connection. * * Assumptions: - * This function is called from the MAC device driver and may be called - * from the timer interrupt/watchdog handle level. + * This function is called from the MAC device driver with the network + * locked. * ****************************************************************************/ @@ -453,8 +496,8 @@ static inline int devif_poll_tcp_timer(FAR struct net_driver_s *dev, * out the packet. * * Assumptions: - * This function is called from the MAC device driver and may be called - * from the timer interrupt/watchdog handle level. + * This function is called from the MAC device driver with the network + * locked. * ****************************************************************************/ @@ -530,7 +573,7 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) if (!bstop) #endif -#if defined(CONFIG_NET_IPFORWARD) || defined(CONFIG_NETDEV_MULTINIC) +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) { /* Traverse all of the tasks waiting to forward a packet to this device. */ @@ -565,8 +608,8 @@ int devif_poll(FAR struct net_driver_s *dev, devif_poll_callback_t callback) * out the packet. * * Assumptions: - * This function is called from the MAC device driver and may be called from - * the timer interrupt/watchdog handle level. + * This function is called from the MAC device driver with the network + * locked. * ****************************************************************************/ diff --git a/net/devif/ipv6_input.c b/net/devif/ipv6_input.c index d8bb34b7933..f71e82c8833 100644 --- a/net/devif/ipv6_input.c +++ b/net/devif/ipv6_input.c @@ -416,7 +416,7 @@ int ipv6_input(FAR struct net_driver_s *dev) * during TCP packet processing by the TCP state meachine. * 3. TCP output resulting from TX or timer polling * - * Cases 2 is handled here. Logic here detected if (1) an attempt + * Case 3 is handled here. Logic here detects if (1) an attempt * to return with d_len > 0 and (2) that the device is an * IEEE802.15.4 MAC network driver. Under those conditions, 6LoWPAN * logic will be called to create the IEEE80215.4 frames. @@ -457,8 +457,40 @@ int ipv6_input(FAR struct net_driver_s *dev) /* Forward the ICMPv6 packet */ icmpv6_input(dev); - break; + +#ifdef CONFIG_NET_6LOWPAN + /* All outgoing ICMPv6 messages come through one of two mechanisms: + * + * 1. The output from internal ICMPv6 message passing. These + * outgoing messages will use device polling and will be + * handled elsewhere. + * 2. ICMPv6 output resulting from TX or timer polling. + * + * Case 2 is handled here. Logic here detects if (1) an attempt + * to return with d_len > 0 and (2) that the device is an + * IEEE802.15.4 MAC network driver. Under those conditions, 6LoWPAN + * logic will be called to create the IEEE80215.4 frames. + */ + +#ifdef CONFIG_NET_MULTILINK + /* Handle the case where multiple link layer protocols are supported */ + + if (dev->d_len > 0 && dev->d_lltype == CONFIG_NET_6LOWPAN) +#else + if (dev->d_len > 0) #endif + { + /* Let 6LoWPAN handle the ICMPv6 output */ + + sixlowpan_icmpv6_send(dev, dev, ipv6); + + /* Drop the packet in the d_buf */ + + goto drop; + } +#endif /* CONFIG_NET_6LOWPAN */ + break; +#endif /* CONFIG_NET_ICMPv6 */ default: /* Unrecognized/unsupported protocol */ #ifdef CONFIG_NET_STATISTICS diff --git a/net/icmpv6/icmpv6_input.c b/net/icmpv6/icmpv6_input.c index ab584c65afb..14a87891373 100644 --- a/net/icmpv6/icmpv6_input.c +++ b/net/icmpv6/icmpv6_input.c @@ -80,6 +80,12 @@ # define DEV_LLTYPE(d) NET_LL_ETHERNET #elif defined(CONFIG_NET_6LOWPAN) # define DEV_LLTYPE(d) NET_LL_IEEE802154 +#elif defined(CONFIG_NET_SLIP) +# define DEV_LLTYPE(d) NET_LL_SLIP +#elif defined(CONFIG_NET_TUN) +# define DEV_LLTYPE(d) NET_LL_TUN +#else /* if defined(CONFIG_NET_LOOPBACK) */ +# define DEV_LLTYPE(d) NET_LL_LOOPBACK #endif /**************************************************************************** diff --git a/net/ipforward/Make.defs b/net/ipforward/Make.defs index cc46826da53..c8ad408c564 100644 --- a/net/ipforward/Make.defs +++ b/net/ipforward/Make.defs @@ -37,8 +37,6 @@ ifeq ($(CONFIG_NET_IPFORWARD),y) -NET_CSRCS += ipfwd_forward.c - ifeq ($(CONFIG_NET_IPv4),y) NET_CSRCS += ipv4_forward.c endif @@ -48,7 +46,7 @@ NET_CSRCS += ipv6_forward.c endif ifeq ($(CONFIG_NETDEV_MULTINIC),y) -NET_CSRCS += ipfwd_alloc.c +NET_CSRCS += ipfwd_alloc.c ipfwd_forward.c ipfwd_poll.c endif ifeq ($(CONFIG_NET_STATISTICS),y) diff --git a/net/ipforward/ipforward.h b/net/ipforward/ipforward.h index 52069b80abe..e88c23a6598 100644 --- a/net/ipforward/ipforward.h +++ b/net/ipforward/ipforward.h @@ -44,16 +44,6 @@ #include -#include -#include -#include -#include -#include - -#include "udp/udp.h" -#include "tcp/tcp.h" -#include "icmpv6/icmpv6.h" - #undef HAVE_FWDALLOC #ifdef CONFIG_NET_IPFORWARD @@ -73,68 +63,15 @@ # define CONFIG_NET_IPFORWARD_NSTRUCT 4 #endif -#define FWD_HEADER(fwd) (FAR union fwd_iphdr_u *)((fwd)->f_iob->io_data) +/* Allocate a new IP forwarding data callback */ + +#define ipfwd_callback_alloc(dev) devif_callback_alloc(dev, &(dev)->d_conncb) +#define ipfwd_callback_free(dev,cb) devif_dev_callback_free(dev, cb) /**************************************************************************** * Public Types ****************************************************************************/ -/* IPv4 + L2 header */ - -#ifdef CONFIG_NET_IPv4 -struct fwd_ipv4hdr_u -{ - struct ipv4_hdr_s l2; - union - { -#ifdef CONFIG_NET_TCP - uint8_t pad[TCP_MAX_HDRLEN]; - struct tcp_hdr_s tcp; -#endif -#ifdef CONFIG_NET_UDP - struct udp_hdr_s udp; -#endif -#ifdef CONFIG_NET_ICMPv6 - struct icmp_hdr_s icmp; -#endif - } l3; -}; -#endif - -/* IPv6 + L2 header */ - -#ifdef CONFIG_NET_IPv6 -struct fwd_ipv6hdr_u -{ - struct ipv6_hdr_s l2; - union - { -#ifdef CONFIG_NET_TCP - uint8_t pad[TCP_MAX_HDRLEN]; - struct tcp_hdr_s tcp; -#endif -#ifdef CONFIG_NET_UDP - struct udp_hdr_s udp; -#endif -#ifdef CONFIG_NET_ICMPv6 - struct icmpv6_hdr_s icmpv6; -#endif - } l3; -}; -#endif - -/* IPv4 or IPv6 + L2 header */ - -union fwd_iphdr_u -{ -#ifdef CONFIG_NET_IPv4 - struct fwd_ipv4hdr_u ipv4; -#endif -#ifdef CONFIG_NET_IPv6 - struct fwd_ipv6hdr_u ipv6; -#endif -}; - /* This is the send state structure */ struct devif_callback_s; /* Forward refernce */ @@ -156,6 +93,9 @@ struct forward_s * Public Function Prototypes ****************************************************************************/ +struct ipv4_hdr_s; /* Forward reference */ +struct ipv6_hdr_s; /* Forward reference */ + /**************************************************************************** * Name: ipfwd_initialize * @@ -305,6 +245,20 @@ void devif_forward(FAR struct forward_s *fwd); int ipfwd_forward(FAR struct forward_s *fwd); +/**************************************************************************** + * Name: ipfwd_poll + * + * Description: + * Poll all pending transfer for ARP requests to send. + * + * Assumptions: + * This function is called from the MAC device driver indirectly through + * devif_poll() and devif_timer(). + * + ****************************************************************************/ + +void ipfwd_poll(FAR struct net_driver_s *dev); + #endif /* CONFIG_NETDEV_MULTINIC */ /**************************************************************************** diff --git a/net/ipforward/ipfwd_alloc.c b/net/ipforward/ipfwd_alloc.c index 01e34099e47..e2265db19ff 100644 --- a/net/ipforward/ipfwd_alloc.c +++ b/net/ipforward/ipfwd_alloc.c @@ -44,10 +44,37 @@ #include #include +#include +#include +#include +#include + #include "ipforward/ipforward.h" #if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef CONFIG_NET_IPv6 +# define L2_MAXHDRLEN IPv6_HDRLEN +#else +# define L2_MAXHDRLEN IPv4_HDRLEN +#endif + +#if defined(CONFIG_NET_TCP) +# define L3_MAXHDRLEN TCP_MAX_HDRLEN +#elif defined(CONFIG_NET_UDP) +# define L3_MAXHDRLEN UDP_HDRLEN +#elif defined(CONFIG_NET_ICMPv6) +# define L3_MAXHDRLEN ICMPv6_HDRLEN +#elif defined(CONFIG_NET_ICMP) +# define L3_MAXHDRLEN ICMP_HDRLEN +#endif + +#define MAX_HDRLEN (L2_MAXHDRLEN + L3_MAXHDRLEN) + /**************************************************************************** * Private Data ****************************************************************************/ @@ -84,7 +111,7 @@ void ipfwd_initialize(void) * the contiguous memory of the first IOB in the IOB chain. */ - DEBUGASSERT(sizeof(union fwd_iphdr_u) <= CONFIG_IOB_BUFSIZE); + DEBUGASSERT(MAX_HDRLEN <= CONFIG_IOB_BUFSIZE); /* Add all pre-allocated forwarding structures to the free list */ diff --git a/net/ipforward/ipfwd_forward.c b/net/ipforward/ipfwd_forward.c index c7e1156b105..9899fadcc73 100644 --- a/net/ipforward/ipfwd_forward.c +++ b/net/ipforward/ipfwd_forward.c @@ -144,8 +144,6 @@ static inline void forward_ipselect(FAR struct forward_s *fwd) #ifdef CONFIG_NET_ETHERNET static inline bool ipfwd_addrchk(FAR struct forward_s *fwd) { - FAR union fwd_iphdr_u *iphdr; - DEBUGASSERT(fwd != NULL && fwd->f_iob != NULL && fwd->f_dev != NULL); /* REVISIT: Could the MAC address not also be in a routing table? */ @@ -157,15 +155,14 @@ static inline bool ipfwd_addrchk(FAR struct forward_s *fwd) } #endif - iphdr = FWD_HEADER(fwd); - #ifdef CONFIG_NET_IPv4 #ifdef CONFIG_NET_IPv6 if (fwd->f_domain == PF_INET) #endif { #if !defined(CONFIG_NET_ARP_IPIN) && !defined(CONFIG_NET_ARP_SEND) - return (arp_find(iphdr->ipv4.l2.destipaddr) != NULL); + FAR stuct ipv4_hdr_s *ipv4 = (FAR stuct ipv4_hdr_s *)fwd->f_iob->io_data; + return (arp_find(ipv4->destipaddr) != NULL); #else return true; #endif @@ -178,7 +175,8 @@ static inline bool ipfwd_addrchk(FAR struct forward_s *fwd) #endif { #if !defined(CONFIG_NET_ICMPv6_NEIGHBOR) - return (neighbor_findentry(iphdr->ipv6.l2.destipaddr) != NULL); + FAR stuct ipv6_hdr_s *ipv4 = (FAR stuct ipv6_hdr_s *)fwd->f_iob->io_data; + return (neighbor_findentry(ipv6->destipaddr) != NULL); #else return true; #endif @@ -266,6 +264,7 @@ static uint16_t ipfwd_interrupt(FAR struct net_driver_s *dev, FAR void *conn, /* Copy the user data into d_appdata and send it. */ devif_forward(fwd); + flags &= ~DEVPOLL_MASK; /* Check if the destination IP address is in the ARP or Neighbor * table. If not, then the send won't actually make it out... it @@ -284,7 +283,7 @@ static uint16_t ipfwd_interrupt(FAR struct net_driver_s *dev, FAR void *conn, fwd->f_cb->priv = NULL; fwd->f_cb->event = NULL; - devif_conn_callback_free(dev, fwd->f_cb, NULL); + ipfwd_callback_free(dev, fwd->f_cb); /* Free any IOBs */ @@ -334,7 +333,7 @@ int ipfwd_forward(FAR struct forward_s *fwd) /* Set up the callback in the connection */ - fwd->f_cb = devif_callback_alloc(fwd->f_dev, NULL); + fwd->f_cb = ipfwd_callback_alloc(fwd->f_dev); if (fwd->f_cb != NULL) { fwd->f_cb->flags = (IPFWD_POLL | NETDEV_DOWN); diff --git a/net/ipforward/ipfwd_poll.c b/net/ipforward/ipfwd_poll.c new file mode 100644 index 00000000000..b519bf7d4fa --- /dev/null +++ b/net/ipforward/ipfwd_poll.c @@ -0,0 +1,206 @@ +/**************************************************************************** + * net/ipforward/ipfwd_poll.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +#include "devif/devif.h" +#include "ipforward/ipforward.h" + +#if defined(CONFIG_NET_IPFORWARD) && defined(CONFIG_NETDEV_MULTINIC) + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ipfwd_packet_proto + * + * Description: + * Generic output conversion hook. Only needed for IEEE802.15.4 for now + * but this is a point where support for other conversions may be + * provided. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_6LOWPAN +static int ipfwd_packet_proto(FAR struct net_driver_s *dev) +{ + FAR struct ipv6_hdr_s *ipv6; + int llhdrlen = NET_LL_HDRLEN(dev); + + /* Make sure the there is something in buffer that is at least as large as + * the IPv6_HDR. + */ + + if (dev->d_len > (IPv6_HDRLEN + llhdrlen)) + { +#ifdef CONFIG_NET_MULTILINK + /* Handle the case where multiple link layer protocols are supported */ + + if (dev->d_lltype == NET_LL_IEEE802154) +#endif + { + /* There should be an IPv6 packet in the at the beginning of the debugger */ + + ipv6 = (FAR struct ipv6_hdr_s *)&dev->d_buf[llhdrlen]; + if ((ipv6->vtc & IP_VERSION_MASK) == IPv6_VERSION) + { + /* Yes.. return the L2 protocol of the packet */ + + return ipv6->proto; + } + } + } + + return -EPROTO; +} +#endif /* CONFIG_NET_6LOWPAN */ + +/**************************************************************************** + * Name: ipfwd_packet_conversion + * + * Description: + * Generic output conversion hook. Only needed for IEEE802.15.4 for now + * but this is a point where support for other conversions may be + * provided. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_6LOWPAN +static void ipfwd_packet_conversion(FAR struct net_driver_s *dev, int proto) +{ +#ifdef CONFIG_NET_MULTILINK + /* Handle the case where multiple link layer protocols are supported */ + + if (dev->d_len > 0 && dev->d_lltype == NET_LL_IEEE802154) +#else + if (dev->d_len > 0) +#endif + { +#ifdef CONFIG_NET_TCP + if (proto == IP_PROTO_TCP) + { + /* Let 6LoWPAN convert IPv6 TCP output into IEEE802.15.4 frames. */ + + sixlowpan_tcp_send(dev, dev, ipv6); + } + else +#endif +#ifdef CONFIG_NET_UDP + if (proto == IP_PROTO_UDP) + { + /* Let 6LoWPAN convert IPv6 UDP output into IEEE802.15.4 frames. */ + + sixlowpan_udp_send(dev, dev, ipv6); + } + else +#endif +#ifdef CONFIG_NET_ICMPv6 + if (proto == IP_PROTO_ICMP6) + { + /* Let 6LoWPAN convert IPv6 UDP output into IEEE802.15.4 frames. */ + + sixlowpan_icmpv6_send(dev, dev, ipv6); + } + else +#endif + { + nwarn("WARNING: Non-TCP packet dropped. Packet type: %u\n", proto); + } + + dev->d_len = 0; + } +} +#endif /* CONFIG_NET_6LOWPAN */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: ipfwd_poll + * + * Description: + * Poll all pending transfer for ARP requests to send. + * + * Assumptions: + * This function is called from the MAC device driver indirectly through + * devif_poll() and devif_timer(). + * + ****************************************************************************/ + +void ipfwd_poll(FAR struct net_driver_s *dev) +{ + uint16_t flags; + + /* Setup for the callback (most of these do not apply) */ + + dev->d_appdata = NULL; + dev->d_len = 0; + dev->d_sndlen = 0; + + /* Perform the forwarding callbacks. Returns the new set of flags. If + * the packet was fowarded, then the new set will be zero. + */ + + flags = devif_conn_event(dev, NULL, IPFWD_POLL, dev->d_conncb); + +#ifdef CONFIG_NET_6LOWPAN + if ((flags & DEVPOLL_MASK) == 0) + { + /* Get the L2 protocol of packet in the device's d_buf */ + + int proto = ipfwd_packet_proto(dev); + if (proto >= 0) + { + /* Perform any necessary conversions on the forwarded packet */ + + ipfwd_packet_conversion(dev, proto); + } + } +#else + UNUSED(flags); +#endif +} + +#endif /* CONFIG_NET_ARP_SEND && CONFIG_NETDEV_MULTINIC */ diff --git a/net/ipforward/ipv6_forward.c b/net/ipforward/ipv6_forward.c index b76a219d81c..6e84caa0b2a 100644 --- a/net/ipforward/ipv6_forward.c +++ b/net/ipforward/ipv6_forward.c @@ -271,6 +271,36 @@ static int ipv6_packet_conversion(FAR struct net_driver_s *dev, } else #endif + +#ifdef CONFIG_NET_ICMPv6 + if (ipv6->proto == IP_PROTO_ICMP6) + { + /* Decrement the TTL in the IPv6 header. If it decrements to + * zero, then drop the packet. + */ + + ret = ipv6_decr_ttl(ipv6); + if (ret < 1) + { + nwarn("WARNING: Hop limit exceeded... Dropping!\n"); + ret = -EMULTIHOP; + } + else + { + /* Let 6LoWPAN convert IPv6 ICMPv6 output into IEEE802.15.4 + * frames. + */ + + sixlowpan_icmpv6_send(dev, fwddev, ipv6); + + /* The packet was forwarded */ + + dev->d_len = 0; + return PACKET_FORWARDED; + } + } + else +#endif { /* Otherwise, we cannot forward the packet */ diff --git a/net/netdev/netdev_ioctl.c b/net/netdev/netdev_ioctl.c index 0d6c1ed49b0..4868c6674bb 100644 --- a/net/netdev/netdev_ioctl.c +++ b/net/netdev/netdev_ioctl.c @@ -145,7 +145,7 @@ static int ioctl_add_ipv4route(FAR struct rtentry *rtentry) #endif /* CONFIG_NET_ROUTE && CONFIG_NET_IPv4 */ /**************************************************************************** - * Name: ioctl_addipv6route + * Name: ioctl_add_ipv6route * * Description: * Add an IPv6 route to the routing table. @@ -156,7 +156,7 @@ static int ioctl_add_ipv4route(FAR struct rtentry *rtentry) ****************************************************************************/ #if defined(CONFIG_NET_ROUTE) && defined(CONFIG_NET_IPv6) -static int ioctl_add_ipv4route(FAR struct rtentry *rtentry) +static int ioctl_add_ipv6route(FAR struct rtentry *rtentry) { FAR struct sockaddr_in6 *target; FAR struct sockaddr_in6 *netmask; @@ -1145,7 +1145,7 @@ static int netdev_rt_ioctl(FAR struct socket *psock, int cmd, else #endif { - ret = ioctl_addipv6route(rtentry); + ret = ioctl_add_ipv6route(rtentry); } #endif /* CONFIG_NET_IPv6 */ } diff --git a/net/procfs/netdev_statistics.c b/net/procfs/netdev_statistics.c index 610670d25af..729a4fd5446 100644 --- a/net/procfs/netdev_statistics.c +++ b/net/procfs/netdev_statistics.c @@ -290,7 +290,13 @@ static int netprocfs_inet4addresses(FAR struct netprocfs_file_s *netfile) addr.s_addr = dev->d_netmask; len += snprintf(&netfile->line[len], NET_LINELEN - len, - "Mask:%s\n\n", inet_ntoa(addr)); +#ifdef CONFIG_NET_IPv6 + "Mask:%s\n", /* IPv6 addresses will follow */ +#else + "Mask:%s\n\n", /* Double space at end of device description */ +#endif + inet_ntoa(addr)); + return len; } #endif @@ -319,7 +325,7 @@ static int netprocfs_inet6address(FAR struct netprocfs_file_s *netfile) if (inet_ntop(AF_INET6, dev->d_ipv6addr, addrstr, INET6_ADDRSTRLEN)) { len += snprintf(&netfile->line[len], NET_LINELEN - len, - "\tinet6 addr:%s/%d\n", addrstr, preflen); + "\tinet6 addr: %s/%d\n", addrstr, preflen); } return len; @@ -351,7 +357,7 @@ static int netprocfs_inet6draddress(FAR struct netprocfs_file_s *netfile) if (inet_ntop(AF_INET6, dev->d_ipv6draddr, addrstr, INET6_ADDRSTRLEN)) { len += snprintf(&netfile->line[len], NET_LINELEN - len, - "\tinet6 DRaddr:%s/%d\n\n", addrstr, preflen); + "\tinet6 DRaddr: %s/%d\n\n", addrstr, preflen); } return len; diff --git a/net/route/net_addroute.c b/net/route/net_addroute.c index 28496ebe196..498c37b0371 100644 --- a/net/route/net_addroute.c +++ b/net/route/net_addroute.c @@ -84,7 +84,7 @@ int net_addroute(in_addr_t target, in_addr_t netmask, in_addr_t router) return -ENOMEM; } - /* Format the new route table entry */ + /* Format the new routing table entry */ net_ipv4addr_copy(route->target, target); net_ipv4addr_copy(route->netmask, netmask); @@ -116,7 +116,7 @@ int net_addroute_ipv6(net_ipv6addr_t target, net_ipv6addr_t netmask, net_ipv6add return -ENOMEM; } - /* Format the new route table entry */ + /* Format the new routing table entry */ net_ipv6addr_copy(route->target, target); net_ipv6addr_copy(route->netmask, netmask); diff --git a/net/route/net_allocroute.c b/net/route/net_allocroute.c index edb08d24b51..919e5c2f21b 100644 --- a/net/route/net_allocroute.c +++ b/net/route/net_allocroute.c @@ -152,7 +152,7 @@ void net_initroute(void) * None * * Returned Value: - * On success, a pointer to the newly allocated route table entry is + * On success, a pointer to the newly allocated routing table entry is * returned; NULL is returned on failure. * ****************************************************************************/ diff --git a/net/route/net_foreachroute.c b/net/route/net_foreachroute.c index f386088ce41..5100e09beb0 100644 --- a/net/route/net_foreachroute.c +++ b/net/route/net_foreachroute.c @@ -58,9 +58,11 @@ * Name: net_foreachroute * * Description: - * Traverse the route table + * Traverse the routing table * * Parameters: + * handler - Will be called for each route in the routing table. + * arg - An arbitrary value that will be passed tot he handler. * * Returned Value: * 0 if in use; 1 if avaialble and the new entry was added diff --git a/net/route/route.h b/net/route/route.h index 460b9dfd0cb..22baca8c8cd 100644 --- a/net/route/route.h +++ b/net/route/route.h @@ -105,6 +105,7 @@ extern "C" #endif /* This is the routing table */ + #ifdef CONFIG_NET_IPv4 EXTERN sq_queue_t g_routes; #endif @@ -143,7 +144,7 @@ void net_initroute(void); * None * * Returned Value: - * On success, a pointer to the newly allocated route table entry is + * On success, a pointer to the newly allocated routing table entry is * returned; NULL is returned on failure. * ****************************************************************************/ @@ -327,7 +328,7 @@ void netdev_ipv6_router(FAR struct net_driver_s *dev, * Name: net_foreachroute * * Description: - * Traverse the route table + * Traverse the routing table * * Parameters: * diff --git a/net/sixlowpan/Make.defs b/net/sixlowpan/Make.defs index 749d8216562..25cdc8bdd83 100644 --- a/net/sixlowpan/Make.defs +++ b/net/sixlowpan/Make.defs @@ -47,7 +47,17 @@ NET_CSRCS += sixlowpan_tcpsend.c endif ifeq ($(CONFIG_NET_UDP),y) -NET_CSRCS += sixlowpan_udpsend.c sixlowpan_send.c +NET_CSRCS += sixlowpan_udpsend.c +endif + +ifeq ($(CONFIG_NET_ICMPv6),y) +NET_CSRCS += sixlowpan_icmpv6send.c +endif + +ifeq ($(CONFIG_NET_UDP),y) +NET_CSRCS += sixlowpan_send.c +else ifeq ($(CONFIG_NET_ICMPv6),y) +NET_CSRCS += sixlowpan_send.c endif ifeq ($(CONFIG_NET_6LOWPAN_COMPRESSION_HC1),y) diff --git a/net/sixlowpan/sixlowpan.h b/net/sixlowpan/sixlowpan.h index aad911597a0..e1041992241 100644 --- a/net/sixlowpan/sixlowpan.h +++ b/net/sixlowpan/sixlowpan.h @@ -147,6 +147,41 @@ void sixlowpan_tcp_send(FAR struct net_driver_s *dev, FAR struct net_driver_s *fwddev, FAR struct ipv6_hdr_s *ipv6); +/**************************************************************************** + * Name: sixlowpan_icmpv6_send + * + * Description: + * All outgoing ICMPv6 messages come through one of two mechanisms: + * + * 1. The output from internal ICMPv6 message passing. These outgoing + * messages will use device polling. + * 2. ICMPv6 output resulting from TX or timer polling. + * + * Both cases are handled here. + * + * Parameters: + * dev - The network device containing the packet to be sent. + * fwddev - The network device used to send the data. This will be the + * same device except for the IP forwarding case where packets + * are sent across devices. + * ipv6 - A pointer to the IPv6 header in dev->d_buf which lies AFTER + * the L1 header. NOTE: dev->d_len must have been decremented + * by the size of any preceding MAC header. + * + * Returned Value: + * None + * + * Assumptions: + * Called with the network locked. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_ICMPv6 +void sixlowpan_icmpv6_send(FAR struct net_driver_s *dev, + FAR struct net_driver_s *fwddev, + FAR struct ipv6_hdr_s *ipv6); +#endif + /**************************************************************************** * Name: psock_6lowpan_udp_send * diff --git a/net/sixlowpan/sixlowpan_framelist.c b/net/sixlowpan/sixlowpan_framelist.c index c15b968909f..17532457943 100644 --- a/net/sixlowpan/sixlowpan_framelist.c +++ b/net/sixlowpan/sixlowpan_framelist.c @@ -212,7 +212,7 @@ static uint16_t sixlowpan_protosize(FAR const struct ipv6_hdr_s *ipv6hdr, * * Input Parameters: * ieee - The IEEE802.15.4 MAC driver instance - * ipv6hdr - IPv6 header followed by TCP, UDP, or ICMPv6 header. + * ipv6 - IPv6 header followed by TCP, UDP, or ICMPv6 header. * buf - Beginning of the packet packet to send (with IPv6 + protocol * headers) * buflen - Length of data to send (include IPv6 and protocol headers) @@ -230,7 +230,7 @@ static uint16_t sixlowpan_protosize(FAR const struct ipv6_hdr_s *ipv6hdr, ****************************************************************************/ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, - FAR const struct ipv6_hdr_s *destip, + FAR const struct ipv6_hdr_s *ipv6, FAR const void *buf, size_t buflen, FAR const struct sixlowpan_tagaddr_s *destmac) { @@ -266,10 +266,10 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, /* Set stream mode for all TCP packets, except FIN packets. */ #if 0 /* Currently the frame type is always data */ - if (destip->proto == IP_PROTO_TCP) + if (ipv6->proto == IP_PROTO_TCP) { FAR const struct tcp_hdr_s *tcp = - &((FAR const struct ipv6tcp_hdr_s *)destip)->tcp; + &((FAR const struct ipv6tcp_hdr_s *)ipv6)->tcp; if ((tcp->flags & TCP_FIN) == 0 && (tcp->flags & TCP_CTL) != TCP_ACK) @@ -379,9 +379,9 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, /* Try to compress the headers */ #if defined(CONFIG_NET_6LOWPAN_COMPRESSION_HC1) - ret = sixlowpan_compresshdr_hc1(ieee, destip, destmac, fptr); + ret = sixlowpan_compresshdr_hc1(ieee, ipv6, destmac, fptr); #elif defined(CONFIG_NET_6LOWPAN_COMPRESSION_HC06) - ret = sixlowpan_compresshdr_hc06(ieee, destip, destmac, fptr); + ret = sixlowpan_compresshdr_hc06(ieee, ipv6, destmac, fptr); #else # error No compression specified #endif @@ -391,14 +391,14 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, { /* Small.. use IPv6 dispatch (no compression) */ - ret = sixlowpan_compress_ipv6hdr(destip, fptr); + ret = sixlowpan_compress_ipv6hdr(ipv6, fptr); } /* Get the size of any uncompressed protocol headers */ if (ret == COMPRESS_HDR_INLINE) { - protosize = sixlowpan_protosize(destip, fptr); + protosize = sixlowpan_protosize(ipv6, fptr); } ninfo("Header of length=%u protosize=%u\n", g_frame_hdrlen, protosize); @@ -465,7 +465,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, if (protosize > 0) { - FAR uint8_t *src = (FAR uint8_t *)destip + IPv6_HDRLEN; + FAR uint8_t *src = (FAR uint8_t *)ipv6 + IPv6_HDRLEN; memcpy(fptr + g_frame_hdrlen, src, protosize); } @@ -625,7 +625,7 @@ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, if (protosize > 0) { - FAR uint8_t *src = (FAR uint8_t *)destip + IPv6_HDRLEN; + FAR uint8_t *src = (FAR uint8_t *)ipv6 + IPv6_HDRLEN; memcpy(fptr + g_frame_hdrlen, src, protosize); } diff --git a/net/sixlowpan/sixlowpan_icmpv6send.c b/net/sixlowpan/sixlowpan_icmpv6send.c new file mode 100644 index 00000000000..c8a06203a6e --- /dev/null +++ b/net/sixlowpan/sixlowpan_icmpv6send.c @@ -0,0 +1,161 @@ +/**************************************************************************** + * net/sixlowpan/sixlowpan_icmpv6send.c + * + * Copyright (C) 2017 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include + +#include "icmpv6/icmpv6.h" +#include "sixlowpan/sixlowpan_internal.h" +#include "sixlowpan/sixlowpan.h" + +#if defined(CONFIG_NET_6LOWPAN) && defined(CONFIG_NET_ICMPv6) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: sixlowpan_icmpv6_send + * + * Description: + * Handles forwarding a ICMPv6 packet via 6LoWPAN. This is currently only + * used by the IPv6 forwarding logic. + * + * Parameters: + * dev - An instance of nework device state structure + * fwddev - The network device used to send the data. This will be the + * same device except for the IP forwarding case where packets + * are sent across devices. + * ipv6 - A pointer to the IPv6 header in dev->d_buf which lies AFTER + * the L1 header. NOTE: dev->d_len must have been decremented + * by the size of any preceding MAC header. + * + * Returned Value: + * None + * + * Assumptions: + * Called with the network locked. + * + ****************************************************************************/ + +#ifdef CONFIG_NET_IPFORWARD +void sixlowpan_icmpv6_send(FAR struct net_driver_s *dev, + FAR struct net_driver_s *fwddev, + FAR struct ipv6_hdr_s *ipv6) +{ + FAR struct ipv6icmp_hdr_s *ipv6icmpv6 = (FAR struct ipv6icmp_hdr_s *)ipv6; + + /* Double check */ + + DEBUGASSERT(dev != NULL && dev->d_len > 0); + + ninfo("d_len %u\n", dev->d_len); + + if (dev != NULL && dev->d_len > 0) + { + sixlowpan_dumpbuffer("Outgoing ICMPv6 packet", + (FAR const uint8_t *)ipv6icmpv6, dev->d_len); + + /* The ICMPv6 data payload should follow the IPv6 header plus the + * protocol header. + */ + + if (ipv6icmpv6->ipv6.proto != IP_PROTO_ICMPv6) + { + nwarn("WARNING: Expected ICMPv6 protoype: %u vs %s\n", + ipv6icmpv6->ipv6.proto, IP_PROTO_ICMPv6); + } + else + { + struct sixlowpan_tagaddr_s destmac; + FAR uint8_t *buf; + uint16_t hdrlen; + uint16_t buflen; + int ret; + + /* Get the IEEE 802.15.4 MAC address of the destination. This + * assumes an encoding of the MAC address in the IPv6 address. + */ + + ret = sixlowpan_destaddrfromip((FAR struct ieee802154_driver_s *)dev, + ipv6icmpv6->ipv6.destipaddr, &destmac); + if (ret < 0) + { + nerr("ERROR: Failed to dest MAC address: %d\n", ret); + goto drop; + } + + /* Get the IPv6 + ICMPv6 combined header length. NOTE: This header + * size includes only the common 32-bit header at the beginning of + * each ICMPv6 message. + */ + + hdrlen = IPv6_HDRLEN + ICMPv6_HDRLEN; + + /* Drop the packet if the buffer length is less than this. */ + + if (hdrlen > dev->d_len) + { + nwarn("WARNING: Dropping small ICMPv6 packet: %u < %u\n", + buflen, hdrlen); + } + else + { + /* Convert the outgoing packet into a frame list. */ + + buf = (FAR uint8_t *)ipv6 + hdrlen; + buflen = dev->d_len - hdrlen; + + (void)sixlowpan_queue_frames( + (FAR struct ieee802154_driver_s *)fwddev, + &ipv6icmpv6->ipv6, buf, buflen, &destmac); + } + } + } + +drop: + dev->d_len = 0; +} +#endif + +#endif /* CONFIG_NET_6LOWPAN && CONFIG_NET_ICMPv6 */ diff --git a/net/sixlowpan/sixlowpan_internal.h b/net/sixlowpan/sixlowpan_internal.h index ccc7e04a5a8..4fac3812ad6 100644 --- a/net/sixlowpan/sixlowpan_internal.h +++ b/net/sixlowpan/sixlowpan_internal.h @@ -356,7 +356,7 @@ int sixlowpan_frame_submit(FAR struct ieee802154_driver_s *ieee, * * Input Parameters: * ieee - The IEEE802.15.4 MAC driver instance - * ipv6hdr - IPv6 header followed by TCP or UDP header. + * ipv6 - IPv6 header followed by TCP or UDP header. * buf - Beginning of the packet packet to send (with IPv6 + protocol * headers) * buflen - Length of data to send (include IPv6 and protocol headers) @@ -374,7 +374,7 @@ int sixlowpan_frame_submit(FAR struct ieee802154_driver_s *ieee, ****************************************************************************/ int sixlowpan_queue_frames(FAR struct ieee802154_driver_s *ieee, - FAR const struct ipv6_hdr_s *ipv6hdr, + FAR const struct ipv6_hdr_s *ipv6, FAR const void *buf, size_t buflen, FAR const struct sixlowpan_tagaddr_s *destmac);