CycloneTCP Migration Guide
CycloneTCP Migration Guide
//Dependencies
#include "core/net.h"
• The following functions are deprecated. It is highly recommended (but not mandatory)
to switch to the new API instead. The legacy API is still available to maintain
compatibility with existing projects:
• http_server.c
• http_server_auth.c
• http_server_misc.c
The HTTP server does not longer create/delete tasks dynamically. All the necessary
resources (including client tasks) are created statically at startup (in httpServerInit and
httpServerStart functions). Your Web server initialization routine shall be modified as follows
to allocate these resources statically:
//Dependencies
#include "net.h"
#include "http_server.h"
//Global variables
HttpServerContext httpServerContext;
HttpConnection httpConnections[APP_HTTP_MAX_CONNECTIONS];
//Local variables
HttpServerSettings httpServerSettings;
All the device drivers includes a new field that identify the type of device :
All driver structures also feature the link MTU (1500 bytes for Ethernet)
/**
* @brief STM32F407/417/427/437 Ethernet MAC driver
**/
• common
• cyclone_tcp
• cyclone_ssl (if applicable)
• cyclone_crypto (if applicable)
As a consequence, you may have to change the include directives in your source code files.
For example, replace the following include directives:
//Dependencies
#include "tcp_ip_stack.h"
#include "stm32f4x7_eth.h"
#include "dp83848.h"
#include "dhcp_client.h"
#include "slaac.h"
#include "http_server.h"
#include "mime.h"
//Dependencies
#include "core/tcp_ip_stack.h"
#include "drivers/stm32f4x7_eth.h"
#include "drivers/dp83848.h"
#include "dhcp/dhcp_client.h"
#include "ipv6/slaac.h"
#include "http/http_server.h"
#include "http/mime.h"
Note that a new file (compiler_port.h) has been added in the common/ directory. You can
add this file to your project.
Because of name collision with CMSIS-RTOS, the entire API has been renamed. This brand
new RTOS abstraction layer also makes the process of porting of the TCP/IP stack to new
operating systems easier.
Normally, the RTOS abstraction layer is only used internally. Thus, this modification shall not
impact users. However, if you make use of some of the functions of the RTOS abstraction
layer, you have to switch to the new functions :
To make the TCP/IP stack portable among various RTOS environments, the Ethernet drivers
now configure all the priority bits of the Cortex-M core to pre-emption priority (no bits for
subpriority). You can change this default behavior, by overriding some properties in your
tcp_ip_stack_config.h configuration file.
For instance, if you use the STM32F4x7 Ethernet MAC driver, you can override the following
properties with the desired settings:
• STM32F4X7_ETH_IRQ_PRIORITY_GROUPING
• STM32F4X7_ETH_IRQ_GROUP_PRIORITY
• STM32F4X7_ETH_IRQ_SUB_PRIORITY
• getHostByName prototype has been simplified. The 4th and the 5th parameters have been
removed. Please read the user manual to get more details about this function.
IpAddr ipAddr;
• Add a new file to your project os_port_config.h. This file shall contain
#define USE_FREERTOS
• Add one of the following FreeRTOS files to your project in order to manage memory
allocation. The files can be copied from demo\common\freertos\portable\memmang
File Description
heap_1.c The simplest possible implementation of pvPortMalloc(). Note that this
implementation does not allow allocated memory to be freed again
heap_2.c A simple implementation of pvPortMalloc() and vPortFree() that permits
allocated blocks to be freed, but does not combine adjacent free blocks
into a single larger block (and so will fragment memory)
heap_3.c Implementation of pvPortMalloc() and vPortFree() that relies on the
compiler own malloc() and free() implementations
heap_4.c A sample implementation of pvPortMalloc() and vPortFree() that
combines (coalescences) adjacent memory blocks as they are freed,
and in so doing limits memory fragmentation.
Using heap_3.c maintains compatibility with existing projects (linker files are not required to
be changed using this file).
If you consider using heap_4.c, please update FreeRTOS configuration header by settings
the desired heap size (configTOTAL_HEAP_SIZE compilation flag)
void main(void)
{
//...
//...
}
void main(void)
{
MacAddr macAddr;
//...
//...
}
• dhcpClientInit must be called to initialize the DHCP client. When the code returns from
dhcpClientInit, the DHCP client is not yet running. For that purpose your must call the
dhcpClientStart function
void main(void)
{
//Settings structure can be a local variable
DhcpClientSettings dhcpClientSettings;
//...
//...
}
//...
//Manual configuration
interface = &netInterface[0];
//IPv4 address
ipv4StringToAddr("192.168.0.20", &interface->ipv4Config.addr);
//Subnet mask
ipv4StringToAddr("255.255.255.0", &interface->ipv4Config.subnetMask);
//Default gateway
ipv4StringToAddr("192.168.0.254", &interface >ipv4Config.defaultGateway);
//...
Ipv4Addr ipv4Addr;
//...
//...
//...
//...
//Prefix
interface->ipv6Config.prefixLength = 64;
ipv6StringToAddr("1122:3344:5566:7788::", &interface->ipv6Config.prefix);
//Global address
ipv6StringToAddr("1122:3344:5566:7788::abcd",
&interface->ipv6Config.globalAddr);
//Router
ipv6StringToAddr("fe80::eeff", &interface->ipv6Config.router);
Ipv6Addr ipv6Addr;
//...
//Set router
ipv6StringToAddr("fe80::eeff", &ipv6Addr);
ipv6SetRouter(interface, &ipv6Addr);
void main(void)
{
//Settings structure can be a local variable
HttpServerSettings httpServerSettings;
//...
//...
}