Raspberry Pi bare metal - Ultibo and Nim

The place to share and discuss your Ultibo projects.
mark
Posts: 1223
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Raspberry Pi bare metal - Ultibo and Nim

Postby mark » Mon Jul 30, 2018 8:17 am

https://github.com/markprocess/ultibo-nim

Blinks the raspberry pi's activity led using a combination of Ultibo and Nim
Ultibo - The Internet of Things that Just Work
User avatar
Ultibo
Site Admin
Posts: 2002
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Raspberry Pi bare metal - Ultibo and Nim

Postby Ultibo » Mon Jul 30, 2018 11:18 am

mark wrote:Blinks the raspberry pi's activity led using a combination of Ultibo and Nim

This is very much in line with where things are going with Ultibo.

I know almost nothing about Nim so far other than what I read in the five minute introduction, while it might not change the language I choose when writing my own code all of this does look very interesting.

Well done.
Ultibo.org | Make something amazing
https://ultibo.org
mark
Posts: 1223
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: Raspberry Pi bare metal - Ultibo and Nim

Postby mark » Fri Aug 10, 2018 6:03 pm

Ultibo wrote:
mark wrote:Well done.

Thanks. Update at https://forum.nim-lang.org/t/4087#25651
Ultibo - The Internet of Things that Just Work
Gavinmc42
Posts: 1387
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Raspberry Pi bare metal - Ultibo and Nim

Postby Gavinmc42 » Sat Aug 11, 2018 12:18 am

Hi Mark,
You might have to dumb it down for me, I am just a hardware guy trying to learn coding.
Nim seems to be a language,

How is it being used with Ultibo and why are you using it,
Which led is blinking?
I see what looks like the Ultibo Web Status page and what?
User avatar
Ultibo
Site Admin
Posts: 2002
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Raspberry Pi bare metal - Ultibo and Nim

Postby Ultibo » Mon Aug 13, 2018 11:30 pm

Hi Mark,

Do you have any reference on what would be needed to fully support Nim under Ultibo?

By that I mean being able to write a complete application in Nim then compile it and link with an Ultibo kernel to create a working application without needing any Pascal source except for maybe a project template wrapper that calls the Nim code on boot.

We have been working on creating an API that exposes the full Ultibo feature set to other languages, this will be in the form of a set of C header files (.h) which can be used by other languages to call Ultibo functions with all of the details of name mangling and calling convention etc already taken care of. All that is needed on the Ultibo side is for the new API unit to be included in the project.

Since most languages are actually written in C then having the header files means that support can be added for a whole range of languages over time, I am wondering whether this is also enough to make Nim support possible.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1387
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Raspberry Pi bare metal - Ultibo and Nim

Postby Gavinmc42 » Tue Aug 14, 2018 2:34 am

We have been working on creating an API that exposes the full Ultibo feature set to other languages,

Wow, not thinking small then ;)
I guess that would be why it has been quiet on new the releases?

Inverts all my thinking to date.
This Ultibo is too flexible, I'm still struggling with the VC4 stuff in 2.0.

Could build the Redox OS in Rust with Ultibo as the lowest layer?
Use QT5 over Ultibo?

This Nim language does look interesting.
mark
Posts: 1223
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: Raspberry Pi bare metal - Ultibo and Nim

Postby mark » Wed Aug 15, 2018 3:00 am

Ultibo wrote:Do you have any reference on what would be needed to fully support Nim under Ultibo?
No, not yet, I need to answer a handful of smaller questions for myself before starting into that. The two nim compiler switches that are relevant are --os and --gc. The current demo uses --os:standalone and --gc:none. I am working now to eliminate the --gc:none (in which case I expect to supply nim with one or more large blocks of memory allocated from ultibo's heap that are then managed by nim's gc.) Getting to --os:ultibo or something like it will answer what else is needed for complete support.

Do you have .h interfaces for ActivityLed/Enable/Disable/On/Off and GetTickCount? These are the functional parts of the demo. The current design uses ring buffers between the main thread and the nim thread. I'd like to add design number 2 that eliminates the buffers and has the nim thread directly call those led and clock functions. The nim source for design 2 would be indistinguishable from a typical nim main program. The build script would still make the nim code into a .a library to be linked with ultibo, and the ultibo part would create a thread that uses the standard nim main as its entry point. I think that would make a good stepping stone.

Mark
Ultibo - The Internet of Things that Just Work
mark
Posts: 1223
Joined: Mon Oct 03, 2016 2:12 am
Location: Indianapolis, US

Re: Raspberry Pi bare metal - Ultibo and Nim

Postby mark » Wed Aug 15, 2018 3:28 am

Gavinmc42 wrote:Hi Mark,
You might have to dumb it down for me, I am just a hardware guy trying to learn coding.
Nim seems to be a language,

How is it being used with Ultibo and why are you using it,
Which led is blinking?
I see what looks like the Ultibo Web Status page and what?

My initial interest in nim is that it provides a high level approach for embedded, but without garbage collection. I have some C/MCU projects for which I can't yet use ultibo but I want something better than C.

Of course, one thing led to another.

I asked the nim forum if anyone had blinked the led on an rpi without using linux. There was no response so I started with the activity led because it is on all rpi's and shows ultibo working on all rpi's with only the required boot files plus a 2MB kernel file. The ultibo part provides initialization and support but the mission is in nim. The web status page should provide all sorts of stimulation to the imagination of those that have eyes that can see.

If you have already included ultibo productively in your projects (as you report) then this particular connection between nim and ultibo might not be that helpful to you in the short term.

In and of itself, I anticipate replacing my bash and python scripts with nim.
Ultibo - The Internet of Things that Just Work
User avatar
Ultibo
Site Admin
Posts: 2002
Joined: Sat Dec 19, 2015 3:49 am
Location: Australia

Re: Raspberry Pi bare metal - Ultibo and Nim

Postby Ultibo » Wed Aug 15, 2018 10:56 am

mark wrote:Do you have .h interfaces for ActivityLed/Enable/Disable/On/Off and GetTickCount?

Yes, we have .h files created for almost every Ultibo function and are just working through the details of some that use strings and other FPC specifics.

If you are willing to test we can upload a couple of headers that provide just the minimal interface you are wanting and a matching Ultibo unit to manage the exports, it would be very good to get some feedback on how this setup works with other projects and languages.

Give us a couple of days and we'll publish the relevant bits as well as a small C example and makefile that shows how to use it.

mark wrote:The build script would still make the nim code into a .a library to be linked with ultibo, and the ultibo part would create a thread that uses the standard nim main as its entry point. I think that would make a good stepping stone.

That's exactly the strategy that we are working toward, the program is compiled to either a .a file or several .o files and linked into the final kernel image by FPC without the need to write any Pascal code at all.
Ultibo.org | Make something amazing
https://ultibo.org
Gavinmc42
Posts: 1387
Joined: Sun Jun 05, 2016 12:38 pm
Location: Brisbane, Australia

Re: Raspberry Pi bare metal - Ultibo and Nim

Postby Gavinmc42 » Wed Aug 15, 2018 12:38 pm

https://nim-lang.org/features.html
The binaries produced by Nim have zero dependencies and are typically very small. This makes their distribution easy and keeps your users happy.

Ok, I'm interested :D
But how well does Free Pascal's garbage collection compare?
I have yet to notice any garbage collection issues with Ultibo.

Embedded
https://github.com/nim-lang/Nim/issues/4437

Converts Pascal to Nimrod ;)
http://nimrod-lang.org/#cross-compilation

Use cases
https://github.com/nim-lang/Nim/wiki/Nim-use-cases

If I understand, you guys are thinking that Nim's RTL run time library will be written in Ultibo?
That would also include all the VC4 stuff being accessible?

Hardware/software abstraction layer that looks like SDL?

Return to “Projects”

Who is online

Users browsing this forum: No registered users and 0 guests