首页 > 系统相关 >PYNQ-Z2启动NutShell(果壳处理器)——修正官方文档错误

PYNQ-Z2启动NutShell(果壳处理器)——修正官方文档错误

时间:2023-01-18 10:55:05浏览次数:71  
标签:pynq mnt dev NutShell Vivado build PYNQ Z2 board

Compile chisel code

这里是英文版,之后会编写一个中文


  • before start, git checkout release-21228

  • Install mill. Refer to the Manual section in this guide.

  • Run make verilog BOARD=pynq to generate verilog code. The output file is build/TopMain.v.

Run programs by simulation

You can either use our ready-to-run image for simulation or build image yourself.

To use ready-to run image (recommended) :

  • Run make emu to launch simulation. Default image is linux kernel.

Run on FPGA

Sub-directories Overview

fpga
├── board              # supported FPGA boards and files to build a Vivado project
├── boot               # PS boot flow of zynq and zynqmp
├── lib                # HDL sources shared by different boards
├── Makefile
├── Makefile.check
└── NutShell.tcl       # wrapper of NutShell core in the Vivado project

Build a Vivado project

  • Install Vivado 2019.1, and source the setting of Vivado and SDK
  • Run the following command to build a Vivado project
cd fpga
make PRJ=myproject BOARD=pynq STANDALONE=true

Change pynq to the target board you want. Supported boards are listed under board/. The project will be created under board/pynq/build/myproject-pynq. Please note that STANDALONE mode is only used in pynq board.

  • Open the project with Vivado and generate bitstream.

  • To generate bitstream with vivado 2022.2, please add (* ram_style = "registers" *) before array tlbmd_0 tlbmd_2 tlbmd_3 in EmbeddedTLBMDmodule.See here for more details.

    (* ram_style = "registers" *) 
      reg [120:0] tlbmd_0 [0:0];
    

prepare SD card

Stand-Alone Mode

In stand-alone mode, control is directly transferred to PL (Program Logic) through FSBL (First Stage BootLoader) after the board is powered on, so that PL has access to on-board peripherals such as SD card, Ethernet, etc., which is necessary to boot Debian and other OS.

We use PYNQ-Z2 board as example to demonstrate how to prepare SD card in stand-alone mode.

Build BOOT.BIN

BOOT.bin is the default filename of packaged hardware-related binary files. Here is a pre-built and currently-used BOOT.BIN.

You can also build it yourself. Please refer to the following process.

  • create a project in Vivado and generate bitstream

    cd $(NUTSHELL_HOME)/fpga
    make PRJ=myprj BOARD=pynq STANDALONE=true vivado
    
  • generate hardware description file in Vivado

    Vivado -> File -> Export -> Export Hardware
    
  • do bootgen initially

    cd $(NUTSHELL_HOME)/fpga
    make bootgen PRJ=myprj BOARD=pynq STANDALONE=true
    # this will report some error messages
    

    If you want to do bootgen with Vivado 22.2 please install Vitis first.

  • create project-related links

    cd $(NUTSHELL_HOME)/fpga/boot/build/zynq
    ln -sf $(NUTSHELL_HOME)/fpga/board/pynq/build/myprj-pynq/myprj-pynq.sdk/system_top_wrapper.hdf ps.hdf
    ln -sf $(NUTSHELL_HOME)/fpga/board/pynq/build/myprj-pynq/myprj-pynq.runs/impl_1/system_top_wrapper.bit fpga.bit
    # modify FSBL_LOC in $(NUTSHELL_HOME)/fpga/resource/fsbl-loader/Makefile like this:
    # FSBL_LOC = ../../boot/build/myprj-pynq/fsbl
    
  • generate BOOT.BIN

    cd $(NUTSHELL_HOME)/fpga
    make bootgen PRJ=myprj BOARD=pynq STANDALONE=true
    

Build RV_BOOT.bin

RV_BOOT.bin is the default filename of linux-kernel image. Here is a pre-built and currently-used image. You can also build it yourself by riscv-pk and riscv-linux (currently not avaliable to the public).

Build rootfs in SD card

Save the contents before the SD card in case of loss

mount -t vfat /dev/mmcblk0p1 /mnt
mkdir sd_card_save
cp /mnt/* sd_card_save
umount /mnt
  1. Prepare
//umount the SD card
umount /dev/sdb*
  1. Partition
# creat two partitions in SD card
sudo fdisk /dev/sdb
  • Delete the partition before execute the steps

image

  • New partitions

image

  • Or use sudo cfdisk /dev/sdb to create partition
  1. Format
mkfs.vfat /dev/sdb1
mkfs -t ext4 /dev/sdb2

if you see the following error report after executing mkfs -t ext4 /dev/sdb2 , you can change partition type by using sudo cfdisk /dev/sdb , see here for more details.

mkfs.ext4: inode_size (128) * inodes_count (0) too big for a
        filesystem with 0 blocks, specify higher inode_ratio (-i)
        or lower inode count (-N).
  1. mount
mount -t ext4 /dev/sdb2 /mnt
mkdir /mnt/boot
mount -t vfat /dev/sdb1 /mnt/boot
  1. copy

copy the files which has been generated before into /dev/sdb1

  • BOOT.BIN
  • RV_BOOT.BIN
  1. download the debian base system to sdb2 with qemu-debootstrap , and enter the command below.
sudo su
qemu-debootstrap --arch riscv64 unstable /mnt http://deb.debian.org/debian-ports
chroot /mnt /bin/bash
passwd
apt-get update
apt-get install net-tools openssh-server vim build-essential minicom tmux libreadline-dev
exit
  1. Add a line of ttyPS0 in /mnt/etc/securetty to allow login debian via ttyPS0. See here for more details.

  2. Add a line of PermitRootLogin yes in /mnt/etc/ssh/sshd_config to enable root login via ssh. See here for more details.

  3. Add the following lines to /mnt/etc/fstab

# <file system> <mount point> <type>  <options> <dump>  <pass>
proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults 0 2
/dev/mmcblk0p2 / ext4 errors=remount-ro 0 1

标签:pynq,mnt,dev,NutShell,Vivado,build,PYNQ,Z2,board
From: https://www.cnblogs.com/GrootStudy/p/17059382.html

相关文章

  • bzip2 C/C++ 库bzlib.h使用案例:读取.bz2文件
    准备从网上下载bzip2库,我下载的是V1.0.8版本的。然后在C工程中添加一个筛选器(文件夹)名叫bzlib,然后把下载的库中的如下9个文件,添加到其中:代码主函数代码如下:#include......
  • jz2440存储管理实验【学习笔记】
    平台:jz2440作者:庄泽彬(欢迎转载,请注明作者)说明:韦东山一期视频学习笔记简介:先来简单的说明一下这次的实验,看看下图,我们的程序通过烧录器下载到nandflash当中去,之后在启动......
  • linux下tar.gz、tar、bz2、zip等解压缩、压缩命令小结
    本文介绍了linux下的压缩程式tar、gzip、gunzip、bzip2、bunzip2、compress、uncompress、zip、unzip、rar、unrar等程式,以及如何使用它们对.tar、.gz、.tar.gz、.tgz、......
  • NTMFS4C810NAT3G场效应管30V NCH,DEC1515H-D0-I/Z2集成电路TQFP
    产品参数1、型号:DEC1515H-D0-I/Z2封装:TQFP128批次:新年份2、型号:NTMFS4C810NAT3GFET类型:N通道技术:MOSFET(金属氧化物)漏源电压(Vdss):30V25°C时电流-连续漏极(Id):8.2A(Ta......
  • GRYZ20221020解题报告
    期望得分:\(100+100+0=200\pts\)实际得分:$70+100+0=170\pts$题目很傻逼当然我也很傻逼。因为赛前吸了LB的rp导致T1挂分(T1线段树签到题。开始以为仨操作是......
  • 如何解压.bz2文件包
    课程内容:各种k8s部署方式。包括minikube部署,kubeadm部署,kubeasz部署,rancher部署,k3s部署。包括开发测试环境部署k8s,和生产环境部署k8s。腾讯课堂连接地址https://ke.qq.com/c......
  • 3W SMA稳压二极管SMA3Z3.3A-SMA3Z200A
    常用稳压二极管功耗有1W、1.5W、2W、3W、5W,其中功耗为3W的稳压管有:3EZ5.6D5-3EZ200D5、SMA3EZ5.6D5-SMA3EZ200D5、SMB3EZ5.6D5-SMB3EZ200D5、SMA3Z3.3A-SMA3Z200A、SMB3Z3.3......
  • linux驱动移植-linux块设备驱动z2ram
    linux内核将块设备相关的驱动放在drivers/block路径下:root@zhengyang:/work/sambashare/linux-5.2.8#lsdrivers/block/amiflop.cbuilt-in.aloop.cnbd.c......
  • Linux Kernel in a Nutshell - 7
    CustomizingaKernel原文链接我的博客以·问题·做关键字搜索,还有问题构建你自己的Linux内核版本最困难的部分,应该就是确定哪一个驱动以及配置选项是你的设备需要的......
  • Linux Kernel in a Nutshell - 8
    KernelConfigurationRecipes原文链接我的博客前面介绍了重新配置内核的机制,本章介绍制作自己的内核通常会遇到的那些问题,并给出对应指令来处理它。DisksLinux内核......