Topic: Problem writing a correct EmbedSend and EmbedRecieve

Hello,

I am using Microchip harmony 1.09 and a PIC32 processor. After clicking in the appropriate fields in the harmony configurator (including TCP IP and WolfSSL) I learned that the flag WOLFSSL_USER_IO flag was set. This surpriced me, I thought that a PIC32 processor, single threaded, without RTOS, would be included in WolfSSL setup. Is it correct that the WOLFSSL_USER_IO flag should be set?

What is the easiest way for me to write Embedsend and EmbedRecieve. Should I tick in the box of Berkeley api in the harmony configurator, and use this api (which seems to have the correct error handling for WolfSSL) or should I use the ArrayPut and ArrayGet that is included in the Harmony?

Kind Regards

Peter Abdelmassih Waller

Share

Re: Problem writing a correct EmbedSend and EmbedRecieve

Hi Peter,

I would recommend Berkley Socket Descriptor (BSD) API. That is well tested and known to work. I am not familiar with ArrayGet and ArrayPut so while I can not recommend them, they may work with a custom IO callback. However BSD API should provide you with access to "recv" and "send" in which case you could remove the define for WOLFSSL_USER_IO and use our default "EmbedReceive" and "EmbedSend" IO callbacks (loaded by default when WOLFSSL_USER_IO is not defined).


Regards,

Kaleb

Re: Problem writing a correct EmbedSend and EmbedRecieve

Dear Kaleb,

Thank you for your response.

However, please let me know if there is any problem overriding the the setting for WOLFSSL_USER_IO in the settings.h file (<wolfssl/wolfcrypt/settings.h>) .

In this file it is stated:


#ifdef MICROCHIP_PIC32
    /* #define WOLFSSL_MICROCHIP_PIC32MZ */
    #define SIZEOF_LONG_LONG 8
    #define SINGLE_THREADED
    #define WOLFSSL_USER_IO
    #define NO_WRITEV
    #define NO_DEV_RANDOM
    #define NO_FILESYSTEM
    #define USE_FAST_MATH
    #define TFM_TIMING_RESISTANT
    #define NEED_AES_TABLES
    #define WOLFSSL_HAVE_MIN
#endif

As I understand it I need to define MICROCHIP_PIC32 due to my choice of platform (according to WolfSSL manual), and then WOLFSSL_USER_IO will be defined. Can you explain why it is defined, and why it is ok to override?

Kind Regards

Peter

Share

Re: Problem writing a correct EmbedSend and EmbedRecieve

Hi Peter,

That setting was a design decision made by the developer who did the port for PIC32. The developer was aware that PIC32 can work with both legacy mla, harmony, and even third-party peripherals. Because of this the decision was made to define "WOLFSSL_USER_IO" by default. The intent was to alert developers working with the port that there is a need to:

A. Determine if "send" and "recv" are available, if so then use them.
B. If not available implement custom IO callbacks based on available API.

In your case you have determined that BSD API is available which indicates that the "send" and "recv" functions should also be available. You should be safe to override that setting. If you build without that setting and find that "send" and "recv" are not available THEN you will need to implement custom IO callbacks based on what the BSD implementation is using for send/recv. No harm in trying the simplest solution first.


Regards,

Kaleb

Re: Problem writing a correct EmbedSend and EmbedRecieve

Dear Kaleb

thank you very much for your reply. Maybe it would be a good idea to put this information in a comment in the code and/or in the porting guideline. It would have saved me a lot of effort.

By the way, this means that the harmony installation (where the settings.h while is located) might need to be specific for each development project, since changes are made within the framework.

Kind Regards

Peter

Share

Re: Problem writing a correct EmbedSend and EmbedRecieve

Hi Peter,

I have made a note of it and will review with the team at our next meeting. We appreciate feedback of this kind from the community and would like to extend our gratitude for taking the time to point this out.


Warmest Regards,

Kaleb