Hi Jan,
I encountered memory problems in the beginning (cpu hang - insufficient heap memory) but after little tuning the application works well.
Sometimes when Server Hello message is delayed a bit (what I'm contantly observing on Wireshark) handshake will just end with WANT_READ error before it could even read this message.
Also I don't see any memory problems on mbedTLS debug and no errors on lwip_stats.
Please look at logs below. I'm attaching also Wireshark packets with Handshake beginning. Packet 6510 is a client hello message (compared with Wireshark). Look when it is ready, and when it is sent out on interface - just after returning error on parsing Server Hello which couldn't be there as Client Hello is still in buffer!
This is why I supposed threading problems.
tcp_output_segment: 6509:6509
tcp_enqueue_flags: queueing 6509:6510 (0x2)
+-+-+-+-+-+-+-+-+-+-+-+-+-+- tcp_input: flags -+-+-+-+-+-+-+-+-+-+-+-+-+-+
tcp_parseopt: MSS
SYN-SENT: ackno 6510 pcb->snd_nxt 6510 unacked 6509
=> handshake
client state: 0
=> flush output
<= flush output
client state: 1
=> flush output
<= flush output
=> write client hello
client hello, max version: [3:3]
client hello, session id len.: 0
client hello, add ciphersuite: c030
client hello, got 1 ciphersuites (excluding SCSVs)
adding EMPTY_RENEGOTIATION_INFO_SCSV
client hello, compress len.: 1
client hello, compress alg.: 0
client hello, adding signature_algorithms extension
client hello, adding supported_elliptic_curves extension
client hello, adding supported_point_formats extension
client hello, adding session ticket extension
client hello, total extension length: 48
=> write handshake message
=> write record
output record: msgtype = 22, version = [3:3], msglen = 97
=> flush output
message length: 102, out_left: 102
tcp_write(address@hidden, address@hidden, len=102, apiflags=1)
tcp_write: queueing 6510:6612
ssl->f_send() returned 102 (-0xffffff9a)
<= flush output
<= write record
<= write handshake message
<= write client hello
client state: 2
=> flush output
<= flush output
=> parse server hello
=> read record
=> fetch input
in_left: 0, nb_want: 5
while( ssl->in_left < nb_want )
f_recv
in_left: 0, nb_want: 5, ret: -26880
<= handshake
tcp_output_segment: 6510:6612