Skip to content

EXA8 Development

Lorenzo Mangani edited this page Jul 7, 2019 · 7 revisions

Cross-Compiling for EXA8/ARM64

The EXA8 ships by default with OS Ubuntu Xenial for ARM64. Developers can easily cross-compile software for the platform using Docker and the arm64v8/ubuntu:xenial image

QEMU

QEMU is required on the Docker host in order to execute arm64/aarch64 code:

apt-get install -y qemu-user-static qemu-user

Docker pipeline

Create a script (builder.sh) with commands to build your application inside the running container.

git clone https://github.com/example/my_arm_app.git
cd my_arm_app.git
make

The following pipeline can be used as example to map qemu and launch any script within the arm64v8/ubuntu:xenial container:

docker run --rm \
  -v /usr/bin/qemu-aarch64-static:/usr/bin/qemu-aarch64-static \
  -v $(pwd)/:/tmp/build \
  --entrypoint=/scripts/builder.sh \
  arm64v8/ubuntu:xenial

DEB Packaging

FPM can be used to easily generate deb packages for our platform in a few simple steps

Install fpm

Inside the running container install fpm and its requirements before compiling your code

apt-get -y install ruby ruby-dev rubygems build-essential
gem install --no-ri --no-rdoc fpm
Compile

Compile and Install your code to a custom directory, later used to create the package

mkdir /tmp/mycode
make && make DESTDIR=/tmp/mycode install
Create a Package

Launch fpm using the installation directory and adding your variables for name, version, etc:

fpm -s dir -t deb -C /tmp/mycode \
	--name ${VERSION_NAME} --version ${VERSION_PROJECT}  -p "${VERSION_NAME}_${VERSION_PROJECT}-${INV}.${OS}.${ARCH}.deb" \
	--iteration 1 --deb-no-default-config-files --depends ${DEPENDENCY} --description "rtpagent" .
Copy Package

Last but not least, copy the generated package the the mounted directory on the host:

cp -v *.deb /tmp/build

KERNEL SOURCES

The EXA8 Ubuntu distribution ships w/ kernel 4.14.11-svn258 and no Headers. In order to compile modules:

wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14.11/linux-headers-4.14.11-041411_4.14.11-041411.201801022143_all.deb
wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v4.14.11/linux-headers-4.14.11-041411-generic_4.14.11-041411.201801022143_arm64.deb
dpkg -i ./linux-headers-*
ln -s /lib/modules/4.14.11-041411-generic /lib/modules/4.14.11-svn258
cd /lib/modules/4.14.11-041411-generic/build
sed -i '/CONFIGS_SECURITY_SELINUX/d' ./scripts/Makefile
make headers_check
make headers_install
make scripts

Package Editing

In case of need, packages and their dependecies can be edited as follows:

Unpack deb

Command will create i.e. three files: debian-binary control.tar.gz data.tar.gz

ar x golden-linux.deb
Unpack control archive:

command will create: postinst postrm preinst prerm md5sums control

tar xzf control.tar.gz 
Fix dependencies in control

(use a text editor)

Repack control.tar.gz:
tar c {post,pre}{inst,rm} md5sums control | gzip -c > control.tar.gz
Repack deb (order important!)
ar rcs newpackage.deb debian-binary control.tar.gz data.tar.gz