Live data from Hacker News

Show HN: MicroLua – Lua for the RP2040 Microcontroller

github.com

21–30 of 35 posts

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#23
post #20

OpenWRT's LuCI WebUI, Torch ML, and embedded interpreters in game engines are also written in Lua. Apache Arrow's C GLib implementation works with Lua. From https://news.ycombinator.com/item?id=38103326 : > Apache Arrow already supports C, C++, Python, Rust, Go and has C GLib support Lua: https://github.com/apache/arrow/tree/main/c_glib/example/lua LearnXinYminutes Lua: https://learnxinyminutes.com/docs/lua/ OpenWRT…

Yes, it's impossible (i'm dev on OpenWRT) because it build toolchain first then, Linux kernel, drives and userland apps.

> probably impossible

https://github.com/raspberrypi/pico-sdk/ links to a PDF about connecting to the interwebs with a pi pico: "Connecting to the Internet with Raspberry Pi Pico W" https://rptl.io/picow-connect

micropython/micropython//ports/rp2/boards/RPI_PICO_W: https://github.com/micropython/micropython/tree/master/ports...

micropython/micropython//lib: https://github.com/micropython/micropython/blob/master/lib

micropython/micropython//examples/network/http_server_simplistic.py: https://github.com/micropython/micropython/blob/master/examp...

micropython/micropython//examples/network/http_server_ssl.py: https://github.com/micropython/micropython/blob/master/examp...

raspberrypi/pico-sdk//lib: btstack, cyw43-driver, lwip, mbedtls, tinyusb https://github.com/raspberrypi/pico-sdk/tree/master/lib

raspberrypi/pico-examples//pico_w/wifi/access_point/picow_access_point.c: https://github.com/raspberrypi/pico-examples/blob/master/pic...

There's an iperf opkg pkg, or is it just netperf (which works with the flent CLI and GUI)?

raspberrypi/pico-examples//pico_w/wifi/iperf/picow_iperf.c: https://github.com/raspberrypi/pico-examples/blob/master/pic...

raspberrypi/pico-examples//pico_w/wifi/freertos/iperf/picow_iperf.c: https://github.com/raspberrypi/pico-examples/blob/master/pic...

FreeRTOS > Process management: https://en.wikipedia.org/wiki/FreeRTOS#Process_managememt

elf2uf2: https://github.com/raspberrypi/pico-sdk/tree/master/tools/el...

adafruit/circuitpython//tests/micropython: https://github.com/adafruit/circuitpython/tree/main/tests/mi...

adafruit/circuitpython//tools: https://github.com/adafruit/circuitpython/tree/main/tools

adafruit/circuitpython//tools/cortex-m-fault-gdb.py: https://github.com/adafruit/circuitpython/blob/main/tools/co...

RP2040 > Features: 2x ARM Cortex-M0 https://en.wikipedia.org/wiki/RP2040#Features

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#25
post #14

Does Lua have primitive arrays now? When I looked at it some years ago, it seemed to support only hash maps, and arrays were emulated using hash maps, which I found to be completely bizarre. There were discussions online where Lua folks were saying, no, you don't really need arrays. And I'm thinking to myself, hell yeah, I really needs arrays on resource-constrained microcontroller systems without garage collection.

That discussion must have been really long ago, otherwise you missed the point. Since Lua 5.0 (2003) tables are implemented as a pair of an array and a hashmap, and the array part can even handle small nil gaps. So tables used as arrays are implemented as arrays as well.

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#27
post #13

This is very cool. Thanks for sharing this. I have wanted to do something similar for either an existing language or a subset of such or for a minimal language I create. Do you have any suggestions on how to get started on that in terms of high-level steps?

I can't really give advice for creating a new language, or even for creating a new implementation of an existing one. MicroLua uses the existing Lua implementation from lua.org, and just packages it to make it useful on a specific platform.

For that, it helps if the existing implementation is already cross-platform and has few dependencies. Lua is great in this respect, as it only depends on a libc. The first step is to get it to compile for the target platform and have it execute a hard-coded "hello world" script. After that, it's only a matter of adding more libraries, one at a time.

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#28
post #9

How does it do in performance/efficiency? (Lua is pretty low overhead, but I guess for something embedded like this maybe latency in responding to an input, rather than a "normal" benchmark, would make more sense?)

I haven't run any benchmarks yet, and TBH performance isn't a high priority, but event dispatch latency is currently fairly bad, between 100 and 150 us (when overclocking the Pico at 250 MHz). It feels like it should be possible to bring it down to <30 us. I suspect the bad latency is due to my very naive implementation of thread scheduling and timers.

Re: Show HN: MicroLua – Lua for the RP2040 Microcontroller

#30

I can't get my head around a 1 based language.

I have to admit that this was one reason why it took me so long to start a project with Lua. Now that I've had some exposure to the language, I can say that it's not as bad as it seems, but it's also not "nothing". I frequently have to think about indices to avoid making mistakes in Lua, while in zero-based language indexing is pretty much muscle memory.
Post reply on HN