[Libwebsockets] MBED3 LWS Port

Andy Green andy at warmcat.com
Sat Nov 14 10:02:21 CET 2015



On 11/13/2015 11:15 AM, Andy Green wrote:
> Hi -
>
> After saying there are no new big things to do with lws, pretty
> quickly a new big thing turned up.
>
> Lws has always been designed to be especially lightweight, but it has
> always assumed the platform was at least Posix-ish.
>
> However there are a lot of Cortex-M chips out there that could
> theoretically run lws, but they lack Posix.  Traditionally that
> low-middle embedded space has been a minefield of different
> proprietary or roll-your-own RTOS type OS, but recently ARM are making
> efforts to unify the platform of choice to be their MBED3 OS.  (Not to
> be confused with "mbed", https://developer.mbed.org, that has existed
> for a while, MBED3 is a rewrite that is still incomplete and somewhat
> buggy... however it is the future).
>
> https://www.mbed.com
>
> If you're curious about it, you can read a series of blog posts with
> my adventures with it here.
>
> https://warmcat.com/embedded/iot/2015/10/29/the-mbed-maze.html
>
> Basically it only supports one board / SoC at the moment, it's a US$35
> dev board with nice development support on it and a SoC with 1MB Flash
> + 256KB SRAM, and Ethernet.
>
> http://www.freescale.com/products/arm-processors/kinetis-cortex-m/k-series/k6x-ethernet-mcus/freescale-freedom-development-platform-for-kinetis-k64-k63-and-k24-mcus:FRDM-K64F
>
> MBED3 itself is a bit of an interesting challenge, it has sockets
> support via LWIP but the whole OS is an event queue, and there is no
> threading and no real Posix.  So the port basically has external
> callbacks coming that are already serialized and call straight into
> lws guts: there is no more lws service loop the whole OS is the
> service loop.  And the whole OS and all other dependencies are one
> static-linked binary at the end of the build.
>
> I succeeded in porting lws, but bugs in the mbed3 network stack wrt
> listening socket accept flow have stalled the effort
>
> https://github.com/ARMmbed/sockets/issues/35
>
> Even so, it can work both for HTTP serving of the example server
> test.html and if the mbed3 networking stack functions enough, it will
> succeed with the upgrade handshake and communication in both
> directions on ws already; I have not been able to test mirror protocol
> but dumb increment has been seen to work.
>
> Including MBED3, network stack, lws, the sample app, and the sameple
> app assets (test.html, favicon.ico, the logo png) the whole working
> binary is 117KB.  So targeting Cortex M3 with 128KB Flash is workable.
> Which gives a new meaning to "lightweight" ^^
>
> You can find the lws port itself on a separate branch for now, it does
> some major #ifdef surgery and needs a round of integration cleanups
> before it can go in the main tree
>
> https://github.com/warmcat/libwebsockets/tree/mbed3

I cleaned this up a bit and confirmed using Appveyor + Travis that he 
still builds on everything, and that the test apps work on Linux and 
mbed3 (as far as the networking stack will allow).  Then I removed the 
mbed3 branch and pushed the whole integrated thing on master branch.

There's some docs added to README.build.md about how to build it for 
mbed3.  MBED3 is still a bit avant guarde but if you want a modern GUI 
on a headless very cheap one-chip solution, the cost / performance ratio 
is (or will be when it does listening sockets properly) hard to beat.

-Andy

> There is a separate project for the test server (which uses mbed3
> dependency system to 'want' libwebsockets)
>
> https://github.com/warmcat/lws-test-server
>
> -Andy
> _______________________________________________
> Libwebsockets mailing list
> Libwebsockets at ml.libwebsockets.org
> http://ml.libwebsockets.org/mailman/listinfo/libwebsockets
>



More information about the Libwebsockets mailing list