Translate

Sunday, February 18, 2024

Flipper Zero - setting up a development environment

Flipper Zero is defined as "hacking" tool, i.e. is a collection of HW and SW that allows to explore and interact with technology around us.

How can we work on it ?

Goal

This article goal is to set up a working development environment for Flipper Zero, where to build and install the stock firmware in the device.

Development environment

Flipper Zero is open source.
One of the capabilities of Flipper Zero is to be used to develop applications interacting with the outer world via peripherals, like the GPIO.
In order to do that, is necessary to set up a development environment.
Of course it can be done in many different way, the device itself has a kind of an embedded mini IDE but is not practical.

So my goal is to have an IDE running on a Linux box or a Mac, capable to work in C or Python, connected with the Flipper Zero.
The examples in this article are based on a Linux box with Ubuntu 22.04 LTS

Grocery list

So what we need to have to setup our development environment ?

Hardware

  • a computer Linux or Mac based  (Linux in this example)
  • a Flipper Zero

Software

  • on the Linux machine connected to the Flipper Zero, need to be installed  :
    • Git (vs 2.25.1)
    • Terminal
    • qFlipper (mainly for maintenance/official firmware upgrade)
    • Visual Studio Code (IDE - vs 1.86.2)
    • latest Python (>= 3.x - on my machine 3.8.10)

Code

  • Firmware/apps for Flipper (github)
    There are different repo we can use, here some :
We are going to use in this article only the stock firmware.

Setting up

Start to clone the repos you are interested in.
Better to clone rather than download the zip code, is much easier to keep the sandbox updated since  the repo content can change quite often.
After creating a directory somewhere for the firmware :
  • git clone --recursive https://github.com/flipperdevices/flipperzero-firmware.git
For the firmware be sure to use the --recursive option since there are lot of submodules to be initialized.

Firmware code init

Let start with the stock firmware.
From a terminal go in the repo root. In my case : cd ~/Projects/FlipperZero/flipperzero-firmware
In it there is a script called fbt (Flipper Build Tool - fbt).  
This script is used to build the code and initialize it, so the first time (i.e. after the installation from the repo), just execute it : ./fbt

The script is checking for missing tools/libraries and initialize the environment to be used by Visual Studio Code.
Once the first fbt run ends, execute it again to build but the Visual Studio Code menu :
  ./fbt vscode_dist
This will build the VSC menu accessible via the Ctrl - Shift - B command

Visual Studio Code (VSC)

At this point open the VSC and load the folder with the original firmware and complete the suggested extension installation (if any).
After this task, it may require to restart VSC few times, the environment is ready.

As first task we'll try to build the firmware and install in the Flipper Zero.

Building the firmware


Before to proceed be sure to have the Flipper Zero connected to the USB port.
Verify everything is OK running qFlipper but don't leave qFlipper running while building and flashing the device.
Leave the Flipper Zero connected to the USB cable but close qFlipper.

Step 1

Select the release branch.
After the initialization the default selected branch is dev (development).
It can be done in the terminal or in VSC.

From terminal

  • git status
    to show what branch is selected
  • git branch
    to show what branches are.  The first time only dev will appears since on;y the local copy is shown.
  • git checkout <name_branch>
    to switch branch.  The first time be sure to select origin:<name branch>
The repo has two branches :
  • dev
  • release_0_98
So select : git checkout release_0_98

From VSC

Select Source control on the left bar 
The dev environment is selected (see on the left of the flipperzero_firmware)









Click on "dev" and select "release_0_98" (or the first time the origin:release_0_98)








Done

Step 2

Click "Ctrl-Shift-B" to show the task list.


Be sure to have the Flipper Zero connected to an USB port, then select "Flash USB with resources"

The building will start and if no errors will load it on the Flipper Zero.
During the flash an Updating view will appear indicating the operation and in the end, if everything OK :
  • another view on Flipper will indicate : Firmware update Success
  • running qFlipper again will show the firmware release as : 0.98.3
    The build date remains wrong
Done, the firmware was built and installed

Resources


No comments:

Post a Comment