summaryrefslogtreecommitdiffstats
path: root/scripts/lib/ptxd_make_xilinx_bsp.sh
blob: 117f5318f5ae8df69529a842150653b10430b9b4 (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
#
# Copyright (C) 2011-2012 by Stephan Linz <linz@li-pro.net>
#
# See CREDITS for details about who has contributed to this project.
#
# For further information about the PTXdist project and license conditions
# see the README file.
#

#
# apply project files (remove old, link new)
#
ptxd_make_xilinx_bsp_apply_files()
{
    local ptx_xlbsp_dir
    local pkg_xlbsp_file
    local pkg_xlbsp_files

    if [ $# -ne 2 ]; then
	echo "xlbsp: ${pkg_xlbsp_apply}: missing arguments (<dir>,<filelist>)"
	return
    fi
    ptx_xlbsp_dir="${1}"
    pkg_xlbsp_files="${2}"

    echo "xlbsp: ${pkg_xlbsp_apply}: board '$(ptxd_print_path "${ptx_xlbsp_dir:-<none>}")'"
    pushd "${ptx_xlbsp_dir}" > /dev/null &&
    for pkg_xlbsp_file in ${pkg_xlbsp_files}; do
	echo "xlbsp: ${pkg_xlbsp_apply}: rm/ln '$(ptxd_print_path "${pkg_xlbsp_file:-<none>}")'"

	local pkg_file="$(basename "${pkg_xlbsp_file}")" &&
	ln -sf ${pkg_xlbsp_file} ${pkg_file}

    done &&
    popd > /dev/null
}
export -f ptxd_make_xilinx_bsp_apply_files

# apply Xilinx BSP for U-Boot
#
ptxd_make_xilinx_bsp_apply_uboot()
{
    local ptx_xlbsp_uboot_cfg="$(ptxd_get_ptxconf PTXCONF_U_BOOT_CONFIG)"
    local pkg_xlbsp_uboot_files="${pkg_xlbsp_dir}config.mk		\
				 ${pkg_xlbsp_dir}xparameters.h"
    local pkg_xlbsp_uboot_file
    local ptx_xlbsp_uboot_dir

    # find ptx_xlbsp_uboot_dir
    if ! ptxd_get_path "${pkg_build_dir}/board/xilinx/${ptx_xlbsp_uboot_cfg%%_config}"; then
	echo "xlbsp: ${pkg_xlbsp_apply}: no board path found"
	return
    fi
    ptx_xlbsp_uboot_dir="${ptxd_reply}"

    # apply files (remove old, link new)
    ptxd_make_xilinx_bsp_apply_files "${ptx_xlbsp_uboot_dir}" "${pkg_xlbsp_uboot_files}"
}
export -f ptxd_make_xilinx_bsp_apply_uboot

#
# apply Xilinx BSP for Linux kernel 2.x / 3.x
#
ptxd_make_xilinx_bsp_apply_kernel()
{
    local ptx_xlbsp_kernel_arch="$(ptxd_get_ptxconf PTXCONF_KERNEL_ARCH_STRING)"
    local pkg_xlbsp_kernel24_files="${pkg_xlbsp_dir}auto-config.in"
    local pkg_xlbsp_kernel26_files="${pkg_xlbsp_dir}Kconfig.auto"
    local ptx_xlbsp_kernel_platform
    local pkg_xlbsp_kernel_files
    local pkg_xlbsp_kernel_file
    local ptx_xlbsp_kernel_dir

    # files and platform to use per version
    case "${pkg_pkg}" in
	linux-24*|linux-2.4*)
	    pkg_xlbsp_kernel_files=${pkg_xlbsp_kernel24_files};
	    ptx_xlbsp_kernel_platform="uclinux-auto";
	    ;;
	linux-26*|linux-2.6*|linux-3*)
	    pkg_xlbsp_kernel_files=${pkg_xlbsp_kernel26_files};
	    ptx_xlbsp_kernel_platform="generic";
	    ;;
	*)
	    echo "xlbsp: ${pkg_xlbsp_apply}: unsupported kernel version: ${pkg_pkg##linux-}"
	    return
	    ;;
    esac

    # find ptx_xlbsp_kernel_dir
    if ! ptxd_get_path "${pkg_build_dir}/arch/${ptx_xlbsp_kernel_arch}/platform/${ptx_xlbsp_kernel_platform}"; then
	echo "xlbsp: ${pkg_xlbsp_apply}: no board path found"
	return
    fi
    ptx_xlbsp_kernel_dir="${ptxd_reply}"

    # apply files (remove old, link new)
    ptxd_make_xilinx_bsp_apply_files "${ptx_xlbsp_kernel_dir}" "${pkg_xlbsp_kernel_files}"
}
export -f ptxd_make_xilinx_bsp_apply_kernel

#
# generic apply Xilinx BSP function
#
ptxd_make_xilinx_bsp_apply()
{
    local pkg_xlbsp_dir
    local pkg_xlbsp_apply

    ptxd_in_path PTXDIST_PATH_PLATFORMS_XLBSP || return
    pkg_xlbsp_dir="${ptxd_reply}"

    # files to use per package
    case "${pkg_pkg}" in
	u-boot*)
	    pkg_xlbsp_apply="uboot";
	    ;;
	linux*)
	    pkg_xlbsp_apply="kernel";
	    ;;
	*)
	    echo "xlbsp: unsupported package: ${pkg_pkg}"
	    return
	    ;;
    esac

    echo "pkg_xlbsp_dir:     '$(ptxd_print_path "${pkg_xlbsp_dir:-<none>}")'"
    echo "pkg_build_dir:     '$(ptxd_print_path "${pkg_build_dir:-<none>}")'"
    echo

    # apply Xilinx BSP per package if files are available
    if [ -n "${pkg_xlbsp_apply}" ]; then
	echo    "xlbsp: ${pkg_xlbsp_apply}: apply '$(ptxd_print_path "${pkg_xlbsp_dir:-<none>}")'"
	"ptxd_make_xilinx_bsp_apply_${pkg_xlbsp_apply}" || return
	echo -e "xlbsp: ${pkg_xlbsp_apply}: done\n"
    fi
}
export -f ptxd_make_xilinx_bsp_apply

#
# copy and adjust per package
#
ptxd_make_xilinx_bsp() {
    ptxd_make_world_init || return
    ptxd_make_xilinx_bsp_apply
}
export -f ptxd_make_xilinx_bsp