Skip to content

Rebuilding system emulator environment

Michael Messner edited this page Nov 11, 2022 · 12 revisions

TODO - see all the repos here https://github.com/EMBA-support-repos/

This documentation is work in progress! Currently it is not recommend to trust the information :)

The following documentation describes the process of building the binaries and kernels used by the system-emulation environment from EMBA.

Cross-compiler

In order to build any of the binaries used by EMBA, you will need different cross-compilation toolchains. To simplify the process of building these toolchains, we recommend using musl-cross-make project.

There are multiple TARGET configurations possible. The following definitions are some of the used definitions for building the toolchains used by EMBA:

TARGET = i486-linux-musl
TARGET = x86_64-linux-musl
TARGET = arm-linux-musleabi
TARGET = arm-linux-musleabihf
TARGET = mips64-linux-musln32
TARGET = mips64-linux-musl
TARGET = mips64el-linux-musl
TARGET = powerpc-linux-musl
TARGET = powerpc64-linux-musl
TARGET = mips-linux-musl
TARGET = mipsel-linux-musl

I recommend using the mips or mipsel TARGET definition as a starting point.

Another quite important setting is the version of the gcc that should be build. In our case we set this to version 6.5.0:

GCC_VER = 6.5.0

Finally, we set the OUTPUT definition to a useful directory where we would store the toolchains:

OUTPUT = /opt/cross

Now it should be possible to start building the toolchain with make. After finishing it a sudo make install installs the toolchain to the TARGET directory.

Busybox

https://busybox.net/downloads/busybox-1.29.3.tar.bz2

Libnvram

Console

Linux Kernel

Currently we are using nearly the original FirmAE kernel. The EMBA fork of it can be found here.

git clone https://github.com/EMBA-support-repos/FirmAE_kernel-v4.1.git
cd FirmAE_kernel-v4.1/

MIPS architecture

Since MIPS systems can be either big-endian or little-endian, this kernel should be compiled for both endianness. The below instructions produce a little-endian (mipsel) kernel, but should be repeated for a big-endian (mipseb) kernel.

Little-Endian (MIPSEL)

Create the kernel build output directory:

mkdir -p build/mipsel

Copy the configuration file into the build directory:

cp config.mipsel build/mipsel/.config

Assuming that the appropriate cross-compiler is installed in /opt/cross/mipsel-linux-musl, execute:

make ARCH=mips CROSS_COMPILE=/opt/cross/mipsel-linux-musl/bin/mipsel-linux-musl- O=./build/mipsel -j8

The output kernel image will be generated at the following location:

build/mipsel/vmlinux

Big-Endian (MIPSEB)

Create the kernel build output directory:

mkdir -p build/mipseb

Copy the configuration file into the build directory:

cp config.mipseb build/mipseb/.config

Assuming that the appropriate cross-compiler is installed in /opt/cross/mipseb-linux-musl, execute:

make ARCH=mips CROSS_COMPILE=/opt/cross/mipseb-linux-musl/bin/mipseb-linux-musl- O=./build/mipseb -j8

The output kernel image will be generated at the following location:

build/mipseb/vmlinux

MIPS64

ARMel (Little Endian)

sf and hf

x86

Addons

Addons - strace

Addons - gdb

Credits

This documentation is based on the original documentation of the FirmAE and the firmadyne project!