Project 1: Boot Process of an Embedded System, Its BSP and Development Environment
Total Page:16
File Type:pdf, Size:1020Kb
LECTURE: MP-6171 SISTEMAS EMPOTRADOS DE ALTO DESEMPEÑO Project 1: Boot Process of an Embedded System, its BSP and Development Environment Lecturers: MSc. José Araya Martínez MSc. Sergio Arriola-Valverde First term, 2020 0 Contents 1 Introduction3 1.1 Administrative Matters...........................3 1.1.1 Team Formation..........................3 1.1.2 Forum and Communication....................3 1.1.3 Plagiarism.............................4 1.2 Development Environment Overview....................4 1.2.1 Nomenclature............................5 2 Setting up the Host5 2.1 Downloading the VM and Configuring VirtualBox............6 2.2 Version Control: GIT............................7 2.3 Configure Local Area Network with Static IP...............8 2.4 Configure a TFTP Server for File Sharing.................9 2.5 Set NFS for Mounting a Remote File System............... 10 2.6 Installing the Eclipse IDE for C/C++ Developers............. 10 3 Setting up our Embedded System and its Board Support Package 11 3.1 Using a Pre-compiled Image: Raspbian.................. 12 3.2 Establishing UART Connection with the RPI............... 13 3.3 How Does an Embedded Device Boot?................... 16 3.3.1 The Specific Case of the Raspberry Pi 4.............. 18 3.4 First Stage Bootloader: BootROM..................... 19 3.5 Second Stage Bootloader: Das U-Boot................... 19 3.5.1 Toolchain for Cross-Compilation................. 20 3.5.2 Cross-compiling U-Boot...................... 21 3.5.3 Configuring our Target to Load U-Boot.............. 22 3.5.4 Configuring Static IP in U-Boot.................. 24 3.6 The Linux Kernel.............................. 25 3.6.1 Cross-compiling the Linux Kernel................. 26 3.6.2 Loading Kernel from TFTP.................... 29 3.7 YOCTO, File System and the Toolchain.................. 32 3.7.1 Generating a File System with Yocto............... 32 3.7.2 Deploying a Remote Network File System (NFS)......... 36 3.7.3 Configure the Embedded System to mount a NFS......... 37 3.8 Testing the Target’s SSH Server...................... 40 3.9 Cross-compiler and Toolchain....................... 40 3.9.1 Install the Generated ARM Toolchain............... 40 3.9.2 Yocto Plugin for the Eclipse IDE.................. 42 1 0 3.9.3 Configuring the Yocto Plugin and Create Example Project.... 42 4 Create a Custom Meta-Layer in Yocto 44 5 The Application: Composite Trapezoidal Numerical Integration 45 5.1 Motivation and Description......................... 46 5.2 Prototyping and Programming Process................... 46 5.2.1 Prototyping............................. 47 5.2.2 Programming............................ 47 6 Deliverables and Grading 48 6.1 Work flow requirements........................... 48 6.2 Folder Structure of your Deliverables.................... 49 6.3 Grading................................... 50 6.4 Deliverables Submission.......................... 50 2 1.1.2 1 Introduction In this project, each team will be guided through the process of bringing up an embedded system. During the project we will learn what is the common boot process of an industrial embedded device and the specific case of the Raspberry Pi 4 (RPI4), additionally the students will need to make use of the widely-used Linaro cross-compilation toolchain and throw some light on the powerful but complex Yocto Project. All this without forgetting to keep an eye on the code’s version control as is usual in every serious development team nowadays. The students will be guided through the setup of a cross development environment (host and target). For this, we will go through the compilation and configuration of the multiple software components needed to orchestrate a cross development environment with the ultimate purpose of developing and optimizing our own application. Towards the end of the project, each team will implement an application using the Trape- zoidal Numerical Integration concept. To do so, we will first prototype our application in a high-level programming language, then we will implement using the more efficient C language and at the end we will include it into our custom File System as a standard application of our Linux distribution. 1.1 Administrative Matters Before we get down to business, some administrative affairs are to be discussed: 1.1.1 Team Formation Work teams of 2 students should be made up. Please send as soon as possible a list with the team members and their respective Email (the one associated with GIT) to the following Email Addresses: [email protected] and [email protected]. 1.1.2 Forum and Communication This project will be evaluated remotely, for this reason having a suitable online platform turns out to be very important to facilitate the communication between students and lec- turers. In order to do so, we will adopt a "community" approach by means of a forum in the TecDigital platform. In the forum, all students can create new topics as questions arise. All discussions are public to all the course members so that any fellow student can answer and/or add more information to the proposed question. Please avoid sending project- related queries directly to the lecturers Email, as this prevents other students to benefit from the answer. In the forum we all are a team! The only restriction is to not share 3 1.2 working source code in the forum, instead, we can create discussion and propose ideas and concepts that lead to the solution. 1.1.3 Plagiarism Any evidence of plagiarism will be thoroughly investigated. If it is corroborated, the team will receive a zero grade in the project and the incident will be communicated to the corresponding institutional authorities for further processing. 1.2 Development Environment Overview Embedded systems are ubiquitous; they are present everywhere in our daily-life activities. This project will introduce students in both: the setup of the development environment and some best design and implementation practices concerning embedded systems. A Raspberry Pi 4 will be used as target platform. As Figure1 shows, our development environment consists of two main components: • Host: Serves as main development platform. As it typically has more computing capacity than the target, all the design and implementation will be done here. • Target: This is the test and debug environment. Once a design phase has been concluded, the target platform is used as a test system. Here we validate correct functioning, profile and benchmark our application. It is even possible to measure the energy and efficiency of our algorithms for energy-aware applications. Figure 1: General view of the development environment It is worth noting that there are 2 connections between the host and target: • UART: Thanks to its simplicity, this is usually the first communication established with the target even at early stages of the board bring-up. It will serve to send commands to the bootloader and get logging information of the boot process. 4 2.1 • Ethernet: Because UART does not a allow a high transfer rate (normally up to a range of hundreds of kBps), we need a faster communication method to share large files in a reasonable amount of time. For this reason the TFTP protocol will be used over Ethernet to share the device tree and Linux kernel at boot time. In addition the Target will mount a File System present in the Host over the NTFS protocol. 1.2.1 Nomenclature As we will work with different command-line consoles during the setup of the develop- ment environment, it is necessary to specify where the commands are to be executed. Table1 summarizes the prompt symbols for the different command-line consoles. Table 1: Prompt symbols for the multiple command-line consoles during the project. Prompt symbol Description $ Host Linux PC => Target: U-Boot @ Target: Linux 2 Setting up the Host Once we have reviewed the main hardware components of our set up, it is time to check that all required software is installed in the host to support our development. In order to carry out the installation process quickly, a virtual machine (VM) with some pre-installed software will be provided. Besides making the installation easier, a virtual machine isolates many potential problems from our native system and allows us all to have the same base configuration to avoid version mismatch of software tools. Only this Virtual Machine will be supported during the project, due to time and resource limitations we cannot attend questions if you decide to go for a native installation. Please note the following concerning the virtual machine: • Any reference to host in this document will refer to this virtual machine. • Using the provided VM is highly recommended. However, if for any reason you prefer to use a native Ubuntu installation please make sure your system match: – Ubuntu 18.04.4 LTS – GIT 2.17.1 – Eclipse for C/C++ Developers 5 2.1 2.1 Downloading the VM and Configuring VirtualBox 1. Downloading the .zip: Please go to the following link and download the .zip file. 2. Extracting the files: As the download is available to everyone, the .zip file is pro- tected with a password. Unpack all contents of the .zip file in a hard drive with at least 180GB of free space (it can also be an external HD). The provided virtual hard drive (.vdi file) allocates memory dynamically as needed up to 256GB. Password: MaesTria_TeC 3. Install VirtualBox: Download the VirtualBox 5.2 or greater (for instance 6.0 ver- sion) binaries matching your current operating system from here and install the application. 4. Create a new VM in your VirtualBox: Go to Machine ! New (a) Name: Ubuntu18.04 ! Type: Linux ! Version Ubuntu (64-bit). (b) Select a RAM memory of at least 4GB. Warning: Never go beyond the green limit of VirtualBox. If you cannot assign 4GB of RAM to your virtual machine, you can try with less but it will be much slower and the compilation process might fail in Sections 3.6.1 and/or 3.7.