2014-09-13

Arduino with MINIX NEO X5 mini

Intro

I received the "MINIX NEO X5 mini" as a gift some time ago. The TV set I have is pretty much filled with multimedia capabilities so having an android based entertainment system was not that appealing to me. I've spent a lot of time thinking how could I put it to better use so I decided to use it as a gathering node for my arduino projects. In order to use the device this way I had to root it. The process of rooting is described here. But be careful since the rooting scripts are not 100% correct. I had to edit some of them in order to make everything work. It's a trial and error. The remote coming with the device is not the best solution when it comes down to interfacing with the android. I strongly recommend using a mouse.

Linux Deploy

The original plan was to install some sort of linux on my "MINIX NEO X5 mini" but it actually turned out that "Linux Deploy" is a decent alternative because there is not a lot of messing around with the system and is really easy to install. Once you run the app you are going to see the IP address of the host system. That info is very useful later on. The icons are placed to the right side.

  • Start
  • Stop
  • Properties
  • Context

Before doing anything we have to setup the properties. The default install platform is Debian. Adapt the mirror URL according to your location. You can find the locations here, mine is for instance http://ftp.hr.debian.org/debian/. Under Settings I enabled autostart so that I don't have to run the application every time MINIX turns off. Once you are ready to install linux go to the properties again and press "Install". This will take around 20-30 minutes. When everything is finished you should see a success message. It's time to start the installation. All you have to do is to press the start button. I'll assume that the rest of the tutorial will be followed along from some other computer in terminal. In the top left corner you can see the IP address of the "MINIX NEO X5 mini". The installed system does not support serial communication out of the box because the modules for serial communication were removed from it. You can add the modules with the following commands:

        $ ssh android@IP_FROM_TOP_LEFT_CORNER
        android@IP_FROM_TOP_LEFT_CORNER's password:

        [type in the default password: changeme]

        Linux localhost 3.0.36+ #172 SMP PREEMPT armv7l
        Debian GNU/Linux 7 (wheezy) [running on Android via Linux Deploy]

        ~$ mkdir temp
        ~$ cd temp

        ~/temp$ wget http://www.tatsch-it.de/wp-content/uploads/2014/06/cdc-acm.ko_.zip
        ~/temp$ sudo apt-get install zip
        ~/temp$ unzip cdc-acm.ko_.zip
        ~/temp$ sudo insmod cdc-acm.ko
        ~/temp$ sudo mkdir /lib/modules
        ~/temp$ sudo mkdir /lib/modules/`uname -r`
        ~/temp$ cd /lib/modules/`uname -r`

        3.0.36+$ sudo mkdir -p drivers/usb/class
        3.0.36+$ sudo mv ~/temp/cdc-acm.ko /lib/modules/3.0.36+/drivers/usb/class/cdc-acm.ko
        3.0.36+$ sudo touch /lib/modules/3.0.36+/modules.order
        3.0.36+$ sudo touch /lib/modules/3.0.36+/modules.builtin
        3.0.36+$ sudo depmod -a
        3.0.36+$ sudo nano /etc/modules

        # add a line "cdc-acm" to the file
        # don't do it in a line starting with "#"
    

After doing the previous steps go back to the the Linux Deploy and press STOP. Wait for the system to shut down and then press START again. Now go back to the shell and reconnect to the linux deploy and check if the module was loaded after the restart it should look something like described in the following section:

        $ ssh android@IP_FROM_TOP_LEFT_CORNER
        android@IP_FROM_TOP_LEFT_CORNER's password:

        [type in the default password: changeme]

        Linux localhost 3.0.36+ #172 SMP PREEMPT armv7l
        Debian GNU/Linux 7 (wheezy) [running on Android via Linux Deploy]

        ~$ sudo dmesg | grep cdc_acm
        [ 1238.018779] usbcore: registered new interface driver cdc_acm
        [ 1238.018827] cdc_acm: USB Abstract Control Model driver for 
        USB modems and ISDN adapters
    

Arduino

We won't do anything too complicated with the arduino. At the moment all we are interested in is the serial communication, so we will write a simple hello world level sketch and upload it to our arduino:

        int counter;

        void setup(){
          Serial.begin(9600);
          counter = 0;
        }

        void loop(){
          counter++;
          
          Serial.print("Hello from android ");
          Serial.print(counter);
          Serial.println();
           
          delay(1000);
        }
    

Upload the sketch and go to tools > Serial Monitor. You should see something like:

        Hello from android 1
        Hello from android 2
        Hello from android 3
        ...
    

Back to the Linux Deploy

        $ ssh android@IP_FROM_TOP_LEFT_CORNER
        android@IP_FROM_TOP_LEFT_CORNER's password:

        [type in the default password: changeme]

        Linux localhost 3.0.36+ #172 SMP PREEMPT armv7l
        Debian GNU/Linux 7 (wheezy) [running on Android via Linux Deploy]

        ~$ ls /dev/tty*0
        # you should see /dev/ttyACM0 
        # in the list after you plugin the arduino to the MINIX

        # let's check what the arduino is sending us

        ~$ cat /dev/ttyACM0
        Hello from android 1
        Hello from android 2
        Hello from android 3
        Hello from android 4
        ^C
    

Your "MINIX NEO X5 mini" can now communicate with the Arduino over the serial port. Just imagine the things the MINIX is now capable of :)

RedEye Sleep Toggle(Free)

If you leave your MINIX on for too long, It might go into some kind of a sleep mode. To prevent this I installed the RedEye Sleep Toggle(Free) and set it up to start when the MINIX is started. Enjoy!

2 comments:

Anonymous said...

Hi Marko, congratulations for the work!
I try to install on Minix neo X5 Linux with Linux Deploy, but i receive error "Checking mount point".
Which SD card have you used? There are other setting? Many Thanks

Marko Švaljek said...

I used the internal storage of the Minix, I didn't use any kind of extra SD card to do this. Could you email me your linux deploy settings to msvaljek@gmail.com. Also the device has to be rooted.