world leader in high performance signal processing
Trace: » customizing_for_your_board

Porting Linux To Your Board

While we try to keep drivers as CPU and hardware agnostic as possible, there's a point where the kernel needs to know what resources a specific board actually has allocated. Things like which pin a peripheral hooks up to simply cannot be deduced dynamically. Besides, considering these sort of resources never change once the hardware has been laid out, it's not that big of a deal and in theory simply adds runtime overhead by detecting the same exact setup every time you boot the kernel.

In this document, we'll cover the places in the Linux kernel which you will need to customize for your specific board.

You will have to replace CPU with the Blackfin CPU family you're using and BOARD with the name of your board. Here we'll create a new board called “foober” that has a BF537 on it.


In order to make the board appear in the kernel configuration menu, we need to update the Kconfig file. Open up the arch/blackfin/mach-bf537/boards/Kconfig file and update the System type choice section.

	prompt "System type"
config BFIN537_FOOBER
	bool "BF537-FOOBER"
	depends on (BF537)
	  The FOOBER board that has a BF537 on it.

If your board will only work with a certain processor variant, then list them on the depends line. If you want to be able to build for all possible variants, just omit the depends line completely. For information on Kconfig syntax, see the Documentation/kbuild/kconfig-language.txt file.

Once you've added your board here, it will show up in the kernel configuration:

Blackfin Processor Options --->
  CPU (BF537)
  System type (BF537-FOOBER)


The kernel needs to know what source files to include when compiling the kernel, so we need to add one line to the arch/blackfin/mach-bf537/boards/Makefile:

obj-$(CONFIG_BFIN537_FOOBER) += foober.o

Now the kernel knows that when you select the BF537-FOOBER board, it should compile the foober.c file in the arch/blackfin/mach-bf537/boards/ directory.

Board Resources

The last (and most important) step is declaring your board resources. This is done in a board-specific file, arch/blackfin/mach-bf537/boards/foober.c in this case.

We provide a generic board file for you to get started with, generic_board.c, so just copy that if you like. It's as simple as:

$ cp arch/blackfin/mach-bf537/boards/generic_board.c arch/blackfin/mach-bf537/boards/foober.c

The tough part of course is changing the file to match your board. The general setup of the file looks like:

  • bfin_board_name - a short string describing the board
  • board_devices - an array of platform_devices
  • board_init - an arch_initcall() function that performs board registration (registers the devices)

So some pseudo code:

/* #include all the headers you need */
char *bfin_board_name = "foober";
/* peripheral resources; see specific peripheral documents */
static struct platform_device *board_devices[] __initdata = {
	/* pointers to peripheral structures */
static int __init board_init(void)
	printk(KERN_INFO "%s(): registering device resources\n", __func__);
	platform_add_devices(board_devices, ARRAY_SIZE(board_devices));
	/* any other board-specific setup needed */
	return 0;

Since the actual resources declared vary greatly between peripherals and drivers, for more information please refer to the example generic board and to the peripheral-specific documents in this wiki.

Default Configuration

You can create a default configuration file for your board so that you can have a known good “reference” configuration file tucked away for safe keeping and distribution.

To create the first .config file, you can use any other board as a starting point (preferably one similar to yours), and then customize it like normal using kconfig:

$ make menuconfig

Then simply take that configuration file you know works, and drop it into the right place:

$ cp .config arch/blackfin/configs/BF537-FOOBER_defconfig

All you have to do in the future to get the default kernel settings for your board is run:

$ make BF537-FOOBER_defconfig

This will setup the default kernel .config file for you.