New Horizons

Welcome to my blog

My name is Sven Andersson and I
work as a consultant in embedded
system design, implemented in ASIC
and FPGA.
In my spare time I write this blog
and I hope it will inspire others to
learn more about this fantastic field.
I live in Stockholm Sweden and have
my own company


You are welcome to contact me
and ask questions or make comments
about my blog.


New Horizons
What's new
Starting a blog
Writing a blog
Using an RSS reader

Zynq Design From Scratch
Started February 2014
1 Introduction
Changes and updates
2 Zynq-7000 All Programmable SoC
3 ZedBoard and other boards
4 Computer platform and VirtualBox
5 Installing Ubuntu
6 Fixing Ubuntu
7 Installing Vivado
8 Starting Vivado
9 Using Vivado
10 Lab 1. Create a Zynq project
11 Lab 1. Build a hardware platform
12 Lab 1. Create a software application
13 Lab 1. Connect to ZedBoard
14 Lab 1. Run a software application
15 Lab 1. Benchmarking ARM Cortex-A9
16 Lab 2. Adding a GPIO peripheral
17 Lab 2. Create a custom HDL module
18 Lab 2. Connect package pins and implement
19 Lab 2. Create a software application and configure the PL
20 Lab 2. Debugging a software application
21 Running Linux from SD card
22 Installing PetaLinux
23 Booting PetaLinux
24 Connect to ZedBoad via ethernet
25 Rebuilding the PetaLinux kernel image
26 Running a DHCP server on the host
27 Running a TFTP server on the host
28 PetaLinux boot via U-boot
29 PetaLinux application development
30 Fixing the host computer
31 Running NFS servers
32 VirtualBox seamless mode
33 Mounting guest file system using sshfs
34 PetaLinux. Setting up a web server
35 PetaLinux. Using cgi scripts
36 PetaLinux. Web enabled application
37 Convert from VirtualBox to VMware
38 Running Linaro Ubuntu on ZedBoard
39 Running Android on ZedBoard
40 Lab2. Booting from SD card and SPI flash
41 Lab2. PetaLinux board bringup
42 Lab2. Writing userspace IO device driver
43 Lab2. Hardware debugging
44 MicroZed quick start
45 Installing Vivado 2014.1
46 Lab3. Adding push buttons to our Zynq system
47 Lab3. Adding an interrupt service routine
48 Installing Ubuntu 14.04
49 Installing Vivado and Petalinux 2014.2
50 Using Vivado 2014.2
51 Upgrading to Ubuntu 14.04
52 Using Petalinux 2014.2
53 Booting from SD card and SPI flash
54 Booting Petalinux 2014.2 from SD card
55 Booting Petalinux 2014.2 from SPI flash
56 Installing Vivado 2014.3

Chipotle Verification System

EE Times Retrospective Series
It all started more than 40 years ago
My first job as an electrical engineer
The Memory (R)evolution
The Microprocessor (R)evolution

Four soft-core processors
Started January 2012
Table of contents
OpenRISC 1200
Nios II

Using the Spartan-6 LX9 MicroBoard
Started August 2011
Table of contents
Problems, fixes and solutions

FPGA Design From Scratch
Started December 2006
Table of contents
Acronyms and abbreviations

Actel FPGA design
Designing with an Actel FPGA. Part 1
Designing with an Actel FPGA. Part 2
Designing with an Actel FPGA. Part 3
Designing with an Actel FPGA. Part 4
Designing with an Actel FPGA. Part 5

A hardware designer's best friend
Zoo Design Platform

Installing Cobra Command Tool
A processor benchmark

Porting a Unix program to Mac OS X
Fixing a HyperTerminal in Mac OS X
A dream come true

Stockholm by bike

The New York City Marathon

Kittelfjall Lappland

Tour skating in Sweden and around the world
Wild skating
Tour day
Safety equipment
A look at the equipment you need
Skate maintenance
Books, photos, films and videos
Weather forecasts

38000 feet above see level
A trip to Spain
Florida the sunshine state

Photo Albums
Seaside Florida
Ronda Spain
Sevilla Spain
Cordoba Spain
Alhambra Spain
KittelfjÀll Lapland
Landsort Art Walk
Skating on thin ice

100 Power Tips for FPGA Designers

Adventures in ASIC
Computer History Museum
Design & Reuse
d9 Tech Blog
EDA Cafe
EDA DesignLine
Eli's tech Blog
FPGA Arcade
FPGA Central
FPGA developer
FPGA Journal
FPGA World
Lesley Shannon Courses
Mac 2 Ubuntu
Programmable Logic DesignLine
World of ASIC

If you want to be updated on this weblog Enter your email here:

rss feed

Friday, April 25, 2014
Zynq design from scratch. Part 40.
Booting from SD card or SPI flash

In a true, embedded application, we will not have a JTAG cable connected that can transfer our programs to the board. Our code must be able to do this before transferring control to an application. Let's return to lab2 and see how we can run our LED dimmer application directly from the SD card or from the on-board SPI flash.

But first we will learn a little bit more about the Zynq boot process. We can find a description in the documents "Zynq-7000 All Programmable Software Developers Guide (ug821)" and the "Technical Reference Manual (ug585)".

The processor system boot

The processor system boot is a two-stage process:
  • An internal BootROM stores the stage-0 boot code, which configures one of the ARM processors and the necessary peripherals to start fetching the First Stage Bootloader (FSBL) boot code from one of the boot devices. The programmable logic (PL) is not configured by the BootROM. The BootROM is not writable.
  • The FSBL boot code is typically stored in one of the flash memories, or can be downloaded through JTAG. BootROM code copies the FSBL boot code from the chosen flash memory to On-Chip Memory (OCM). The size of the FSBL loaded into OCM is limited to 192 kilobyte. The full 256 kilobyte is available after the FSBL begins executing.

The FSBL boot code is completely under user control and is referred to as user boot code. This provides us with the flexibility to implement whatever boot code is required for our system.

First stage bootloader

The First Stage Bootloader (FSBL) starts after the boot. The BootROM loads FSBL into the OCM. The FSBL is responsible for:
  • Initializing with the PS configuration data that Xilinx hardware configuration tools provide
  • Programming the PL using a bitstream (if provided)
  • Loading second stage bootloader or bare-metal application code into DDR memory
  • Handoff to the second stage bootloader or bare-metal application
Flow diagram

Create the first stage bootloader

The first step is to create the FSBL application. This is a C program that embeds all the Zynq internal register settings that were established during the Vivado Block Design. We start Xlinx SDK and make sure we have exported the lab2 design from Vivado and that we setup the Board Support Package (BSP).

->xsdk &

The SDK program will open with the setup we used in our lab2 experiment. Before creating the FSBL file we have to add a library file used by the FSBL c-program. Select from the top menu:

Xilinx Tools-> Board Support Package Settings

Click OK and wait for the settings window to open.

We will add the xilffs library. We are now ready to generate the FSBL program.

1. Select New->Application Project

2. Enter a name (fsbl_0) and select existing BSP (standalone_bsp_0).

3. Click Next.

4. Select Zynq FSBL and click Finish. When the generation has finished there is a new entry in the Project Explorer namned fsbl_0.

5. Right-click the fsbl_0 entry and select: Build Configurations->Set Active->Release. The release configuration will have less overhead.

6. Build the release configuration by right-clicking and select Build Project.

7. Here is the result:


Generate the boot image

The next step is to create a non-volatile boot image for ZedBoard. The ZedBoard has two non-volatile bootable sources, QSPI flash and SD Card.

1. In the Project Explorer select LED_Dimmer

2. From the top menu select: Xilinx Tools->Create Zynq Boot Image

3. The tool will automatically pick up the files needed to build the boot image.

  • fsbl_0.elf
  • system_wrapper.bit
  • LED_Dimmer.elf
4. To generate a boot image for the microSD card we will rename the Output path file name (output.bin) to boot.bin and click the Create Image button.

5. To generate a boot image for the SPI flash we will change the Output path file name to LED_Dimmer.mcs and rerun the Create Boot Image generation. It is the file type (bin or mcs) that defines what type of boot image that will be generated.

6. Here is the result.

Boot from the SD card

Copy the boot.bin file to the SD card and insert the card in to the ZedBoard. Set the jumpers to boot from SD card and power up the board. Connect a terminal and control the LEDs by entering different values.

Boot from SPI flash

First we will program the SPI flash using the LED_Dimmer.mcs file we just have generated. To program the SPI flash.

1. Connect the JTAG cable (see part 13).

2. Set the jumpers to JTAG mode.

3. In SDK select Xilinx Tools->Program Flash.

4. Specify the image file LED_Dimmer.mcs and click Program.

5. The programming will take a few minutes.

6. Power off the board and set the jumpers to SPI flash boot.

7. Power on the board. Connect a terminal and we are up and running in milliseconds.

Top   Previous   Next

Posted at 11:22 by

May 14, 2014   07:35 PM PDT
Hi Suheb,

You should complete lab2 meaning you should go through all the lab2 links.


Leave a Comment:


Homepage (optional)


Previous Entry Home Next Entry