aboutsummaryrefslogtreecommitdiffstats
path: root/classes/xilinx-kernel.bbclass
blob: 198033f7976416619fe0d2dc328863bf8cac193a (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
# Copyright (C) 2007, Stelios Koroneos - Digital OPSiS, All Rights Reserved
# Copyright (C) 2010, Adrian Alonso <aalonso00@gmail.com>
# Released under the MIT license (see packages/COPYING)
#
#This class handles all the intricasies of getting the required files from the
#ISE/EDK/project to the kernel and prepare the kernel for compilation.
#The Xilinx EDK supports 2 different architectures : PowerPC (ppc 405,440) and Microblaze
#Only the PowerPC BSP has been tested so far
#For this to work correctly you need to add XILINX_BSP_PATH and XILINX_BOARD to your
#local.conf
#XILINX_BSP_PATH should have the complete path to your project dir
#XILINX_BOARD should have the board type i.e ML403
#
#Currently tested on
#Xilinx ML405
#Xilinx ML507
#More to come soon ;)

def device_tree(a, d):
    # Device tree helper function
    import re

    board = bb.data.getVar('XILINX_BOARD', d, 1)
    cpu = bb.data.getVar('TARGET_CPU', d, 1)
    if re.match('powerpc', a):
        target = cpu + '-' + board
        dts = '${S}/arch/' + a + '/boot/dts/virtex' + target + '.dts'
    else:
        target = 'system'
        dts = '${S}/arch/' + a + '/boot/dts/' + target + '.dts'

    bb.data.setVar('KERNEL_TARGET', target, d)
    return dts


do_configure_prepend() {
if [ "${KERNEL_DEVICETREE}" ]; then
   bbnote "Using linux kernel device tree in: ${KERNEL_DEVICETREE}"
   exit 0
fi

#first check that the XILINX_BSP_PATH and XILINX_BOARD have been defined in local.conf
#now depending on the board type and arch do what is nessesary
if [ -n "${XILINX_BSP_PATH}" ]; then
	if [ "${XILINX_BOARD}" != "unknown" ]; then
		dts=`find "${XILINX_BSP_PATH}" -name *.dts -print`
		if [ -e "$dts" ]; then
			bbnote "Xilinx BSP device tree located in: ${dts}"
			if [ "${TARGET_ARCH}" = "powerpc" ]; then
				bbnote "Replacing linux kernel powerpc device tree to match located hardware model: virtex${KERNEL_TARGET}.dts"
				cp -pP ${dts} ${S}/arch/powerpc/boot/dts/virtex${KERNEL_TARGET}.dts
			else
				bbnote "Replacing linux kernel microblaze device tree to match located hardware model: ${KERNEL_TARGET}.dts"
				cp -pP ${dts} ${S}/arch/microblaze/platform/generic/${KERNEL_TARGET}.dts
			fi
		else
			bbfatal "No device tree found, missing hardware ref design?"
			exit 1
		fi
	else
		bbnote "Xilinx board model: ${XILINX_BOARD}"
        bbfatal "XILINX_BSP_PATH points to a valid Xilinx XPS project directory? ! Exit"
		exit 1
	fi
else
	bbfatal "XILINX_BSP_PATH not defined ! Exit"
	exit 1
fi
}