Presentation is loading. Please wait.

Presentation is loading. Please wait.

Computer System Laboratory

Similar presentations


Presentation on theme: "Computer System Laboratory"— Presentation transcript:

1 Computer System Laboratory
Lab2 - Bootloader / 20

2 Experimental Goal Cross-compile U-Boot.
Connect to Raspberry Pi via an USB-TTL cable. Boot Raspberry Pi via U-Boot. / 20

3 Environment Host Machine Target Machine Build Machine OS: Windows
Raspberry Pi (2 or 3) Build Machine A computer with a SD card slot OS: Ubuntu (or above) 64-bit / 20

4 Software Required Host Machine Build Machine
PL2303 Driver PuTTY Build Machine U-Boot Source Code Prebuilt Raspberry Pi Firmware Raspberry Pi bootloader configuration (config.txt) GCC Cross-Compiler targeting ARM GParted You may find all software on the CSL Course Software. / 20

5 Hardware Checklist Raspberry Pi Power supply
Micro SD card and card reader USB-TTL cable / 20

6 Overview In Lab1, we installed the official OS on RPi, and prepared an additional set of I/O components for RPi to interact with it. In this lab, we treat RPi as an embedded device. First, we cross-compile U-Boot, a bootloader for embedded systems, in the build machine and copy it to the SD card of RPi. Second, we plug a serial cable between RPi and the host machine, and open a terminal in the host machine to interact with RPi. Third, we boot RPi via the bootloader (no OS kernel yet). / 20

7 Cross Compilation Many embedded systems do not have user interfaces nor compilers to build programs. As the result, people build programs for embedded systems in another machine, and then copy the built programs to the storage devices used by embedded systems. A compiler that compiles programs for other platforms is call a “cross-compiler”, and a machine that runs cross-compilers is called a “build machine”. Even if the ISA of the build machine is the same as the ISA of the machine on which the built programs run, the cross-compiler is still more suitable than the native compiler in the build machine. The reason is left for the Lab question. You may reference the article in the reference page. / 20

8 Setup the ARM Cross-Compiler
In the build machine, install the GCC cross-compiler toolchain. % sudo apt-get update % sudo apt-get install build-essential lzop u-boot-tools bc curl libncurses5-dev % sudo apt-get install lib32z1 lib32ncurses5 lib32bz lib32stdc # ignore lib32bz2-1.0 in Ubuntu 16.04 % sudo apt-get install gcc-arm-linux-gnueabihf Set environment variables. % export ARCH=arm % export CROSS_COMPILE=arm-linux-gnueabihf- / 20

9 Check the Cross-Compiler
The target is arm-linux-gnueabihf. Version above 4.9.x is required. (Ubuntu has a GCC.) Execute the following command to check. % arm-linux-gnueabihf-gcc -v / 20

10 Build U-Boot Download and extract the U-Boot source code.
Configure and start compiling. % cd u-boot % make clean % make rpi_2_defconfig % make # You may append –j<n> to accelerate. For example, you execute “make –j4” if you have 4 CPUs. After the process finishes, you get the U-Boot image named u-boot.bin. / 20

11 Format the SD card (1) Install and launch GParted.
% sudo apt-get install gparted % sudo gparted Unmount and than delete the original partitions. / 20

12 Format the SD card (2) Create two partitions.
1st partition: filesystem = fat32, size = 64MiB, label = boot 2nd partition: filesystem = ext4, size = all remained space, label = root / 20

13 Format the SD card (3) Apply all operations. / 20

14 Setup the Boot Partition (1)
Download and extract the Raspberry Pi firmware. Copy the U-Boot image to the boot directory and rename it. % cp u-boot /u-boot.bin firmware /boot/uboot.img Download config.txt to the boot directory. Replace the line “#kernel=” with “kernel=uboot.img”. The value of the “kernel” variable should match the filename of the U-Boot image (i.e. uboot.img without quotes). / 20

15 Setup the Boot Partition (2)
Copy all files in the boot directory to the 1st partition of the SD card. Now your SD card is bootable. Eject the SD card and plug it to RPi. / 20

16 Plug the USB-TTL Cable There are several modules of USB-TTL. The one we use is PL2303. In the host machine, download and install the PL2303 driver. Plug the USB-TTL cable between RPi and the host machine. USB-TTL GND (black)  GPIO GND (pin6) USB-TTL RX (white)  GPIO TXD0 (pin8) USB-TTL TX (green)  GPIO RXD0 (pin10) / 20

17 Connect to Raspberry Pi
If you have installed the PL2303 driver, you will find a new COM port in the device manager after you plug the USB-TTL cable. Launch PuTTY. Enter the following options and click open. There is nothing output yet since the RPi is not on. Connection type = Serial Serial port = the COM port Speed = / 20

18 Boot Successfully Plug the RPi power supply to turn on RPi. You will see the message in PuTTY. Hit any key to stop autoboot in 2 seconds, and you will drop into the U-Boot command line. / 20

19 Lab Requirement Show that you can execute some U-Boot commands. / 20

20 Reference Why do I need a Cross Compiler?
Das U-Boot -- the Universal Boot Loader config.txt - Raspberry Pi Documentation USB to TTL / 20


Download ppt "Computer System Laboratory"

Similar presentations


Ads by Google