News:

Registered a URL and setup a forum as the IPCam stuff really needed its own site vs my irregular blog posts about IPCam hacking at http://www.computersolutions.cn/blog

Author Topic: Compiling a simple "Hello world" C program for a hi3518 camera  (Read 1577 times)

  • No avatar
  • *
August 05, 2016, 02:49:33 pm
Hi,

I have got my hands on a Yi home camera that is basically a hi3518 based camera. I have root terminal access to it via telnet and it is already running an FTP server among other stuff, so I can easily copy files over to it.

The first lines of dmesg are like this:

Quote
Linux version 3.0.8 (rock07@Server) (gcc version 4.4.1 (Hisilicon_v100(gcc4.4-290+uclibc_0.9.32.1+eabi+linuxpthread)) ) #1 Wed Apr 30 16:56:49 CST 2014
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00053177
CPU: VIVT data cache, VIVT instruction cache
Machine: hi3518

So, I want to cross compile a simple "Hello World" C program for it. I downloaded the hi3518 SDK (v. 1.0.7.0) and I can successfully run the compiler.

Quote
$ arm-hisiv100nptl-linux-gcc --version
arm-hisiv100nptl-linux-gcc (Hisilicon_v100(gcc4.4-290+uclibc_0.9.32.1+eabi+linuxpthread)) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Then I wrote the simplest Hello World program I could think:
Code: [Select]
#include <stdio.h>

int main(void){
    printf("\n-----------\nHello, I am the Yi camera!\n-----------\n\n\r");
    return 0;
}

I am trying to compile it with the following command:
Quote
$ arm-hisiv100nptl-linux-gcc hello.c -o hello

I also tried to specify the architecture, with the same results:
Quote
arm-hisiv100nptl-linux-gcc -march=armv5 hello.c -o hello
And an executable called "hello" is created as expected.
As soon I transfer it over the camera and making it executable (just to be sure), I get an "Illegal instruction" thrown at me when I am trying to run it.
Quote
./hello
Illegal instruction

Any ideas on why this happens? It should be pretty much straight forward to run this. What am I doing wrong?