-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
可以用的,应用层测试代码 #3
Comments
verify_key.slot=KEY_ID_0; KEY_ID_0? is not defind |
这个芯片在i2C总线上的地址 是多少呀 |
reg = <0x64>;
***@***.***
发件人: 张文龙
发送时间: 2023-09-25 10:56
收件人: Tvirus/atsha204a_driver
抄送: liweifoic; Author
主题: Re: [Tvirus/atsha204a_driver] 可以用的,应用层测试代码 (Issue #3)
#include <string.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <linux/i2c-dev.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdint.h> #include "atsha204a_ioctl.h"
const char *filename = "/dev/atsha204a";
const uint8_t secret_key[32] = { 0x33, 0x77, 0x16, 0x22, 0x82, 0xde, 0xad, 0x8c, 0xe9, 0x14, 0x21, 0x87, 0xf5, 0x34, 0x6e, 0x55, 0xee, 0x42, 0x55, 0xd5, 0xff, 0x33, 0x3a, 0x40, 0x9a, 0xdf, 0xdb, 0x83, 0x55, 0x1b, 0xe2, 0x66 };
void print_hex(const char *str, const uint8_t *hex, const int len) { int i;
printf("%s : ", str);
for (i = 0; i < len; i++)
{
if (i > 0)
{
printf(" ");
}
printf("0x%02X", hex[i]);
}
printf("\n");
printf("\r\n");
}
uint8_t serial_number[9] = { 0 }; int main() { int file; int rc = 0;
static atsha204a_cmd_sn_t sn;
static atsha204a_cmd_mac_t mac;
static atsha204a_cmd_otp_t otp;
static uint16_t random_number = 0;
static atsha204a_cmd_nonce_t nonce;
static atsha204a_cmd_verify_key_t verify_key;
if ((file = open(filename, O_RDWR)) < 0)
{
/* ERROR HANDLING: you can check errno to see what went wrong */
perror("Failed to open the i2c bus");
exit(1);
}
if (ioctl(file, ATSHA204A_CMD_READ_SN, &sn) < 0)
{
printf("ATSHA204A_CMD_READ_SN failed \n");
rc = 1;
goto close_exit;
}
print_hex("ATSHA204A_CMD_READ_SN Received data", (uint8_t *)sn.sn,
sizeof(sn));
memset(&verify_key,0,sizeof(verify_key));
verify_key.slot=KEY_ID_0;
memcpy(verify_key.key, secret_key, sizeof(verify_key.key));
if (ioctl(file, ATSHA204A_CMD_VERIFY_KEY, &verify_key) < 0)
{
printf("ATSHA204A_CMD_MAC failed \n");
rc = 1;
goto close_exit;
}
printf("ATSHA204A_CMD_VERIFY_KEY OK \n");
close_exit:
close(file);
return rc;
}
这个芯片在i2C总线上的地址 是多少呀
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
您好:
我使用i2c tool命令行去查看i2c设备节点,对应的64没有被加载为UU,另外再去尝试直接使用命令行去读写都是失败的,这个原因是因为驱动没有正确被加载,所以使用不了这个设备吗?
…------------------ 原始邮件 ------------------
发件人: "Tvirus/atsha204a_driver" ***@***.***>;
发送时间: 2023年10月24日(星期二) 中午11:15
***@***.***>;
***@***.******@***.***>;
主题: Re: [Tvirus/atsha204a_driver] 可以用的,应用层测试代码 (Issue #3)
reg = <0x64>;
***@***.***
发件人: 张文龙
发送时间: 2023-09-25 10:56
收件人: Tvirus/atsha204a_driver
抄送: liweifoic; Author
主题: Re: [Tvirus/atsha204a_driver] 可以用的,应用层测试代码 (Issue #3)
#include <string.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <linux/i2c-dev.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <stdint.h> #include "atsha204a_ioctl.h"
const char *filename = "/dev/atsha204a";
const uint8_t secret_key[32] = { 0x33, 0x77, 0x16, 0x22, 0x82, 0xde, 0xad, 0x8c, 0xe9, 0x14, 0x21, 0x87, 0xf5, 0x34, 0x6e, 0x55, 0xee, 0x42, 0x55, 0xd5, 0xff, 0x33, 0x3a, 0x40, 0x9a, 0xdf, 0xdb, 0x83, 0x55, 0x1b, 0xe2, 0x66 };
void print_hex(const char *str, const uint8_t *hex, const int len) { int i;
printf("%s : ", str);
for (i = 0; i < len; i++)
{
if (i > 0)
{
printf(" ");
}
printf("0x%02X", hex[i]);
}
printf("\n");
printf("\r\n");
}
uint8_t serial_number[9] = { 0 }; int main() { int file; int rc = 0;
static atsha204a_cmd_sn_t sn;
static atsha204a_cmd_mac_t mac;
static atsha204a_cmd_otp_t otp;
static uint16_t random_number = 0;
static atsha204a_cmd_nonce_t nonce;
static atsha204a_cmd_verify_key_t verify_key;
if ((file = open(filename, O_RDWR)) < 0)
{
/* ERROR HANDLING: you can check errno to see what went wrong */
perror("Failed to open the i2c bus");
exit(1);
}
if (ioctl(file, ATSHA204A_CMD_READ_SN, &sn) < 0)
{
printf("ATSHA204A_CMD_READ_SN failed \n");
rc = 1;
goto close_exit;
}
print_hex("ATSHA204A_CMD_READ_SN Received data", (uint8_t *)sn.sn,
sizeof(sn));
memset(&verify_key,0,sizeof(verify_key));
verify_key.slot=KEY_ID_0;
memcpy(verify_key.key, secret_key, sizeof(verify_key.key));
if (ioctl(file, ATSHA204A_CMD_VERIFY_KEY, &verify_key) < 0)
{
printf("ATSHA204A_CMD_MAC failed \n");
rc = 1;
goto close_exit;
}
printf("ATSHA204A_CMD_VERIFY_KEY OK \n");
close_exit:
close(file);
return rc;
}
这个芯片在i2C总线上的地址 是多少呀
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <linux/i2c-dev.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdint.h>
#include "atsha204a_ioctl.h"
const char *filename = "/dev/atsha204a";
const uint8_t secret_key[32] = { 0x33, 0x77, 0x16, 0x22, 0x82, 0xde, 0xad, 0x8c,
0xe9, 0x14, 0x21, 0x87, 0xf5, 0x34, 0x6e, 0x55,
0xee, 0x42, 0x55, 0xd5, 0xff, 0x33, 0x3a, 0x40,
0x9a, 0xdf, 0xdb, 0x83, 0x55, 0x1b, 0xe2, 0x66
};
void print_hex(const char *str, const uint8_t *hex, const int len)
{
int i;
}
uint8_t serial_number[9] = { 0 };
int main()
{
int file;
int rc = 0;
close_exit:
}
The text was updated successfully, but these errors were encountered: