VoCore: Starter Tutorial Part1

In this tutorial, I will show you the full process about setup a develop environment and compile/run a “hello world” on VoCore, step by step.

1. Prepare Linux
a) Download and install VirtualBox. VirtualBox is a famous open source VM software, I like it. If you are using Linux OS already, just ignore this.

https://www.virtualbox.org/wiki/Downloads

Screen Shot 2014-11-20 at 10.45.00 am

Click on the links, you will get the install package, run it to install VirtualBox into your computer. If you have VoCore you can not be a newbie to such thing.

b) Download Ubuntu. Ubuntu is the first UI Linux I used. I like the font 🙂

http://www.ubuntu.com/download/
Screen Shot 2014-11-20 at 10.47.38 am

After download, you will get the ubuntu install iso file.

c) Setup VirtualBox and install ubuntu into it.
Screen Shot 2014-11-20 at 10.51.24 am (2)

Better to have 30GB free disk space(at least 20GB).
Screen Shot 2014-11-20 at 10.51.38 am (2)

Click “Create”, then double click the new item in VBox.
It will popup a window request you to select the iso.
Now select your downloaded ubuntu iso, then click Start.
Screen Shot 2014-11-20 at 10.51.59 am (2)

Rest is the install Ubuntu, I will not post here, please check ubuntu.com for the install instruction.

d) Install VirtualBox driver to ubuntu.
After ubuntu installed and startup successfully, we have to install VirtualBox driver so we can use the network, etc in VM.

Details is here: https://www.virtualbox.org/manual/UserManual.html

Now we have a Linux system in VM.

2. Prepare OpenWrt.(http://vocore.io/wiki/index/id:15)

a) Install necessary tools:
sudo apt-get install zlib1g-dev libncurses5-dev gawk subversion libssl-dev git

b) Download openwrt
git clone git://git.openwrt.org/openwrt.git

c) Make & Compile
goto openwrt folder(git create that), for example: cd ~/openwrt
make menuconfig
Screen Shot 2014-11-20 at 11.07.52 am (2)
make sure the config is like upper picture.

call make to compile openwrt, or make -jX for faster speed.(X is your CPU core number +1, for my macbook pro, it is -j9)

3. Write your first application.
use vi or any text edit, create main.c.

#include <stdio.h>

int main(void)
{
    return printf("hello world\n");
}

Now there are two ways to compile your main.c
One is to write a makefile, put the file to openwrt package folder, I will show this way in later tutorial.

Another way is super simple 🙂 Just make sure main.c is in current folder.

`find . -name mipsel-openwrt-linux-gcc` -g main.c -o hello

Now you have the compiled application, hello.
Note: you might get this warning, just ignore that.

mipsel-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined

4. Upload to VoCore

a) Connect to your VoCore.

Here is the tutoral

VoCore: Simple Start Tutorial 1

VoCore: Simple Start Tutorial 2

b) scp the file to VoCore, password vocore.

scp ./hello root@192.168.61.1:/tmp/

c) ssh to VoCore.

ssh root@192.168.61.1

d) Try to run your first app.
Works well 🙂
Screen Shot 2014-11-20 at 11.39.21 am (2)

Next tutorial, I will show how to remote control GPIO.

18 thoughts on “VoCore: Starter Tutorial Part1

  1. brandonhead

    In real application it is not that simple just calling gcc. Linking external libraries is the hard part. The helloworld example is not that meaningful.

    1. vonger Post author

      This is for beginners..:) I think this is “real” app. Just step by step, you can not become fat in one day. For me, library is just -l, but for beginners that is a long way.

  2. rcpaul

    Hi I am a super beginner. When I try “3. Write your first application.” I get ” -bash: syntax error near unexpected token `(‘ “

    1. vonger Post author

      Make sure openwrt is compiled successfully.
      And mipsel-openwrt-linux-gcc is somewhere in openwrt folder.

      1. rcpaul

        How do I know if openwrt is compiled successfully? When I run “make -j9” it does a bunch of compiles and makes (1,2,3). I don’t get any error codes when its done (when I think its done).

        1. vonger Post author

          goto openwrt/bin/ramips/ folder, check if there is openwrt-ramips-rt305x-vocore-squashfs-sysupgrade.bin, if not, your openwrt is not compiled.

  3. vonger Post author

    call this directly: find . -name mipsel-openwrt-linux-gcc
    what you get?

  4. rcpaul

    “./staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc”

    Thats what it comes back with

  5. vonger Post author

    Looks normal, this should work.
    ./staging_dir/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc -g main.c -o hello

    1. rcpaul

      “mipsel-openwrt-linux-gcc: error: main.c: No such file or directory
      mipsel-openwrt-linux-gcc: fatal error: no input files
      compilation terminated.”

      Thats what I get when I put that in

  6. vonger Post author

    Oh 🙂 I get it. …There is no main.c in your current folder…Just create one with that code.

  7. rcpaul

    gezz how do do that, go into “openwrt/staging_dir/target-mipsel_24kec+dsp_uClibc-0.9.33.2/bin/” and create a folder?

    1. vonger Post author

      orz
      Just use any text editor, create a text file with the source and named main.c then put it in your openwrt folder.

  8. vonger Post author

    If still not work, just search how to use gcc on google…

  9. rcpaul

    “#include

    int main(void)
    {
    return printf(“hello world\n”);
    }”

    This is the source that I name “main.c”?

    1. vonger Post author

      This source has some problem when I paste it to html..
      Now fixed.
      It should be #include

Comments are closed.