Compile and Upload Custom Flipper Code

Want to play with your flipper device and upload your own code changes? Try this out.

Prep Notes:

  • EVERYTHING NEEDS TO BE DONE IN ROOT - If you can get this working without it, please let me know how in a reply.
  • Using Ubuntu Server all from the CLI (Jammy Jellyfish 22.04)
  • Need install the correct compiler otherwise there will be issues
  • If you brick your device (I did 4 times figuring this out) you can unbrick it by putting it in DFU mode and flashing it with qflipper https://docs.flipperzero.one/basics/firmware-update/firmware-recovery
  • Working in the /opt directory
  • You can get this to spit out a DFU using the “make” command. These DFUs did not work and I had to recover my device. Maybe you will have better luck.

Installation:

1. Set variables
toolchain=“gcc-arm-none-eabi-10.3-2021.10” toolchain_package=“$toolchain-$(uname -m)-linux”

2. pull down the correct compiler to the opt directory
wget -P /opt “https://developer.arm.com/-/media/Files/downloads/gnu-rm/10.3-2021.10/$toolchain_package.tar.bz2”

3. # unpack the package and remove the compressed file
tar xjf /opt/$toolchain_package.tar.bz2 -C /opt
rm /opt/$toolchain_package.tar.bz2

4. This should link everything, but that did not work and I hated the hard links. I use Option 2. Option 1 does not always work for me.
Option 1: “for file in /opt/$toolchain/bin/* ; do ln -s “${file}” ”/usr/bin/$(basename ${file})“ ; done”
Option 2: “export PATH=/opt/gcc-arm-none-eabi-10.3-2021.10/bin:$PATH”
Option 2 note: THIS ONLY WORKS FOR ONE SESSION

5. additional software needed
– openocd - debugging/flashing over SWD - This does not cover SWD flashing but here all the same
– heatshrink - compiling image assets
– clang-format - code formatting
– dfu-util - flashing over USB DFU
– protobuf - compiling proto sources

This is how I install and what components I use:
apt update
apt install openocd clang-format-13 dfu-util protobuf-compiler

6. Download the firmware from github to the /opt directory
git clone https://github.com/flipperdevices/flipperzero-firmware.git

7. Git Fetch protobuf to prevent compile error
cd /opt/flipperzero-firmware/assets/protobuf
git fetch

8. Put Flipper zero in DFU Mode. Unplug USB and hold down the Okay and Back buttons simultaneously for 30 seconds. The screen will be entirely blank. https://docs.flipperzero.one/basics/firmware-update/firmware-recovery

9. Connect flipper zero to the linux machine via USB and compile and upload using the command below. I should note, sometimes I have to use the command twice after it fails once. No idea why. I do this work in a VM so I have to share the USB device with the host machine.
make -C firmware upload

2 Likes

Hallo
Ich bin in der Schweiz und habe einen neuen Flipper Zero bekommen…Doch ich habe null Ahnung und Erfahrung mit solchen Dingen.
Gibt es auch eine Anleitung fĂĽr dumme wo sich mit dieser Materie nicht auskennen?
Ich habe absolut keine Ahnung?

You will probably get more help if you write that in english.

Warum kaufst du dir dann einen Flipper Zero? Und wofĂĽr musst du den source code compelieren?