diff --git a/examples/stm32/nucleo-f746zg-make-freertos-tcp/FreeRTOSConfig.h b/examples/stm32/nucleo-f746zg-make-freertos-tcp/FreeRTOSConfig.h index 75960f44..06480113 100644 --- a/examples/stm32/nucleo-f746zg-make-freertos-tcp/FreeRTOSConfig.h +++ b/examples/stm32/nucleo-f746zg-make-freertos-tcp/FreeRTOSConfig.h @@ -1,4 +1,5 @@ #pragma once +#define FREERTOS_CONFIG_H #include "hal.h" diff --git a/examples/stm32/nucleo-f746zg-make-freertos-tcp/FreeRTOSIPConfig.h b/examples/stm32/nucleo-f746zg-make-freertos-tcp/FreeRTOSIPConfig.h index d1adf6f7..b1a8ec92 100644 --- a/examples/stm32/nucleo-f746zg-make-freertos-tcp/FreeRTOSIPConfig.h +++ b/examples/stm32/nucleo-f746zg-make-freertos-tcp/FreeRTOSIPConfig.h @@ -128,13 +128,9 @@ stack. FreeRTOS includes optional stack overflow detection, see: http://www.freertos.org/Stacks-and-stack-overflow-checking.html */ #define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 ) -/* ipconfigRAND32() is called by the IP stack to generate random numbers for -things such as a DHCP transaction number or initial sequence number. Random -number generation is performed via this macro to allow applications to use their -own random number generation method. For example, it might be possible to -generate a random number by sampling noise on an analogue input. */ -extern UBaseType_t uxRand(); -#define ipconfigRAND32() uxRand() +/* ipconfigRAND32() is no longer valid. See xApplicationGetRandomNumber() instead +https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/API/xApplicationGetRandomNumber.html +*/ /* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the network event hook at the appropriate times. If ipconfigUSE_NETWORK_EVENT_HOOK @@ -165,6 +161,7 @@ set to 1 if a valid configuration cannot be obtained from a DHCP server for any reason. The static configuration used is that passed into the stack by the FreeRTOS_IPInit() function call. */ #define ipconfigUSE_DHCP 1 +#define ipconfigUSE_DHCP_HOOK 0 /* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at increasing time intervals until either a reply is received from a DHCP server diff --git a/examples/stm32/nucleo-f746zg-make-freertos-tcp/Makefile b/examples/stm32/nucleo-f746zg-make-freertos-tcp/Makefile index eaf2cb96..9d2e7ab3 100644 --- a/examples/stm32/nucleo-f746zg-make-freertos-tcp/Makefile +++ b/examples/stm32/nucleo-f746zg-make-freertos-tcp/Makefile @@ -56,9 +56,9 @@ cmsis_core: # ARM CMSIS core headers cmsis_f7: # ST CMSIS headers for STM32F7 series git clone --depth 1 -b v1.2.8 https://github.com/STMicroelectronics/cmsis_device_f7 $@ FreeRTOS-Kernel: # FreeRTOS sources - git clone --depth 1 -b V10.5.0 https://github.com/FreeRTOS/FreeRTOS-Kernel $@ + git clone --depth 1 -b V11.1.0 https://github.com/FreeRTOS/FreeRTOS-Kernel $@ FreeRTOS-TCP: # FreeRTOS-Plus-TCP sources - git clone --depth 1 -b V3.1.0 https://github.com/FreeRTOS/FreeRTOS-Plus-TCP $@ + git clone --depth 1 -b V4.1.0 https://github.com/FreeRTOS/FreeRTOS-Plus-TCP $@ # Automated remote test. Requires env variable VCON_API_KEY set. See https://vcon.io/automated-firmware-tests/ DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/5 diff --git a/examples/stm32/nucleo-f746zg-make-freertos-tcp/main.c b/examples/stm32/nucleo-f746zg-make-freertos-tcp/main.c index 707d1524..b0e36be0 100644 --- a/examples/stm32/nucleo-f746zg-make-freertos-tcp/main.c +++ b/examples/stm32/nucleo-f746zg-make-freertos-tcp/main.c @@ -70,12 +70,13 @@ static void blinker(void *args) { (void) args; } -// https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial_Initialising_TCP.html -void vApplicationIPNetworkEventHook(eIPCallbackEvent_t ev) { +// https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial_Initialising_TCP.updated.html +void vApplicationIPNetworkEventHook_Multi(eIPCallbackEvent_t ev, struct xNetworkEndPoint *ep) { static bool mongoose_started = false; MG_INFO(("FreeRTOS-Plus-TCP net event: %d", ev)); if (ev == eNetworkUp && mongoose_started == false) { - uint32_t ip = FreeRTOS_GetIPAddress(); + uint32_t ip; + FreeRTOS_GetEndPointConfiguration(&ip, NULL, NULL, NULL, ep); MG_INFO(("READY, IP: %M", mg_print_ip4, &ip)); xTaskCreate(server, "server", 2048, 0, configMAX_PRIORITIES - 1, NULL); mongoose_started = true; @@ -91,7 +92,16 @@ int main(void) { static const uint8_t netmask[4] = {255, 255, 255, 0}; static const uint8_t dnsaddr[4] = {8, 8, 8, 8}; static const uint8_t gwaddr[4] = {192, 168, 0, 1}; - FreeRTOS_IPInit(ipaddr, netmask, gwaddr, dnsaddr, macaddr); + static NetworkInterface_t ifcs[1]; + static NetworkEndPoint_t eps[1]; + extern NetworkInterface_t *pxSTM32Fxx_FillInterfaceDescriptor( + BaseType_t, NetworkInterface_t *); + + pxSTM32Fxx_FillInterfaceDescriptor(0, &(ifcs[0])); + FreeRTOS_FillEndPoint(&(ifcs[0]), &(eps[0]), ipaddr, netmask, gwaddr, dnsaddr, + macaddr); + eps[0].bits.bWantDHCP = pdTRUE; + FreeRTOS_IPInit_Multi(); MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, macaddr)); // Start tasks. NOTE: stack sizes are in 32-bit words diff --git a/mongoose.h b/mongoose.h index 3b137349..e6a5ce6e 100644 --- a/mongoose.h +++ b/mongoose.h @@ -549,7 +549,6 @@ int sscanf(const char *, const char *, ...); #include #include -#include // contents to be moved and file removed, some day #define MG_SOCKET_TYPE Socket_t #define MG_INVALID_SOCKET FREERTOS_INVALID_SOCKET @@ -581,6 +580,7 @@ int sscanf(const char *, const char *, ...); #define sockaddr_in freertos_sockaddr #define sockaddr freertos_sockaddr +#define sin_addr sin_address.ulIP_IPv4 #define accept(a, b, c) FreeRTOS_accept((a), (b), (c)) #define connect(a, b, c) FreeRTOS_connect((a), (b), (c)) #define bind(a, b, c) FreeRTOS_bind((a), (b), (c)) diff --git a/src/net_ft.h b/src/net_ft.h index 9679605b..d00c3b9a 100644 --- a/src/net_ft.h +++ b/src/net_ft.h @@ -7,7 +7,6 @@ #include #include -#include // contents to be moved and file removed, some day #define MG_SOCKET_TYPE Socket_t #define MG_INVALID_SOCKET FREERTOS_INVALID_SOCKET @@ -39,6 +38,7 @@ #define sockaddr_in freertos_sockaddr #define sockaddr freertos_sockaddr +#define sin_addr sin_address.ulIP_IPv4 #define accept(a, b, c) FreeRTOS_accept((a), (b), (c)) #define connect(a, b, c) FreeRTOS_connect((a), (b), (c)) #define bind(a, b, c) FreeRTOS_bind((a), (b), (c))