mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
LM3S ethernet driver development
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1811 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -168,6 +168,7 @@ Eagle100-specific Configuration Options
|
|||||||
|
|
||||||
CONFIG_LM3S_ETHERNET - This must be set (along with CONFIG_NET)
|
CONFIG_LM3S_ETHERNET - This must be set (along with CONFIG_NET)
|
||||||
to build the LM3S Ethernet driver
|
to build the LM3S Ethernet driver
|
||||||
|
CONFIG_LM3S_ETHLEDS - Enable to use Ethernet LEDs on the board.
|
||||||
CONFIG_LM3S_BOARDMAC - If the board-specific logic can provide
|
CONFIG_LM3S_BOARDMAC - If the board-specific logic can provide
|
||||||
a MAC address (via lm3s_ethernetmac()), then this should be selected.
|
a MAC address (via lm3s_ethernetmac()), then this should be selected.
|
||||||
|
|
||||||
|
|||||||
@@ -138,6 +138,7 @@ extern void lm3s_boardinitialize(void);
|
|||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifdef CONFIG_LM3S_BOARDMAC
|
#ifdef CONFIG_LM3S_BOARDMAC
|
||||||
|
struct ether_addr;
|
||||||
extern void lm3s_ethernetmac(struct ether_addr *ethaddr);
|
extern void lm3s_ethernetmac(struct ether_addr *ethaddr);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,120 @@
|
|||||||
|
############################################################################
|
||||||
|
# configs/eagle100/nettest/Make.defs
|
||||||
|
#
|
||||||
|
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||||
|
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
CROSSDEV = arm-elf-
|
||||||
|
CC = $(CROSSDEV)gcc
|
||||||
|
CXX = $(CROSSDEV)g++
|
||||||
|
CPP = $(CROSSDEV)gcc -E
|
||||||
|
LD = $(CROSSDEV)ld
|
||||||
|
AR = $(CROSSDEV)ar rcs
|
||||||
|
NM = $(CROSSDEV)nm
|
||||||
|
OBJCOPY = $(CROSSDEV)objcopy
|
||||||
|
OBJDUMP = $(CROSSDEV)objdump
|
||||||
|
|
||||||
|
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}
|
||||||
|
|
||||||
|
ARCHCFLAGS = -fno-builtin
|
||||||
|
ARCHCXXFLAGS = -fno-builtin -fno-exceptions
|
||||||
|
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow
|
||||||
|
ARCHWARNINGSXX = -Wall -Wshadow
|
||||||
|
|
||||||
|
ifeq ("${CONFIG_DEBUG}","y")
|
||||||
|
ARCHOPTIMIZATION = -g
|
||||||
|
else
|
||||||
|
ARCHOPTIMIZATION = -Os -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
|
||||||
|
endif
|
||||||
|
|
||||||
|
ARCHCPUFLAGS = -mtune=cortex-m3 -march=armv7-m -mfloat-abi=soft
|
||||||
|
ARCHDEFINES =
|
||||||
|
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
|
||||||
|
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
|
||||||
|
|
||||||
|
ARCHPICFLAGS = -fpic
|
||||||
|
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/nettest/ld.script
|
||||||
|
|
||||||
|
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
|
||||||
|
$(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) -pipe
|
||||||
|
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) \
|
||||||
|
$(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) -pipe
|
||||||
|
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES)
|
||||||
|
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
|
||||||
|
|
||||||
|
OBJEXT = .o
|
||||||
|
LIBEXT = .a
|
||||||
|
EXEEXT =
|
||||||
|
|
||||||
|
ifeq ("${CONFIG_DEBUG}","y")
|
||||||
|
LDFLAGS += -g
|
||||||
|
endif
|
||||||
|
|
||||||
|
define PREPROCESS
|
||||||
|
@echo "CPP: $1->$2"
|
||||||
|
@$(CPP) $(CPPFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define COMPILE
|
||||||
|
@echo "CC: $1"
|
||||||
|
@$(CC) -c $(CFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define COMPILEXX
|
||||||
|
@echo "CXX: $1"
|
||||||
|
@$(CXX) -c $(CXXFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define ASSEMBLE
|
||||||
|
@echo "AS: $1"
|
||||||
|
@$(CC) -c $(AFLAGS) $1 -o $2
|
||||||
|
endef
|
||||||
|
|
||||||
|
define ARCHIVE
|
||||||
|
echo "AR: $2"; \
|
||||||
|
$(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; }
|
||||||
|
endef
|
||||||
|
|
||||||
|
define CLEAN
|
||||||
|
@rm -f *.o *.a
|
||||||
|
endef
|
||||||
|
|
||||||
|
MKDEP = $(TOPDIR)/tools/mkdeps.sh
|
||||||
|
|
||||||
|
HOSTCC = gcc
|
||||||
|
HOSTINCLUDES = -I.
|
||||||
|
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
|
||||||
|
HOSTLDFLAGS =
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,97 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* configs/eagle100/nettest/ld.script
|
||||||
|
*
|
||||||
|
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||||
|
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
*
|
||||||
|
* 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 LM3S6918 has 256Kb of FLASH beginning at address 0x0000:0000. However,
|
||||||
|
* if the the Eagle100 Ethernet bootloader is used, then the entry point must
|
||||||
|
* be at the following offset in FLASH (and the size of the FLASH must be
|
||||||
|
* reduced to 248Kb):
|
||||||
|
*/
|
||||||
|
|
||||||
|
MEMORY
|
||||||
|
{
|
||||||
|
/* flash (rx) : ORIGIN = 0x00000000, LENGTH = 256K */
|
||||||
|
flash (rx) : ORIGIN = 0x00002000, LENGTH = 248K
|
||||||
|
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
|
||||||
|
}
|
||||||
|
|
||||||
|
OUTPUT_ARCH(arm)
|
||||||
|
ENTRY(_stext)
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
.text : {
|
||||||
|
_stext = ABSOLUTE(.);
|
||||||
|
*(.vectors)
|
||||||
|
*(.text)
|
||||||
|
*(.fixup)
|
||||||
|
*(.gnu.warning)
|
||||||
|
*(.rodata)
|
||||||
|
*(.rodata.str1.1)
|
||||||
|
*(.glue_7)
|
||||||
|
*(.glue_7t)
|
||||||
|
*(.got) /* Global offset table */
|
||||||
|
_etext = ABSOLUTE(.);
|
||||||
|
} > flash
|
||||||
|
|
||||||
|
_eronly = ABSOLUTE(.); /* See below */
|
||||||
|
|
||||||
|
/* The LM3S6918 has 64Kb of SRAM beginning at the following address */
|
||||||
|
|
||||||
|
.data : {
|
||||||
|
_sdata = ABSOLUTE(.);
|
||||||
|
*(.data)
|
||||||
|
CONSTRUCTORS
|
||||||
|
_edata = ABSOLUTE(.);
|
||||||
|
} > sram AT > flash
|
||||||
|
|
||||||
|
.bss : { /* BSS */
|
||||||
|
_sbss = ABSOLUTE(.);
|
||||||
|
*(.bss)
|
||||||
|
*(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) }
|
||||||
|
}
|
||||||
Executable
+46
@@ -0,0 +1,46 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# configs/eagle100/nettest/setenv.sh
|
||||||
|
#
|
||||||
|
# Copyright (C) 2009 Gregory Nutt. All rights reserved.
|
||||||
|
# Author: Gregory Nutt <spudmonkey@racsa.co.cr>
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ "$(basename $0)" = "setenv.sh" ] ; then
|
||||||
|
echo "You must source this script, not run it!" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z ${PATH_ORIG} ]; then export PATH_ORIG=${PATH}; fi
|
||||||
|
|
||||||
|
WD=`pwd`
|
||||||
|
export BUILDROOT_BIN=${WD}/../buildroot/build_arm_nofpu/staging_dir/bin
|
||||||
|
export PATH=${BUILDROOT_BIN}:/sbin:/usr/sbin:${PATH_ORIG}
|
||||||
|
|
||||||
|
echo "PATH : ${PATH}"
|
||||||
@@ -41,6 +41,8 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
#include <net/ethernet.h>
|
#include <net/ethernet.h>
|
||||||
|
|
||||||
@@ -71,25 +73,23 @@
|
|||||||
|
|
||||||
#ifdef CONFIG_LM3S_BOARDMAC
|
#ifdef CONFIG_LM3S_BOARDMAC
|
||||||
void lm3s_ethernetmac(struct ether_addr *ethaddr)
|
void lm3s_ethernetmac(struct ether_addr *ethaddr)
|
||||||
{
|
|
||||||
struct ether_addr
|
|
||||||
{
|
{
|
||||||
uint32 user0;
|
uint32 user0;
|
||||||
uint32 user1;
|
uint32 user1;
|
||||||
|
|
||||||
/* Get the current value of the user registers */
|
/* Get the current value of the user registers */
|
||||||
|
|
||||||
user0 = getreg32();
|
user0 = getreg32(LM3S_FLASH_USERREG0);
|
||||||
user1 = getreg32();
|
user1 = getreg32(LM3S_FLASH_USERREG1);
|
||||||
DEBUGASSERT(user0 != 0xffffffff && user1 == 0xffffffff);
|
DEBUGASSERT(user0 != 0xffffffff && user1 == 0xffffffff);
|
||||||
|
|
||||||
/* Re-format that MAC address the way that uIP expects to see it */
|
/* Re-format that MAC address the way that uIP expects to see it */
|
||||||
|
|
||||||
ethaddr->ether_addr_octet.addr[0] = ((user0 >> 0) & 0xff);
|
ethaddr->ether_addr_octet[0] = ((user0 >> 0) & 0xff);
|
||||||
ethaddr->ether_addr_octet.addr[1] = ((user0 >> 8) & 0xff);
|
ethaddr->ether_addr_octet[1] = ((user0 >> 8) & 0xff);
|
||||||
ethaddr->ether_addr_octet.addr[2] = ((user0 >> 16) & 0xff);
|
ethaddr->ether_addr_octet[2] = ((user0 >> 16) & 0xff);
|
||||||
ethaddr->ether_addr_octet.addr[3] = ((user1 >> 0) & 0xff);
|
ethaddr->ether_addr_octet[3] = ((user1 >> 0) & 0xff);
|
||||||
ethaddr->ether_addr_octet.addr[4] = ((user1 >> 8) & 0xff);
|
ethaddr->ether_addr_octet[4] = ((user1 >> 8) & 0xff);
|
||||||
ethaddr->ether_addr_octet.addr[5] = ((user1 >> 16) & 0xff);
|
ethaddr->ether_addr_octet[5] = ((user1 >> 16) & 0xff);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user