How to start programing microcontroller in Julia ? is any package?

How to start programing microcontroller in Julia ? is any package ?
Paul

4 Likes

I am not sure it is supported though https://github.com/rennis250/Arduino.jl

2 Likes

Sombody are using ATMEGA8 (16…) with Julia ?
Paul

W dniu 2017-05-14 o 20:58, Michele Zaffalon pisze:

1 Like

THX , but I am using microcontroller ATMEGA8 , Arduino is other chip. Question stil actual.
Paul

You can’t run julia on a ATMEGA8.
Julia can only be run on a computer with a (supported) operating system.

1 Like

Shure!

I am lookong for some suport to programing ATMEGA8, analogical like
Arduino.jl …

Paul

I was looking into this a while back and I believe one would need the chip to at least support llvm. I had heard espressif was working on this for the xtensa based esp32 with an eye to supporting the rust language, but according to this post, that is behind:

Paul, Julia does run on the Raspberry Pi. OK, that’s not a microcontroller but you should be able to hook at Atmega8 up to the Pi

I’m still unclear if you want to:

  • run julia on the ATMEGA8 – impossible (without some serious work on changing the language itself)
  • communicate with a program on ATMEGA – which is what Arduino.jl lets you do, but you could do directly with SerialPorts.jl
  • Use julia to automate the transferring of compiled programs (eg written in C), to the ATMEGA, eg via JTAG – in which case you probably are best off using julia’s great power for calling external programs, to run the commandline tools that Atmel provides.
3 Likes

No one has done it that I’m aware of, but with some work, one could probably cross-compile Julia code (static) with LLVM’s atmel backend. A similar approach is being worked on for Rust:

http://dylanmckay.io/blog/rust/avr/llvm/2017/02/09/safer-microcontrollers-almost-here.html

3 Likes

Hi
Typical way to prgraming microcontrolers ATMEGA is preparing program in
lenguage C. But I i am using Julia (Not C) and Ia mlooking for simply
way to programing mikrokontolers in Julia !
Paul
W dniu 2017-06-22 o 05:14, Lyndon White pisze:

BIg Thx, idea nice but for me very hard… i will try :slight_smile:
P

W dniu 2017-06-21 o 16:58, John Hearns pisze:

Python have http://micropython.org/ and PyBoard MicroPython Store

Having a MicroJulia and a JuliaBoard with a ARM MCU (such as STM32) or ESP32 will be great!

Some others boards supporting MicroPython

1 Like

I don’t expect that Julia would ever run directly on an MCU that small, because Julia (well, really its dependencies) is big. LLVM alone takes up a huge amount of space (not to mention computational time during compilation), and is not currently suitable to be run on an MCU. The only reason Python gets by here, is that at its core, it’s just a simple (slow) interpreter, which is easy enough to implement on an MCU, given the RAM, Flash, and CPU budget you have available. I’m of course glossing over certain important details, but suffice to say that Python and Julia are two very different beasts.

2 Likes

Go have TinyGo GitHub - tinygo-org/tinygo: Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM. for microcontrollers. It’s also using LLVM.

Rust have

for microcontrollers. It’s also using LLVM.

2 Likes

tinygo is a compiler which runs on a host computer and compiles code for the target MCU. If that’s what we want to do for Julia, then I’m all for it.

The point I was making is that the interpreted part of Julia (where you have a REPL where you can type code into and have it JIT compiled as usual) could never run directly on an MCU most likely, because it just involves way too much overhead from memory usage and library size. Of course, there’s nothing to stop you from building an interpreter that can interpret most of Julia to run directly on an MCU, but it’ll be slower than compiled code flashed from a host computer.

2 Likes

Right, any 8/16 bit MCUs/CPUs, such as Arduino, are impossible, as I thought (see answer to my question on it). Except for Julia2C loophole. See below.

Julia supports ARM, and there is one non-8/16-bit Arduino, the 32-bit ARM-based Arduino Due (or Zero or M0 variant currently sold out). That’s the one potentially having the fewest issues to get working with Julia.Note the ARM-based MCUs, at least these ones may only support “Thumb ARM”, not full ARM, so I’m not even sure Julia would support such variants currently. A better bet might be x86 based Arduino: Arduino Official Store | Boards Shields Kits Accessories

The link in the thread above to Arduino.jl is broken, but from memory it’s just to interface to it, same as SerialPorts.jl that actually has a “Arduino submodule”. [This may even be the same code? I’m not sure if the name was changed as it was misleading or that package copied from the former.]

You can use Julia with/for C programs as you say; but also there was Intel’s Julia2C project. It seems to have bitrotted. If it would get maintained (or just using very old Julia syntax…) you could translate Julia to C and then get the code on the MCU. Possibly almost any MCU, even 8/16 bit ones. I’m however ignoring all OS issues. Julia by default requires running in an OS. A project similar to MicroPython, done for Julia, could help with that, and there’s a Discourse thread on it.

Unless you get around the OS/Linux requirement of Julia you need to look into this thread and answers there:

We can customize the Linux to run on Due.
But what we want to achieve with this?
Any value added that we are getting with this?

1 Like

You may find
https://gitlab.control.lth.se/labdev/LabConnections.jl
useful. We use a beaglebone to control lab processes using Julia in our university lab. The Readme links to documentation with install instructions

2 Likes