Live data from Hacker News

Running Julia bare-metal on an Arduino

seelengrab.github.io

1–10 of 27 posts

Re: Running Julia bare-metal on an Arduino

#2
This is really impressive, and a great write up. I’ve been following the work on static compiling Julia to x86 libraries from the GPUCompiler.jl folks but I didn’t expect to see Julia working on an Arduino any time soon. With some kind of basic GC support (even if just using a bump allocator) it seems like a good fraction of the language could actually be available. Most tight loops hopefully don’t allocate so it would mostly just be necessary for creating initial arrays and mutable structs.

Re: Running Julia bare-metal on an Arduino

#3
This is very promising for embedded control applications. Bootstrapping this with a simple allocator and even something as basic as FreeRTOS [1] combined with CBinding.jl [2] for portability would be game-changing for many applications, and directly compete with e.g. MathWorks' Arduino Simulink target [3]. ESP8266/32 next, once LLVM support [4] lands?

[1]: https://microcontrollerslab.com/use-freertos-arduino/

[2]: https://github.com/analytech-solutions/CBinding.jl

[3]: https://www.mathworks.com/help/supportpkg/arduino/run-on-tar...

[4]: https://github.com/espressif/llvm-project

Re: Running Julia bare-metal on an Arduino

#4
post #2

This is really impressive, and a great write up. I’ve been following the work on static compiling Julia to x86 libraries from the GPUCompiler.jl folks but I didn’t expect to see Julia working on an Arduino any time soon. With some kind of basic GC support (even if just using a bump allocator) it seems like a good fraction of the language could actually be available. Most tight loops hopefully don’t allocate so it wou…

Haha, thank you!

Yeah, this was mostly an experiment to see what kinds of problems I run into - I didn't expect this to actually work out! It's still very finicky, relying on LLVM to remove dead runtime calls and so on, but non-allocating stuff with immutables should work, though I haven't actually tested it.

Re: Running Julia bare-metal on an Arduino

#5
post #3

This is very promising for embedded control applications. Bootstrapping this with a simple allocator and even something as basic as FreeRTOS [1] combined with CBinding.jl [2] for portability would be game-changing for many applications, and directly compete with e.g. MathWorks' Arduino Simulink target [3]. ESP8266/32 next, once LLVM support [4] lands? [1]: https://microcontrollerslab.com/use-freertos-arduino/ [2]: ht…

I didn't know about FreeRTOS, interesting!

I don't think CBinding.jl is an option, since the whole point of the arduino is that the julia runtime can't run there (and doesn't fit in the first place - there's not enough RAM and swapping to the SD seems bad). Linking with C created .o files should work though?

I don't own any ESP32, but if that happens, yes I'd very much like to try!

Re: Running Julia bare-metal on an Arduino

#6
post #5
post #3

This is very promising for embedded control applications. Bootstrapping this with a simple allocator and even something as basic as FreeRTOS [1] combined with CBinding.jl [2] for portability would be game-changing for many applications, and directly compete with e.g. MathWorks' Arduino Simulink target [3]. ESP8266/32 next, once LLVM support [4] lands? [1]: https://microcontrollerslab.com/use-freertos-arduino/ [2]: ht…

I didn't know about FreeRTOS, interesting! I don't think CBinding.jl is an option, since the whole point of the arduino is that the julia runtime can't run there (and doesn't fit in the first place - there's not enough RAM and swapping to the SD seems bad). Linking with C created .o files should work though? I don't own any ESP32, but if that happens, yes I'd very much like to try!

Would you accept an ESP32 for your edification? No strings attached. Email me

I think CBinding.jl could be helpful if one wanted to write a target-specific shim library in C and link against it. I would expect that some of the glue is going to be easier to write in C than in Julia, and you can play some tricks with macros to create bare modules [1] within some kind of `@arduino_setup`/`@arduino_loop`-style blocks.

Edit: By the way, those target-specific shims might already exist as part of the Arduino IDE. PlatformIO [2] is also another possible collider of these types of platform-specific glues.

[1]: https://docs.julialang.org/en/v1/manual/modules/#Default-top...

[2]: https://docs.platformio.org/en/latest/boards/index.html

Re: Running Julia bare-metal on an Arduino

#8
The default arduino toolchain, which is a g++ wrapper, supports C++, even though the whole system only has only 1 kilobyte of RAM.

The C++ 'new' operator does seem to be supported, so I assume it has some kind of heap allocator - although I imagine that when you've only got 1 kilobyte to play with it gets quickly eaten by the allocators datastructures and C++ vtable pointers, not to mention the impact of fragmentation if you allocate any objects more than a few tens of bytes.

Re: Running Julia bare-metal on an Arduino

#9
post #6
post #5

Earlier quoted context omitted.

I didn't know about FreeRTOS, interesting! I don't think CBinding.jl is an option, since the whole point of the arduino is that the julia runtime can't run there (and doesn't fit in the first place - there's not enough RAM and swapping to the SD seems bad). Linking with C created .o files should work though? I don't own any ESP32, but if that happens, yes I'd very much like to try!

Would you accept an ESP32 for your edification? No strings attached. Email me I think CBinding.jl could be helpful if one wanted to write a target-specific shim library in C and link against it. I would expect that some of the glue is going to be easier to write in C than in Julia, and you can play some tricks with macros to create bare modules [1] within some kind of `@arduino_setup`/`@arduino_loop`-style blocks. Ed…

That'd be awesome, sure! I'll shoot you an email.

PlatformIO is nice, yes - I've already been suggested linking/using that, but I haven't looked into it yet. I also haven't worked with that before, so it'd be completely new territory for me.

Re: Running Julia bare-metal on an Arduino

#10

LLVM is one of those truly awesome projects. LLVM gets a new backend and then for the most part many of the languages are able to generate code for it. Want to see Rust on that new m68k backend or 6502 backend mostly out of morbid curiosity.

While great, it is following the path others have trailed before.

https://en.wikipedia.org/wiki/Amsterdam_Compiler_Kit

One example among many others.

Post reply on HN