Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/flipperdevices/flipperzero-ufbt
Compact tool for building and debugging applications for Flipper Zero.
https://github.com/flipperdevices/flipperzero-ufbt
fap faps fbt flipper flipper-app flipper-plugin flipper-plugins flipperzero ufbt
Last synced: 2 days ago
JSON representation
Compact tool for building and debugging applications for Flipper Zero.
- Host: GitHub
- URL: https://github.com/flipperdevices/flipperzero-ufbt
- Owner: flipperdevices
- License: gpl-3.0
- Created: 2022-10-30T17:30:19.000Z (about 2 years ago)
- Default Branch: dev
- Last Pushed: 2024-08-20T18:54:32.000Z (4 months ago)
- Last Synced: 2024-12-19T18:02:45.803Z (10 days ago)
- Topics: fap, faps, fbt, flipper, flipper-app, flipper-plugin, flipper-plugins, flipperzero, ufbt
- Language: Python
- Homepage: https://pypi.org/project/ufbt/
- Size: 149 KB
- Stars: 615
- Watchers: 27
- Forks: 42
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# uFBT - micro Flipper Build Tool
uFBT is a cross-platform tool for building applications for [Flipper Zero](https://flipperzero.one/). It is a simplified version of [Flipper Build Tool (FBT)](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/fbt.md).
**uFBT has an [official GitHub Action](https://github.com/marketplace/actions/build-flipper-application-package-fap). With it, you can automate building and publishing your application using GitHub workflows.**
uFBT enables basic development tasks for Flipper Zero, such as building and debugging applications, flashing firmware, creating VSCode development configurations. It uses prebuilt binaries and libraries, so you don't need to build [the whole firmware](https://github.com/flipperdevices/flipperzero-firmware) to compile and debug your application for Flipper.
## Installation
- **Linux & macOS**: `python3 -m pip install --upgrade ufbt`
- **Windows**: `py -m pip install --upgrade ufbt`uFBT uses your system's Python for running bootstrap code. Minimal supported version is **Python 3.8**. For executing actual build tasks, uFBT will download and use its own Python binaries and a toolchain built for your platform.
On first run, uFBT will download and install required SDK components from `release` update channel of official firmware. For more information on how to switch to a different version of the SDK, see [Managing the SDK](#managing-the-sdk) section.
### Using pyenv
If you are using `pyenv` to manage python versions, after installation you may need to run `pyenv rehash` to generate [shim](https://github.com/pyenv/pyenv#understanding-shims) for `ufbt` command.
## Usage
### Building & running your application
Run `ufbt` in the root directory of your application (the one with `application.fam` file in it). It will build your application and place the resulting binary in `dist` subdirectory.
You can upload and start your application on Flipper attached over USB using `ufbt launch`.
To see other available commands and options, run `ufbt -h`.
### Debugging
In order to debug your application, you need to be running the firmware distributed alongside with current SDK version. You can flash it to your Flipper using `ufbt flash` (using a supported SWD probe), `ufbt flash_usb` (over USB).
For other flashing and debugging options, see `ufbt -h`.
### VSCode integration
uFBT provides a configuration for VSCode that allows you to build and debug your application directly from the IDE. To deploy it, run `ufbt vscode_dist` in the root directory of your application. Then you can open the project in VSCode (`File`-`Open Folder...`) and use the provided launch (`ctrl+shift+b`) & debugging (`ctrl+shift+d`) configurations.
### Application template
uFBT can create a template for your application. To do this, run `ufbt create APPID=` in the directory where you want to create your application. It will create an application manifest and its main source file. You can then build and debug your application using the instructions above.
Application manifests are explained in the [FBT documentation](https://github.com/flipperdevices/flipperzero-firmware/blob/dev/documentation/AppManifests.md).
### Other
* `ufbt cli` starts a CLI session with the device;
* `ufbt lint`, `ufbt format` run clang-format on application's sources;
* You can temporarily add toolchain binaries (compiler, linter, OpenOCD and others) to your PATH. See `ufbt --help` for more information.## Managing the SDK
To update the SDK, run `ufbt update`. This will download and install all required SDK components from previously used source.
- To switch to SDK for a different **release channel**, run `ufbt update --channel=[dev|rc|release]`.
- uFBT also supports 3rd-party update indexers, following the same schema as [official firmware](https://github.com/flipperdevices/flipperzero-firmware). To use them, run `ufbt update --index-url=`, where `` is a URL to the index file, e.g. `https://update.flipperzero.one/firmware/directory.json`.
- To use SDK for a **certain release** or a not-yet-merged **branch** from official repo, run `ufbt update --branch=0.81.1` or `ufbt update --branch=owner/my-awesome-feature`.
- You can also use branches from other repos, where build artifacts are available from an indexed directory, by specifying `--index-url=`.
- uFBT can also download and update the SDK from any **fixed URL**. To do this, run `ufbt update --url=`.
- To use a **local copy** of the SDK, run `ufbt update --local=`. This will use the SDK located in `` instead of downloading it. Useful for testing local builds of the SDK.### Global and per-project SDK management
By default, uFBT stores its state - SDK and toolchain - in `.ufbt` subfolder of your home directory. You can override this location by setting `UFBT_HOME` environment variable.
uFBT also supports dotenv (`.env`) files, containing environment variable overrides for the project in current directory. Most commonly, you will want to use this to override the default state directory to a local one, so that your project could use a specific version and/or hardware target of the SDK.
You can enable dotenv mode for current directory by running `ufbt dotenv_create`. This will create `.env` file in current directory with default values, linking SDK state to `.ufbt` subfolder in current directory, and creating a symlink for toolchain to `.ufbt/toolchain` in your home directory. You can then edit `.env` file to further customize the environment.
You can also specify additional options when creating the `.env` file. See `ufbt dotenv_create --help` for more information.
### ufbt-bootstrap
Updating the SDK is handled by uFBT component called _bootstrap_. It has a dedicated entry point, `ufbt-bootstrap`, with additional options that might be useful in certain scenarios. Run `ufbt-bootstrap --help` to see them.
## Troubleshooting
If something goes wrong and uFBT state becomes corrupted, you can reset it by running `ufbt clean`. If that doesn't work, you can try removing `.ufbt` subfolder manually from your home folder.
`ufbt-bootstrap` and SDK-related `ufbt` subcommands accept `--verbose` option that will print additional debug information.
## Contributing
uFBT is a small tool and does not contain the actual implementation of build system, project templates or toolchain. It functions as a downloader and manager of SDK components that are packaged [alongside with Flipper firmware](https://github.com/flipperdevices/flipperzero-firmware/tree/dev/scripts/ufbt).
Issues and pull requests regarding `ufbt-bootstrap` features like SDK management should be reported to this project, and the rest - related to actual application development - to [Flipper firmware repo](https://github.com/flipperdevices/flipperzero-firmware/issues).