SAM4E-EK: Add an EMAC driver. Initial commit is just a quick port of the SAMA5D3 EMAC driver
This commit is contained in:
parent
5a0100aef4
commit
1a2845a4ef
@ -349,6 +349,8 @@ config SAM34_EMAC
|
||||
bool "Ethernet MAC (EMAC)"
|
||||
default n
|
||||
depends on ARCH_CHIP_SAM3X || ARCH_CHIP_SAM3A || ARCH_CHIP_SAM4E
|
||||
select NETDEVICES
|
||||
select ARCH_HAVE_PHY
|
||||
|
||||
config SAM34_FREQM
|
||||
bool "Frequency Meter (FREQM)"
|
||||
@ -688,7 +690,7 @@ config SAM34_RC32K
|
||||
endmenu # AT91SAM3/4 Clock Configuration
|
||||
endif # ARCH_CHIP_SAM4L
|
||||
|
||||
menu "External Memory Configuration"
|
||||
menu "AT91SAM3/4 External Memory Configuration"
|
||||
|
||||
config ARCH_HAVE_EXTNAND
|
||||
bool
|
||||
@ -830,7 +832,7 @@ config SAM34_EXTSRAM1HEAP
|
||||
endif # SAM34_EXTSRAM1
|
||||
endmenu # External Memory Configuration
|
||||
|
||||
comment "AT91SAM3/4 GPIO Interrupt Configuration"
|
||||
menu "AT91SAM3/4 GPIO Interrupt Configuration"
|
||||
|
||||
config GPIO_IRQ
|
||||
bool "GPIO pin interrupts"
|
||||
@ -867,6 +869,218 @@ config GPIOF_IRQ
|
||||
depends on ARCH_CHIP_SAM3X || ARCH_CHIP_SAM3A
|
||||
|
||||
endif # GPIO_IRQ
|
||||
endmenu # AT91SAM3/4 GPIO Interrupt Configuration
|
||||
|
||||
if SAM34_EMAC
|
||||
|
||||
menu "AT91SAM3/4 EMAC device driver options"
|
||||
|
||||
config SAM34_EMAC_NRXBUFFERS
|
||||
int "Number of RX buffers"
|
||||
default 16
|
||||
---help---
|
||||
EMAC buffer memory is segmented into 128 byte units (not
|
||||
configurable). This setting provides the number of such 128 byte
|
||||
units used for reception. This is also equal to the number of RX
|
||||
descriptors that will be allocated The selected value must be an
|
||||
even power of 2.
|
||||
|
||||
config SAM34_EMAC_NTXBUFFERS
|
||||
int "Number of TX buffers"
|
||||
default 8
|
||||
---help---
|
||||
EMAC buffer memory is segmented into full Ethernet packets (size
|
||||
NET_BUFSIZE bytes). This setting provides the number of such packets
|
||||
that can be in flight. This is also equal to the number of TX
|
||||
descriptors that will be allocated.
|
||||
|
||||
config SAM34_EMAC_PREALLOCATE
|
||||
bool "Preallocate buffers"
|
||||
default n
|
||||
---help---
|
||||
Buffer an descriptor many may either be allocated from the memory
|
||||
pool or pre-allocated to lie in .bss. This options selected pre-
|
||||
allocated buffer memory.
|
||||
|
||||
config SAM34_EMAC_NBC
|
||||
bool "Disable Broadcast"
|
||||
default n
|
||||
---help---
|
||||
Select to disable receipt of broadcast packets.
|
||||
|
||||
config SAM34_EMAC_PHYADDR
|
||||
int "PHY address"
|
||||
default 1
|
||||
---help---
|
||||
The 5-bit address of the PHY on the board. Default: 1
|
||||
|
||||
config SAM34_EMAC_PHYINIT
|
||||
bool "Board-specific PHY Initialization"
|
||||
default n
|
||||
---help---
|
||||
Some boards require specialized initialization of the PHY before it can be used.
|
||||
This may include such things as configuring GPIOs, resetting the PHY, etc. If
|
||||
SAM34_EMAC_PHYINIT is defined in the configuration then the board specific logic must
|
||||
provide sam_phyinitialize(); The SAM34 EMAC driver will call this function
|
||||
one time before it first uses the PHY.
|
||||
|
||||
choice
|
||||
prompt "PHY interface"
|
||||
default SAM34_EMAC_MII
|
||||
|
||||
config SAM34_EMAC_MII
|
||||
bool "MII"
|
||||
---help---
|
||||
Support Ethernet MII interface (vs RMII).
|
||||
|
||||
config SAM34_EMAC_RMII
|
||||
bool "RMII"
|
||||
depends on !ARCH_CHIP_SAM4E
|
||||
---help---
|
||||
Support Ethernet RMII interface (vs MII).
|
||||
|
||||
endchoice # PHY interface
|
||||
|
||||
config SAM34_EMAC_CLAUSE45
|
||||
bool "Clause 45 MII"
|
||||
depends on SAM34_EMAC_MII
|
||||
---help---
|
||||
MDIO was originally defined in Clause 22 of IEEE RFC802.3. In the
|
||||
original specification, a single MDIO interface is able to access up
|
||||
to 32 registers in 32 different PHY devices. To meet the needs the
|
||||
expanding needs of 10-Gigabit Ethernet devices, Clause 45 of the
|
||||
802.3ae specification provided the following additions to MDIO:
|
||||
|
||||
- Ability to access 65,536 registers in 32 different devices on
|
||||
32 different ports
|
||||
- Additional OP-code and ST-code for Indirect Address register
|
||||
access for 10 Gigabit Ethernet
|
||||
- End-to-end fault signaling
|
||||
- Multiple loopback points
|
||||
- Low voltage electrical specification
|
||||
|
||||
By default, Clause 22 PHYs will be supported unless this option is
|
||||
selected.
|
||||
|
||||
config SAM34_EMAC_AUTONEG
|
||||
bool "Use autonegotiation"
|
||||
default y
|
||||
---help---
|
||||
Use PHY autonegotiation to determine speed and mode
|
||||
|
||||
config SAM34_EMAC_ETHFD
|
||||
bool "Full duplex"
|
||||
default n
|
||||
depends on !SAM34_EMAC_AUTONEG
|
||||
---help---
|
||||
If SAM34_EMAC_AUTONEG is not defined, then this may be defined to select full duplex
|
||||
mode. Default: half-duplex
|
||||
|
||||
config SAM34_EMAC_ETH100MBPS
|
||||
bool "100 Mbps"
|
||||
default n
|
||||
depends on !SAM34_EMAC_AUTONEG
|
||||
---help---
|
||||
If SAM34_EMAC_AUTONEG is not defined, then this may be defined to select 100 MBps
|
||||
speed. Default: 10 Mbps
|
||||
|
||||
config SAM34_EMAC_PHYSR
|
||||
int "PHY Status Register Address (decimal)"
|
||||
depends on SAM34_EMAC_AUTONEG
|
||||
---help---
|
||||
This must be provided if SAM34_EMAC_AUTONEG is defined. The PHY status register
|
||||
address may diff from PHY to PHY. This configuration sets the address of
|
||||
the PHY status register.
|
||||
|
||||
config SAM34_EMAC_PHYSR_ALTCONFIG
|
||||
bool "PHY Status Alternate Bit Layout"
|
||||
default n
|
||||
depends on SAM34_EMAC_AUTONEG
|
||||
---help---
|
||||
Different PHYs present speed and mode information in different ways. Some
|
||||
will present separate information for speed and mode (this is the default).
|
||||
Those PHYs, for example, may provide a 10/100 Mbps indication and a separate
|
||||
full/half duplex indication. This options selects an alternative representation
|
||||
where speed and mode information are combined. This might mean, for example,
|
||||
separate bits for 10HD, 100HD, 10FD and 100FD.
|
||||
|
||||
config SAM34_EMAC_PHYSR_SPEED
|
||||
hex "PHY Speed Mask"
|
||||
depends on SAM34_EMAC_AUTONEG && !SAM34_EMAC_PHYSR_ALTCONFIG
|
||||
---help---
|
||||
This must be provided if SAM34_EMAC_AUTONEG is defined. This provides bit mask
|
||||
for isolating the 10 or 100MBps speed indication.
|
||||
|
||||
config SAM34_EMAC_PHYSR_100MBPS
|
||||
hex "PHY 100Mbps Speed Value"
|
||||
depends on SAM34_EMAC_AUTONEG && !SAM34_EMAC_PHYSR_ALTCONFIG
|
||||
---help---
|
||||
This must be provided if SAM34_EMAC_AUTONEG is defined. This provides the value
|
||||
of the speed bit(s) indicating 100MBps speed.
|
||||
|
||||
config SAM34_EMAC_PHYSR_MODE
|
||||
hex "PHY Mode Mask"
|
||||
depends on SAM34_EMAC_AUTONEG && !SAM34_EMAC_PHYSR_ALTCONFIG
|
||||
---help---
|
||||
This must be provided if SAM34_EMAC_AUTONEG is defined. This provide bit mask
|
||||
for isolating the full or half duplex mode bits.
|
||||
|
||||
config SAM34_EMAC_PHYSR_FULLDUPLEX
|
||||
hex "PHY Full Duplex Mode Value"
|
||||
depends on SAM34_EMAC_AUTONEG && !SAM34_EMAC_PHYSR_ALTCONFIG
|
||||
---help---
|
||||
This must be provided if SAM34_EMAC_AUTONEG is defined. This provides the
|
||||
value of the mode bits indicating full duplex mode.
|
||||
|
||||
config SAM34_EMAC_PHYSR_ALTMODE
|
||||
hex "PHY Mode Mask"
|
||||
depends on SAM34_EMAC_AUTONEG && SAM34_EMAC_PHYSR_ALTCONFIG
|
||||
---help---
|
||||
This must be provided if SAM34_EMAC_AUTONEG is defined. This provide bit mask
|
||||
for isolating the speed and full/half duplex mode bits.
|
||||
|
||||
config SAM34_EMAC_PHYSR_10HD
|
||||
hex "10MBase-T Half Duplex Value"
|
||||
depends on SAM34_EMAC_AUTONEG && SAM34_EMAC_PHYSR_ALTCONFIG
|
||||
---help---
|
||||
This must be provided if SAM34_EMAC_AUTONEG is defined. This is the value
|
||||
under the bit mask that represents the 10Mbps, half duplex setting.
|
||||
|
||||
config SAM34_EMAC_PHYSR_100HD
|
||||
hex "100Base-T Half Duplex Value"
|
||||
depends on SAM34_EMAC_AUTONEG && SAM34_EMAC_PHYSR_ALTCONFIG
|
||||
---help---
|
||||
This must be provided if SAM34_EMAC_AUTONEG is defined. This is the value
|
||||
under the bit mask that represents the 100Mbps, half duplex setting.
|
||||
|
||||
config SAM34_EMAC_PHYSR_10FD
|
||||
hex "10Base-T Full Duplex Value"
|
||||
depends on SAM34_EMAC_AUTONEG && SAM34_EMAC_PHYSR_ALTCONFIG
|
||||
---help---
|
||||
This must be provided if SAM34_EMAC_AUTONEG is defined. This is the value
|
||||
under the bit mask that represents the 10Mbps, full duplex setting.
|
||||
|
||||
config SAM34_EMAC_PHYSR_100FD
|
||||
hex "100Base-T Full Duplex Value"
|
||||
depends on SAM34_EMAC_AUTONEG && SAM34_EMAC_PHYSR_ALTCONFIG
|
||||
---help---
|
||||
This must be provided if SAM34_EMAC_AUTONEG is defined. This is the value
|
||||
under the bit mask that represents the 100Mbps, full duplex setting.
|
||||
|
||||
config SAM34_EMAC_REGDEBUG
|
||||
bool "Register-Level Debug"
|
||||
default n
|
||||
depends on DEBUG
|
||||
---help---
|
||||
Enable very low-level register access debug. Depends on DEBUG.
|
||||
|
||||
config SAM34_EMAC_ISETH0
|
||||
bool
|
||||
default y if !SAM34_EMAC || !SAM34_GMAC_ISETH0
|
||||
default n if SAM34_EMAC && SAM34_GMAC_ISETH0
|
||||
|
||||
endmenu # EMAC device driver options
|
||||
endif # SAM34_EMAC
|
||||
|
||||
if SAM34_WDT
|
||||
comment "AT91SAM3/4 Watchdog Configuration"|
|
||||
|
@ -104,6 +104,10 @@ ifeq ($(CONFIG_SAM34_PDCA),y)
|
||||
CHIP_CSRCS += sam4l_pdca.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SAM34_EMAC),y)
|
||||
CHIP_CSRCS += sam_emac.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SAM34_HSMCI),y)
|
||||
CHIP_CSRCS += sam_hsmci.c
|
||||
endif
|
||||
|
@ -52,8 +52,8 @@
|
||||
|
||||
#define sam_enableperiph0(s) putreg32((1 << (s)), SAM_PMC_PCER0)
|
||||
#define sam_enableperiph1(s) putreg32((1 << ((s) - 32)), SAM_PMC_PCER1)
|
||||
#define sam_disableperiph0(s) putreg32((1 << (s)), SAM_PMC_PDER0)
|
||||
#define sam_disableperiph1(s) putreg32((1 << ((s) - 32)), SAM_PMC_PDER1)
|
||||
#define sam_disableperiph0(s) putreg32((1 << (s)), SAM_PMC_PCDR0)
|
||||
#define sam_disableperiph1(s) putreg32((1 << ((s) - 32)), SAM_PMC_PCDR1)
|
||||
|
||||
#define sam_supc_enableclk() sam_enableperiph0(SAM_PID_SUPC)
|
||||
#define sam_rstc_enableclk() sam_enableperiph0(SAM_PID_RSTC)
|
||||
|
@ -125,5 +125,12 @@ void sam_cmcc_invalidateall(void);
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#else /* CONFIG_SAM34_CMCC */
|
||||
|
||||
/* Stubs so that we don't have to put condition compilation in driver source */
|
||||
|
||||
# define sam_cmcc_invalidate(start, end)
|
||||
# define sam_cmcc_invalidateall()
|
||||
|
||||
#endif /* CONFIG_SAM34_CMCC */
|
||||
#endif /* __ARCH_ARM_SRC_SAM34_SAM_CMCC_H */
|
||||
|
2917
arch/arm/src/sam34/sam_emac.c
Normal file
2917
arch/arm/src/sam34/sam_emac.c
Normal file
File diff suppressed because it is too large
Load Diff
120
arch/arm/src/sam34/sam_emac.h
Normal file
120
arch/arm/src/sam34/sam_emac.h
Normal file
@ -0,0 +1,120 @@
|
||||
/************************************************************************************
|
||||
* arch/arm/src/sam34/sam_ethernet.h
|
||||
*
|
||||
* Copyright (C) 2014 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.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_SAM34_SAM_ETHERNET_H
|
||||
#define __ARCH_ARM_SRC_SAM34_SAM_ETHERNET_H
|
||||
|
||||
/************************************************************************************
|
||||
* Included Files
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "chip/sam_emac.h"
|
||||
|
||||
#ifdef CONFIG_SAM34_EMAC
|
||||
|
||||
/************************************************************************************
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/************************************************************************************
|
||||
* Public Functions
|
||||
************************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: up_netinitialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the EMAC driver. Also prototyped in up_internal.h.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; Negated errno on failure.
|
||||
*
|
||||
* Assumptions:
|
||||
* Called very early in the initialization sequence.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void up_netinitialize(void);
|
||||
|
||||
/************************************************************************************
|
||||
* Function: sam_phy_boardinitialize
|
||||
*
|
||||
* Description:
|
||||
* Some boards require specialized initialization of the PHY before it can be used.
|
||||
* This may include such things as configuring GPIOs, resetting the PHY, etc. If
|
||||
* CONFIG_SAM34_PHYINIT is defined in the configuration then the board specific
|
||||
* logic must provide sam_phyinitialize(); The SAM34 Ethernet driver will call
|
||||
* this function one time before it first uses the PHY.
|
||||
*
|
||||
* Parameters:
|
||||
* intf - Always zero for now.
|
||||
*
|
||||
* Returned Value:
|
||||
* OK on success; Negated errno on failure.
|
||||
*
|
||||
* Assumptions:
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SAM34_PHYINIT
|
||||
int sam_phy_boardinitialize(int intf);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_SAM34_EMAC */
|
||||
#endif /* __ARCH_ARM_SRC_SAM34_SAM_ETHERNET_H */
|
||||
|
@ -1,12 +1,12 @@
|
||||
README
|
||||
^^^^^^
|
||||
======
|
||||
|
||||
This README discusses issues unique to NuttX configurations for the Atmel
|
||||
SAM4E-EK development. This board features the SAM4E16 MCU running at 96
|
||||
or 120MHz.
|
||||
|
||||
Contents
|
||||
^^^^^^^^
|
||||
========
|
||||
|
||||
- Development Environment
|
||||
- GNU Toolchain Options
|
||||
@ -19,11 +19,12 @@ Contents
|
||||
- Writing to FLASH using SAM-BA
|
||||
- LEDs
|
||||
- Serial Console
|
||||
- Networking Support
|
||||
- SAM4E-EK-specific Configuration Options
|
||||
- Configurations
|
||||
|
||||
Development Environment
|
||||
^^^^^^^^^^^^^^^^^^^^^^^
|
||||
=======================
|
||||
|
||||
Either Linux or Cygwin on Windows can be used for the development environment.
|
||||
The source has been built only using the GNU toolchain (see below). Other
|
||||
@ -31,7 +32,7 @@ Development Environment
|
||||
environment.
|
||||
|
||||
GNU Toolchain Options
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
=====================
|
||||
|
||||
The NuttX make system can be configured to support the various different
|
||||
toolchain options. All testing has been conducted using the NuttX buildroot
|
||||
@ -86,7 +87,7 @@ GNU Toolchain Options
|
||||
MKDEP = $(TOPDIR)/tools/mknulldeps.sh
|
||||
|
||||
IDEs
|
||||
^^^^
|
||||
====
|
||||
|
||||
NuttX is built using command-line make. It can be used with an IDE, but some
|
||||
effort will be required to create the project (There is a simple RIDE project
|
||||
@ -119,7 +120,7 @@ IDEs
|
||||
startup object needed by RIDE.
|
||||
|
||||
NuttX EABI "buildroot" Toolchain
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
================================
|
||||
|
||||
A GNU GCC-based toolchain is assumed. The files */setenv.sh should
|
||||
be modified to point to the correct path to the Cortex-M3 GCC toolchain (if
|
||||
@ -162,7 +163,7 @@ NuttX EABI "buildroot" Toolchain
|
||||
See instructions below.
|
||||
|
||||
NuttX OABI "buildroot" Toolchain
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
================================
|
||||
|
||||
The older, OABI buildroot toolchain is also available. To use the OABI
|
||||
toolchain:
|
||||
@ -181,7 +182,7 @@ NuttX OABI "buildroot" Toolchain
|
||||
-NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
|
||||
|
||||
NXFLAT Toolchain
|
||||
^^^^^^^^^^^^^^^^
|
||||
================
|
||||
|
||||
If you are *not* using the NuttX buildroot toolchain and you want to use
|
||||
the NXFLAT tools, then you will still have to build a portion of the buildroot
|
||||
@ -214,7 +215,7 @@ NXFLAT Toolchain
|
||||
the path to the newly builtNXFLAT binaries.
|
||||
|
||||
Atmel Studio 6.1
|
||||
^^^^^^^^^^^^^^^^
|
||||
================
|
||||
|
||||
You can use Atmel Studio 6.1 to load and debug code.
|
||||
|
||||
@ -247,7 +248,7 @@ Atmel Studio 6.1
|
||||
not readable. A little more needs to be done to wring out this procedure.
|
||||
|
||||
Loading Code into SRAM with J-Link
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
==================================
|
||||
|
||||
Loading code with the Segger tools and GDB
|
||||
------------------------------------------
|
||||
@ -277,7 +278,7 @@ Loading Code into SRAM with J-Link
|
||||
debugging after writing the program to FLASH using SAM-BA.
|
||||
|
||||
Writing to FLASH using SAM-BA
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
=============================
|
||||
|
||||
Assumed starting configuration:
|
||||
|
||||
@ -296,7 +297,7 @@ Writing to FLASH using SAM-BA
|
||||
STATUS: Works great!
|
||||
|
||||
LEDs
|
||||
^^^^
|
||||
====
|
||||
|
||||
The SAM4E-EK board has three, user-controllable LEDs labelled D2 (blue),
|
||||
D3 (amber), and D4 (green) on the board. Usage of these LEDs is defined
|
||||
@ -321,7 +322,7 @@ LEDs
|
||||
*** D4 may also flicker normally if signals are processed.
|
||||
|
||||
Serial Console
|
||||
^^^^^^^^^^^^^^
|
||||
==============
|
||||
|
||||
By default, all of these configurations use UART0 for the NuttX serial
|
||||
console. UART0 corresponds to the DB-9 connector J17 labelled "DBGU".
|
||||
@ -342,8 +343,153 @@ Serial Console
|
||||
By default serial console is configured for 115000, 8-bit, 1 stop bit, and
|
||||
no parity.
|
||||
|
||||
Networking
|
||||
==========
|
||||
|
||||
Networking support via the can be added to NSH by selecting the following
|
||||
configuration options.
|
||||
|
||||
Selecting the EMAC peripheral
|
||||
-----------------------------
|
||||
|
||||
System Type -> SAM34 Peripheral Support
|
||||
CONFIG_SAM34_EMAC=y : Enable the EMAC peripheral
|
||||
|
||||
System Type -> EMAC device driver options
|
||||
CONFIG_SAM34_EMAC_NRXBUFFERS=16 : Set aside some RS and TX buffers
|
||||
CONFIG_SAM34_EMAC_NTXBUFFERS=4
|
||||
CONFIG_SAM34_EMAC_PHYADDR=1 : KSZ8051 PHY is at address 1
|
||||
CONFIG_SAM34_EMAC_AUTONEG=y : Use autonegotiation
|
||||
CONFIG_SAM34_EMAC_MII=y : Only the MII interface is supported
|
||||
CONFIG_SAM34_EMAC_PHYSR=30 : Address of PHY status register on KSZ8051
|
||||
CONFIG_SAM34_EMAC_PHYSR_ALTCONFIG=y : Needed for KSZ8051
|
||||
CONFIG_SAM34_EMAC_PHYSR_ALTMODE=0x7 : " " " " " "
|
||||
CONFIG_SAM34_EMAC_PHYSR_10HD=0x1 : " " " " " "
|
||||
CONFIG_SAM34_EMAC_PHYSR_100HD=0x2 : " " " " " "
|
||||
CONFIG_SAM34_EMAC_PHYSR_10FD=0x5 : " " " " " "
|
||||
CONFIG_SAM34_EMAC_PHYSR_100FD=0x6 : " " " " " "
|
||||
|
||||
PHY selection. Later in the configuration steps, you will need to select
|
||||
the KSZ8051 PHY for EMAC (See below)
|
||||
|
||||
Networking Support
|
||||
CONFIG_NET=y : Enable Neworking
|
||||
CONFIG_NET_SOCKOPTS=y : Enable socket operations
|
||||
CONFIG_NET_BUFSIZE=562 : Maximum packet size (MTD) 1518 is more standard
|
||||
CONFIG_NET_RECEIVE_WINDOW=536 : Should be the same as CONFIG_NET_BUFSIZE
|
||||
CONFIG_NET_TCP=y : Enable TCP/IP networking
|
||||
CONFIG_NET_TCPBACKLOG=y : Support TCP/IP backlog
|
||||
CONFIG_NET_TCP_READAHEAD_BUFSIZE=536 Read-ahead buffer size
|
||||
CONFIG_NET_UDP=y : Enable UDP networking
|
||||
CONFIG_NET_BROADCAST=y : Needed for DNS name resolution
|
||||
CONFIG_NET_ICMP=y : Enable ICMP networking
|
||||
CONFIG_NET_ICMP_PING=y : Needed for NSH ping command
|
||||
: Defaults should be okay for other options
|
||||
Device drivers -> Network Device/PHY Support
|
||||
CONFIG_NETDEVICES=y : Enabled PHY selection
|
||||
CONFIG_ETH0_PHY_KSZ8051=y : Select the KSZ8051 PHY (for EMAC)
|
||||
|
||||
Application Configuration -> Network Utilities
|
||||
CONFIG_NETUTILS_RESOLV=y : Enable host address resolution
|
||||
CONFIG_NETUTILS_TELNETD=y : Enable the Telnet daemon
|
||||
CONFIG_NETUTILS_TFTPC=y : Enable TFTP data file transfers for get and put commands
|
||||
CONFIG_NETUTILS_UIPLIB=y : Network library support is needed
|
||||
CONFIG_NETUTILS_WEBCLIENT=y : Needed for wget support
|
||||
: Defaults should be okay for other options
|
||||
Application Configuration -> NSH Library
|
||||
CONFIG_NSH_TELNET=y : Enable NSH session via Telnet
|
||||
CONFIG_NSH_IPADDR=0x0a000002 : Select an IP address
|
||||
CONFIG_NSH_DRIPADDR=0x0a000001 : IP address of gateway/host PC
|
||||
CONFIG_NSH_NETMASK=0xffffff00 : Netmask
|
||||
CONFIG_NSH_NOMAC=y : Need to make up a bogus MAC address
|
||||
: Defaults should be okay for other options
|
||||
|
||||
Using the network with NSH
|
||||
--------------------------
|
||||
|
||||
So what can you do with this networking support? First you see that
|
||||
NSH has several new network related commands:
|
||||
|
||||
ifconfig, ifdown, ifup: Commands to help manage your network
|
||||
get and put: TFTP file transfers
|
||||
wget: HTML file transfers
|
||||
ping: Check for access to peers on the network
|
||||
Telnet console: You can access the NSH remotely via telnet.
|
||||
|
||||
You can also enable other add on features like full FTP or a Web
|
||||
Server or XML RPC and others. There are also other features that
|
||||
you can enable like DHCP client (or server) or network name
|
||||
resolution.
|
||||
|
||||
By default, the IP address of the SAM4E-EK will be 10.0.0.2 and
|
||||
it will assume that your host is the gateway and has the IP address
|
||||
10.0.0.1.
|
||||
|
||||
nsh> ifconfig
|
||||
eth0 HWaddr 00:e0:de:ad:be:ef at UP
|
||||
IPaddr:10.0.0.2 DRaddr:10.0.0.1 Mask:255.255.255.0
|
||||
|
||||
You can use ping to test for connectivity to the host (Careful,
|
||||
Window firewalls usually block ping-related ICMP traffic). On the
|
||||
target side, you can:
|
||||
|
||||
nsh> ping 10.0.0.1
|
||||
PING 10.0.0.1 56 bytes of data
|
||||
56 bytes from 10.0.0.1: icmp_seq=1 time=0 ms
|
||||
56 bytes from 10.0.0.1: icmp_seq=2 time=0 ms
|
||||
56 bytes from 10.0.0.1: icmp_seq=3 time=0 ms
|
||||
56 bytes from 10.0.0.1: icmp_seq=4 time=0 ms
|
||||
56 bytes from 10.0.0.1: icmp_seq=5 time=0 ms
|
||||
56 bytes from 10.0.0.1: icmp_seq=6 time=0 ms
|
||||
56 bytes from 10.0.0.1: icmp_seq=7 time=0 ms
|
||||
56 bytes from 10.0.0.1: icmp_seq=8 time=0 ms
|
||||
56 bytes from 10.0.0.1: icmp_seq=9 time=0 ms
|
||||
56 bytes from 10.0.0.1: icmp_seq=10 time=0 ms
|
||||
10 packets transmitted, 10 received, 0% packet loss, time 10100 ms
|
||||
|
||||
NOTE: In this configuration is is normal to have packet loss > 0%
|
||||
the first time you ping due to the default handling of the ARP
|
||||
table.
|
||||
|
||||
On the host side, you should also be able to ping the SAM4E-EK:
|
||||
|
||||
$ ping 10.0.0.2
|
||||
|
||||
You can also log into the NSH from the host PC like this:
|
||||
|
||||
$ telnet 10.0.0.2
|
||||
Trying 10.0.0.2...
|
||||
Connected to 10.0.0.2.
|
||||
Escape character is '^]'.
|
||||
sh_telnetmain: Session [3] Started
|
||||
|
||||
NuttShell (NSH) NuttX-6.31
|
||||
nsh> help
|
||||
help usage: help [-v] [<cmd>]
|
||||
|
||||
[ echo ifconfig mkdir mw sleep
|
||||
? exec ifdown mkfatfs ping test
|
||||
cat exit ifup mkfifo ps umount
|
||||
cp free kill mkrd put usleep
|
||||
cmp get losetup mh rm wget
|
||||
dd help ls mount rmdir xd
|
||||
df hexdump mb mv sh
|
||||
|
||||
Builtin Apps:
|
||||
nsh>
|
||||
|
||||
NOTE: If you enable this feature, you experience a delay on booting.
|
||||
That is because the start-up logic waits for the network connection
|
||||
to be established before starting NuttX. In a real application, you
|
||||
would probably want to do the network bringup on a separate thread
|
||||
so that access to the NSH prompt is not delayed.
|
||||
|
||||
This delay will be especially long if the board is not connected to
|
||||
a network.
|
||||
|
||||
|
||||
SAM4E-EK-specific Configuration Options
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
=======================================
|
||||
|
||||
CONFIG_ARCH - Identifies the arch/ subdirectory. This should
|
||||
be set to:
|
||||
@ -504,7 +650,7 @@ SAM4E-EK-specific Configuration Options
|
||||
support a 320x240 "Landscape" orientation.
|
||||
|
||||
Configurations
|
||||
^^^^^^^^^^^^^^
|
||||
==============
|
||||
|
||||
Information Common to All Configurations
|
||||
----------------------------------------
|
||||
|
@ -133,7 +133,7 @@ config NET_MAX_LISTENPORTS
|
||||
Maximum number of listening TCP/IP ports (all tasks). Default: 20
|
||||
|
||||
config NET_TCP_READAHEAD
|
||||
bool "Enabled TCP/IP read-ahead buffering"
|
||||
bool "Enable TCP/IP read-ahead buffering"
|
||||
default y
|
||||
---help---
|
||||
Read-ahead buffers allows buffering of TCP/IP packets when there is no
|
||||
@ -179,7 +179,7 @@ config NET_NTCP_READAHEAD_BUFFERS
|
||||
endif # NET_TCP_READAHEAD
|
||||
|
||||
config NET_TCP_WRITE_BUFFERS
|
||||
bool "Enabled TCP/IP write buffering"
|
||||
bool "Enable TCP/IP write buffering"
|
||||
default n
|
||||
---help---
|
||||
Write buffers allows buffering of ongoing TCP/IP packets, providing
|
||||
|
Loading…
x
Reference in New Issue
Block a user