Update to latest FreeRTOS+TCP

This commit is contained in:
Sergio R. Caprile 2024-05-30 11:22:32 -03:00
parent 0f9f0b545e
commit aa3fda9c33
6 changed files with 23 additions and 15 deletions

View File

@ -1,4 +1,5 @@
#pragma once #pragma once
#define FREERTOS_CONFIG_H
#include "hal.h" #include "hal.h"

View File

@ -128,13 +128,9 @@ stack. FreeRTOS includes optional stack overflow detection, see:
http://www.freertos.org/Stacks-and-stack-overflow-checking.html */ http://www.freertos.org/Stacks-and-stack-overflow-checking.html */
#define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 ) #define ipconfigIP_TASK_STACK_SIZE_WORDS ( configMINIMAL_STACK_SIZE * 5 )
/* ipconfigRAND32() is called by the IP stack to generate random numbers for /* ipconfigRAND32() is no longer valid. See xApplicationGetRandomNumber() instead
things such as a DHCP transaction number or initial sequence number. Random https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/API/xApplicationGetRandomNumber.html
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()
/* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+TCP will call the /* 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 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 reason. The static configuration used is that passed into the stack by the
FreeRTOS_IPInit() function call. */ FreeRTOS_IPInit() function call. */
#define ipconfigUSE_DHCP 1 #define ipconfigUSE_DHCP 1
#define ipconfigUSE_DHCP_HOOK 0
/* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at /* 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 increasing time intervals until either a reply is received from a DHCP server

View File

@ -56,9 +56,9 @@ cmsis_core: # ARM CMSIS core headers
cmsis_f7: # ST CMSIS headers for STM32F7 series cmsis_f7: # ST CMSIS headers for STM32F7 series
git clone --depth 1 -b v1.2.8 https://github.com/STMicroelectronics/cmsis_device_f7 $@ git clone --depth 1 -b v1.2.8 https://github.com/STMicroelectronics/cmsis_device_f7 $@
FreeRTOS-Kernel: # FreeRTOS sources 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 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/ # 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 DEVICE_URL ?= https://dash.vcon.io/api/v3/devices/5

View File

@ -70,12 +70,13 @@ static void blinker(void *args) {
(void) args; (void) args;
} }
// https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial_Initialising_TCP.html // https://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/TCP_Networking_Tutorial_Initialising_TCP.updated.html
void vApplicationIPNetworkEventHook(eIPCallbackEvent_t ev) { void vApplicationIPNetworkEventHook_Multi(eIPCallbackEvent_t ev, struct xNetworkEndPoint *ep) {
static bool mongoose_started = false; static bool mongoose_started = false;
MG_INFO(("FreeRTOS-Plus-TCP net event: %d", ev)); MG_INFO(("FreeRTOS-Plus-TCP net event: %d", ev));
if (ev == eNetworkUp && mongoose_started == false) { 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)); MG_INFO(("READY, IP: %M", mg_print_ip4, &ip));
xTaskCreate(server, "server", 2048, 0, configMAX_PRIORITIES - 1, NULL); xTaskCreate(server, "server", 2048, 0, configMAX_PRIORITIES - 1, NULL);
mongoose_started = true; mongoose_started = true;
@ -91,7 +92,16 @@ int main(void) {
static const uint8_t netmask[4] = {255, 255, 255, 0}; static const uint8_t netmask[4] = {255, 255, 255, 0};
static const uint8_t dnsaddr[4] = {8, 8, 8, 8}; static const uint8_t dnsaddr[4] = {8, 8, 8, 8};
static const uint8_t gwaddr[4] = {192, 168, 0, 1}; 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)); MG_INFO(("MAC: %M. Waiting for IP...", mg_print_mac, macaddr));
// Start tasks. NOTE: stack sizes are in 32-bit words // Start tasks. NOTE: stack sizes are in 32-bit words

View File

@ -549,7 +549,6 @@ int sscanf(const char *, const char *, ...);
#include <FreeRTOS_IP.h> #include <FreeRTOS_IP.h>
#include <FreeRTOS_Sockets.h> #include <FreeRTOS_Sockets.h>
#include <FreeRTOS_errno_TCP.h> // contents to be moved and file removed, some day
#define MG_SOCKET_TYPE Socket_t #define MG_SOCKET_TYPE Socket_t
#define MG_INVALID_SOCKET FREERTOS_INVALID_SOCKET #define MG_INVALID_SOCKET FREERTOS_INVALID_SOCKET
@ -581,6 +580,7 @@ int sscanf(const char *, const char *, ...);
#define sockaddr_in freertos_sockaddr #define sockaddr_in freertos_sockaddr
#define sockaddr freertos_sockaddr #define sockaddr freertos_sockaddr
#define sin_addr sin_address.ulIP_IPv4
#define accept(a, b, c) FreeRTOS_accept((a), (b), (c)) #define accept(a, b, c) FreeRTOS_accept((a), (b), (c))
#define connect(a, b, c) FreeRTOS_connect((a), (b), (c)) #define connect(a, b, c) FreeRTOS_connect((a), (b), (c))
#define bind(a, b, c) FreeRTOS_bind((a), (b), (c)) #define bind(a, b, c) FreeRTOS_bind((a), (b), (c))

View File

@ -7,7 +7,6 @@
#include <FreeRTOS_IP.h> #include <FreeRTOS_IP.h>
#include <FreeRTOS_Sockets.h> #include <FreeRTOS_Sockets.h>
#include <FreeRTOS_errno_TCP.h> // contents to be moved and file removed, some day
#define MG_SOCKET_TYPE Socket_t #define MG_SOCKET_TYPE Socket_t
#define MG_INVALID_SOCKET FREERTOS_INVALID_SOCKET #define MG_INVALID_SOCKET FREERTOS_INVALID_SOCKET
@ -39,6 +38,7 @@
#define sockaddr_in freertos_sockaddr #define sockaddr_in freertos_sockaddr
#define sockaddr freertos_sockaddr #define sockaddr freertos_sockaddr
#define sin_addr sin_address.ulIP_IPv4
#define accept(a, b, c) FreeRTOS_accept((a), (b), (c)) #define accept(a, b, c) FreeRTOS_accept((a), (b), (c))
#define connect(a, b, c) FreeRTOS_connect((a), (b), (c)) #define connect(a, b, c) FreeRTOS_connect((a), (b), (c))
#define bind(a, b, c) FreeRTOS_bind((a), (b), (c)) #define bind(a, b, c) FreeRTOS_bind((a), (b), (c))