mirror of
https://github.com/xboot/xfel.git
synced 2024-11-27 03:33:28 +08:00
[r128]using payload_arm_thumb_read32 to read sid
This commit is contained in:
parent
1bf6a578ca
commit
52c1a60657
37
chips/r128.c
37
chips/r128.c
@ -12,14 +12,43 @@ static int chip_reset(struct xfel_ctx_t * ctx)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
.global _start
|
||||
_start:
|
||||
ldr r0, _adr
|
||||
add r1, pc, #12
|
||||
ldr r2, [r0]
|
||||
str r2, [r1, #0]
|
||||
bx lr
|
||||
.align 2
|
||||
_adr:
|
||||
.word 0x11223344
|
||||
_val:
|
||||
.word 0x55667788
|
||||
*/
|
||||
static uint32_t payload_thumb_read32(struct xfel_ctx_t * ctx, uint32_t addr)
|
||||
{
|
||||
static const uint8_t payload[] = {
|
||||
0x02, 0x48, 0x03, 0xa1, 0x02, 0x68, 0x0a, 0x60, 0x70, 0x47, 0x00, 0xbf,
|
||||
};
|
||||
uint32_t adr = cpu_to_le32(addr);
|
||||
uint32_t val;
|
||||
|
||||
fel_write(ctx, ctx->version.scratchpad, (void *)payload, sizeof(payload));
|
||||
fel_write(ctx, ctx->version.scratchpad + sizeof(payload), (void *)&adr, sizeof(adr));
|
||||
fel_exec(ctx, ctx->version.scratchpad);
|
||||
fel_read(ctx, ctx->version.scratchpad + sizeof(payload) + sizeof(adr), (void *)&val, sizeof(val));
|
||||
return le32_to_cpu(val);
|
||||
}
|
||||
|
||||
static int chip_sid(struct xfel_ctx_t * ctx, char * sid)
|
||||
{
|
||||
uint32_t id[4];
|
||||
|
||||
id[0] = R32(0x4004e600 + 0x0);
|
||||
id[1] = R32(0x4004e600 + 0x4);
|
||||
id[2] = R32(0x4004e600 + 0x8);
|
||||
id[3] = R32(0x4004e600 + 0xc);
|
||||
id[0] = payload_thumb_read32(ctx, 0x4004e600 + 0x0);
|
||||
id[1] = payload_thumb_read32(ctx, 0x4004e600 + 0x4);
|
||||
id[2] = payload_thumb_read32(ctx, 0x4004e600 + 0x8);
|
||||
id[3] = payload_thumb_read32(ctx, 0x4004e600 + 0xc);
|
||||
sprintf(sid, "%08x%08x%08x%08x", id[0], id[1], id[2], id[3]);
|
||||
return 1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user