summaryrefslogtreecommitdiff
path: root/classes/xilinx-bsp.bbclass
blob: eb47634da23df4e8c46f2293a6c5a198616fcb39 (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
# 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 map_target(a, d):
	import re
	board = bb.data.getVar('XILINX_BOARD', d, 1)
	cpu = bb.data.getVar('TARGET_CPU', d, 1)

	if re.match('powerpc', a):
		return 'ppc' + cpu + '-' + board
	else:
		return 'system'

def uboot_machine(a, d):
    import re

    board = bb.data.getVar('XILINX_BOARD', d, 1)
    if board in ['ml300', 'ml401', 'ml403', 'ml405', 'ml507', 'ml510']:
        if re.match('powerpc', a):
            if board == 'ml403':
                return 'ml401_config'
            elif board == 'ml510':
                return 'ml507_config'
            else:
                return board + '_config'
        else:
            return 'microblaze-generic_config'

def uboot_target(a, d):
    import re

    board = bb.data.getVar('XILINX_BOARD', d, 1)
    target = bb.data.getVar('TARGET_CPU', d, 1) + '-generic'
    if board in ['ml300', 'ml401', 'ml403', 'ml405', 'ml507', 'ml510']:
        if re.match('powerpc', a):
            if board == 'ml403':
                return 'ml401'
            elif board == 'ml510':
                return 'ml507'
            else:
                return board
        else:
            return target

do_configure_prepend() {
#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 [ -n "${XILINX_BOARD}" ]; then
		if [ -d "${S}/arch/${TARGET_ARCH}/boot" ]; then
			dts=`find "${XILINX_BSP_PATH}" -name *.dts -print`
			if [ -e "$dts" ]; then
				oenote "Replacing device tree to match hardware model"
				if [ "${TARGET_ARCH}" == "powerpc" ]; then
					cp -pP ${dts} ${S}/arch/powerpc/boot/dts/virtex${TARGET_BOARD}.dts
				else
					cp -pP ${dts} ${S}/arch/microblaze/platform/generic/${TARGET_BOARD}.dts
				fi
			else
				oefatal "No device tree found, missing hardware ref design?"
				exit 1
			fi
		elif [ -d "${S}/board/xilinx" ]; then
			oenote "Replacing xparameters header to match hardware model"
			if [ "${TARGET_ARCH}" == "powerpc" ]; then
				xparam="${XILINX_BSP_PATH}/ppc${TARGET_CPU}_0/include/xparameters.h"
				cpu="PPC`echo ${TARGET_CPU} | tr '[:lower:]' '[:upper:]'`"
			else
				xparam="${XILINX_BSP_PATH}/${TARGET_CPU}_0/include/xparameters.h"
				cpu=`echo ${TARGET_CPU} | tr '[:lower:]' '[:upper:]'`
			fi
			if [ -e "$xparam" ]; then
				cp ${xparam} ${S}/board/xilinx/${UBOOT_TARGET}
				echo "/*** Cannonical definitions ***/
#define XPAR_PLB_CLOCK_FREQ_HZ XPAR_PROC_BUS_0_FREQ_HZ
#define XPAR_CORE_CLOCK_FREQ_HZ XPAR_CPU_${cpu}_CORE_CLOCK_FREQ_HZ
#ifndef XPAR_DDR2_SDRAM_MEM_BASEADDR
# define XPAR_DDR2_SDRAM_MEM_BASEADDR XPAR_DDR_SDRAM_MPMC_BASEADDR
#endif
#define XPAR_PCI_0_CLOCK_FREQ_HZ    0" >> ${S}/board/xilinx/${UBOOT_TARGET}/xparameters.h
			else
				oefatal "No xparameters header file found, missing hardware ref design?"
                exit 1
			fi
		fi
	else
		oefatal "XILINX_BOARD not defined ! Exit"
		exit 1
	fi
else
	oefatal "XILINX_BSP_PATH not defined ! Exit"
	exit 1
fi
}

do_deploy_prepend() {
# Install u-boot elf image
if [ -d "${XILINX_BSP_PATH}" ]; then
	if [ -e "${S}/u-boot" ]; then
		install ${S}/u-boot ${XILINX_BSP_PATH}
	fi
fi
}