summaryrefslogtreecommitdiff
path: root/docs/adding-boards.txt
blob: b04552fb5fd25457445962659ffd8ab70457fb33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
// -*- mode:doc; -*-
// vim: set syntax=asciidoc:

[[adding-boards]]
Adding new embedded boards to OpenADK
-------------------------------------

This section covers how support for new embedded boards
can be integrated into OpenADK. 

First step is to create a board description file in
target/<arch>/systems with the short name of your embedded board.

For example you would create following file for Raspberry PI 2 support:
target/arm/systems/raspberry-pi2
---------------------
config ADK_TARGET_SYSTEM_RASPBERRY_PI2
        bool "Raspberry PI 2"
        select ADK_CPU_CORTEX_A7
        select ADK_TARGET_LITTLE_ENDIAN
        select ADK_TARGET_CPU_WITH_NEON
        select ADK_TARGET_BOARD_BCM28XX
        select ADK_TARGET_WITH_VGA
        select ADK_TARGET_WITH_SERIAL
        select ADK_TARGET_WITH_CPU_FREQ
        select ADK_TARGET_WITH_USB
        select ADK_TARGET_WITH_INPUT
        select ADK_TARGET_WITH_SD
        select ADK_TARGET_WITH_I2C
        select ADK_TARGET_WITH_SPI
        select ADK_TARGET_WITH_SMP
        select ADK_PACKAGE_BCM28XX_BOOTLOADER
        select ADK_TARGET_WITH_ROOT_RW
        select ADK_TARGET_KERNEL_ZIMAGE
        help
          Raspberry PI 2
------------------------

You need to select as a minimum a CPU type and Kernel format. 
If a bootloader is required you also need to select it.
(ADK_PACKAGE_BCM28XX_BOOTLOADER) If the bootloader does not exist as a package
in OpenADK, you need to port it first.

The hardware capabilities are optional. (f.e. ADK_TARGET_WITH_SD), but
required when you configure the driver configuration later.

For architectures with a choice for endianess you should select either
ADK_TARGET_LITTLE_ENDIAN or ADK_TARGET_BIG_ENDIAN.

If the CPU type like in this example ADK_CPU_CORTEX_A7 is not yet available
you need to add it to target/config/Config.in.cpu. For optimized code generation
you should also add ADK_TARGET_GCC_CPU or ADK_TARGET_GCC_ARCH symbol for your CPU
type. Furthermore you need to decide if your CPU has a MMU, FPU and NPTL support
in the C library.

After the creation of the file you can go into the menu based system and
select your embedded board.

The second step is to create a Kernel configuration file fragment, which contains
only the basic support for your board to get serial console access.

For example the snippet for Raspberry PI 2:
target/arm/kernel/raspberry-pi2
------------------------
CONFIG_ARM=y
CONFIG_ARM_PATCH_PHYS_VIRT=y
CONFIG_ARCH_MULTI_V7=y
CONFIG_ARCH_BCM2709=y
CONFIG_MACH_BCM2709=y
CONFIG_FIQ=y
CONFIG_SERIAL_AMBA_PL011=y
CONFIG_SERIAL_AMBA_PL011_CONSOLE=y
------------------------

The kernel file must be registered in target/config/Config.in.kernel
------------------------
config ADK_TARGET_KERNEL_MINICONFIG
        string
	...
	default "raspberry-pi2" if ADK_TARGET_SYSTEM_RASPBERRY_PI2
------------------------

If the mainstream kernel from kernel.org does not contain support for your board
you need to get a working kernel tree and create a patch.
For example for Raspberry PI 2 we basically use following method to create a patch:
------------------------
git clone https://github.com/raspberrypi/linux.git linux-rpi
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.18.9.tar.xz
tar xvf linux-3.18.9.tar.xz
find linux-3.18.9 linux-rpi -type l -delete
rm -rf linux-rpi/.git
diff -Nur linux-3.18.9 linux-rpi > target/arm/bcm28xx/patches/3.18.9/0000-raspberry-pi.patch
------------------------

Normally you use target/<arch>/<target system>/patches/<kernelversion>/0000-<target-system>.patch.
In case of Raspberry PI 2 we have a single patch for Raspberry PI and Raspberry PI 2 and use
the extra board name bcm28xx to describe the family of devices.

After that you can build the toolchain, kernel and base system and write the resulting
firmware from firmware/<target system>/ to your device or boot via netboot and NFS.

If you have some special notes for your embedded board, please add some advise to
target/<arch>/Makefile. You can add information for the different rootfilesystem types.

If your system boots up fine to a shell, you can add the driver configuration.
For example if you add SD card driver support to Raspberry PI 2 you
would add following to target/linux/config/Config.in.block
------------------------
config ADK_KERNEL_MMC_BCM2835
        bool "SD card support for BCM2835 boards"
        select ADK_KERNEL_SCSI
        select ADK_KERNEL_MMC
        select ADK_KERNEL_MMC_BLOCK
        select ADK_KERNEL_BLK_DEV
        select ADK_KERNEL_BLK_DEV_SD
        select ADK_KERNEL_MMC_SDHCI
        select ADK_KERNEL_MMC_SDHCI_PLTFM
        select ADK_KERNEL_MMC_BCM2835_DMA
        depends on ADK_TARGET_BOARD_BCM28XX
        default y if ADK_TARGET_BOARD_BCM28XX
        default n
------------------------

We use the symbol prefix ADK_KERNEL instead of CONFIG. Otherwise the symbols are
matching the kernel symbol names.

Get again into the menu based system, enable the driver you added and recompile.
If your driver is available as kernel module use tristate.