I was doing some research into Kotlin and saw it's...
# kotlin-native
j
I was doing some research into Kotlin and saw it's supported by LLVM and I'm also tangentially aware of LLVM-AVR as a target for the ATMEGA 8 bit micros like those found in the Arduino Uno. I emailed the author of AVR LLVM and asked him about using the Kotlin/Native LLVM platform as an AVR-LLVM source. I'd be interested in developing C bindings for Kotlin/Native on AVR-LLVM if something like that is possible.
m
For now Kotlin/Native stdlib is about 200KiB: https://github.com/JetBrains/kotlin-native/issues/841
n
Also Kotlin Native hasn't been heavily optimised yet ⏲️ . For instance compile time for incremental code changes (changing around 1-3 lines) on a quad core i5 laptop equipped with a SSD (running Linux) takes around 30 sec ( https://github.com/JetBrains/kotlin-native/issues/733 ), which is excruciatingly slow 😱.
j
@nick That's fair. Being able to do it at all though is my primary interest. Given the size of the binaries in the thread provided getting this on an AVR seems highly unlikely. I've just been exploring in my free time what platforms can run Kotiln. I'm in the middle of looking at the beagle pocket. but being able to run it on a 5V microcontroller would be nice for some automotive applications so I'm going to check out the ATMEL SAMC which has a 32 bit ARM Cortex MCU and a few others.
n
Kotlin Native can run on a BBB (Beaglebone Black) which uses a ARM A series CPU. Presumably the Beagle Pocket is related to the BBB (part of the same family of boards). Are you referring to the Pocket Beagle ( https://beagleboard.org/pocket ; uses a ARM M series CPU which is different from what the BBB uses)?
j
Yep, I meant the Pocket Beagle. I'll have one in hand in a few days. If it won't run Kotlin I'll still find a use for it around here in some project 🙂
n
It is known that some boards (eg STM32 Discovery series) can run Kotlin Native programs via Zephyr ( https://www.zephyrproject.org/ ). There is a Kotlin Native Zephyr sample available: https://github.com/JetBrains/kotlin-native/tree/master/samples/zephyr
Just realised that the Pocket Beagle uses ARM A and M series CPUs (1x ARM Cortex-M3, and 1x ARM Cortex-A8) so you should be able to get Kotlin Native programs running on the board via the linux_x64 target (in theory) on the ARM A series CPU only. Looked a bit confusing with the multiple CPUs on the board 🙃. The porting system that Kotlin Native uses assumes that the hardware doesn't use different types of CPUs, and that a OS is used.
The Kotlin Native team will need to decide if the porting system will accommodate multi CPU hardware or not (it is a bit of a grey area) ☁️ .
@jwd83 - Out of curiosity what are the typical performance requirements for a embedded program (running on a uC) in the automotive sector? Kotlin Native's memory model uses ARC ( https://github.com/JetBrains/kotlin-native/blob/bf7040a119c77b7a5128e5ed40d0b749eb098e77/RELEASE_NOTES.md#compatibility-and-features ) with a cyclic collector (a cut down Garbage Collector).
d
I’ll like to be able to write K/N for Teensy boards
n
Mario Arias - Which versions of the Teensy boards are you interested in (ARM versions only, AVR versions only, or all of them)?
d
For now AVR. Is just a hobby nothing serious about it. I have a couple of keyboards with QMK firmware and I’ll like to create a K/N version of it
n
Nowadays ARM is the standard CPU for new uCs.
j
Sorry for coming back to this so late. I've had a number of other projects to juggle. Depending on the application performance may not be super critical. I haven't had a chance to play with the pocket beagle yet. I was wanting to simply pull CAN messages off of a bus and upload them to a server over TCP (losslessly) or stream them over UDP (lossy OK)