2025-12-16 11:50 PM
I get two errors from here:
ret = wolfSSL_connect(g_tls.ssl);
if (ret == WOLFSSL_SUCCESS) {
printf("TLS handshake OK\r\n");
g_tls.state = TLS_STATE_TLS_ESTABLISHED;
} else
{
int err = wolfSSL_get_error(g_tls.ssl, ret);
if (err == WOLFSSL_ERROR_WANT_READ ||
err == WOLFSSL_ERROR_WANT_WRITE) {
} else {
printf("TLS handshake failed: %d\r\n", err);
g_tls.state = TLS_STATE_ERROR;
ret = -1 and err = 32
No ClientHello is being sent.
This is how the main looks:
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "lwip/opt.h"
#include "lwip/init.h"
#include "netif/etharp.h"
#include "lwip/netif.h"
#include "lwip/timeouts.h"
#if LWIP_DHCP
#include "lwip/dhcp.h"
#endif
#include "ethernetif.h"
#include "main.h"
#include "app_ethernet.h"
//#include "tcp_echoserver.h"
#include "tls_client.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#if defined(__ICCARM__)
#include <LowLevelIOInterface.h>
#endif /* __ICCARM__ */
#include "tls_client.h"
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
#if defined(__ICCARM__)
/* New definition from EWARM V9, compatible with EWARM8 */
int iar_fputc(int ch);
#define PUTCHAR_PROTOTYPE int iar_fputc(int ch)
#elif defined(__ARMCC_VERSION)
/* ARM Compiler 6*/
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#elif defined(__GNUC__)
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#endif /* __ICCARM__ */
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
struct netif gnetif;
UART_HandleTypeDef UartHandle;
RNG_HandleTypeDef hrng;
/* Private function prototypes -----------------------------------------------*/
static void SystemClock_Config(void);
static void BSP_Config(void);
static void Netif_Config(void);
static void MX_USART1_UART_Init(void);
static void RISAF_Config(void);
static void MPU_Config(void);
static void MX_RNG_Init(void);
/**
* @brief The application entry point.
* @retval int
*/
int main(void) {
/* Configure the MPU */
MPU_Config();
/* Enable the CPU Cache */
/* Enable I-Cache---------------------------------------------------------*/
SCB_EnableICache();
/* Enable D-Cache---------------------------------------------------------*/
SCB_EnableDCache();
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
RISAF_Config();
/* Initialize all configured peripherals */
MX_USART1_UART_Init();
/* Configure the LEDs ...*/
BSP_Config();
printf("TLS 1.3 Handshake \r\n");
printf("STM32N6570 board \r\n");
printf("State: Ethernet Initialization ... \r\n");
/* Initialize the LwIP stack */
lwip_init();
/* Configure the Network interface */
Netif_Config();
/* UDP client connect */
// tcp_echoserver_init();
TLS_GlobalInit();
/* Infinite loop */
ip_addr_t serverIp;
IP4_ADDR(&serverIp, 192,168,50,1);
// TLS_ClientStart(&serverIp, 443);
static int started = 0;
while (1)
{
ethernetif_input(&gnetif);
sys_check_timeouts();
#if LWIP_NETIF_LINK_CALLBACK
Ethernet_Link_Periodic_Handle(&gnetif);
#endif
#if LWIP_DHCP
DHCP_Periodic_Handle(&gnetif);
#endif
if (!started &&
netif_is_up(&gnetif) &&
!ip4_addr_isany_val(*netif_ip4_addr(&gnetif))) {
started = 1;
printf("IP: %s\r\n", ip4addr_ntoa(netif_ip4_addr(&gnetif)));
printf("NM: %s\r\n", ip4addr_ntoa(netif_ip4_netmask(&gnetif)));
printf("GW: %s\r\n", ip4addr_ntoa(netif_ip4_gw(&gnetif)));
ip_addr_t serverIp;
IP4_ADDR(&serverIp, 192,168,50,1);
TLS_ClientStart(&serverIp, 11111); // besser: Port auf dem dein wolfSSL server wirklich lauscht
}
TLS_ClientProcess();
}
I used this as base:
https://github.com/ABESTM/stm32n6-classic-coremw-apps/tree/main/Projects/STM32N6570-DK/Applications/LwIP/LwIP_TCP_Echo_Server
I had to make modifications to the linker script, as it was only limited to the fsbl RAM.
2025-12-16 11:56 PM
The TCP Handshake works, so it is connected to the server, but like I wrote, it is not starting the TLS Handshake.