Compile On Kali Linux
Compiling Mayhem Firmware on Kali Linux
Tested at 21. Sept. 2024 on Kali 2024.3 kali-rolling
Should work for any Debian based Distribution, see comments.
Download and install dependencies
sudo apt update
sudo apt install git tar bzip2 lz4 wget curl cmake python3 python3-setuptools python3-distutils-extra python3-yaml dfu-util hackrf
In many distributions the tool hackrf
is provided, but outdated because of the release policy. Kali is rolling release, so does not follow this restrictions.
If you have a R9 or newer HackRF and need a newer version, I recommended to download and compile it by yourself. Source: https://github.com/greatscottgadgets/hackrf
Download and install the ARM toolchain
If you use another Version as 9.2.1, the mayham cmake warns you:
WARNING: Compiler version mismatch, please use the official compiler version 9.2.1 when sharing builds! Current compiler version: 13.2.1
It might compile. From other projects, as Proxmark3 or Chameleon Ultra, we know the gcc-arm-none-eabi in version 13 (provided by various distributions) creates a bigger firmware image, which won’t fit into the memory. Even if it compiles without error, the firmware file is useless.
sudo mkdir /opt/build
sudo chmod $USER:$(id -gn $USER) /opt/build
cd /opt/build
wget https://developer.arm.com/-/media/Files/downloads/gnu-rm/9-2019q4/gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2
mkdir armbin
tar --strip=1 -xjvf gcc-arm-none-eabi-9-2019-q4-major-x86_64-linux.tar.bz2 -C armbin
I recommend to adjust the user rights at the first possible moment. Work as root as less as possible.
If more than one person works in the system, feel free to set the group to something more generic. For example src
or staff
.
Source for the newest toolcain: https://developer.arm.com/downloads/-/arm-gnu-toolchain-downloads
Source for deprecated toolchain: https://developer.arm.com/downloads/-/gnu-rm
Set toolchain as default
echo 'PATH=/opt/build/armbin/bin:/opt/build/armbin/lib:$PATH' >> ~/.zshrc
source ~/.zshrc
Kali Linux uses ZSH as default shell. On Debian is Bash the default shell, so if you are using Debian or changed the default shell, you need to pipe the echo into ~/.bashrc (or the related rc file)
Get the Firmware from Github
cd ~
mkdir git
cd git
git clone https://github.com/portapack-mayhem/mayhem-firmware/ --recurse-submodules
Personal Note:
You could work at any place, for example
/opt
. The FHS says/usr/src
wold be the right place for source codes. But this would be in/
and most systems I know got roundabout 20 to 50 GB for/
and several 100 GB for/home
, so I decide to work with git in /home.
Build the firmware
cd ~/git/mayhem-firmware
mkdir build
cd build
cmake ..
make clean && make
For the first compile make clean &&
is not necessary. But if the compilation stops of any reason, you need to use clean. If nothing is there, it won’t hurt.