diff --git a/bsp/stm3210/application.c b/bsp/stm3210/application.c index 8cde671bbb..41c4725c0b 100644 --- a/bsp/stm3210/application.c +++ b/bsp/stm3210/application.c @@ -17,71 +17,94 @@ */ /*@{*/ +#include #include -#include "led.h" -char thread_led1_stack[512]; -struct rt_thread thread_led1; -static void rt_thread_entry_led1(void* parameter) +#ifdef RT_USING_DFS +/* dfs init */ +#include +/* dfs filesystem:ELM filesystem init */ +#include +/* dfs Filesystem APIs */ +#include +#endif + +#ifdef RT_USING_LWIP +#include +#include +#include +#endif + +void rt_init_thread_entry(void* parameter) { - /* init led configuration */ - rt_hw_led_init(); +/* Filesystem Initialization */ +#ifdef RT_USING_DFS + { + /* init the device filesystem */ + dfs_init(); - while (1) - { - /* led on */ - rt_kprintf("led1 on\r\n"); - rt_hw_led_on(0); - rt_thread_delay(50); /* sleep 0.5 second and switch to other thread */ +#ifdef RT_USING_DFS_ELMFAT + /* init the elm chan FatFs filesystam*/ + elm_init(); - /* led off */ - rt_kprintf("led1 off\r\n"); - rt_hw_led_off(0); - rt_thread_delay(50); - } -} + /* mount sd card fat partition 1 as root directory */ + if (dfs_mount("sd0", "/", "elm", 0, 0) == 0) + { + rt_kprintf("File System initialized!\n"); + } + else + rt_kprintf("File System initialzation failed!\n"); +#endif + } +#endif -char thread_led2_stack[512]; -struct rt_thread thread_led2; -void rt_thread_entry_led2(void* parameter) -{ - unsigned int count=0; - while (1) - { - /* led on */ - rt_kprintf("led2 on,count : %d\r\n",count); - count++; - rt_hw_led_on(1); - rt_thread_delay(RT_TICK_PER_SECOND); +/* LwIP Initialization */ +#ifdef RT_USING_LWIP + { + extern void lwip_sys_init(void); - /* led off */ - rt_kprintf("led2 off\r\n"); - rt_hw_led_off(1); - rt_thread_delay(RT_TICK_PER_SECOND); - } + /* register ethernetif device */ + eth_system_device_init(); + +#ifdef STM32F10X_CL + rt_hw_stm32_eth_init(); +#else + /* STM32F103 */ + #if STM32_ETH_IF == 0 + rt_hw_enc28j60_init(); + #elif STM32_ETH_IF == 1 + rt_hw_dm9000_init(); + #endif +#endif + + /* re-init device driver */ + rt_device_init_all(); + + /* init lwip system */ + lwip_sys_init(); + rt_kprintf("TCP/IP initialized!\n"); + } +#endif } int rt_application_init() { - /* init led1 thread */ - rt_thread_init(&thread_led1, - "led1", - rt_thread_entry_led1, - RT_NULL, - &thread_led1_stack[0], - sizeof(thread_led1_stack),10,10); - rt_thread_startup(&thread_led1); + rt_thread_t init_thread; - /* init led2 thread */ - rt_thread_init(&thread_led2, - "led2", - rt_thread_entry_led2, - RT_NULL, - &thread_led2_stack[0], - sizeof(thread_led2_stack),10,10); - rt_thread_startup(&thread_led2); +#if (RT_THREAD_PRIORITY_MAX == 32) + init_thread = rt_thread_create("init", + rt_init_thread_entry, RT_NULL, + 2048, 8, 20); +#else + init_thread = rt_thread_create("init", + rt_init_thread_entry, RT_NULL, + 2048, 80, 20); +#endif - return 0; + if (init_thread != RT_NULL) + rt_thread_startup(init_thread); + + return 0; } /*@}*/ diff --git a/bsp/stm3210/project.Uv2 b/bsp/stm3210/project.Uv2 index b17602999c..6dfe8a3983 100644 --- a/bsp/stm3210/project.Uv2 +++ b/bsp/stm3210/project.Uv2 @@ -2,24 +2,30 @@ ### Do not modify ! Target (RT-Thread STM32), 0x0004 // Tools: 'ARM-ADS' -Target (RT-Thread STM32 Simulator), 0x0004 // Tools: 'ARM-ADS' Group (Startup) Group (StdPeriph_Driver) Group (CMSIS) Group (Kernel) Group (STM32) +Group (finsh) +Group (Filesystem) +Group (LwIP) File 1,1,<.\stm32f10x_it.c> File 1,1,<.\board.c> File 1,1,<.\application.c> File 1,1,<.\startup.c> File 1,1,<.\led.c> +File 1,1,<.\usart.c> +File 1,1,<.\sdcard.c> +File 1,1,<.\msd.c> +File 1,1,<.\enc28j60.c> +File 1,1,<.\dm9000a.c> +File 1,1,<.\rtc.c> File 1,5,<.\rtconfig.h> File 1,5,<.\board.h> -File 1,1,<.\usart.c> File 2,1,<.\Libraries\STM32F10x_StdPeriph_Driver\src\misc.c> -File 2,1,<.\Libraries\STM32F10x_StdPeriph_Driver\src\stm32f10x_wwdg.c> File 2,1,<.\Libraries\STM32F10x_StdPeriph_Driver\src\stm32f10x_adc.c> File 2,1,<.\Libraries\STM32F10x_StdPeriph_Driver\src\stm32f10x_bkp.c> File 2,1,<.\Libraries\STM32F10x_StdPeriph_Driver\src\stm32f10x_can.c> @@ -40,6 +46,7 @@ File 2,1,<.\Libraries\STM32F10x_StdPeriph_Driver\src\stm32f10x_sdio.c> File 2,1,<.\Libraries\STM32F10x_StdPeriph_Driver\src\stm32f10x_tim.c> File 2,1,<.\Libraries\STM32F10x_StdPeriph_Driver\src\stm32f10x_usart.c> +File 2,1,<.\Libraries\STM32F10x_StdPeriph_Driver\src\stm32f10x_wwdg.c> File 3,1,<.\Libraries\CMSIS\Core\CM3\core_cm3.c> File 3,1,<.\Libraries\CMSIS\Core\CM3\system_stm32f10x.c> File 4,1,<..\..\src\clock.c> @@ -59,10 +66,73 @@ File 5,1,<..\..\libcpu\arm\stm32\cpu.c> File 5,1,<..\..\libcpu\arm\stm32\fault.c> File 5,1,<..\..\libcpu\arm\stm32\interrupt.c> File 5,1,<..\..\libcpu\arm\stm32\stack.c> +File 5,1,<..\..\libcpu\arm\stm32\serial.c> File 5,2,<..\..\libcpu\arm\stm32\context_rvds.S> File 5,2,<..\..\libcpu\arm\stm32\fault_rvds.S> File 5,2,<..\..\libcpu\arm\stm32\start_rvds.s> -File 5,1,<..\..\libcpu\arm\stm32\serial.c> +File 6,1,<..\..\finsh\symbol.c> +File 6,1,<..\..\finsh\cmd.c> +File 6,1,<..\..\finsh\finsh_compiler.c> +File 6,1,<..\..\finsh\finsh_error.c> +File 6,1,<..\..\finsh\finsh_heap.c> +File 6,1,<..\..\finsh\finsh_init.c> +File 6,1,<..\..\finsh\finsh_node.c> +File 6,1,<..\..\finsh\finsh_ops.c> +File 6,1,<..\..\finsh\finsh_parser.c> +File 6,1,<..\..\finsh\finsh_token.c> +File 6,1,<..\..\finsh\finsh_var.c> +File 6,1,<..\..\finsh\finsh_vm.c> +File 6,1,<..\..\finsh\shell.c> +File 7,1,<..\..\filesystem\dfs\src\dfs_util.c> +File 7,1,<..\..\filesystem\dfs\src\dfs_cache.c> +File 7,1,<..\..\filesystem\dfs\src\dfs_fs.c> +File 7,1,<..\..\filesystem\dfs\src\dfs_init.c> +File 7,1,<..\..\filesystem\dfs\src\dfs_posix.c> +File 7,1,<..\..\filesystem\dfs\src\dfs_raw.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\base\plibc.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\base\efs.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\base\extract.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\base\partition.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\ui.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\dir.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\fat.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\file.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\fs.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\ls.c> +File 7,1,<..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\time.c> +File 8,1,<..\..\net\lwip\src\core\dhcp.c> +File 8,1,<..\..\net\lwip\src\core\dns.c> +File 8,1,<..\..\net\lwip\src\core\init.c> +File 8,1,<..\..\net\lwip\src\core\memp.c> +File 8,1,<..\..\net\lwip\src\core\netif.c> +File 8,1,<..\..\net\lwip\src\core\pbuf.c> +File 8,1,<..\..\net\lwip\src\core\raw.c> +File 8,1,<..\..\net\lwip\src\core\stats.c> +File 8,1,<..\..\net\lwip\src\core\sys.c> +File 8,1,<..\..\net\lwip\src\core\tcp.c> +File 8,1,<..\..\net\lwip\src\core\tcp_in.c> +File 8,1,<..\..\net\lwip\src\core\tcp_out.c> +File 8,1,<..\..\net\lwip\src\core\udp.c> +File 8,1,<..\..\net\lwip\src\core\ipv4\ip_frag.c> +File 8,1,<..\..\net\lwip\src\core\ipv4\autoip.c> +File 8,1,<..\..\net\lwip\src\core\ipv4\icmp.c> +File 8,1,<..\..\net\lwip\src\core\ipv4\igmp.c> +File 8,1,<..\..\net\lwip\src\core\ipv4\inet.c> +File 8,1,<..\..\net\lwip\src\core\ipv4\inet_chksum.c> +File 8,1,<..\..\net\lwip\src\core\ipv4\ip.c> +File 8,1,<..\..\net\lwip\src\core\ipv4\ip_addr.c> +File 8,1,<..\..\net\lwip\src\api\tcpip.c> +File 8,1,<..\..\net\lwip\src\api\api_lib.c> +File 8,1,<..\..\net\lwip\src\api\api_msg.c> +File 8,1,<..\..\net\lwip\src\api\err.c> +File 8,1,<..\..\net\lwip\src\api\netbuf.c> +File 8,1,<..\..\net\lwip\src\api\netdb.c> +File 8,1,<..\..\net\lwip\src\api\netifapi.c> +File 8,1,<..\..\net\lwip\src\api\sockets.c> +File 8,1,<..\..\net\lwip\src\netif\ethernetif.c> +File 8,1,<..\..\net\lwip\src\netif\etharp.c> +File 8,1,<..\..\net\lwip\src\arch\sys_arch_init.c> +File 8,1,<..\..\net\lwip\src\arch\sys_arch.c> Options 1,0,0 // Target 'RT-Thread STM32' @@ -123,7 +193,7 @@ Options 1,0,0 // Target 'RT-Thread STM32' ADSCMISC () ADSCDEFN (USE_STDPERIPH_DRIVER, STM32F10X_HD,) ADSCUDEF () - ADSCINCD (.\Libraries\STM32F10x_StdPeriph_Driver\inc;.\Libraries\CMSIS\Core\CM3;..\..\include;.;..\..\libcpu\arm\stm32) + ADSCINCD (.\Libraries\STM32F10x_StdPeriph_Driver\inc;.\Libraries\CMSIS\Core\CM3;..\..\include;.;..\..\libcpu\arm\stm32;..\..\filesystem\dfs;..\..\filesystem\dfs\include;..\..\filesystem\dfs\filesystems\efsl\src\include;..\..\filesystem\dfs\filesystems\efsl\src\base\include;..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\include;..\..\net\lwip\src;..\..\net\lwip\src\include;..\..\net\lwip\src\arch\include;..\..\net\lwip\src\include\ipv4;..\..\finsh) ADSASFLG { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } ADSAMISC () ADSADEFN () @@ -144,104 +214,14 @@ Options 1,0,0 // Target 'RT-Thread STM32' ADSLDSC () ADSLDIB () ADSLDIC () - ADSLDMC () + ADSLDMC (--keep __fsym_* --keep __vsym_*) ADSLDIF () ADSLDDW () OPTDL (SARMCM3.DLL)()(DARMSTM.DLL)(-pSTM32F103ZE)(SARMCM3.DLL)()(TARMSTM.DLL)(-pSTM32F103ZE) OPTDBG 49150,7,()()()()()()()()()() (Segger\JL2CM3.dll)()()() - FLASH1 { 9,0,0,0,1,0,0,0,5,16,0,0,0,0,0,0,0,0,0,0 } + FLASH1 { 9,0,0,0,1,0,0,0,6,16,0,0,0,0,0,0,0,0,0,0 } FLASH2 (Segger\JL2CM3.dll) FLASH3 ("" ()) FLASH4 () EndOpt -Options 2,0,0 // Target 'RT-Thread STM32 Simulator' - Device (STM32F103ZE) - Vendor (STMicroelectronics) - Cpu (IRAM(0x20000000-0x2000FFFF) IROM(0x8000000-0x807FFFF) CLOCK(8000000) CPUTYPE("Cortex-M3")) - FlashUt () - StupF ("STARTUP\ST\STM32F10x.s" ("STM32 Startup Code")) - FlashDR (UL2CM3(-O14 -S0 -C0 -N00("ARM Cortex-M3") -D00(1BA00477) -L00(4) -FO7 -FD20000000 -FC800 -FN1 -FF0STM32F10x_512 -FS08000000 -FL080000)) - DevID (4216) - Rgf (stm32f10x_lib.h) - Mem () - C () - A () - RL () - OH () - DBC_IFX () - DBC_CMS () - DBC_AMS () - DBC_LMS () - UseEnv=0 - EnvBin () - EnvInc () - EnvLib () - EnvReg (˙ST\STM32F10x\) - OrgReg (˙ST\STM32F10x\) - TgStat=16 - OutDir (.\obj\) - OutName (rtthread-stm32) - GenApp=1 - GenLib=0 - GenHex=0 - Debug=1 - Browse=0 - LstDir (.\obj\) - HexSel=1 - MG32K=0 - TGMORE=0 - RunUsr 0 0 <> - RunUsr 1 0 <> - BrunUsr 0 0 <> - BrunUsr 1 0 <> - CrunUsr 0 0 <> - CrunUsr 1 0 <> - SVCSID <> - GLFLAGS=1790 - ADSFLGA { 243,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } - ACPUTYP ("Cortex-M3") - RVDEV () - ADSTFLGA { 0,12,0,2,99,0,0,66,0,0,0,0,0,0,0,0,0,0,0,0 } - OCMADSOCM { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } - OCMADSIRAM { 0,0,0,0,32,0,0,1,0 } - OCMADSIROM { 1,0,0,0,8,0,0,8,0 } - OCMADSXRAM { 0,0,0,0,0,0,0,0,0 } - OCR_RVCT { 1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,1,0,0,0,8,0,0,8,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,1,0,0,0,0,0,0,0,0,0,0 } - RV_STAVEC () - ADSCCFLG { 5,32,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } - ADSCMISC () - ADSCDEFN (USE_STDPERIPH_DRIVER, STM32F10X_HD, STM32_SIMULATOR) - ADSCUDEF () - ADSCINCD (.\Libraries\STM32F10x_StdPeriph_Driver\inc;.\Libraries\CMSIS\Core\CM3;..\..\include;.;..\..\libcpu\arm\stm32) - ADSASFLG { 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } - ADSAMISC () - ADSADEFN () - ADSAUDEF () - ADSAINCD () - PropFld { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } - IncBld=1 - AlwaysBuild=0 - GenAsm=0 - AsmAsm=0 - PublicsOnly=0 - StopCode=3 - CustArgs () - LibMods () - ADSLDFG { 17,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } - ADSLDTA (0x08000000) - ADSLDDA (0x20000000) - ADSLDSC () - ADSLDIB () - ADSLDIC () - ADSLDMC () - ADSLDIF () - ADSLDDW () - OPTDL (SARMCM3.DLL)()(DARMSTM.DLL)(-pSTM32F103ZE)(SARMCM3.DLL)()(TARMSTM.DLL)(-pSTM32F103ZE) - OPTDBG 49149,7,()()()()()()()()()() (Segger\JL2CM3.dll)()()() - FLASH1 { 9,0,0,0,1,0,0,0,5,16,0,0,0,0,0,0,0,0,0,0 } - FLASH2 (Segger\JLTAgdi.dll) - FLASH3 ("" ()) - FLASH4 () -EndOpt - diff --git a/bsp/stm3210/project.ewp b/bsp/stm3210/project.ewp index a4b74f9df2..44b5d4b048 100644 --- a/bsp/stm3210/project.ewp +++ b/bsp/stm3210/project.ewp @@ -285,6 +285,16 @@ $PROJ_DIR$\Libraries\CMSIS\Core\CM3 $PROJ_DIR$\..\..\include $PROJ_DIR$\..\..\libcpu\arm\stm32 + $PROJ_DIR$\..\..\finsh + $PROJ_DIR$\..\..\filesystem\dfs + $PROJ_DIR$\..\..\filesystem\dfs\include + $PROJ_DIR$\..\..\filesystem\dfs\filesystems\efsl\src\include + $PROJ_DIR$\..\..\filesystem\dfs\filesystems\efsl\src\base\include + $PROJ_DIR$\..\..\filesystem\dfs\filesystems\efsl\src\fs\vfat\include + $PROJ_DIR$\..\..\net\lwip\src + $PROJ_DIR$\..\..\net\lwip\src\include + $PROJ_DIR$\..\..\net\lwip\src\arch\include + $PROJ_DIR$\..\..\net\lwip\src\include\ipv4