xilinx zynq boot 使用tfpt加載uboot+固化到flash+使用JTAG 模式 U-boot 添加python支持


 

Booting 使用tftp模式加載 linux鏡像

前置准備:

已經安裝vivado 啟動SDK工具,打開了Ethernet控制

已經有petalinux生成的Boot.bin,zynq_fsbl.elf,image.ub

使用SDK燒寫Boot.bin,zynq_fsbl.el

在電腦端配置tftp32的server綁定IP到192.168.1.104

啟動板子進入ZynpMP提示符,

輸入以下命令:

setenv serverip 192.168.1.104
setenv ipaddr 192.168.1.101
tftpboot 0x30000000 image.ub
bootm 0x30000000

 

 

 

Booting 使用tftp模式加載 linux鏡像並且固化到flash中

仍然使用tftp加載image.ub到內存,然后使用sf操作flash,將內存中的image.ub固化到flash指定位置:

setenv serverip 192.168.1.105
setenv ipaddr 192.168.1.101
tftpboot 0x30000000 image.ub
#copy image.ub到內存0x30000000
setenv kernelsize 0x2000000
sf probe 0 0 0
sf erase ${kernelstart} ${kernelsize}
#把flash中的${kernelstart}~${kernelsize}大小的內容擦除
sf write 0x30000000 ${kernelstart} ${kernelsize}
#把DDR內存中0x30000000開始的${kernelsize}的內容寫到flash ${kernelstart}開始的后面的空間去。

從flash運行image.ub

run cp_kernel2ram && bootm ${netstart}
# cp_kernel2ram 可以print 打印cp_kernel2ram內容,copy ${kernelstart}到DDR內存地址0x10000000

 

 

添加python支持

petalinux-config -c rootfs

#->Filesystem Packages->misc->python->python3

Booting 使用JTAG 模式加載 linux鏡像

前置准備:

已經安裝vivado 啟動SDK工具

已經有petalinux生成的u-boot.elf,zynq_fsbl.elf,image.ub

下載bitstream

1.如果有FPGA程序,使用 SDK自帶的Xilinx Tools → Program FPGA 點擊program;沒有則直接跳過該步驟。

2.打開Xilinx System Debugger (XSCT)SDK自帶的調試工具Xilinx Tools → XSCT Console.

3.在XSCT命令提示下,做如下操作

xsct% 
xsct% connect
tcfchan#1
xsct% targets
  1  PS TAP
     2  PMU
     3  PL
  4  PSU
     5  RPU
        6  Cortex-R5 #0 (Halted)
        7  Cortex-R5 #1 (Lock Step Mode)
     8  APU
        9  Cortex-A53 #0 (Running)
       10  Cortex-A53 #1 (Power On Reset)
xsct% ta 9

xsct% dow "C:/Users/changry/Desktop/zynqmp_fsbl.elf"

Downloading Program -- C:/Users/changry/Desktop/zynqmp_fsbl.elf
    section, .text: 0xfffc0000 - 0xfffcd91f
    section, .init: 0xfffcd940 - 0xfffcd973
    section, .fini: 0xfffcd980 - 0xfffcd9b3
    section, .note.gnu.build-id: 0xfffcd9b4 - 0xfffcd9d7
    section, .rodata: 0xfffcda00 - 0xfffce417
    section, .sys_cfg_data: 0xfffce440 - 0xfffcec77
    section, .mmu_tbl0: 0xfffcf000 - 0xfffcf00f
    section, .mmu_tbl1: 0xfffd0000 - 0xfffd1fff
    section, .mmu_tbl2: 0xfffd2000 - 0xfffd5fff
    section, .data: 0xfffd6000 - 0xfffd7377
    section, .sbss: 0xfffd7378 - 0xfffd737f
    section, .bss: 0xfffd7380 - 0xfffddb7f
    section, .heap: 0xfffddb80 - 0xfffddf7f
    section, .stack: 0xfffddf80 - 0xfffdff7f
    section, .dup_data: 0xfffdff80 - 0xfffe12f7
    section, .handoff_params: 0xfffe9e00 - 0xfffe9e87
    section, .bitstream_buffer: 0xffff0040 - 0xfffffc3f

  0%    0MB   0.0MB/s  ??:?? ETA
100%    0MB   0.4MB/s  00:00    

Setting PC to Program Start Address 0xfffc0000
Successfully downloaded C:/Users/changry/Desktop/zynqmp_fsbl.elf
xsct% con
xsct% dow "C:/Users/changry/Desktop/u-boot.elf"
 
xsct% dow -data "C:/Users/changry/Desktop/image.ub" 0x30000000

之后在串口界面執行

ZynqMP> bootm 0x30000000

 

 可以看到進入了linux的提示命令行

 

 

U-Boot 命令

在U-Boot提示符下可以訪問U-Boot命令列表。鍵入“幫助”或“?”有關可用命令的完整列表。下面給出一個例子:

?       - alias for 'help'
base    - print or set address offset
bdinfo  - print Board Info structure
boot    - boot default, i.e., run 'bootcmd'
bootd   - boot default, i.e., run 'bootcmd'
bootm   - boot application image from memory
bootp   - boot image via network using BOOTP/TFTP protocol
cmp     - memory compare
coninfo - print console devices and information
cp      - memory copy
crc32   - checksum calculation
date    - get/set/reset date && time
echo    - echo args to console
editenv - edit environment variable
erase   - erase FLASH memory
ext2load- load binary file from a Ext2 filesystem
ext2ls  - list files in a directory (default /)
fatinfo - print information about filesystem
fatload - load binary file from a dos filesystem
fatls   - list files in a directory (default /)
fdt     - flattened device tree utility commands
flinfo  - print FLASH memory information
go      - start application at address 'addr'
help    - print command description/usage
iminfo  - print header information for application image
imls    - list all images found in flash
imxtract- extract a part of a multi-image
itest   - return true/false on integer compare
loadb   - load binary file over serial line (kermit mode)
loads   - load S-Record file over serial line
loady   - load binary file over serial line (ymodem mode)
loop    - infinite loop on address range
md      - memory display
mm      - memory modify (auto-incrementing address)
mmc     - MMC sub system
mmcinfo - display MMC info
mtest   - simple RAM read/write test
mw      - memory write (fill)
nfs     - boot image via network using NFS protocol
nm      - memory modify (constant address)
ping    - send ICMP ECHO_REQUEST to network host
printenv- print environment variables
protect - enable or disable FLASH write protection
rarpboot- boot image via network using RARP/TFTP protocol
reset   - Perform RESET of the CPU
run     - run commands in an environment variable
setenv  - set environment variables
sf      - SPI flash sub-system
sleep   - delay execution for some time
source  - run script from memory
sspi    - SPI utility commands
tftpboot- boot image via network using TFTP protocol
version - print monitor version

 

燒寫QSPI Flash

U-Boot提供SF命令來對串行閃存設備進行編程。在所有通過u-boot進行的Xilinx平台上,您都可以使用SF命令對QSPI設備進行編程。這是將圖像文件加載到QSPI設備的示例。

uboot> sf
Usage:
sf probe [[bus:]cs] [hz] [mode] - init flash device on given SPI bus and chip select
sf read addr offset len         - read 'len' bytes starting at 'offset' to memory at 'addr'
sf write addr offset len        - write 'len' bytes from memory at 'addr' to flash at 'offset'
sf erase offset [+]len          - erase 'len' bytes from 'offset'; '+len' round up 'len' to block size
sf update addr offset len       - erase and write 'len'bytes from memory at 'addr' to flash at 'offset
  
uboot> sf probe 0 0 0
SF: Detected N25Q128 with page size 256, total 16 MiB
16384 KiB N25Q128 at 0:0 is now current device

引導應用程序映像

U-Boot提供了bootm命令來引導應用程序映像(即Linux),該映像希望這些映像可以使用mkimage用U-Boot特定的標頭包裝。該命令可用於引導舊的U-Boot映像或新的多組件映像(FIT),如U-Boot中所述。

標准的Linux構建過程將構建包裝器uImage,而Petalinux項目默認也會生成多組件FIT圖像。

以下U-Boot命令說明了使用bootm命令使用單個映像和FIT映像從SD卡加載Linux映像。

 

u-boot> fatload mmc 0 0x3000000 uImage
u-boot> fatload mmc 0 0x2A00000 devicetree.dtb
u-boot> fatload mmc 0 0x2000000 uramdisk.image.gz
u-boot> bootm 0x3000000 0x2000000 0x2A00000
u-boot> fatload mmc 0 0x1000000 image.ub
u-boot> bootm 0x1000000

使用bootm命令,U-Boot會在引導Linux之前重新定位映像,以使上面的地址可能不是內核看到的地址。

U-Boot還會更改設備樹,以告知內核ramdisk映像在內存中的位置(initrd-start和initrd-end)。bootm命令將r2寄存器設置為內存中設備樹的地址,而go命令無法完成該操作。

使用booti命令和bootm命令的差異和用例也不斷發展。

從U-Boot 2020.01開始,主要區別在於處理U-Boot幫助中所述的未壓縮Linux映像文件(在64位Arm平台上常見)與壓縮Linux zImage文件(在32位Arm平台上常見)。通常,僅根據Linux映像類型來區分用法,

不是僅基於體系結構來區分。booti-從內存中啟動Linux內核“映像”格式。bootm-從內存啟動應用程序映像

booti和bootm的完整幫助分別詳細說明了用法上的差異。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM