FreeRTOS-PLUS-TCP: Ethernet installation with DHCP enable and TCP server

OK perfect. I’ll try asap and then I’ll let you know. Many thanks Htibosch

Hi Htibosch, wherw do I found the file like “ff_time.h”? where is this folder with this all files? thanks

Hello @fraGu, you can find the FreeRTOS+FAT time module here.

As neither FreeRTOS, nor FreeRTTOS+FAT have a notion of the real time, you have to provide this function:

time_t FreeRTOS_time( time_t * pxTime );

My FreeRTOS_time() module/function will lookup the NTP time every xx minutes, and return an estimate of the real time when called. The reason is: I don’t want the FreeRTOS_time() function to cause a delay.

I didn’t like to interfere with the existing time() function, because doing so will often cause confusion.

Remember that time() returns a time that has nothing to do with time zones or DST, it returns the current Coordinated Universal Time (UTC).

Hi Htibosch, ok perfect. I tested the ramdisk on my board and seem all ok. I installed 128K of fat on my ram memory. Do you have an example for installing the fat on internal flash memory? how do I setting the parameter ffconfigDEV_SUPPORT? Many thanks

Hi Htibosch, I try to installed the http server and now seem all ok. The HTTP server working fine with first simple commands.

Can I have a help for HTTPS? are there some example about https with freeRTOS? I need to installed a security http server…Many thanks

When enabled, ffconfigDEV_SUPPORT will allow you to make a FAT system with multiple drives. The drives are not numbered 1 2 3, neither A: B: and C:
The drives are named like :

    /flash
    /temp
    /ram

There is a +FAT driver for RAM, for several SD-card devices, but (as far as I know) not for flash.

But once you have created a flash volume, you can tread it as a RAM drive.

Can I have a help for HTTPS? are there some example about https with freeRTOS? I need to installed a security http server…Many thanks

I can recommend either WolfSSL or embed TLS. I’m about to do a project with https, so we might join forces.

Hio Htibosch
I will try to use the flash as the ram for the ramdisk. In fact I need a fat for the flash without sd.

About the HTTPS, for now I will start to see with the WolfSSL and then I will ask you for help. Then if you need anything from my development let me know.

In the folder WolfSSL, what is the example that you recommend for my stm32h735 board?

Many thanks and very kind as always.

Hi Htibosh,
can you tell me if this init code below for wolfssl is ok? Can you give me please some example of CA, cert and key to exchange with client for https? Thanks

		ret = WOLFSSL_FAILURE;
		xConnectedSocket = FreeRTOS_accept(xListeningSocket, &xClient, &xSize);
		configASSERT(xConnectedSocket != FREERTOS_INVALID_SOCKET);

		/* Create WOLFSSL_CTX object */
		ctx = wolfSSL_CTX_new(wolfTLSv1_2_server_method());

		/* Load server certificates into WOLFSSL_CTX */
		if (ctx == NULL) {
			printf("Error: wolfSSL_CTX_new.\n");
			break;
		}

		/* set callback functions for send and receive into context ctx */
		wolfSSL_CTX_SetIOSend(ctx, EmbedSend);
		wolfSSL_CTX_SetIORecv(ctx, EmbedReceive);

        ret = wolfSSL_CTX_load_verify_buffer(ctx, CA_BUF, SIZEOF_CA_BUF,
				 	 	 	 	 	 	 	 SSL_FILETYPE_ASN1);
		if (ret != WOLFSSL_SUCCESS) {
			printf("Error [%d]: wolfSSL_CTX_load_verify_buffer.\n",ret);
			break;
		}


		ret = wolfSSL_CTX_use_certificate_buffer(ctx, CERT_BUF, SIZEOF_CERT_BUF,
												 SSL_FILETYPE_ASN1);
		/* Load server key into WOLFSSL_CTX */
		if (ret != WOLFSSL_SUCCESS) {
			printf("Error [%d]: wolfSSL_CTX_use_certificate_buffer.\n",ret);
			break;
		}

		ret = wolfSSL_CTX_use_PrivateKey_buffer(ctx, KEY_BUF, SIZEOF_KEY_BUF,
												SSL_FILETYPE_ASN1);
		/* Create a WOLFSSL object */
		if (ret != WOLFSSL_SUCCESS) {
			printf("Error [%d]: wolfSSL_CTX_use_PrivateKey_buffer.\n",ret);
			break;
		}

		ssl = wolfSSL_new(ctx);
		/* Attach wolfSSL to the socket */
		if (ssl == NULL) {
			printf("Error: wolfSSL_new.\n");
			break;
		}

		ret = wolfSSL_set_fd(ssl, (int) xConnectedSocket);
		/* Establish TLS connection */
		if (ret != WOLFSSL_SUCCESS) {
			printf("Error [%d]: wolfSSL_set_fd.\n",ret);
			break;
		}

		ret = wolfSSL_accept(ssl);
		/* Read the client data into our buff array */
		if (ret != WOLFSSL_SUCCESS) {
			printf("Error [%d]: wolfSSL_set_fd.\n",ret);
			break;
		}

I’d recommend to reach out to WolfSSL maintainers for WolfSSL related questions as you are likely to get better responses there.

ok thank you for your response

You’re on the right track with your FreeRTOS and Ethernet setup. For DHCP and TCP server configurations, double-check that all necessary libraries are correctly included and settings are adjusted. Additionally, using a shipment tracker like traceshipments. com can help you monitor the delivery of critical components and avoid delays. This ensures that you have all the necessary resources on time for smooth development and testing.

Hi Jhoney, seem ok now but I have last question about freeRTOS Ethernet. With your library into STM32H735 board, how can use data and instruction cache? is it possible enable or need disable this config about cache of micro? Thanks

Hi Jhoney, do you have news about my last question? how need setting instruction and data cache for use correctly freeRTOS-TCP? For now in my uses case with data cache enable the Ethernet not working correctly…Thanks

This seems related to ST and I’d suggest to reach out to them. I found this link which you may find useful - https://community.st.com/t5/stm32-mcus/how-to-create-a-project-for-stm32h7-with-ethernet-and-lwip-stack/ta-p/49308.

Hi Aggarg, with lwip stack Ethernet working fine with data and instruction cache enable. If I want use your stack Ethernet freeRTOS-TCP with data cache enable then not working. I want to know how working your buffer Ethernet (ram? DMA? need some flush cache? other particular things?). Thanks

@FraGu AFAIK, we haven’t tested the STM32H7 network interface with D-cache enabled. You would need to specify MPU region for network buffers and mark that area as non-cacheable. @tony-josi-aws @Shub can you please confirm. Thanks.

I have not tested STM32H7 network interface with D-cache enabled.

Which network buffer allocation scheme are you using, BufferAllocation1 or BufferAllocation2? With buffer allocation 1, you can specify where to place the network buffers and their alignment, instead of getting them allocated via heap APIs.

You can also check where the lwip project places the DMA TX and RX descriptors in the linker file and keep the same settings for the decriptors used in FreeRTOS+TCP project.

If you are planning to use network buffer storage areas with D-cache enabled, you need to verify that ETH_RX_BUF_SIZE is defined to a size thats aligned to the cache line size of your device, which I believe is 32 bits as per this document.. Also make sure the ipconfigBUFFER_PADDING is also a 32 bit aligned value.

1 Like

Hi Tony, I used bufferallocation2…I’ll following your suggestion and test again the Ethernet with data cache enable. I let you know asap. Thanks

Hi @FraGu ,

We usually recommend having Ethernet buffers in non-cached regions as the least error prone path. Even in systems where D-cache is enabled we should define an un-cached region to hold the network buffers.

The reason being that a process involving DMA needs cache coherency. Hence, if Dcache is enabled and network buffers are in cached regions, each packet would need a memory barrier or cache flush/invalidate operation in both receive and transmit directions. This will be a huge overhead to the Ethernet performance as it’s a per packet operation and hence we don’t validate with D-cache enabled. However, surely a way can be figured out if D-cache enabling is a must. However, in that case the system designer should be prepared to have a performance hit because of the per packet cache operations.

ok understand. Which is the dma of ethernet? Thanks