Skip to content

Commit 7cba7d1

Browse files
Merge pull request #68 from tropicsquare/develop
Develop
2 parents 8db168d + d8026d6 commit 7cba7d1

File tree

12 files changed

+187
-17
lines changed

12 files changed

+187
-17
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ option(LT_ENABLE_FW_UPDATE "Enable firmware update functions and compile firmwar
1515
# This switch controls if helper utilities are compiled in. In most cases this should be ON,
1616
# examples and tests need to have helpers utilities compiled.
1717
# Switch it off to compile only basic libtropic API.
18-
option(LT_UTILS "Compile helper function" ON)
18+
option(LT_HELPERS "Compile helper function" ON)
1919

2020
# Check if cryptography provider is defined
2121
if(
@@ -160,7 +160,7 @@ if(LT_USE_TREZOR_CRYPTO)
160160
target_compile_definitions(tropic PRIVATE LT_USE_TREZOR_CRYPTO)
161161
endif()
162162

163-
if(LT_UTILS)
164-
target_compile_definitions(tropic PUBLIC LT_UTILS)
163+
if(LT_HELPERS)
164+
target_compile_definitions(tropic PUBLIC LT_HELPERS)
165165
endif()
166166

CONTRIBUTING.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# Contributing
22

3-
We love contributions! To make contributing simple for both sides please:
3+
We love contributions! To make contributing simple for both sides, please:
44

55
- Open an issue
66
- Describe how you would like to contribute and discuss details with us
77
- Make sure your code is properly formatted
8-
- Make sure your comit messages follow conventional commit guidelines [link](https://www.conventionalcommits.org/en/v1.0.0/#specification)
8+
- Make sure your commit messages follow [Conventional Commits guidelines](https://www.conventionalcommits.org/en/v1.0.0/#specification)
99
- Create pull request
1010

1111
### Commit messages:

docs/contributors.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ Library architecture explained: core, examples, helpers, layers, hal, …
1616

1717
“Libtropic is standalone library expected to be used within a parent project”
1818

19-
TBD add picture
19+
<a href="libtropic_arch.drawio.png" target="_blank">
20+
<img src="libtropic_arch.drawio.png" alt="Secure Tropic Click" width="50%"/>
21+
</a>
2022

2123
## How to: Adding new embedded platform {#adding-new-embedded-platform}
2224

docs/img/libtropic_arch.drawio.png

174 KB
Loading

docs/index.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ We recommend to add libtropic as a submodule. Libtropic uses CMAKE build system,
7777
set(PATH_LIBTROPIC "libtropic/")
7878
7979
# This switch will expose not only core library functions, but also helper functions
80-
set(LT_UTILS ON)
80+
set(LT_HELPERS ON)
8181
8282
# This switch exposes also functions containing example of usage.
8383
# Might be a good starting point.
@@ -116,7 +116,7 @@ Libtropic is configurable with cmake options. They are either passed from parent
116116
# This switch controls if helper utilities are compiled in. In most cases this should be ON,
117117
# examples and tests need to have helpers utilities compiled.
118118
# Switch it off to compile only libtropic's core
119-
-DLT_UTILS=1
119+
-DLT_HELPERS=1
120120
121121
# Build libtropic documentation
122122
-DLT_BUILD_DOCS=1
@@ -137,7 +137,7 @@ In order to have examples exposed in your parent project, libtropic must be comp
137137
# This switch controls if helper utilities are compiled in. In most cases this should be ON,
138138
# examples and tests need to have helpers utilities compiled.
139139
# Switch it off to compile only libtropic's core
140-
-DLT_UTILS=1
140+
-DLT_HELPERS=1
141141
142142
# Compile libtropic also with functions containing example usage - good for initial evaluation
143143
-DLT_ADD_EXAMPLES=1

examples/libtropic_examples.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef HELLO_WORLD_EXAMPLE
2-
#define HELLO_WORLD_EXAMPLE
1+
#ifndef LT_LIBTROPIC_EXAMPLES_H
2+
#define LT_LIBTROPIC_EXAMPLES_H
33

44
/**
55
* @file TROPIC01_hw_wallet.h

examples/lt_ex_fw_update.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,31 @@ void print_headers(lt_handle_t *h)
4646
{
4747
LOG_OUT(" Chip contains following headers:\r\n");
4848
uint8_t header[LT_L2_GET_INFO_FW_HEADER_SIZE] = {0};
49-
LOG_OUT(" lt_get_info_fw_bank() FW_BANK_FW1 %s\r\n", lt_ret_verbose(lt_get_info_fw_bank(&h, FW_BANK_FW1, header, LT_L2_GET_INFO_FW_HEADER_SIZE)));
49+
LOG_OUT(" lt_get_info_fw_bank() FW_BANK_FW1 %s\r\n", lt_ret_verbose(lt_get_info_fw_bank(h, FW_BANK_FW1, header, LT_L2_GET_INFO_FW_HEADER_SIZE)));
5050
LOG_OUT(" Header: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\r\n", header[0], header[1], header[2], header[3],
5151
header[4], header[5], header[6], header[7],
5252
header[8], header[9]);
5353
LOG_OUT(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\r\n", header[10], header[11], header[12], header[13],
5454
header[14], header[15], header[16], header[17],
5555
header[18], header[19]);
5656

57-
LOG_OUT(" lt_get_info_fw_bank() FW_BANK_FW2 %s\r\n", lt_ret_verbose(lt_get_info_fw_bank(&h, FW_BANK_FW2, header, LT_L2_GET_INFO_FW_HEADER_SIZE)));
57+
LOG_OUT(" lt_get_info_fw_bank() FW_BANK_FW2 %s\r\n", lt_ret_verbose(lt_get_info_fw_bank(h, FW_BANK_FW2, header, LT_L2_GET_INFO_FW_HEADER_SIZE)));
5858
LOG_OUT(" Header: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\r\n", header[0], header[1], header[2], header[3],
5959
header[4], header[5], header[6], header[7],
6060
header[8], header[9]);
6161
LOG_OUT(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\r\n", header[10], header[11], header[12], header[13],
6262
header[14], header[15], header[16], header[17],
6363
header[18], header[19]);
6464

65-
LOG_OUT(" lt_get_info_fw_bank() FW_BANK_SPECT1 %s\r\n", lt_ret_verbose(lt_get_info_fw_bank(&h, FW_BANK_SPECT1, header, LT_L2_GET_INFO_FW_HEADER_SIZE)));
65+
LOG_OUT(" lt_get_info_fw_bank() FW_BANK_SPECT1 %s\r\n", lt_ret_verbose(lt_get_info_fw_bank(h, FW_BANK_SPECT1, header, LT_L2_GET_INFO_FW_HEADER_SIZE)));
6666
LOG_OUT(" Header: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\r\n", header[0], header[1], header[2], header[3],
6767
header[4], header[5], header[6], header[7],
6868
header[8], header[9]);
6969
LOG_OUT(" %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\r\n", header[10], header[11], header[12], header[13],
7070
header[14], header[15], header[16], header[17],
7171
header[18], header[19]);
7272

73-
LOG_OUT(" lt_get_info_fw_bank() FW_BANK_SPECT2 %s\r\n", lt_ret_verbose(lt_get_info_fw_bank(&h, FW_BANK_SPECT2, header, LT_L2_GET_INFO_FW_HEADER_SIZE)));
73+
LOG_OUT(" lt_get_info_fw_bank() FW_BANK_SPECT2 %s\r\n", lt_ret_verbose(lt_get_info_fw_bank(h, FW_BANK_SPECT2, header, LT_L2_GET_INFO_FW_HEADER_SIZE)));
7474
LOG_OUT(" Header: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\r\n", header[0], header[1], header[2], header[3],
7575
header[4], header[5], header[6], header[7],
7676
header[8], header[9]);

include/libtropic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@ struct lt_config_t {
681681
uint32_t obj[27];
682682
};
683683

684-
#ifdef LT_UTILS
684+
#ifdef LT_HELPERS
685685
/**
686686
* @brief Get the conf desc object from config description table
687687
*

src/libtropic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1653,7 +1653,7 @@ const char *lt_ret_verbose(lt_ret_t ret) {
16531653
}
16541654

16551655
//--------------------------------------------------------------------------------------------------------//
1656-
#ifdef LT_UTILS
1656+
#ifdef LT_HELPERS
16571657
/** @brief This helper structure together with two get* interfaces is meant to be used to simplify looping
16581658
* through all config addresses and printing them out into log */
16591659
struct lt_config_obj_desc_t config_description_table[27] = {

tests/model_based/CMakeLists.txt

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
cmake_minimum_required(VERSION 3.21.0)
2+
3+
4+
###########################################################################
5+
# #
6+
# Paths and setup #
7+
# #
8+
###########################################################################
9+
10+
#set(CMAKE_BUILD_TYPE Debug)
11+
12+
set(PATH_LIBTROPIC "../../")
13+
14+
15+
###########################################################################
16+
# #
17+
# Define project's name #
18+
# #
19+
###########################################################################
20+
21+
project(libtropic_unix_example
22+
VERSION 0.1.0
23+
DESCRIPTION "Example of libtropic's usage in Unix environment"
24+
LANGUAGES C)
25+
26+
27+
###########################################################################
28+
# #
29+
# Sources defined by this project #
30+
# #
31+
###########################################################################
32+
33+
add_executable(run main.c
34+
${CMAKE_CURRENT_SOURCE_DIR}/${PATH_LIBTROPIC}hal/port/unix/lt_port_unix_tcp.c
35+
)
36+
37+
38+
###########################################################################
39+
# #
40+
# Define what examples will be compiled into main(). #
41+
# If any of examples is enabled, libtropic is compiled with #
42+
# examples exposed. #
43+
# #
44+
###########################################################################
45+
46+
# -DLT_EX_HW_WALLET=1
47+
if(LT_EX_HW_WALLET)
48+
set(LT_ADD_EXAMPLES ON)
49+
target_compile_definitions(run PRIVATE LT_EX_HW_WALLET)
50+
endif()
51+
# -DLT_EX_HELLO_WORLD=1
52+
if(LT_EX_HELLO_WORLD)
53+
set(LT_ADD_EXAMPLES ON)
54+
target_compile_definitions(run PRIVATE LT_EX_HELLO_WORLD)
55+
endif()
56+
# -DLT_EX_TEST_REVERSIBLE=1
57+
if(LT_EX_TEST_REVERSIBLE)
58+
set(LT_ADD_EXAMPLES ON)
59+
target_compile_definitions(run PRIVATE LT_EX_TEST_REVERSIBLE)
60+
endif()
61+
# --DLT_EX_TEST_IREVERSIBLE=1
62+
if(LT_EX_TEST_IREVERSIBLE)
63+
set(LT_ADD_EXAMPLES ON)
64+
target_compile_definitions(run PRIVATE LT_EX_TEST_IREVERSIBLE)
65+
endif()
66+
67+
###########################################################################
68+
# #
69+
# Add libtropic and set it up #
70+
# #
71+
###########################################################################
72+
73+
# Use trezor crypto as a source of backend cryptography code
74+
set(LT_USE_TREZOR_CRYPTO ON)
75+
76+
# Add path to libtropic's repository root folder
77+
add_subdirectory(${PATH_LIBTROPIC} "libtropic")
78+
79+
# Customize libtropic's compilation
80+
target_compile_options(tropic PRIVATE -Wall)
81+
target_compile_options(tropic PRIVATE -ffunction-sections -fdata-sections)
82+
target_compile_options(tropic PRIVATE -Wno-implicit-function-declaration)
83+
84+
85+
###########################################################################
86+
# #
87+
# Link executable #
88+
# #
89+
###########################################################################
90+
91+
target_link_options(run PRIVATE -Wl,--gc-sections)
92+
target_link_libraries(run PRIVATE tropic)

0 commit comments

Comments
 (0)