mirror of
https://github.com/thead-yocto-mirror/light-libs
synced 2026-06-21 17:02:28 +02:00
Compare commits
3 Commits
Linux_SDK_
...
develop
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
38190e95b6 | ||
|
|
49ae529b8f | ||
|
|
9d4965f71f |
@@ -43,6 +43,18 @@ typedef enum {
|
||||
SECURE_BOOT_EN = 0x5a5a5a5a,
|
||||
} sboot_st_t;
|
||||
|
||||
enum life_cycle_e {
|
||||
LC_INIT = 0,
|
||||
LC_DEV,
|
||||
LC_OEM,
|
||||
LC_PRO,
|
||||
LC_RMA,
|
||||
LC_RIP,
|
||||
LC_KILL_KEY1,
|
||||
LC_KILL_KEY0,
|
||||
LC_MAX,
|
||||
};
|
||||
|
||||
/**
|
||||
* csi_efuse_get_chipid() - Get chip id in eFuse
|
||||
*
|
||||
@@ -374,4 +386,18 @@ int csi_efuse_update_lc_rma();
|
||||
*/
|
||||
int csi_efuse_update_lc_rip();
|
||||
|
||||
/**
|
||||
* csi_efuse_get_lc_preld() - get efuse life cycle preld
|
||||
* @lc_name: the output name of life cycle preld
|
||||
* Return: 0: Success others: Failed
|
||||
*/
|
||||
int csi_efuse_get_lc_preld(char *lc_name);
|
||||
|
||||
/*
|
||||
* csi_efuse_update_lc(enum life_cycle_e life_cycle)
|
||||
* @life_cycle: the life cycle to set
|
||||
* Return: 0: Success others: Failed
|
||||
*/
|
||||
int csi_efuse_update_lc(enum life_cycle_e life_cycle);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1505,3 +1505,113 @@ int csi_efuse_update_lc_rip()
|
||||
return 0;
|
||||
}
|
||||
|
||||
int csi_efuse_get_lc_preld(char *lc_name)
|
||||
{
|
||||
int fd, ret;
|
||||
char data[30] = {0};
|
||||
unsigned int lf = 0;
|
||||
const char *dev_path = "/sys/devices/platform/soc/ffff210000.efuse/lc_preld";
|
||||
char *str;
|
||||
|
||||
assert(lc_name);
|
||||
|
||||
fd = open(dev_path, O_RDONLY);
|
||||
if (fd < 0) {
|
||||
printf("failed to open device '%s' (%d)\n", dev_path, -errno);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
ret = read(fd, data, 30);
|
||||
if (ret < 0){
|
||||
printf("failed to read lifecycle from preld area\n");
|
||||
return -errno;
|
||||
}
|
||||
|
||||
lf = strtoul(data, NULL, 16);
|
||||
|
||||
switch (lf) {
|
||||
case 0xC44ACFCF:
|
||||
str = "LC_INIT";
|
||||
break;
|
||||
case 0xCA410C33:
|
||||
str = "LC_DEV";
|
||||
break;
|
||||
case 0x548411A6:
|
||||
str = "LC_OEM";
|
||||
break;
|
||||
case 0xABB00F15:
|
||||
str = "LC_PRO";
|
||||
break;
|
||||
case 0x67E93416:
|
||||
str = "LC_RMA";
|
||||
break;
|
||||
case 0x9fCAE0EA:
|
||||
str = "LC_RIP";
|
||||
break;
|
||||
default:
|
||||
str = "LC_MAX";
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
strcpy(lc_name, str);
|
||||
|
||||
close(fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* csi_efuse_update_lc(enum life_cycle_e life_cycle)
|
||||
* @life_cycle: the life cycle to set
|
||||
* Return: 0: Success others: Failed
|
||||
*/
|
||||
int csi_efuse_update_lc(enum life_cycle_e life_cycle)
|
||||
{
|
||||
int fd, ret = 0;
|
||||
char *lf;
|
||||
const char *dev_path = "/sys/devices/platform/soc/ffff210000.efuse/update_lc";
|
||||
|
||||
fd = open(dev_path, O_WRONLY);
|
||||
if (fd < 0) {
|
||||
printf("failed to open device '%s' (%d)\n", dev_path, -errno);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
switch (life_cycle) {
|
||||
case LC_DEV:
|
||||
lf = "LC_DEV";
|
||||
break;
|
||||
case LC_OEM:
|
||||
lf = "LC_OEM";
|
||||
break;
|
||||
case LC_PRO:
|
||||
lf = "LC_PRO";
|
||||
break;
|
||||
case LC_RMA:
|
||||
lf = "LC_RMA";
|
||||
break;
|
||||
case LC_RIP:
|
||||
lf = "LC_RIP";
|
||||
break;
|
||||
case LC_KILL_KEY1:
|
||||
lf = "LC_KILL_KEY1";
|
||||
break;
|
||||
case LC_KILL_KEY0:
|
||||
lf = "LC_KILL_KEY0";
|
||||
break;
|
||||
default:
|
||||
ret = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
ret = write(fd, lf, strlen(lf));
|
||||
if (ret < 0)
|
||||
printf("failed to update efuse life cycle(%d)\n", ret);
|
||||
else
|
||||
ret = 0;
|
||||
|
||||
exit:
|
||||
close(fd);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -43,6 +43,18 @@ typedef enum {
|
||||
SECURE_BOOT_EN = 0x5a5a5a5a,
|
||||
} sboot_st_t;
|
||||
|
||||
enum life_cycle_e {
|
||||
LC_INIT = 0,
|
||||
LC_DEV,
|
||||
LC_OEM,
|
||||
LC_PRO,
|
||||
LC_RMA,
|
||||
LC_RIP,
|
||||
LC_KILL_KEY1,
|
||||
LC_KILL_KEY0,
|
||||
LC_MAX,
|
||||
};
|
||||
|
||||
/**
|
||||
* csi_efuse_get_chipid() - Get chip id in eFuse
|
||||
*
|
||||
@@ -374,4 +386,18 @@ int csi_efuse_update_lc_rma();
|
||||
*/
|
||||
int csi_efuse_update_lc_rip();
|
||||
|
||||
/**
|
||||
* csi_efuse_get_lc_preld() - get efuse life cycle preld
|
||||
* @lc_name: the output name of life cycle preld
|
||||
* Return: 0: Success others: Failed
|
||||
*/
|
||||
int csi_efuse_get_lc_preld(char *lc_name);
|
||||
|
||||
/*
|
||||
* csi_efuse_update_lc(enum life_cycle_e life_cycle)
|
||||
* @life_cycle: the life cycle to set
|
||||
* Return: 0: Success others: Failed
|
||||
*/
|
||||
int csi_efuse_update_lc(enum life_cycle_e life_cycle);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -410,18 +410,38 @@ void csi_efuse_gmac_macaddr_test()
|
||||
printf("gmac mac0 address: %2x:%2x:%2x:%2x:%2x:%2x\n", r_mac1[0], r_mac1[1], r_mac1[2], r_mac1[3], r_mac1[4], r_mac1[5]);
|
||||
}
|
||||
|
||||
void csi_efuse_get_lc_preld_test()
|
||||
{
|
||||
char life_cycle[12] = {0};
|
||||
int ret;
|
||||
|
||||
ret = csi_efuse_get_lc_preld(life_cycle);
|
||||
if (ret) {
|
||||
printf("ret = %d\n", ret);
|
||||
return;
|
||||
}
|
||||
printf("lc_preld: %s\n", life_cycle);
|
||||
}
|
||||
|
||||
void csi_efuse_update_lc_test()
|
||||
{
|
||||
csi_efuse_update_lc(LC_DEV);
|
||||
csi_efuse_update_lc(LC_RMA);
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("efuse testing....\n");
|
||||
csi_efuse_update_lc_test();
|
||||
#if 0
|
||||
csi_efuse_get_lc_preld_test();
|
||||
csi_efuse_bl4_img_encrypt_test();
|
||||
csi_efuse_bl2_img_encrypt_test();
|
||||
csi_efuse_bl3_img_encrypt_test();
|
||||
csi_efuse_get_bl1_version_test();
|
||||
csi_efuse_get_hash_challenge_test();
|
||||
csi_efuse_get_secure_boot_st_test();
|
||||
#endif
|
||||
csi_efuse_offset_test();
|
||||
#if 0
|
||||
csi_efuse_usr_brom_cct_test();
|
||||
csi_efuse_usr_brom_usb_fastboot_test();
|
||||
csi_efuse_boot_index_test();
|
||||
@@ -432,9 +452,7 @@ int main()
|
||||
csi_efuse_get_secure_boot_st_test();
|
||||
csi_efuse_get_hash_challenge_test();
|
||||
csi_efuse_userdata_group_test();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
efuse_chip_id_get_test();
|
||||
csi_efuse_user_dbg_mode_test();
|
||||
csi_efuse_boot_offset_test();
|
||||
@@ -442,9 +460,7 @@ int main()
|
||||
csi_efuse_bak_boot_offset_test();
|
||||
csi_efuse_bak_boot_index_test();
|
||||
csi_efuse_usr_brom_usb_fastboot_test();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
csi_efuse_usr_brom_cct_test();
|
||||
printf("welcome to riscv world!!!\n");
|
||||
|
||||
@@ -457,13 +473,9 @@ int main()
|
||||
csi_efuse_get_hash_challenge_test();
|
||||
csi_efuse_userdata_group_test();
|
||||
csi_efuse_offset_test();
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
csi_efuse_update_lc_rma_test();
|
||||
csi_efuse_update_lc_rip_test();
|
||||
#endif
|
||||
#if 0
|
||||
csi_efuse_gmac_macaddr_test();
|
||||
#endif
|
||||
return 0;
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user