uboot源码配置和编译流程
linux系统非安全启动流程需要进行basic版本移植,要参考DK1公板进行移植。
#配置编译流程
配置交叉编译工具链,打开uboot源码顶层目录下Makefile,搜索CROSS_COMPILE
262 ifeq ($(HOSTARCH),$(ARCH))
263 CROSS_COMPILE ?=
更改为:
262 ifeq (arm,arm)
263 CROSS_COMPILE ?=arm-linux-gnueabihf-
在uboot源码顶层目录下,配置非安全模式的默认缺省配置文件
make stm32mp15_basic_defconfig
成功现象:
#
# configuration written to .config
#
复制设备树的相关内容
由于FSMP1A开发板是参考DK1公板进行设计的,所以需要复制DK1公板相关设备树内容
1)在uboot源码顶层目录下,进入arch/arm/dts,查找DK1公板相关设备树内容
stm32mp157a-dk1.dts
stm32mp157a-dk1-u-boot.dtsi
stm32mp15xx-dkx.dtsi
2)进入arch/arm/dts,将DK1公板设备树相关内容,复制为FSMP1A相关平台内容
cp stm32mp157a-dk1.dts stm32mp157a-fsmp1a.dts
cp stm32mp157a-dk1-u-boot.dtsi stm32mp157a-fsmp1a-u-boot.dtsi
cp stm32mp15xx-dkx.dtsi stm32mp15xx-fsmp1x.dtsi
3)进入arch/arm/dts,打开stm32mp157a-fsmp1a.dts文件
12 #include "stm32mp15xx-dkx.dtsi"
13
14 / {
15 model = "STMicroelectronics STM32MP157A-DK1 Discovery Board";
16 compatible = "st,stm32mp157a-dk1", "st,stm32mp157";
更改为以下内容:
12 #include "stm32mp15xx-fsmp1x.dtsi"
13
14 / {
15 model = "HQYJ STM32MP157A-FSMP1A Discovery Board";
16 compatible = "hqyj,stm32mp157a-fsmp1a", "hqyj,stm32mp157";
更改Makefile文件,将自己板子的设备树进行编译
进入arch/arm/dts,打开Makefile文件,添加stm32mp157a-fsmp1a.dtb
945 dtb-$(CONFIG_STM32MP15x) += \
946 stm32mp157a-dk1.dtb \
947 stm32mp157a-fsmp1a.dtb \
进入uboot源码顶层目录下,对uboot源码进行编译
time make -j4 all
time:显示编译时间
-j4:开启4个线程进行编译
编译成功现象:
生成
u-boot-spl.stm32
u-boot.img
把源码镜像文件烧写到TF卡中
1.将TF开插入到读卡器中,将读卡器插入到电脑中,并且被ubuntu识别,点击确定
2.查看TF卡分区
linux@ubuntu:~/FSMP1A/u-boot-stm32mp-v2020.10-stm32mp-r2-r0/u-boot-stm32mp-v2020.10-stm32mp-r2$ ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda5 /dev/sdb /dev/sdb1 /dev/sdb2 /dev/sdb3 /dev/sdb4 /dev/sdb5
3.删除TF卡所有分区
sudo parted -s /dev/sdb mklabel msdos
执行完以上命令之后,再进行查看: ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 /dev/sda5 /dev/sdb
4.对TF卡进行分区
sudo sgdisk --resize-table=128 -a 1 -n 1:34:545 -c 1:fsbl1 -n 2:546:1057 -c 2:fsbl2 -n 3:1058:5153 -c 3:ssbl -n 4:5154:136225 -c 4:bootfs -n 5:136226 -c 5:rootfs -A 4:set:2 -p /dev/sdb -g
5.进入uboot源码顶层目录下,对uboot源码镜像文件进行烧写
linux@ubuntu:$ sudo dd if=u-boot-spl.stm32 of=/dev/sdb1 conv=fdatasync
linux@ubuntu:$ sudo dd if=u-boot-spl.stm32 of=/dev/sdb2 conv=fdatasync
linux@ubuntu:$ sudo dd if=u-boot.img of=/dev/sdb3 conv=fdatasync
#电源管理问题
一、对比参考办和开发板电路图是否一致
1.错误现象:
U-Boot SPL 2020.10 (Nov 03 2022 - 10:41:21 +0800)
Model: STMicroelectronics STM32MP157C eval daughter on eval mother
stpmic1_read: failed to read register x : 32stpmic1_read: failed to read register x : 24RAM: DDR3-DDR3L 32bits 533000Khz
stpmic1_read: failed to read register x : 39ddr power init failed
resetting ...
2.通过打印信息的关键字(POWER/PMIC)猜测可能是电源管理相关问题
3.分析可知
1)FSMP1A开发板是通过DK1公板进行设计的
2)去对比以下FSMP1A开发板和DK1公板电源电路图
二、删除DK1公板相关电源内容
1.在uboot源码顶层目录下,进入arch/arm/dts,打开DK1公板设备树相关文件 ,vi stm32mp15xx-fsmp1x.dtsi,搜索i2c4关键字
228 /*
229 &i2c4 {
230 pinctrl-names = "default", "sleep";
231 pinctrl-0 = <&i2c4_pins_a>;
232 pinctrl-1 = <&i2c4_sleep_pins_a>;
233 i2c-scl-rising-time-ns = <185>;
234 i2c-scl-falling-time-ns = <20>;
235 clock-frequency = <400000>;
236 status = "okay";*/
......................................................
387 watchdog {
388 compatible = "st,stpmic1-wdt";
389 status = "disabled";
390 };
391 };
392 };
393 */
2.在uboot源码顶层目录下,进入arch/arm/dts,打开DK1公板设备树相关文件 ,vi stm32mp15xx-fsmp1x.dtsi,搜索cpu0和cpu1关键字
122 /*
123 &cpu0{
124 cpu-supply = <&vddcore>;
125 };
126
127 &cpu1{
128 cpu-supply = <&vddcore>;
129 };
130 */
3.在uboot源码顶层目录下,进入arch/arm/dts,打开DK1公板设备树相关文件vi stm32mp157a-fsmp1a-u-boot.dtsi,搜索cpu0和cpu1关键字
67 /*
68 &pmic {
69 u-boot,dm-pre-reloc;
70 };
71 */
4.在uboot源码顶层目录下,执行make menuconfig,去掉电源管理相关内容
Device Drivers --->
Power --->
[ ] Enable support for STMicroelectronics STPMIC1 PMIC ----->按电脑键盘空格键,将*去掉,不被编译
三、添加FSMP1A电源相关内容
1.在uboot源码顶层目录下,进入arch/arm/dts,打开DK1公板设备树相关文件 ,vi stm32mp15xx-fsmp1x.dtsi,搜索sound关键字
73 sound {
74 compatible = "audio-graph-card";
75 label = "STM32MP1-DK";
76 routing =
77 "Playback" , "MCLK",
78 "Capture" , "MCLK",
79 "MICL" , "Mic Bias";
80 dais = <&sai2a_port &sai2b_port &i2s2_port>;
81 status = "okay";
82 };
------------------填写到这个节点下面------------------
v3v3: regulator-3p3v {
compatible = "regulator-fixed";
regulator-name = "v3v3";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
regulator-boot-on;
};
v1v8_audio: regulator-v1v8-audio {
compatible = "regulator-fixed";
regulator-name = "v1v8_audio";
regulator-min-microvolt = <1800000>;
regulator-max-microvolt = <1800000>;
regulator-always-on;
regulator-boot-on;
};
v3v3_hdmi: regulator-v3v3-hdmi {
compatible = "regulator-fixed";
regulator-name = "v3v3_hdmi";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
regulator-boot-on;
};
v1v2_hdmi: regulator-v1v2-hdmi {
compatible = "regulator-fixed";
regulator-name = "v1v2_hdmi";
regulator-min-microvolt = <1200000>;
regulator-max-microvolt = <1200000>;
regulator-always-on;
regulator-boot-on;
};
vdd: regulator-vdd {
compatible = "regulator-fixed";
regulator-name = "vdd";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
regulator-boot-on;
};
vdd_usb: regulator-vdd-usb {
compatible = "regulator-fixed";
regulator-name = "vdd_usb";
regulator-min-microvolt = <3300000>;
regulator-max-microvolt = <3300000>;
regulator-always-on;
regulator-boot-on;
};
四、对uboot源码编译测试
1.进入uboot源码顶层目录下,对uboot源码进行编译
time make -j4 all
time:显示编译时间
-j4:开启4个线程进行编译
2.编译成功现象:
u-boot-spl.stm32
u-boot.img
3.将sdtools.sh拷贝到uboot源码顶层目录下,并且添加最高权限
4.将TF开插入到读卡器中,将读卡器插入到电脑中,并且被ubuntu识别,点击确定
5.在uboot源码顶层目录下执行:./sdtools.sh /dev/sdb,参考如下图片进行选择
6.首先将读卡器从ubuntu中断开,并将TF卡从读卡器中拔出
7.将TF卡插入到开发板中
8.将拨码开关拨到SD卡启动方式
9.观察现象
U-Boot SPL 2020.10 (Nov 03 2022 - 14:39:27 +0800)
Model: STMicroelectronics STM32MP157C eval daughter on eval mother
RAM: DDR3-DDR3L 32bits 533000Khz
DDR invalid size : 0x4, expected 0x40000000
DRAM init failed: -22
### ERROR ### Please RESET the board ###
#内存问题
#TF卡问题