June 1, 2024

Antminer S9 board - linux - importing executables

I have two goals here. One is to be able to write C programs and then compile and run them. The other is to bring in other useful packages (like vim, bash, and python).

Setting up a C compiler to cross compiler user space ARM executables on my x86 Fedora system is nothing that can be done using existing Fedora packages -- So I am not going to pursue that.

What I did do is to dig out an OrangePi PC board along with and SD card with "Armbian" (a form of Debian) and boot that up. That has a C compiler and a full suite of things. I compiled the usual hello world in two ways:

cc -o hi -static hi.c
cc -o hi2 hi.c
Somewhat to my suprise, both run fine -- there is no need to static link.

make and PATH

I copied over "make" and it worked without any problem. Now I want to put it someplace "official".
I do this:
su
cd /usr
mkdir local
chown tom:tom local
Then as tom, I do this:
cd /usr/local
mkdir bin
cp /home/tom/make bin
And there we have it. I make /usr/local owned by tom to make my life simpler as I expect to be continually adding things for a while.

The PATH is set by /etc/profile and has /usr/local/bin already in it, and at the front so that things I place into /usr/local/bin will take priority over the less desirable things provided by busybox.

bash

I also copy this from the armbian donor system and place it into /usr/local/bin. Then I edit /etc/passwd and make this the login shell for user tom. It does not work until I add bash to the file /etc/shells. After doing this, I can log in via ssh as tom and get a bash shell. For one thing this gives me history. For another, it gives me filename completion.

vim

This is not so easy. I get:
./vim: error while loading shared libraries: libselinux.so.1: cannot open
I am surprised that vim needs to have anything to do with selinux.
On the donor system I do:
cd /usr/bin
ldd vim
libselinux.so.1 => /lib/arm-linux-gnueabihf/libselinux.so.1 (0xb6cef000)
I copy this to /usr/lib and then find I have to do the same for:
/usr/lib/arm-linux-gnueabihf/libgpm.so.2
/lib/arm-linux-gnueabihf/libpcre.so.3
After this, Vim starts up, telling me it is version 7.4.576 It seems to work just fine.

python

I expect trouble with this. I copied "python" (which is python 2.7.9 on the donor system). I get this:
Could not find platform independent libraries 
Could not find platform dependent libraries 
Consider setting $PYTHONHOME to [:]
ImportError: No module named site
I tried copying the entire /usr/lib/python2.7 tree. And now it starts up! Running python 2.7.9

ruby

This one gives me:
error while loading shared libraries: libruby-2.1.so.2.1: cannot open shared object file
libruby-2.1.so.2.1 => /usr/lib/arm-linux-gnueabihf/libruby-2.1.so.2.1
libgmp.so.10 => /usr/lib/arm-linux-gnueabihf/libgmp.so.10
After these libraries are provided in /usr/lib, I get:
:1:in `require': cannot load such file -- rubygems.rb (LoadError)
	from :1:in `'
I copy /usr/lib/ruby -- now I get:
/usr/lib/ruby/2.1.0/rubygems.rb:8:in `require': cannot load such file -- rbconfig (LoadError)
	from /usr/lib/ruby/2.1.0/rubygems.rb:8:in `'
	from :1:in `require'
	from :1:in `'
I run "apt-get update" on my donor Debian system (it runs Jessie). The lines all show "Ign" or "Err". Then "apt-get install mlocate.

I track down rbconfig.rb in /usr/lib/arm-linux-gnueabihf/ruby, so I copy that over and:

su
cd /usr/lib
mkdir arm-linux-gnueabihf
chown tom:tom arm-linux-gnueabihf
su tom
cd arm-linux-gnueabihf
mkdir ruby
cd ruby ; tar xvf /home/tom/ruby.tar
After this I type "ruby" and don't get a prompt. But this is actually correct. I put together a short script and it works. This is ruby 2.1.5p273 from 2014.
Feedback? Questions? Drop me a line!

Tom's Computer Info / tom@mmto.org