原文档链接:https://github.com/OSCPU/NutShell

这篇文章暂时先用原文档的英文版,之后会编写一个中文版文档

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

  • New partitions

  • 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-Z2启动NutShell(果壳处理器)——整理补充原官方文档的更多相关文章

  1. Es官方文档整理-3.Doc Values和FieldData

    Es官方文档整理-3.Doc Values和FieldData 1.Doc Values 聚合使用一个叫Doc Values的数据结构.Doc Values使聚合更快.更高效且内存友好. Doc Va ...

  2. Es官方文档整理-2.分片内部原理

    Es官方文档整理-2.分片内部原理 1.集群      一个运行的Elasticsearch实例被称为一个节点,而集群是有一个或多个拥有相同claster.name配置的节点组成,他们共同承担数据和负 ...

  3. 微信小程序官方文档错误整理

    大致看了一遍微信小程序文档,发现有几处微小的错误,但瑕不掩瑜.记录下,以后发现了还会继续在此添加.如果有记录不对的,请及时指出错误. 1.视图层->WXSS->尺寸单位 明显错误,应该为 ...

  4. 国家密码标准-商密SM2官方文档整理

    SM2官方文档整理 算法原理 SM2算法介绍 我国自主知识产权的商业密码算法,是ECC(椭圆加密算法)的一种,基于椭圆曲线离散对数问题(公钥密码体制所依据的难题主要为大素数分解问题.离散对数问题.椭圆 ...

  5. [整理] FFmpeg官方文档树

    扫了一遍官方文档,整理张官文树. 当然还有很多细节,可以慢慢沿着树根填,有需要可以联系我要ProcessON源文件,我尽量给个最新的出来. 官文 : http://ffmpeg.org/documen ...

  6. 【原创】官方文档-hive 启动命令

    [一起学Hive]之十六-Hive的WEB页面接口-HWI Apache Hive 管网 hive metrics hive常用命令整理 Hive学习之HiveServer2服务端配置与启动 启动hi ...

  7. 关于 share 音乐分享官方文档补充

    例子 音乐分享 /*--------微信朋友圈--------*/ [shareParams SSDKSetupWeChatParamsByText:@"内容" title:@&q ...

  8. tomcat 5 启动过程官方文档

    http://tomcat.apache.org/tomcat-7.0-doc/architecture/startup/serverStartup.txt Licensed to the Apach ...

  9. openstack liberty 版本按照官方文档手动整合 完成后 基于dashboard-horizon 创建虚拟机报错 用CL却是成功的 网络等验证都是正确的通过启动的虚拟实例测试以成功

  10. 终端开发补充 : 读 curses模块官方文档...

    curses是一个提供终端屏幕打印和键盘处理的库, 我个人的理解就是终端里的gui(当然它是基于文本的)... 写2048的时候用到了这个库, 所以现在过来好好研究一下这个库... 下面是文档内容 : ...

随机推荐

  1. 效能时代,数栈专属DevOps跑出加速度

    ​ 一.浅析DevOps 互联网的发展形同潮水,来势汹汹.快而迅猛,企业业务日益庞大的同时伴随着团队规模的扩大,业务的复杂度与关联性显著提升的同时对效能也有了更高的要求,高效协同之间,我们既要追求快速 ...

  2. DotTrace系列:4. 诊断窗体程序变卡之原因分析

    一:背景 1. 讲故事 写这一篇是因为昨天看 dottrace 官方文档时,在评论区看到了一条不友好的评论,截图如下: 虽然语气上带有些许愤怒,但说实话人家也不是无中生有,作为 dottrace 的忠 ...

  3. Spring AI Alibaba 1.0 正式发布!核心特性速览+老项目升级指南

    随着 Spring AI 首个正式版本 1.0 的发布,国产之光 Spring AI Alibaba 也发布了 1.0 GA 正式版本,更新速度真的很快! 我对框架的更新真的是又爱又恨,爱的是功能更丰 ...

  4. 用 AI 制作超长视频,保姆级教程!

    大家好,我是程序员鱼皮.之前分享了 如何利用 AI 生成 ASMR 视频 和 动物奥运会视频,给大家推荐了 Google Flow 这个 AI 视频创作工具. Google Flow 可以直接使用最新 ...

  5. 关于 winform Dev 使用的总结

    treeList控件 1.去除树的头一行:属性–OptionsView–ShowColumns 设为fakse 2.去除树最左列的鼠标箭头列:属性–OptionsView–ShowIndicator设 ...

  6. 遇见linux端运行qt程序报错, Could not find the Qt platform plugin “xcb“ in ““ This application failed to st

    简介 .zshrc 里面进行设置 export QT_QPA_PLATFORM_PLUGIN_PATH=/mnt/hdd1/software/qt5_12_0/5.12.0/gcc_64/plugin ...

  7. 关于 var 目录磁盘空间不足的解决方案

    参考博客 博客

  8. iga 入门之 泛函

    简介 变分法理解 参考链接 https://zhuanlan.zhihu.com/p/41573146 核心摘要 这里把泛函和函数.算子的概念区别理解一下: 算子是一个函数到另一个函数的映射,它是从向 ...

  9. SciTech-BigDataAIML-Adam动量自适应的梯度快速收敛

    http://faculty.bicmr.pku.edu.cn/~wenzw/optbook/pages/stograd/Adam.html 版权声明 此页面为<最优化:建模.算法与理论> ...

  10. unity ui穿透点击

    unity ui穿透点击 using System.Collections; using System.Collections.Generic; using UnityEngine; using Un ...