Shop OBEX P1 Docs P2 Docs Learn Events
Will the P2 be able to run linux with one cog + load other cogs? — Parallax Forums

Will the P2 be able to run linux with one cog + load other cogs?

Christof Eb.Christof Eb. Posts: 1,195
edited 2013-12-15 03:37 in Propeller 2
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!

Comments

  • cgraceycgracey Posts: 14,151
    edited 2013-12-14 09:23
    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!

    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.
  • Bill HenningBill Henning Posts: 6,445
    edited 2013-12-14 09:51
    There is an mmu-less uCLinux that should be able to run on P2, RetroBSD is another possibility.

    Or the P2 could emulate a processor that has an MMU in software and run a full version of Linux.
    cgracey wrote: »
    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.
  • Heater.Heater. Posts: 21,230
    edited 2013-12-14 10:31
    Real Linux requires an MMU and interrupts.
    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.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-12-14 10:38
    It really depends on what you think LInux really is.

    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 Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-12-14 10:45
    If the objective is to combine Linux with the P2, I would pick another proceesor more suited to Linux (e.g. a cheap ARM) and use the P2 as a coprocessor for the things that it's good at.

    -Phil
  • Heater.Heater. Posts: 21,230
    edited 2013-12-14 10:50
    We know exactly what "Linux" is. It is that body of software you can check out from this repository https://github.com/torvalds/linux

    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.
  • SapiehaSapieha Posts: 2,964
    edited 2013-12-14 10:51
    Hi Christof Eb.

    I'm sure that if it is possible --- That will be people on forum that made it!


    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!
  • jmgjmg Posts: 15,173
    edited 2013-12-14 11:24
    Hi,
    will the P2 be able to run for example Linux with one cog and then load the other cogs independently with control tasks?

    Given even an AVR can 'run lkinux'. a better question is 'is it practical to run Linux', or similar ?

    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.

    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 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!

    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 :)
  • potatoheadpotatohead Posts: 10,261
    edited 2013-12-14 12:31
    Would you still want that Linux if you could build your projects without it easily?

    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.
  • mindrobotsmindrobots Posts: 6,506
    edited 2013-12-14 12:57
    To add to what everyone else has said. What functions do you want/need from Linux?

    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.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-12-15 03:37
    In the beginning, I too was hoping for Linux on microcontrollers just because it is such a rich educational environment and at no cost. In fact, all my regular computers are loaded with Linux, even if there is Windwos installed.

    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.
Sign In or Register to comment.