最近在研究xboot对于T113-S3的启动源码,有一点一直搞不明白,就是在sys-copyself.c中的get_boot_device函数,源码如下:
static int get_boot_device(void)
{
uint8_t s = *((volatile uint8_t *)(0x00020000 + 0x28));
if(s == 0x3)
{
sys_uart_putc('3');
return BOOT_DEVICE_SPINOR;
}
else if(s == 0x4)
{
sys_uart_putc('4');
return BOOT_DEVICE_SPINAND;
}
else if(s == 0x0)
{
sys_uart_putc('0');
return BOOT_DEVICE_SDCARD;
}
sys_uart_putc(s);
return BOOT_DEVICE_SPINOR;
}
我还添加了打印,
log在下面:
xboot: /# 3
█████████████████████████████████
██ ▄▄▄▄▄ █▄ ▄▄▄█ █▀▄▀█ ▄▄▄▄▄ ██
██ █ █ ██▀▄▀ ▄▄▄ ▀ ▄ █ █ █ ██
██ █▄▄▄█ █ ▄▀ ▄▀▄▄▀█▀▄▀█ █▄▄▄█ ██
██▄▄▄▄▄▄▄█▄█ █▄█▄▀▄█ ▀▄█▄▄▄▄▄▄▄██
███ ▄▄▀▄▀▀█ ▄█▄▄▀▄█▀▄ ███ ██
██▀█▄▄█ ▄ ▀ ▄▄█▄▄▄█ ██ █ ▄█▄███
██▄█▄▀█▀▄█▄██▀▄ ▄▄ ▄▄ ▀▄▀▄▀▄▄▄ ██
██▀ ▀▄█ ▀ ▄▄█▀ ▀█▄█▄▀█▀▀▄▄ ███
██▀█▄ █▄▄██▄▀▀█▀▄▀█▄▀▀▄▀▀▄▀ ▄▄▀██
██ █▄█▄█▄▄▀ ▄▀▀█▄ ▄█▀▀█ ██ ██ ███
██▄█▄▄█▄▄█▀▀▀▄█▀ ▄▄▄▄▀ ▄▄▄ ▄▄▀██
██ ▄▄▄▄▄ █ ▀ ▀▀▄█ ▄█▄▄ █▄█ ██ ███
██ █ █ █ ▄▄▄▄▀ ▄▄ ▄█▄ ▄ ▄ ▄▀▀██
██ █▄▄▄█ █ ▀ ▄ █▄ ▄█ ▀▀▀▄█ ▄▄ ███
██▄▄▄▄▄▄▄██▄█▄▄▄▄█▄▄▄███▄█▄▄▄████
█████████████████████████████████
_ _
_ _ | |___ _____ _____ _| |_
\ \/ /| _ | _ | _ |_ _| (C) 2007-2023
) ( | |_| | |_| | |_| | | |____JIANJUN.JIANG__
/_/\_\|_____|_____|_____| |_____________________|
V3.0.0 (Dec 31 2023 - 02:44:20) - [mangopi][MangoPi-MQ Based On Allwinner T133-S3 SOC]
[ 0.000020]Probe device 'blk-romdisk.0' with blk-romdisk
[ 0.000800]Probe device 'ext-32k' with clk-fixed
[ 0.000810]Probe device 'rc-16m' with clk-fixed
[ 0.000820]Probe device 'dcxo24m' with clk-fixed
我理解的0x00020000 + 0x28这个地方应该存放的是xboot.bin的开头的识别信息里platform information,我把mksunxi之后的xboot.bin给反汇编了(mksunxi中貌似也只是修改了_spl_size和checksum吧),根据反汇编:
00000000 <.data>:
0: ea00000e b 0x40
4: 4e4f4765 cdpmi 7, 4, cr4, cr15, cr5, {3}
8: 3054422e subscc r4, r4, lr, lsr #4
c: c019bd71 andsgt fp, r9, r1, ror sp
10: 0000c000 andeq ip, r0, r0
14: 00000030 andeq r0, r0, r0, lsr r0
18: 30303033 eorscc r3, r0, r3, lsr r0
1c: 00020000 andeq r0, r2, r0
20: 00020000 andeq r0, r2, r0
...
2c: 00302e34 eorseq r2, r0, r4, lsr lr
...
40: ea00000d b 0x7c
44: e59ff014 ldr pc, [pc, #20] ; 0x60
48: e59ff014 ldr pc, [pc, #20] ; 0x64
4c: e59ff014 ldr pc, [pc, #20] ; 0x68
50: e59ff014 ldr pc, [pc, #20] ; 0x6c
54: e59ff014 ldr pc, [pc, #20] ; 0x70
58: e59ff014 ldr pc, [pc, #20] ; 0x74
5c: e59ff014 ldr pc, [pc, #20] ; 0x78
60: 40000400 andmi r0, r0, r0, lsl #8
64: 400004c0 andmi r0, r0, r0, asr #9
我发现,0x28处就是0啊,但实际打印出来却是0x3,但我一直找不到是在什么时候把0x00020000 + 0x28处的值改成0x3了,希望有大佬能解释一下。
最近编辑记录 zm (2023-12-31 16:11:43)
离线