公告

大中华汽车电子生态圈社区并入开发者社区- 更多资讯点击此

Tip / 登入 to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
ytx
Level 2
Level 2
10 replies posted First like given 5 sign-ins

tc389 DLMU RAM(CPU0_NC)上的内容,内容时初始化时就已经写好的,如:

uint32 test = 0xffffffff;

但是将test地址传递给hsm核,hsm使用

HSM_BRIDGE->SAHBASE = targetAddr & 0xFFFF0000;
pmem = (unsigned int *)(0xF0050000 | (targetAddr & 0x0000FFFF));
return pmem[0];
的形式去读,结果读到的值为0,请问各位大咖是什么原因呢?
0 点赞
1 解答
Jeremy_Z
Moderator
Moderator
Moderator
250 sign-ins 100 likes received 750 replies posted

Hi @ytx 

HSM本身是confidential的内容,不适合在论坛中公开讨论,

我建议按照这个步骤创建case来讨论,问题描述最后用英文。

BR,

Jeremy

在原帖中查看解决方案

0 点赞
8 回复数
ytx
Level 2
Level 2
10 replies posted First like given 5 sign-ins

更详细的描述如下:

有一个定义在0xb000431e的变量,长度为16,以如下方式定义
uint8 test = {0x6b,0xc1,0xbe,0xe2,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a};
tricore上未对该地址内容进行修改,但是将地址传递给HSM核后,HSM读到的内容为
{0x00,0x00,0x00,0x00,0x2e,0x40,0x9f,0x96,0xe9,0x3d,0x7e,0x11,0x73,0x93,0x17,0x2a}
即前面4字节没有取到数据,如果对该地址内容死循环的读,直到非0值后退出,是可以读到正确的值的。
按照《Infineon-AURIX_TC3xx_Part1-UserManual-v02_00-EN》上介绍:
该地址属于DLMU RAM(CPU0_NC),应该也跟cache没关系吧?麻烦帮忙看一下,感谢!
0 点赞
Jeremy_Z
Moderator
Moderator
Moderator
250 sign-ins 100 likes received 750 replies posted

Hi @ytx ,

首先,能否分享HSM读HOST memory的数据的函数或者代码,其次,HOST memory中存储的起始地址请保证16字节对齐。

BR,

Jeremy

0 点赞
ytx
Level 2
Level 2
10 replies posted First like given 5 sign-ins
您好,读的方式如下,对于非RAM的地址是直接读的,对于RAM的地址先设置了
SAHBASE然后读的
 
typedef struct {
    unsigned int start;
    unsigned int end;
} RAM_ADDR_RANGE;

RAM_ADDR_RANGE ramAddrRange[] = {
    {0x10000000, 0x80000000},
    {0xb0000000, 0xc0000000},
};
unsigned int hostread32(unsigned int addr, unsigned int offset)
{
    unsigned int count = 0;
    unsigned int ret = 0;
    unsigned int *pmem;
    unsigned int targetAddr = addr + (offset * 4);
    unsigned char isRamAddr = 0;
    for (unsigned int i = 0; i < sizeof(ramAddrRange) / sizeof(RAM_ADDR_RANGE); i++) {
        if (targetAddr >= ramAddrRange[i].start && targetAddr < ramAddrRange[i].end) {
            isRamAddr = 1;
        }
    }

 

    if (isRamAddr == 0) { // 非RAM地址
        pmem = (unsigned int *)targetAddr;
    } else { // RAM地址
        HSM_BRIDGE->SAHBASE = targetAddr & 0xFFFF0000;
        pmem = (unsigned int *)(0xF0050000 | (targetAddr & 0x0000FFFF));
    }
    return pmem[0];
}
0 点赞
ytx
Level 2
Level 2
10 replies posted First like given 5 sign-ins

另外,请问下:

1. 非16字节对齐的起始地址,访问的话有可能导致读到的数据为0吗?

2. 按16字节对齐后,每4字节读一次的话,读的第二次是非16字节对齐,有可能导致数据为0吗?

0 点赞
ytx
Level 2
Level 2
10 replies posted First like given 5 sign-ins

您好,

刚刚按32字节对齐进行了尝试,还是有可能会读到0值。

=================aes cbc key value================= 0xb0002bc0
2b 7e 15 16 28 ae d2 a6 ab f7 15 88 09 cf 4f 3c
=================aes cbc iv value================== 0xb0002be0
03 02 01 00 07 06 05 04 0b 0a 09 08 0f 0e 0d 0c
=================aes cbc original value============ 0xb0002c00
6b c1 be e2 2e 40 9f 96 e9 3d 7e 11 73 93 17 2a
=================aes cbc encrypt value============= 0xb0004bc0
dd ef ed d0 df 7c 48 74 b0 98 bc 34 bb 2f c0 c1

使用工具对加密后的数据解密可以看到,原加密数据为:

00 00 00 00 2E 40 9F 96 E9 3D 7E 11 73 93 17 2A

前面4字节没读到

 

0 点赞
Jeremy_Z
Moderator
Moderator
Moderator
250 sign-ins 100 likes received 750 replies posted

Hi @ytx ,

请尝试以下代码更新你上面的函数再试试。

        HSM_BRIDGE->SAHBASE = targetAddr & 0xFFFF0000;
        pmem = (unsigned int *)((targetAddr & 0x0000FFFF) | (unsigned int)&HSM_BRIDGE->SAHMEM[0]);
BR,
Jeremy
0 点赞
ytx
Level 2
Level 2
10 replies posted First like given 5 sign-ins

我进行了更新,但是似乎情况还是一样的

0 点赞
Jeremy_Z
Moderator
Moderator
Moderator
250 sign-ins 100 likes received 750 replies posted

Hi @ytx 

HSM本身是confidential的内容,不适合在论坛中公开讨论,

我建议按照这个步骤创建case来讨论,问题描述最后用英文。

BR,

Jeremy

0 点赞