diff --git a/Drivers/BSP/NET/net_socket.c b/Drivers/BSP/NET/net_socket.c index c85ac04..eb8cf75 100644 --- a/Drivers/BSP/NET/net_socket.c +++ b/Drivers/BSP/NET/net_socket.c @@ -106,8 +106,8 @@ int net_init(const char *ip, const char *mask, const char *gateway) { ch395f_reset(); DBG_INFO("net_init: set_fun_para..."); - /* 启用 TCP Server 多连接模式(bit1=1) */ - ch395f_set_fun_para(0x02); + /* 启用单连接模式:每个 Socket 独立工作,支持多监听 Socket(FTP PASV 需要) */ + ch395f_set_fun_para(0x00); DBG_INFO("net_init: set_tcp_mss..."); /* 设置 TCP MSS */ @@ -353,7 +353,7 @@ void net_process_messages(void) { break; } - xTaskNotifyGive(msg.caller); + xTaskNotify(msg.caller, (uint32_t)msg.result, eSetValueWithOverwrite); } } @@ -569,7 +569,11 @@ int net_listen(int sockfd, int backlog) { return -1; } - ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + { + uint32_t s_notified; + xTaskNotifyWait(0, 0, &s_notified, portMAX_DELAY); + msg.result = (int)s_notified; + } if (msg.result < 0) { s_net_errno = NET_ERR; @@ -666,7 +670,11 @@ int net_accept(int sockfd, struct net_sockaddr *addr, int *addrlen) { return -1; } - ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + { + uint32_t s_notified; + xTaskNotifyWait(0, 0, &s_notified, portMAX_DELAY); + msg.result = (int)s_notified; + } if (addrlen != NULL && addr != NULL) { *addrlen = sizeof(struct net_sockaddr_in); @@ -889,7 +897,11 @@ int net_send(int sockfd, const void *buf, int len, int flags) { return -1; } - ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + { + uint32_t s_notified; + xTaskNotifyWait(0, 0, &s_notified, portMAX_DELAY); + msg.result = (int)s_notified; + } if (msg.result < 0) { s_net_errno = NET_ERR; @@ -935,7 +947,11 @@ int net_recv(int sockfd, void *buf, int len, int flags) { return -1; } - ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + { + uint32_t s_notified; + xTaskNotifyWait(0, 0, &s_notified, portMAX_DELAY); + msg.result = (int)s_notified; + } if (msg.result < 0) { s_net_errno = NET_ERR; @@ -975,13 +991,18 @@ int net_close(int sockfd) { return -1; } - ulTaskNotifyTake(pdTRUE, portMAX_DELAY); + { + uint32_t s_notified; + xTaskNotifyWait(0, 0, &s_notified, portMAX_DELAY); + msg.result = (int)s_notified; + } if (msg.result < 0) { s_net_errno = NET_ERR; } return msg.result; } + /* * 函数功能:发送 UDP 数据报(含目标地址) * 入口参数:sockfd - Socket 描述符 int >= 0 && < NET_MAX_SOCKETS diff --git a/MDK-ARM/STM32F407-Demo.uvprojx b/MDK-ARM/STM32F407-Demo.uvprojx index 7348110..4f1e718 100644 --- a/MDK-ARM/STM32F407-Demo.uvprojx +++ b/MDK-ARM/STM32F407-Demo.uvprojx @@ -1,7 +1,10 @@ - - + + + 2.1 +
### uVision Project, (C) Keil Software
+ STM32F407-Demo @@ -16,28 +19,28 @@ Keil.STM32F4xx_DFP.3.1.1 https://www.keil.com/pack/ IRAM(0x20000000-0x2001BFFF) IRAM2(0x2001C000-0x2001FFFF) IROM(0x8000000-0x80FFFFF) CLOCK(25000000) FPU2 CPUTYPE("Cortex-M4") TZ - - - + + + 0 - - - - - - - - - - + + + + + + + + + + $$Device:STM32F407ZGTx$CMSIS\SVD\STM32F407.svd 0 0 - - - - - + + + + + 0 0 @@ -52,15 +55,15 @@ 1 1 1 - + 1 0 0 0 0 - - + + 0 0 0 @@ -69,8 +72,8 @@ 0 0 - - + + 0 0 0 @@ -79,15 +82,15 @@ 0 1 - - + + 0 0 0 0 1 - + 0 @@ -101,8 +104,8 @@ 0 0 3 - - + + 0 @@ -136,10 +139,10 @@ 1 BIN\UL2CM3.DLL "" () - - - - + + + + 0 @@ -172,7 +175,7 @@ 0 0 "Cortex-M4" - + 0 0 0 @@ -307,7 +310,7 @@ 0x4000 - + 1 @@ -334,9 +337,9 @@ 0 0 - + USE_HAL_DRIVER,STM32F407xx,NDEBUG - + ../Inc;../Drivers/STM32F4xx_HAL_Driver/Inc;../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy;../Drivers/CMSIS/Device/ST/STM32F4xx/Include;../Drivers/CMSIS/Include;../Drivers/BSP;../Drivers/BSP/CH395F;../Drivers/BSP/GD5F2GQ5UE;../Drivers/BSP/TPAFE5160;../Drivers/BSP/SD2506;../Drivers/BSP/RS485;../Drivers/BSP/NET;../Drivers/BSP/NET/lftpd;../App;../App/task;../App/util;../Middlewares/Third_Party/FreeRTOS/Source/include;../Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2;../Middlewares/Third_Party/FreeRTOS/Source/portable/RVDS/ARM_CM4F;../Lib/dhara;../Lib/FatFs @@ -352,9 +355,9 @@ 0 1 - - - + + + ../Drivers/CMSIS/Include @@ -365,15 +368,15 @@ 0 1 0 - - - - - - - - - + + + + + + + + + @@ -418,6 +421,8 @@ 2 2 11 + + 1 @@ -445,6 +450,12 @@ 2 2 2 + + + + + + @@ -466,6 +477,8 @@ 2 2 11 + + 1 @@ -493,6 +506,12 @@ 2 2 2 + + + + + + @@ -514,6 +533,8 @@ 2 2 11 + + 1 @@ -541,6 +562,12 @@ 2 2 2 + + + + + + @@ -562,6 +589,8 @@ 2 2 11 + + 1 @@ -589,6 +618,12 @@ 2 2 2 + + + + + + @@ -610,6 +645,8 @@ 2 2 11 + + 1 @@ -637,6 +674,12 @@ 2 2 2 + + + + + + @@ -668,6 +711,8 @@ 2 2 11 + + 1 @@ -695,6 +740,12 @@ 2 2 2 + + + + + + @@ -761,6 +812,8 @@ 2 2 11 + + 1 @@ -788,6 +841,12 @@ 2 2 2 + + + + + + @@ -809,6 +868,8 @@ 2 2 11 + + 1 @@ -836,6 +897,12 @@ 2 2 2 + + + + + + @@ -922,6 +989,8 @@ 2 2 11 + + 1 @@ -949,6 +1018,12 @@ 2 2 2 + + + + + + @@ -970,6 +1045,8 @@ 2 2 11 + + 1 @@ -997,6 +1074,12 @@ 2 2 2 + + + + + + @@ -1018,6 +1101,8 @@ 2 2 11 + + 1 @@ -1045,6 +1130,12 @@ 2 2 2 + + + + + + @@ -1066,6 +1157,8 @@ 2 2 11 + + 1 @@ -1093,6 +1186,12 @@ 2 2 2 + + + + + + @@ -1194,6 +1293,8 @@ 2 2 11 + + 1 @@ -1221,6 +1322,12 @@ 2 2 2 + + + + + + 2 @@ -1233,6 +1340,12 @@ 2 2 1 + + + + + + @@ -1254,6 +1367,8 @@ 2 2 11 + + 1 @@ -1281,6 +1396,12 @@ 2 2 2 + + + + + + @@ -1302,6 +1423,8 @@ 2 2 11 + + 1 @@ -1329,6 +1452,12 @@ 2 2 2 + + + + + + @@ -1350,6 +1479,8 @@ 2 2 11 + + 1 @@ -1377,6 +1508,12 @@ 2 2 2 + + + + + + @@ -1398,6 +1535,8 @@ 2 2 11 + + 1 @@ -1425,6 +1564,12 @@ 2 2 2 + + + + + + @@ -1446,6 +1591,8 @@ 2 2 11 + + 1 @@ -1473,6 +1620,12 @@ 2 2 2 + + + + + + @@ -1494,6 +1647,8 @@ 2 2 11 + + 1 @@ -1521,6 +1676,12 @@ 2 2 2 + + + + + + @@ -1542,6 +1703,8 @@ 2 2 11 + + 1 @@ -1569,6 +1732,12 @@ 2 2 2 + + + + + + @@ -1590,6 +1759,8 @@ 2 2 11 + + 1 @@ -1617,6 +1788,12 @@ 2 2 2 + + + + + + @@ -1638,6 +1815,8 @@ 2 2 11 + + 1 @@ -1665,6 +1844,12 @@ 2 2 2 + + + + + + @@ -1686,6 +1871,8 @@ 2 2 11 + + 1 @@ -1713,6 +1900,12 @@ 2 2 2 + + + + + + @@ -1734,8 +1927,8 @@ 2 2 11 - - + + 1 @@ -1765,9 +1958,9 @@ 2 --diag_suppress=177 - - - + + + @@ -1782,10 +1975,10 @@ 2 1 - - - - + + + + @@ -1819,18 +2012,20 @@ + - + - + - + - + + @@ -1839,5 +2034,5 @@ -
+
diff --git a/MDK-ARM/build_log.txt b/MDK-ARM/build_log.txt index 01655a2..de5a427 100644 --- a/MDK-ARM/build_log.txt +++ b/MDK-ARM/build_log.txt @@ -1,71 +1,71 @@ *** Using Compiler 'V5.06 update 7 (build 960)', folder: 'C:\Keil_v5\ARM\ARMCC\Bin' Rebuild target 'STM32F407-Demo' assembling startup_stm32f407xx.s... -compiling crc.c... compiling ringbuf.c... +compiling crc.c... +compiling stm32f4xx_it.c... compiling i2c.c... compiling stm32f4xx_hal_msp.c... -compiling stm32f4xx_hal_timebase_tim.c... -compiling spi.c... compiling gpio.c... +compiling usart.c... +compiling spi.c... +compiling stm32f4xx_hal_timebase_tim.c... compiling stm32f4xx_hal_rcc_ex.c... +compiling stm32f4xx_hal_flash_ex.c... compiling dma.c... compiling app_main.c... -compiling stm32f4xx_it.c... -compiling stm32f4xx_hal_flash_ex.c... -compiling stm32f4xx_hal_flash_ramfunc.c... compiling sys_clock.c... -compiling usart.c... +compiling stm32f4xx_hal_flash_ramfunc.c... compiling stm32f4xx_hal_gpio.c... -compiling adc_task.c... compiling stm32f4xx_hal_flash.c... +compiling stm32f4xx_hal_rcc.c... +compiling adc_task.c... compiling rs485_task.c... -compiling main.c... compiling stm32f4xx_hal_tim_ex.c... +compiling main.c... compiling net_task.c... compiling freertos.c... -compiling stm32f4xx_hal_rcc.c... compiling stm32f4xx_hal_tim.c... -compiling system_stm32f4xx.c... -compiling sd2506.c... -compiling stm32f4xx_hal_pwr.c... -compiling lftpd_inet.c... -compiling stm32f4xx_hal_i2c_ex.c... compiling stm32f4xx_hal_dma.c... compiling stm32f4xx_hal_pwr_ex.c... -compiling stm32f4xx_hal.c... -compiling stm32f4xx_hal_exti.c... +compiling system_stm32f4xx.c... +compiling stm32f4xx_hal_i2c_ex.c... compiling stm32f4xx_hal_cortex.c... -compiling rs485.c... -compiling lftpd_io.c... -compiling ch395f.c... -compiling nand_ftl.c... compiling stm32f4xx_hal_dma_ex.c... +compiling rs485.c... +compiling stm32f4xx_hal.c... +compiling stm32f4xx_hal_pwr.c... +compiling stm32f4xx_hal_exti.c... +compiling lftpd_io.c... +compiling sd2506.c... compiling tpafe5160.c... compiling lftpd_string.c... -compiling net_select.c... +compiling nand_ftl.c... +compiling ch395f.c... compiling gd5f2gq5ue.c... compiling stm32f4xx_hal_uart.c... +compiling net_select.c... +compiling lftpd_inet.c... compiling stm32f4xx_hal_spi.c... -compiling lftpd.c... compiling croutine.c... compiling ch395f_test.c... compiling event_groups.c... compiling list.c... +compiling lftpd.c... compiling net_socket.c... +compiling stm32f4xx_hal_i2c.c... compiling stream_buffer.c... compiling queue.c... compiling timers.c... compiling heap_4.c... -compiling stm32f4xx_hal_i2c.c... -compiling tasks.c... compiling map.c... +compiling tasks.c... compiling journal.c... compiling port.c... compiling ff.c... compiling cmsis_os2.c... linking... -Program Size: Code=57652 RO-data=2132 RW-data=392 ZI-data=54848 +Program Size: Code=57728 RO-data=2132 RW-data=392 ZI-data=54848 FromELF: creating hex file... ".\STM32F407-Demo\STM32F407-Demo.axf" - 0 Error(s), 0 Warning(s). -Build Time Elapsed: 00:00:19 +Build Time Elapsed: 00:00:18 diff --git a/Src/freertos.c b/Src/freertos.c index edb419f..1448d9b 100644 --- a/Src/freertos.c +++ b/Src/freertos.c @@ -301,6 +301,7 @@ void StartNetTask(void *argument) __weak void StartFtpTask(void *argument) { /* USER CODE BEGIN StartFtpTask */ + osDelay(7000); lftpd_t ftp; lftpd_start("/", 21, &ftp); /* USER CODE END StartFtpTask */