# Julia for microcontrollers (like Micropython)

**URL:** <https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393>\
**Category:** Internals & Design\
**Tags:** proposal\
**Created:** [September 23, 2018, 5:13pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393 "2018-09-23T17:13:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Parthasarathi\_S](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/parthasarathi_s/32/5484_2.png) [@Parthasarathi\_S](https://discourse.julialang.org/u/Parthasarathi_S)\
**Post date:** [September 23, 2018, 5:13pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/1 "2018-09-23T17:13:36Z")

</div>

Dear Julia community members,

I wish to develop a fork of Julia that can run on low memory low ram microcontrollers .

Similar to Micropython (python for microcontrollers)

[Micropython website](https://micropython.org/)

I’m working on low cost wifi module ESP8266 with micropython.

I’m working on developing RTOS for Internet of things.

Kindly shed some light on my path to reach my goal…

---

<div class="post-metadata">

**Author:** ![kevbonham](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kevbonham/32/216165_2.png) [@kevbonham](https://discourse.julialang.org/u/kevbonham)\
**Post date:** [September 23, 2018, 6:35pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/2 "2018-09-23T18:35:20Z")

</div>

Welcome! I’m not sure how to help you, but I suspect you will have better luck with others if you follow some of [these suggestions](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/) with your question.

The project you describe sounds like a big one, and when you just ask “what path should I take?” I’m guessing it’s a bit too vague, and very few people will have any sense of how to help you. Maybe tell us what you’ve done already, and what problems you’ve encountered that you need help solving.

---

<div class="post-metadata">

**Author:** ![Youcamp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/youcamp/32/8062_2.png) [@Youcamp](https://discourse.julialang.org/u/Youcamp)\
**Post date:** [November 18, 2018, 7:48pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/3 "2018-11-18T19:48:10Z")

</div>

This is a great idea! I’ve been hoping one of the chip manufacturers would pick up on how great Julia is and integrate it themselves. I saw that the university of Malta is working on an LLVM for the 16 bit MSP430, so you might get some information there.  
This does sound like a monumental task, and I can’t wait to see you succeed!

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [December 11, 2018, 10:51am UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/4 "2018-12-11T10:51:38Z")

</div>

> [@Parthasarathi\_S](#):
>
> Similar to Micropython (python for microcontrollers)
> 
> [Micropython website](https://micropython.org/)
> 
> I’m working on low cost wifi module ESP8266 with micropython.

In theory something like Micropython could be replicated for Julia, (while it would be even more work for e.g. that MCU; I wasn’t even sure MicroPython supported any non-ARM ones). ARM (or x86) MCU would be the best bet.

Since you can call Python with PyCall.jl, or should I say, call Julia from Pyhon using PyJulia package (that’s based on PyCall.jl), it might be helpful to look into if PyJulia would work with MicroPython. It likely doesn’t because MicroPython is baremetal non-standard variant. Julia however requires an OS (currently at least) and a filesystem. I’m not sure you have any filesystem [access] with MicroPython. MicroPython also has changed garbage collection from regular Python. That it supports real-time use is interesting (and I recall based on fixed amount of memory and knowing the exact hardware/size). Getting the same GC guarantees with Julia should be possible, but I wouldn’t rely on it happening just by change.

Julia would not work directly on ESP8266 given that it uses “L106 32-bit [RISC](https://en.wikipedia.org/wiki/Reduced_instruction_set_computing) microprocessor core based on the [Tensilica](https://en.wikipedia.org/wiki/Tensilica) Xtensa”; and neither for any 16-bit despite it working on an LLVM:

> [@Youcamp](#):
>
> is working on an LLVM for the 16 bit MSP430

E.g. even with 8/16-bit AVR having LLVM support (and working with Rust language, or getting there), that CPU, or any non-32-bit (or 64-bit), such as MSP430, will not work with Julia (see my thread in it; ans answers on how difficult and unlikely adding 26-bit support is; long term I see 8- and 16-bit CPUs as dead anyway, and would concentrate on ARM).

Only possibly workaround might be Julia2C (see other microcontroller thread where I wrote about that).

---

<div class="post-metadata">

**Author:** ![amckay1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amckay1/32/8280_2.png) [@amckay1](https://discourse.julialang.org/u/amckay1)\
**Post date:** [February 17, 2019, 9:20pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/5 "2019-02-17T21:20:58Z")

</div>

Just FYI, Espressif released a work in progress LLVM version for Xtensa last week. I don’t think it is ready for prime time quite yet, but the ESP32 is a 32-bit architecture, and while this development was likely aimed at Rust, seems as though Julia could piggy-back as well some day?

> **[LLVM for Xtensa - ESP32 Forum](https://esp32.com/viewtopic.php?t=9226)**
>
> Espressif ESP32 Official Forum

---

<div class="post-metadata">

**Author:** ![jpsamaroo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jpsamaroo/32/46804_2.png) [@jpsamaroo](https://discourse.julialang.org/u/jpsamaroo)\
**Post date:** [February 18, 2019, 3:45pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/6 "2019-02-18T15:45:20Z")

</div>

This still runs into the problem of requiring a Julia runtime + large shared libraries to get a fully-functional system, but at least with a working LLVM backend we could do something like CUDAnative and launch “kernels” on the ESP32 as an accelerator of sorts. I’d be open to contributing to something like that once my free time becomes less finite 😄

---

<div class="post-metadata">

**Author:** ![mustela125](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mustela125](https://discourse.julialang.org/u/mustela125)\
**Post date:** [April 18, 2021, 5:29pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/7 "2021-04-18T17:29:20Z")

</div>

Forgive my ignorance, but what I personally would favor is a sort of Julia API for programming microcontrollers such as the ESP32, etc. I wouldn’t care so much if it’s actually C running the chip as long as I don’t need to learn C and just use Julia.

I feel like it would be much less work to write a Julia API/wrapper for microcontroller programming than it would be to write a “microJulia” that runs on MCUs. But again I point you to my ignorance here.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [April 19, 2021, 5:27pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/8 "2021-04-19T17:27:28Z")

</div>

ESP32/Xtensa is not supported by Julia language, and likely never will. It’s not theoretically impossible however, it seems: [https://github.com/espressif/llvm-project](https://github.com/espressif/llvm-project)

You can of course interface with any microcontroller somehow with Julia, but the best bet to get Julia code running on one would be on ARM and nothing else really viable. Long-term I don’t even see the point of any non-ARM for any embedded system, Julia or not. Is ESP32 better or cheaper for anything?

---

<div class="post-metadata">

**Author:** ![Paulo\_Jabardo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/paulo_jabardo/32/3196_2.png) [@Paulo\_Jabardo](https://discourse.julialang.org/u/Paulo_Jabardo)\
**Post date:** [April 19, 2021, 5:44pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/9 "2021-04-19T17:44:29Z")

</div>

The ESP32 is fast, it is cheap and provides WiFi and Bluetooth out of the box but the analog inputs are terrible. I have been using it frequently.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [April 21, 2021, 12:02am UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/10 "2021-04-21T00:02:56Z")

</div>

The new Pi Pico doesn’t run Linux, but possibly Julia could be made to work on that Unix/microcontroller (or similar):

> **[Now you can run Unix on the tiny $4 Raspberry Pi Pico](https://www.zdnet.com/article/now-you-can-run-unix-on-the-tiny-4-raspberry-pi-pico/)**
>
> Fuzix, an operating system for very small machines, is now available for the Raspberry Pi Pico.

“Dual-core Arm Cortex-M0+ @ 133MHz” is not a lot, and 264KB RAM certainly limiting, and (at least currently):

> The Fuzix port only uses one of the Pico’s cores

> **[THE RASPBERRY PI PICO CAN’T RUN LINUX. BUT IT CAN RUN FUZIX.](https://projects-raspberry.com/the-raspberry-pi-pico-cant-run-linux-but-it-can-run-fuzix/)**
>
> The great divide in terms of single board computers lies between those that can run some form of Linux-based distribution, and those that can not. For

[https://www.iottrends.tech/blog/raspberry-pi-pico-vs-esp-32/](https://www.iottrends.tech/blog/raspberry-pi-pico-vs-esp-32/)

[http://cowlark.com/2021-02-09-esp8266-fuzix/](http://cowlark.com/2021-02-09-esp8266-fuzix/)

---

<div class="post-metadata">

**Author:** ![mustela125](https://avatars.discourse-cdn.com/v4/letter/m/3bc359/32.png) [@mustela125](https://discourse.julialang.org/u/mustela125)\
**Post date:** [April 21, 2021, 6:35am UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/11 "2021-04-21T06:35:09Z")

</div>

Again, I would suggest a Julia API to write and compile Lua or C++ or Assembly code to program any particular MCU, not try to have the MCU run Julia. This is given my all too many hobbies and the likelihood of picking up a lower-level language is slim despite the desire. So it would be nice to just learn an API in a language I already know and use (i.e. Julia) to do more exciting things (i.e. program MCUs).

Maybe not the best solution, but I can’t be the only one that doesn’t know C/C++ but would enjoy programming MCUs.

---

<div class="post-metadata">

**Author:** ![znmeb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/znmeb/32/28328_2.png) [@znmeb](https://discourse.julialang.org/u/znmeb)\
**Post date:** [August 19, 2021, 3:34am UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/12 "2021-08-19T03:34:02Z")

</div>

What’s the path of least resistance, though? Learning C++ or MicroPython, or getting Julia to work on a very tiny microcontroller?

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [August 19, 2021, 5:07am UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/13 "2021-08-19T05:07:26Z")

</div>

It probably depends on your background. If you know Julia, Python is similar and shouldn’t take too long to pick up. MicroPython is mostly just Python minus a few less-used features.

---

<div class="post-metadata">

**Author:** ![blackeneth](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/blackeneth/32/10353_2.png) [@blackeneth](https://discourse.julialang.org/u/blackeneth)\
**Post date:** [August 19, 2021, 7:17am UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/14 "2021-08-19T07:17:15Z")

</div>

C++ is less daunting than its reputation. Julia is likely not practical on ESP32, etc., until the ability to compile a sysimage with only what is needed.

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [August 19, 2021, 8:31am UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/15 "2021-08-19T08:31:27Z")

</div>

What do you mean with tiny? As in size of RAM (or physical size?), then not even MicroPython or C will work. Julia works on something like Raspberry Pi.

Julia is not the least-resistence path to (tiny) microcontrollers, will probably take some more years to get to work. I really like the idea of Julia working on them, but MicroPython is now a good choice and e.g. C is for most microcontrollers. For some very low-RAM, you need Forth or assembly, and nothing else will work.

The smallest computer (i.e. a “microcontroller”), in the world is ARM-based (has no pins), and I do not see Julia exclusive to more mainstream small microcontrollers (assuming for now they are ARM-based):

[https://electronics.stackexchange.com/questions/84800/what-are-the-smallest-microcontrollers](https://electronics.stackexchange.com/questions/84800/what-are-the-smallest-microcontrollers)

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [August 19, 2021, 9:42am UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/16 "2021-08-19T09:42:57Z")

</div>

Totally depends on what you want to do. Communicating with the microcontroller from Julia + using Arduino IDE works wonders: I don’t want all the logic to reside on the microcontroller, so I know enough C++ to get it to do simple things, and the rest I program on Julia and it runs on a laptop that communicates with the microcontroller. But that might not be possible in your case if you want it to be autonomous…

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [August 19, 2021, 6:15pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/17 "2021-08-19T18:15:51Z")

</div>

The controllers @znmeb seems to be interested in is the category that supports MicroPython and C but not a whole Julia installation. [Development Boards, MicroPython Products Category on Adafruit Industries](https://www.adafruit.com/category/924)

---

<div class="post-metadata">

**Author:** ![contradict](https://avatars.discourse-cdn.com/v4/letter/c/ac91a4/32.png) [@contradict](https://discourse.julialang.org/u/contradict)\
**Post date:** [August 19, 2021, 6:24pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/18 "2021-08-19T18:24:57Z")

</div>

A previous [thread](https://discourse.julialang.org/t/bring-julia-code-to-embedded-hardware-arm/19979) on this topic.

I really like the idea from that thread of using GPUCompiler to emit small “kernels” that run on the microcontroller. It is still a lot of work, but it sure seems better than limiting to microconctrollers that can fit the whole runtime.

---

<div class="post-metadata">

**Author:** ![krrutkow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/krrutkow/32/9138_2.png) [@krrutkow](https://discourse.julialang.org/u/krrutkow)\
**Post date:** [August 19, 2021, 6:32pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/19 "2021-08-19T18:32:10Z")

</div>

I am currently working on a microcontroller kernel compiler Julia package, but only in my spare time unfortunately…

---

<div class="post-metadata">

**Author:** ![znmeb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/znmeb/32/28328_2.png) [@znmeb](https://discourse.julialang.org/u/znmeb)\
**Post date:** [August 19, 2021, 6:39pm UTC](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393/20 "2021-08-19T18:39:53Z")

</div>

Forth would work for my use case - the microcontroller is an STM32 and the application is audio. There are several hardware options, among them Raspberry Pi Pico, Teensy and Electro-Smith Daisy. They all have different versions of the STM32 and different flash and RAM sizes. And they all have C/C++ audio / DSP libraries.

A host (most likely a BeagleBone Black or an NVIDIA Jetson) plus microcontroller is also a viable option. Julia will definitely run on both of them and the Jetson GPU works with Julia’s CUDA library. I haven’t tested Julia on the BeagleBone Black yet but I don’t see why it wouldn’t work; it’s got Linux running on it.

[Next page](https://discourse.julialang.org/t/julia-for-microcontrollers-like-micropython/15393.md?page=2)
