zybo的linux开发教程,嵌入式Linux教程 - Zybo (下)

接上文

Step 20: U-Boot Source Code

FMSNUM3HWCJH7PJ.MEDIUM.jpg

FG7JICQHWCJH7PK.MEDIUM.jpg

F8E1R4XHWCJH7PP.LARGE.jpgFD5FHTDHWCJH7PR.LARGE.jpg

*Note: Use the Master-Next Branches until further notice

Get the source code for U-Boot from the Digilent git repository. There are two ways to retrieve the source code:

Using git command:

If you have git installed in your distribution, you can clone the repository to your computer by command git clone https://github.com/Digilent/u-boot-Digilent-Dev.g...The whole Git Repository is around 55MB, as shown in image 1. If you want to get a separate branch, for example the next branch follow image 2. The next contains the u-boot that is not yet released. The clone url referenced above can be found on the Digilent git-hub page as seen in image 3.

Download a compressed package:

If you only want to use u-boot once and do not want to track the updates, you can also download a compressed package from github.com:https://github.com/Digilent/u-boot-digilent.Go to the drop down box that shows the branch and select tags. The most recent tag is zynq-beta-v2.2. (image 4).

If you downloaded the tar.gz, you can decompress it using command

tar zxvf u-boot-digilent-2012.04-digilent-13.01.tar.gz

If you downloaded the zip file, you can decompress it using command

unzip u-boot-digilent-2012.04-digilent-13.01.zip

Step 21: Compile U-Boot

FH3KM59HWCJH7PS.MEDIUM.jpg

To compile U-Boot, we need cross-compile tools which are provided by Vivado 2014.1. Those tools have a prefix arm-xilinx-linux-gnueabi- to the standard names for the GCC tool chain. The prefix references the platforms that are used. The Zybo board has two arm cores so we reference arm. In order to use the cross-platform compilers, please make sure Vivado 2014.1 settings have been sourced. If not, please refer to step 2. To configure and build U-Boot for Zybo, follow the image attached to this step.

Step 22: U-boot.elf

FCTFLENHWCJH7PT.MEDIUM.jpg

After the compilation,

the ELF (Executable and Linkable File) generated is named u-boot. We need to add a .elf extension to the file name so that Xilinx SDK can read the file layout and generate BOOT.BIN. In this tutorial, we are going to move the u-boot.elf to sd_image folder and substitute the u-boot.elf that comes along with Zybo Base System Design Package.

Step 23: Export Hardware for SDK

FQPKHI6HWCJH7PW.MEDIUM.jpg

FJT6IO4HWCJH7PX.MEDIUM.jpg

Export the hardware design (after step I-16) to Xilinx SDK by clicking on File -> Export -> Export Hardware for SDK…, as shown in the first image.

Leave the workspace as . Make sure that Launch SDK is checked and click OK, as shown in the second image.

Note: You may have to export twice.

Step 24: New Project

FHW0AOPHWCJH7PY.MEDIUM.jpg

FRM9AF3HWCJH7Q0.MEDIUM.jpg

After SDK launches, the hardware platform project is already present in Project Explorer on the left of the SDK main window, as shown in image 1. We now need to create a First Stage Bootloader (FSBL). Click File->New->Project…, as shown in image 2.

Step 25: Application Project

FZJVCQAHWCJH7Q3.MEDIUM.jpg

In the New Project window, select Xilinx->Application Project, and then Click Next.

Step 26: Name the Project FSBL

F22DKL3HWCJH7Q4.MEDIUM.jpg

We will name the project FSBL. Select hw_platform_0 for Target Hardware because it is the hardware project we just exported. Select standalone for OS Platform. Click Next.

Step 27: Create Zynq FSBL Template

FHROLOWHWCJH7Q5.MEDIUM.jpg

Select Zynq FSBL as template, and click Finish.

Step 28: FSBL Hook

FDBEGXOHWCJH7Q9.MEDIUM.jpg

For the Zybo, we need set the mac address for the Ethernet in the fsbl hook. We want the mac address for the Ethernet to remain constant when we turn off and on the Zybo Board. You can swap the fsbl_hooks.c file in the FSBL project with the fsbl_hooks.c under source/vivado/SDK/fsbl in the Zybo Base System Design.

After you have saved the changes to fsbl_hooks.c,

the project will rebuild itself automatically. If it does not rebuild, Click Project->Clean to clean the project files, and Project->Build All to rebuild all the projects. The compiled ELF file is located in zybo_base_system/source/vivado/hw/zybo_bsd.sdk/SDK/SDK_Export/FSBL/Debug

Step 29: Create Boot Image

FSX9YYMHWCJH7QC.MEDIUM.jpg

Now, we have all the files ready to create BOOT.BIN. Click Xilinx Tools -> Create Zynq Boot Image.

Step 30: Add FSBL, system.bit and u-boot.elf

FZLEL4JHWCJH7QD.MEDIUM.jpg

In the Create Zynq Boot Image window, Click Browse to set the path for FSBL elf. Click Add to add the system.bit file found at /zybo_base_system/source/vivado/hw/zybo_bsd/zybo_bsd.sdk/SDK/SDK_Export/hw_platform_0/.Click Add to add the u-boot.elf file found at zybo_base_system/sd_image/. It is very important that the 3 files are added in this order, or else the FSBL will not work properly. It is also very important that you set FSBL.elf as the bootloader and system.bit and u-boot.elf as data files. In this tutorial, the sd_image folder is set as output folder for the BIN file. Click Create Image.

Step 31: Linux Kernel Source Code

FF3BUYRHWCJH7QF.MEDIUM.jpg

FWLLQ21HWCJH7QG.MEDIUM.jpg

*Note: Use the Master-Next Branches until further notice

Get the Linux kernel source code from Digilent git repository. There are two ways to retrieve the source code:

Using git command: If you have git installed in your distribution, you can clone the repository to your computer by command git clonehttps://github.com/DigilentInc/Linux-Digilent-Dev... The whole Git Repository is around 850MB, as shown in image 1.

Download a compressed package: If you only want to use u-boot once and do not want to track the updates, you can also download a compressed package from github.com: https://github.com/DigilentInc/Linux-Digilent-Dev. Click Tags on the top right corner of the page.The most recent tag is zynq-dt-for-3.14 (image 2).

If you downloaded the tar.gz, you can decompress it using command

tar zxvf linux-digilent-v3.6-digilent-13.01.tar.gz

If you downloaded the zip file, you can decompress it using command

unzip linux-digilent-v3.6-digilent-13.01.zip

Step 32: Configure the Kernel

FNQBTBNHWCJH7QH.MEDIUM.jpg

We will start to configure the kernel with the default configuration for Zybo. The configuration is located at arch/arm/configs/xylinx_zynq_defconfig. To use the default configuration follow the image attached to this step.

Step 33: Compile the Linux Kernel

F7KOL1OHWCJH7QJ.MEDIUM.jpg

Follow the example in the image.

Step 34: Make Uimage

FHK6S12HWCJH7QK.MEDIUM.jpg

After the compilation, the kernel image is located at arch/arm/boot/zImage. However in this case the kernel image has to be a uimage (unzipped) rather than a zimage. To make the uimage follow the image in this step.

Step 35: Optional Path change

FHS8N7FHWCJH7QL.MEDIUM.jpg

Note: Depending on your distribution of linux you may get an error regarding the path of the mkimage. If this is the case you can change the path following the image in this step.

Step 36: Make Uramdisk

FA4GK1OHWCJH7QM.MEDIUM.jpg

To boot the Linux Operating System on the Zybo, you need BOOT.BIN, a Linux kernel image (uImage), a device tree blob (DTB file), and a file system. BOOT.BIN has been created in Section III and uImage has been compiled in Section IV. We will now compile the DTB file. The default device tree source file is located in the Linux Kernel source at arch/arm/boot/dts/zynq-zybo.dts.

RAMDISK: For zynq only the ramdisk image has to be wrapped in a u-boot header in order for u-boot to boot with it. This is shown in the image in this step.

Step 37: Generate DTB file

FI1LCFBHWCJH7QN.MEDIUM.jpg

Follow the example provided in the image.

Step 38: Copy File Image to SD Card

F0B9B4CHWCJH7QP.MEDIUM.jpg

FRA4OOSHWCJH7QS.MEDIUM.jpg

RAMDISK) Copy BOOT.BIN, devicetree.dtb, uImage and uramdisk.image.gz to the first partition of an SD card, as shown in the first image – RamDisk.

NOTE: The first partition of the SD card is mounted to /media/ZYBO_BOOT

Step 39: Boot from SD Card

F9UICU2HWCJH7QV.MEDIUM.jpg

Plug the SD Card into the Zybo. To boot from SD card, jumper 7 needs to be configured for USB as shown on the Zybo Board and Jumper 5 must be connected to SD. Connect UART port to PC with micro USB cable and set the UART terminal on PC to 115200 baud rate, 8 data bits, 1 stop bit, no parity, and no flow control. After powering on the board, the console should be seen at the UART terminal if you use RamDisk. More information about this file system can be found in Getting Started with Embedded Linux ZedBoard.

Step 40: Create a Drivers Directory

FZC5RRVHWCJH7QX.MEDIUM.jpg

Create a directory named drivers in the Tutorial folder, as shown the image in this step. Inside the drivers directory, we will compose the driver for the myLed controller.

Step 41: Create the Makefile

F80BQV2HWCJH7R1.MEDIUM.jpg

F8J2AA8HWCJH7R2.MEDIUM.jpg

We need a Makefile so that we can compile the driver. The Makefile is created in image 1.

After creating the file, hit I to change to insert mode and insert the following text in image 2. Make sure you use tab characters where appropriate.

Step 42: Create myled.c

FLU514QHWCJH7R5.MEDIUM.jpg

We will start with a simple driver that creates a file named myled under the Linux /proc file system. The status of the on-board LEDs can be changed by writing a number to the file. The driver is coded in the last four images and is attached

Step 43: Compile Driver

FAGHH1QHWCJH7RG.MEDIUM.jpg

Compile and generate the driver module using make. Don’t forget to source Vivado settings.

Step 44: Add myled to the Device Tree

FZVMYL4HWCJH7RH.MEDIUM.jpg

F6S1X1AHWCJH7RI.MEDIUM.jpgFR8WRRQHWCJH7RJ.MEDIUM.jpg

We need to add the myLed device node into the device tree.

Make a copy of the default device tree source in the drivers folder, and modify it according to the second image. The compatibility string of the node is the same as we define in the driver source code (myled.c: line 182). The reg property defines the physical address and size of the node. The address here should match with the address of the myLed IP core in the address editor tab of the Vivado design, as shown in the last image.

Step 45: Recompile Device Tree Blob

FTAQLRCHWCJH7RM.MEDIUM.jpg

Recompile the device tree blob as shown in the attached image.

Step 46: Copy Driver and Modified Device Tree to SD card

FABDGBLHWCJH7RP.MEDIUM.jpg

Copy these two files to the first partition of the SD card, as shown in the image in this step. We are ready to test our driver on-board now.

Step 47: Boot From SD Card

FB1FL06HX1W5R28.MEDIUM.jpg

Plug the SD card into the Zybo, and we can start testing our driver. Use the insmod command to install the driver module into the kernel. After the driver is installed, an entry named myled will be created under the /proc file system. Writing 0x0F to /proc/myled will light up LED 0~3. You can either remove the driver with command rmmod or power off the system by command poweroff. In both case, all the LEDs will be turned off, as shown in Figure 69 and 70. For instructions on using the terminal with the Zybo. please refer to Step V-4 or Section Boot from SD in Getting Started with Embedded Linux – ZedBoard.

Step 48: User Application: led_blink

FY4LYNNHWCJH7RS.MEDIUM.jpg

FXFR770HWCJH7RV.MEDIUM.jpgFB6FTXTHWCJH7RW.MEDIUM.jpg

In this section, we will write a user application that makes the LEDs

blink by writing to /proc/myled. Create a directory named user_app in the Tutorial folder, as shown in the first image. Inside the user_app directory, we will compose the led_blink.c, as shown in the second and third image.

Step 49: Create Makefile and Compile led_blink

F2FJ0XKHWCJH7RZ.MEDIUM.jpg

FCARFIWHWCJH7S1.MEDIUM.jpgFXNEC0ZHWCJH7S2.MEDIUM.jpg

Compose a Makefile and compile led_blink.c into led_blink.o, as shown in the three images in this step.

Step 50:

FDYHWTMHWCJH7S3.MEDIUM.jpg

Insert the SD card into the computer, and copy the binary file led_blink onto the first partition of SD card.

Step 51: Run led_blink

FZ2I3N7HWCJH7S4.MEDIUM.jpg

Plug the SD card into the ZYBO. Use the insmod command to install the driver module into the kernel. Run led_blink and the LED will start blinking.

Step 52: Feedback!

Just a reminder, this is a draft. There will be an official copy that will be released onDigilentinc.com.

I appreciate any feedback to make the official copy stronger.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Zybo开发板介绍: ZYBO (Zynq Board) 是一款基于 Z-7010 而构建的功能丰富入门级嵌入式即用型软件和数字电路开发平台。 具有板上存储器、视频与音频 I/O、双模 USB、以太网和 SD 插槽等丰富配置,无需添加任何硬件即可使您的设计运行就绪。此外,还提供五个 Pmod 连接器,便于对任何设计进行升级。 ZYBO 可用于设计各种复杂程度的系统,例如运行多个服务器串联应用的完整操作系统,或者用来控制 LED 的简单裸机程序。如需要操作系统,Digilent 可提供一种专门在 ZYBO 上运行的现成的 Linux 解决方案,以及相关技术文档,用于介绍如何对其进行最佳调节以适应您的目的要求。Xilinx 工具和 Linux 解决方案都无需附加费用即可与 ZYBO 搭配使用。 关键特性: 128Mb 串行 Flash w/ QSPI 接口 16 位每像素 VGA 端口 1G Ethernet, USB 2.0, SDIO 512MB x32 DDR3 w/ 1066Mbps 带宽 667Mhz 双核Cortex-A9处理器 带耳机输出孔、麦克风和线路插口的音频编解码器 带 8 DMA 通道的 DDR3 内存控制器 五个 Pmod 连接器(1 个处理器专用,1 个双路模拟/数字) GPIO:6 个按钮,4 个滑动开关,5 个 LED 低带宽外设控制器: SPI, UART, CAN, I2C MicroSD slot (支持 Linux 文件系统) 板上 JTAG 编程和 UART 至 USB 转换器 三态 (1Gbit/100Mbit/10Mbit) Ethernet PH 目标应用: 嵌入式开发 嵌入式处理 高级 Digilent 设计 Zybo原理图截图:

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值