【随笔记】ATECC608 加密芯片调试记录
芯片通信测试
根据芯片手册,ATECC608B 的 7bit 器件地址是:0x35
root@linux:/usr/bin# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- 35 -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- UU -- --
50: -- UU 52 53 -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
下载必要文件
大多数加密芯片都是由原厂提供库文件,便于降低开发难度。
官网下载:CryptoAuthLib
https://www.microchip.com/en-us/software-library/cryptoauthlib
https://codeload.github.com/MicrochipTech/cryptoauthlib/zip/refs/tags/v3.3.3
编译库文件的版本只需要最低 cmake 2.6.4 版本,但是测试程序最低 cmake 3.10
官网下载:
https://cmake.org/files/v3.10/cmake-3.10.3-Linux-x86_64.tar.gz
解压并设置好环境变量:
export PATH=/home/lmx/work/tmp/cmake-3.10.3-Linux-x86_64/bin:$PATH
移植编译源码
配置编译工具链
建立新的配置文件,指定编译工具链的位置:xxx_linux_toolchain.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_TOOLCHAIN_PATH /home/lmx/work/xxx/lichee/out/gcc-linaro-5.3.1-2016.05/gcc-aarch64)
set(CMAKE_C_COMPILER ${CMAKE_TOOLCHAIN_PATH}/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${CMAKE_TOOLCHAIN_PATH}/bin/arm-linux-gnueabihf-g++)
编译动态链接库
通过生成 Makefile:
lmx@lmx:~/work/xxx/application/cryptoauthlib-3.3.3$ mkdir build && cd build
lmx@lmx:~/work/xxx/application/cryptoauthlib-3.3.3/build$ cmake -DCMAKE_TOOLCHAIN_FILE=xxx_linux_toolchain.cmake -DATCA_HAL_I2C=ON ../
-- The C compiler identification is GNU 4.9.3
-- Check for working C compiler: /home/lmx/work/xxx/lichee/out/gcc-linaro-5.3.1-2016.05/gcc-aarch64/bin/aarch64-linux-gnu-gcc
-- Check for working C compiler: /home/lmx/work/xxx/lichee/out/gcc-linaro-5.3.1-2016.05/gcc-aarch64/bin/aarch64-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for malloc
-- Looking for malloc - found
-- Looking for free
-- Looking for free - found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lmx/work/xxx/application/cryptoauthlib-3.3.3/build
编译动态库文件:
lmx@lmx:~/work/xxx/application/cryptoauthlib-3.3.3/build$ make
Scanning dependencies of target cryptoauth
[ 1%] Building C object lib/CMakeFiles/cryptoauth.dir/atca_basic.c.o
[ 2%] Building C object lib/CMakeFiles/cryptoauth.dir/atca_cfgs.c.o
......
[ 95%] Building C object lib/CMakeFiles/cryptoauth.dir/hal/atca_hal.c.o
[ 97%] Building C object lib/CMakeFiles/cryptoauth.dir/hal/hal_linux.c.o
[ 98%] Building C object lib/CMakeFiles/cryptoauth.dir/hal/hal_linux_i2c_userspace.c.o
[100%] Linking C shared library libcryptoauth.so
[100%] Built target cryptoauth
得到两个关键文件:
lmx@lmx:~/work/xxx/application/cryptoauthlib-3.3.3/build$ ls -l lib/*.h lib/*.so
-rw-r--r-- 1 lmx lmx 2923 11月 4 11:20 lib/atca_config.h
-rwxrwxr-x 1 lmx lmx 927371 11月 4 14:02 lib/libcryptoauth.so
编译可执行程序
指定动态链接库的位置:
--- cryptoauthlib-3.3.3\test\CMakeLists.txt
+++ cryptoauthlib-3.3.3\test\CMakeLists.txt
@@ -52,13 +52,13 @@
${CMAKE_CURRENT_SOURCE_DIR}/../lib
${CMAKE_CURRENT_SOURCE_DIR}/../third_party
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/mbedtls/include
${CMAKE_CURRENT_SOURCE_DIR}/../third_party/wolfssl
${CMAKE_CURRENT_BINARY_DIR}/../lib)
-target_link_libraries(cryptoauth_test cryptoauth)
+target_link_libraries(cryptoauth_test ${CMAKE_CURRENT_BINARY_DIR}/../lib/libcryptoauth.so)
if(UNIX)
target_link_libraries(cryptoauth_test pthread)
endif()
if(ATCA_BUILD_SHARED_LIBS)
编译可执行程序:
lmx@lmx:~/work/xxx/application/cryptoauthlib-3.3.3/build$ mkdir bin && cd bin
lmx@lmx:~/work/xxx/application/cryptoauthlib-3.3.3/build/bin$ cmake -DCMAKE_TOOLCHAIN_FILE=../xxx_linux_toolchain.cmake ../../test/
-- The C compiler identification is GNU 4.9.3
-- Check for working C compiler: /home/lmx/work/xxx/lichee/out/gcc-linaro-5.3.1-2016.05/gcc-aarch64/bin/aarch64-linux-gnu-gcc
-- Check for working C compiler: /home/lmx/work/xxx/lichee/out/gcc-linaro-5.3.1-2016.05/gcc-aarch64/bin/aarch64-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/lmx/work/xxx/application/cryptoauthlib-3.3.3/build/bin
lmx@lmx:~/work/xxx/application/cryptoauthlib-3.3.3/build/bin$ make
Scanning dependencies of target cryptoauth_test
[ 1%] Building C object CMakeFiles/cryptoauth_test.dir/atca_crypto_sw_tests.c.o
[ 2%] Building C object CMakeFiles/cryptoauth_test.dir/atca_test.c.o
......
[ 98%] Building C object CMakeFiles/cryptoauth_test.dir/home/lmx/work/xxx/application/cryptoauthlib-3.3.3/third_party/unity/unity_memory.c.o
[100%] Linking C executable cryptoauth_test
[100%] Built target cryptoauth_test
测试芯片功能:
执行测试程序(器件地址是 0x35,传给测试程序需要左移一位得到 0x6a):
root@linux:~# ./cryptoauth_test info -d ecc608 -i i2c 1 -a 0x6a
revision:
00 00 60 03
root@linux:~# ./cryptoauth_test sernum -d ecc608 -i i2c 1 -a 0x6a
serial number:
01 23 1A 41 5D 5C E7 AF 01
【随笔记】ATECC608 加密芯片调试记录的更多相关文章
- SPI 核软件调试记录
SPI 核软件调试记录 1.首先说说int SpiFlashWaitForFlashReady(void)这一函数,基本上其它函数在执行的时候,都会事先执行一次此函数. 因为此函数的作用主要是用 ...
- Video Timing Controller v6.1软件调试记录
Video Timing Controller v6.1软件调试记录 GUI配置: . case XVTC_VMODE_PAL: //576i@50 { TimingPtr->Interlace ...
- Video Test Pattern Generator(7.0)软件调试记录
Video Test Pattern Generator(7.0)软件调试记录 . XVidC_VideoMode XVIDC_VM_576_50_I = XVIDC_VM_720x576_50_I ...
- 笔记:LIR2032 电池充电记录
笔记:LIR2032 电池充电记录 LIR2032 电池是锂电池,形状和 CR2032 一样,只不过可以充电,材料是锂离子. 一个单颗的 LIR2032 电池容量只有 40mAH,容量很小. 那么就需 ...
- MA82G5D16AS16 主频调试记录
MA82G5D16AS16 主频调试记录 当 SCKS 设置 为 MCKDO / 128 时 MCU 的电流为 0.58mA,100UF 电容可以维持 0.5S,大概可以满足. 但是需要注意外围的线路 ...
- Apusic中间件结合MyEclipse进行远程调试记录
Apusic中间件结合MyEclipse进行远程调试记录. 在金蝶域中正常部署应用. 启动金蝶中间件时使用"startapusic -ds"命令. 在MyEclipse的Run-- ...
- http://stblog.baidu-tech.com/?p=1684) coredump调试记录 - PHP篇 原创: 扶墙 贝壳产品技术 今天
http://stblog.baidu-tech.com/?p=1684) coredump调试记录 - PHP篇 原创: 扶墙 贝壳产品技术 今天
- 基于freescale i.Mx6(ARM)的阿里云oss调试记录
交叉编译阿里OSS调试记录 1.1 开通oss服务 具体参考以下链接: https://help.aliyun.com/document_detail/31884.html?spm=a2c4g.111 ...
- [ZJCTF 2019]EasyHeap | house of spirit 调试记录
BUUCTF 上的题目,由于部分环境没有复现,解法是非期望的 house of spirit 第一次接触伪造堆的利用方式,exp 用的是 Pwnki 师傅的,本文为调试记录及心得体会. 逆向分析的过程 ...
随机推荐
- 【lwip】07-链路层收发以太网数据帧源码分析
目录 前言 7.1 链路层概述 7.2 MAC地址的基本概念 7.3 以太网帧结构 7.4 以太网帧结构 7.5 以太网帧报文数据结构 7.6 发送以太网数据帧 7.7 接收以太网数据帧 7.8 虚拟 ...
- ES6学习笔记(十四)module的简单使用
1.前言 module模块机制是es6新引入的,它解决了作用域的问题,使代码更加规范和结构化. 下面简单的使用一下. 2.基本使用 2.1 模块和脚本的区别 模块代码运行在严格模式下,并且没有任何办法 ...
- 嵌入式-C语言基础:字符串比较函数strcmp及其实现
#include<stdio.h> #include <string.h> int mystrcmp(char * p1,char * p2) { int ret=0; if( ...
- PHP 代码解一元二次方程
1 function php_getSolutionOVQE($a,$b,$c=0){ 2 $x1=0; 3 $x2=0; 4 $detal=0; 5 if($a==0 && $b== ...
- win10+vs2019 编译webrtc m108
不能访问外网途径的捷径 已经下载好的资源,可以直接生成工程: https://pan.baidu.com/s/14plvXZD_qX9nn441RbsCwA?pwd=ww8c 该资源可以跳过的步骤 步 ...
- dafny : 微软推出的形式化验证语言
dafny是一种可验证的编程语言,由微软推出,现已经开源. dafny能够自我验证,可以在VS Code中进行开发,在编辑算法时,写好前置条件和后置条件,dafny验证器就能实时验证算法是否正确. 在 ...
- 错误“AxImp.exe”已退出,代码为 -1163019603
最近调试项目时突然出现错误"AxImp.exe"已退出,代码为 -1163019603 发现引用中的组件出现了一个感叹号 经过核对是锐浪报表的组件出现了问题,尝试打开报表设计器也无 ...
- qtCreator警告解决
警告 qtCreator Warning: QT_DEVICE_PIXEL_RATIO is deprecated. Instead use: QT_AUTO_SCREEN_SCALE_FACTOR ...
- jmeter 从多个数中随机取一个值的方法
问题描述:使用jmeter进行接口测试时,遇到枚举值(如:10代表闲置.15代表使用中.20代表维修等)我们需要随机取一个类型传到接口中. 解决思路:通过函数助手查找随机函数,找到__chooseRa ...
- MasaFramework -- 领域驱动设计
概念 什么是领域驱动设计 领域驱动的主要思想是, 利用确定的业务模型来指导业务与应用的设计和实现.主张开发人员与业务人员持续地沟通和模型的持续迭代,从而保证业务模型与代码的一致性,实现有效管理业务的复 ...