Skip to content

Commit

Permalink
EpicChain Ledger Nano - EpicChain Lab's
Browse files Browse the repository at this point in the history
  • Loading branch information
xmoohad committed Dec 30, 2024
0 parents commit d82924d
Show file tree
Hide file tree
Showing 117 changed files with 9,796 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
BasedOnStyle: Google
IndentWidth: 4
---
Language: Cpp
ColumnLimit: 120
PointerAlignment: Right
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AllowAllParametersOfDeclarationOnNextLine: false
SortIncludes: false
SpaceAfterCStyleCast: true
AllowShortCaseLabelsOnASingleLine: false
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortFunctionsOnASingleLine: None
BinPackArguments: false
BinPackParameters: false
---
2,576 changes: 2,576 additions & 0 deletions .doxygen/Doxyfile

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
name: Compilation & tests

on: [push, pull_request]

jobs:
job_build_debug:
name: Build debug
runs-on: ubuntu-latest

container:
image: ghcr.io/ledgerhq/ledger-app-builder:latest

steps:
- name: Clone
uses: actions/checkout@v2

- name: Build
run: |
make DEBUG=1
- name: Upload app binary
uses: actions/upload-artifact@v2
with:
name: boilerplate-app-debug
path: bin

job_unit_test:
name: Unit test
needs: job_build_debug
runs-on: ubuntu-latest

container:
image: ghcr.io/ledgerhq/ledger-app-builder:latest

steps:
- name: Clone
uses: actions/checkout@v2

- name: Build unit tests
run: |
cd unit-tests/
cmake -Bbuild -H. && make -C build && make -C build test
- name: Generate code coverage
run: |
cd unit-tests/
lcov --directory . -b "$(realpath build/)" --capture --initial -o coverage.base && \
lcov --rc lcov_branch_coverage=1 --directory . -b "$(realpath build/)" --capture -o coverage.capture && \
lcov --directory . -b "$(realpath build/)" --add-tracefile coverage.base --add-tracefile coverage.capture -o coverage.info && \
lcov --directory . -b "$(realpath build/)" --remove coverage.info '*/unit-tests/*' -o coverage.info && \
genhtml coverage.info -o coverage
- uses: actions/upload-artifact@v2
with:
name: code-coverage
path: unit-tests/coverage

- name: Upload to codecov.io
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./unit-tests/coverage.info
flags: unittests
name: codecov-app-boilerplate
fail_ci_if_error: true
verbose: true

- name: HTML documentation
run: doxygen .doxygen/Doxyfile

- uses: actions/upload-artifact@v2
with:
name: documentation
path: doc/html



job_test:
name: Test
needs: job_build_debug
runs-on: ubuntu-latest

container:
image: ghcr.io/ledgerhq/speculos:latest
ports:
- 1234:1234
- 9999:9999
- 40000:40000
- 41000:41000
- 42000:42000
- 43000:43000
options: --entrypoint /bin/bash

steps:
- name: Clone
uses: actions/checkout@v2

- name: Download app binary
uses: actions/download-artifact@v2
with:
name: boilerplate-app-debug
path: bin

- name: Run test
run: |
apt update && apt install -qy gcc # /!\ workaround for pysha3
nohup bash -c "python /speculos/speculos.py bin/app.elf --sdk 2.0 --apdu-port 9999 --button-port 42000 --automation-port 43000 --display headless" > speculos.log 2<&1 &
cd tests && pip install -r requirements.txt && pytest --headless
- name: Upload Speculos log
uses: actions/upload-artifact@v2
with:
name: speculos-log
path: speculos.log

19 changes: 19 additions & 0 deletions .github/workflows/lint-workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Code style check

on: [push, pull_request]

jobs:
job_lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Clone
uses: actions/checkout@v2

- name: Lint
uses: DoozyX/clang-format-lint-action@v0.11
with:
source: './src'
extensions: 'h,c'
clangFormatVersion: 11
31 changes: 31 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Compilation of Ledger's app
src/glyphs.c
src/glyphs.h
bin/
debug/
dep/
obj/

# Unit tests and code coverage
unit-tests/build/
unit-tests/coverage/
unit-tests/coverage.info

# Fuzzing
fuzzing/build/


# Editors
.idea/

# Python
*.pyc[cod]
*.egg
__pycache__/
*.egg-info/
.eggs/
.python-version

# Doxygen
doc/html
doc/latex
50 changes: 50 additions & 0 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"env": {
"BOLOS_SDK": "/opt/ledger/nanos-secure-sdk",
"BOLOS_ENV": "/opt/ledger"
},
"configurations": [
{
"name": "Nano S",
"includePath": [
"/usr/include",
"${workspaceFolder}/src",
"${env:BOLOS_SDK}/include/*",
"${env:BOLOS_SDK}/lib_ux/include/*",
"${env:BOLOS_SDK}/lib_cxng/include/*"
],
"defines": [
"TARGET_NANOS",
"OS_IO_SEPROXYHAL",
"HAVE_BAGL",
"HAVE_SPRINTF",
"HAVE_IO_USB",
"HAVE_L4_USBLIB",
"IO_USB_MAX_ENDPOINTS=6",
"IO_HID_EP_LENGTH=64",
"HAVE_USB_APDU",
"USB_SEGMENT_SIZE=64",
"UNUSED(x)=(void)x",
"APPVERSION=\"0.1.0\"",
"APPNAME=\"NEO3\"",
"MAJOR_VERSION=0",
"MINOR_VERSION=1",
"PATCH_VERSION=0",
"IO_SEPROXYHAL_BUFFER_SIZE_B=128",
"HAVE_UX_FLOW",
"DEBUG=1",
"HAVE_PRINTF",
"PRINTF=screen_printf"
],
"compilerPath": "${env:BOLOS_ENV}/gcc-arm-none-eabi-10-2020-q4-major/bin/arm-none-eabi-gcc",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-arm",
"browse": {
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
26 changes: 26 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "gdb",
"request": "attach",
"name": "Attach to gdbserver",
"executable": "${workspaceFolder}/bin/app.elf",
"target": ":1234",
"remote": true,
"cwd": "${workspaceFolder}",
"valuesFormatting": "parseText",
"gdbpath": "gdb-multiarch",
"autorun": [
"set architecture arm",
"handle SIGILL nostop pass noprint",
"add-symbol-file ${workspaceFolder}/bin/app.elf 0x40000000",
"b *0x40000000",
"c"
]
}
]
}
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"files.associations": {
"*.h": "c",
"array": "c",
"string_view": "c",
"initializer_list": "c",
"ranges": "c",
"utility": "c"
},
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
"editor.formatOnSave": true,
"git.ignoreLimitWarning": true
}
111 changes: 111 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "make",
"type": "shell",
"command": "make clean && make",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "[debug] make",
"type": "shell",
"command": "make clean && make DEBUG=1",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "make clean",
"type": "shell",
"command": "make clean",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "make load",
"type": "shell",
"command": "make load",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "run unit tests",
"type": "shell",
"command": "cd unit-tests && rm -rf build && cmake -Bbuild -H. && make -C build && CTEST_OUTPUT_ON_FAILURE=1 make -C build test",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": [
"$gcc"
]
},
{
"label": "run Speculos",
"type": "shell",
"command": "python /path/to/speculos/speculos.py ${workspaceFolder}/bin/app.elf --ontop --sdk 1.6 --apdu-port 9999 --button-port 42000 --automation-port 43000",
"group": {
"kind": "build",
"isDefault": true
},
"dependsOn": [
"make debug"
],
"problemMatcher": []
},
{
"label": "[debug] run Speculos",
"type": "shell",
"command": "python /path/to/speculos/speculos.py -d ${workspaceFolder}/bin/app.elf --ontop --sdk 1.6 --apdu-port 9999 --button-port 42000 --automation-port 43000",
"group": {
"kind": "build",
"isDefault": true
},
"dependsOn": [
"make debug"
],
"problemMatcher": []
},
{
"label": "run tests",
"type": "shell",
"command": "cd tests && pytest",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "kill Speculos",
"type": "shell",
"command": "pkill -f speculos.py",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
]
}
Loading

0 comments on commit d82924d

Please sign in to comment.