Finally got back to this after a couple of months of fire fighting and have some additional info to capture.
First, my device actually has the MCF5328, not the 29 as I said in my OP. I must have been trying to use the 29 because the NanoSSL bean didnt show up when I selected the 28 - could be because the 28 does not have a crypto acceleration unit (CAU). The lack of CAU does explain the crash I initially saw when the code tried to initialize the CAU.
I discovered that the status bar of the Bean Selector dialog has a Filter which says "for MCF5328 only". I click the text and it removes the filter allowing the NanoSSL bean to show up in the list. Generating code seemed to work better if I actually removed the CPU bean, added the NanoSSL bean then added the 5328 CPU bean.
After generating code for the bean, I loaded my real project into CW and dragged the Generated_Code folder from the bean project tree to the real project tree and renamed to nanossl. I then did a clean and make on the real project. I get about 60 warnings in the NanoSSL code, most about implicit conversion of data types.
The NanoSSL package has a demo directory but the contents are anything but a simple, straight forward example. Here is what I did to get something basic working. Obviously this is not complete or ready to compile, but it all comes from the mms_common.c/.h and mms_ssl_client.c/.h in the demo folder.
_ssl_init()
{
MOCANA_initMocana()
MOCANA_initLog( param )
SSL_init( 0, 5 )
mss_ssl_ca_mgmt_init_upcalls()
}
_ssl_connect()
{
// resolve host name as necessary
mms_rtcs_connect_socket( &sock, ipaddr, port)
// create socket
// set send timeout, okay at 5000ms
// set recv timeout, okay at 5000ms
// set connect timeout, okay at 30000ms
// don’t seem to need set tx/rx buff sizes
// setup sockaddr_in struct
// call connect()
conn = SSL_connect( sock … ) // get connection instance
SSL_ioctl( SSL_SET_VERSION )
SSL_negotiateConnection( conn )
}
_ssl_getpage()
{
msg = “GET /index.html HTTP/1.0\n\n”;
SSL_send( conn, msg, msglen )
while( receiving )
{
result = SSL_recv( conn, buff, buffsize, &bytes )
if( result >= 0 )
{
// do something with buff and bytes
}else
{
receiving = 0
}
}
}
_ssl_close()
{
SSL_closeConnection( conn )
if( sock != RTCS_SOCKET_ERROR )
{
shutdown( sock, FLAG_ABORT_CONNECTION )
}
}
_ssl_cleanup()
{
MOCANA_freeMocana()
}
_ssl_test()
{
_ssl_init()
while( true == runtest )
{
_ssl_connect()
_ssl_getpage()
_ssl_close()
}
_ssl_cleanup()
}
This is working pretty well with two caveats:
- There seems to be some concurrency issues within the SSL_conect stuff. My app keeps the host name/addr info, the socket and the connection instance in a thread-specific structure. Despite this, I experienced a lot of failed SSL_negotiateConnection()s until I put a mutex around the call to _ssl_connect().
- SSL_negotiateConnection() takes 6-11 seconds to complete. The device completely hangs during that time. I have not found anything that affects the length of delay (for better or worse). I have traced into the NanoSSL and RTCS code without gaining much insight. The delay seems to be during a call to recv() so it is entirely possible that the server is taking that long to respond. I need to find a way to dig into this further.
Ill add more as I make progress.
Jay