Browse Source
* PASS1-137: Add Justfile support to Gen 1 repo First pass - not all expected commands are added yet * Update Justfile with fmt command Add py and c/h formatting Need to finalize .clang-format file before doing a full reformatting PR * Refactor Justfiles to separate them out Also add graphics build commands * Update Justfiles a bit Fix formatting of graphics header files in preparation for automatic code formattingPASS1-132
committed by
GitHub
13 changed files with 316 additions and 23 deletions
@ -0,0 +1,129 @@ |
|||||
|
# SPDX-FileCopyrightText: 2021 Foundation Devices, Inc. <hello@foundationdevices.com> |
||||
|
# |
||||
|
# SPDX-License-Identifier: GPL-3.0-or-later |
||||
|
|
||||
|
# Install dependencies. |
||||
|
deps: |
||||
|
@echo "Not sure we will need this if all deps are setup via Dockerfile" |
||||
|
|
||||
|
# Initialize development environment |
||||
|
init: deps |
||||
|
git config core.hooksPath .githooks |
||||
|
|
||||
|
# Lint only the code of the project |
||||
|
lint-code: |
||||
|
@echo "TBD" |
||||
|
|
||||
|
# Lint all of the project |
||||
|
lint: lint-code |
||||
|
reuse lint |
||||
|
|
||||
|
# |
||||
|
# Firmware Commands |
||||
|
# |
||||
|
|
||||
|
build: |
||||
|
make BOARD=Passport |
||||
|
|
||||
|
# Sign current firmware build with the user.pem key and set specified version |
||||
|
sign version="1.0.0": build |
||||
|
@echo "\nAdding user signature...\n" |
||||
|
@cosign -f build-Passport/firmware.bin -k ~/bin/keys/user.pem -v {{version}} > /dev/null |
||||
|
|
||||
|
@cosign -f build-Passport/firmware-key-user.bin -x |
||||
|
@echo "\nSigning Complete!" |
||||
|
|
||||
|
# Build, sign and flash the firmware with the specified version |
||||
|
flash version="1.0.0": (sign version) |
||||
|
just run-ocd-command "flash write_image erase build-Passport/firmware-key-user.bin 0x8020000" |
||||
|
just reset |
||||
|
|
||||
|
# Install a recent Foundation-signed build |
||||
|
flash-foundation version="1.0.0": |
||||
|
just run-ocd-command "flash write_image erase ../../releases/passport-fw-{{version}}.bin 0x8020000" |
||||
|
just reset |
||||
|
|
||||
|
# Clean the firmware build |
||||
|
clean: |
||||
|
make BOARD=Passport clean |
||||
|
|
||||
|
# |
||||
|
# Misc. Commands |
||||
|
# |
||||
|
|
||||
|
# Launch OCD, run a command and then exit |
||||
|
run-ocd-command command: |
||||
|
sudo /usr/local/bin/openocd -f stlink.cfg -c "adapter speed 1000; transport select hla_swd" -f stm32h7x.cfg -c "init; reset halt; {{command}}" -c "exit" |
||||
|
|
||||
|
# Build all Python graphics |
||||
|
graphics-py: |
||||
|
just -f boards/Passport/graphics/py/Justfile build |
||||
|
|
||||
|
# Build all C graphics (firmware & bootloader) |
||||
|
graphics-c: |
||||
|
just -f boards/Passport/graphics/c/Justfile build |
||||
|
|
||||
|
graphics: graphics-py graphics-c |
||||
|
|
||||
|
# Reset the Passport |
||||
|
reset: |
||||
|
just run-ocd-command "reset" |
||||
|
|
||||
|
# Get the username for use below |
||||
|
user := `whoami` |
||||
|
|
||||
|
# Read the "ROM Secrets" from Passport and save them to a file |
||||
|
save-secrets filename="boards/Passport/bootloader/secrets": |
||||
|
just run-ocd-command "dump_image {{filename}} 0x0801FF00 256" |
||||
|
# Running OCD as sudo makes the output file be owned by root, so switch it back to the user |
||||
|
sudo chown {{user}}:{{user}} {{filename}} |
||||
|
|
||||
|
secrets: |
||||
|
#!/usr/bin/env bash |
||||
|
# The last bit below redirects stderr to stdout, which the backticks capture into the variable `secrets` |
||||
|
secrets=`just run-ocd-command "mdb 0x0801FF00 256" 2>&1` |
||||
|
secrets=`echo "$secrets" | tail -n 8` |
||||
|
echo -e "Passport ROM Secrets:\n$secrets" |
||||
|
|
||||
|
# Calculate all hashes and format it all for GitHub release notes |
||||
|
hash filepath: |
||||
|
#!/usr/bin/env bash |
||||
|
filename=`basename {{filepath}}` |
||||
|
|
||||
|
# SHA256 |
||||
|
sha=`shasum -b -a 256 {{filepath}} | sed -rn 's/^(.*) .*$/\1/p'` |
||||
|
echo -e "\n\`SHA256: $sha\`" |
||||
|
echo -e "\`(shasum -b -a 256 $filename)\`\n" |
||||
|
|
||||
|
# MD5 |
||||
|
md5=`mdsum {{filepath}} | sed -rn 's/^(.*) .*$/\1/p'` |
||||
|
echo "\`MD5: $md5\`" |
||||
|
echo -e "\`(md5 $filename or mdsum $filename)\`\n" |
||||
|
|
||||
|
# Build Hash |
||||
|
build_hash=`cosign -f {{filepath}} -x | sed -rn 's/^FW Build Hash: (.*)$/\1/p'` |
||||
|
echo -e "\`Build Hash: $build_hash\`" |
||||
|
echo -e "\`(Developers Only)\`\n" |
||||
|
|
||||
|
# Run all tests |
||||
|
test: |
||||
|
@echo "TBD" |
||||
|
|
||||
|
# Format the project's .py files under boards/Passport/modules |
||||
|
fmt-py: |
||||
|
#!/usr/bin/env bash |
||||
|
pushd boards/Passport/modules |
||||
|
files_to_fmt=`find . -path ./trezor-firmware -prune -false -o -name '*.py'` |
||||
|
autopep8 --max-line-length=120 --in-place $files_to_fmt |
||||
|
popd |
||||
|
|
||||
|
# Format the project's .c and .h files under boards/Passport/ |
||||
|
fmt-c: |
||||
|
#!/usr/bin/env bash |
||||
|
pushd boards/Passport |
||||
|
files_to_fmt=`find . -path ./trezor-firmware -prune -false -o -name '*.[c|h]'` |
||||
|
clang-format-5.0 -i --style=file $files_to_fmt |
||||
|
popd |
||||
|
|
||||
|
# Format the project's source code under boards/Passport |
||||
|
fmt: fmt-py fmt-c |
@ -1,7 +1,107 @@ |
|||||
--- |
--- |
||||
# We'll use defaults from the LLVM style, but with 4 columns indentation. |
Language: Cpp |
||||
BasedOnStyle: Mozilla |
# BasedOnStyle: Chromium |
||||
IndentWidth: 4 |
AccessModifierOffset: -1 |
||||
--- |
AlignAfterOpenBracket: Align |
||||
Language: Cpp |
AlignConsecutiveAssignments: true |
||||
ColumnLimit: 120 |
AlignConsecutiveDeclarations: true |
||||
|
AlignEscapedNewlines: Left |
||||
|
AlignOperands: true |
||||
|
AlignTrailingComments: true |
||||
|
AllowAllParametersOfDeclarationOnNextLine: true |
||||
|
AllowShortBlocksOnASingleLine: false |
||||
|
AllowShortCaseLabelsOnASingleLine: false |
||||
|
AllowShortFunctionsOnASingleLine: Inline |
||||
|
AllowShortIfStatementsOnASingleLine: true |
||||
|
AllowShortLoopsOnASingleLine: false |
||||
|
AlwaysBreakAfterDefinitionReturnType: None |
||||
|
AlwaysBreakAfterReturnType: None |
||||
|
AlwaysBreakBeforeMultilineStrings: true |
||||
|
AlwaysBreakTemplateDeclarations: true |
||||
|
BinPackArguments: true |
||||
|
BinPackParameters: false |
||||
|
BraceWrapping: |
||||
|
AfterClass: false |
||||
|
AfterControlStatement: false |
||||
|
AfterEnum: false |
||||
|
AfterFunction: false |
||||
|
AfterNamespace: false |
||||
|
AfterObjCDeclaration: false |
||||
|
AfterStruct: false |
||||
|
AfterUnion: false |
||||
|
BeforeCatch: false |
||||
|
BeforeElse: false |
||||
|
IndentBraces: false |
||||
|
SplitEmptyFunction: true |
||||
|
SplitEmptyRecord: true |
||||
|
SplitEmptyNamespace: true |
||||
|
BreakBeforeBinaryOperators: None |
||||
|
BreakBeforeBraces: Attach |
||||
|
BreakBeforeInheritanceComma: false |
||||
|
BreakBeforeTernaryOperators: true |
||||
|
BreakConstructorInitializersBeforeComma: false |
||||
|
BreakConstructorInitializers: BeforeColon |
||||
|
BreakAfterJavaFieldAnnotations: false |
||||
|
BreakStringLiterals: false |
||||
|
ColumnLimit: 120 |
||||
|
CommentPragmas: '^ IWYU pragma:' |
||||
|
CompactNamespaces: false |
||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: true |
||||
|
ConstructorInitializerIndentWidth: 4 |
||||
|
ContinuationIndentWidth: 4 |
||||
|
Cpp11BracedListStyle: true |
||||
|
DerivePointerAlignment: false |
||||
|
DisableFormat: false |
||||
|
ExperimentalAutoDetectBinPacking: false |
||||
|
FixNamespaceComments: true |
||||
|
ForEachMacros: |
||||
|
- foreach |
||||
|
- Q_FOREACH |
||||
|
- BOOST_FOREACH |
||||
|
IncludeCategories: |
||||
|
- Regex: '^<.*\.h>' |
||||
|
Priority: 1 |
||||
|
- Regex: '^<.*' |
||||
|
Priority: 2 |
||||
|
- Regex: '.*' |
||||
|
Priority: 3 |
||||
|
IncludeIsMainRegex: '([-_](test|unittest))?$' |
||||
|
IndentCaseLabels: true |
||||
|
IndentWidth: 4 |
||||
|
IndentWrappedFunctionNames: false |
||||
|
JavaScriptQuotes: Leave |
||||
|
JavaScriptWrapImports: true |
||||
|
KeepEmptyLinesAtTheStartOfBlocks: false |
||||
|
MacroBlockBegin: '' |
||||
|
MacroBlockEnd: '' |
||||
|
MaxEmptyLinesToKeep: 1 |
||||
|
NamespaceIndentation: None |
||||
|
ObjCBlockIndentWidth: 2 |
||||
|
ObjCSpaceAfterProperty: false |
||||
|
ObjCSpaceBeforeProtocolList: false |
||||
|
PenaltyBreakAssignment: 2 |
||||
|
PenaltyBreakBeforeFirstCallParameter: 1 |
||||
|
PenaltyBreakComment: 300 |
||||
|
PenaltyBreakFirstLessLess: 120 |
||||
|
PenaltyBreakString: 1000 |
||||
|
PenaltyExcessCharacter: 1000000 |
||||
|
PenaltyReturnTypeOnItsOwnLine: 200 |
||||
|
PointerAlignment: Left |
||||
|
ReflowComments: false |
||||
|
SortIncludes: true |
||||
|
SortUsingDeclarations: true |
||||
|
SpaceAfterCStyleCast: false |
||||
|
SpaceAfterTemplateKeyword: true |
||||
|
SpaceBeforeAssignmentOperators: true |
||||
|
SpaceBeforeParens: ControlStatements |
||||
|
SpaceInEmptyParentheses: false |
||||
|
SpacesBeforeTrailingComments: 2 |
||||
|
SpacesInAngles: false |
||||
|
SpacesInContainerLiterals: true |
||||
|
SpacesInCStyleCastParentheses: false |
||||
|
SpacesInParentheses: false |
||||
|
SpacesInSquareBrackets: false |
||||
|
Standard: Auto |
||||
|
TabWidth: 8 |
||||
|
UseTab: Never |
||||
|
... |
||||
|
@ -0,0 +1,39 @@ |
|||||
|
# SPDX-FileCopyrightText: 2021 Foundation Devices, Inc. <hello@foundationdevices.com> |
||||
|
# |
||||
|
# SPDX-License-Identifier: GPL-3.0-or-later |
||||
|
|
||||
|
# Launch OCD, run a command and then exit |
||||
|
run-ocd-command command: |
||||
|
cd ../../../; sudo /usr/local/bin/openocd -f stlink.cfg -c "adapter speed 1000; transport select hla_swd" -f stm32h7x.cfg -c "init; reset halt; {{command}}" -c "exit" |
||||
|
|
||||
|
|
||||
|
# Build the bootloader (debug, release, locked or production) |
||||
|
# TODO: Need to handle {{rel}} for locked and production, which should look in release folder for binary |
||||
|
build rel="release": |
||||
|
@echo "\nBuilding Bootloader..." |
||||
|
make {{rel}} |
||||
|
|
||||
|
@echo "\nAppending secrets to the end..." |
||||
|
add-secrets -b arm/{{rel}}/bootloader.bin -s secrets |
||||
|
|
||||
|
@echo "\nBootloader Build Complete" |
||||
|
|
||||
|
# Clean the bootloader build |
||||
|
clean: |
||||
|
@echo "Cleaning Bootloader..." |
||||
|
make clean |
||||
|
@echo "Bootloader Clean Complete" |
||||
|
|
||||
|
# Build and flash the bootloader with the secrets appended to the end |
||||
|
flash rel="release": (build rel) |
||||
|
just run-ocd-command "flash write_image erase boards/Passport/bootloader/arm/{{rel}}/bootloader-secrets.bin 0x8000000" |
||||
|
just reset |
||||
|
|
||||
|
# Build and flash the bootloader with no secrets (use to setup a new Secure Element) |
||||
|
flash-raw rel="release": (build rel) |
||||
|
just run-ocd-command "flash write_image erase boards/Passport/bootloader/arm/{{rel}}/bootloader.bin 0x8000000" |
||||
|
just reset |
||||
|
|
||||
|
# Reset the Passport |
||||
|
reset: |
||||
|
just run-ocd-command "reset" |
Binary file not shown.
@ -0,0 +1,9 @@ |
|||||
|
# SPDX-FileCopyrightText: 2021 Foundation Devices, Inc. <hello@foundationdevices.com> |
||||
|
# |
||||
|
# SPDX-License-Identifier: GPL-3.0-or-later |
||||
|
|
||||
|
# Build all C graphics and copy files to main source folders |
||||
|
build: |
||||
|
make |
||||
|
cp firmware_graphics.* ../../ |
||||
|
cp bootloader_graphics.* ../../bootloader/ |
@ -0,0 +1,8 @@ |
|||||
|
# SPDX-FileCopyrightText: 2021 Foundation Devices, Inc. <hello@foundationdevices.com> |
||||
|
# |
||||
|
# SPDX-License-Identifier: GPL-3.0-or-later |
||||
|
|
||||
|
# Build all Python graphics and copy files to main source folder |
||||
|
build: |
||||
|
make |
||||
|
cp graphics.py ../../modules/ |
Loading…
Reference in new issue