[Libwebsockets] LWS on the Texas Instruments SimpleLink CC3220.

Ralph Corderoy ralph at inputplus.co.uk
Sun May 17 14:03:40 CEST 2020


Hi,

I've the ‘good fortune’ to be writing some code on TI's SimpleLink
CC3220SF chip on a LaunchPad CC3220SFMODASF development board.  It has
multiple ARM Cortex CPUs in it.  My code runs on a ‘host’ Cortex-M4 and
the project is using FreeRTOS.  A second processor is the ‘network
processor’ running closed-source TI software; my first foray with closed
source in a long time.  It is between me on the host CPU and the MAC and
PHY which give Wi-Fi.  TI provide source to run on the host which
interfaces to the network CPU giving a socket API and high-level
concepts, e.g. a HTTP server, with the network CPU doing all the work.
The network processor also provides crypto facilities, including the
storage of certs and secrets, with tamper detection, etc.

Unusually, TLS is built into the sockets API with a struct pointer on
some socket operations indicating things like TLS 1.2 is required, the
ciphers which are acceptable, etc, rather than be a separate thing
layered on top.  (TI say this is to make it more awkward to accidentally
have a plain-text connection.) 

It follows from the above that FreeRTOS is providing threading, a heap,
..., but not a TCP/IP stack.

Having spent a lot of time trying to use one TI-provided feature after
another, I keep arriving back at Go, without collecting £200.  For
example, the network CPU's HTTP server does not allow a body to be
specified in reply to a POST request!  (This is ‘documented’ by one line
on page 194 of the 312-page Network Processor Programmer's Guide PDF.)

My need is to have a TLS HTTP server which will have a limited chat to
an app on the WLAN to ‘provision’, i.e. tell me what I need to know to
use the user's access point.  After that, I make a TLS HTTP client
connection to a cloud server, promptly upgrade to a WebSocket, and chat
away.  I was wondering how much effort it would be to port LWS to this
platform to get that functionality.

I've downloaded and searched the mailing-list archive for any mentions
of Texas Instruments, SimpleLink, or a CC3[23]xx chip, and found
nothing.  (BTW, there are lots of duplicate, or almost identical, emails
in the archive; 4,577 unique ones.)

I see
https://libwebsockets.org/git/libwebsockets/tree/minimal-examples/raw/minimal-raw-adopt-tcp
might be a half-way house where I use TI's code to get the TLS
connection ‘file descriptor’ which is then adopted by LWS; presumably
with TI taking care of things like renegotiation and LWS treating it as
a plain-text connection.  This may be easier than teaching LWS about the
unusual merged socket+TLS API.

I wouldn't want to move TLS to the host processor as this code runs off
battery and gains from the network-CPU's hardware having crypto support.

So overall, I'm wondering if LWS is a good fit, and whether the amount
of porting labour required would be less than implementing HTTP client,
HTTP server, and WebSocket myself given I only need to be able to talk
to me on the other side of the ether, not all the implementations in the
world at large.

LWS looks like a nicely designed and coded piece of work so even if it's
not suitable for this I'd like to experiment with it in the future once
I'm done with TI.

One last thing.
https://libwebsockets.org/git/libwebsockets/tree/lib/event-libs looks
wrong; it's linked from the home page.

-- 
Cheers, Ralph.


More information about the Libwebsockets mailing list