芯片通信测试

根据芯片手册,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 加密芯片调试记录的更多相关文章

  1. SPI 核软件调试记录

    SPI 核软件调试记录 1.首先说说int SpiFlashWaitForFlashReady(void)这一函数,基本上其它函数在执行的时候,都会事先执行一次此函数.    因为此函数的作用主要是用 ...

  2. Video Timing Controller v6.1软件调试记录

    Video Timing Controller v6.1软件调试记录 GUI配置: . case XVTC_VMODE_PAL: //576i@50 { TimingPtr->Interlace ...

  3. Video Test Pattern Generator(7.0)软件调试记录

    Video Test Pattern Generator(7.0)软件调试记录 . XVidC_VideoMode XVIDC_VM_576_50_I = XVIDC_VM_720x576_50_I ...

  4. 笔记:LIR2032 电池充电记录

    笔记:LIR2032 电池充电记录 LIR2032 电池是锂电池,形状和 CR2032 一样,只不过可以充电,材料是锂离子. 一个单颗的 LIR2032 电池容量只有 40mAH,容量很小. 那么就需 ...

  5. MA82G5D16AS16 主频调试记录

    MA82G5D16AS16 主频调试记录 当 SCKS 设置 为 MCKDO / 128 时 MCU 的电流为 0.58mA,100UF 电容可以维持 0.5S,大概可以满足. 但是需要注意外围的线路 ...

  6. Apusic中间件结合MyEclipse进行远程调试记录

    Apusic中间件结合MyEclipse进行远程调试记录. 在金蝶域中正常部署应用. 启动金蝶中间件时使用"startapusic -ds"命令. 在MyEclipse的Run-- ...

  7. http://stblog.baidu-tech.com/?p=1684) coredump调试记录 - PHP篇 原创: 扶墙 贝壳产品技术 今天

    http://stblog.baidu-tech.com/?p=1684) coredump调试记录 - PHP篇 原创: 扶墙 贝壳产品技术 今天

  8. 基于freescale i.Mx6(ARM)的阿里云oss调试记录

    交叉编译阿里OSS调试记录 1.1 开通oss服务 具体参考以下链接: https://help.aliyun.com/document_detail/31884.html?spm=a2c4g.111 ...

  9. [ZJCTF 2019]EasyHeap | house of spirit 调试记录

    BUUCTF 上的题目,由于部分环境没有复现,解法是非期望的 house of spirit 第一次接触伪造堆的利用方式,exp 用的是 Pwnki 师傅的,本文为调试记录及心得体会. 逆向分析的过程 ...

随机推荐

  1. Java函数式编程:二、高阶函数,闭包,函数组合以及柯里化

    承接上文:Java函数式编程:一.函数式接口,lambda表达式和方法引用 这次来聊聊函数式编程中其他的几个比较重要的概念和技术,从而使得我们能更深刻的掌握Java中的函数式编程. 本篇博客主要聊聊以 ...

  2. OpenMP 教程(一) 深入人剖析 OpenMP reduction 子句

    OpenMP 教程(一) 深入人剖析 OpenMP reduction 子句 前言 在前面的教程OpenMP入门当中我们简要介绍了 OpenMP 的一些基础的使用方法,在本篇文章当中我们将从一些基础的 ...

  3. SpringBoot 06: springboot中使用redis

    配置SpringBoot 创建SpringBoot项目时勾选Redis起步依赖 <dependency> <groupId>org.springframework.boot&l ...

  4. Atlassian Confluence 远程代码执行漏洞(CVE-2022-26134)漏洞复现

    目录 免责声明: Atlassian Confluence 远程代码执行漏洞(CVE-2022-26134)漏洞复现 漏洞概述: 影响版本: 漏洞复现: 利用POC: 利用过程: 修复建议: 参考 免 ...

  5. fastjson远程代码执行漏洞

    fastjson漏洞学习记录 免责声明: Fastjson 1.2.24 远程代码执行漏洞 漏洞说明 前提条件 影响范围 漏洞复现 Fastjson<=1.2.47 远程代码执行漏洞 Fastj ...

  6. 解决can't compare offset-naive and offset-aware datetimes报错

    问题描述 在比较 <class 'datetime.datetime'> 类型时,抛出异常 原因 俩个做比较的,一个具有时区,一个不具有时区 解决 如果可以确认俩个时间都是本地时间可以将时 ...

  7. python-封装、继承、多态

    封装 面向对象编程有三大特性:封装.继承.多态,其中最重要的一个特性就是封装.封装指的就是把数据与功能都整合到一起,针对封装到对象或者类中的属性,我们还可以严格控制对它们的访问,分两步实现:隐藏与开放 ...

  8. Linux系统各种库/软件版本输出指令

    日常开发基于Linux系统(其实更多的是Ubuntu平台),平时总会遇到一些情况需要查看某个库或者软件的版本信息,在这里做一下简单的记录. 1. 查看glibc版本 方法一:使用ldd指令 cv@cv ...

  9. 【Java EE】Day11 BootStrap、响应式布局、栅格系统、CSS样式、案例

    一.BootStrap介绍 https://v3.bootcss.com/css/#overview 1.概念 基于三剑客开发的前端开发框架 定义了许多css样式和js插件,从而得到丰富的页面效果 依 ...

  10. .net6制作让同事不能上网的arp欺骗工具

    摘一段来自网上的arp欺诈解释:ARP欺骗(ARP spoofing),又称ARP毒化(ARP poisoning,网络上多译为ARP病毒)或ARP攻击,是针对以太网地址解析协议(ARP)的一种攻击技 ...