Will the P2 be able to run linux with one cog + load other cogs?
Christof Eb.
Posts: 1,214
Hi,
will the P2 be able to run for example Linux with one cog and then load the other cogs independently with control tasks?
Background of the question:
I have now played with a beaglebone black. While the full blown Linux with its graphic Desktop is very impressing, it seemed (for me) to be impossible to make a time critical control software, because ports are not fast accessible with all that Linux overhead.
I have then switched to arduino yun now, which combines simple arduino programming and its pin access possibilities with a second processor running Linux. The link beween the two worlds is only a Serial line.
It would really be stunning, if such two worlds could be integrated into one P2!
will the P2 be able to run for example Linux with one cog and then load the other cogs independently with control tasks?
Background of the question:
I have now played with a beaglebone black. While the full blown Linux with its graphic Desktop is very impressing, it seemed (for me) to be impossible to make a time critical control software, because ports are not fast accessible with all that Linux overhead.
I have then switched to arduino yun now, which combines simple arduino programming and its pin access possibilities with a second processor running Linux. The link beween the two worlds is only a Serial line.
It would really be stunning, if such two worlds could be integrated into one P2!
Comments
I don't know what Linux would entail, hardware-wise, but I've heard it mentioned here that Linux requires a Memory Management Unit, which I assume remaps blocks of memory. I don't know if that's something that can be worked around in software, or not. Otherwise, your idea seems reasonable.
Or the P2 could emulate a processor that has an MMU in software and run a full version of Linux.
uCLinux might work at a pinch but is hardly what we are after.
Still, if Linux can be run on an 8 bit AVR running a ARM emulator we are in with a chance.
http://dangerousprototypes.com/2012/03/29/running-linux-on-a-8bit-avr/
I can't see it being a practical proposition though.
As for "load the other cogs independently with control tasks?" That is much the same as a Linux driver loading firmware into a GPU or WIFI adapter or whatever device.
Historically it is an OS for multiusers and a sophisticated file system. This might be done. For myself, I wonder why I would need such a tiny multiuser system... after all I use most of my projects alone. The Propeller does nicely with SDcards and FAT32 as a single user OS.
On the other hand, if you are just hoping to be able to go to a depository and download just about any of the vast code libaries that Linux has available, compile them via C, and use them in a GUI environment... you might be much happier with a Raspberry Pi or an alternative OpenAVR device that will take an Ubuntu image.
And I also thin that loading the entire LInux OS kernel` on one cog and using other cogs for other things is not very realistic. If you want all and everything that Linux can do, it will use several cogs to provide complete services.
~~~~~~~~~~~~~
I do understand your frustration with having only a serial link to another processor for time critical processes. But I suspect that you really would find just using a Propeller without LInux more rewarding.
David Hein has developed a Forth environment called SpinX, that is a LInux-like single user OS. You can use a terminal interface to Linux machine and get a very nice real-time user interface.
I have had excellent results in writing code in Forth that loads itself to an unused cog, runs its task and then exits the cog so that the next Forth task can come along and use the vacant cog. I even wrote a HOWTO for pfth Forth on how to do this. It is easy and fast.
-Phil
Never mind the "multiuser" thing. A kernel like Linux is very useful when you want a lot of different programs working together on a single machine.
The problem with the Pi and such machines is that they have limited I/O and high speed real world interfacing possibilities. That is why some new ARM chips come with little "CPU's on the side" to do external interfacing.
Conversely the problem with micro-controllers is that they can handle Linux or just "big code". That is why XMOS now makes a version of it's MCU with an ARM core added.
I agree it does not seem Linux on the Propeller would ever be more than a curio, rather like being able to run CP/M.
I'm sure that if it is possible --- That will be people on forum that made it!
Given even an AVR can 'run lkinux'. a better question is 'is it practical to run Linux', or similar ?
Arduino Yun uses a Linux WiFi module, Atheros AR9331, which seems a simple building block, with a tolerable price.
Using that alongside a P2, certainly could give a powerful system.
The best first steps would be starting with two blocks, and then see how much Linux Grunt is really used, and what useful tasks _need_ this combination.
A serial line is not a bad link, it just needs to run fast enough
Or, do you want the Linux for the ability to use the device like a computer which then does your Projects easily?
In the first case, P2 won't need something like Linux to get things done. The hardware multi-processes easily.
In the second case, the P2 is best applied as a peripherial to a Linux system.
A Linux hosted development environment? (I think P2 may surprise us being able to host its own development environment since I know that is one of Chip's goals.)
A Linux to collect and crunch data, do vision processing or other tasks that fit well in its bag of tricks? Then the the P2 will make a dandy Field Programmable SPI device (FPSPID?). I think all the magic sauce has now been added to make it able to function as an SPI slave.
Now, you can support high speed (230K-2Mbit) serial connections that allow you to load independent COGs with functionality (OK, you have to knuckle under to one of the Forths but the capability is there)
I think we need to know why Linux? Because a single COG Linux will be mighty disappointing for most things that would probably just be better done with some native Spin/PASM/C on the Propeller. You should be able to host a keyboard/mouse/video and some simple monitoring functions in a single COG and still have 7 COGs to play with. Not a bad set up for a microcontroller!
Linux is great and has a place at the table but I don't quite understand what a single COG Linux will buy you over other solutions.
But I really think you can work with the Proeller and one serial port as interface if you use an interpreted language. It doesn't matter which Forth you choose -- Tachyon, PropForth, or pfth. They all can provide the means to define a task that starts a cog, runs the task, and then stops the cog. This feature combined with an SDcard to extend dictionary space pretty much means that you can allocate cogs in real time and from a Linux computer or a dumb terminal. Also, the serial can be full duplex to assure that the computer that is designating tasks is getting responses as fast as possible.
The biggest advantages that the P2 would bring are [1] a lot more RAM for a Forth dictionary, so you may not require an SDcard, [2] a heck of a lot more i/o pins, and [3] built-in ADC and DAC for all i/o. If none of these are particularly important to you, you can just get started with a P1.
Peter J of TachyonForth is using this cog starting and stopping to get a complete Web server in a P1 that allows itself to be reconfigured on the fly. IOW, with Forth.. you may have all the power you need.