Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 4 additions & 20 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,14 @@ jobs:
run: |
tar czpf artifacts/flipper-z-any-scripts-${{steps.names.outputs.suffix}}.tgz scripts

- name: 'Rebuild Assets'
uses: ./.github/actions/docker
with:
run: |
set -e
make assets_rebuild assets_manifest
git diff --quiet || ( echo "Assets recompilation required."; exit 255 )

- name: 'Build the firmware in docker'
uses: ./.github/actions/docker
with:
run: |
set -e
for TARGET in ${TARGETS}
do
make updater_package TARGET=${TARGET} ${{ startsWith(github.ref, 'refs/tags') && 'DEBUG=0 COMPACT=1' || '' }}
./fbt TARGET_HW=`echo ${TARGET} | sed 's/f//'` --with-updater updater_package ${{ startsWith(github.ref, 'refs/tags') && 'DEBUG=0 COMPACT=1' || '' }}
done

- name: 'Move upload files'
Expand All @@ -97,7 +89,7 @@ jobs:
set -e
for TARGET in ${TARGETS}
do
mv dist/${TARGET}/* artifacts/
mv dist/${TARGET}-*/* artifacts/
done

- name: 'Bundle self-update package'
Expand All @@ -124,7 +116,7 @@ jobs:
uses: ./.github/actions/docker
with:
run: |
make -C assets copro_bundle
./fbt copro_dist
tar czpf artifacts/flipper-z-any-core2_firmware-${{steps.names.outputs.suffix}}.tgz -C assets core2_firmware

- name: 'Upload artifacts to update server'
Expand Down Expand Up @@ -208,20 +200,12 @@ jobs:
echo "WORKFLOW_BRANCH_OR_TAG=${BRANCH_OR_TAG}" >> $GITHUB_ENV
echo "DIST_SUFFIX=${SUFFIX}" >> $GITHUB_ENV

- name: 'Rebuild Assets'
uses: ./.github/actions/docker
with:
run: |
set -e
make assets_rebuild assets_manifest
git diff --quiet || ( echo "Assets recompilation required."; exit 255 )

- name: 'Build the firmware in docker'
uses: ./.github/actions/docker
with:
run: |
set -e
for TARGET in ${TARGETS}
do
make TARGET=${TARGET} DEBUG=0 COMPACT=1
./fbt TARGET_HW=`echo ${TARGET} | sed 's/f//'` --with-updater updater_package DEBUG=0 COMPACT=1
done
2 changes: 1 addition & 1 deletion .github/workflows/lint_c.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
id: syntax_check
uses: ./.github/actions/docker
with:
run: SET_GH_OUTPUT=1 make lint
run: SET_GH_OUTPUT=1 ./fbt lint

- name: Report code formatting errors
if: failure() && steps.syntax_check.outputs.errors && github.event.pull_request
Expand Down
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,11 @@ dist

# kde
.directory

# SCons
.sconsign.dblite
# SCons build dir
build/

# Toolchain
toolchain*/
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,6 @@
[submodule "lib/microtar"]
path = lib/microtar
url = https://github.com/amachronic/microtar.git
[submodule "lib/scons"]
path = lib/scons
url = https://github.com/SCons/scons.git
2 changes: 0 additions & 2 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
cask "gcc-arm-embedded"
brew "protobuf"
brew "gdb"
brew "heatshrink"
brew "open-ocd"
brew "clang-format"
brew "dfu-util"
brew "imagemagick"
2 changes: 1 addition & 1 deletion CODING_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Almost everything in flipper firmware is built around this concept.
# C coding style

- Tab is 4 spaces
- Use `make format` to reformat source code and check style guide before commit
- Use `fbt format` to reformat source code and check style guide before commit

## Naming

Expand Down
178 changes: 21 additions & 157 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,157 +1,21 @@
PROJECT_ROOT := $(abspath $(dir $(abspath $(firstword $(MAKEFILE_LIST)))))

include $(PROJECT_ROOT)/make/git.mk
include $(PROJECT_ROOT)/assets/copro.mk
include $(PROJECT_ROOT)/assets/splash.mk

PROJECT_SOURCE_DIRECTORIES := \
$(PROJECT_ROOT)/applications \
$(PROJECT_ROOT)/core \
$(PROJECT_ROOT)/firmware/targets \
$(PROJECT_ROOT)/lib/app-template \
$(PROJECT_ROOT)/lib/app-scened-template \
$(PROJECT_ROOT)/lib/common-api \
$(PROJECT_ROOT)/lib/drivers \
$(PROJECT_ROOT)/lib/flipper_file \
$(PROJECT_ROOT)/lib/infrared \
$(PROJECT_ROOT)/lib/nfc_protocols \
$(PROJECT_ROOT)/lib/ST25RFAL002 \
$(PROJECT_ROOT)/lib/onewire \
$(PROJECT_ROOT)/lib/qrcode \
$(PROJECT_ROOT)/lib/subghz \
$(PROJECT_ROOT)/lib/toolbox \
$(PROJECT_ROOT)/lib/u8g2

NPROCS := 3
OS := $(shell uname -s)

ifeq ($(OS), Linux)
NPROCS := $(shell grep -c ^processor /proc/cpuinfo)
else ifeq ($(OS), Darwin)
NPROCS := $(shell sysctl -n hw.ncpu)
endif

include $(PROJECT_ROOT)/make/defaults.mk

.PHONY: all
all: firmware_all
@$(PROJECT_ROOT)/scripts/dist.py copy -t $(TARGET) -p firmware -s $(DIST_SUFFIX)

.PHONY: whole
whole: flash_radio firmware_flash

.PHONY: clean
clean: firmware_clean updater_clean
@rm -rf $(PROJECT_ROOT)/dist/$(TARGET)

.PHONY: flash
flash: firmware_flash

.PHONY: debug
debug:
@$(MAKE) -C firmware -j$(NPROCS) debug

.PHONY: debug_other
debug_other:
@$(MAKE) -C firmware -j$(NPROCS) debug_other

.PHONY: blackmagic
blackmagic:
@$(MAKE) -C firmware -j$(NPROCS) blackmagic

.PHONY: wipe
wipe:
@$(PROJECT_ROOT)/scripts/flash.py wipe
@$(PROJECT_ROOT)/scripts/ob.py set

.PHONY: firmware_all
firmware_all:
@$(MAKE) -C $(PROJECT_ROOT)/firmware -j$(NPROCS) all

.PHONY: firmware_clean
firmware_clean:
@$(MAKE) -C $(PROJECT_ROOT)/firmware -j$(NPROCS) clean

.PHONY: firmware_flash
firmware_flash:
ifeq ($(FORCE), 1)
@rm $(PROJECT_ROOT)/firmware/.obj/f*-firmware/flash || true
endif
@$(MAKE) -C $(PROJECT_ROOT)/firmware -j$(NPROCS) flash

.PHONY: updater
updater:
@$(MAKE) -C $(PROJECT_ROOT)/firmware -j$(NPROCS) RAM_EXEC=1 all

.PHONY: updater_clean
updater_clean:
@$(MAKE) -C $(PROJECT_ROOT)/firmware -j$(NPROCS) RAM_EXEC=1 clean

.PHONY: updater_debug
updater_debug:
@$(MAKE) -C $(PROJECT_ROOT)/firmware -j$(NPROCS) RAM_EXEC=1 debug

.PHONY: updater_package_bin
updater_package_bin: firmware_all updater
@$(PROJECT_ROOT)/scripts/dist.py copy -t $(TARGET) -p firmware updater -s $(DIST_SUFFIX) --bundlever "$(VERSION_STRING)"

.PHONY: updater_package
updater_package: firmware_all updater assets_manifest
@$(PROJECT_ROOT)/scripts/dist.py copy \
-t $(TARGET) -p firmware updater \
-s $(DIST_SUFFIX) -r $(PROJECT_ROOT)/assets/resources \
--bundlever "$(VERSION_STRING)" \
--radio $(COPRO_STACK_BIN_PATH) \
--radiotype $(COPRO_STACK_TYPE) \
$(COPRO_DISCLAIMER) \
--obdata $(PROJECT_ROOT)/scripts/$(COPRO_OB_DATA) \
--splash $(UPDATER_SPLASH_DIR)

.PHONY: assets_manifest
assets_manifest:
@$(MAKE) -C $(PROJECT_ROOT)/assets manifest

.PHONY: assets_rebuild
assets_rebuild:
@$(MAKE) -C $(PROJECT_ROOT)/assets clean all

.PHONY: flash_radio
flash_radio:
@$(PROJECT_ROOT)/scripts/flash.py core2radio $(COPRO_STACK_BIN_PATH) --addr=$(COPRO_STACK_ADDR)
@$(PROJECT_ROOT)/scripts/ob.py set

.PHONY: flash_radio_fus
flash_radio_fus:
@echo
@echo "================ DON'T DO IT ================"
@echo "= Flashing FUS is going to erase secure enclave ="
@echo "= You will lose ability to use encrypted assets ="
@echo "= type 'find / -exec rm -rf {} \;' ="
@echo "= In case if you still want to continue ="
@echo "================ JUST DON'T ================"
@echo

.PHONY: flash_radio_fus_please_i_m_not_going_to_complain
flash_radio_fus_please_i_m_not_going_to_complain:
@$(PROJECT_ROOT)/scripts/flash.py core2fus 0x080EC000 --statement=AGREE_TO_LOSE_FLIPPER_FEATURES_THAT_USE_CRYPTO_ENCLAVE $(COPRO_FIRMWARE_DIR)/stm32wb5x_FUS_fw_for_fus_0_5_3.bin
@$(PROJECT_ROOT)/scripts/flash.py core2fus 0x080EC000 --statement=AGREE_TO_LOSE_FLIPPER_FEATURES_THAT_USE_CRYPTO_ENCLAVE $(COPRO_FIRMWARE_DIR)/stm32wb5x_FUS_fw.bin
@$(PROJECT_ROOT)/scripts/ob.py set

.PHONY: lint
lint:
@echo "Checking source code formatting"
@$(PROJECT_ROOT)/scripts/lint.py check $(PROJECT_SOURCE_DIRECTORIES)

.PHONY: format
format:
@echo "Reformating sources code"
@$(PROJECT_ROOT)/scripts/lint.py format $(PROJECT_SOURCE_DIRECTORIES)

.PHONY: guruguru
guruguru:
@echo "ぐるぐる回る"
@$(PROJECT_ROOT)/scripts/guruguru.py $(PROJECT_ROOT)

.PHONY: generate_compile_db
generate_compile_db:
@$(MAKE) -C $(PROJECT_ROOT)/firmware -j$(NPROCS) generate_compile_db
$(info +-------------------------------------------------+)
$(info | |)
$(info | Hello, this is Flipper team speaking! |)
$(info | |)
$(info | We've migrated to new build system |)
$(info | It's nice and based on scons |)
$(info | |)
$(info | Crash course: |)
$(info | |)
$(info | `./fbt` |)
$(info | `./fbt flash` |)
$(info | `./fbt debug` |)
$(info | |)
$(info | More details in documentation/fbt.md |)
$(info | |)
$(info | Also Please leave your feedback here: |)
$(info | https://flipp.dev/4RDu |)
$(info | or |)
$(info | https://flipp.dev/2XM8 |)
$(info | |)
$(info +-------------------------------------------------+)
28 changes: 12 additions & 16 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ Flipper Zero's firmware consists of two components:

They both must be flashed in order described.

## With offline update package

`./fbt --with-updater updater_package`

Copy the resulting directory to Flipper's SD card and navigate to `update.fuf` file in Archive app.

## With STLink

### Core1 Firmware
Expand All @@ -36,17 +42,7 @@ Prerequisites:
- [arm-gcc-none-eabi](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
- openocd

One liner: `make flash`

### Core2 flashing procedures

Prerequisites:

- Linux / macOS
- Terminal
- STM32_Programmer_CLI (v2.5.0) added to $PATH

One liner: `make flash_radio`
One liner: `./fbt firmware_flash`

## With USB DFU

Expand All @@ -56,7 +52,6 @@ One liner: `make flash_radio`
- Press and hold `← Left` + `↩ Back` for reset
- Release `↩ Back` and keep holding `← Left` until blue LED lights up
- Release `← Left`
<!-- ![Switch to DFU sequence](https://habrastorage.org/webt/uu/c3/g2/uuc3g2n36f2sju19rskcvjzjf6w.png) -->

3. Run `dfu-util -D full.dfu -a 0`

Expand All @@ -74,7 +69,7 @@ One liner: `make flash_radio`
## Compile everything

```sh
docker-compose exec dev make
docker-compose exec dev ./fbt
```

Check `dist/` for build outputs.
Expand All @@ -85,6 +80,8 @@ If compilation fails, make sure all submodules are all initialized. Either clone

# Build on Linux/macOS

Check out `documentation/fbt.md` for details on building and flashing firmware.

## macOS Prerequisites

Make sure you have [brew](https://brew.sh) and install all the dependencies:
Expand Down Expand Up @@ -127,7 +124,7 @@ heatshrink has to be compiled [from sources](https://github.com/atomicobject/hea
## Compile everything

```sh
make
./fbt
```

Check `dist/` for build outputs.
Expand All @@ -138,7 +135,7 @@ Use **`flipper-z-{target}-full-{suffix}.dfu`** to flash your device.

Connect your device via ST-Link and run:
```sh
make whole
./fbt firmware_flash
```

# Links
Expand All @@ -158,7 +155,6 @@ make whole
- `documentation` - Documentation generation system configs and input files
- `firmware` - Firmware source code
- `lib` - Our and 3rd party libraries, drivers and etc...
- `make` - Make helpers
- `scripts` - Supplementary scripts and python libraries home

Also pay attention to `ReadMe.md` files inside of those directories.
Loading