EPeak Daily

An FPGA Tackle the Raspberry Pi: PetaLinux on the ZynqBerry

0 10

As I’ve talked about prior to now, I’ve a mushy spot for well-marketed growth boards (let’s be trustworthy, I hoard dev boards generally) so once I got here throughout an FPGA growth board in a Raspberry Pi kind issue with the identify ‘ZynqbBerry’… I used to be bought instantly. I purchased mine straight from the German firm that designed them, Trenz Digital.

In the event you’re not conversant in the assorted FPGA chipset households, the Zynq 7010 chip the ZynqBerry will get its identify from is likely one of the SoCs (system-on-chip) from Xilinx’s lineup of FPGAs. Its defining function is its dual-core Arm processor embedded into the material (logic gates) of the FPGA. That is advantageous in that now you may have each a microcontroller and an FPGA in a single chip.

style="display:block; text-align:center;" data-ad-format="fluid" data-ad-layout="in-article" data-ad-client="ca-pub-4791668236379065" data-ad-slot="8840547438">

FPGA growth offers you the design granularity needed when it’s essential obtain properties resembling low latency, parallel knowledge processing, low energy consumption, and many others. Nonetheless, since you’re designing at such a low degree, you find yourself re-inventing the wheel in an particularly painful means on fundamental functionalities resembling serial communication interfaces. That is the place having an Arm processor embedded into the FPGA is a big benefit. Loads of libraries, each in naked steel and embedded Linux, are on the market to implement widespread interfaces resembling SPI, I2C, UART, TCP/IP, and many others. which are properly written and examined (Aspect word: Tender-processors such because the MicroBlaze are an choice that may be instantiated in an FPGA’s material, however we’ll simply be specializing in the bodily Arm processors within the Zynq on this article).

With its Raspberry Pi kind issue, the ZynqBerry can simply reap the benefits of all of the peripherals and equipment out there for the Pi.

With my ZynqBerry in hand, I created a base Vivado undertaking and a naked steel UART software that echoed again characters written to the UART on the micro-USB port as a check drive (posted right here). After getting my ft moist, I rapidly set my sights on increasing my design’s performance to make the most of the 4 common USB ports and the Ethernet port. Xilinx’s SDK has naked steel drivers for each USB 2.Zero and lwIP (gentle weight TCP/IP) that I had initially deliberate to make use of for my preliminary design. Though, once I began trying into the pinout of the Zynq 7010’s bundle on the ZynqBferry to determine which bundle pins the ethernet and USB interfaces had been routed to, I hit a agency roadblock. The 4 USB 2.Zero and Ethernet ports should not related on to the Zynq chip. They’re as a substitute all routed to a SMSC LAN9514 chip, which is a USB 2.Zero hub with an ethernet controller in-built. So as to add a layer of complexity on high of that, the upstream USB PHY port of the LAN9514 is routed via a SMSC USB3320 hi-speed USB 2.Zero ULPI transceiver as a way to present a high-speed parallel interface between the 5 ports and the Zynq (in any other case we’d should implement a singular serial interface to repeatedly ballot and deal with the occasions on every of the ports — which might be considerably slower).

The 4 USB 2.Zero and ethernet ports should not related on to the Zynq chip, however are as a substitute routed via a hub and PHY transceiver chip.

What this all boiled right down to for me was that if I needed to speak to the 4 USB 2.Zero ports and the ethernet port from my naked steel software, I’d have to jot down my very own ULPI interface driver in naked steel then work out a strategy to convert that to speak to the lwIP driver and the USB 2.Zero driver (keep in mind what I used to be saying about re-inventing the wheel in an particularly painful means?). Since naked steel had changed into a lower than favorable choice for this specific design, an embedded OS was the following choice. Embedded Linux (applied utilizing PetaLinux for Xilinx chips) rapidly labored its strategy to the highest of my checklist given there are already drivers for the LAN9514 chip and ULPI-PHY interface.

A couple of aspect notes earlier than leaping into my design circulate in PetaLinux:

1 — After deciding on embedded Linux, I took word that the ZynqBerry solely has 16MByte on onboard of on-board flash reminiscence which meant that it’d must boot from an embedded Linux picture on an SD card (that is one thing that’s import to find out early on in your design as it can have an effect on the way you configure your boot course of).

2 — Xilinx gives board help packages for his or her reference boards inside PetaLinux as a place to begin for customized designs. What this actually gives you is a place to begin on your machine tree on your Linux kernel. Personally, I discovered it simpler to only begin from scratch and edit the machine tree myself (though with nice energy, comes nice accountability I discovered…).

3— I’m working Vivado/SDK/PetaLinux model 2018.2 on Ubuntu 16.04 (Set up tutorial).

Step 1 — Create the PetaLinux Challenge

I personally wish to hold all of my supply recordsdata collectively (Vivado/SDK/PetaLinux) for a given undertaking, so earlier than I run the preliminary command to create the undertaking (which creates your complete PetaLinux undertaking file construction inside no matter listing you’re in once you run the command) I alter directories into the highest degree Vivado undertaking folder. I then created my PetaLinux undertaking concentrating on the Zynq and named it zynqberryOS.

As soon as the undertaking had been created, I alter directories into its high degree folder to execute the configuration steps of constructing my embedded Linux picture.

Step 2 — Import {Hardware} Description File (.hdf) From Corresponding Vivado Challenge

First issues first, PetaLinux must know what {hardware} you may have in your design. After producing the bitstream in Vivado, you export it to SDK the place it’s then compiled right into a {hardware} description file (*.hdf). Based mostly on the knowledge this {hardware} description file comprises, PetaLinux generates u-boot header recordsdata, the machine tree supply file, and permits the suitable Linux kernel drivers.

This command will deliver up the highest system configuration menu within the type of an an ASCII GUI. The vast majority of these settings could be left because the default settings for the ZynqBerry, the one settings that must be modified are the settings that configure the kernel and u-boot to level to the SD card.

The Subsystem AUTO {Hardware} Settings act as globals for system huge {hardware} settings, that means that the instrument is updating the machine tree, u-boot configuration, and kernel configuration all in accordance to the knowledge from these settings. There are two issues that must be modified right here to configure your complete system to level to the SD card:

1 — Main SD/SDIO must be set to ‘ps7_sd_1’ underneath SD/SDIO Settings

2 — Picture Storage Media must be set to ‘main sd’ underneath Superior Bootable Pictures Storage Settings →dtb picture settings

The one different tab that wants a few minor edits is the Picture Packaging Configuration tab. The Root Filesystem Kind must be set to ‘SD card’. Then if it’s not already, the machine node of SD machine must be set to ‘/dev/mmcblk0p2’. This tells the kernel to go search for the foundation file system in partition two of reminiscence storage machine zero. For the reason that SD card is the one reminiscence storage machine on this case, it can greater than possible default to machine zero when u-boot goes to search for it. We are going to confirm this later…

The choice for ‘Copy ultimate photos to tftpboot’ additionally must be unchecked since we’re booting from an SD card and never over a community. You’ll see some random warning messages about tftpboot in a while when the ZynqBerry is definitely booting, however you may ignore them. It’s simply because this selection has been unselected right here.

Exit the GUI and provides it a short while to compile. If it’s essential come again and edit these settings at any level, you simply must run the ‘petalinux-config’ command from throughout the high degree PetaLinux undertaking folder. You solely must specify the {hardware} description file the primary time after preliminary undertaking creation.

Aspect word: the terminal window must be not less than a minimal dimension to ensure that the ASCII GUI to have the ability to launch. So when you get a bizarre error message once you attempt to run ‘petalinux-config’, simply make your terminal window giant and rerun the command.

Step 3 — Configure the Linux Kernel

Many of the needed machine drivers have already been enabled primarily based upon the earlier settings within the high system configuration, however extra specialised machine drivers should be enabled manually. Deliver up the Kernel Configuration menu by working the next command:

That is the place the drivers for the LAN9514 chip and ULPI-PHY interface are activated in order that the 4 USB 2.Zero ports and the ethernet port on the ZynqBerry could be utilized. Navigate to System DriversCommunity System AssistUSB Community Adapters, and embody the Multi-purpose USB Networking Framework choice and the SMSC LAN95XX primarily based USB2.0 10/100 ethernet units choice.

Once more, exit the GUI and permit it time to compile. When it has accomplished, there’s another factor that must be completed earlier than constructing your complete undertaking. Though the drivers for the LAN9514 chip and ULPI-PHY interface have been enabled, it nonetheless must be added to the machine tree blob. Inside the PetaLinux undertaking listing, <PetaLinux Challenge>/project-spec/meta-user/recipes-bsp/device-tree/recordsdata, is the machine tree supply embody file (system-user.dtsi). This machine tree file is the one user-editable one, the remainder are auto-generated by PetaLinux and can both overwrite any edits made to them or trigger your total undertaking to blow up (sure, I did determine this out the laborious means). Since we didn’t use a pre-packaged BSP, the system-user.dtsi file shall be clean. Simply add the code from the screenshot under, save, and shut the file. I received’t go into element right here about precisely how this code works, however when you’re curious learn over this hyperlink and this one.

Step 4 — Construct the PetaLinux Challenge

Now that all the things has been configured and compiled, its time to construct the system picture with the next command:

This step will take fairly some time, particularly the primary time it’s run in a undertaking. The standing messages are very verbose by default so that you’ll get loads of suggestions all through the method.

Step 5 — Create Boot Picture File

The boot picture for an embedded Linux picture comprises on the very least the u-boot binary recordsdata and first stage bootloader (FSBL). It’s potential for the boot picture file to include all the things together with the FPGA bitstream, machine tree, the Linux kernel picture, and the foundation file system. For the reason that ZynqBerry’s Zynq chip is in a CLG225 bundle, SD Card boot immediately from ROM bootloader is just not supported. Which means the ZynqBerry’s on-board QSPI flash reminiscence must be used for main boot, and the SD card used for secondary boot. To realize this, the boot picture file for the ZynqBerry will simply include the FSBL, FPGA bitstream, and u-boot. The machine tree, the Linux kernel picture, and the foundation file system shall be situated on the SD card.

The packaging command to create the boot picture file will find yourself trying one thing like this:

Observe: the FSBL I’m utilizing right here is similar FSBL I utilized in my first naked steel software to check the UART. In the event you want a reference of find out how to create this FSBL, you’ll find it right here. There may be nothing particular wanted for this FSBL, it’s simply the default Zynq FSBL software.

Step 6 — Program Boot Picture File Into Flash Reminiscence of the ZynqBerry Utilizing SDK

After the earlier command has been run, the boot picture file shall be output into the <undertaking listing>/photos/linux folder. Use the Program Flash Reminiscence operate in SDK with the particular FSBL the ZynqBerry wants as a way to have its on-board QSPI flash reminiscence programmed over JTAG (the identical hyperlink within the word in Step 5 particulars find out how to create this particular FSBL) to program the BOOT.bin into the QSPI flash reminiscence.

Step 7 — Prep the SD Card

The SD card must be formatted with two completely different partitions. The primary of which must be not less than least 60MB in fats32, and it wants 4MB of unallocated house continuing it. That is the place the kernel picture and machine tree will stay. The remainder of the SD card must be formatted as ext4 and shall be residence to the foundation file system. Ext4 is a typical Linux filesystem format, you need to use ext3 however ext4 is the most recent and biggest so I like to recommend sticking with it. Fats32 is likely one of the earliest filesystem sorts and boasts broad compatibility throughout many alternative working techniques. For this reason it makes choice for putting your kernel picture and machine tree on for the reason that root file system you name could possibly be just about something. Whereas your fats32 partition should be not less than 60MB, it wouldn’t be a good suggestion to make it any bigger than 4GB as it could solely index a most of 4GB of recordsdata.

Step 8 — Copy Recordsdata to SD Card

Every of the partitions on the SD card want a mounting level for recordsdata to be copied to them. Create one for the fats32 partition titled ‘BOOT’ and the opposite for the ext4 partition titled ‘rootfs’.

Mount the corresponding partitions of the SD card to every listing:

Copy the kernel picture and machine tree into the BOOT (fats32) partition and extract the foundation file system into the roots (ext4) partition:

Unmount every of the SD card partitions earlier than eradicating the SD card out of your pc:

Step 9 — Launch Putty as a Tremendous Person to be Capable of Create and Save the Configuration for the COM of the ZynqBerry

You don’t should launch Putty as a brilliant consumer as a way to run it, however if you wish to create, save, or recall a saved configuration, you do must run it as a brilliant consumer.

The ZynqBerry creates a COM port throughout its boot course of as a way to present an entry level into the u-boot surroundings and output standing/error through the boot course of. Realizing when to launch Putty within the boot course of is the tough half and took me a minute to determine. You may additionally should plug within the Zynqerry a number of occasions to find out what COM port quantity it can decide on in your system to save lots of right into a Putty configuration.

Observe: Since this can be a Zynq chip we’re working with, the default baud fee is 115200.

Step 10 — Connect with the ZynqBerry through JTAG Port andConnect to the COM Port Created with Putty

Set up the SD card into the ZynqBerry and plug it in to your pc through its JTAG port (on the micro-USB connector). You’ll see the crimson standing LED close to the micro-USB blink quickly at first, then change to a slower tempo earlier than stopping. Wait till the crimson LED is blinking on the slower tempo to launch the Putty session. The COM port has not been created but when the LED is blinking quickly, however as soon as the LED has shut off there’s nothing being output on the COM port to see any longer. The Putty session additionally must be launched early in the timeframe by which the LED is blinking slowly, as that is the timeframe by which u-boot permits itself to be halted for modifying. If you launch Putty on the proper time, you’ll see a countdown taking place, that is the countdown earlier than u-boot will proceed on with the boot course of. Press any key throughout this countdown to halt the boot course of and enter the u-boot surroundings.

Step 11 — Configure ZynqBerry’s U-Boot

There are some things within the ZynqBerry’s u-boot surroundings that must be modified. A few boot arguments and boot instructions must be added to inform the kernel that the partition the foundation file system is on is ext4 format, and the place to load the kernel picture and machine tree from.

First issues first, we have to examine to see that the SD card really confirmed up as machine Zero as we predicted again in Step 2 after we set the machine node of the SD card to /dev/mmcblk0p2 within the high system configuration menu.

Run mmc checklist within the command immediate. If the machine exhibits up underneath node 1, you’ll want to begin again at Step 2 and alter set the machine node of the SD card to /dev/mmcblk1p2.

To inform u-boot the place to load the kernel picture and machine tree from, run the next instructions:

setenv cp_dtb2ram ‘fatload mmc 0 ${dtbnetstart} ${dtb_img}’
setenv cp_kernel2ram ‘fatload mmc 0 ${netstart} ${kernel_img}’
setenv default_bootcmd ‘run cp_kernel2ram && cp_dtb2ram && bootm ${netstart} – ${dtbnetstart}’

One thing I discovered to be fascinating was that I discovered the kernel whining in regards to the root file system partition on the SD card being in ext4 as a substitute of ext3, even though ext4 is the present normal Linux filesystem sort and Xilinx’s consumer information for PetaLinux (UG1144) tells you to format that partition of the SD card as ext4. I removed this peskyness by modifying my boot arguments as such:

setenv bootargs ‘console=ttyPS0,115200 earlyprintk root=/dev/mmcblk0p2 rootfstype=ext4 ru rootwait’

Aspect word: in case your SD card exhibits up as machine 1 as a substitute of machine zero, in every single place you see ‘mmc 0’ or ‘mmcblk0’ in my instructions above you’ll want to vary to ‘mmc 1’ and ‘mmcblk1’.

After you have made all of those adjustments, save the ZynqBerry’s boot surroundings by writing it to its flash reminiscence with the command ‘saveenv’. You may print out the entire present u-boot settings to examine them at any time with the command ‘printenv’.

Step 12— Manually Boot ZynqBerry From the U-Boot Setting Editor

After saving the boot surroundings to the ZynqBerry’s flash reminiscence, it’s prepared for its maiden boot voyage! Merely run the command ‘boot’ within the u-boot editor and watch the boot course of step via its paces. In the event you run into an issue don’t solely take a look at the final message printed out on the COM port, make sure you scroll again and skim the entire messages from the start of the boot course of all the way in which as much as wherever it bought hung up. I had by chance instructed u-boot as well from the second Arm processor once I meant to inform it as well from the primary Arm processor on my preliminary try at this. It bought hung up in a bizarre place within the boot course of and the final message printed out had me chasing my tail pondering my SD card was corrupt as a result of the message was saying it couldn’t learn an ext4 format. As soon as I began scrolling again via the messages on the COM after attempting my third SD card and getting the identical outcome, I lastly discovered a number of messages that instructed me what was actually happening in direction of the start of the boot course of.

In the event you didn’t set your personal customized login once you configured the kernel again in Step 3, the default login is username = root and password = root. Positively return and reconfigure your kernel to set your personal customized login when you plan to make use of your ZynqBerry on a community.

As you may see, as soon as I bought logged in, I used the checklist command to confirm my file system construction was all there. It’s additionally only a satisfying sanity examine to see all the things is the place you suppose it must be. I do know that is fairly a protracted learn, however I actually needed to reveal a number of the thought course of behind embedded system design and the way obstacles affect the design decisions made to attain an answer. The roadblock I hit once I initially tried to jot down a naked steel driver to manage the 4 USB ports and ethernet port that lead me to decide on to create an embedded Linux picture is an ideal instance of the form of design selection adjustments embedded system designers should make frequently.

Supply hyperlink

Leave A Reply

Hey there!

Sign in

Forgot password?

Processing files…