I have a TV set top box that i'm currently experimenting on:

enter image description here

I established a serial console connection to it through a serial port located on the board. I am trying to compile a simple C executable to run on this device but I can't seem to find out how to do so.

I tried CodeSourcery, cross-compiler-mipsel and uClibc but they didn't work and in the later was very confusing to build with its configuration options.

Here is the data I was able to collect about the system:

A sample file architechture:

apps-startup: ELF 32-bit LSB  executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.12, stripped

System information:

tangox[/]# uname -a
Linux tangox #3230 PREEMPT Thu Oct 3 15:54:23 IST 2013 mips GNU/Linux


tangox[/]# cat /proc/cpuinfo 
system type             : Sigma Designs TangoX
processor               : 0
cpu model               : MIPS 24K V7.12  FPU V0.0
Initial BogoMIPS                : 332.59
wait instruction        : yes
microsecond timers      : yes
tlb_entries             : 32
extra interrupt vector  : yes
hardware watchpoint     : yes
ASEs implemented        : mips16
shadow register sets    : 1
VCED exceptions         : not available
VCEI exceptions         : not available

SMP8XXX Chip ID         : 8653
SMP8XXX Rev ID          : 2
System bus frequency    : 333000000 Hz
CPU frequency           : 499500000 Hz
DSP frequency           : 333000000 Hz


tangox[/]# dmesg
Linux version (buildmgr@hulk) (gcc version 4.3.2 (Sourcery G++ Lite 4.3-51) ) #3230 PREEMPT Thu Oct 3 15:54:23 IST 2013
Mixed DRAM usage enabled.
Configured for SMP865x, detected SMP8653 (revision ES2).
Detected CPU/System/DSP Frequencies: 499.50/333.00/333.00MHz
SMP86xx Enabled Devices under Linux/XENV 0x9f3fbff4 = 0x003303f8

Files and directories:

tangox[/]# ls
apps@             images/           mrua_SMP8654F/    sysfs/
apps-peer/        init*             mruafw/           system@
bin/              initial_settings/ opt/              tmp/
cpgui/            lib/              probe/            upgrade/
data/             linuxrc@          proc/             usr/
dcchd_SMP8652/    logd/             rfs/              var/
dev/              lost+found/       root/             vnms/
etc/              media@            sbin/             webkit/
home/             mnt/              sys/

tangox[/]# find . -type f -name *.c
tangox[/]# find . -type f -name *.h
tangox[/]# find . -type f -name *.cpp
tangox[/]# find . -type f -name *.hpp
tangox[/]# find . -type f -name *.so

There are no kernel or library headers but only static libraries. How do I create binaries that are compatible with this board?


Of course nobody will leave any source code on embedded system, because this is unnecessary. Embedded systems like yours usually have little space even to store their firmware.

You see that it contains glibc. It's seen by presence of shared objects in /lib version-named -2.8.so. You need glibc compatible toolchain which contains glibc 2.8 or earlier to compile binaries for this system.

Or you can abandon idea of building with glibc and just statically link your executables with uClibc toolchain. Use -static command line argument.

Building with musl libc is even easier and there are already toolchains for that. You just put one libc.so into /lib, dynamic linker symlink to it and your binary somewhere.

I hope apps-startup is from your board and you already know what endianness it runs.

And you did not mentioned your requirements for your simple C executable. Maybe it requires additional libraries that you probably will need to build.

| improve this answer | |
  • I'm new to cross compiling and have average knowledge in gcc so i'm not sure how to use glibc, uclibc or musl libc yet. However i tried mips-linux-gnu-gcc with these flags -EL -mips32 and was able to compile a simple program that loops 10 times and print something each time. What i'm trying to do now is to compile openssh-server for this board but i'm getting problems with zlib library, could you direct me to some sources where i can learn how to do that i would appreciate it. The apps-start is from the board btw. – razzak Dec 29 '15 at 19:02
  • I did not tried cross compiling openssh for other architectures, and you'll not only need zlib but also openssl, which is tricky to compile (not even saying to cross compile). I can suggest you building dropbear instead - it has all crypto code inside and today it's nearly same grade ssh server as openssh. – user140866 Dec 30 '15 at 3:01
  • And if you want to cross compile stuff with packages that use configure, you need to pass something like --host=mips-linux-gnu when compiling. And if you need additional dependencies, you need to point to them with additional CFLAGS and LDFLAGS like that: ./configure --host=mips-linux-gnu --prefix= CFLAGS=-I/path/to/libs/include LDFLAGS=-L/path/to/libs/lib, where /path/to/libs is where you're going to install libraries dependencies for mips architecture (install somewhere in your /home). – user140866 Dec 30 '15 at 3:06
  • And if you're really need openssh, I suggest you not messing with openssl but use libressl fork instead - it has at least very nice cleaned up build system which do not tie you to know crippled internals and having perl as build time requirement. – user140866 Dec 30 '15 at 3:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.