mirror of
https://github.com/apache/nuttx.git
synced 2026-05-24 16:11:56 +08:00
Merge remote-tracking branch 'origin/master' into beacon802154
This commit is contained in:
@@ -13,6 +13,7 @@ core
|
||||
/.config
|
||||
/.config.old
|
||||
/.version
|
||||
/defconfig
|
||||
/Make.defs
|
||||
/nuttx
|
||||
/nuttx.*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<tr align="center" bgcolor="#e4e4e4">
|
||||
<td>
|
||||
<h1><big><font color="#3c34ec"><i>NuttX RTOS</i></font></big></h1>
|
||||
<p>Last Updated: June 5, 2017</p>
|
||||
<p>Last Updated: July 8, 2017</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@@ -796,6 +796,14 @@
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
<p>
|
||||
<li>IP Forwarding.</li>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><br></td>
|
||||
<td>
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+93
-19
@@ -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:
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,149 @@
|
||||
/************************************************************************************
|
||||
* configs/b-l475e-iot01a/include/board.h
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Simon Piriou <spiriou31@gmail.com>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#include <stm32l4.h>
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Clocking *************************************************************************/
|
||||
|
||||
#include <arch/board/b-l475e-iot01a_clock.h>
|
||||
|
||||
/* 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 */
|
||||
@@ -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
|
||||
File diff suppressed because it is too large
Load Diff
@@ -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) }
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
/.depend
|
||||
/Make.dep
|
||||
@@ -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
|
||||
@@ -0,0 +1,88 @@
|
||||
/****************************************************************************
|
||||
* configs/b-l475e-iot01a/src/b-l475e-iot01a.h
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Simon Piriou <spiriou31@gmail.com>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#include <nuttx/compiler.h>
|
||||
#include <arch/stm32l4/chip.h>
|
||||
|
||||
/****************************************************************************
|
||||
* 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 */
|
||||
@@ -0,0 +1,90 @@
|
||||
/****************************************************************************
|
||||
* config/b-l475e-iot01a/src/stm32_appinit.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#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 */
|
||||
@@ -0,0 +1,116 @@
|
||||
/****************************************************************************
|
||||
* configs/b-l475e-iot01a/src/stm32_autoleds.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#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 */
|
||||
@@ -0,0 +1,91 @@
|
||||
/************************************************************************************
|
||||
* configs/b-l475e-iot01a/src/stm32_boot.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Simon Piriou <spiriou31@gmail.com>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#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 */
|
||||
@@ -0,0 +1,101 @@
|
||||
/****************************************************************************
|
||||
* config/b-l475e-iot01a/src/stm32_bringup.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Simon Piriou <spiriou31@gmail.com>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mount.h>
|
||||
#include <syslog.h>
|
||||
|
||||
#include <nuttx/input/buttons.h>
|
||||
#include <nuttx/leds/userled.h>
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
|
||||
#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;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
/****************************************************************************
|
||||
* configs/b-l475e-iot01a/src/stm32_userleds.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Simon Piriou <spiriou31@gmail.com>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <arch/board/board.h>
|
||||
#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 */
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-4
@@ -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 */
|
||||
|
||||
@@ -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:
|
||||
|
||||
+27
-9
@@ -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 */
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#if defined(CONFIG_NET)
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include <debug.h>
|
||||
#include <assert.h>
|
||||
@@ -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
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <assert.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/mm/iob.h>
|
||||
#include <nuttx/net/netdev.h>
|
||||
|
||||
#include "ipforward/ipforward.h"
|
||||
|
||||
+68
-25
@@ -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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
+34
-2
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -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)
|
||||
|
||||
+21
-67
@@ -44,16 +44,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <nuttx/net/ip.h>
|
||||
#include <nuttx/net/udp.h>
|
||||
#include <nuttx/net/tcp.h>
|
||||
#include <nuttx/net/icmp.h>
|
||||
#include <nuttx/net/icmpv6.h>
|
||||
|
||||
#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 */
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -44,10 +44,37 @@
|
||||
#include <errno.h>
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/tcp.h>
|
||||
#include <nuttx/net/udp.h>
|
||||
#include <nuttx/net/icmp.h>
|
||||
#include <nuttx/net/icmpv6.h>
|
||||
|
||||
#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 */
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
/****************************************************************************
|
||||
* net/ipforward/ipfwd_poll.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
|
||||
#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 */
|
||||
@@ -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 */
|
||||
|
||||
|
||||
@@ -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 */
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@@ -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
|
||||
|
||||
+3
-2
@@ -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:
|
||||
*
|
||||
|
||||
+11
-1
@@ -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)
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
/****************************************************************************
|
||||
* net/sixlowpan/sixlowpan_icmpv6send.c
|
||||
*
|
||||
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* 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 <nuttx/config.h>
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#include <nuttx/net/netdev.h>
|
||||
#include <nuttx/net/ip.h>
|
||||
|
||||
#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 */
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user