(ES) 1.2 Proceso de arranque - coffeebrain/Codesign_HW_SW GitHub Wiki
Introducción
El proceso de arranque es la secuencia que sigue el sigue el sistema al ser encendido. Cada sistema tiene su propio proceso de arranque que depende del hardware, sistema operativo y la configuración requerida. Este proceso puede ser llevado a cabo desde muchos dispositivos llamados dispositivos de arranque (boot devices), como el disco duro, dispositivo USB, CD, o incluso desde una tarjeta SD.

Cyclone V Boot Flow
There are different boot stages depending on the board, but the general boot stages are similar between boards. In this section we will analyze the Cyclone V boot flow. In this case, the boot device is an SD card that can be inserted in the development board SD card slot. All these stages occur whenever the system is power up and lead to the FPGA configuration and HPS system startup.

Reset
It begins when the reset state is released (for example at power up) and starts reading the reset exception address where the Boot ROM normally is.
Boot ROM
It starts with the reset vector address in the Boot ROM address space. It can't be modified as it a read only memory that is configured by the fabricant.
It is responsible for:
- Detecting the boot source.
- Initialize minimal HPS functions.
- Loading the preloader stage from Flash to OCRAM.
Preloader
The preloader is the first user defined boot stage. This stage may load the boot loader (which will load the OS) or a Bare Metal Application.
It is responsible for:
- Making additional HPS initialization.
- Start the SDRAM.
- Loading the boot loader stage.
Boot loader
The boot loader is in charge of loading the operating system and passing the software control to it. The boot loader runs in SDRAM, so is not limited by OCRAM size. It has typical responsibilities that are similar to the Preloader, except it does not need to bring up SDRAM. The Cyclone V uses U-Boot as the boot loader. The sources of the boot loader may be the same flash device that contains the preloader, a different flash device, or a communication interface.
U-Boot
The U-Boot (Universal Boot Loader) is an open-source, primary boot loader used in embedded devices to package the instructions to boot the device's operating system kernel. It is available for a number of computer architectures, including 68k, ARM, Blackfin, MicroBlaze, MIPS, Nios, SuperH, PPC, RISC-V and x86.
The boot loader loads the OS stage which could be a Bare-Metal Application, RTOS or a kernel OS, as Linux. For this guide, Linux Kernel is being used.
Linux Kernel
Linux Kernel is the most important and crucial part of an operating system (OS) used in many computing devices such as personal computers, servers, smartphones, embedded systems and others. As stated before, Linux is not an OS, but makes part of it. It is common to get confused as most people call Linux refering to the whole OS and not just the kernel, as it should be. Many reasons are found for using Linux Kernel rather that a Bare-Metal Application, but from them one of the most important in this guide is Linux’s built-in drivers that support plenty of devices, as the USB and Ethernet ports of the development board and allow us to skip writing drivers for these. The developer can take advantage of these drivers and their high-level abstraction layers provided to use the devices.
Operating System (OS)
An OS is the software which allows for interaction between the hardware and the user. It is the platform which enables to run programs and communicate with the peripherals (as keyboard, mouse, monitor...), this last is done through drivers.
Ubuntu 18.04 LTS
Ubuntu is a free, open-source, supported OS. It is a Linux distribution based on Debian, made for computers and servers. LTS stand for Long Term Support, meaning that is meant to be a stable version for a long time. At this moment, the lastest known version is Ubuntu 20.04, but Ubuntu 18.04 was used since the software was intended to work with ROS Melodic.
User application
In this step the boot flow ends, enabling the user to interact with the system through terminal or grapical interfaces (the later one most commonly know a GUI [Graphic User Interface]). This process is a mixture of automatic and manually running scripts, which are mainly coded in low or high level programming languages (as C, C++, Java, Python...).
Initial scripts
Besides the critical code that must be running for the system to work, the user may include additional scripts to run when the operating system is already running. These scripts are located at a startup section (or called from an startup script), and are useful when the user needs to them to run every time the board is turned on (or almost aways). Without including the scripts in this section, they should be called manually as "End applications".
End application
As mentioned above, these user applications run from high or low level programming languages scripts. These might be interpreted or compiled languages. There are several ways of running these scripts based on the language, wheter they are compiled or not, and if there is an executable for them. In this guide, we will be working with C and C++ scripts, although other languages as Java or Python may be included, as a minimal installation of Ubuntu 18.04 is used as OS.
Boot Sources
These are the devices from which the OS can begin. It can be from a hard disk drive, a USB device, a CD, a network interface, a SD card and others. It is important to have some hardware and software that enables for this taks to happen. In a modern computer the BIOS is made to select and boot from devices that are bootable.
Cyclone V Boot Sources
In the case of the HPS can boot from the following sources:
Secure Digital Card/MultiMediaCard (SD Card/MMC)
Booting from an SD Card can be made in two different ways:
- Raw mode: Preloader images are at address0. This way allows no partitions.
- Partition mode: Preloader images are at offset 0 on a ID=A2 partition on the card. In this case, the preloader is called by the master boot record (MBR).
Quad Serial Peripheral Interface (QSPI)
In this case, the four Preloader images are located at the beginning of the QSPI address space, and occupy 256 KB.
NAND Flash memory
In this case, the Preloader images are located at the beginning of the flash memory. Each image starts at NAND flash block boundary.
FPGA
In this case, the following operations are performed int the Boot ROM:
- Waits till the FPGA is configured and in user mode.
- Verifies that the booting from FPGA was enabled in the FPGA.
- Jumps to address 0xC0000000, which corresponds to offset 0 on the HPS-to-FPGA bridge.
Relevant Links
For additional information about boot options for the Cyclone V refer to the following links:
- Booting and Configuration Introduction
- AN 709: HPS SoC Boot Guide - Cyclone V SoC Development Kit
- Booting Your Computer