June 22, 2020

The DPH153-AT Femtocell - running my own code

The Femto is a MIPS system, so I will need a cross toolchain. My first goal would be to just run the usual "hello world". I can pull code to the femto using tftp, which is adequate for the few tests I want to run. The issue of adding things permanently (to flash) is another topic entirely that I am postponing, perhaps indefinitely.

Since linux runs on a bunch of the open source MIPS based routers, I thought I would look at ddwrt, tomato, and openwrt and settled on OpenWRT to get started.

So away we go:
cd projects/Femto
git clone https://git.openwrt.org/openwrt/openwrt.git
mv openwrt Openwrt
cd Openwrt
git fetch --tags
git tag -l  (lists available tags)
git checkout v19.07.3
This version is the last tag listed and what is recommended in the "install build system" tutorial.

Then I type "make prereq" and after a bunch of checking I get presented with a GUI. This is the OpenWRT config dialog.

I select "MediaTek Ralink MIPS" as the target, "RT3x5x/RT5350 based boards" as the subtarget. I select "default profile".

And I type "make"

It makes a bunch of stuff in "tools" and then is on to the races. 2 hours later it is still going. I should have run make as "make -j8" or maybe even "make -j" which puts no limit on concurrency.

I do see "dropbear" getting compiled.

Try something

I rummage around for a candidate in Openwrt/build_dir/target-mipsel_24kc_musl. I settle on "lua". The executable is "lua" and is a mere 21020 bytes. I use tftp to pull it over to the femto, and need to disable my host firewall for tftp to run (due to my use of a 192.168.73.x subnet). The transfer takes a small fraction of a second. Then I use chmod a+x and type ./lua -- and get:
-sh: lua: not found
Well, this is not good and is clearly a bad error message (the file is right there). I try copying it to /bin and still the same message. This is probably some kind of shared library issue (but maybe I am tricking myself since I have expected that to be an issue all along). Maybe it is a bad file format. I see:
file lua
lua: ELF 32-bit LSB executable, MIPS, MIPS32 rel2 version 1 (SYSV), dynamically linked,
interpreter /lib/ld-musl-mipsel-sf.so.1, with debug_info, not stripped

I clearly don't have that library on the target system.
Compare that to:

file wizard
wizard: ELF 32-bit LSB executable, MIPS, MIPS-II version 1 (SYSV), dynamically linked,
interpreter /lib/ld-uClibc.so.0, stripped
Interestingly, look at this:
ls -l ld-musl-mipsel-sf.so.1
lrwxrwxrwx 1 tom tom      7 Jul 23 17:59 ld-musl-mipsel-sf.so.1 -> libc.so
ls -l libc.so
-rwxr-xr-x 1 tom tom 626691 May 16 11:32 libc.so

Pretty big. But on the device itself:

cd /lib
ls -l *libc*
-rw-r--r--    1 1000     1000       749580 libuClibc-0.9.28.so
lrwxrwxrwx    1 1000     1000           19 libc.so.0 -> libuClibc-0.9.28.so
lrwxrwxrwx    1 1000     1000           19 libc.so -> libuClibc-0.9.28.so
-rwxr-xr-x    1 1000     1000        26472 ld-uClibc-0.9.28.so
lrwxrwxrwx    1 1000     1000           19 ld-uClibc.so.0 -> ld-uClibc-0.9.28.so

Interestingly, there is no "mv" (or even "ln") on my target system. However there is cp, so I can copy then erase the original to achieve the same as "mv"

I find ld-musl-mipsel-sf.so.1 in Openwrt/build_dir/target-mipsel_24kc_musl/root-ramips/lib I copy the file to /var/lib/tftpboot/femto, then:

tftp -g -r femto 192.168.73.5
cp femto /lib/ld-musl-mipsel-sf.so.1
Now the message changes to:
lua
-sh: lua: Permission denied

The file is owned by root (and root is trying to run it).  No chown in the target system.


Have any comments? Questions? Drop me a line!

Tom's electronics pages / tom@mmto.org