diff --git a/.gitignore b/.gitignore index ed572e0..570e28c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,15 @@ -**/.pio -**/.vscode +.vscode **/.DS_Store +.pio +build +sdkconfig +sdkconfig.old +sdkconfig.core2foraws +dependencies.lock + **/__pycache__ *.py[cod] + +**/*.key +**/*.pem \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 50d172c..3ce68b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,7 @@ set( COMPONENT_INCLUDEDIRS "${CRYPTOAUTHLIB_DIR}/" set( COMPONENT_PRIV_INCLUDEDIRS "port/include" ) -set( COMPONENT_REQUIRES "mbedtls" "freertos" "driver" "Core2-for-AWS-IoT-EduKit" ) +set( COMPONENT_REQUIRES "mbedtls" "freertos" "driver" "Core2-for-AWS-IoT-Kit" ) # Don't include the default interface configurations from cryptoauthlib set( COMPONENT_EXCLUDE_SRCS "${CRYPTOAUTHLIB_DIR}/atca_cfgs.c" ) diff --git a/README.md b/README.md index f03a78c..177b4b0 100644 --- a/README.md +++ b/README.md @@ -2,12 +2,12 @@ # ESP-CRYPTOAUTHLIB -This is a port of Microchip's [cryptoauthlib](https://github.com/MicrochipTech/cryptoauthlib) to work on the [M5Stack Core2 for AWS IoT EduKit](https://aws.amazon.com/iot/edukit/#Get_started_with_AWS_IoT_EduKit). It contains necessary build support to use cryptoauthlib with ESP-IDF as well as `esp_cryptoauthlib_utility` for configuring and provisiong ATECC608 chip integrated with the Core2 for AWS. The cryptoauthlib folder is a submodule of Microchip's [cryptoauthlib](https://github.com/MicrochipTech/cryptoauthlib). This ported library requires the [Core2 for AWS IoT EduKit board support package](https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/tree/BSP-dev) (BSP) to be included for thread-safe access to the I2C bus using Rop Gonggrijp's I2C Manager, and power to the chip using the ported Mika Tuupola's AXP192 driver. +This is a port of Microchip's [cryptoauthlib](https://github.com/MicrochipTech/cryptoauthlib) to work on the [M5Stack Core2 for AWS IoT Kit](https://shop.m5stack.com/products/m5stack-core2-esp32-iot-development-kit-for-aws-iot-edukit). It contains necessary build support to use cryptoauthlib with ESP-IDF as well as `esp_cryptoauthlib_utility` for configuring and provisiong ATECC608 chip integrated with the Core2 for AWS. The cryptoauthlib folder is a submodule of Microchip's [cryptoauthlib](https://github.com/MicrochipTech/cryptoauthlib). This ported library requires the [Core2 for AWS IoT Kit board support package](https://github.com/m5stack/Core2-for-AWS-IoT-Kit/tree/BSP-dev) (BSP) to be included for thread-safe access to the I2C bus using Rop Gonggrijp's I2C Manager, and power to the chip using the ported Mika Tuupola's AXP192 driver. ## Requirements -* Core2 for AWS IoT EduKit BSP(https://github.com/m5stack/Core2-for-AWS-IoT-EduKit/tree/BSP-dev) -* Configuration in [sdkconfig.defaults](https://github.com/aws-iot-edukit/Project_Template-Core2_for_AWS/blob/main/sdkconfig.defaults) +* Core2 for AWS IoT Kit BSP(https://github.com/m5stack/Core2-for-AWS-IoT-Kit/tree/BSP-dev) +* Configuration in [sdkconfig.defaults](https://github.com/m5stack/Project_Template-Core2_for_AWS/blob/main/sdkconfig.defaults) * Preferred [ESP-IDF](https://github.com/espressif/esp-idf) tag `release/v4.3` or newer OR use PlatformIO with [Espressif32 platform](https://github.com/platformio/platform-espressif32/) v3.3.1+. * Environment variable `IDF_PATH` should be set @@ -27,7 +27,7 @@ There are two ways to use **esp-cryptoauthlib** and the Core2 for AWS BSP in you * Download **esp-cryptoauthlib** and the **Core2 for AWS BSP** with: ``` git clone https://github.com/espressif/esp-cryptoauthlib.git --recurse-submodules - git clone https://github.com/m5stack/Core2-for-AWS-IoT-EduKit.git --recurse-submodules + git clone https://github.com/m5stack/Core2-for-AWS-IoT-Kit.git --recurse-submodules ``` 3) Enable the correct configurations for ESP-IDF using KConfig menu: ``` diff --git a/cryptoauthlib b/cryptoauthlib index e320651..ff22b80 160000 --- a/cryptoauthlib +++ b/cryptoauthlib @@ -1 +1 @@ -Subproject commit e3206516a6c606d3f75ecbe38cec01521f7f6506 +Subproject commit ff22b804aaff7f08382df579e9f24d786e2e8b6d diff --git a/port/atca_cfgs_port.c b/port/atca_cfgs_port.c index e591a0a..8a1d84d 100644 --- a/port/atca_cfgs_port.c +++ b/port/atca_cfgs_port.c @@ -29,6 +29,7 @@ #include "atca_cfgs.h" #include "atca_iface.h" #include "atca_device.h" +#include "sdkconfig.h" /** \defgroup config Configuration (cfg_) * \brief Logical device configurations describe the CryptoAuth device type and logical interface. @@ -41,13 +42,13 @@ ATCAIfaceCfg cfg_ateccx08a_i2c_default = { .iface_type = ATCA_I2C_IFACE, .devtype = ATECC608A, #ifdef ATCA_ENABLE_DEPRECATED - .atcai2c.slave_address = 0x6A, + .atcai2c.slave_address = CONFIG_ATCA_I2C_ADDRESS, #else - .atcai2c.address = 0x6A, + .atcai2c.address = CONFIG_ATCA_I2C_ADDRESS, #endif .atcai2c.bus = 0, - .atcai2c.baud = 100000, - .wake_delay = CONFIG_I2C_MANAGER_0_TIMEOUT, + .atcai2c.baud = CONFIG_ATCA_I2C_BAUD_RATE, + .wake_delay = 1500, .rx_retries = 20 }; diff --git a/port/atca_config.h b/port/atca_config.h index c3b8adf..abea39f 100644 --- a/port/atca_config.h +++ b/port/atca_config.h @@ -3,6 +3,22 @@ #ifndef ATCA_CONFIG_H #define ATCA_CONFIG_H +#if __has_include("esp_idf_version.h") +#include "esp_idf_version.h" +#endif + +/* +This requires the `esp_idf_version.h' to be defined. +*/ + +#ifdef ESP_IDF_VERSION + +#if ESP_IDF_VERSION <= ESP_IDF_VERSION_VAL(4, 3, 1) +#define ATCA_ENABLE_DEPRECATED +#endif + +#endif + /* Include HALS */ #define ATCA_HAL_I2C #define ATCA_USE_RTOS_TIMER 1