Thank you so much for documenting your progress here! This is an awesome undertaking!
I am very interested in trying out your code for a hobby project- is it at a point where I could buy a microcontroller board and use the IDE straight away (if so, could you provide a link to the board you’re using, tools needed to write to it etc)? Or would I need to add additional ROM and other customisation (because of the 2MB limit)? The closest I’ve done to microcontroller programming is with a raspberry pi, so I’m a complete beginner in the field but I’d like to try it out and support if I can.
Hi @Geordie_J, if you don't have any previous knowledge about embedded programming, it's a little hard to make the whole chain work well in a short time. The raspberry pi stuff is different from the bare-metal programming, cause u need to deal with the linux system rather than the hardware.
If you need something in a hurry, I recommend having a try of Arduino, it's a fully developed ecosystem.
I'm now busy making the latest beta version of SwiftIO board. It's about 10 pieces. If everything goes well, I may make a small-batch production in October. Before that, I will give an update here and count those guys who are interested. Plz stay tuned : )
Thanks for your reply! I have a couple of Arduinos and similar (not only raspberry pi) lying around but I was hoping to try with Swift instead of C/Lua. I will patiently await your updates then :)
Just to add some news: I have a Mac Mini coming next Monday, and my plan is to work on LLVM/Swift and/or Swift for MCU. So @andyliu definitely please keep me on your list of interested parties.
I have extensive implementation experience with C/C++ compilers for embedded systems, including the -M4 and -M7 cores which I think should/might work for Swift. We have our own IDE derived from CodeBlocks, probably too much work to make it work with Swift for now, and I am mainly interested in developing the compiler and runtime, not the IDE.
I am the author of the thesis Swift for Embedded Systems mentioned in this thread. After a long time, I finally got back to working on it so I would like to share some progress with you
It is still in an early phase, but I am currently not aware of any bugs (but there are some, for sure ).
The toolchain itself now supports any thumbv7m or thumbv7em-based device.
I managed to reduce the code size of a "Hello World" app down to one megabyte, which is still not great, but it means any board with 2MB of FLASH can be used comfortably to run quite a big program! That was my goal, as such boards are generally available.
I am currently focusing on supporting the STM32F439ZI (NUCLEO-F439ZI), but adding support for any other board from the STM32F4 family should be very easy.
I added support to the Swift Package Manager, so you can organize your code to packages as you are used to :).
Tooling is important, so I added support to sourcekit-lsp too! :)
And the most important thing – everything is now open-sourced on GitHub and contributions are welcome!
Hi Alan,
have you considered adding the new Arduino Portenta H7 to the supported boards? It would be fantastic to be able to use Swift on an official Arduino board which is as powerful as this one.
The chip is also STM and ARM and therefore it should be the same toolchain.
As it is an official board from Arduino I think it will catch a lot of attention from the huge developer community which Arduino has. So I think a lot more people will use Swift on microcontrollers if it would be available on a board which is easily available via the Arduino store and which many, many developers are familiar with.
Hi Alan, finally meet you here : ) You've done a great job! In my implementation of baremetal Swift compiler, I made some hard-coded changes to the source code, especially those compiling scripts/cmake files for the standard library and runtime. It's not beautiful but just work. So it's really hard to merge it to the main stream in a short time. You've done much better than me on those aspects
After I added -fno-data-sections/-fno-function-sections flags to the compiler. I continued trying for 1 week to reduce the binary size. But I found it concerns not only the compiler but also a lot of work at the linking stage, then I just made a bootloader for the SwiftIO board so it could boot from the SD card. What I do now is coping the binary to the sd card. Hope you can have some good progress in this aspect
Let me introduce my SwiftIO board to you I will focus on this board in recent months. You must know some technical details about the NXP i.MX RT 105x microcontroller . It's based on thumbv7em and it's really powerful. I plan to leverage the open source RTOS zephyr as the base HAL abstraction. The board has just been added to the zephyr main stream a few days ago.
I've just received the latest version of SwiftIO board. I'll give some updates very soon. If all the testing is good. I plan to start preselling for the beta version board on my website. Hope I could get some advice from you then.