KernelDriverProgrammingCourse2015/Preparations: Difference between revisions

From RevSpace
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 108: Line 108:
then a longer commit message explaining what you're changing and why, e.g.:
then a longer commit message explaining what you're changing and why, e.g.:


###
  ###
This is a test commit
  This is a test commit
 
  In order to test git send-email we need a test commit. This commit adds such
  a test commit, fixing the lack of a test commit.


In order to test git send-email we need a test commit. This commit adds such
  Signed-off-by: Firstname Lastname <user@domain.ext>
a test commit, fixing the lack of a test commit.
  ###
 
Signed-off-by: Firstname Lastname <user@domain.ext>
###


The Signed-off-by: line has already been added by git commit, the -s flag
The Signed-off-by: line has already been added by git commit, the -s flag

Revision as of 12:26, 20 July 2015

Introduction

ARM boards, unlike x86 systems often do not have any way for the operating system to discover which hardware is present in a system. This means that the bootloader (u-boot) and the OS need to be explictly told what hardware is present, and at which addresses, irqs, etc. u-boot uses a board configuration file for this, and the kernel uses a text file called a devicetree for this.

The day will start with an introduction on devicetree files, after which you will get to work with devicetree yourself. You will be working with an ARM boards for which a driver for some component has recently been written, but not yet enabled in devicetree. The mission for the day is to modify the dts file for your board to enable these components.

sdcards with a Fedora 22 ARM image on them will be provided, but in order for these to boot your board they need to have a u-boot tailered to your board build and installed. For this you will need the u-boot sources and an arm cross compiler, the devicetree sources for your board are part of the Linux kernel, so you will need the kernel sources too.

Preparation

You will need to have a laptop with a recent Linux distribution installed, and then take the following steps to get everything in place:

1) Make sure you've at least 10 GigaByte of free space in your homedir

2) Install git (yum install git / apt-get install git)

2a) Install a devicetree compiler

On Fedora this can be installed with:

 yum install dtc

On Ubuntu:

 apt-get install device-tree-compiler 


3) Clone the u-boot and linux-kernel sources from git, since we will be needing some bits which are not yet all upstream please execute these 2 commands to clone my personal repo-s which do have the necessary bits:

 git clone https://github.com/jwrdegoede/linux-sunxi.git linux
 git clone https://github.com/jwrdegoede/u-boot-sunxi.git u-boot

Note the linux git repository is huge, this is going to take a while!

 cd linux
 git checkout -B sunxi-wip origin/sunxi-wip
 cd u-boot
 git checkout -B sunxi-wip origin/sunxi-wip

4) Install an ARM cross-compiler, see: http://linux-sunxi.org/Toolchain Note it is best to use distro packages where possible.

5) Figure out your cross-compiler prefix, do: "ls /usr/bin/arm-linux*-gcc" the prefix is the part between /usr/bin/ and -gcc, e.g. if the output is: /usr/bin/arm-linux-gnu-gcc then the prefix is arm-linux-gnu-. The rest of this document will use arm-linux-gnu- everywhere, you MUST replace this with your own prefix when entering commands!

6) Do a u-boot test-build:

 cd u-boot
 make -j4 CROSS_COMPILE=arm-linux-gnu- A10-OLinuXino-Lime_defconfig
 make -j4 CROSS_COMPILE=arm-linux-gnu-

The last lines output should be:

 OBJCOPY spl/u-boot-spl.bin
 MKSUNXI spl/sunxi-spl.bin
 CAT     u-boot-sunxi-with-spl.bin

7) Do a kernel devicetree binary (dtb) test build:

 cd linux
 wget https://fedorapeople.org/~jwrdegoede/kernel-driver-programming/kernel-config
 mv kernel-config .config
 make -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnu- oldconfig
 make -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnu- dtbs

8) Configure git so that you can send out patches, edit ~/.gitconfig and add the following lines:

 [user]
       name = Firstname Lastname
       email = user@domain.ext
 [sendemail]
       smtpserver = smtp.ziggo.nl

Note the smtpserver setting is for at revspace, at home you may need to use something else.

Now lets make your first git commit, and send it to yourself :)

 cd linux
 edit <somefile>, and make some changes.
 git commit -as

This will give you your default editor (EDITOR shell environment variable) to edit a commit message, the first line is the Subject, as with email, type a single line summary of your change here. Then and empty line, and then a longer commit message explaining what you're changing and why, e.g.:

 ###
 This is a test commit
 
 In order to test git send-email we need a test commit. This commit adds such
 a test commit, fixing the lack of a test commit.
 Signed-off-by: Firstname Lastname <user@domain.ext>
 ###

The Signed-off-by: line has already been added by git commit, the -s flag does this. This line is mandatory for any patches submitted to upstream u-boot and the kernel, it indicates that you are the author of the code changes being submitted and that you've the right to submit them, see:

http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/Documentation/SubmittingPatches

After saving the commit message and exiting your editor, you can send an email with a patch for these changes by doing:

 git send-email HEAD~

When asked for a destination email address use your own address, after sending the mail open your mail-client and check that the mail has arrived and contains what you expected.

9) All done, see you Sunday the 26th!

Regards,

Hans