PA 8001 2014 Practical 0
Under Preparation; To be finalised befoer Monday
Contents
Objectives
The objectives of this practical are twofold:
- To set up and familiarise yourself with the lab environment (e.g., Raspberri Pi and ARM Cross Compiler)
- To make sure that you have understood the basic concepts of C programming required for the rest of the course
- To acquire basic familiarity with Raspberri PI bare-metal programming
- To apply basic principles of Test Driven Development
Instructions
You need to submit a single .zip file on blackboard containing the programs for Part 1 and Part 2. The two parts should be put in two different folders, named Part 1 and Part 2, respectively. Only submissions before the deadline are considered, unless you ask for a deadline extension before the deadline. You do not have to wait for an acknowledgment if you ask for an extension. You can only ask for a deadline extension for one week for at most 2 out of 5 practicals.
The practicals are based on the following two practicals:
Part 1: C Programming
Unpacking and Installing Your Raspberry Pi
Programming Bit-Vectors in C
- Create a local directory in your raspberry pi and move iregister.zip there.
- Unpack the zip file and open main.c and study the instructions.
- Include the required documentation as comments in iregister.h .
- Implement the required functions in iregister.c and the testcases in main.c .
- After compiling, linking and running the files, make sure that all the test cases have run successfully.
Part 2: Bare-Metal Programming for Raspberry Pi
In this part of the lab, you will replace the Linux operating system on Raspberry Pi with your own program. You will implement a kernel that blinks the ACT LED on Raspberry Pi. This LED is controlled by GPIO16. Thus, to blink the LED first, you need to set GPIO16 as an output; then to turn the LED on and off, you iteratively set and reset the 16th bit of GPIO6 with some delay in between. To set GPIO16 output low and high, use an iRegister and map its contents to the 4 bytes from the base address 0x20200000.
You can start with a code <lab0.c> that turn off ACT LED and modify it to a blinker using the above given instructions.
You need to compile the code using the Arm Cross Compiler with the following options:
arm-none-eabi-gcc -O2 -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -nostartfiles lab0.c -o lab0.elf
and create an image file using
arm-none-eabi-objcopy lab0.elf -O binary recovery.img
Raspberry-Pi board has two processors: a GPU to start the execution of a code and an ARM processor to run the code. The SD card already has a GPU bootloader (if not you can download it form <GPU boot>). Rename the existing recovery.img on the SD card to something else, and put the new recovery.img on the SD card using a SD card reader.