1.说明
本文采取aspeed sdk v09.01
版本来适配自己的实际的硬件开发平台。!!非采取qemu模拟方式!!
2.采用的镜像文件
2.1 采用网站编译好的镜像
采用网站: https://github.com/AspeedTech-BMC/openbmc/releases
的文件:
1.ast2600-default-515-obmc.tar.gz
.选择里面的文件image-bmc
.发现BMC
启动不了,u-boot
挂了。
2.ast2600-default-obmc.tar.gz
里面的image-bmc
.发现BMC
启动不了,报错:
Boot from spi
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
Error loading kernel FIT image
ast# BP1c00
注意: 使用openbmc
中的u-boot
更新固件,在u-boot
命令行可以采用的命令如下:
# mw 0x1E620064 0x500 //停止WDT2
# setenv gatewayip 10.245.27.1 //设置gatewayip
# setenv netmask 255.255.255.0 //设置网关
# dhcp //获取bmc ip 或者使用 setenv ipaddr 10.245.27.xx
# setenv serverip 10.245.27.xx //设置tftp服务器ip目的地址
# tftp 0x81000000 image-bmc //tftp 下载文件
# sf probe 0:0 //选中 flash0
# sf update 0x81000000 0x000000 0x4000000 //更新固件
2.2 自行编译镜像
从网站: https://github.com/AspeedTech-BMC/openbmc
上选择sdkv09.01
版本的代码之后,编译:
$ source setup ast2600-default
$ bitbake obmc-phosphor-image
产生的固件image-bmc
烧录之后,发现报错:
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
使用命令print
查看环境信息:
ast# print
baudrate=115200
boot_ast2700=echo "Boot from ${boot_device}!";if test ${boot_device} = mmc; then run bootmmc; fi;if test ${boot_device} = spi; then run bootspi; fi;ves
boot_device=spi
boota=setenv bootpart 2; setenv rootfs rofs-a; run setmmcargs; ext4load mmc 0:${bootpart} ${loadaddr} fitImage && bootm; echo Error loading kernel FITe
bootargs=console=ttyS4,115200n8 root=/dev/ram rw
bootb=setenv bootpart 3; setenv rootfs rofs-b; run setmmcargs; ext4load mmc 0:${bootpart} ${loadaddr} fitImage && bootm; echo Error loading kernel FITe
bootcmd=echo Boot from ${boot_device}; if test ${boot_device} = mmc; then run bootmmc; fi; if test ${boot_device} = spi; then run bootspi; fi;
bootdelay=2
bootfile=all.bin
bootmmc=if test "${bootside}" = "b"; then run bootb; run boota; else run boota; run bootb; fi
bootside=a
bootspi=fdt addr 20160000 && fdt header get fitsize totalsize && cp.b 20160000 ${loadaddr} ${fitsize} && bootm; echo Error loading kernel FIT image
fdtcontroladdr=bcf55f18
gatewayip=192.168.0.1
ipaddr=192.168.0.45
loadaddr=0x83000000
netmask=255.255.255.0
rootfs=rofs-a
serverip=192.168.0.81
setmmcargs=setenv bootargs ${bootargs} rootwait root=PARTLABEL=${rootfs}
stderr=serial@1e784000
stdin=serial@1e784000
stdout=serial@1e784000
Environment size: 1265/131068 bytes
环境变量默认值来源于:build/ast2600-default/workspace/sources/u-boot-aspeed-sdk/include/configs/evb_ast2600.h
.
然后使用命令fdt addr
:
ast# fdt addr 20160000
libfdt fdt_check_header(): FDT_ERR_BADMAGIC
分析到文件:meta-aspeed/conf/machine/evb-ast2600.conf
中使用的dts
信息:
KERNEL_DEVICETREE = "aspeed/aspeed-ast2600-evb.dtb"
UBOOT_MACHINE = "ast2600_openbmc_spl_defconfig"
UBOOT_DEVICETREE = "ast2600-evb"
查看linux
的flash layout
:
build/ast2600-default/workspace/sources/linux-aspeed/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dts
中,引用了build/ast2600-default/workspace/sources/linux-aspeed/arch/arm/boot/dts/aspeed/aspeed-evb-flash-layout-64.dtsi
// SPDX-License-Identifier: GPL-2.0+
/*
* Copyright (C) 2023 ASPEED.
*/
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
u-boot@0 {
reg = <0x0 0x140000>; // 1280KB
label = "u-boot";
};
u-boot-env@140000 {
reg = <0x140000 0x20000>; // 128KB
label = "u-boot-env";
};
kernel@160000 {
reg = <0x160000 0x800000>; // 8MB
label = "kernel";
};
rofs@960000 {
reg = <0x960000 0x24a0000>; // 36.625MB
label = "rofs";
};
rwfs@2e00000 {
reg = <0x2e00000 0x1200000>; // 18MB
label = "rwfs";
};
};
从基本信息来看,代码基本上没问题,那么,进入u-boot
中手动去加载dts
,查看是否仍然有问题:
1.在u-boot中disable FMC_WDT2
# mw 0x1e620064 0x0 //disable FMC_WDT2
2.在主机中,将
fitImage
文件拷贝到tftp
服务器中:
# cp tmp/deploy/images/ast2600-default/fitImage /home/wityuan/Desktop/tftp
3.设置BMC的ip等信息
# setenv gatewayip 10.245.27.1
# setenv netmask 255.255.255.0
# dhcp
# setenv serverip 10.245.27.69 //服务器ip
4.在u-boot中加载fitImage
# tftp 0x83000000 fitImage
5.使用fdt addr加载fdt信息
# fdt addr 0x83000000
# fdt header get fitsize totalsize
# cp.b 0x83000000 ${loadaddr} ${fitsize}
6.启动linux
使用命令:
# bootm
可以看到系统加载成功。
7.排查
1.tftp 0x83000000 fitImage //将数据加载到0x83000000 地址上
2.使用md.b 0x83000000 20 查看数据
2.使用notepad++查看image-bmc的0x00160000地址上的数据
使用sf read
读取flash
的0
地址,发现数据不正确:
切换到flash2
启动(包含正常启动的uboot
),然后使用flash2
排查flash1
的数据:
数据符合预期。
因此: sdk09.01
的uboot
代码是有问题的. 工具sf read
需要修正或者仅仅是dts
配置有问题,导致spi
工作不正常。
修改build/ast2600-default/workspace/sources/u-boot-aspeed-sdk/arch/arm/dts/ast2600-evb.dts
中:
&fmc {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_fmcquad_default>;
flash@0 {
compatible = "spi-flash", "sst,w25q256";
status = "okay";
spi-max-frequency = <50000000>;
spi-tx-bus-width = <2>;
spi-rx-bus-width = <2>;
};
flash@1 {
compatible = "spi-flash", "sst,w25q256";
status = "okay";
spi-max-frequency = <50000000>;
spi-tx-bus-width = <2>;
spi-rx-bus-width = <2>;
};
};
执行:
# bitbake -c build u-boot-aspeed-sdk
# bitbake -c deploy u-boot-aspeed-sdk
对于flash(mx66l512)芯片,默认的是3B模式,需要注意,后面u-boot代码都改为设置4B模式一次,详见代码:
另外,需要修改linux
代码:build/ast2600-default/workspace/sources/linux-aspeed/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dts
:
&fmc {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_fwqspi_default>;
flash@0 {
status = "okay";
m25p,fast-read;
label = "bmc";
spi-rx-bus-width = <2>;
spi-tx-bus-width = <2>;
spi-max-frequency = <50000000>;
#include "aspeed-evb-flash-layout-64.dtsi"
};
flash@1 {
status = "okay";
m25p,fast-read;
label = "fmc0:1";
spi-rx-bus-width = <2>;
spi-tx-bus-width = <2>;
spi-max-frequency = <50000000>;
};
flash@2 {
status = "disabled";
m25p,fast-read;
label = "fmc0:2";
spi-rx-bus-width = <4>;
spi-tx-bus-width = <4>;
spi-max-frequency = <50000000>;
};
};
最重要的是需要设置:
spi-rx-bus-width = <2>;
spi-tx-bus-width = <2>;
否则会发生报错:
以上,修改完成后,在ac
上电时候,需要进入u-boot
手动禁止掉watchdog
:
//disable fmc watchdog
# mw 0x1e620064 0x0
# //disable watchdog
mw 0x1e78508c 0x0
以上,成功进入BMC
系统:
3.适配网络
当前系统启动,网络并不能分配地址,报错如:
当前使用的是硬件上的MAC1(datasheet数值加1)
连接RTL8211
,作为dedicated
网络。MAC2(datasheet数值加1)
不做网络用途。
修改代码build/ast2600-default/workspace/sources/linux-aspeed/arch/arm/boot/dts/aspeed/aspeed-ast2600-evb.dts
内容:
&mdio0 {
status = "okay";
ethphy0: ethernet-phy@0 {
compatible = "ethernet-phy-ieee802.3-c22";
reg = <1>;
};
};
启动BMC
后,能找到网卡设备:
web
可以访问:
ssh
也可以访问到:
ipmitool
也可以访问到:
简单看一下"reg = <0x1>"的解析流程:
build/ast2600-default/workspace/sources/linux-aspeed/drivers/net/mdio/of_mdio.c
__of_mdiobus_register()
build/ast2600-default/workspace/sources/linux-aspeed/include/linux/of_mdio.h
---> of_mdio_parse_addr()
---> ret = of_property_read_u32(np, "reg", &addr);
/* A PHY must have a reg property in the range [0-31] */
---> if (addr >= PHY_MAX_ADDR) {
...
}
所以该:reg
值的范围是0~31
,概念为:PHY_MAX_ADDR
.
原理图上为:
此处描述如果有误,还请告知^ _ ^ .
4.修复重启
如果AC
,会发现BMC
执行到kernel
一段时间之后就会启动到flash2
上,这是因为fmc watchdog
的超时导致。
可以在uboot
代码中:build/ast2600-default/workspace/sources/u-boot-aspeed-sdk/arch/arm/mach-aspeed/ast2600/board_common.c
添加一段代码:
void board_add_ram_info(int use_default)
{
...
//disable fmc watchdog and watchdog
{
unsigned long value = 0;
//disable watchdog
*((volatile unsigned long *)(0x1e78508c)) = 0x0;
value = *((volatile unsigned long *)(0x1e78508c));
printf("\nwatchdog stop: 0x%08x \n", value);
//disable fmc watchdog
*((volatile unsigned long *)(0x1e620064)) = 0x0;
value = *((volatile unsigned long *)(0x1e620064));
printf("\nfmc watchdog stop: 0x%08x \n", value);
}
}
...
备注
- 1.
u-boot
的编译结果可以查看目录:build/ast2600-default/workspace/sources/u-boot-aspeed-sdk/oe-workdir/build/
- 2.当前采用的
fmc spi
芯片是mx66l51235l
,要注意一个问题: mtd: spi-nor: fix options for mx66l51235f - 3.本节的所有内容的修改,可以参考
gitee
提交: https://gitee.com/wit_yuan/sdk_v09.01_ast2600/tree/ast2600_porting_base_network/ - 4.单独更新
u-boot
的方法:
# setenv gatewayip 10.245.xx.xx
# setenv netmask 255.255.255.0
# dhcp
# setenv serverip 10.245.xx.xx
# tftp 0x83000000 image-u-boot
# sf probe 0
# sf update 0x83000000 0 $filesize
- 5.单独更新
kernel
的方法:
# setenv gatewayip 10.245.xx.xx
# setenv netmask 255.255.255.0
# dhcp
# setenv serverip 10.245.xx.xx
# tftp 0x83000000 fitimage
# sf probe 0
# sf update 0x83000000 0 $filesize
- 6.单独更新
bmc
的方法:
# setenv gatewayip 10.245.xx.xx
# setenv netmask 255.255.255.0
# dhcp
# setenv serverip 10.245.xx.xx
# tftp 0x83000000 image-bmc
# sf probe 0
# sf update 0x83000000 0 $filesize