Vidar

Vidar

How to make Nerves use all processors of ARM processors with different type cores?

Hi everyone,

Some time ago I got a wrongly shipped Luckfox Lyra Ultra (https://www.luckfox.com/Luckfox-Lyra-Ultra). As it seemed like a handy format, and I had no other use for it, I decided that would be an interesting one to learn how to get Nerves running on a new target. And while it has been more interesting than I imagined it finally does give me iex and run programs.

The Rockchip RK3506B processor on this one has 3 ARM Cortex-A7 processors and one ARM Cortex-M0. I got Nerves running the 3 A7s but not the M0. It can be started and run on its own in parallel, but not as part of Nerves.

That is a random hobby project anyway so not that important, but the learning process it is also a warm up for using the Rockchip RK3588 with Nerves. And that one has 4 of each type of processor core so a good solution to use all would be nice.

I’ve tried searching around, so sorry if this is a recurring question, but how is this best handled?

Marked As Solved

lawik

lawik

Nerves Core Team

My understanding of M-cores is limited. But I understand it as being essentiallt an integrated microcontroller on the device. Nerves (with Linux) won’t go on there.

Now if it has access to enough memory and someone does the effort to establish support you might be able to do Elixir on it via AtomVM. Since that runs on microcontrollers.

My expectation is that Nerves would be able to program the M-cores and talk to whatever runs on there through some shared mechanism. But not that Nerves runs on those cores.

Also Liked

Vidar

Vidar

Well, this turned into a very long day. The 4*A76 and 4*A55 show up as 8 cores. I guess the faster cores will just finish and get more work faster.

It should be an interesting SBC. Ethernet, Wifi, sound, the GPU, VPU and NPU all report for duty. And so do the HDMI outs and the interesting HDMI in. Whether all work as expected is for testing and fixing another day.

Vidar

Vidar

So this is a bit of a rabbit hole except there be dragons in that hat! Since I’m just waiting for some rebuild I’ll do a little update:

The Radxa 5 series have two workable approaches, but neither is perfect. They are imperfect in different ways though:

  1. The official Radxa setup forked off at about linux kernel 6.1, and there are many proprietary blobs and drivers to make things like the NPU and VPU work. Reportedly it does so just fine. I made an image with that, but then hit the combination of wanting a browser kiosk solution with Mali GPU acceleration. Several possible ways were tried but in the end the conclusion was that I couldn’t make the Mali GPU driver work with 6.1 kernel needed for the other stuff. For the 5T I also had to backport the Wifi driver. (Reference if anyone else have a go at this version).

  2. The other path, which initially at least was much smoother, was going with the mainline linux kernel and the amazing work of Collabora and all their patches and improvements for the RK3588. Getting a kiosk up and running with Mali GPU acceleration was just fine. Thus the setup I’m working on now is based on their stable 6.18 linux kernel for the RK3588. No proprietary out of reach secret blobs, but on the other hand not (yet) full NPU and VPU functionality.

    For the NPU though Tomeu Vizoso have obviously put serious work into making an open source alternative. Drivers and libraries like Rocket, Mesa and Teflon make the NPU available without the Radxa proprietary blobs. The NPU has 3 cores though, and currently the above will only use one. Thus I’ve put up a round robin worker pool where each worker gets their own video frame. 3 workers are busy at the NPU at any time while a 4th worker is busy loading up the data to use. That seems to work pretty well. XLA does not support the NPU yet though, so a nice Elixir EXLA/ Axon/ NX solution seemed out of reach. Thus it is now built around a Rust NIF.

    The VPU functionality on this the open source alternative is currently limited to full HD decoding in various codecs and just jpg encoding. For higher resolutions it seems some OpenCL work might be needed.

    The headphone sound has had me stumped for hours and demoralized. The chip is old and used on many other SBCs for years so one would think it would be a well explored and documented how to make it work. I finally found the 37 page user guide to that chip, and most pages seems to be registers to combine and set just right. If I happen to get sound I’ll play the lottery the same day for sure!

    The 3588 also have two ISPs handling up to 48 megapixels. That was a welcome surprise, although I still have no idea of how to actually access or use them. Later is probably the right time for that.

Vidar

Vidar

Yes, it slowly dawned on me after posting that the M0 core is actually the same as used on the RP2040. If a core is not capable it makes sense that it is just ignored. It seems it was added more as a coprocessor for GPIO pins and so on. If I can find a half justified use case I’ll play a bit with that and see how that goes.

But for more capable different core processors I assume the logic then is that Nerves will use all cores capable enough? And for better or worse match the workload with their relative capabilities? That would be quite impressive out of the box!

Last Post!

lawik

lawik

Nerves Core Team

Excited about the NPU. Then I can use it with ex_nvr. I already have an implementation for the Pi Hailo accelerator.

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New

Other popular topics Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement