获得u-boot源码
我直接使用git clone来获取
新建一个用于存放u-boot的目录 git clone 然后就开始下载了。
这破网,有点醉人
这个速度,下到下班也下不完,还好,我有之前下好的zip文件,这里就不下了,浪费时间。
sudo unzip u-boot-xlnx-master.zip
解压成功,进入到uboot源码。
source /opt/Xilinx/SDK/2015.4/settings64.sh 这里执行这一步是为了使用SDK中的交叉编译工具。
arm-xilinx-linux-gnueabi-gcc -v 查看版本号,如果可以正常显示,那么就可以用,如果不能正常显示,还可能需要手动添加环境变量,相当于是当source /opt/Xilinx/SDK/2015.4/settings64.sh这条指令没有生效时,可以export PATH=/opt/Xilinx/SDK/2015.4/gnu/arm/lin/bin:$PATH.那么设置都已完成,先试一下编译是否可以通过。
make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- zynq_picozed_defconfig
配置成功,开始编译
make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi-
报错,提示dtc没有找到,dtc是devcie tree compiler
sudo apt-get install device-tree-compiler然后再重新编译就可以了。
编译成功,然而这并没有什么用,为什么呢,让我细细道来。因为这个版本的uboot和新版本的内核一样,驱动的加载使用的是devcie tree,我们进到相关目录打开picozed的来看看。
先看zynq_piczed_defconfig 在configs目录下面。
进入到u-boot-xlnx-master/arch/arm/dts打开zynq-picozed.dts
/*
* Avnet PicoZed board DTS
*
* Copyright (C) 2015 Xilinx, Inc.
*
* SPDX-License-Identifier: GPL-2.0+
*/
/dts-v1/;
#include "zynq-7000.dtsi"
/ {
model = "Zynq PicoZed Board";
compatible = "xlnx,zynq-picozed", "xlnx,zynq-7000";
aliases {
serial0 = &uart1;
};
memory {
device_type = "memory";
reg = <0 0x40000000>;
};
};
&uart1 {
u-boot,dm-pre-reloc;
status = "okay";
};
从上面看,就初始了DDR还有一个串口,这明显没什么用嘛。怎么办,机智如我,直接从其他地方借一些东西来用用。来看看zed board的
/*
* Xilinx ZED board DTS
*
* Copyright (C) 2011 - 2015 Xilinx
* Copyright (C) 2012 National Instruments Corp.
*
* SPDX-License-Identifier: GPL-2.0+
*/
/dts-v1/;
#include "zynq-7000.dtsi"
/ {
model = "Zynq Zed Development Board";
compatible = "xlnx,zynq-zed", "xlnx,zynq-7000";
aliases {
ethernet0 = &gem0;
serial0 = &uart1;
spi0 = &qspi;
mmc0 = &sdhci0;
};
memory {
device_type = "memory";
reg = <0x0 0x20000000>;
};
chosen {
bootargs = ""; //这里的也可以从另一个地方传递进来,这里面的是从include/configs/zynq-common.h里面传的。所以我们这里先不管,当然也可以设置从这里传进去参数。
stdout-path = "serial0:115200n8";
};
usb_phy0: phy0 {
compatible = "usb-nop-xceiv";
#phy-cells = <0>;
};
};
&clkc {
ps-clk-frequency = <33333333>;
};
&gem0 {
status = "okay";
phy-mode = "rgmii-id";
phy-handle = <ðernet_phy>;
ethernet_phy: ethernet-phy@0 {
reg = <0>;
};
};
&qspi {
u-boot,dm-pre-reloc;
status = "okay";
is-dual = <0>;
num-cs = <1>;
flash@0 {
compatible = "n25q128a11";
reg = <0x0>;
spi-tx-bus-width = <1>;
spi-rx-bus-width = <4>;
spi-max-frequency = <50000000>;
#address-cells = <1>;
#size-cells = <1>;
partition@qspi-fsbl-uboot {
label = "qspi-fsbl-uboot";
reg = <0x0 0x100000>;
};
partition@qspi-linux {
label = "qspi-linux";
reg = <0x100000 0x500000>;
};
partition@qspi-device-tree {
label = "qspi-device-tree";
reg = <0x600000 0x20000>;
};
partition@qspi-rootfs {
label = "qspi-rootfs";
reg = <0x620000 0x5E0000>;
};
partition@qspi-bitstream {
label = "qspi-bitstream";
reg = <0xC00000 0x400000>;
};
};
};
&sdhci0 {
u-boot,dm-pre-reloc;
status = "okay";
};
&uart1 {
u-boot,dm-pre-reloc;
status = "okay";
};
&usb0 {
status = "okay";
dr_mode = "host";
usb-phy = <&usb_phy0>;
};
参考这个来改就是了
/*
* Avnet PicoZed board DTS
*
* Copyright (C) 2015 Xilinx, Inc.
*
* SPDX-License-Identifier: GPL-2.0+
*/
/dts-v1/;
#include "zynq-7000.dtsi"
/ {
model = "Zynq PicoZed Board";
compatible = "xlnx,zynq-picozed", "xlnx,zynq-7000";
aliases {
serial0 = &uart1;
};
memory {
device_type = "memory";
reg = <0 0x40000000>;
};
chosen {
bootargs = "";
stdout-path = "serial0:115200n8";
};
usb_phy0: phy0 {
compatible = "usb-nop-xceiv";
#phy-cells = <0>;
};
};
&clkc {
ps-clk-frequency = <33333333>;
};
&gem0 {
status = "okay";
phy-mode = "rgmii-id";
phy-handle = <ðernet_phy>;
ethernet_phy: ethernet-phy@0 {
reg = <0>;
};
};
&qspi {
u-boot,dm-pre-reloc;
status = "okay";
is-dual = <0>;
num-cs = <1>;
flash@0 {
compatible = "n25q128a11";
reg = <0x0>;
spi-tx-bus-width = <1>;
spi-rx-bus-width = <4>;
spi-max-frequency = <50000000>;
#address-cells = <1>;
#size-cells = <1>;
partition@qspi-fsbl-uboot {
label = "qspi-fsbl-uboot";
reg = <0x0 0x100000>;
};
partition@qspi-linux {
label = "qspi-linux";
reg = <0x100000 0x500000>;
};
partition@qspi-device-tree {
label = "qspi-device-tree";
reg = <0x600000 0x20000>;
};
partition@qspi-rootfs {
label = "qspi-rootfs";
reg = <0x620000 0x5E0000>;
};
partition@qspi-bitstream {
label = "qspi-bitstream";
reg = <0xC00000 0x400000>;
};
};
};
&sdhci0 {
u-boot,dm-pre-reloc;
status = "okay";
};
&uart1 {
u-boot,dm-pre-reloc;
status = "okay";
};
&usb0 {
status = "okay";
dr_mode = "host";
usb-phy = <&usb_phy0>;
};
保存,然后重新编译。
make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- distclean
make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- zynq_picozed_defconfig
make ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi-
这样就可以生成了,我们要的是elf格式的u-boot就是生成的u-boot没有后缀的,至此,u-boot生成完毕。