Posts Tagged ‘BSP’

I’ve been doing some Linux work again lately and so it back to bootloaders. Every time I work on a new product I have to do this so I thought I’d write up a post about it. Usually the vendors provide a working u-boot source tree but more often than not it’s pretty old and I’ve been playing around with putting together a multi architecture kernel so I’d like have device tree support in my bootloader. So here is the procedure. First get the sources and start a branch for your project:

git clone git://
git checkout -b project-name

If you’re going to be working on this for multiple projects I suggest starting a fork and the easiest way to do that is with Github. Then if you want to update your master branch to the latest from U-Boot all you need to do is add a git remote and merge the changes in.

git remote add upstream git://
git fetch upstream
git checkout master
git merge upstream/master

The name upstream is just a generic name, you could call in denx or uboot or whatever you want. Next you need to create the location for your sources and the way in which U-Boot does that is in the board folder. In this folder add a folder with your company name and then a folder with the name of the project you’re working on. ./board/acme/rocket The easiest way to start with this is to copy the sources from another board which uses the same processor. Your folder will now usually look as follows:

board -> acme -> rocket.c
|-> rocket.h
\-> Makefile

Next you need to add your configuration file and tell the build system about your new project. This is again easiest done by copying the configuration file of the board that is most similar to yours. The configuration files are located in ./include/configs/rocket.h Instructing the build system is done by editing the boards.cfg file in the root. This file is kept in alphabetical order so you should add it in the same manner. It’s form is:

Status, Arch, CPU:SPLCPU, SoC, Vendor, Board name, Target, Options, Maintainers
Active, arm, armv7, am33xx, acme, rocket, rocket, -,

You may also want to add an entry to ./arch/arm/include/asm/mach-types.h so that U-Boot can tell the Linux kernel that it’s your custom board that is booting and this should be in the form #define MACH_TYPE_ROCKET 9999 Just make sure it is a unique number. That is why I usually add it as a high number as new board are being added to the sources all the time. Now you can make your changes to your configuration and board sources and when you are ready to compile just run:

make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- rocket_config
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf-

There is obviously a lot more to this process and there are a fair few edits to these instructions that may need to be made for you system but it’s a good start. I hope this is helpful to someone and if you need a hand with something similar give me a shout. I’ll write another post about the kernel and device tree when I get a chance. It really is an amazing system!