Skip to content

riscv: telink: load DAC key/cert from flash zone.#366

Merged
damien0x0023 merged 5 commits intodevelop_dualfrom
develop_dual_dac_loader
Jan 13, 2025
Merged

riscv: telink: load DAC key/cert from flash zone.#366
damien0x0023 merged 5 commits intodevelop_dualfrom
develop_dual_dac_loader

Conversation

@pulin1103
Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread src/platform/telink/FactoryDataParser.c Outdated
{
return false;
}
if (efuse_get_chip_id(chip_id))
Copy link
Copy Markdown
Collaborator

@andy-liu-telink andy-liu-telink Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

efuse_get_chip_id在B92和TL321x中的返回值不同的,处理逻辑刚好相反。可以参考金邈的这个PR里面的处理方式:telink-semi/mcuboot#3

Comment thread src/platform/telink/FactoryDataParser.c Outdated
}

size_t dac_cert_len;
dac_cert_len = buffer[100];
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

100用宏表示一下吧。 比如
static constexpr uint32_t kDacContentsOffset = 100;

Comment thread src/platform/telink/FactoryDataParser.c Outdated

size_t dac_cert_len;
dac_cert_len = buffer[100];
dac_cert_len |= (uint16_t) buffer[101] << 8;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

按照上面的处理方式,这里可以101可以替换成kDacContentsOffset + 1

Comment thread src/platform/telink/FactoryDataParser.c Outdated
{
return false;
}
factoryData->dac_cert.data = buffer + 102;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

kDacContentsOffset + 2

@pulin1103 pulin1103 force-pushed the develop_dual_dac_loader branch from acda9b6 to 9f99531 Compare January 9, 2025 07:18
Comment thread src/platform/telink/FactoryDataParser.c Outdated

#if CHIP_DEVICE_SECURE_PROGRAMMING

#if defined(CONFIG_SOC_RISCV_TELINK_B92)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是不是可以改成 #ifdef CONFIG_SOC_RISCV_TELINK_B92

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以统一到#ifdef

Comment thread src/platform/telink/FactoryDataParser.c Outdated
#include "aes.h"
#endif

#if defined(CONFIG_SOC_RISCV_TELINK_TL321X)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#if defined -> #ifdef

Comment thread config/telink/chip-module/Kconfig Outdated
config SECURE_PROGRAMMING
bool "Enable reading DAC and keys from the DAC partition"
depends on CHIP_FACTORY_DATA
default n
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

代码没对齐

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还有就是,我记得海文说过,Kconfig里面不要Enable xxx,CI会不过,直接Read DAC and keys from the DAC partition会不会简单点

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以看CI结果确认一下。

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

刚和海文确认了下,matter这边没这个问题,那应该没什么问题

@pulin1103 pulin1103 force-pushed the develop_dual_dac_loader branch from 9f99531 to f20f19e Compare January 9, 2025 08:05
Signed-off-by: Zhenghuan Zhang <zhenghuan.zhang@telink-semi.com>
@pulin1103 pulin1103 force-pushed the develop_dual_dac_loader branch from f20f19e to f23f72a Compare January 9, 2025 08:17
- add plaintext vid, pid & discriminator at the beginning.
- add optional argument --secure-programming-verification and --chip-id to
generate factory data and independent DAC.

Signed-off-by: Damien Ji <yinghao.ji@telink-semi.com>
Signed-off-by: Zhenghuan Zhang <zhenghuan.zhang@telink-semi.com>
@pulin1103 pulin1103 force-pushed the develop_dual_dac_loader branch from 099e852 to 0abcf93 Compare January 10, 2025 02:04
Zhenghuan Zhang and others added 2 commits January 10, 2025 11:40
Signed-off-by: Zhenghuan Zhang <zhenghuan.zhang@telink-semi.com>
- modify mfg_tool code format.
- add merge_factorydata_dac.

Signed-off-by: Damien Ji <yinghao.ji@telink-semi.com>
to fix code style issues.

Signed-off-by: Damien Ji <yinghao.ji@telink-semi.com>
}
else
{
LOG_ERR("Private key decryption failed.");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个错误信息应该改成“Failed to retrieve chip ID.”

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pulin1103 How about we add this change to my next Pull Request?

@damien0x0023 damien0x0023 merged commit 390d6be into develop_dual Jan 13, 2025
@damien0x0023 damien0x0023 deleted the develop_dual_dac_loader branch January 13, 2025 01:38
fengtai-telink pushed a commit that referenced this pull request Mar 6, 2025
- modify factorydataparse to load DAC key/cert from the flash zone.
- add plaintext vid, pid & discriminator at the beginning of factory_data_ext.
- add optional argument --secure-programming-verification and --chip-id to
generate factory_data_ext without DAC and independent DAC.
- add merge_factorydata_dac for TL321x programming.

Signed-off-by: Zhenghuan Zhang <zhenghuan.zhang@telink-semi.com>
Signed-off-by: Damien Ji <yinghao.ji@telink-semi.com>
Co-authored-by: Zhenghuan Zhang <zhenghuan.zhang@telink-semi.com>
Co-authored-by: Damien Ji <yinghao.ji@telink-semi.com>
fengtai-telink pushed a commit that referenced this pull request Apr 3, 2025
- modify factorydataparse to load DAC key/cert from the flash zone.
- add plaintext vid, pid & discriminator at the beginning of factory_data_ext.
- add optional argument --secure-programming-verification and --chip-id to
generate factory_data_ext without DAC and independent DAC.
- add merge_factorydata_dac for TL321x programming.

Signed-off-by: Zhenghuan Zhang <zhenghuan.zhang@telink-semi.com>
Signed-off-by: Damien Ji <yinghao.ji@telink-semi.com>
Co-authored-by: Zhenghuan Zhang <zhenghuan.zhang@telink-semi.com>
Co-authored-by: Damien Ji <yinghao.ji@telink-semi.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants