• An IP stack on the Raspberry Pi Pico W in Forth

    From Travis Bemann@21:1/5 to All on Sun Oct 1 18:54:16 2023
    Just in case anyone is interested, I have a working IP stack, which I call "zeptoIP" as it runs on zeptoforth, implemented in Forth for the Raspberry Pi Pico W. It makes use of the CYW43439 WiFi chip on the board. Aside from a the CYW43439 firmware and a
    tiny bit of code written in assembly (namely byte order-switching operations) it is written entirely in Forth (even if it uses an OO layer which, despite being written in Forth itself, may not be all too Forthy, and even though it severely abuses local
    variables). It does make heavy use of multitasking operations provided by zeptoforth, so it is strictly unportable without significant modification.

    Note that for legal reasons (i.e. non-free code) it is up to the user to upload the firmware, which is distributed separately from zeptoforth, for the CYW43439 to their Pico W and then load the CYW43439 driver (note that it is not derivative of Damien
    George's non-free CYW43439 driver) and zeptoIP on top of it.

    In case you are wondering, it does not follow the typical BSD socket model from an API standpoint. Rather one receives pending "endpoints", for lack of a better term (I do not call them "connections" because they also include listening for UDP packets),
    with state or data changes, processes it (whether immediately or by storing the data into buffers for later handling), and then declares the endpoints "done". There is no need to copy the data into a separate buffer, whereas using a BSD socket model
    would inherently involve maintaining separate buffers to copy data into.

    Currently the code is in a beta state, so it is not in the master branch of zeptoforth but rather in the devel branch. You can find a guide to the installation and use of zeptoIP at:

    https://github.com/tabemann/zeptoforth/blob/devel/BUILDING_AND_USING_ZEPTOIP.md

    Also, for some example programs, you can find a very rudimentary HTTP server using zeptoIP at:

    https://github.com/tabemann/zeptoforth/blob/devel/test/rp2040/pico_w_net_http_led.fs

    and a (warning - very insecure) TCP console server using zeptoIP at:

    https://github.com/tabemann/zeptoforth/blob/devel/test/rp2040/pico_w_net_repl_notify.fs

    Warning - there appear to be a few glitches in it - connections do not seem to always be correctly closed, for whatever reason.

    Hope you find this useful or interesting,

    Travis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Howerd@21:1/5 to Travis Bemann on Mon Oct 2 11:47:04 2023
    On Monday, October 2, 2023 at 3:54:18 AM UTC+2, Travis Bemann wrote:
    Just in case anyone is interested, I have a working IP stack, which I call "zeptoIP" as it runs on zeptoforth, implemented in Forth for the Raspberry Pi Pico W. It makes use of the CYW43439 WiFi chip on the board. Aside from a the CYW43439 firmware and
    a tiny bit of code written in assembly (namely byte order-switching operations) it is written entirely in Forth (even if it uses an OO layer which, despite being written in Forth itself, may not be all too Forthy, and even though it severely abuses local
    variables). It does make heavy use of multitasking operations provided by zeptoforth, so it is strictly unportable without significant modification.

    Note that for legal reasons (i.e. non-free code) it is up to the user to upload the firmware, which is distributed separately from zeptoforth, for the CYW43439 to their Pico W and then load the CYW43439 driver (note that it is not derivative of Damien
    George's non-free CYW43439 driver) and zeptoIP on top of it.

    In case you are wondering, it does not follow the typical BSD socket model from an API standpoint. Rather one receives pending "endpoints", for lack of a better term (I do not call them "connections" because they also include listening for UDP packets),
    with state or data changes, processes it (whether immediately or by storing the data into buffers for later handling), and then declares the endpoints "done". There is no need to copy the data into a separate buffer, whereas using a BSD socket model
    would inherently involve maintaining separate buffers to copy data into.

    Currently the code is in a beta state, so it is not in the master branch of zeptoforth but rather in the devel branch. You can find a guide to the installation and use of zeptoIP at:

    https://github.com/tabemann/zeptoforth/blob/devel/BUILDING_AND_USING_ZEPTOIP.md

    Also, for some example programs, you can find a very rudimentary HTTP server using zeptoIP at:

    https://github.com/tabemann/zeptoforth/blob/devel/test/rp2040/pico_w_net_http_led.fs

    and a (warning - very insecure) TCP console server using zeptoIP at:

    https://github.com/tabemann/zeptoforth/blob/devel/test/rp2040/pico_w_net_repl_notify.fs

    Warning - there appear to be a few glitches in it - connections do not seem to always be correctly closed, for whatever reason.

    Hope you find this useful or interesting,

    Travis
    Hi Travis,

    Nice work! I will download it and take a look, when I have a free minute or two :-)

    Cheers,
    Howerd

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)