Hot!Using Amazon FreeRTOS with Harmony

Author
mrpackethead
packet mangler
  • Total Posts : 952
  • Reward points : 0
  • Joined: 2007/04/01 23:33:39
  • Location: 0
  • Status: offline
2018/04/10 19:56:19 (permalink)
0

Using Amazon FreeRTOS with Harmony

Currently Harmony 2.05.01 comes with FreeRTOS version 9.x.     Upgrading to FreeRTOS version 10.x was trivial.  I downloaded the most recent version from the freeRTOS SVN repo,  got the Source folder and replaced the source folder.   Recompiled with no errors and it is all functional.  Horrah for that.   Version 10.x provides a few extra features..

As you may or may not know, FreeRTOS was bought by Amazon, who have subsequently modified it to be AWS FreeRTOS,   and sadly it seems it is not nearly as a trivial upgrade. 
There seems like quite a few thigns that have changed, the directory structure has changed for a start. 

Has anyone sucessfully migrated to AWS freeRTOS with Harmomy?
 
 
post edited by mrpackethead - 2018/04/15 15:01:23
#1

11 Replies Related Threads

    mrpackethead
    packet mangler
    • Total Posts : 952
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/04/15 15:08:12 (permalink)
    0
    I have been able to migrate from usig the 9.x FreeRTOS source to 10.x and then to the FreeRTOS source that Amazon is using.    Fortunatly the AWS source is not very different from 10.x ( some is identicial ).
     
    The big issue i've now struck is that the Amazon Librarys are built around the FreeRTOS+IP.     They use secure sockets that are built into that as well.    This makes using them inside of Harmony difficult, as its quite a different stack. :-(

    The first library i want to be able to use is MQTT.  Since I want to keep the Microchip IP stack, the next step would be to map hte AWS MQTT functionality into the sockets API so that it matches the header provided by lib/include/aws_secure_sockets.h. The MQTT library calls into these API. 
    #2
    mrpackethead
    packet mangler
    • Total Posts : 952
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/04/15 17:14:42 (permalink)
    0
    It appears that all the socket calls are made in aws_mqtt_agent.c 

    The real question i suppose is how easy ( if even possible ) is it to replace the secure sockets that FreeRTOS provides
    with the ones that Harmony does.
    #3
    mrpackethead
    packet mangler
    • Total Posts : 952
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/04/15 21:24:27 (permalink)
    0
    Having spent a few more hours on this,  changing from teh FreeRTOS stack to the harmony one is going to be a nightmare..  



    #4
    friesen
    Super Member
    • Total Posts : 1971
    • Reward points : 0
    • Joined: 2008/05/08 05:23:35
    • Location: Indiana, USA
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/04/16 07:12:14 (permalink)
    0
    If all you are after is mqtt, why not just use a different mqtt library within harmony?  I personally use the eclipse paho embedded C as a serializer/deserializer, it isn't that difficult.
     
    As to the different IP stack, maybe it wouldn't be too bad.  It seemed easier to understand than Harmony when I looked it over.

    Erik Friesen
    #5
    mrpackethead
    packet mangler
    • Total Posts : 952
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/04/16 14:01:52 (permalink)
    0
    The MQTT implementation includes an MQTT client library suitable for use 
    in bare metal applications, and an MQTT agent for FreeRTOS.

    You could integrate just the library, but it probably will be simpler to create an 
    application if you could also integrate the agent.
     
    The agent (think daemon task) manages the MQTT library on behalf of the 
    app, providing a simple connect, publish, and subscribe interface,  - You dont' need to do 
    anything special to manage the MQTT protocol itself. - for example there is no need to periodically call the MQTT library, the agent does that transparently in the background for you.
     
    The agent has a couple of dependencies. Although the provided examples use the FreeRTOS+TCP stack, it does so through an abstraction layer (called the 'secure sockets' layer, as it also 
    abstracts away TLS),


    So options; ( now growing )

    (1) port of that abstraction layer ( the secure sockets ) to the Harmony TCP/IP stack if you wanted, instead of using the FreeRTOS+TCP stack.


    (2) Change the project to use the FreeRTOS+TCP stack and the provided secure sockets abstraction layer for that stack,
     
    (3)  Alternatively you could use just the MQTT library component. 
     
    (4) or as Erik Suggested, use a different library.
    #6
    mrpackethead
    packet mangler
    • Total Posts : 952
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/04/16 17:09:50 (permalink)
    0
    Im going to go down the path of porting the abstraction layer;

    These are the functions that need to be changed;

    SOCKETS_Close
    SOCKETS_Connect
    SOCKETS_GetHostByName
    SOCKETS_Init
    SOCKETS_Recv
    SOCKETS_Send
    SOCKETS_SetSockOpt
    SOCKETS_Shutdown
    SOCKETS_Socket
    prvNetworkRecv
    prvNetworkSend

    Now to work out what to port them to.
    #7
    mrpackethead
    packet mangler
    • Total Posts : 952
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/04/18 15:44:59 (permalink)
    0
    Progress is being made; albeit a bit slowly.
     
    - I've decided to go down this path as I to be sensible, i really need encryption ( TLS ) of the messages.   there is a MQTT library ( WolfMQQT ) that is supplied with Harmony, but the moment that you use the Wolf Librarys you are into 'interesting' licencing territory that is largely incompatible with what I need/want to do. 

    Amazon uses mbedTLS, and that does not have the same license issues.

    Now work starts on porting the aws_secure_sockets to use the sockets that are used in Harmony. 
     
     
     
     
    In order to make this an easy to use reference project, I am making modifications the the demo project that is supplied with Harmony 2.05.01   ( apps/rtos/freertos/tcpip_client_server_).  Work to date is at https://github.com/mrpackethead/harmony_aws_freertos_mqtt

    P
    lease NOTE this is NOT yet working. there is still work to be done!
     
     
    My project ends up at C:\microchip\harmony\v2_05_01\dev\rtos\freertos\harmony_aws_freertos_mqtt


     
     
    In order to make this work a few things need to be installed;

    (1) The AWS Librarys.  I have installed them  at 
    C:\microchip\harmony\v2_05_01\third_party\amazon-freertos
    The easiest way to get this is to clone it from Github, which has the most recent versions;
    https://github.com/aws/amazon-freertos

    Note that these librarys also include FreeRTOS, but it is the AWS Version which has been modified, and it is easier to use the generic FreeRTOS10.x

    (2) FreeRTOS 10.x;
    Harmony 2.05.01 ships with FreeRTOS9.x  Fortunately upgrading it to Version 10.x is very simple. 
    Download FreeRTOS from Source Forge ( https://sourceforge.net/projects/freertos/ ).   Copy the Folder 'FreeRTOS' when its expanded out    ( FreeRTOSv10.0.1\FreeRTOS )  and use it to replace the FreeRTOS Folder that was installed with Harmony   ( In my case it was C:\microchip\harmony\v2_05_01\third_party\rtos\FreeRTOS )





     
     
     
     
     
    #8
    steverap
    Super Member
    • Total Posts : 151
    • Reward points : 0
    • Joined: 2003/11/07 12:38:54
    • Location: San Jose, CA, USA
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/04/19 09:35:38 (permalink)
    0
    mrpackethead,
     
    What platform/hardware/chip are you using? I have a mostly working PIC32MZ2048EFM144 prototype, and now need to add MQTT and AWS support. I am not using the Harmony framework, but am using the libraries. I've been considering using an RTOS, and the relatively new MQTT/AWS requirement has me looking into FreeRTOS.
     
    Thank you for starting this thread. I'm following your progress, and if I decide to go that way, may be a guinea pig, er... tester.
    #9
    mrpackethead
    packet mangler
    • Total Posts : 952
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/04/19 13:47:57 (permalink)
    0
    I'm using a PIC32MZ2048EFM144 on the Pic32 ethernet starter board.    I know some dot' like harmony, but once you get your head around it, it saves a lot of time, and speeds development up.          The AWS MQTT library is deeply rooted with FreeRTOS and would be difficult to port out to run without it.     It will be easy to move from processor to processor with harmony. 



    #10
    RISC
    Super Member
    • Total Posts : 5271
    • Reward points : 0
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/05/10 09:56:16 (permalink)
    0
    Hi,
    There is a bundle for Amazon FreeRTOS + PIC32 curiosity starter kit but it does not seem to use Harmony :
    https://docs.aws.amazon.com/freertos/latest/userguide/getting_started_mch.html
    Regards
     
    #11
    mrpackethead
    packet mangler
    • Total Posts : 952
    • Reward points : 0
    • Joined: 2007/04/01 23:33:39
    • Location: 0
    • Status: offline
    Re: Using Amazon FreeRTOS with Harmony 2018/05/11 03:49:57 (permalink)
    0
    Yes.  there is and no it does'nt use harmony. I had an offical repsponse from microchip that they have no intention to support the AWS models inside Harmony. :-(
     
    #12
    Jump to:
    © 2018 APG vNext Commercial Version 4.5