From 5d45949ec5cd25185e64ed3a9cbff6726a521127 Mon Sep 17 00:00:00 2001 From: qiuyiuestc Date: Sat, 2 Jan 2010 16:38:50 +0000 Subject: [PATCH] prepare for RT-Thread/LM3S 0.3.0 version git-svn-id: https://rt-thread.googlecode.com/svn/trunk@274 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- bsp/lm3s/SConstruct | 3 +- bsp/lm3s/board.c | 19 +- bsp/lm3s/board.h | 2 + bsp/lm3s/project_lwip_dfs.Opt | 213 +++++++++---------- bsp/lm3s/project_lwip_dfs.Uv2 | 6 + bsp/lm3s/rtconfig.h | 2 +- bsp/lm3s/rtconfig.py | 2 +- libcpu/arm/lm3s/start_rvds.S | 4 +- net/apps/netio.c | 370 ++++++++++++++++++++++++++++++++++ 9 files changed, 512 insertions(+), 109 deletions(-) create mode 100644 net/apps/netio.c diff --git a/bsp/lm3s/SConstruct b/bsp/lm3s/SConstruct index edccc757d8..5cf0be646c 100644 --- a/bsp/lm3s/SConstruct +++ b/bsp/lm3s/SConstruct @@ -37,8 +37,9 @@ if rtconfig.RT_USING_LWIP: src_bsp = ['application.c', 'startup.c', 'board.c'] +src_drv = [] if rtconfig.RT_USING_DFS: - src_drv = ['sdcard.c'] + src_drv += ['sdcard.c'] if rtconfig.RT_USING_LWIP: src_drv += ['luminaryif.c'] diff --git a/bsp/lm3s/board.c b/bsp/lm3s/board.c index 2f267f395a..0a64a2f120 100644 --- a/bsp/lm3s/board.c +++ b/bsp/lm3s/board.c @@ -50,12 +50,27 @@ void rt_hw_timer_handler(void) } /** - * This function will initial STM32 board. + * This is the ethernet interrupt service routine. + * + */ +void rt_hw_eth_handler(void) +{ +#ifdef RT_USING_LWIP + /* luminary ethernet interface */ + extern void luminaryif_isr(void); + luminaryif_isr(); +#endif +} + +/** + * This function will initial LM3S board. */ void rt_hw_board_init() { + /* set ldo */ + SysCtlLDOSet(SYSCTL_LDO_2_50V); /* set clock */ - SysCtlClockSet(SYSCTL_SYSDIV_2 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | + SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_6MHZ); /* init systick */ diff --git a/bsp/lm3s/board.h b/bsp/lm3s/board.h index 9a2f330aa0..f386ea3cfd 100644 --- a/bsp/lm3s/board.h +++ b/bsp/lm3s/board.h @@ -10,8 +10,10 @@ * Change Logs: * Date Author Notes * 2006-10-08 Bernard add board.h to this bsp + * 2009-12-25 yi.qiu add LM3S configration */ +// <<< Use Configuration Wizard in Context Menu >>> #ifndef __BOARD_H__ #define __BOARD_H__ diff --git a/bsp/lm3s/project_lwip_dfs.Opt b/bsp/lm3s/project_lwip_dfs.Opt index e879594682..3d25594d9c 100644 --- a/bsp/lm3s/project_lwip_dfs.Opt +++ b/bsp/lm3s/project_lwip_dfs.Opt @@ -15,112 +15,121 @@ GRPOPT 1,(Startup),1,0,0 GRPOPT 2,(Kernel),0,0,0 GRPOPT 3,(finsh),0,0,0 GRPOPT 4,(LM3S),0,0,0 -GRPOPT 5,(driverlib),1,0,0 -GRPOPT 6,(Filesystem),1,0,0 -GRPOPT 7,(LwIP),0,0,0 +GRPOPT 5,(driverlib),0,0,0 +GRPOPT 6,(Filesystem),0,0,0 +GRPOPT 7,(LwIP),1,0,0 GRPOPT 8,(Utils),1,0,0 -OPTFFF 1,1,1,201326592,0,0,0,0,<.\application.c> -OPTFFF 1,2,1,2,0,10,18,0,<.\board.c> { 44,0,0,0,2,0,0,0,3,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,22,0,0,0,29,0,0,0,161,2,0,0,71,1,0,0 } -OPTFFF 1,3,1,0,0,0,0,0,<.\startup.c> -OPTFFF 1,4,5,0,0,0,0,0,<.\rtconfig.h> +OPTFFF 1,1,1,0,0,1,1,0,<.\application.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,88,0,0,0,116,0,0,0,236,2,0,0,123,1,0,0 } +OPTFFF 1,2,1,486539264,0,63,63,0,<.\board.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,44,0,0,0,58,0,0,0,183,2,0,0,100,1,0,0 } +OPTFFF 1,3,1,0,0,130,135,0,<.\startup.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,22,0,0,0,29,0,0,0,161,2,0,0,71,1,0,0 } +OPTFFF 1,4,5,469762048,0,115,128,0,<.\rtconfig.h> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,0,0,0,0,0,0,0,0,139,2,0,0,42,1,0,0 } OPTFFF 1,5,1,922746880,0,0,0,0,<.\sdcard.c> -OPTFFF 1,6,1,0,0,0,0,0,<.\luminaryif.c> -OPTFFF 2,7,1,0,0,0,0,0,<..\..\src\clock.c> -OPTFFF 2,8,1,0,0,0,0,0,<..\..\src\device.c> -OPTFFF 2,9,1,0,0,0,0,0,<..\..\src\idle.c> -OPTFFF 2,10,1,0,0,0,0,0,<..\..\src\ipc.c> -OPTFFF 2,11,1,0,0,0,0,0,<..\..\src\irq.c> -OPTFFF 2,12,1,0,0,0,0,0,<..\..\src\mem.c> -OPTFFF 2,13,1,0,0,0,0,0,<..\..\src\mempool.c> -OPTFFF 2,14,1,0,0,0,0,0,<..\..\src\object.c> -OPTFFF 2,15,1,0,0,0,0,0,<..\..\src\scheduler.c> -OPTFFF 2,16,1,0,0,0,0,0,<..\..\src\slab.c> -OPTFFF 2,17,1,0,0,0,0,0,<..\..\src\thread.c> -OPTFFF 2,18,1,0,0,0,0,0,<..\..\src\timer.c> -OPTFFF 2,19,1,0,0,0,0,0,<..\..\src\kservice.c> -OPTFFF 3,20,1,0,0,0,0,0,<..\..\finsh\symbol.c> -OPTFFF 3,21,1,0,0,0,0,0,<..\..\finsh\cmd.c> -OPTFFF 3,22,1,0,0,0,0,0,<..\..\finsh\finsh_compiler.c> -OPTFFF 3,23,1,0,0,0,0,0,<..\..\finsh\finsh_error.c> -OPTFFF 3,24,1,0,0,0,0,0,<..\..\finsh\finsh_heap.c> -OPTFFF 3,25,1,0,0,0,0,0,<..\..\finsh\finsh_init.c> -OPTFFF 3,26,1,0,0,0,0,0,<..\..\finsh\finsh_node.c> -OPTFFF 3,27,1,0,0,0,0,0,<..\..\finsh\finsh_ops.c> -OPTFFF 3,28,1,0,0,0,0,0,<..\..\finsh\finsh_parser.c> -OPTFFF 3,29,1,0,0,0,0,0,<..\..\finsh\finsh_token.c> -OPTFFF 3,30,1,0,0,0,0,0,<..\..\finsh\finsh_var.c> -OPTFFF 3,31,1,0,0,0,0,0,<..\..\finsh\finsh_vm.c> -OPTFFF 3,32,1,0,0,0,0,0,<..\..\finsh\shell.c> -OPTFFF 4,33,1,0,0,0,0,0,<..\..\libcpu\arm\lm3s\cpu.c> -OPTFFF 4,34,1,0,0,0,0,0,<..\..\libcpu\arm\lm3s\interrupt.c> -OPTFFF 4,35,1,0,0,0,0,0,<..\..\libcpu\arm\lm3s\stack.c> -OPTFFF 4,36,2,0,0,0,0,0,<..\..\libcpu\arm\lm3s\context_rvds.S> -OPTFFF 4,37,2,0,0,0,0,0,<..\..\libcpu\arm\lm3s\start_rvds.S> -OPTFFF 4,38,1,0,0,0,0,0,<..\..\libcpu\arm\lm3s\serial.c> -OPTFFF 4,39,1,0,0,0,0,0,<..\..\libcpu\arm\lm3s\fault.c> -OPTFFF 4,40,2,0,0,0,0,0,<..\..\libcpu\arm\lm3s\fault_rvds.S> -OPTFFF 5,41,4,0,0,0,0,0, -OPTFFF 6,42,1,1,0,0,0,0,<..\..\filesystem\dfs\src\dfs_init.c> -OPTFFF 6,43,1,0,0,0,0,0,<..\..\filesystem\dfs\src\dfs_fs.c> -OPTFFF 6,44,1,0,0,0,0,0,<..\..\filesystem\dfs\src\dfs_raw.c> -OPTFFF 6,45,1,0,0,0,0,0,<..\..\filesystem\dfs\src\dfs_util.c> -OPTFFF 6,46,1,0,0,1,1,0,<..\..\filesystem\dfs\src\dfs_cache.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,0,0,0,0,0,0,0,0,135,2,0,0,41,1,0,0 } -OPTFFF 6,47,1,0,0,0,0,0,<..\..\filesystem\dfs\src\dfs_posix.c> -OPTFFF 6,48,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\base\efs.c> -OPTFFF 6,49,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\base\extract.c> -OPTFFF 6,50,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\base\partition.c> -OPTFFF 6,51,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\base\plibc.c> -OPTFFF 6,52,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\dir.c> -OPTFFF 6,53,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\fat.c> -OPTFFF 6,54,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\file.c> -OPTFFF 6,55,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\fs.c> -OPTFFF 6,56,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\ls.c> -OPTFFF 6,57,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\time.c> -OPTFFF 6,58,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\ui.c> -OPTFFF 7,59,1,1,0,0,0,0,<..\..\net\lwip\src\core\dhcp.c> -OPTFFF 7,60,1,0,0,0,0,0,<..\..\net\lwip\src\core\dns.c> -OPTFFF 7,61,1,0,0,0,0,0,<..\..\net\lwip\src\core\init.c> -OPTFFF 7,62,1,0,0,0,0,0,<..\..\net\lwip\src\core\netif.c> -OPTFFF 7,63,1,0,0,0,0,0,<..\..\net\lwip\src\core\pbuf.c> -OPTFFF 7,64,1,0,0,0,0,0,<..\..\net\lwip\src\core\raw.c> -OPTFFF 7,65,1,0,0,0,0,0,<..\..\net\lwip\src\core\stats.c> -OPTFFF 7,66,1,0,0,0,0,0,<..\..\net\lwip\src\core\sys.c> -OPTFFF 7,67,1,0,0,0,0,0,<..\..\net\lwip\src\core\tcp.c> -OPTFFF 7,68,1,0,0,0,0,0,<..\..\net\lwip\src\core\tcp_in.c> -OPTFFF 7,69,1,0,0,0,0,0,<..\..\net\lwip\src\core\tcp_out.c> -OPTFFF 7,70,1,0,0,0,0,0,<..\..\net\lwip\src\core\udp.c> -OPTFFF 7,71,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\autoip.c> -OPTFFF 7,72,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\icmp.c> -OPTFFF 7,73,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\igmp.c> -OPTFFF 7,74,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\inet.c> -OPTFFF 7,75,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\inet_chksum.c> -OPTFFF 7,76,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\ip.c> -OPTFFF 7,77,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\ip_addr.c> -OPTFFF 7,78,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\ip_frag.c> -OPTFFF 7,79,1,0,0,0,0,0,<..\..\net\lwip\src\core\snmp\msg_in.c> -OPTFFF 7,80,1,0,0,0,0,0,<..\..\net\lwip\src\core\snmp\msg_out.c> -OPTFFF 7,81,1,0,0,0,0,0,<..\..\net\lwip\src\api\api_lib.c> -OPTFFF 7,82,1,0,0,0,0,0,<..\..\net\lwip\src\api\api_msg.c> -OPTFFF 7,83,1,0,0,0,0,0,<..\..\net\lwip\src\api\err.c> -OPTFFF 7,84,1,0,0,0,0,0,<..\..\net\lwip\src\api\netbuf.c> -OPTFFF 7,85,1,0,0,0,0,0,<..\..\net\lwip\src\api\netdb.c> -OPTFFF 7,86,1,0,0,0,0,0,<..\..\net\lwip\src\api\netifapi.c> -OPTFFF 7,87,1,0,0,0,0,0,<..\..\net\lwip\src\api\tcpip.c> -OPTFFF 7,88,1,0,0,0,0,0,<..\..\net\lwip\src\netif\etharp.c> -OPTFFF 7,89,1,0,0,0,0,0,<..\..\net\lwip\src\netif\ethernetif.c> -OPTFFF 7,90,1,0,0,0,0,0,<..\..\net\lwip\src\netif\loopif.c> -OPTFFF 7,91,1,0,0,0,0,0,<..\..\net\lwip\src\arch\sys_arch_init.c> -OPTFFF 7,92,1,0,0,0,0,0,<..\..\net\lwip\src\arch\sys_arch.c> -OPTFFF 7,93,1,0,0,0,0,0,<..\..\net\lwip\src\api\sockets.c> -OPTFFF 7,94,1,0,0,0,0,0,<..\..\net\lwip\src\core\memp_tiny.c> -OPTFFF 8,95,1,0,0,0,0,0,<..\..\net\apps\chargen.c> -OPTFFF 8,96,1,0,0,0,0,0,<..\..\net\apps\ftpd.c> -OPTFFF 8,97,1,0,0,0,0,0,<..\..\net\apps\sntp.c> -OPTFFF 8,98,1,0,0,0,0,0,<..\..\net\apps\tcpecho.c> -OPTFFF 8,99,1,486539264,0,0,0,0,<..\..\net\apps\tftp.c> -OPTFFF 8,100,1,0,0,0,0,0,<..\..\net\apps\udpecho.c> +OPTFFF 1,6,1,1006632960,0,1,1,0,<.\luminaryif.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,66,0,0,0,87,0,0,0,205,2,0,0,129,1,0,0 } +OPTFFF 1,7,5,0,0,0,0,0,<.\board.h> +OPTFFF 2,8,1,0,0,0,0,0,<..\..\src\clock.c> +OPTFFF 2,9,1,0,0,0,0,0,<..\..\src\device.c> +OPTFFF 2,10,1,0,0,51,60,0,<..\..\src\idle.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,66,0,0,0,87,0,0,0,205,2,0,0,129,1,0,0 } +OPTFFF 2,11,1,0,0,0,0,0,<..\..\src\ipc.c> +OPTFFF 2,12,1,0,0,0,0,0,<..\..\src\irq.c> +OPTFFF 2,13,1,0,0,0,0,0,<..\..\src\mem.c> +OPTFFF 2,14,1,0,0,0,0,0,<..\..\src\mempool.c> +OPTFFF 2,15,1,0,0,0,0,0,<..\..\src\object.c> +OPTFFF 2,16,1,0,0,0,0,0,<..\..\src\scheduler.c> +OPTFFF 2,17,1,0,0,0,0,0,<..\..\src\slab.c> +OPTFFF 2,18,1,0,0,0,0,0,<..\..\src\thread.c> +OPTFFF 2,19,1,0,0,0,0,0,<..\..\src\timer.c> +OPTFFF 2,20,1,0,0,0,0,0,<..\..\src\kservice.c> +OPTFFF 3,21,1,0,0,0,0,0,<..\..\finsh\symbol.c> +OPTFFF 3,22,1,0,0,0,0,0,<..\..\finsh\cmd.c> +OPTFFF 3,23,1,0,0,0,0,0,<..\..\finsh\finsh_compiler.c> +OPTFFF 3,24,1,0,0,0,0,0,<..\..\finsh\finsh_error.c> +OPTFFF 3,25,1,0,0,0,0,0,<..\..\finsh\finsh_heap.c> +OPTFFF 3,26,1,0,0,0,0,0,<..\..\finsh\finsh_init.c> +OPTFFF 3,27,1,0,0,0,0,0,<..\..\finsh\finsh_node.c> +OPTFFF 3,28,1,0,0,0,0,0,<..\..\finsh\finsh_ops.c> +OPTFFF 3,29,1,0,0,0,0,0,<..\..\finsh\finsh_parser.c> +OPTFFF 3,30,1,0,0,0,0,0,<..\..\finsh\finsh_token.c> +OPTFFF 3,31,1,0,0,0,0,0,<..\..\finsh\finsh_var.c> +OPTFFF 3,32,1,0,0,0,0,0,<..\..\finsh\finsh_vm.c> +OPTFFF 3,33,1,0,0,0,0,0,<..\..\finsh\shell.c> +OPTFFF 4,34,1,0,0,0,0,0,<..\..\libcpu\arm\lm3s\cpu.c> +OPTFFF 4,35,1,0,0,0,0,0,<..\..\libcpu\arm\lm3s\interrupt.c> +OPTFFF 4,36,1,0,0,0,0,0,<..\..\libcpu\arm\lm3s\stack.c> +OPTFFF 4,37,2,0,0,0,0,0,<..\..\libcpu\arm\lm3s\context_rvds.S> +OPTFFF 4,38,2,0,0,0,0,0,<..\..\libcpu\arm\lm3s\start_rvds.S> +OPTFFF 4,39,1,0,0,0,0,0,<..\..\libcpu\arm\lm3s\serial.c> +OPTFFF 4,40,1,0,0,0,0,0,<..\..\libcpu\arm\lm3s\fault.c> +OPTFFF 4,41,2,0,0,0,0,0,<..\..\libcpu\arm\lm3s\fault_rvds.S> +OPTFFF 5,42,4,0,0,0,0,0, +OPTFFF 6,43,1,1,0,0,0,0,<..\..\filesystem\dfs\src\dfs_init.c> +OPTFFF 6,44,1,0,0,0,0,0,<..\..\filesystem\dfs\src\dfs_fs.c> +OPTFFF 6,45,1,0,0,0,0,0,<..\..\filesystem\dfs\src\dfs_raw.c> +OPTFFF 6,46,1,0,0,0,0,0,<..\..\filesystem\dfs\src\dfs_util.c> +OPTFFF 6,47,1,0,0,0,0,0,<..\..\filesystem\dfs\src\dfs_cache.c> +OPTFFF 6,48,1,0,0,0,0,0,<..\..\filesystem\dfs\src\dfs_posix.c> +OPTFFF 6,49,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\base\efs.c> +OPTFFF 6,50,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\base\extract.c> +OPTFFF 6,51,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\base\partition.c> +OPTFFF 6,52,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\base\plibc.c> +OPTFFF 6,53,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\dir.c> +OPTFFF 6,54,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\fat.c> +OPTFFF 6,55,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\file.c> +OPTFFF 6,56,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\fs.c> +OPTFFF 6,57,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\ls.c> +OPTFFF 6,58,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\time.c> +OPTFFF 6,59,1,0,0,0,0,0,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\ui.c> +OPTFFF 7,60,1,1,0,0,0,0,<..\..\net\lwip\src\core\dhcp.c> +OPTFFF 7,61,1,0,0,0,0,0,<..\..\net\lwip\src\core\dns.c> +OPTFFF 7,62,1,0,0,247,247,0,<..\..\net\lwip\src\core\init.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,0,0,0,0,0,0,0,0,139,2,0,0,42,1,0,0 } +OPTFFF 7,63,1,0,0,0,0,0,<..\..\net\lwip\src\core\netif.c> +OPTFFF 7,64,1,0,0,0,0,0,<..\..\net\lwip\src\core\pbuf.c> +OPTFFF 7,65,1,0,0,0,0,0,<..\..\net\lwip\src\core\raw.c> +OPTFFF 7,66,1,0,0,0,0,0,<..\..\net\lwip\src\core\stats.c> +OPTFFF 7,67,1,0,0,0,0,0,<..\..\net\lwip\src\core\sys.c> +OPTFFF 7,68,1,0,0,381,381,0,<..\..\net\lwip\src\core\tcp.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,88,0,0,0,116,0,0,0,227,2,0,0,158,1,0,0 } +OPTFFF 7,69,1,0,0,0,0,0,<..\..\net\lwip\src\core\tcp_in.c> +OPTFFF 7,70,1,0,0,0,0,0,<..\..\net\lwip\src\core\tcp_out.c> +OPTFFF 7,71,1,0,0,0,0,0,<..\..\net\lwip\src\core\udp.c> +OPTFFF 7,72,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\autoip.c> +OPTFFF 7,73,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\icmp.c> +OPTFFF 7,74,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\igmp.c> +OPTFFF 7,75,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\inet.c> +OPTFFF 7,76,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\inet_chksum.c> +OPTFFF 7,77,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\ip.c> +OPTFFF 7,78,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\ip_addr.c> +OPTFFF 7,79,1,0,0,0,0,0,<..\..\net\lwip\src\core\ipv4\ip_frag.c> +OPTFFF 7,80,1,0,0,0,0,0,<..\..\net\lwip\src\core\snmp\msg_in.c> +OPTFFF 7,81,1,0,0,0,0,0,<..\..\net\lwip\src\core\snmp\msg_out.c> +OPTFFF 7,82,1,0,0,0,0,0,<..\..\net\lwip\src\api\api_lib.c> +OPTFFF 7,83,1,0,0,0,0,0,<..\..\net\lwip\src\api\api_msg.c> +OPTFFF 7,84,1,0,0,0,0,0,<..\..\net\lwip\src\api\err.c> +OPTFFF 7,85,1,0,0,0,0,0,<..\..\net\lwip\src\api\netbuf.c> +OPTFFF 7,86,1,0,0,0,0,0,<..\..\net\lwip\src\api\netdb.c> +OPTFFF 7,87,1,0,0,0,0,0,<..\..\net\lwip\src\api\netifapi.c> +OPTFFF 7,88,1,1,0,0,0,0,<..\..\net\lwip\src\api\tcpip.c> +OPTFFF 7,89,1,0,0,0,0,0,<..\..\net\lwip\src\netif\etharp.c> +OPTFFF 7,90,1,0,0,0,0,0,<..\..\net\lwip\src\netif\ethernetif.c> +OPTFFF 7,91,1,0,0,0,0,0,<..\..\net\lwip\src\netif\loopif.c> +OPTFFF 7,92,1,0,0,0,0,0,<..\..\net\lwip\src\arch\sys_arch_init.c> +OPTFFF 7,93,1,0,0,0,0,0,<..\..\net\lwip\src\arch\sys_arch.c> +OPTFFF 7,94,1,0,0,0,0,0,<..\..\net\lwip\src\api\sockets.c> +OPTFFF 7,95,1,0,0,0,0,0,<..\..\net\lwip\src\core\memp_tiny.c> +OPTFFF 8,96,1,0,0,0,0,0,<..\..\net\apps\chargen.c> +OPTFFF 8,97,1,671088640,0,1,14,0,<..\..\net\apps\ftpd.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,44,0,0,0,58,0,0,0,183,2,0,0,100,1,0,0 } +OPTFFF 8,98,1,0,0,0,0,0,<..\..\net\apps\sntp.c> +OPTFFF 8,99,1,0,0,46,46,0,<..\..\net\apps\tcpecho.c> { 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,66,0,0,0,87,0,0,0,205,2,0,0,129,1,0,0 } +OPTFFF 8,100,1,486539264,0,0,0,0,<..\..\net\apps\tftp.c> +OPTFFF 8,101,1,0,0,0,0,0,<..\..\net\apps\udpecho.c> +OPTFFF 8,102,1,0,0,0,0,0,<..\..\net\apps\tcpclient.c> +OPTFFF 8,103,1,0,0,0,0,0,<..\..\net\apps\tcpserver.c> +OPTFFF 8,104,1,0,0,0,0,0,<..\..\net\apps\udpclient.c> +OPTFFF 8,105,1,0,0,0,0,0,<..\..\net\apps\udpserver.c> +OPTFFF 8,106,1,369098754,0,1,16,0,<..\..\net\apps\netio.c> { 44,0,0,0,2,0,0,0,3,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,44,0,0,0,58,0,0,0,183,2,0,0,100,1,0,0 } +ExtF 153,153,0,{ 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,88,0,0,0,116,0,0,0,227,2,0,0,158,1,0,0 } +ExtF 80,84,0,{ 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,22,0,0,0,29,0,0,0,170,2,0,0,36,1,0,0 } +ExtF 13,13,0,{ 44,0,0,0,0,0,0,0,1,0,0,0,255,255,255,255,255,255,255,255,252,255,255,255,226,255,255,255,0,0,0,0,0,0,0,0,139,2,0,0,42,1,0,0 } TARGOPT 1, (RT-Thread/LM3S) ADSCLK=6000000 diff --git a/bsp/lm3s/project_lwip_dfs.Uv2 b/bsp/lm3s/project_lwip_dfs.Uv2 index 94bad23c27..2fc50ee93e 100644 --- a/bsp/lm3s/project_lwip_dfs.Uv2 +++ b/bsp/lm3s/project_lwip_dfs.Uv2 @@ -18,6 +18,7 @@ File 1,1,<.\startup.c> File 1,5,<.\rtconfig.h> File 1,1,<.\sdcard.c> File 1,1,<.\luminaryif.c> +File 1,5,<.\board.h> File 2,1,<..\..\src\clock.c> File 2,1,<..\..\src\device.c> File 2,1,<..\..\src\idle.c> @@ -112,6 +113,11 @@ File 8,1,<..\..\net\apps\sntp.c> File 8,1,<..\..\net\apps\tcpecho.c> File 8,1,<..\..\net\apps\tftp.c> File 8,1,<..\..\net\apps\udpecho.c> +File 8,1,<..\..\net\apps\tcpclient.c> +File 8,1,<..\..\net\apps\tcpserver.c> +File 8,1,<..\..\net\apps\udpclient.c> +File 8,1,<..\..\net\apps\udpserver.c> +File 8,1,<..\..\net\apps\netio.c> Options 1,0,0 // Target 'RT-Thread/LM3S' diff --git a/bsp/lm3s/rtconfig.h b/bsp/lm3s/rtconfig.h index 7235c64553..416b704e71 100644 --- a/bsp/lm3s/rtconfig.h +++ b/bsp/lm3s/rtconfig.h @@ -116,7 +116,7 @@ #define RT_LWIP_ETH_PAD_SIZE 2 /* TCP sender buffer space*/ -#define RT_LWIP_TCP_SND_BUF 2048 +#define RT_LWIP_TCP_SND_BUF 1024*8 /* Enable SNMP protocol*/ /* #define RT_LWIP_SNMP */ diff --git a/bsp/lm3s/rtconfig.py b/bsp/lm3s/rtconfig.py index 334745dace..83bec409da 100644 --- a/bsp/lm3s/rtconfig.py +++ b/bsp/lm3s/rtconfig.py @@ -21,7 +21,7 @@ CPU='lm3s' #EXEC_PATH = 'E:/Program Files/CodeSourcery/Sourcery G++ Lite/bin' PLATFORM = 'armcc' EXEC_PATH = 'E:/Keil' -BUILD = 'debug' +BUILD = 'release' if PLATFORM == 'gcc': # toolchains diff --git a/libcpu/arm/lm3s/start_rvds.S b/libcpu/arm/lm3s/start_rvds.S index 994d95f7d4..f6eab2e85e 100644 --- a/libcpu/arm/lm3s/start_rvds.S +++ b/libcpu/arm/lm3s/start_rvds.S @@ -65,7 +65,7 @@ __heap_limit IMPORT rt_hw_pend_sv IMPORT rt_hw_timer_handler IMPORT rt_hw_uart_isr_1 - IMPORT luminaryif_isr + IMPORT rt_hw_eth_handler IMPORT rt_hw_hard_fault ;****************************************************************************** @@ -148,7 +148,7 @@ __Vectors DCD IntDefaultHandler ; CAN0 DCD IntDefaultHandler ; CAN1 DCD IntDefaultHandler ; CAN2 - DCD luminaryif_isr ; Ethernet + DCD rt_hw_eth_handler ; Ethernet DCD IntDefaultHandler ; Hibernate DCD IntDefaultHandler ; USB0 DCD IntDefaultHandler ; PWM Generator 3 diff --git a/net/apps/netio.c b/net/apps/netio.c new file mode 100644 index 0000000000..c603acc947 --- /dev/null +++ b/net/apps/netio.c @@ -0,0 +1,370 @@ +/** + * @file + * MetIO Server + * + */ + +/* + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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. + * + * This file is part of the lwIP TCP/IP stack. + * + */ +#include "lwip/opt.h" + +#if LWIP_TCP +#include "lwip/tcp.h" + +/* + * This implements a netio server. + * The client sends a command word (4 bytes) then a data length word (4 bytes). + * If the command is "receive", the server is to consume "data length" bytes into + * a circular buffer until the first byte is non-zero, then it is to consume + * another command/data pair. + * If the command is "send", the server is to send "data length" bytes from a circular + * buffer with the first byte being zero, until "some time" (6 seconds in the + * current netio126.zip download) has passed and then send one final buffer with + * the first byte being non-zero. Then it is to consume another command/data pair. + */ + +/* See http://www.nwlab.net/art/netio/netio.html to get the netio tool */ + +/* implementation options */ +#define NETIO_BUF_SIZE (4 * 1024) +#define NETIO_USE_STATIC_BUF 0 + +/* NetIO server state definition */ +#define NETIO_STATE_WAIT_FOR_CMD 0 +#define NETIO_STATE_RECV_DATA 1 +#define NETIO_STATE_SEND_DATA 2 +#define NETIO_STATE_SEND_DATA_LAST 3 +#define NETIO_STATE_DONE 4 + +struct netio_state { + u32_t state; + u32_t cmd; + u32_t data_len; + u32_t cntr; + u8_t * buf_ptr; + u32_t buf_pos; + u32_t first_byte; + u32_t time_stamp; +}; + +/* NetIO command protocol definition */ +#define NETIO_CMD_QUIT 0 +#define NETIO_CMD_C2S 1 +#define NETIO_CMD_S2C 2 +#define NETIO_CMD_RES 3 + +static err_t netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err); + +static void +netio_close(void *arg, struct tcp_pcb *pcb) +{ + err_t err; + + struct netio_state *ns = arg; + ns->state = NETIO_STATE_DONE; + tcp_recv(pcb, NULL); + err = tcp_close(pcb); + + if (err != ERR_OK) { + /* closing failed, try again later */ + tcp_recv(pcb, netio_recv); + } else { + /* closing succeeded */ +#if NETIO_USE_STATIC_BUF != 1 + if(ns->buf_ptr != NULL){ + mem_free(ns->buf_ptr); + } +#endif + tcp_arg(pcb, NULL); + tcp_poll(pcb, NULL, 0); + tcp_sent(pcb, NULL); + if (arg != NULL) { + mem_free(arg); + } + } +} + +static err_t +netio_recv(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err) +{ + struct netio_state *ns = arg; + u8_t * data_ptr; + u32_t data_cntr; + struct pbuf *q = p; + u16_t len; + + if (p != NULL) { + tcp_recved(pcb, p->tot_len); + } + + if (err == ERR_OK && q != NULL) { + + while (q != NULL) { + data_cntr = q->len; + data_ptr = q->payload; + while (data_cntr--) { + if (ns->state == NETIO_STATE_DONE){ + netio_close(ns, pcb); + break; + } else if (ns->state == NETIO_STATE_WAIT_FOR_CMD) { + if (ns->cntr < 4) { + /* build up the CMD field */ + ns->cmd <<= 8; + ns->cmd |= *data_ptr++; + ns->cntr++; + } else if (ns->cntr < 8) { + /* build up the DATA field */ + ns->data_len <<= 8; + ns->data_len |= *data_ptr++; + ns->cntr++; + + if (ns->cntr == 8) { + /* now we have full command and data words */ + ns->cntr = 0; + ns->buf_pos = 0; + ns->buf_ptr[0] = 0; + if (ns->cmd == NETIO_CMD_C2S) { + ns->state = NETIO_STATE_RECV_DATA; + } else if (ns->cmd == NETIO_CMD_S2C) { + ns->state = NETIO_STATE_SEND_DATA; + /* start timer */ + ns->time_stamp = rt_tick_get(); + /* send first round of data */ + + len = tcp_sndbuf(pcb); + len = LWIP_MIN(len, ns->data_len - ns->cntr); + len = LWIP_MIN(len, NETIO_BUF_SIZE - ns->buf_pos); + + do { + err = tcp_write(pcb, ns->buf_ptr + ns->buf_pos, len, TCP_WRITE_FLAG_COPY); + if (err == ERR_MEM) { + len /= 2; + } + } while ((err == ERR_MEM) && (len > 1)); + + ns->buf_pos += len; + ns->cntr += len; + + } else { + /* unrecognized command, punt */ + ns->cntr = 0; + ns->buf_pos = 0; + ns->buf_ptr[0] = 0; + netio_close(ns, pcb); + break; + } + } + } else { + /* in trouble... shouldn't be in this state! */ + } + + } else if (ns->state == NETIO_STATE_RECV_DATA) { + + if(ns->cntr == 0){ + /* save the first byte of this new round of data + * this will not match ns->buf_ptr[0] in the case that + * NETIO_BUF_SIZE is less than ns->data_len. + */ + ns->first_byte = *data_ptr; + } + + ns->buf_ptr[ns->buf_pos++] = *data_ptr++; + ns->cntr++; + + if (ns->buf_pos == NETIO_BUF_SIZE) { + /* circularize the buffer */ + ns->buf_pos = 0; + } + + if(ns->cntr == ns->data_len){ + ns->cntr = 0; + if (ns->first_byte != 0) { + /* if this last round did not start with 0, + * go look for another command */ + ns->state = NETIO_STATE_WAIT_FOR_CMD; + ns->data_len = 0; + ns->cmd = 0; + /* TODO LWIP_DEBUGF( print out some throughput calculation results... ); */ + } else { + /* stay here and wait on more data */ + } + } + + } else if (ns->state == NETIO_STATE_SEND_DATA + || ns->state == NETIO_STATE_SEND_DATA_LAST) { + /* I don't think this should happen... */ + } else { + /* done / quit */ + netio_close(ns, pcb); + break; + } /* end of ns->state condition */ + } /* end of while data still in this pbuf */ + + q = q->next; + } + + pbuf_free(p); + + } else { + + /* error or closed by other side */ + if (p != NULL) { + pbuf_free(p); + } + + /* close the connection */ + netio_close(ns, pcb); + + } + return ERR_OK; + +} + +static err_t +netio_sent(void *arg, struct tcp_pcb *pcb, u16_t len) +{ + struct netio_state *ns = arg; + err_t err = ERR_OK; + + if (ns->cntr >= ns->data_len && ns->state == NETIO_STATE_SEND_DATA) { + /* done with this round of sending */ + ns->buf_pos = 0; + ns->cntr = 0; + + /* check if timer expired */ + if (rt_tick_get() - ns->time_stamp > 600) { + ns->buf_ptr[0] = 1; + ns->state = NETIO_STATE_SEND_DATA_LAST; + } else { + ns->buf_ptr[0] = 0; + } + } + + if(ns->state == NETIO_STATE_SEND_DATA_LAST || ns->state == NETIO_STATE_SEND_DATA){ + len = tcp_sndbuf(pcb); + len = LWIP_MIN(len, ns->data_len - ns->cntr); + len = LWIP_MIN(len, NETIO_BUF_SIZE - ns->buf_pos); + + if(ns->cntr < ns->data_len){ + do { + err = tcp_write(pcb, ns->buf_ptr + ns->buf_pos, len, TCP_WRITE_FLAG_COPY); + if (err == ERR_MEM) { + len /= 2; + } + } while ((err == ERR_MEM) && (len > 1)); + + ns->buf_pos += len; + if(ns->buf_pos >= NETIO_BUF_SIZE){ + ns->buf_pos = 0; + } + + ns->cntr += len; + } + } + + if(ns->cntr >= ns->data_len && ns->state == NETIO_STATE_SEND_DATA_LAST){ + /* we have buffered up all our data to send this last round, go look for a command */ + ns->state = NETIO_STATE_WAIT_FOR_CMD; + ns->cntr = 0; + /* TODO LWIP_DEBUGF( print out some throughput calculation results... ); */ + } + + return ERR_OK; +} + +static err_t +netio_poll(void *arg, struct tcp_pcb *pcb) +{ + struct netio_state * ns = arg; + if(ns->state == NETIO_STATE_SEND_DATA){ + + } else if(ns->state == NETIO_STATE_DONE){ + netio_close(ns, pcb); + } + + return ERR_OK; + +} + +#if NETIO_USE_STATIC_BUF == 1 +static u8_t netio_buf[NETIO_BUF_SIZE]; +#endif + +static err_t +netio_accept(void *arg, struct tcp_pcb *pcb, err_t err) +{ + struct netio_state * ns; + + LWIP_UNUSED_ARG(err); + + ns = mem_malloc(sizeof(struct netio_state)); + + if(ns == NULL){ + return ERR_MEM; + } + + ns->state = NETIO_STATE_WAIT_FOR_CMD; + ns->data_len = 0; + ns->cmd = 0; + ns->cntr = 0; + ns->buf_pos = 0; +#if NETIO_USE_STATIC_BUF == 1 + ns->buf_ptr = netio_buf; +#else + ns->buf_ptr = mem_malloc(NETIO_BUF_SIZE); + + if(ns->buf_ptr == NULL){ + mem_free(ns); + return ERR_MEM; + } +#endif + + ns->buf_ptr[0] = 0; + + tcp_arg(pcb, ns); + tcp_sent(pcb, netio_sent); + tcp_recv(pcb, netio_recv); + tcp_poll(pcb, netio_poll, 4); /* every 2 seconds */ + return ERR_OK; +} + +void netio_init(void) +{ + struct tcp_pcb *pcb; + + pcb = tcp_new(); + tcp_bind(pcb, IP_ADDR_ANY, 18767); + pcb = tcp_listen(pcb); + tcp_accept(pcb, netio_accept); +} + +#endif /* LWIP_TCP */ + +#ifdef RT_USING_FINSH +#include +FINSH_FUNCTION_EXPORT(netio_init, netio server); +#endif -- GitLab