{"id":7068,"date":"2021-01-26T21:16:52","date_gmt":"2021-01-26T15:46:52","guid":{"rendered":"https:\/\/nuclearrambo.com\/wordpress\/?p=7068"},"modified":"2024-10-03T15:10:17","modified_gmt":"2024-10-03T09:40:17","slug":"running-petalinux-on-zynq-soc-from-scratch-zybo-board","status":"publish","type":"post","link":"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/","title":{"rendered":"Running Petalinux on Zynq SoC from scratch &#8211; Zybo board"},"content":{"rendered":"\n<p>In a couple of <a href=\"https:\/\/nuclearrambo.com\/wordpress\/tag\/zynq\/\">previous articles<\/a>, we went over a few very basic designs on the <a href=\"https:\/\/www.xilinx.com\/products\/silicon-devices\/soc\/zynq-7000.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Zynq SoC<\/a>. Those examples used no operating system. They were all what we call &#8220;bare metal&#8221;. Running bare metal has it&#8217;s advantages and disadvantages. For example, you can quickly build and test things by manipulating registers and various other things. When things start to complex and need to interact with each other, writing software on bare metal could become a bit cumbersome. Having a basic OS allows one to skip the mundane tasks and focus on the main thing you intend to accomplish. Those mundane tasks we talked about are offloaded to the operating system; Petalinux in this case. <\/p>\n\n\n\n<p>Zynq, a full-fledged ARM SoC has two parts to it. The processing system with dual core ARM Cortex A9 cores and programmable logic part. Similarly, a more recent SoC from Xilinx, <a href=\"https:\/\/www.xilinx.com\/products\/silicon-devices\/soc\/zynq-ultrascale-mpsoc.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Zynq Ultrascale+<\/a> comes with a higher number of processor cores and a much larger FPGA fabric. <\/p>\n\n\n\n<p>I will be building the Linux Operating system with the help of Xilinx&#8217;s Petalinux tool. This post will more likely focus on actually getting Linux to run your Zynq SoC with minimum amount of effort. For someone new to Zynq, should at least go through my previous Zynq articles. If possible, try them out before you jump into Linux. This is not something you can continue to build upon if you have no background on this. <\/p>\n\n\n\n<center><p><script type=\"text\/javascript\">\n\tatOptions = {\n\t\t'key' : 'a488f095e80c8a74746e5fdca977eaea',\n\t\t'format' : 'iframe',\n\t\t'height' : 90,\n\t\t'width' : 728,\n\t\t'params' : {}\n\t};\n\tdocument.write('<scr' + 'ipt type=\"text\/javascript\" src=\"http' + (location.protocol === 'https:' ? 's' : '') + ':\/\/www.profitabledisplaynetwork.com\/a488f095e80c8a74746e5fdca977eaea\/invoke.js\"><\/scr' + 'ipt>');\n<\/script><\/p><\/center>\n\n\n\n<h2 class=\"wp-block-heading\">Creating a base project in Vivado<\/h2>\n\n\n\n<p>Compared to my previous projects, I upgraded myself to Vitis 2020.2 and PetaLinux 2020.2. This tutorial can still be tried out on Vitis 2019.2 or older versions. The flow hasn&#8217;t changed much over past few years. Like I said earlier, you need to try out the <a href=\"https:\/\/nuclearrambo.com\/wordpress\/programming-the-zynq-7000-with-vivado-2019-2-and-vitis\/\">basic Zynq project<\/a> in my older article because I won&#8217;t be showing each little step. <\/p>\n\n\n\n<p>In Vivado, create a new project and open a new block design. Place the Zynq processing system block and run block automation. <\/p>\n\n\n\n<p>Next, you can simply continue to next part or spend some time adding logic blocks. In my case, I added a AXI GPIO block in the design. The AXI GPIO being connected to the 4 LEDs on my Zybo board will allow me to toggle some LEDs through Linux command line. Interesting right? <\/p>\n\n\n\n<p>So far, this is how my block design looks. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized is-style-default\"><a href=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/petalinux_bd-2.jpg\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"388\" src=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/petalinux_bd-2-1024x388.jpg\" alt=\"Petalinux with zynq\" class=\"wp-image-7075\" style=\"width:960px;height:363px\" srcset=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/petalinux_bd-2-1024x388.jpg 1024w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/petalinux_bd-2-300x114.jpg 300w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/petalinux_bd-2-768x291.jpg 768w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/petalinux_bd-2.jpg 1190w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Block design with Zynq PS and AXI GPIO block<\/figcaption><\/figure>\n\n\n\n<p>Since, Zybo comes with its own board files, I do not need to do any kind of pin mapping with the constraints file. In case you are doing this on a custom board, make sure to map your IO lines in the constraints file. One advantage of having board files is you don&#8217;t need to do any other settings in the PS block. For those on a custom board, make sure to enable UART, Ethernet, SD card and also set your clock frequency correctly. On the Zybo board, UART 1 is mapped out to the USB port which we will be using late. <\/p>\n\n\n\n<p>Build the design by clicking on &#8220;Generate bitstream&#8221; button. Once finished, export hardware with bitstream included. That will generate a .xsa file. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Let&#8217;s build linux<\/h2>\n\n\n\n<p>To proceed any further, you need to have <a href=\"https:\/\/www.instructables.com\/Getting-Started-With-PetaLinux\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Petalinux tools installed<\/a>. Installing it all will take a couple of hours depending on how fast is your system. With that out of the way, everything else becomes quite simple. <\/p>\n\n\n\n<p>Open your terminal and navigate into the project directory and run Petalinux settings script. You need to run this script every time you want to do something with the <a href=\"https:\/\/www.xilinx.com\/support\/download\/index.html\/content\/xilinx\/en\/downloadNav\/embedded-design-tools.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Petalinux tools<\/a>. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">source \/path\/to\/installation\/Xilinx2020.2\/PetaLinux\/2020.2\/bin\/settings.sh<\/pre>\n\n\n\n<p>In order to confirm whether the script did anything at all, type this command and in response you should get the path to the petalinux binary.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">echo $PETALINUX\n>\/home\/nuclearrambo\/Xilinx2020.2\/PetaLinux\/2020.2\/bin<\/pre>\n\n\n\n<p>Yes, that&#8217;s where my Xilinx installation resides. You may get a different path depending on where you install. <\/p>\n\n\n\n<p>Let&#8217;s ask Petalinux to read our .xsa file so that it can do some things based on it. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">petalinux-create -t project -n LinuxBoot --template zynq\ncd LinuxBoot\npetalinux-config --get-hw-description=..\/your.xsa<\/pre>\n\n\n\n<p>The first command creates a petalinux project using the &#8220;zynq&#8221; template and having a name &#8220;LinuxBoot&#8221;. This will create a folder with that name and you need to enter that folder to run the next commands. <\/p>\n\n\n\n<p>The configuration command will pop up a configuration window like below. <\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/peta_config_hw.png\"><img loading=\"lazy\" decoding=\"async\" width=\"776\" height=\"520\" src=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/peta_config_hw.png\" alt=\"petalinux reading hardware\" class=\"wp-image-7076\" srcset=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/peta_config_hw.png 776w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/peta_config_hw-300x201.png 300w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/peta_config_hw-768x515.png 768w\" sizes=\"auto, (max-width: 776px) 100vw, 776px\" \/><\/a><figcaption class=\"wp-element-caption\">Hardware configuration<\/figcaption><\/figure><\/div>\n\n\n<p>This is the first configuration dialog you will get in the process. It will allow you to do a variety of modifications to the base Linux system. If you haven&#8217;t noticed, Petalinux is all based on Yocto project. Our main purpose of this tutorial is to have a basic linux system running. Therefore, we won&#8217;t be diving into these settings at all.<\/p>\n\n\n\n<p>You can simply exit and that will save the necessary settings in the project workspace. May be, once your linux system runs fine, you could come back to this step and try to play with these settings. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configure u-boot<\/h3>\n\n\n\n<p>U-boot is a very commonly used second stage bootloader which loads the entire linux operating system. The first stage bootloader invokes u-boot after its finished executing and initializing the hardware. The First stage bootloader basically clears the ground of the grass and pokey things so that u-boot can lay down the red carpet for Linux. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">petalinux-config -c u-boot<\/pre>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/u-boot.png\"><img loading=\"lazy\" decoding=\"async\" width=\"487\" height=\"343\" src=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/u-boot.png\" alt=\"petalinux uboot configuration\" class=\"wp-image-7078\" srcset=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/u-boot.png 487w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/u-boot-300x211.png 300w\" sizes=\"auto, (max-width: 487px) 100vw, 487px\" \/><\/a><figcaption class=\"wp-element-caption\">U-boot config<\/figcaption><\/figure><\/div>\n\n\n<p>The wizard allows us to modify whole lot of low level bootloader settings. U-boot in itself has its own console and it will be quite interesting to write about one day. Right now, you can simply exit and proceed to next stage. We don&#8217;t really need to modify anything here. <\/p>\n\n\n\n<center><p><script type=\"text\/javascript\">\n\tatOptions = {\n\t\t'key' : 'a488f095e80c8a74746e5fdca977eaea',\n\t\t'format' : 'iframe',\n\t\t'height' : 90,\n\t\t'width' : 728,\n\t\t'params' : {}\n\t};\n\tdocument.write('<scr' + 'ipt type=\"text\/javascript\" src=\"http' + (location.protocol === 'https:' ? 's' : '') + ':\/\/www.profitabledisplaynetwork.com\/a488f095e80c8a74746e5fdca977eaea\/invoke.js\"><\/scr' + 'ipt>');\n<\/script><\/p><\/center>\n\n\n\n<h3 class=\"wp-block-heading\">Configure kernel<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">petalinux-config -c kernel<\/pre>\n\n\n\n<p>Running this command would allow yourself to play with the linux kernel configuration. Normally, for this project we need not change anything except one setting. <\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/kernel_config.png\"><img loading=\"lazy\" decoding=\"async\" width=\"489\" height=\"341\" src=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/kernel_config.png\" alt=\"petalinux kernel\" class=\"wp-image-7077\" srcset=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/kernel_config.png 489w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/kernel_config-300x209.png 300w\" sizes=\"auto, (max-width: 489px) 100vw, 489px\" \/><\/a><figcaption class=\"wp-element-caption\">Petalinux kernel<\/figcaption><\/figure><\/div>\n\n\n<p>Scroll down until you see &#8220;Library Routines&#8221;. Hit enter, and modify the &#8220;<em>Default contiguous memory area size<\/em>&#8221; and make it &#8220;256&#8221;. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configure the root file system<\/h3>\n\n\n\n<p>Finally, we need to configure the root file system by running the following command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">petalinux-config -c rootfs<\/pre>\n\n\n\n<p>This configuration wizard allows us to modify what goes inside our Linux operating system. For example, we can configure it to compile certain packages and basic tools like Python, SSH, Apache webserver and so on. You get the point, the usual Linux stuff. Remember, that Linux OS in itself is basically a scheduler and handles all sorts of things from protecting memory locations, running applications, interacting with external hardware and what not. Everything else is an added bonus. The less &#8220;bonus content&#8221; you ask for, the smaller its size gets. Bare linux OS can sit happily in a tiny area as small as a few mega bytes. Its the &#8220;bonus content&#8221; or rather the applications that cause a inflation in its size. <\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/rootfs_config.png\"><img loading=\"lazy\" decoding=\"async\" width=\"780\" height=\"519\" src=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/rootfs_config.png\" alt=\"petalinux rootfs configuration\" class=\"wp-image-7079\" srcset=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/rootfs_config.png 780w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/rootfs_config-300x200.png 300w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/rootfs_config-768x511.png 768w\" sizes=\"auto, (max-width: 780px) 100vw, 780px\" \/><\/a><figcaption class=\"wp-element-caption\">Configuring rootfs<\/figcaption><\/figure><\/div>\n\n\n<p>I will now tell you what basic things you need to activate to have a usable system. This is what I did.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Filesystem packages -&gt; admin -&gt; sudo<\/li>\n\n\n\n<li>Filesystem packages -&gt; devel -&gt; python<\/li>\n\n\n\n<li>Filesystem packages -&gt; console -&gt; network -&gt; wget<\/li>\n<\/ol>\n\n\n\n<p>I then proceeded further to save these settings and build the Linux system. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">petalinux-build<\/pre>\n\n\n\n<p>This will build the everything and spit out a few files that we need to package.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Packaging everything<\/h2>\n\n\n\n<p>The build process itself would take quite a while. Once you are done building, we need to package it all together with one last command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">petalinux-package --boot --force --fsbl images\/linux\/zynq_fsbl.elf --fpga images\/linux\/system.bit --u-boot<\/pre>\n\n\n\n<p>Like I said earlier, Linux needs a first stage bootloader and a second stage bootloader. It all needs to be combined together into one file. Additionally, you need to remember that we are working on a FPGA as well. We can&#8217;t forget that FPGA also needs to be programmed while we are doing all this. Hence, the system.bit file. The <em>petalinux-package <\/em>command combines the FSBL and the bit file into one BIN file called BOOT.bin. Additionally, image.ub contains uboot. Of course, that&#8217;s not all but you get the idea. There are several other things that go into these files; for example, the device tree.<\/p>\n\n\n\n<p>Finally, you will also find rootfs.tar.gz being generated in the <em>images\/linux <\/em>path. Lets find out what we do to it. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Preparing the SD card<\/h2>\n\n\n\n<p>Now that we are done compiling and building linux, we can finally put it to test. Before we do that, we need to prepare our SD card. <\/p>\n\n\n\n<p>Make two partitions on your SD card. The first partition needs to be of <em>FAT32 <\/em>file system with at least 500MB space. Whereas, the second partition needs to be of <em>EXT4 <\/em>file system. <\/p>\n\n\n\n<p>Extract the contents of <em>rootfs.tar.gz <\/em>into the <em>ext4 <\/em>partition using the following command. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">tar -xzvf rootfs.tar.gz -C \/media\/nuclearrambo\/root_partition\/\nsync<\/pre>\n\n\n\n<p>Furthermore, copy the following three files into the <em>FAT32 <\/em>partition;<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>BOOT.bin<\/li>\n\n\n\n<li>boot.scr<\/li>\n\n\n\n<li>image.ub<\/li>\n<\/ol>\n\n\n\n<p>That&#8217;s all! Insert the SD card into the board and power it up. On the Zybo board, you should see a bunch of text getting thrown over the UART. All this text comes from the various stages of linux booting process. Here is a small screenshot of the text.<\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/linux_boot.png\"><img loading=\"lazy\" decoding=\"async\" width=\"979\" height=\"913\" src=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/linux_boot.png\" alt=\"zynq petalinux boot up\" class=\"wp-image-7089\" srcset=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/linux_boot.png 979w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/linux_boot-300x280.png 300w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/linux_boot-768x716.png 768w\" sizes=\"auto, (max-width: 979px) 100vw, 979px\" \/><\/a><figcaption class=\"wp-element-caption\">Text output during linux boot process<\/figcaption><\/figure><\/div>\n\n\n<p>If everything goes well, you should have a login prompt appear. In that case, your login credentials are <em>root <\/em>and <em>root.<\/em><\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/login_prompt.png\"><img loading=\"lazy\" decoding=\"async\" width=\"513\" height=\"129\" src=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/login_prompt.png\" alt=\"zynq petalinux login prompt\" class=\"wp-image-7090\" srcset=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/login_prompt.png 513w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/login_prompt-300x75.png 300w\" sizes=\"auto, (max-width: 513px) 100vw, 513px\" \/><\/a><figcaption class=\"wp-element-caption\">Linux login prompt<\/figcaption><\/figure><\/div>\n\n\n<p>On the other hand, if you happen to have Ethernet on your board, you can plug in the cable. Usually, the router on your network will auto-assign an IP address to your Zynq board which can be spotted in boot up text.<\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/ethernet.png\"><img loading=\"lazy\" decoding=\"async\" width=\"475\" height=\"202\" src=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/ethernet.png\" alt=\"petalinux ethernet dhcp\" class=\"wp-image-7091\" srcset=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/ethernet.png 475w, https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/ethernet-300x128.png 300w\" sizes=\"auto, (max-width: 475px) 100vw, 475px\" \/><\/a><figcaption class=\"wp-element-caption\">DHCP assigns an IP address to our Zynq board<\/figcaption><\/figure><\/div>\n\n\n<p>Use this IP address to gain access of your board over SSH. Now, this means you can open your SSH port on your network and remotely connect to your Zynq Petalinux instance. It also means, that this board operates quite well over a network interface. Ideally, you should now be able to run any service on it like any other Linux system. <\/p>\n\n\n\n<center><p><script type=\"text\/javascript\">\n\tatOptions = {\n\t\t'key' : 'a488f095e80c8a74746e5fdca977eaea',\n\t\t'format' : 'iframe',\n\t\t'height' : 90,\n\t\t'width' : 728,\n\t\t'params' : {}\n\t};\n\tdocument.write('<scr' + 'ipt type=\"text\/javascript\" src=\"http' + (location.protocol === 'https:' ? 's' : '') + ':\/\/www.profitabledisplaynetwork.com\/a488f095e80c8a74746e5fdca977eaea\/invoke.js\"><\/scr' + 'ipt>');\n<\/script><\/p><\/center>\n\n\n\n<h2 class=\"wp-block-heading\">Trying out Python<\/h2>\n\n\n\n<p>Remember, I had enabled Python while configuring the <em>rootfs<\/em>. Time&#8217;s come to test our Python setup. Someone with basic idea about python needs no further explanation. For the sake of it, try out the following command.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"Try out python\" data-enlighter-group=\"\">python\n>>help(\"modules\")<\/pre>\n\n\n\n<p>The above command will help you list down all the available python packages. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Playing with the GPIOs<\/h2>\n\n\n\n<p>I hope you remember that we still got the GPIO block in place. We need to try using the GPIOs if they work at all. Now, you can find the address of the AXI GPIO in the Vivado address editor. Furthermore, it can also be found through command line in Petalinux. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">root@LinuxBoot:~# cat \/sys\/class\/gpio\/gpiochip1020\/label\n\/amba_pl\/gpio@41200000<\/pre>\n\n\n\n<p>There could be multiple GPIOs in your system, but you can always find the right one with the <em>label<\/em>. Since, we know that our GPIO block is connected over AXI bus which happens to be part of the AMBA bus standard; that makes it easy to identify the correct block. Additionally, you can also try the <em>ngpio <\/em>keyword instead of <em>label. <\/em>That will display the number of GPIO pins available on the particular block. That&#8217;s rather a crude way to do things but in this case, it should have no issue. <\/p>\n\n\n\n<p>The number after the <em>@<\/em> symbol is the address of the peripheral. You can always cross check this with the Vivado address listing. <\/p>\n\n\n\n<p>With the <em>devmem <\/em>command, we can directly write to the given memory mapped peripheral address. Correspondingly, the data register of the GPIO block has an offset of 0x00. Therefore, a direct write to the <em>0x41200000 <\/em>address should directly set\/reset the GPIOs. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">devmem 0x41200000 8 0xF<\/pre>\n\n\n\n<p>This command will write <em>&#8216;1&#8217; <\/em>to all the 4 GPIOs.<\/p>\n\n\n\n<p>Looking at the command, the 3<sup>rd<\/sup> parameter <em>&#8216;8&#8217;<\/em> stands for the data width. Here, we are only writing 8 bits of data because I know that I got only 4 GPIOs to work with. You could go all the way up to 32 bits.<\/p>\n\n\n\n<p> Physically, you should be able to see all four LEDs light up. Another way to verify whether the command worked would be to read back the data register.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">devmem 0x41200000 8\n>0x0F<\/pre>\n\n\n\n<p>The readback <em>0x0F <\/em>confirms that we have successfully written to the desired memory address. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Final words<\/h2>\n\n\n\n<p>I hope you found this short tutorial interesting. In one of the future articles, we will dive a little deeper into Petalinux and run some interesting application on it.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In a couple of previous articles, we went over a few very basic designs on the Zynq SoC. Those examples used no operating system. They were all what we call &#8220;bare metal&#8221;. Running bare&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":7078,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1212],"tags":[1771,1746,1770,1769,1768],"class_list":["post-7068","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-electronics-2","tag-embedded-systems","tag-fpga","tag-linux","tag-petalinux","tag-zynq-fpga"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Running Petalinux on Zynq SoC from scratch - Zybo board<\/title>\n<meta name=\"description\" content=\"Running Linux on the Zynq SoC opens up many possibilities to develop applications. Here I build petalinux and run it on my usual Zybo board\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Running Petalinux on Zynq SoC from scratch - Zybo board\" \/>\n<meta property=\"og:description\" content=\"Running Linux on the Zynq SoC opens up many possibilities to develop applications. Here I build petalinux and run it on my usual Zybo board\" \/>\n<meta property=\"og:url\" content=\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/\" \/>\n<meta property=\"og:site_name\" content=\"Nuclearrambo\" \/>\n<meta property=\"article:published_time\" content=\"2021-01-26T15:46:52+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-03T09:40:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/u-boot.png\" \/>\n\t<meta property=\"og:image:width\" content=\"487\" \/>\n\t<meta property=\"og:image:height\" content=\"343\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"nuclearrambo\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@darkusul\" \/>\n<meta name=\"twitter:site\" content=\"@darkusul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"nuclearrambo\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/\"},\"author\":{\"name\":\"nuclearrambo\",\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/#\/schema\/person\/6093ae9d048d4789bd3d18c136577a0c\"},\"headline\":\"Running Petalinux on Zynq SoC from scratch &#8211; Zybo board\",\"datePublished\":\"2021-01-26T15:46:52+00:00\",\"dateModified\":\"2024-10-03T09:40:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/\"},\"wordCount\":2021,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/#organization\"},\"keywords\":[\"embedded systems\",\"fpga\",\"linux\",\"petalinux\",\"zynq fpga\"],\"articleSection\":[\"Electronics\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/\",\"url\":\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/\",\"name\":\"Running Petalinux on Zynq SoC from scratch - Zybo board\",\"isPartOf\":{\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/#website\"},\"datePublished\":\"2021-01-26T15:46:52+00:00\",\"dateModified\":\"2024-10-03T09:40:17+00:00\",\"description\":\"Running Linux on the Zynq SoC opens up many possibilities to develop applications. Here I build petalinux and run it on my usual Zybo board\",\"breadcrumb\":{\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/nuclearrambo.com\/wordpress\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Running Petalinux on Zynq SoC from scratch &#8211; Zybo board\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/#website\",\"url\":\"https:\/\/nuclearrambo.com\/wordpress\/\",\"name\":\"Nuclearrambo\",\"description\":\"Information is FREE! Progress is MUST! Awakening is inevitable!\",\"publisher\":{\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/nuclearrambo.com\/wordpress\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/#organization\",\"name\":\"Nuclearrambo\",\"url\":\"https:\/\/nuclearrambo.com\/wordpress\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/logo-nuclearrambo.png\",\"contentUrl\":\"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/logo-nuclearrambo.png\",\"width\":1489,\"height\":1152,\"caption\":\"Nuclearrambo\"},\"image\":{\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/darkusul\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/#\/schema\/person\/6093ae9d048d4789bd3d18c136577a0c\",\"name\":\"nuclearrambo\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/nuclearrambo.com\/wordpress\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8a9d2d82dd7e65e77405f7b4ccaa34450e8a268f369ac893882cc5f13a797?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/9cc8a9d2d82dd7e65e77405f7b4ccaa34450e8a268f369ac893882cc5f13a797?s=96&r=g\",\"caption\":\"nuclearrambo\"},\"description\":\"Salil is an electronics enthusiast working on various electronics systems. In his free time he writes on the blog, talks over ham radio or builds circuits. He has Yaesu FT2900R VHF transceiver, FT450D HF transceiver, TYT UV8000E and Quansheng UVK6 Handheld transceivers.\",\"sameAs\":[\"http:\/\/nuclearrambo.com\/wordpress\"],\"url\":\"https:\/\/nuclearrambo.com\/wordpress\/author\/admin\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Running Petalinux on Zynq SoC from scratch - Zybo board","description":"Running Linux on the Zynq SoC opens up many possibilities to develop applications. Here I build petalinux and run it on my usual Zybo board","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/","og_locale":"en_US","og_type":"article","og_title":"Running Petalinux on Zynq SoC from scratch - Zybo board","og_description":"Running Linux on the Zynq SoC opens up many possibilities to develop applications. Here I build petalinux and run it on my usual Zybo board","og_url":"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/","og_site_name":"Nuclearrambo","article_published_time":"2021-01-26T15:46:52+00:00","article_modified_time":"2024-10-03T09:40:17+00:00","og_image":[{"width":487,"height":343,"url":"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/u-boot.png","type":"image\/png"}],"author":"nuclearrambo","twitter_card":"summary_large_image","twitter_creator":"@darkusul","twitter_site":"@darkusul","twitter_misc":{"Written by":"nuclearrambo","Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/#article","isPartOf":{"@id":"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/"},"author":{"name":"nuclearrambo","@id":"https:\/\/nuclearrambo.com\/wordpress\/#\/schema\/person\/6093ae9d048d4789bd3d18c136577a0c"},"headline":"Running Petalinux on Zynq SoC from scratch &#8211; Zybo board","datePublished":"2021-01-26T15:46:52+00:00","dateModified":"2024-10-03T09:40:17+00:00","mainEntityOfPage":{"@id":"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/"},"wordCount":2021,"commentCount":2,"publisher":{"@id":"https:\/\/nuclearrambo.com\/wordpress\/#organization"},"keywords":["embedded systems","fpga","linux","petalinux","zynq fpga"],"articleSection":["Electronics"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/","url":"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/","name":"Running Petalinux on Zynq SoC from scratch - Zybo board","isPartOf":{"@id":"https:\/\/nuclearrambo.com\/wordpress\/#website"},"datePublished":"2021-01-26T15:46:52+00:00","dateModified":"2024-10-03T09:40:17+00:00","description":"Running Linux on the Zynq SoC opens up many possibilities to develop applications. Here I build petalinux and run it on my usual Zybo board","breadcrumb":{"@id":"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/nuclearrambo.com\/wordpress\/running-petalinux-on-zynq-soc-from-scratch-zybo-board\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/nuclearrambo.com\/wordpress\/"},{"@type":"ListItem","position":2,"name":"Running Petalinux on Zynq SoC from scratch &#8211; Zybo board"}]},{"@type":"WebSite","@id":"https:\/\/nuclearrambo.com\/wordpress\/#website","url":"https:\/\/nuclearrambo.com\/wordpress\/","name":"Nuclearrambo","description":"Information is FREE! Progress is MUST! Awakening is inevitable!","publisher":{"@id":"https:\/\/nuclearrambo.com\/wordpress\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/nuclearrambo.com\/wordpress\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/nuclearrambo.com\/wordpress\/#organization","name":"Nuclearrambo","url":"https:\/\/nuclearrambo.com\/wordpress\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nuclearrambo.com\/wordpress\/#\/schema\/logo\/image\/","url":"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/logo-nuclearrambo.png","contentUrl":"https:\/\/nuclearrambo.com\/wordpress\/wp-content\/uploads\/2021\/01\/logo-nuclearrambo.png","width":1489,"height":1152,"caption":"Nuclearrambo"},"image":{"@id":"https:\/\/nuclearrambo.com\/wordpress\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/twitter.com\/darkusul"]},{"@type":"Person","@id":"https:\/\/nuclearrambo.com\/wordpress\/#\/schema\/person\/6093ae9d048d4789bd3d18c136577a0c","name":"nuclearrambo","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/nuclearrambo.com\/wordpress\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/9cc8a9d2d82dd7e65e77405f7b4ccaa34450e8a268f369ac893882cc5f13a797?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9cc8a9d2d82dd7e65e77405f7b4ccaa34450e8a268f369ac893882cc5f13a797?s=96&r=g","caption":"nuclearrambo"},"description":"Salil is an electronics enthusiast working on various electronics systems. In his free time he writes on the blog, talks over ham radio or builds circuits. He has Yaesu FT2900R VHF transceiver, FT450D HF transceiver, TYT UV8000E and Quansheng UVK6 Handheld transceivers.","sameAs":["http:\/\/nuclearrambo.com\/wordpress"],"url":"https:\/\/nuclearrambo.com\/wordpress\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/posts\/7068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/comments?post=7068"}],"version-history":[{"count":13,"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/posts\/7068\/revisions"}],"predecessor-version":[{"id":8415,"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/posts\/7068\/revisions\/8415"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/media\/7078"}],"wp:attachment":[{"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/media?parent=7068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/categories?post=7068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nuclearrambo.com\/wordpress\/wp-json\/wp\/v2\/tags?post=7068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}