mirror of
https://github.com/apache/nuttx.git
synced 2026-06-08 01:42:58 +08:00
Merged nuttx/nuttx into master
This commit is contained in:
@@ -937,6 +937,7 @@ o Network (net/, drivers/net)
|
||||
LM3S NO NO
|
||||
TM4C YES YES
|
||||
eZ80 NO NO
|
||||
Kinetis YES YES (not tested)
|
||||
LPC17xx YES YES (not tested)
|
||||
LPC43xx YES YES (not tested)
|
||||
DMxxx NIC NO NO
|
||||
|
||||
@@ -548,18 +548,27 @@ config KINETIS_ENETNTXBUFFERS
|
||||
Number of Ethernet Tx buffers to use. The size of one buffer is
|
||||
determined by NET_BUFSIZE
|
||||
|
||||
config KINETIS_ENETPHYADDR
|
||||
int "PHY address"
|
||||
default 1
|
||||
---help---
|
||||
MII/RMII address of the PHY
|
||||
|
||||
config KINETIS_ENETUSEMII
|
||||
bool "Use MII interface"
|
||||
default n
|
||||
---help---
|
||||
The the MII PHY interface. Default: Use RMII interface
|
||||
|
||||
config KINETIS_ENET_MDIOPULLUP
|
||||
bool "MDIO pull-up"
|
||||
default n
|
||||
---help---
|
||||
If there is no on-board pull-up resister on the MII/RMII MDIO line,
|
||||
then this option may be selected in order to configure an internal
|
||||
pull-up on MDIO.
|
||||
|
||||
config KINETIS_ENET_NORXER
|
||||
bool "Suppress RXER"
|
||||
default n
|
||||
---help---
|
||||
If selected, then the MII/RMII RXER output will be configured as a
|
||||
GPIO and pulled low.
|
||||
|
||||
endmenu # Kinetis Ethernet Configuration
|
||||
|
||||
menu "Kinetis SDHC Configuration"
|
||||
|
||||
@@ -83,12 +83,12 @@
|
||||
#define PIN_FTM0_CH1_1 (PIN_ALT3 | PIN_PORTA | PIN4)
|
||||
#define PIN_NMI (PIN_ALT7 | PIN_PORTA | PIN4)
|
||||
#define PIN_FTM0_CH2_1 (PIN_ALT3 | PIN_PORTA | PIN5)
|
||||
#if 0
|
||||
#ifdef CONFIG_KINETIS_ENET_NORXER
|
||||
# define PIN_RMII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
# define PIN_MII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
#else
|
||||
# define PIN_RMII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
# define PIN_MII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
#else
|
||||
# define PIN_RMII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
# define PIN_MII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
#endif
|
||||
#define PIN_CMP2_OUT_1 (PIN_ALT5 | PIN_PORTA | PIN5)
|
||||
#define PIN_I2S0_RX_BCLK_1 (PIN_ALT6 | PIN_PORTA | PIN5)
|
||||
@@ -174,7 +174,11 @@
|
||||
#define PIN_TSI0_CH0 (PIN_ANALOG | PIN_PORTB | PIN0)
|
||||
#define PIN_I2C0_SCL_1 (PIN_ALT2 | PIN_PORTB | PIN0)
|
||||
#define PIN_FTM1_CH0_3 (PIN_ALT3 | PIN_PORTB | PIN0)
|
||||
#define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#ifdef CONFIG_KINETIS_ENET_MDIOPULLUP
|
||||
# define PIN_RMII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0)
|
||||
#else
|
||||
# define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#endif
|
||||
#define PIN_MII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#define PIN_FTM1_QD_PHA_3 (PIN_ALT6 | PIN_PORTB | PIN0)
|
||||
#define PIN_ADC0_SE9 (PIN_ANALOG | PIN_PORTB | PIN1)
|
||||
|
||||
@@ -398,14 +398,22 @@
|
||||
#define PIN_MII0_COL (PIN_ALT4 | PIN_PORTA | PIN29)
|
||||
#define PIN_MII0_CRS (PIN_ALT4 | PIN_PORTA | PIN27)
|
||||
#define PIN_MII0_MDC (PIN_ALT4 | PIN_PORTB | PIN1)
|
||||
#define PIN_MII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#ifdef CONFIG_KINETIS_ENET_MDIOPULLUP
|
||||
# define PIN_MII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0)
|
||||
#else
|
||||
# define PIN_MII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#endif
|
||||
#define PIN_MII0_RXCLK (PIN_ALT4 | PIN_PORTA | PIN11)
|
||||
#define PIN_MII0_RXD0 (PIN_ALT4 | PIN_PORTA | PIN13)
|
||||
#define PIN_MII0_RXD1 (PIN_ALT4 | PIN_PORTA | PIN12)
|
||||
#define PIN_MII0_RXD2 (PIN_ALT4 | PIN_PORTA | PIN10)
|
||||
#define PIN_MII0_RXD3 (PIN_ALT4 | PIN_PORTA | PIN9)
|
||||
#define PIN_MII0_RXDV (PIN_ALT4 | PIN_PORTA | PIN14)
|
||||
#define PIN_MII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
#ifdef CONFIG_KINETIS_ENET_NORXER
|
||||
# define PIN_MII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
#else
|
||||
# define PIN_MII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
#endif
|
||||
#define PIN_MII0_TXCLK (PIN_ALT4 | PIN_PORTA | PIN25)
|
||||
#define PIN_MII0_TXD0 (PIN_ALT4 | PIN_PORTA | PIN16)
|
||||
#define PIN_MII0_TXD1 (PIN_ALT4 | PIN_PORTA | PIN17)
|
||||
@@ -427,10 +435,18 @@
|
||||
|
||||
#define PIN_RMII0_CRS_DV (PIN_ALT4 | PIN_PORTA | PIN14)
|
||||
#define PIN_RMII0_MDC (PIN_ALT4 | PIN_PORTB | PIN1)
|
||||
#define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#ifdef CONFIG_KINETIS_ENET_MDIOPULLUP
|
||||
# define PIN_RMII0_MDIO (PIN_ALT4_PULLUP | PIN_PORTB | PIN0)
|
||||
#else
|
||||
# define PIN_RMII0_MDIO (PIN_ALT4 | PIN_PORTB | PIN0)
|
||||
#endif
|
||||
#define PIN_RMII0_RXD0 (PIN_ALT4 | PIN_PORTA | PIN13)
|
||||
#define PIN_RMII0_RXD1 (PIN_ALT4 | PIN_PORTA | PIN12)
|
||||
#define PIN_RMII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
#ifdef CONFIG_KINETIS_ENET_NORXER
|
||||
# define PIN_RMII0_RXER (GPIO_PULLDOWN | PIN_PORTA | PIN5)
|
||||
#else
|
||||
# define PIN_RMII0_RXER (PIN_ALT4 | PIN_PORTA | PIN5)
|
||||
#endif
|
||||
#define PIN_RMII0_TXD0 (PIN_ALT4 | PIN_PORTA | PIN16)
|
||||
#define PIN_RMII0_TXD1 (PIN_ALT4 | PIN_PORTA | PIN17)
|
||||
#define PIN_RMII0_TXEN (PIN_ALT4 | PIN_PORTA | PIN15)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+302
-30
@@ -10,7 +10,7 @@ Contents
|
||||
o Freedom K64F Features
|
||||
o Serial Console
|
||||
o LEDs and Buttons
|
||||
o Ethernet
|
||||
o Networking Support
|
||||
o Development Environment
|
||||
o GNU Toolchain Options
|
||||
o Freedom K64F Configuration Options
|
||||
@@ -129,40 +129,286 @@ LEDs and Buttons
|
||||
SW2 PTC6/SPI0_SOUT/PD0_EXTRG/I2S0_RX_BCLK/FB_AD9/I2S0_MCLK/LLWU_P10
|
||||
SW3 PTA4/FTM0_CH1/NMI_b/LLWU_P3
|
||||
|
||||
Ethernet
|
||||
========
|
||||
Networking Support
|
||||
==================
|
||||
|
||||
Ethernet MAC/KSZ8081 PHY
|
||||
------------------------
|
||||
------------ ----------------- --------------------------------------------
|
||||
KSZ8081 Board Signal(s) K64F Pin
|
||||
Pin Signal Function
|
||||
Pin Signal Function pinmux Name
|
||||
--- -------- ----------------- --------------------------------------------
|
||||
1 VDD_1V2 VDDPLL_1.2V ---
|
||||
2 VDDA_3V3 VDDA_ENET ---
|
||||
3 RXM ENET1_RX- ---
|
||||
4 RXP ENET1_RX+ ---
|
||||
5 TXM ENET1_TX- ---
|
||||
6 TXP ENET1_TX+ ---
|
||||
7 X0 RMII_XTAL0 ---
|
||||
8 XI RMII_XTAL1 ---
|
||||
9 REXT --- ---, Apparently not connected
|
||||
10 MDIO RMII0_MDIO PTB0/RMII0_MDIO
|
||||
11 MDC RMII0_MDC PTB1/RMII0_MDC
|
||||
12 RXD1 RMII0_RXD_1 PTA12/RMII0_RXD1
|
||||
13 RXD0 RMII0_RXD_0 PTA13/RMII0_RXD0
|
||||
14 VDDIO VDDIO_ENET ---
|
||||
15 CRS_DIV PTA14/RMII0_CRS_DV
|
||||
16 REF_CLK RMII_RXCLK PTA18/EXTAL0, PHY clock input
|
||||
17 RXER RMII0_RXER PTA5/RMII0_RXER
|
||||
18 INTRP RMII0_INT_B, J14 Pin 2, Apparently not available unless jumpered
|
||||
PHY_INT_1
|
||||
19 TXEN RMII0_TXEN PTA15/RMII0_TXEN
|
||||
20 TXD0 RMII0_TXD_0 PTA16/RMII0_TXD0
|
||||
21 TXD1 RMII0_TXD_1 PTA17/RMII0_TXD1
|
||||
22 GND1 --- ---
|
||||
24 nRST PHY_RST_B ---
|
||||
25 GND2 --- ---
|
||||
1 VDD_1V2 VDDPLL_1.2V --- ---
|
||||
2 VDDA_3V3 VDDA_ENET --- ---
|
||||
3 RXM ENET1_RX- --- ---
|
||||
4 RXP ENET1_RX+ --- ---
|
||||
5 TXM ENET1_TX- --- ---
|
||||
6 TXP ENET1_TX+ --- ---
|
||||
7 X0 RMII_XTAL0 --- ---
|
||||
8 XI RMII_XTAL1 --- ---
|
||||
9 REXT --- ---, Apparently not connected ---
|
||||
10 MDIO RMII0_MDIO PTB0/RMII0_MDIO PIN_RMII0_MDIO
|
||||
11 MDC RMII0_MDC PTB1/RMII0_MDC PIN_RMII0_MDC
|
||||
12 RXD1 RMII0_RXD_1 PTA12/RMII0_RXD1 PIN_RMII0_RXD1
|
||||
13 RXD0 RMII0_RXD_0 PTA13/RMII0_RXD0 PIN_RMII0_RXD0
|
||||
14 VDDIO VDDIO_ENET --- ---
|
||||
15 CRS_DIV PTA14/RMII0_CRS_DV PIN_RMII0_CRS_DV
|
||||
16 REF_CLK RMII_RXCLK PTA18/EXTAL0, PHY clock input ---
|
||||
17 RXER RMII0_RXER PTA5/RMII0_RXER PIN_RMII0_RXER
|
||||
18 INTRP RMII0_INT_B, J14 Pin 2, Apparently not ---
|
||||
PHY_INT_1 available unless jumpered
|
||||
19 TXEN RMII0_TXEN PTA15/RMII0_TXEN PIN_RMII0_TXEN
|
||||
20 TXD0 RMII0_TXD_0 PTA16/RMII0_TXD0 PIN_RMII0_TXD0
|
||||
21 TXD1 RMII0_TXD_1 PTA17/RMII0_TXD1 PIN_RMII0_TXD1
|
||||
22 GND1 --- --- ---
|
||||
24 nRST PHY_RST_B --- ---
|
||||
25 GND2 --- --- ---
|
||||
--- -------- ----------------- --------------------------------------------
|
||||
|
||||
No external pullup is available on MDIO signal when MK64FN1M0VLL12 MCU is
|
||||
requests status of the Ethernet link connection. Internal pullup is required
|
||||
when port configuration for MDIO signal is enabled:
|
||||
|
||||
CONFIG_KINETIS_ENET_MDIOPULLUP=y
|
||||
|
||||
Networking support via the can be added to NSH by selecting the following
|
||||
configuration options.
|
||||
|
||||
Selecting the EMAC peripheral
|
||||
-----------------------------
|
||||
|
||||
System Type -> Kinetis Peripheral Support
|
||||
CONFIG_KINETIS_ENET=y : Enable the EThernet MAC peripheral
|
||||
|
||||
System Type -> Ethernet Configuration
|
||||
CONFIG_KINETIS_ENETNETHIFS=1
|
||||
CONFIG_KINETIS_ENETNRXBUFFERS=6
|
||||
CONFIG_KINETIS_ENETNTXBUFFERS=2
|
||||
CONFIG_KINETIS_ENET_MDIOPULLUP=y
|
||||
|
||||
Networking Support
|
||||
CONFIG_NET=y : Enable Neworking
|
||||
CONFIG_NET_ETHERNET=y : Support Ethernet data link
|
||||
CONFIG_NET_NOINTS=y : Should operative at non-interrupt level
|
||||
CONFIG_NET_SOCKOPTS=y : Enable socket operations
|
||||
CONFIG_NET_MULTIBUFFER=y : Multi-packet buffer option required
|
||||
CONFIG_NET_ETH_MTU=590 : Maximum packet size (MTU) 1518 is more standard
|
||||
CONFIG_NET_ETH_TCP_RECVWNDO=536 : Should be the same as CONFIG_NET_ETH_MTU
|
||||
CONFIG_NET_ARP=y : Enable ARP
|
||||
CONFIG_NET_ARPTAB_SIZE=16 : ARP table size
|
||||
CONFIG_NET_ARP_IPIN=y : Enable ARP address harvesting
|
||||
CONFIG_NET_ARP_SEND=y : Send ARP request before sending data
|
||||
CONFIG_NET_TCP=y : Enable TCP/IP networking
|
||||
CONFIG_NET_TCP_READAHEAD=y : Support TCP read-ahead
|
||||
CONFIG_NET_TCP_WRITE_BUFFERS=y : Support TCP write-buffering
|
||||
CONFIG_NET_TCPBACKLOG=y : Support TCP/IP backlog
|
||||
CONFIG_NET_MAX_LISTENPORTS=20 :
|
||||
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
|
||||
f Application Configuration -> Network Utilities
|
||||
CONFIG_NETDB_DNSCLIENT=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_NETLIB=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 a fixed 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
|
||||
|
||||
You can also enable enable the DHCPC client for networks that use
|
||||
dynamically assigned address:
|
||||
|
||||
Application Configuration -> Network Utilities
|
||||
CONFIG_NETUTILS_DHCPC=y : Enables the DHCP client
|
||||
|
||||
Networking Support
|
||||
CONFIG_NET_UDP=y : Depends on broadcast UDP
|
||||
|
||||
Application Configuration -> NSH Library
|
||||
CONFIG_NET_BROADCAST=y
|
||||
CONFIG_NSH_DHCPC=y : Tells NSH to use DHCPC, not
|
||||
: the fixed addresses
|
||||
|
||||
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 DK-TM4C129X 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 DK-TM4C129X:
|
||||
|
||||
$ 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 networking as described above, you will
|
||||
experience a delay on booting NSH. 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. On the order of minutes! You will probably think that
|
||||
NuttX has crashed! And then, when it finally does come up after
|
||||
numerous timeouts and retries, the network will not be available --
|
||||
even if the network cable is plugged in later.
|
||||
|
||||
The long delays can be eliminated by using a separate the network
|
||||
initialization thread discussed below. Recovering after the network
|
||||
becomes available requires the network monitor feature, also discussed
|
||||
below.
|
||||
|
||||
Network Initialization Thread
|
||||
-----------------------------
|
||||
There is a configuration option enabled by CONFIG_NSH_NETINIT_THREAD
|
||||
that will do the NSH network bring-up asynchronously in parallel on
|
||||
a separate thread. This eliminates the (visible) networking delay
|
||||
altogether. This current implementation, however, has some limitations:
|
||||
|
||||
- If no network is connected, the network bring-up will fail and
|
||||
the network initialization thread will simply exit. There are no
|
||||
retries and no mechanism to know if the network initialization was
|
||||
successful (it could perform a network Ioctl to see if the link is
|
||||
up and it now, keep trying, but it does not do that now).
|
||||
|
||||
- Furthermore, there is currently no support for detecting loss of
|
||||
network connection and recovery of the connection (similarly, this
|
||||
thread could poll periodically for network status, but does not).
|
||||
|
||||
Both of these shortcomings could be eliminated by enabling the network
|
||||
monitor:
|
||||
|
||||
Network Monitor
|
||||
---------------
|
||||
By default the network initialization thread will bring-up the network
|
||||
then exit, freeing all of the resources that it required. This is a
|
||||
good behavior for systems with limited memory.
|
||||
|
||||
If the CONFIG_NSH_NETINIT_MONITOR option is selected, however, then the
|
||||
network initialization thread will persist forever; it will monitor the
|
||||
network status. In the event that the network goes down (for example, if
|
||||
a cable is removed), then the thread will monitor the link status and
|
||||
attempt to bring the network back up. In this case the resources
|
||||
required for network initialization are never released.
|
||||
|
||||
Pre-requisites:
|
||||
|
||||
- CONFIG_NSH_NETINIT_THREAD as described above.
|
||||
|
||||
- The K64F EMAC block does not support PHY interrupts. The KSZ8081
|
||||
PHY interrupt line is brought to a jumper block and it should be
|
||||
possible to connect that some some interrupt port pin. You would
|
||||
need to provide some custom logic in the Freedcom K64F
|
||||
configuration to set up that PHY interrupt.
|
||||
|
||||
- In addtion to the PHY interrupt, the Network Monitor also requires the
|
||||
following setting:
|
||||
|
||||
CONFIG_NETDEV_PHY_IOCTL. Enable PHY IOCTL commands in the Ethernet
|
||||
device driver. Special IOCTL commands must be provided by the Ethernet
|
||||
driver to support certain PHY operations that will be needed for link
|
||||
management. There operations are not complex and are implemented for
|
||||
the Atmel SAMA5 family.
|
||||
|
||||
CONFIG_ARCH_PHY_INTERRUPT. This is not a user selectable option.
|
||||
Rather, it is set when you select a board that supports PHY
|
||||
interrupts. For the K64F, like most other architectures, the PHY
|
||||
interrupt must be provided via some board-specific GPIO. In any
|
||||
event, the board-specific logic must provide support for the PHY
|
||||
interrupt. To do this, the board logic must do two things: (1) It
|
||||
must provide the function arch_phy_irq() as described and prototyped
|
||||
in the nuttx/include/nuttx/arch.h, and (2) it must select
|
||||
CONFIG_ARCH_PHY_INTERRUPT in the board configuration file to
|
||||
advertise that it supports arch_phy_irq().
|
||||
|
||||
And a few other things: UDP support is required (CONFIG_NET_UDP) and
|
||||
signals must not be disabled (CONFIG_DISABLE_SIGNALS).
|
||||
|
||||
Given those prerequisites, the network monitor can be selected with these
|
||||
additional settings.
|
||||
|
||||
System Type -> Kinetis Ethernet Configuration
|
||||
CONFIG_ARCH_PHY_INTERRUPT=y : (auto-selected)
|
||||
CONFIG_NETDEV_PHY_IOCTL=y : (auto-selected)
|
||||
|
||||
Application Configuration -> NSH Library -> Networking Configuration
|
||||
CONFIG_NSH_NETINIT_THREAD : Enable the network initialization thread
|
||||
CONFIG_NSH_NETINIT_MONITOR=y : Enable the network monitor
|
||||
CONFIG_NSH_NETINIT_RETRYMSEC=2000 : Configure the network monitor as you like
|
||||
CONFIG_NSH_NETINIT_SIGNO=18
|
||||
|
||||
Development Environment
|
||||
=======================
|
||||
|
||||
@@ -400,6 +646,24 @@ Where <subdir> is one of the following:
|
||||
CONFIG_ARMV7M_TOOLCHAIN_GNU_EABIW=y : ARM/mbed toolcahin (arm-none-elf-gcc)
|
||||
CONFIG_INTELHEX_BINARY=y : Output formats: Intel hex binary
|
||||
|
||||
3. No external pullup is available on MDIO signal when MK64FN1M0VLL12 MCU
|
||||
is requests status of the Ethernet link connection. Internal pullup is
|
||||
required when port configuration for MDIO signal is enabled:
|
||||
|
||||
CONFIG_KINETIS_ENET_MDIOPULLUP=y
|
||||
|
||||
4. Configured to use a fixed IPv4 address:
|
||||
|
||||
CONFIG_NSH_IPADDR=0x0a000002
|
||||
CONFIG_NSH_DRIPADDR=0x0a000001
|
||||
CONFIG_NSH_NETMASK=0xffffff00
|
||||
|
||||
And a bogus MAC address:
|
||||
|
||||
CONFIG_NSH_NOMAC=y
|
||||
CONFIG_NSH_SWMAC=y
|
||||
CONFIG_NSH_MACADDR=0x00e0deadbeef
|
||||
|
||||
nsh:
|
||||
---
|
||||
Configures the NuttShell (nsh) located at apps/examples/nsh using a
|
||||
@@ -455,5 +719,13 @@ Status
|
||||
NSH configuration is working and LEDs are working. The only odd
|
||||
behavior that I see is that pressing SW3 causes an unexpected interrupt
|
||||
error.
|
||||
|
||||
2016-07-12: Added support for the KSZ8081 PHY and added the netnsh
|
||||
configuration. Untested as of this writing.
|
||||
configuration. The network is basically functional, but a lot more
|
||||
testing is needed to confirm that.
|
||||
|
||||
In testing, I notice a strange thing. If I run at full optimization the
|
||||
code runs (albeit with bugs-to-be-solved). But with no optimization or
|
||||
even at -O1, the system fails to boot. This seems to be related to the
|
||||
watchdog timer.
|
||||
|
||||
|
||||
@@ -41,8 +41,9 @@
|
||||
************************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
# include <stdint.h>
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
@@ -68,7 +69,7 @@
|
||||
*
|
||||
* PLL Input frequency: PLLIN = REFCLK / PRDIV = 50 Mhz / 20 = 2.5 MHz
|
||||
* PLL Output frequency: PLLOUT = PLLIN * VDIV = 2.5 Mhz * 48 = 120 MHz
|
||||
* MCG Frequency: PLLOUT = 96MHz
|
||||
* MCG Frequency: PLLOUT = 120 MHz
|
||||
*
|
||||
* PRDIV register value is the divider minus one. So 20 -> 19
|
||||
* VDIV regiser value is offset by 24. So 28 -> 24
|
||||
@@ -100,36 +101,37 @@
|
||||
* SDCLK frequency = (base clock) / (prescaler * divisor)
|
||||
*
|
||||
* The SDHC module is always configure configured so that the core clock is the base
|
||||
* clock.
|
||||
* clock. Possible values for presscaler and divisor are:
|
||||
*
|
||||
* SDCLKFS: {2, 4, 8, 16, 32, 63, 128, 256}
|
||||
* DVS: {1..16}
|
||||
*/
|
||||
|
||||
/* Identification mode: 400KHz = 96MHz / ( 16 * 15) */
|
||||
/* Identification mode: Optimal 400KHz, Actual 120MHz / (32 * 10) = 375 Khz */
|
||||
|
||||
#define BOARD_SDHC_IDMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16
|
||||
#define BOARD_SDHC_IDMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15)
|
||||
#define BOARD_SDHC_IDMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV32
|
||||
#define BOARD_SDHC_IDMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(10)
|
||||
|
||||
/* MMC normal mode: 16MHz = 96MHz / (2 * 3) */
|
||||
/* MMC normal mode: Optimal 20MHz, Actual 120MHz / (2 * 3) = 20 MHz */
|
||||
|
||||
#define BOARD_SDHC_MMCMODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
|
||||
#define BOARD_SDHC_MMCMODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
|
||||
|
||||
/* SD normal mode (1-bit): 16MHz = 96MHz / (2 * 3) */
|
||||
/* SD normal mode (1-bit): Optimal 20MHz, Actual 120MHz / (2 * 3) = 20 MHz */
|
||||
|
||||
#define BOARD_SDHC_SD1MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
|
||||
#define BOARD_SDHC_SD1MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
|
||||
|
||||
/* SD normal mode (4-bit): 24MHz = 96MHz / (2 * 2) (with DMA)
|
||||
* SD normal mode (4-bit): 16MHz = 96MHz / (2 * 3) (no DMA)
|
||||
/* SD normal mode (4-bit): Optimal 25MHz, Actual 120MHz / (2 * 3) = 20 MHz (with DMA)
|
||||
* SD normal mode (4-bit): Optimal 20MHz, Actual 120MHz / (2 * 3) = 20 MHz (no DMA)
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SDIO_DMA
|
||||
# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
|
||||
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(2)
|
||||
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
|
||||
#else
|
||||
//# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
|
||||
//# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
|
||||
# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV16
|
||||
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(15)
|
||||
# define BOARD_SDHC_SD4MODE_PRESCALER SDHC_SYSCTL_SDCLKFS_DIV2
|
||||
# define BOARD_SDHC_SD4MODE_DIVISOR SDHC_SYSCTL_DVS_DIV(3)
|
||||
#endif
|
||||
|
||||
/* LED definitions ******************************************************************/
|
||||
|
||||
@@ -245,8 +245,9 @@ CONFIG_KINETIS_ENET=y
|
||||
CONFIG_KINETIS_ENETNETHIFS=1
|
||||
CONFIG_KINETIS_ENETNRXBUFFERS=6
|
||||
CONFIG_KINETIS_ENETNTXBUFFERS=2
|
||||
CONFIG_KINETIS_ENETPHYADDR=1
|
||||
# CONFIG_KINETIS_ENETUSEMII is not set
|
||||
CONFIG_KINETIS_ENET_MDIOPULLUP=y
|
||||
# CONFIG_KINETIS_ENET_NORXER is not set
|
||||
|
||||
#
|
||||
# Kinetis UART Configuration
|
||||
@@ -331,7 +332,14 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y
|
||||
# Board-Specific Options
|
||||
#
|
||||
# CONFIG_BOARD_CRASHDUMP is not set
|
||||
# CONFIG_LIB_BOARDCTL is not set
|
||||
CONFIG_LIB_BOARDCTL=y
|
||||
# CONFIG_BOARDCTL_RESET is not set
|
||||
# CONFIG_BOARDCTL_UNIQUEID is not set
|
||||
# CONFIG_BOARDCTL_TSCTEST is not set
|
||||
# CONFIG_BOARDCTL_ADCTEST is not set
|
||||
# CONFIG_BOARDCTL_PWMTEST is not set
|
||||
# CONFIG_BOARDCTL_GRAPHICS is not set
|
||||
# CONFIG_BOARDCTL_IOCTL is not set
|
||||
|
||||
#
|
||||
# RTOS Features
|
||||
@@ -403,6 +411,7 @@ CONFIG_NAME_MAX=32
|
||||
# CONFIG_SCHED_STARTHOOK is not set
|
||||
# CONFIG_SCHED_ATEXIT is not set
|
||||
# CONFIG_SCHED_ONEXIT is not set
|
||||
# CONFIG_SIG_EVTHREAD is not set
|
||||
|
||||
#
|
||||
# Signal Numbers
|
||||
@@ -411,6 +420,7 @@ CONFIG_SIG_SIGUSR1=1
|
||||
CONFIG_SIG_SIGUSR2=2
|
||||
CONFIG_SIG_SIGALARM=3
|
||||
CONFIG_SIG_SIGCONDTIMEDOUT=16
|
||||
CONFIG_SIG_SIGWORK=17
|
||||
|
||||
#
|
||||
# POSIX Message Queue Options
|
||||
@@ -422,8 +432,11 @@ CONFIG_MQ_MAXMSGSIZE=32
|
||||
#
|
||||
# Work queue support
|
||||
#
|
||||
# CONFIG_SCHED_WORKQUEUE is not set
|
||||
# CONFIG_SCHED_HPWORK is not set
|
||||
CONFIG_SCHED_WORKQUEUE=y
|
||||
CONFIG_SCHED_HPWORK=y
|
||||
CONFIG_SCHED_HPWORKPRIORITY=224
|
||||
CONFIG_SCHED_HPWORKPERIOD=50000
|
||||
CONFIG_SCHED_HPWORKSTACKSIZE=2048
|
||||
# CONFIG_SCHED_LPWORK is not set
|
||||
|
||||
#
|
||||
@@ -615,7 +628,7 @@ CONFIG_SYSLOG_CONSOLE=y
|
||||
CONFIG_ARCH_HAVE_NET=y
|
||||
CONFIG_ARCH_HAVE_PHY=y
|
||||
CONFIG_NET=y
|
||||
# CONFIG_NET_NOINTS is not set
|
||||
CONFIG_NET_NOINTS=y
|
||||
# CONFIG_NET_PROMISCUOUS is not set
|
||||
|
||||
#
|
||||
@@ -759,7 +772,16 @@ CONFIG_FS_FAT=y
|
||||
# CONFIG_FS_ROMFS is not set
|
||||
# CONFIG_FS_TMPFS is not set
|
||||
# CONFIG_FS_SMARTFS is not set
|
||||
# CONFIG_FS_PROCFS is not set
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_PROCFS_REGISTER=y
|
||||
|
||||
#
|
||||
# Exclude individual procfs entries
|
||||
#
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_NET is not set
|
||||
# CONFIG_FS_UNIONFS is not set
|
||||
|
||||
#
|
||||
@@ -918,6 +940,7 @@ CONFIG_EXAMPLES_NSH=y
|
||||
# CONFIG_EXAMPLES_TOUCHSCREEN is not set
|
||||
# CONFIG_EXAMPLES_UDP is not set
|
||||
# CONFIG_EXAMPLES_UDPBLASTER is not set
|
||||
# CONFIG_EXAMPLES_USBSERIAL is not set
|
||||
# CONFIG_EXAMPLES_USBTERM is not set
|
||||
# CONFIG_EXAMPLES_WATCHDOG is not set
|
||||
# CONFIG_EXAMPLES_WEBSERVER is not set
|
||||
@@ -1057,6 +1080,7 @@ CONFIG_NSH_MMCSDMINOR=0
|
||||
CONFIG_NSH_CMDOPT_DF_H=y
|
||||
CONFIG_NSH_CODECS_BUFSIZE=128
|
||||
CONFIG_NSH_CMDOPT_HEXDUMP=y
|
||||
CONFIG_NSH_PROC_MOUNTPOINT="/proc"
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
|
||||
#
|
||||
@@ -1070,7 +1094,7 @@ CONFIG_NSH_FILEIOSIZE=512
|
||||
# Console Configuration
|
||||
#
|
||||
CONFIG_NSH_CONSOLE=y
|
||||
# CONFIG_NSH_ARCHINIT is not set
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
|
||||
#
|
||||
# Networking Configuration
|
||||
|
||||
@@ -192,6 +192,8 @@ CONFIG_ARCH_FAMILY_K64=y
|
||||
CONFIG_KINETIS_UART3=y
|
||||
# CONFIG_KINETIS_UART4 is not set
|
||||
# CONFIG_KINETIS_UART5 is not set
|
||||
# CONFIG_KINETIS_ENET is not set
|
||||
# CONFIG_KINETIS_RNGB is not set
|
||||
# CONFIG_KINETIS_FLEXCAN0 is not set
|
||||
# CONFIG_KINETIS_FLEXCAN1 is not set
|
||||
# CONFIG_KINETIS_SPI0 is not set
|
||||
@@ -312,7 +314,14 @@ CONFIG_ARCH_HAVE_IRQBUTTONS=y
|
||||
# Board-Specific Options
|
||||
#
|
||||
# CONFIG_BOARD_CRASHDUMP is not set
|
||||
# CONFIG_LIB_BOARDCTL is not set
|
||||
CONFIG_LIB_BOARDCTL=y
|
||||
# CONFIG_BOARDCTL_RESET is not set
|
||||
# CONFIG_BOARDCTL_UNIQUEID is not set
|
||||
# CONFIG_BOARDCTL_TSCTEST is not set
|
||||
# CONFIG_BOARDCTL_ADCTEST is not set
|
||||
# CONFIG_BOARDCTL_PWMTEST is not set
|
||||
# CONFIG_BOARDCTL_GRAPHICS is not set
|
||||
# CONFIG_BOARDCTL_IOCTL is not set
|
||||
|
||||
#
|
||||
# RTOS Features
|
||||
@@ -545,6 +554,7 @@ CONFIG_SYSLOG_SERIAL_CONSOLE=y
|
||||
CONFIG_SYSLOG_CONSOLE=y
|
||||
# CONFIG_SYSLOG_NONE is not set
|
||||
# CONFIG_SYSLOG_FILE is not set
|
||||
# CONFIG_SYSLOG_CHARDEV is not set
|
||||
|
||||
#
|
||||
# Networking Support
|
||||
@@ -584,7 +594,15 @@ CONFIG_FS_FAT=y
|
||||
# CONFIG_FS_ROMFS is not set
|
||||
# CONFIG_FS_TMPFS is not set
|
||||
# CONFIG_FS_SMARTFS is not set
|
||||
# CONFIG_FS_PROCFS is not set
|
||||
CONFIG_FS_PROCFS=y
|
||||
CONFIG_FS_PROCFS_REGISTER=y
|
||||
|
||||
#
|
||||
# Exclude individual procfs entries
|
||||
#
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_PROCESS is not set
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_UPTIME is not set
|
||||
# CONFIG_FS_PROCFS_EXCLUDE_MOUNTS is not set
|
||||
# CONFIG_FS_UNIONFS is not set
|
||||
|
||||
#
|
||||
@@ -730,6 +748,7 @@ CONFIG_EXAMPLES_NSH=y
|
||||
# CONFIG_EXAMPLES_TELNETD is not set
|
||||
# CONFIG_EXAMPLES_TIFF is not set
|
||||
# CONFIG_EXAMPLES_TOUCHSCREEN is not set
|
||||
# CONFIG_EXAMPLES_USBSERIAL is not set
|
||||
# CONFIG_EXAMPLES_USBTERM is not set
|
||||
# CONFIG_EXAMPLES_WATCHDOG is not set
|
||||
# CONFIG_EXAMPLES_WEBSERVER is not set
|
||||
@@ -829,7 +848,6 @@ CONFIG_NSH_DISABLE_LOSMART=y
|
||||
# CONFIG_NSH_DISABLE_MV is not set
|
||||
# CONFIG_NSH_DISABLE_MW is not set
|
||||
# CONFIG_NSH_DISABLE_PS is not set
|
||||
# CONFIG_NSH_DISABLE_PSSTACKUSAGE is not set
|
||||
# CONFIG_NSH_DISABLE_PUT is not set
|
||||
# CONFIG_NSH_DISABLE_PWD is not set
|
||||
# CONFIG_NSH_DISABLE_RM is not set
|
||||
@@ -853,6 +871,7 @@ CONFIG_NSH_MMCSDMINOR=0
|
||||
CONFIG_NSH_CMDOPT_DF_H=y
|
||||
CONFIG_NSH_CODECS_BUFSIZE=128
|
||||
CONFIG_NSH_CMDOPT_HEXDUMP=y
|
||||
CONFIG_NSH_PROC_MOUNTPOINT="/proc"
|
||||
CONFIG_NSH_FILEIOSIZE=512
|
||||
|
||||
#
|
||||
@@ -867,7 +886,7 @@ CONFIG_NSH_FILEIOSIZE=512
|
||||
#
|
||||
CONFIG_NSH_CONSOLE=y
|
||||
# CONFIG_NSH_ALTCONDEV is not set
|
||||
# CONFIG_NSH_ARCHINIT is not set
|
||||
CONFIG_NSH_ARCHINIT=y
|
||||
# CONFIG_NSH_LOGIN is not set
|
||||
# CONFIG_NSH_CONSOLE_LOGIN is not set
|
||||
|
||||
|
||||
@@ -49,6 +49,65 @@
|
||||
* Pre-processor Definitions
|
||||
************************************************************************************/
|
||||
|
||||
/* Application Configuration ********************************************************/
|
||||
|
||||
/* Assume we have everything */
|
||||
|
||||
#define HAVE_PROC 1
|
||||
#define NSH_HAVEUSBDEV 1
|
||||
#define NSH_HAVEMMCSD 1
|
||||
|
||||
/* Automount procfs */
|
||||
|
||||
#if !defined(CONFIG_FS_PROCFS)
|
||||
# undef HAVE_PROC
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_PROC) && defined(CONFIG_DISABLE_MOUNTPOINT)
|
||||
# warning Mountpoints disabled. No procfs support
|
||||
# undef HAVE_PROC
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_NSH_PROC_MOUNTPOINT)
|
||||
# define PROCFS_MOUNTPOUNT CONFIG_NSH_PROC_MOUNTPOINT
|
||||
#else
|
||||
# define PROCFS_MOUNTPOUNT "/proc"
|
||||
#endif
|
||||
|
||||
/* SD card support */
|
||||
|
||||
#define MMCSD_SLOTNO 0
|
||||
|
||||
/* Can't support MMC/SD features if mountpoints are disabled or if SDHC support
|
||||
* is not enabled.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_KINETIS_SDHC)
|
||||
# undef NSH_HAVEMMCSD
|
||||
#endif
|
||||
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0
|
||||
# error "Only one MMC/SD slot, slot 0"
|
||||
# endif
|
||||
|
||||
/* We expect to receive GPIO interrupts for card insertion events */
|
||||
|
||||
# ifndef CONFIG_GPIO_IRQ
|
||||
# error "CONFIG_GPIO_IRQ required for card detect interrupt"
|
||||
# endif
|
||||
|
||||
# ifndef CONFIG_KINETIS_PORTEINTS
|
||||
# error "CONFIG_KINETIS_PORTEINTS required for card detect interrupt"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Can't support USB features if USB is not enabled */
|
||||
|
||||
#ifndef CONFIG_USBDEV
|
||||
# undef NSH_HAVEUSBDEV
|
||||
#endif
|
||||
|
||||
/* How many SPI modules does this chip support? The LM3S6918 supports 2 SPI
|
||||
* modules (others may support more -- in such case, the following must be
|
||||
* expanded).
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <sys/mount.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
@@ -54,58 +55,6 @@
|
||||
|
||||
#if defined(CONFIG_LIB_BOARDCTL) || defined(CONFIG_BOARD_INITIALIZE)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* PORT and SLOT number probably depend on the board configuration */
|
||||
|
||||
#ifdef CONFIG_ARCH_BOARD_FREEDOM_K64F
|
||||
# define NSH_HAVEUSBDEV 1
|
||||
# define NSH_HAVEMMCSD 1
|
||||
# if defined(CONFIG_NSH_MMCSDSLOTNO) && CONFIG_NSH_MMCSDSLOTNO != 0
|
||||
# error "Only one MMC/SD slot, slot 0"
|
||||
# undef CONFIG_NSH_MMCSDSLOTNO
|
||||
# endif
|
||||
# ifndef CONFIG_NSH_MMCSDSLOTNO
|
||||
# define CONFIG_NSH_MMCSDSLOTNO 0
|
||||
# endif
|
||||
#else
|
||||
/* Add configuration for new Kinetis boards here */
|
||||
# error "Unrecognized Kinetis board"
|
||||
# undef NSH_HAVEUSBDEV
|
||||
# undef NSH_HAVEMMCSD
|
||||
#endif
|
||||
|
||||
/* Can't support USB features if USB is not enabled */
|
||||
|
||||
#ifndef CONFIG_USBDEV
|
||||
# undef NSH_HAVEUSBDEV
|
||||
#endif
|
||||
|
||||
/* Can't support MMC/SD features if mountpoints are disabled or if SDHC support
|
||||
* is not enabled.
|
||||
*/
|
||||
|
||||
#if defined(CONFIG_DISABLE_MOUNTPOINT) || !defined(CONFIG_KINETIS_SDHC)
|
||||
# undef NSH_HAVEMMCSD
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_NSH_MMCSDMINOR
|
||||
# define CONFIG_NSH_MMCSDMINOR 0
|
||||
#endif
|
||||
|
||||
/* We expect to receive GPIO interrupts for card insertion events */
|
||||
|
||||
#ifndef CONFIG_GPIO_IRQ
|
||||
# error "CONFIG_GPIO_IRQ required for card detect interrupt"
|
||||
#endif
|
||||
|
||||
#ifndef CONFIG_KINETIS_PORTEINTS
|
||||
# error "CONFIG_KINETIS_PORTEINTS required for card detect interrupt"
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@@ -199,9 +148,24 @@ static int k64_cdinterrupt(int irq, FAR void *context)
|
||||
|
||||
int k64_bringup(void)
|
||||
{
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_PROC
|
||||
/* Mount the proc filesystem */
|
||||
|
||||
syslog(LOG_INFO, "Mounting procfs to /proc\n");
|
||||
|
||||
ret = mount(NULL, PROCFS_MOUNTPOUNT, "procfs", 0, NULL);
|
||||
if (ret < 0)
|
||||
{
|
||||
syslog(LOG_ERR,
|
||||
"ERROR: Failed to mount the PROC filesystem: %d (%d)\n",
|
||||
ret, errno);
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef NSH_HAVEMMCSD
|
||||
/* Configure GPIO pins */
|
||||
|
||||
/* Attached the card detect interrupt (but don't enable it yet) */
|
||||
@@ -211,19 +175,18 @@ int k64_bringup(void)
|
||||
|
||||
/* Configure the write protect GPIO */
|
||||
|
||||
kinetis_pinconfig(GPIO_SD_WRPROTECT);
|
||||
//kinetis_pinconfig(GPIO_SD_WRPROTECT);
|
||||
|
||||
/* Mount the SDHC-based MMC/SD block driver */
|
||||
/* First, get an instance of the SDHC interface */
|
||||
|
||||
syslog(LOG_INFO, "Initializing SDHC slot %d\n",
|
||||
CONFIG_NSH_MMCSDSLOTNO);
|
||||
syslog(LOG_INFO, "Initializing SDHC slot %d\n", MMCSD_SLOTNO);
|
||||
|
||||
g_nsh.sdhc = sdhc_initialize(CONFIG_NSH_MMCSDSLOTNO);
|
||||
g_nsh.sdhc = sdhc_initialize(MMCSD_SLOTNO);
|
||||
if (!g_nsh.sdhc)
|
||||
{
|
||||
syslog(LOG_ERR, "ERROR: Failed to initialize SDHC slot %d\n",
|
||||
CONFIG_NSH_MMCSDSLOTNO);
|
||||
MMCSD_SLOTNO);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
@@ -249,6 +212,8 @@ int k64_bringup(void)
|
||||
|
||||
kinetis_pinirqenable(GPIO_SD_CARDDETECT);
|
||||
#endif
|
||||
|
||||
UNUSED(ret);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -1691,6 +1691,11 @@ static int smartfs_unlink(struct inode *mountpt, const char *relpath)
|
||||
ret = OK;
|
||||
|
||||
errout_with_semaphore:
|
||||
if (entry.name != NULL)
|
||||
{
|
||||
kmm_free(entry.name);
|
||||
}
|
||||
|
||||
smartfs_semgive(fs);
|
||||
return ret;
|
||||
}
|
||||
@@ -1856,6 +1861,11 @@ int smartfs_rmdir(struct inode *mountpt, const char *relpath)
|
||||
ret = OK;
|
||||
|
||||
errout_with_semaphore:
|
||||
if (entry.name != NULL)
|
||||
{
|
||||
kmm_free(entry.name);
|
||||
}
|
||||
|
||||
smartfs_semgive(fs);
|
||||
return ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user