利用xfel将boot0运行起来 输出内容如下:
HELLO! BOOT0 is starting!
BOOT0 commit : 27369ab
...
board init ok
ZQ value = 0x31***********
get_pmu_exist = -1
是不是说明boot0里面初始化ddr的操作失败了啊
求大佬指点
(附:本来想上传图片的,奈何上传半天没上传成功,只能手敲...)
离线
离线
利用tina-d1-open/lichee/brandy-2.0/build.sh脚本编译出来的spl固件。
烧录tina-d1-open/lichee/brandy-2.0/spl/nboot/boot0_sdcard.bin或者boot0_sdcard_sun20iw1p1.bin
通过xfel
xfel.exe write 0x20000 boot0_sdcard_sun20iw1p1.bin
100% [================================================] 66 kB, 319.7 kB/s
xfel.exe exec 0x20000
串口并没有任何输出信息,请问操作楼主我这操作流程上有问题吗?
离线
怎么通过write命令初始化uart呢?
离线
March 说:怎么通过write命令初始化uart呢?
这个晚点我研究一下。
gpio复用,时钟,uart使能。
我查看了spl的main函数的代码,里面有初始化uart的操作,难道是串口号不对吗?是什么原因导致无法打印出信息。
离线
https://github.com/xboot/xfel/blob/master/payloads/d1/d1-ddr/source/sys-uart.c
void sys_uart_init(void)
{
virtual_addr_t addr;
u32_t val;
/* Config GPIOB8 and GPIOB9 to txd0 and rxd0 */
addr = 0x02000030 + 0x04;
val = read32(addr);
val &= ~(0xf << ((8 & 0x7) << 2));
val |= ((0x6 & 0xf) << ((8 & 0x7) << 2));
write32(addr, val);
val = read32(addr);
val &= ~(0xf << ((9 & 0x7) << 2));
val |= ((0x6 & 0xf) << ((9 & 0x7) << 2));
write32(addr, val);
/* Open the clock gate for uart0 */
addr = 0x0200190c;
val = read32(addr);
val |= 1 << 0;
write32(addr, val);
/* Deassert uart0 reset */
addr = 0x0200190c;
val = read32(addr);
val |= 1 << 16;
write32(addr, val);
/* Config uart0 to 115200-8-1-0 */
addr = 0x02500000;
write32(addr + 0x04, 0x0);
write32(addr + 0x08, 0xf7);
write32(addr + 0x10, 0x0);
val = read32(addr + 0x0c);
val |= (1 << 7);
write32(addr + 0x0c, val);
write32(addr + 0x00, 0xd & 0xff);
write32(addr + 0x04, (0xd >> 8) & 0xff);
val = read32(addr + 0x0c);
val &= ~(1 << 7);
write32(addr + 0x0c, val);
val = read32(addr + 0x0c);
val &= ~0x1f;
val |= (0x3 << 0) | (0 << 2) | (0x0 << 3);
write32(addr + 0x0c, val);
}
没猜错的话,就是初始化这些寄存器就行了。
离线
确实spl阶段的串口没有信息是初始化时串口指向的问题
把nboot/main/boot0_head.c里面的定义
/*__s32 uart_port;*/
0,
/*normal_gpio_cfg uart_ctrl[2];*/
{
{6, 2, 4, 1, 1, 0, {0} },/*PB8: 4--RX*/
{6, 4, 4, 1, 1, 0, {0} },/*PB9: 4--TX*/
},
改成如下
/*__s32 uart_port;*/
0,
/*normal_gpio_cfg uart_ctrl[2];*/
{
{2, 8, 6, 1, 1, 0, {0} },/*PB8: 4--RX*/
{2, 9, 6, 1, 1, 0, {0} },/*PB9: 4--TX*/
},
spl阶段就能够正常的通过串口输出信息了。
最近编辑记录 bigmagic (2021-06-10 17:37:20)
离线
@bigmagic 那这是不是说明只运行boot0,初始化ddr失败了啊?
离线
fel 模式下下载boot0代码,ddr初始化不成功,这个感觉像主频不匹配?好想下载到nand或者sd卡中自启动试试,有没有办法操作一下
离线
@bigmagic
按照全志的惯例, 应该是从 sys_config.fex 的二进制文件读入配置, 再决定初始化哪组串口,前面应该有读配置(二进制)的过程.
没找到”从 sys_config.fex 的二进制文件读入配置“的过程啊
离线
离线
fel 模式下下载boot0代码,ddr初始化不成功,这个感觉像主频不匹配?好想下载到nand或者sd卡中自启动试试,有没有办法操作一下
离线
这是我用 PhoenixCard.exe 把 1.tina_d1-nezha_uart0.img 烧录到 tf卡,
然后用命令读出 8k 偏移 1M字节:
dd if=/dev/sdb of=a.bin bs=1K skip=8 count=1024
$ dd if=/dev/sdb of=a.bin bs=1K skip=8 count=1024
1000+0 records in
1000+0 records out
1024000 bytes (1.0 MB, 1000 KiB) copied, 0.0871346 s, 11.8 MB/s
再与 boot0_sdcard_sun20iw1p1.bin 对比
离线
下载这个可以初始化DDR和 UART: boot0_sdcard_sun20iw1p1_and_readfrom_tfcard.7z
这是启动记录:
[588]HELLO! BOOT0 is starting!
[590]BOOT0 commit : 27369ab
[593]set pll start
[595]periph0 has been enabled
[598]set pll end
[600][pmu]: bus read error
[602]board init ok
[604]DRAM only have internal ZQ!!
[607]get_pmu_exist() = -1
[610]ddr_efuse_type: 0x0
[613][AUTO DEBUG] single rank and full DQ!
[617]ddr_efuse_type: 0x0
[620][AUTO DEBUG] rank 0 row = 15
[623][AUTO DEBUG] rank 0 bank = 8
[626][AUTO DEBUG] rank 0 page size = 2 KB
[630]DRAM BOOT DRIVE INFO: V0.24
[633]DRAM CLK = 792 MHz
[635]DRAM Type = 3 (2:DDR2,3:DDR3)
[639]DRAMC ZQ value: 0x7b7bfb
[641]DRAM ODT value: 0x42.
[644]ddr_efuse_type: 0x0
[647]DRAM SIZE =512 M
[650]DRAM simple test OK.
[653]dram size =512
[655]card no is 0
[656]sdcard 0 line count 4
[659][mmc]: mmc driver ver 2021-04-2 16:45
[668][mmc]: Wrong media type 0x0
[671][mmc]: ***Try SD card 0***
[680][mmc]: HSSDR52/SDR25 4 bit
[683][mmc]: 50000000 Hz
[685][mmc]: 1904 MB
[687][mmc]: ***SD/MMC 0 init OK!!!***
[692]error:bad magic.
[695]error:bad magic.
[697]Loading boot-pkg fail(error=4)
烧录命令:
dd if=boot0_sdcard_sun20iw1p1_A.bin of=/dev/sdX bs=1K seek=8
(!!!一定要注意盘符 sdX 是否是TF卡)
(!!!一定要注意盘符 sdX 是否是TF卡)
(!!!一定要注意盘符 sdX 是否是TF卡)
离线
离线
xfel 在 0x2800 运行 /opt/D1/out/d1-nezha/image/fes1.fex 的结果。
固件打包流程分析: 固件打包流程分析.pdf
A64_lichee_User_Manual: A64_lichee_User_Manual.pdf
全志平台linux启动流程分析: https://blog.csdn.net/wlwl0071986/article/details/47207809
离线
out/d1-nezha/image/boot0_sdcard.fex
终于搞清楚了, 这个文件就是 TF卡 8K偏移的数据。
所以, 我们把 boot0_sdcard.bin或者boot0_sdcard_sun20iw1p1.bin 烧录到TF卡需要修改源码里面那个结构体数组。
是BT0_head这个结构体数组吗?
离线
所以这里是将整个64k的启动引导程序划分成立boot0和boot1吗?
这里的spl是boot0,boot1是指哪一个呢?还有spl目录下的fes文件具体是什么作用啊?用于烧录的fes1,是什么意思啊?有点迷糊。
离线
fes是给livesuilt用的,主要用于烧录,全志芯片有fel及fes两种usb通信模式,全志真正的烧录都是在fes模式下,fel仅仅是为了传输fes及运行,不过fel模式可以借助xfel实现fes的所有功能
离线
dd if=out/d1-nezha/image/boot0_sdcard.fex of=d1_tfcard_boot.img bs=1K seek=8
dd if=out/d1-nezha/image/u-boot.fex of=d1_tfcard_boot.img bs=1 seek=$((0x1013C00))
dd if=out/d1-nezha/image/opensbi.fex of=d1_tfcard_boot.img bs=1 seek=$((0x1004800))
dd if=out/d1-nezha/image/boot_package.fex of=d1_tfcard_boot.img bs=1 seek=$((0x1004000))
用这个命令可以生成能启动到u-boot 的tf卡引导镜像, 这是日志:
[486]HELLO! BOOT0 is starting!
[489]BOOT0 commit : 27369ab
[492]set pll start
[494]periph0 has been enabled
[497]set pll end
[498][pmu]: bus read error
[501]board init ok
[502]DRAM only have internal ZQ!!
[506]get_pmu_exist() = -1
[508]ddr_efuse_type: 0x0
[511][AUTO DEBUG] single rank and full DQ!
[515]ddr_efuse_type: 0x0
[518][AUTO DEBUG] rank 0 row = 15
[521][AUTO DEBUG] rank 0 bank = 8
[525][AUTO DEBUG] rank 0 page size = 2 KB
[528]DRAM BOOT DRIVE INFO: V0.24
[531]DRAM CLK = 792 MHz
[534]DRAM Type = 3 (2:DDR2,3:DDR3)
[537]DRAMC ZQ value: 0x7b7bfb
[540]DRAM ODT value: 0x42.
[542]ddr_efuse_type: 0x0
[545]DRAM SIZE =512 M
[549]DRAM simple test OK.
[551]dram size =512
[553]card no is 0
[555]sdcard 0 line count 4
[557][mmc]: mmc driver ver 2021-04-2 16:45
[566][mmc]: Wrong media type 0x0
[569][mmc]: ***Try SD card 0***
[578][mmc]: HSSDR52/SDR25 4 bit
[581][mmc]: 50000000 Hz
[583][mmc]: 1904 MB
[585][mmc]: ***SD/MMC 0 init OK!!!***
[641]Loading boot-pkg Succeed(index=0).
[645]Entry_name = opensbi
[648]Entry_name = u-boot
[651]Entry_name = dtb
[654]mmc not para
[656]Jump to second Boot.
OpenSBI v0.6
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|
Platform Name : T-HEAD Xuantie Platform
Platform HART Features : RV64ACDFIMSUVX
Platform Max HARTs : 1
Current Hart : 0
Firmware Base : 0x40000400
Firmware Size : 75 KB
Runtime SBI Version : 0.2
MIDELEG : 0x0000000000000222
MEDELEG : 0x000000000000b1ff
PMP0 : 0x0000000040000000-0x000000004001ffff (A)
PMP1 : 0x0000000040000000-0x000000007fffffff (A,R,W,X)
PMP2 : 0x0000000000000000-0x0000000007ffffff (A,R,W)
PMP3 : 0x0000000009000000-0x000000000901ffff (
U-Boot 2018.05-g0a88ac9-dirty-config-dirty (May 07 2021 - 21:48:53 +0800) Allwinner Technology
[00.740]DRAM: 512 MiB
[00.742]Relocation Offset is: 1def0000
[00.746]secure enable bit: 0
[00.749]CPU=1008 MHz,PLL6=600 Mhz,AHB=200 Mhz, APB1=100Mhz MBus=300Mhz
[00.755]flash init start
[00.757]workmode = 0,storage type = 1
[00.761][mmc]: mmc driver ver uboot2018:2021-04-16 14:23:00-1
[00.766][mmc]: get sdc_type fail and use default host:tm1.
[00.773][mmc]: can't find node "mmc0",will add new node
[00.777][mmc]: fdt err returned <no error>
[00.781][mmc]: Using default timing para
[00.785][mmc]: SUNXI SDMMC Controller Version:0x50310
[00.802][mmc]: card_caps:0x3000000a
[00.805][mmc]: host_caps:0x3000003f
[00.809]sunxi flash init ok
[00.811]line:714 init_clocks
__clk_init: clk pll_periph0x2 already initialized
register fix_factor clk error
[00.821]drv_disp_init
request pwm success, pwm2:pwm2:0x2000c00.
[00.838]drv_disp_init finish
[00.840]boot_gui_init:start
[00.843]set disp.dev2_output_type fail. using defval=0
[01.035]boot_gui_init:finish
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Pa[01.447]LCD open finish
rtition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
partno erro : can't find partition bootloader
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
** Unrecognized filesystem type **
[01.572]sunxi bmp info error : unable to open logo file bootlogo.bmp
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
[01.727]Loading Environment from SUNXI_FLASH... *** Warning - bad CRC, using default environment
Failed (-5)
[01.752][mmc]: memalign dst_align is NULL!
read first backup failed in fun sunxi_flash_mmc_secread line 353
[01.762][mmc]: memalign dst_align is NULL!
read first backup failed in fun sunxi_flash_mmc_secread line 353
[01.771]unknown error happen in item 0 read
[01.775]get secure storage map err
[01.778]sunxi secure storage is not supported
[01.782]usb burn from boot
delay time 0
weak:otg_phy_config
[01.793]usb prepare ok
[02.596]overtime
[02.600]do_burn_from_boot usb : no usb exist
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
[02.620]update part info
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
[02.639]update bootcmd
GUID Partition Table Header signature is wrong: 0x0 != 0x5452415020494645
part_get_info_efi: *** ERROR: Invalid GPT ***
part_get_info_efi: *** Using Backup GPT ***
[02.658]change working_fdt 0x5eaafda8 to 0x5ea8fda8
[02.679]update dts
## Error: "distro_bootcmd" not defined
=>
=>
=>
=> printenv
baudrate=115200
bootcmd=run distro_bootcmd
bootdelay=2
fdtcontroladdr=5eaafda8
force_normal_boot=1
partitions=boot-resource@mmcblk0p1:env@mmcblk0p2:env-redund@mmcblk0p3:boot@mmcblk0p4:rootfs@mmcblk0p5:dsp0@mmcblk0p6:recovery@mmcblk0p7:UDISK@mmcblk0p8
Environment size: 264/131067 bytes
=>
离线
现在更改了BT0_head的初始数据,烧录boot0_sdcard_sun20iw1p1.bin至TF卡中,可以初始化DDR和mmc了,结果如下:
程序连续输出两个“error:bad magic.”错误提示停止了,仔细看了代码,是toc1的头部数据数据不对,而头部数据又是从UBOOT_START_SECTOR_IN_SDMMC=32800处读出来的,利用官方的PhoenixCard工具烧录tina_d1-nezha_uart0.img到TF卡中,输出头部数据,如下:
我的问题是:这个头部数据是在什么时候赋值的呢?这个“32800”是指扇区吗?
望大佬指点一下。
离线
离线
这个头部数据是在哪里赋值的呢?是在打包阶段吗?
离线
March 说:这个头部数据是在哪里赋值的呢?是在打包阶段吗?
你看下脚本,里面有 各个.fex怎么生成的,
比如 update_boot0 专门生成 boot0*.fex 文件。
能力有限,还是不知道这个头部数据在哪里生成的。
离线
@March
请问怎么修改BT0_head可以初始化sdCard呢?
离线
out/d1-nezha/image/boot0_sdcard.fex
终于搞清楚了, 这个文件就是 TF卡 8K偏移的数据。
所以, 我们把 boot0_sdcard.bin或者boot0_sdcard_sun20iw1p1.bin 烧录到TF卡需要修改源码里面那个结构体数组。
请问除了修改boot0_header里的串口数组还需要修改别的吗,我改完之后由tf卡启动boot0 还是无法初始化DDR
离线