码迷,mamicode.com
首页 > 其他好文 > 详细

zynq uboot 配置与编译

时间:2021-04-24 13:11:14      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:sso   dev   rom   roc   tps   class   setting   editing   eal   

本人采用的MicroPhase的Z7Lite板子,由于以太网控制器是定义在pl端的,所以寄存器地址什么的都不太一样。uboot要用petalinux生成,但是还是希望用源码就能编译,这样没有petalinux那么臃肿,而且编译速度快、配置灵活。我们可以考虑通过petalinux来生成源码与配置文件,从中挑选出重要内容,然后复制到uboot-xlnx源码目录里。以此来达到定制化配置uboot的效果,petalinux工程用一次就可以删掉了。

1 准备环境

准备好交叉编译环境、xilinx的uboot官方源码。

2 设备树配置

利用xilinxSDK来生成设备树,具体参考:https://www.cnblogs.com/schips/p/xilinx-sdk-make-dtb-with-sdk-using.html xilinxSDK可以根据hdf文件来生成设备树。

复制设备树中所有dtsi与dts到uboot源码目录的arch/arm/dts/下,并且在system-top.dts最后加上

&axi_ethernet_0{
    local-mac-address = [00 0a 35 00 03 22];
    phy-handle = <&phy1>;
    xlnx,has-mdio = <0x1>;
    phy-mode = "mii";

    mdio{
        #address-cells = <1>;
        #size-cells = <0>;
        phy1:phy@1{
            compatible = "realtek,rtl8201","ethernet-phy-id001c.c816";
            device_type = "ethernet-phy";
            reg = <0>;
        };
    };

};

3 defconfig文件

利用在ubuntu16下的petalinux来生成工程,参考链接。最后配置文件就在/build/tmp/work/zynq-xxx-xilinx-linux/u-boot-xlnx/xxxxxxx/build/.config,将.config文件拷贝到uboot源码目录的configs文件夹下,并且改名为zynq_zzqbd_defconfig。

需要更改的地方主要是这里 CONFIG_DEFAULT_DEVICE_TREE="system-top"

4 配置头文件

petalinux生成的uboot源码下面多了两个文件,可以观察一下zynq_zzqbd_defconfig中的CONFIG_SYS_CONFIG_NAME。如果这个文件不拷贝,那么还是无法成功的。分别是platform-auto.h和platform-top.h。

并且我们主要在platform-auto.h中来配置uboot的环境。将这两个文件拷贝到./include/configs/下。

platform-top.h:

#include <configs/platform-auto.h>
#define CONFIG_SYS_BOOTM_LEN 0xF000000
#define DFU_ALT_INFO_RAM                 "dfu_ram_info="         "setenv dfu_alt_info "         "image.ub ram $netstart 0x1e00000\0"         "dfu_ram=run dfu_ram_info && dfu 0 ram 0\0"         "thor_ram=run dfu_ram_info && thordown 0 ram 0\0"

#define DFU_ALT_INFO_MMC         "dfu_mmc_info="         "set dfu_alt_info "         "${kernel_image} fat 0 1\\\\;"         "dfu_mmc=run dfu_mmc_info && dfu 0 mmc 0\0"         "thor_mmc=run dfu_mmc_info && thordown 0 mmc 0\0"


/*Required for uartless designs */
#ifndef CONFIG_BAUDRATE
#define CONFIG_BAUDRATE 115200
#ifdef CONFIG_DEBUG_UART
#undef CONFIG_DEBUG_UART
#endif
#endif

/*Define CONFIG_ZYNQ_EEPROM here and its necessaries in u-boot menuconfig if you had EEPROM memory. */
#ifdef CONFIG_ZYNQ_EEPROM
#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN         1
#define CONFIG_SYS_I2C_EEPROM_ADDR             0x54
#define CONFIG_SYS_EEPROM_PAGE_WRITE_BITS      4
#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS  5
#define CONFIG_SYS_EEPROM_SIZE                 1024 /* Bytes */
#define CONFIG_SYS_I2C_MUX_ADDR                0x74
#define CONFIG_SYS_I2C_MUX_EEPROM_SEL          0x4
#endif

platform-auto.h

/*
 * This file is auto-generated by PetaLinux SDK 
 * DO NOT MODIFY this file, the modification will not persist
 */

#ifndef __PLNX_CONFIG_H
#define __PLNX_CONFIG_H

/* The following table includes the supported baudrates */


#define CONFIG_SYS_BAUDRATE_TABLE  { 300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400 }



/* processor - ps7_cortexa9_0 */
#define CONFIG_CPU_FREQ_HZ    666666687
#define CONFIG_CLOCKS
#define CONFIG_ARM_DCC
#define CONFIG_SYS_LDSCRIPT    "arch/arm/mach-zynq/u-boot.lds"

/* main_memory - ps7_ddr_0 */

/* uart - ps7_uart_0 */
#define PSSERIAL0    "psserial0=setenv stdout ttyPS0;setenv stdin ttyPS0\0"
#define SERIAL_MULTI    "serial=setenv stdout serial;setenv stdin serial\0"
#define CONSOLE_ARG    "console=console=ttyPS0,115200\0"
#define SERIAL_MULTI  "serial=setenv stdout serial;setenv stdin serial\0"
#define CONFIG_BAUDRATE    115200

/* ethernet - axi_ethernet_0 */
#define CONFIG_MII
#define CONFIG_NET_MULTI
#define CONFIG_NETCONSOLE    1
#define CONFIG_SERVERIP    192.168.5.129
#define CONFIG_IPADDR

/* sdio - ps7_sd_0 */
#define CONFIG_SUPPORT_VFAT
#define CONFIG_ZYNQ_SDHCI_MAX_FREQ  52000000

/* devcfg - ps7_dev_cfg_0 */
#define CONFIG_FPGA_ZYNQPL

/* ps7_scutimer_0 */
#define ZYNQ_SCUTIMER_BASEADDR    0xF8F00600
#define CONFIG_SYS_TIMER_COUNTS_DOWN
#define CONFIG_SYS_TIMERBASE    ZYNQ_SCUTIMER_BASEADDR
#define CONFIG_SYS_TIMER_COUNTER    (CONFIG_SYS_TIMERBASE + 0x4)

/* FPGA */

/* Memory testing handling */
#define CONFIG_SYS_MEMTEST_START    0x0
#define CONFIG_SYS_MEMTEST_END    (0x0 + 0x1000)
#define CONFIG_SYS_LOAD_ADDR    0x0 /* default load address */
#define CONFIG_NR_DRAM_BANKS    1

/* Size of malloc() pool */
#define SIZE    0xC00000
#define CONFIG_SYS_MALLOC_LEN    SIZE

/* Physical Memory Map */
#define CONFIG_SYS_INIT_RAM_ADDR    0xFFFF0000
#define CONFIG_SYS_INIT_RAM_SIZE    0x2000
#define CONFIG_SYS_INIT_SP_ADDR    (CONFIG_SYS_INIT_RAM_ADDR + \ 
                CONFIG_SYS_INIT_RAM_SIZE - \ 
                GENERATED_GBL_DATA_SIZE)

#ifdef CONFIG_DM_SPI_FLASH
# define CONFIG_SPI_GENERIC
# define CONFIG_SF_DEFAULT_SPEED    30000000
# define CONFIG_ENV_SPI_MAX_HZ        30000000
# define CONFIG_SF_DUAL_FLASH
# define CONFIG_CMD_SPI
# define CONFIG_CMD_SF
#endif



/* BOOTP options */
#define CONFIG_BOOTP_SERVERIP
#define CONFIG_BOOTP_BOOTFILESIZE
#define CONFIG_BOOTP_BOOTPATH
#define CONFIG_BOOTP_GATEWAY
#define CONFIG_BOOTP_HOSTNAME
#define CONFIG_BOOTP_MAY_FAIL
#define CONFIG_BOOTP_DNS
#define CONFIG_BOOTP_SUBNETMASK
#define CONFIG_BOOTP_PXE

/*Command line configuration.*/
#define CONFIG_CMDLINE_EDITING
#define CONFIG_AUTO_COMPLETE

#define CONFIG_IMAGE_FORMAT_LEGACY
#define CONFIG_SUPPORT_RAW_INITRD

/* Miscellaneous configurable options */
#define CONFIG_SYS_CBSIZE    2048/* Console I/O Buffer Size      */
#define CONFIG_SYS_PBSIZE    (CONFIG_SYS_CBSIZE + sizeof(CONFIG_SYS_PROMPT) + 16)
#define CONFIG_SYS_BARGSIZE CONFIG_SYS_CBSIZE

/* Use the HUSH parser */
#define CONFIG_SYS_PROMPT_HUSH_PS2 "> "

#define CONFIG_ENV_VARS_UBOOT_CONFIG
#define CONFIG_ENV_OVERWRITE    /* Allow to overwrite the u-boot environment variables */

#define CONFIG_LMB

/* FDT support */
#define CONFIG_DISPLAY_BOARDINFO_LATE


/* architecture dependent code */
#define CONFIG_SYS_HZ   1000

/* Boot Argument Buffer Size */
#define CONFIG_SYS_MAXARGS      32      /* max number of command args */
#define CONFIG_SYS_LONGHELP


#undef CONFIG_BOOTM_NETBSD

/* Initial memory map for Linux */
#define CONFIG_SYS_BOOTMAPSZ 0x08000000

/* Environment settings*/
#define CONFIG_ENV_SIZE    0x80000

/* PREBOOT */
#define CONFIG_PREBOOT    "echo U-BOOT for petalinux_boot_from_sd;setenv preboot; echo; dhcp"

/* Extra U-Boot Env settings */
#define CONFIG_EXTRA_ENV_SETTINGS     SERIAL_MULTI \ 
    CONSOLE_ARG \ 
    PSSERIAL0 \ 
    "nc=setenv stdout nc;setenv stdin nc;\0" \ 
    "ethaddr=00:0a:35:00:22:01\0"     "bootenv=uEnv.txt\0" \ 
    "importbootenv=echo \"Importing environment from SD ...\"; " \ 
        "env import -t ${loadbootenv_addr} $filesize\0" \ 
    "loadbootenv=load mmc $sdbootdev:$partid ${loadbootenv_addr} ${bootenv}\0" \ 
    "sd_uEnvtxt_existence_test=test -e mmc $sdbootdev:$partid /uEnv.txt\0" \ 
    "uenvboot=" \ 
        "if run sd_uEnvtxt_existence_test; then " \ 
            "run loadbootenv; " \ 
            "echo Loaded environment from ${bootenv}; " \ 
            "run importbootenv; " \ 
            "fi; " \ 
        "if test -n $uenvcmd; then " \ 
            "echo Running uenvcmd ...; " \ 
            "run uenvcmd; " \ 
        "fi\0" \ 
    "autoload=no\0" \ 
    "sdbootdev=0\0" \ 
    "clobstart=0x10000000\0" \ 
    "netstart=0x10000000\0" \ 
    "dtbnetstart=0x23fff000\0" \ 
    "loadaddr=0x10000000\0" \ 
    "boot_img=BOOT.BIN\0" \ 
    "load_boot=tftpboot ${clobstart} ${boot_img}\0" \ 
    "update_boot=setenv img boot; setenv psize ${bootsize}; setenv installcmd \"install_boot\"; run load_boot ${installcmd}; setenv img; setenv psize; setenv installcmd\0" \ 
    "install_boot=mmcinfo && fatwrite mmc ${sdbootdev} ${clobstart} ${boot_img} ${filesize}\0" \ 
    "install_bootenv=mmcinfo && fatwrite mmc ${sdbootdev} ${clobstart} ${bootenv_img} ${filesize}\0" \ 
    "kernel_img=image.ub\0" \ 
    "load_kernel=tftpboot ${clobstart} ${kernel_img}\0" \ 
    "update_kernel=setenv img kernel; setenv psize ${kernelsize}; setenv installcmd \"install_kernel\"; run load_kernel ${installcmd}; setenv img; setenv psize; setenv installcmd\0" \ 
    "install_kernel=mmcinfo && fatwrite mmc ${sdbootdev} ${clobstart} ${kernel_img} ${filesize}\0" \ 
    "cp_kernel2ram=mmcinfo && fatload mmc ${sdbootdev} ${netstart} ${kernel_img}\0" \ 
    "dtb_img=system.dtb\0" \ 
    "load_dtb=tftpboot ${clobstart} ${dtb_img}\0" \ 
    "update_dtb=setenv img dtb; setenv psize ${dtbsize}; setenv installcmd \"install_dtb\"; run load_dtb test_img; setenv img; setenv psize; setenv installcmd\0" \ 
    "sd_update_dtb=echo Updating dtb from SD; mmcinfo && fatload mmc ${sdbootdev}:1 ${clobstart} ${dtb_img} && run install_dtb\0" \ 
    "loadbootenv_addr=0x00100000\0" \ 
    "fault=echo ${img} image size is greater than allocated place - partition ${img} is NOT UPDATED\0" \ 
    "test_crc=if imi ${clobstart}; then run test_img; else echo ${img} Bad CRC - ${img} is NOT UPDATED; fi\0" \ 
    "test_img=setenv var \"if test ${filesize} -gt ${psize}\\; then run fault\\; else run ${installcmd}\\; fi\"; run var; setenv var\0" \ 
    "netboot=tftpboot ${netstart} ${kernel_img} && bootm\0" \ 
    "default_bootcmd=run uenvboot; run cp_kernel2ram && bootm ${netstart}\0" \ 
""

/* BOOTCOMMAND */
#define CONFIG_BOOTCOMMAND    "run default_bootcmd"

#endif /* __PLNX_CONFIG_H */

我们可以在 CONFIG_EXTRA_ENV_SETTINGS 中配置uboot环境变量

5 编译

make distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- zynq_zzqbd_defconfig
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi-

zynq uboot 配置与编译

标签:sso   dev   rom   roc   tps   class   setting   editing   eal   

原文地址:https://www.cnblogs.com/kidtic/p/14694168.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!