Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/indexds/charizhard
Browse files Browse the repository at this point in the history
  • Loading branch information
elvador83 committed Jan 12, 2025
2 parents d009167 + aac034f commit a05e974
Show file tree
Hide file tree
Showing 28 changed files with 111 additions and 406 deletions.
10 changes: 4 additions & 6 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ CRATE_CC_NO_DEFAULTS = "1"
[alias]
flash="make flash"
f = "make flash"
monitor-windows="make monitor-windows"
mw = "make monitor-windows"
monitor-linux="make monitor-linux"
ml="make monitor-linux"
c = "make config"
config = "make config"
e = "make erase-flash"
erase = "make erase-flash"
e = "make erase"
erase = "make erase"
m = "make monitor"
monitor = "make monitor"
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["indexds https://github.com/indexds"]
edition = "2021"
resolver = "2"
rust-version = "1.81"
rust-version = "1.82"
readme = "README.md"
description = "A cutting-edge hardware solution designed to secure data exchanges and protect devices from hardware-based threats."
repository = "https://github.com/indexds/charizhard"
Expand Down
12 changes: 4 additions & 8 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,9 @@ args = [
"0x20000", "${CARGO_MAKE_WORKSPACE_WORKING_DIRECTORY}/target/xtensa-esp32-espidf/release/charizhard.bin"
]

[tasks.monitor-windows]
command = "putty"
args = ["-serial", "${COM}", "-sercfg", "115200,8,n,1,N"]

[tasks.monitor-linux]
command = "screen"
args = ["/dev/${ttyUSB}", "115200"]
[tasks.monitor]
command = "espflash"
args = ["monitor"]

[tasks.flash]
dependencies = [
Expand All @@ -30,7 +26,7 @@ dependencies = [
"write",
]

[tasks.erase-flash]
[tasks.erase]
command = "espflash"
args = ["erase-flash"]

Expand Down
84 changes: 18 additions & 66 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,19 @@ vulnerabilities.
With CharizHard, users can trust that their data and devices are secure, providing peace of mind in an increasingly connected
world.

## Requirements

This project uses the [esp-idf](https://github.com/espressif/esp-idf/tree/v5.2.3) version `v5.2.3` for the standard `esp32`.

Drivers for the `esp32` can be found on the [esp-idf website](https://dl.espressif.com/dl/esp-idf/?idf=5.2.3).

## Requirements

This project requires Rust, Python and the standard C toolchain. The standard C toolchain as well as git are assumed to already be installed by the user. If not, the user is likely on Windows and following the msys2 tutorial here should make everything work out of the box: [Install msys2](https://www.msys2.org/).

Installing git can then be done using the following command in a `ucrt64` shell.
```fish
pacman -Syu && pacman -S git
```

The `C:\msys64\ucrt64\bin` folder must be added to the PATH environment variable.

### Windows
Expand All @@ -60,22 +61,22 @@ https://www.python.org/downloads/release/python-3125/
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
```

**Installing Python:** Using your favorite package manager, install `python3.12` `python3-pip` or `python312` and `python-pip`
**Installing Python:** Using your favorite package manager, install `python3.12` `python3-pip` or `python312` and `python-pip` depending on distribution.

Ensure the version is 3.12.5 as more recent versions have proved unstable.

## Installing

This project needs to be cloned in your root directory, as the `esp32` cannot handle long paths.
On windows, this project needs to be cloned in your root directory, as the `esp32` build process cannot handle long paths.

```fish
cd /
```

Install espup to get the esp toolchain required to compile on the `xtensa-esp32-espidf` architecture. Until [*this issue*](https://github.com/esp-rs/espup/issues/440) is fixed, ensure you install the `0.11.0` version of the binary.
Install espup to get the esp toolchain required to compile on the `xtensa-esp32-espidf` architecture.

```fish
cargo install espup@0.11.0
cargo install espup
```

Install the toolchain and follow any additional instruction written to the standard output.
Expand All @@ -86,18 +87,18 @@ Do not forget to run the `export.bat` on Windows or `./export.sh` on Linux situa
espup install
```

Clone the repository then `cd` inside. Note that the name of the folder must be short and located at the root of your filesystem. Here, we use chhard.
Clone the repository then `cd` inside. Note that the name of the folder must be short and located at the root of your filesystem if you are on a Windows distribution. Here, we use chhard.

```fish
git clone https://github.com/indexds/charizhard chhard && cd chhard
```

Install the `cargo-make` binary to make the build process less of a chore. If not possible, the project *can* be compiled by running the commands found in `Makefile.toml` manually.

You're also going to need espflash and ldproxy as dependencies.
You're also going to need `espflash` and `ldproxy` as dependencies.

```fish
cargo install cargo-make cargo-generate cargo-espflash ldproxy
cargo install cargo-make cargo-espflash ldproxy
```

Then you're gonna need:
Expand All @@ -109,62 +110,21 @@ pip install esptool
All that remains is to install all remaining dependencies, build the project and flash the `esp32` with:

```fish
cargo flash
```
or
```
cargo f
cargo [flash|f]
```

## Monitoring

### Windows

On Windows, you can install Putty here: [Download Putty](https://www.putty.org/).

Then set the environment variable defining the port your `esp32` is available on.
You only need to do this once per terminal.
Alternatively you can use `setx` to make the variable permanent.
```fish
set COM=COM{X}
```
With `{X}` being the port your `esp32` is available on. This can be found in the device manager.

Then run,
```fish
cargo monitor-windows
```
or
```fish
cargo mw
```

### Linux

On Linux, install the `screen` package using your favorite package manager, then run:
To get logs to stdout, use:

```ssh
screen /dev/ttyUSB? 115200
```

Or set an environment variable for your `ttyUSB` like so:
```fish
export ttyUSB=ttyUSB{X}
```
With `{X}` being the port your `esp32` is available on.

You can then run either of the following commands:

```fish
cargo monitor-linux
```
or
```fish
cargo ml
cargo [monitor|m]
```

## Menuconfig

The menuconfig tool is used to modify the `sdkconfig` file which dictates what is and isn't compiled into the final binary.

To access the menuconfig tool, install the following dependencies:

```fish
Expand All @@ -184,7 +144,7 @@ cargo pio installpio
You can now access the menuconfig tool using:

```fish
cargo pio espidf menuconfig
cargo [pio espidf menuconfig | c]
```

The tool will first download the `xtensa-esp-elf` toolchain which may take a while.
Expand All @@ -203,23 +163,15 @@ The tool will first download the `xtensa-esp-elf` toolchain which may take a whi

#

* If the program fails upon flashing the `esp32`, press and hold the `BOOT/EN` button on the SOC to put it in bootloader mode. Firmware should start flashing.

#

* If the program fails because of the path length to your project, verify that you cloned the project at the root of your filesystem and that the name of the directory is as short as specified.
* If the program fails to connect to the `esp32` upon flashing, the `esp32` must be rebooted (by grounding then releasing the `EN` pin) while the `BOOT` pin is grounded. This puts the `esp32` in bootloader mode. Firmware should then start flashing.

#

* If the program fails for any reason related to Python, check that the version used by the program is a `3.12.x` as Python `>=3.13` is not currently supported.

#

* If the program fails for any other reason, try running your shell with administrator/sudo privileges

#

* Should the program have multiple dependency failures, try running `cargo clean` then rebuilding the project properly with `cargo flash`.
* Should the program have multiple dependency failures, try running `cargo clean` then rebuilding the project properly with `cargo [flash|f]`.

#

Expand Down
Binary file removed logo/charizhard.PNG
Binary file not shown.
1 change: 0 additions & 1 deletion logo/charizhard.svg

This file was deleted.

Binary file removed logo/charizhard_transparent_background.ico
Binary file not shown.
Binary file removed logo/charizhard_transparent_background.png
Binary file not shown.
1 change: 0 additions & 1 deletion logo/charizhard_transparent_background.svg

This file was deleted.

70 changes: 43 additions & 27 deletions sdkconfig
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ CONFIG_ESP_NETIF_TCPIP_LWIP=y
CONFIG_ESP_NETIF_USES_TCPIP_WITH_BSD_API=y
CONFIG_ESP_NETIF_RECEIVE_REPORT_ERRORS=y
# CONFIG_ESP_NETIF_L2_TAP is not set
CONFIG_ESP_NETIF_BRIDGE_EN=y
# CONFIG_ESP_NETIF_BRIDGE_EN is not set
# end of ESP NETIF Adapter

#
Expand Down Expand Up @@ -1010,9 +1010,9 @@ CONFIG_ESP_WIFI_RX_BA_WIN=6
CONFIG_ESP_WIFI_TASK_PINNED_TO_CORE_1=y
CONFIG_ESP_WIFI_SOFTAP_BEACON_MAX_LEN=752
CONFIG_ESP_WIFI_MGMT_SBUF_NUM=16
# CONFIG_ESP_WIFI_IRAM_OPT is not set
# CONFIG_ESP_WIFI_EXTRA_IRAM_OPT is not set
# CONFIG_ESP_WIFI_RX_IRAM_OPT is not set
CONFIG_ESP_WIFI_IRAM_OPT=y
CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y
CONFIG_ESP_WIFI_RX_IRAM_OPT=y
# CONFIG_ESP_WIFI_ENABLE_WPA3_SAE is not set
# CONFIG_ESP_WIFI_ENABLE_WPA3_OWE_STA is not set
# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set
Expand Down Expand Up @@ -1057,7 +1057,7 @@ CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y
#
# FAT Filesystem support
#
CONFIG_FATFS_VOLUME_COUNT=2
CONFIG_FATFS_VOLUME_COUNT=1
CONFIG_FATFS_LFN_NONE=y
# CONFIG_FATFS_LFN_HEAP is not set
# CONFIG_FATFS_LFN_STACK is not set
Expand Down Expand Up @@ -1088,12 +1088,12 @@ CONFIG_FATFS_CODEPAGE_437=y
CONFIG_FATFS_CODEPAGE=437
CONFIG_FATFS_FS_LOCK=0
CONFIG_FATFS_TIMEOUT_MS=10000
CONFIG_FATFS_PER_FILE_CACHE=y
# CONFIG_FATFS_PER_FILE_CACHE is not set
# CONFIG_FATFS_USE_FASTSEEK is not set
CONFIG_FATFS_VFS_FSTAT_BLKSIZE=0
# CONFIG_FATFS_IMMEDIATE_FSYNC is not set
# CONFIG_FATFS_USE_LABEL is not set
CONFIG_FATFS_LINK_LOCK=y
# CONFIG_FATFS_LINK_LOCK is not set
# end of FAT Filesystem support

#
Expand Down Expand Up @@ -1231,8 +1231,7 @@ CONFIG_LWIP_IP4_FRAG=y
CONFIG_LWIP_IP4_REASSEMBLY=y
CONFIG_LWIP_IP_REASS_MAX_PBUFS=10
CONFIG_LWIP_IP_FORWARD=y
CONFIG_LWIP_IPV4_NAPT=y
CONFIG_LWIP_IPV4_NAPT_PORTMAP=y
# CONFIG_LWIP_IPV4_NAPT is not set
# CONFIG_LWIP_STATS is not set
# CONFIG_LWIP_ESP_GRATUITOUS_ARP is not set
CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32
Expand Down Expand Up @@ -1340,7 +1339,7 @@ CONFIG_LWIP_DNS_MAX_SERVERS=4
# CONFIG_LWIP_FALLBACK_DNS_SERVER_SUPPORT is not set
# end of DNS

CONFIG_LWIP_BRIDGEIF_MAX_PORTS=7
CONFIG_LWIP_BRIDGEIF_MAX_PORTS=5
CONFIG_LWIP_ESP_LWIP_ASSERT=y

#
Expand All @@ -1354,7 +1353,26 @@ CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y
# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set
# end of Hooks

# CONFIG_LWIP_DEBUG is not set
CONFIG_LWIP_DEBUG=y
CONFIG_LWIP_DEBUG_ESP_LOG=y
# CONFIG_LWIP_NETIF_DEBUG is not set
# CONFIG_LWIP_PBUF_DEBUG is not set
# CONFIG_LWIP_ETHARP_DEBUG is not set
# CONFIG_LWIP_API_LIB_DEBUG is not set
# CONFIG_LWIP_SOCKETS_DEBUG is not set
CONFIG_LWIP_IP_DEBUG=y
# CONFIG_LWIP_ICMP_DEBUG is not set
# CONFIG_LWIP_DHCP_STATE_DEBUG is not set
# CONFIG_LWIP_DHCP_DEBUG is not set
# CONFIG_LWIP_IP6_DEBUG is not set
# CONFIG_LWIP_ICMP6_DEBUG is not set
# CONFIG_LWIP_TCP_DEBUG is not set
# CONFIG_LWIP_UDP_DEBUG is not set
# CONFIG_LWIP_SNTP_DEBUG is not set
# CONFIG_LWIP_DNS_DEBUG is not set
# CONFIG_LWIP_BRIDGEIF_DEBUG is not set
# CONFIG_LWIP_BRIDGEIF_FDB_DEBUG is not set
# CONFIG_LWIP_BRIDGEIF_FW_DEBUG is not set
# end of LWIP

#
Expand All @@ -1373,7 +1391,6 @@ CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=512
#
# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set
# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set
# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set
# CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE is not set
# end of mbedTLS v3.x related

Expand Down Expand Up @@ -1439,13 +1456,12 @@ CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y
# CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED is not set
# CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED is not set
# CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED is not set
CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y
CONFIG_MBEDTLS_ECP_NIST_OPTIM=y
# CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED is not set
# CONFIG_MBEDTLS_ECP_NIST_OPTIM is not set
# CONFIG_MBEDTLS_ECP_FIXED_POINT_OPTIM is not set
CONFIG_MBEDTLS_POLY1305_C=y
CONFIG_MBEDTLS_CHACHA20_C=y
CONFIG_MBEDTLS_CHACHAPOLY_C=y
CONFIG_MBEDTLS_HKDF_C=y
# CONFIG_MBEDTLS_POLY1305_C is not set
# CONFIG_MBEDTLS_CHACHA20_C is not set
# CONFIG_MBEDTLS_HKDF_C is not set
# CONFIG_MBEDTLS_THREADING_C is not set
# CONFIG_MBEDTLS_ERROR_STRINGS is not set
# end of mbedTLS
Expand Down Expand Up @@ -1526,8 +1542,8 @@ CONFIG_ESP_PROTOCOMM_SUPPORT_SECURITY_VERSION_0=y
# PThreads
#
CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072
CONFIG_PTHREAD_STACK_MIN=768
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=4096
CONFIG_PTHREAD_STACK_MIN=1024
CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y
# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set
# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set
Expand Down Expand Up @@ -1622,7 +1638,7 @@ CONFIG_SPIFFS_OBJ_NAME_LEN=32
# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set
# CONFIG_SPIFFS_USE_MAGIC is not set
CONFIG_SPIFFS_META_LENGTH=4
CONFIG_SPIFFS_USE_MTIME=y
# CONFIG_SPIFFS_USE_MTIME is not set

#
# Debug Configuration
Expand Down Expand Up @@ -1686,8 +1702,8 @@ CONFIG_WL_SECTOR_SIZE=4096
#
# Wi-Fi Provisioning Manager
#
CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=12
CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30
CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=10
CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=20
# CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION is not set
CONFIG_WIFI_PROV_STA_ALL_CHANNEL_SCAN=y
# CONFIG_WIFI_PROV_STA_FAST_SCAN is not set
Expand Down Expand Up @@ -1822,8 +1838,8 @@ CONFIG_ESP32_WIFI_RX_BA_WIN=6
CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1=y
CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752
CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=16
# CONFIG_ESP32_WIFI_IRAM_OPT is not set
# CONFIG_ESP32_WIFI_RX_IRAM_OPT is not set
CONFIG_ESP32_WIFI_IRAM_OPT=y
CONFIG_ESP32_WIFI_RX_IRAM_OPT=y
# CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE is not set
# CONFIG_ESP32_WIFI_ENABLE_WPA3_OWE_STA is not set
CONFIG_WPA_MBEDTLS_CRYPTO=y
Expand Down Expand Up @@ -1872,8 +1888,8 @@ CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y
# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set
# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set
CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5
CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072
CONFIG_ESP32_PTHREAD_STACK_MIN=768
CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=4096
CONFIG_ESP32_PTHREAD_STACK_MIN=1024
CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y
# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 is not set
# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 is not set
Expand Down
Loading

0 comments on commit a05e974

Please sign in to comment.