element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
FPGA
  • Technologies
  • More
FPGA
Blog Minized PYNQ using EMMC
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join FPGA to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: bartokon
  • Date Created: 8 Aug 2020 5:26 PM Date Created
  • Views 1995 views
  • Likes 1 like
  • Comments 3 comments
  • emmc
  • pynq
  • minized
Related
Recommended

Minized PYNQ using EMMC

bartokon
bartokon
8 Aug 2020

Hello!

 

Here goes my third tutorial on Minized and PYNQ using EMMC memory image

This project will prepare your Minized to work with PYNQ and give you some insight how to modify existing projects to suit your needs.

 

Edit: added how to use Vitis HLS with PYNQ for acceleration.

 

 

 

Story

 

 

This tutorial shows how to create PYNQ for Minized, that uses EMMC memory with extra storage option as PMOD sdcard.

 

 

 

Preparing environment

First we will need to clone repositories from Avnet GitHub with these scripts we will build our project and BSP.

mkdir Avnet;
cd Avnet;
git clone https://github.com/Avnet/bdf.git --branch master;
git clone https://github.com/Avnet/hdl.git --branch 2019.1;
git clone https://github.com/Avnet/petalinux.git --branch 2019.1;
git clone https://github.com/Xilinx/PYNQ.git --branch image_v2.5.4;
wget http://downloads.element14.com/downloads/zedboard/minized/minized_ttc_2019_1.bsp.zip?ICID=minized-datasheet-widget;
unzip minized_ttc_2019_1.bsp.zip?ICID=minized-datasheet-widget;

Go to petalinux → scripts and edit "make_minized_qspi_minimal_bsp.sh"

cd petalinux/scripts;
gedit make_minized_qspi_minimal_bsp.sh;

Change Vivado and Petalinux installation paths

image

 

Run script and wait until it is finished.

./make_minized_qspi_minimal_bsp.sh

In meantime, we will create project based on "minized_ttc_2019.1.bsp"

Open new terminal and source petalinux settings.sh

source /home/bartek/petalinux20191/settings.sh

and create project

petalinux-create -t project -s minized_ttc_2019_1.bsp

Open newly created project.

cd minized_ttc_2019_1

Inside you can see "hardware" folder that contain hardware design used to build that BSP.

We will need to modify device tree used for this project, or else Petalinux won't build with FPGA manager turned on.

Go to project-spec → meta-user → recipes-bsp → device-tree → files and edit "system-user.dtsi"

cd project-spec/meta-user/recipes-bsp/device-tree;
gedit system-user.dtsi

We can safely remove nodes that reference to Wi-Fi module and accelerometer.

I have tried before and reprogramming FPGA will cause Wi-Fi driver to crash, that why I'm removing it, also if you leave accelerometer nodes petalinux build will fail.

/include/ "system-conf.dtsi"
/ {

     aliases {
          serial0 = &uart1;
          serial1 = &uart0;
     };
     
};

&flash0 {
     compatible = "micron,n25q128", "jedec,spi-nor";
};

/{
     usb_phy0: usb_phy@0 {
          compatible = "ulpi-phy";
          #phy-cells = <0>;
          reg = <0xe0002000 0x1000>;
          view-port = <0x0170>;
          drv-vbus;
     };
};

&usb0 {
     dr_mode = "otg";
     usb-phy = <&usb_phy0>;
} ;

/* QSPI addresses are defined with petalinux-config, but here they are overwritten so that one can program the flash internally */
&qspi {
     #address-cells = <1>;
     #size-cells = <0>;
     flash0: flash@0 {
          compatible = "micron,m25p80";
          reg = <0x0>;
          #address-cells = <1>;
          #size-cells = <1>;
          spi-max-frequency = <50000000>;
          partition@0x00000000 {
               label = "boot";
               reg = <0x00000000 0x00ff0000>;
          };
     };
};

/* PMOD SD Interface */
&sdhci0 {
     status = "okay";
     bus-width= <4>;
     xlnx,has-cd = <0x0>;
     xlnx,has-power = <0x0>;
     xlnx,has-wp = <0x0>;
     /* cd-inverted; */
     wp-inverted;

     mmccardpmod: mmccardpmod@1 {
          /* reg = <0>; */
          compatible = "mmc-card";
     };
};

/* SD Interface for eMMC */
&sdhci1 {
     status = "okay";
     non-removeable;
     bus-width= <4>;
     xlnx,has-cd = <0x0>;
     xlnx,has-power = <0x0>;
     xlnx,has-wp = <0x0>;

     mmccard: mmccard@0 {
          reg = <0>;
          compatible = "mmc-card";
          broken-hpi;
     };
};

/* Console UART.  UART1 is tied to the USB serial port on the Zedboard */
&uart1 {
        status = "okay";
     current-speed = <115200>;
     port-number = <0>;
};

/ {

};

 

 

 

PYNQ setup

Open PYNQ → sdbuild → scripts and run "setup_host.sh" script (if you didn't before).

cd PYNQ/sdbuild/scripts;
bash setup_host.sh

Now we will need to modify boot settings for PYNQ.

Open PYNQ → sdbuild → boot → meta-pynq → recipes-bsp → device-tree and edit "pynq_bootargs.dtsi"

cd PYNQ/sdbuild/boot/meta-pynq/recipes-bsp/device-tree;
gedit pynq_bootargs.dtsi

Change "/dev/mmcblk0p2" to "/dev/mmcblk1p2"

 

image

 

Also, you will need prebuilt rootfs image for arm architecture. See PYNQ quick porting guide.

 

image

 

Download it.

Go to PYNQ → sdbuild and type:

make BOARDS=Pynq-Z1

To see if PYNQ is set up properly.

 

 

 

Modifying Minized minimal

The script we ran at start for Minized QSPI should be finished by now.

Open petalinux → project → minized_qspi_minimal_2019_1 and add utility packages to format memory (optional).

cd petalinux/projects/minized_qspi_minimal_2019_1;
petalinux-config -c rootfs

Enable "e2fsprogs", "e2fsprogs-resize2fs", "e2fsprogs-e2fsck" packages.

You can search for packages using "/" in petalinux window.

 

image

 

Exit and rebuild project

petalinux-build

Now we will boot our system via JTAG.

petalinux-boot --jtag --fpga --kernel --verbose;

Login to Minized for example using cutecom or putty.

 

 

 

Format EMMC

Now we will format EMMC. (optional, later we can use "dd" to write image to EMMC)

Use "df -h" command to list all mounted drives and their location

df -h

 

image

 

or "fdisk -l"

fdisk -l

EMMC is "/dev/mmcblk1"

We need to create two partitions. One for "image.ub" and second for "rootfs"

First partition needs to be FAT32 and second partition ext4.

Open mmcblk1.

fdisk /dev/mmcblk1

Delete partitions using fdisk and write changes.

d
1
d
2
w

Now we need to create new partitions (you can use "format_emmc.sh" script as reference it is located in local/bin).

fdisk /dev/mmcblk1
o
n
p
1
enter (default command)
+255M
w

Now we have first partition with for example 255Mb.

fdisk /dev/mmcblk1
n
p
2
enter (default command)
enter (default command)
w

 

 

 

 

 

 

 

Partitions and types

 

 

 

1 / 2 • Partitions and types

Make first partition w95 fat32

fdisk /dev/mmcblk1
t
1
b
w

or use mkfs to format mmblk1p1 to fat32

mkfs.vfat -F 32 -n boot /dev/mmcblk1p1

Format mmblk1p2 to ext4

mkfs.ext4 -L root /dev/mmcblk1p2

Now you EMMC is ready as storage medium.

 

 

 

Creating base project

Open hdl → Projects → minized_petalinux →MINIZED_2019_1

 

image

 

Open block design and remove unused IP's (You could connect SD card mgr to SDIO_0 port for extra storage).

 

you can connect sdio0 wp and cd ports to constant "0" and add "non-removable" to device tree if you wish.

 

you can connect sdio0 wp and cd ports to constant "0" and add "non-removable" to device tree if you wish.

Generate new bistream and export HDF from project.

 

image

 

 

 

 

Creating PYNQ image

Go to minized_ttc_2019_1 project and change referenced HDF and image packaging configuration.

cd minized_ttc_2019_1;
petalinux-config --get-hw-description=/home/bartek/Desktop/Minized_EMMC/Avnet;

 

image

 

Build project and package new BSP.

petalinux-build;
petalinux-package --bsp --p ${PWD} --hwsource /home/bartek/Desktop/Minized_EMMC/Avnet/hdl/Projects/minized_petalinux/MINIZED_2019_1 -o MinizedEMMCPynq;

Copy created BSP to PYNQ → sdbuild with previously downloaded "bionic.arm.2.5.img"

 

image

 

And create PYNQ image

cd PYNQ/sdbuild;
bash scripts/image_from_prebuilt.sh MinizedEMMCPynq MinizedEMMCPynq.bsp arm bionic.arm.2.5.img;
It is better to create custom image for Minized. We will need to apply some modifications to PYNQ board project. (Ready package is in attachments MinizedPynq.7z) extract it somewhere for example in "PYNQ/zz" <- this is our board repository.

 

image

 

I have modified petalinux_bsp → meta-user → ... → user_2018-06-26-17-14-00.cfg

and enabled kernel drivers for some USB Wi-Fi modules.

You can do this via "petalinux-config -c kernel" before packaging BSP.

cd PYNQ/sdbuild;
make PREBUILT=/home/bartek/PYNQ/sdbuild/bionic.arm.2.5.img BOARDDIR=/home/bartek/PYNQ/zz BOARD=Minizedzik

If it doesn't work try adding PYNQ_SDIST:

make PYNQ_SDIST=/home/bartek/Downloads/pynq-2.5.tar.gz PREBUILT=/home/bartek/PYNQ/sdbuild/bionic.arm.2.5.img BOARDDIR=/home/bartek/PYNQ/zz BOARD=Minizedzik

Minized image should be in output folder.

Restore disk image on USB drive.

 

image

 

And resize partition2 to less than size of EMMC minus partition1 size for example 7Gb and check for errors.

 

image

 

Connect USB drive to Minized.

Write image to EMMC using "dd" command (this will take a while).

dd if=/dev/sda of=/dev/mmcblk1

And if you wish check for errors.

e2fsck /dev/mmcblk1p1
e2fsck /dev/mmcblk1p2

Program Minized with "minized_ttc_2019_1" BOOT.bin

petalinux-build;
petalinux-package --boot --fpga --u-boot -o BOOT.bin --force;
program_flash -f ./BOOT.bin -offset 0 -flash_type qspi_single -fsbl ./images/linux/zynq_fsbl.elf;

Minized will use QSPI memory to load BOOT.bin.

ZYNQ will use that BOOT.bin to load FSBL that programs FPGA for Minized, then it will load u-boot that will search for image.ub on "/dev/mmcblk1p1" partition. Image.ub will wait until "/dev/mmcblk1p2" is mounted and load rootfs.

Now Minized should boot with PYNQ system.

 

-bash warrning because I forgot about increasing size of rootfs :)

 

-bash warrning because I forgot about increasing size of rootfs image

 

After properly resizing

 

After properly resizing

Now let's mount pmod sdcard and write something to test functionality.

 

image

 

mkdir mnt;
ls -l /dev | grep mmc;
sudo mount /dev/mmcblk0p2 mnt;

Open mnt folder and create.txt file.

cd mnt;
sudo nano TestWrite.txt;

Exit and save, umount sdcard.

cd ..;
sudo umount mnt;

Let's check what is on sdcard.

 

image

 

 

image

 

 

 

 

Creating overlays

I have upgraded this project for 2020.1 version of Vivado.

Open Vitis HLS and create new empty project for xc7z007 chip.

Click sources → new file

 

 

image

 

Create addition IP-core

 

image

 

Go to project settings → Synthesis and in "Top Function" type "add"

 

image

 

Click ok and run synthesis.

Export our IP to local IP-repository.

 

image

 

Extract "add.zip"

Open Vivado and add new IP to the project and connect it to AXI interconnect.

 

image

 

 

image

 

Save project and export bitstream.

Open Vivado project and search for bistream and .hwh file.

 

 

image

 

 

image

 

Copy and rename these files.

 

image

 

 

Upload them to Minized, but first we will need Wi-Fi.

Start Minized and connect to it for example with putty.

 

 

image

 

As you can see Minized detected our wireless adapter

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

 

 

image

 

sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -B
sudo dhclient wlan0

 

image

 

Open internet browser and connect to Minized (password is xilinx)

 http://192.168.0.105:9090/tree?

Upload files via jupyter notebook.

 

image

 

 

"It just works!"

 

"It just works!"

 

 

 

The End

Now you are ready to develop your own IOT applications based on these three projects.

Get your Minized to work and share your work image

BSP

MinizedPynqPackage

 

https://hacksterio.s3.amazonaws.com/uploads/attachments/1175292/minizedpynq_C1VkgDnOGO.7z

  • Sign in to reply

Top Comments

  • narrucmot
    narrucmot over 4 years ago in reply to bartokon +1
    Hi Bartosz, To create the project on hackster.io, and then copy/paste it to Element14 seems a bit redundant. I think it is probably best to create the project on hackster.io and then share the hackster…
  • bartokon
    bartokon over 4 years ago in reply to narrucmot

    Hi Tom,

     

    Randall Scasny messaged me that it's better to repost the whole blog on element14, so he could promote it and I thought that there is an easy way to move the project between element14 and hackster as both platform are from Avnet.

     

    Thanks for info image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • narrucmot
    narrucmot over 4 years ago in reply to bartokon

    Hi Bartosz,

     

    To create the project on hackster.io, and then copy/paste it  to Element14 seems a bit redundant.  I think it is probably best to create the project on hackster.io and then share the hackster.io link to the project here on Element14.  Sound good?  That is what Avnet does with some other projects.

     

    Cheers,

    Tom

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • bartokon
    bartokon over 4 years ago

    Hey!

     

    I have a quick question, is there a better way to upload hackster project to element14? Right now I'm just copying the whole project with "ctrl+c" and paste it here.

     

    Thanks image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube