summaryrefslogtreecommitdiff
path: root/recipes-kernel/linux/linux-at91_5.4.199.bb
blob: 8647ed4133c5d5914882f91dca80033ad8f8a575 (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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
SECTION = "kernel"
DESCRIPTION = "Linux kernel for Microchip ARM SoCs (aka AT91)"
SUMMARY = "Linux kernel for Microchip ARM SoCs (aka AT91)"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=bbea815ee2795b2f4230826c0c6b8814"

inherit kernel
# mts class to build dtb and append to kernel image
inherit linux-append-dtb

KERNEL_EXTRA_ARGS ="LOADADDR=0x20008000"

RDEPENDS_${KERNEL_PACKAGE_NAME}-base = ""
RDEPENDS_kernel-modules_remove = "kernel-module-softdog"
FILESEXTRAPATHS_prepend := "${THISDIR}/${P}:"

SRCREV = "ae7a63c21ca8d85578db1acef1dae5a5c803a8a3"
SRCREV_sama7g5ek = "d67f0979dcc377863060e803a2280b7a7e1a22c0"

PR = "r2"
KERNEL_VERSION = "${PV}"
KERNEL_REVISION = "${PR}"
EXTRAVERSION = ""

S = "${WORKDIR}/linux4sam-${PV}"

KBRANCH = "linux-5.4-at91"
KBRANCH_sama7g5ek-sd = "sama7g5_early"
KBRANCH_sama7g5ek-emmc = "sama7g5_early"
SRC_URI[sha256sum] = "31dbc76e89ad1b8dc2d1b7c52533411b0664e80c5e29c903878eb7167c384e55"
DEFCONFIG="${@oe.utils.conditional('BB_USE_SD', '1', 'defconfig-sd', 'defconfig-n', d)}"

SRC_URI = "https://www.multitech.net/mlinux/sources/linux4sam-${PV}.tar.xz"
SRC_URI += "file://${DEFCONFIG}"
SRC_URI_remove_sama7g5ek = "file://${DEFCONFIG}"

KERNEL_MODULE_PACKAGE_SUFFIX=""

COMMON_PATCHES = " \
		  file://${DEFCONFIG} \
		  file://linux-5.4-at91sam9_wdt-10second-timeout.patch \
		  file://linux-5.4-export-mmc_pwrseq_alloc.patch \
		  file://linux-5.4-spidev_squack.patch \
		  file://linux-5.4-add-num_accessory_ports-config-option.patch \
		  file://linux-5.4-cdc-acm-ignore-exar-devices.patch \
		  file://EXTRAVERSION.patch \
		  file://linux-5.4-addl-time-for-pmeccerrloc.patch \
		  file://linux-5.4-OF-DT-Overlay-configfs-interface.patch \
		  file://linux-5.4-revert-net-macb-Properly-handle-phylink-on-at91rm9200.patch \
		  file://linux-5.4-bring-back-PAE-bit-and-fix-NCFGR-values-applicable-f.patch \
		  file://linux-5.4-quiet-overlay.patch \
		  file://linux-5.4-bluetooth-connections.patch \
		  file://mt-at91.h \
"

SRC_URI_append_mtcdt = "\
            ${COMMON_PATCHES} \
            file://linux-5.4-reserve-5-bit-serial-for-multidrop.patch \
            file://linux-5.4-rs485-atmel-crtscts.patch \
            file://linux-5.4-module-taint.patch \
            "

SRC_URI_append_mtrv1 = "\
            ${COMMON_PATCHES} \
            file://linux-5.4-module-taint.patch \
            "
SRC_URI_append_mtcap = "\
            ${COMMON_PATCHES} \
            "
SRC_URI_append_mtr = "\
            ${COMMON_PATCHES} \
            file://linux-5.4-fix-atmel-mci-reg-overloading.patch \
            file://linux-5.4-wl12xx_enable_disable.patch \
            "
SRC_URI_append_mtre = "\
            ${COMMON_PATCHES} \
            "

KERNEL_MODULE_AUTOLOAD_mtcap_append += "i2c-dev"
KERNEL_MODULE_AUTOLOAD_mtcdt_append += "i2c-dev"

python __anonymous () {
    if d.getVar('UBOOT_FIT_IMAGE', True) == 'xyes':
        d.appendVar('DEPENDS', ' u-boot-mkimage-native dtc-native')
}

copy_mts_dts_files () {
    # Install MTS device tree files
    cp -f ${THISDIR}/${PN}-${PV}/mts-dts/${MACHINE}.dts ${S}/arch/${ARCH}/boot/dts/
    cp -f ${THISDIR}/${PN}-${PV}/mt-at91.h ${S}/include/dt-bindings/gpio
}

python do_unpack_append () {
    bb.build.exec_func('copy_mts_dts_files', d)
}

# Files needed to build external kernel modules.
do_shared_workdir_append() {
    install -d -m 755 ${STAGING_KERNEL_BUILDDIR}/include/config
    cp -a ${B}/include/config ${STAGING_KERNEL_BUILDDIR}/include/
    cp -a ${B}/scripts ${STAGING_KERNEL_BUILDDIR}
    echo ${PR} > ${STAGING_KERNEL_BUILDDIR}/mlinux_pr
}

do_configure_prepend() {
        # Kernel bbclass requires defconfig be named defconfig.
        cp ${WORKDIR}/${DEFCONFIG} ${WORKDIR}/defconfig
        echo "WORKDIR is ${WORKDIR} S is ${S}"
	if [ ! -f "${WORKDIR}/defconfig" ] && [ -n "${KBUILD_DEFCONFIG}" ]; then
		if [ -f "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}" ]; then
			cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${WORKDIR}/defconfig
                        bbnote "copied ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} to {$WORKDIR}"
                else
                        bbfatal "A KBUILD_DEFCONFIG '${KBUILD_DEFCONFIG}' was specified, but not present in the source tree"
                fi
        fi
}

do_configure_append() {
	frags=""
	for fragment in ${WORKDIR}/*.cfg
	do
		if [ -f ${fragment} ]; then
			cp -v ${fragment} ${B}
			frags=$frags" `basename ${fragment}`"
		fi
	done

	if [ ! -z "${frags}" ]; then
		echo "Fragments are: ${frags}"
		PATH=${S}/scripts/kconfig:${PATH}
		CFLAGS="${CFLAGS} ${TOOLCHAIN_OPTIONS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCPP="${BUILD_CPP}" CC="${KERNEL_CC}" ARCH=${ARCH} merge_config.sh -n .config ${frags}  2>&1
		if [ $? -ne 0 ]; then
			bbfatal_log "Could not configure kernel fragments: ${frags}"
		fi
	fi
}

do_deploy_append() {
	if [ "${UBOOT_FIT_IMAGE}" = "xyes" ]; then
		DTB_PATH="${B}/arch/${ARCH}/boot/dts/"
		if [ ! -e "${DTB_PATH}" ]; then
			DTB_PATH="${B}/arch/${ARCH}/boot/"
		fi

		if [ -e ${S}/arch/${ARCH}/boot/dts/${MACHINE}.its ]; then
			cp ${S}/arch/${ARCH}/boot/dts/${MACHINE}*.its ${DTB_PATH}
			cd ${DTB_PATH}
			mkimage -f ${MACHINE}.its ${MACHINE}.itb
			install -m 0644 ${MACHINE}.itb ${DEPLOYDIR}/${MACHINE}.itb
			cd -
		fi
	fi
}

DTB_APPEND_mtcdt = "mtcdt"
DTB_APPEND_mtrv1 = "mtrv1"
DTB_APPEND_mtcap = "mtcap"
DTB_APPEND_mtr = "mtr"
DTB_APPEND_mtre = "mtre"

COMPATIBLE_MACHINE = "(mtcdt|mtrv1|mtr|mtcap|mths|mtre)"

NET_LOAD_ALL_MACHINES += " \
	8021q \
	bnep \
	br_netfilter \
	dns_resolver \
	garp \
	ip6_gre \
	ip6table_filter \
	ip6table_mangle \
	ip6table_nat \
	ip6table_raw \
	ip6t_ah \
	ip6t_eui64 \
	ip6t_frag \
	ip6t_hbh \
	ip6t_ipv6header \
	ip6t_MASQUERADE \
	ip6t_mh \
	ip6t_NPT \
	ip6t_REJECT \
	ip6t_rpfilter \
	ip6t_rt \
	ip6t_SYNPROXY \
	ip6_vti \
	ipip \
	iptable_mangle \
	iptable_nat \
	iptable_netfilter \
	iptable_raw \
	ip_tables \
	ipt_ah \
	ip_vs \
	l2tp_ppp \
	mac80211 \
	mrp \
	nf_conntrack_ipv4 \
	nf_conntrack_ipv6 \
	nf_conntrack_netbios_ns \
	nf_conntrack_netlink \
	nf_log_ipv4 \
	nf_log_ipv6 \
	nf_nat_ftp \
	nf_nat_h323 \
	nf_nat_pptp \
	nf_nat_sip \
	nf_nat_snmp_basic \
	nfnetlink_cttimeout \
	nf_tables_inet \
	nf_tables_netdev \
	nft_exthdr \
	nft_meta \
	p8022 \
	psnap \
	rfcomm \
	rfkill-gpio \
	rfkill-regulator \
	sit \
	tun \
	xfrm6_mode_tunnel \
	xt_CLASSIFY \
	xt_connmark \
	xt_conntrack \
	xt_CT \
	xt_ecn \
	xt_esp \
	xt_hashlimit \
	xt_hl \
	xt_HL \
	xt_iprange \
	xt_l2tp \
	xt_LED \
	xt_limit \
	xt_LOG \
	xt_mac \
	xt_mark \
	xt_multiport \
	xt_nat \
	xt_NETMAP \
	xt_NFLOG \
	xt_NFQUEUE \
	xt_policy \
	xt_recent \
	xt_REDIRECT \
	xt_set \
	xt_state \
	xt_tcpudp \
	xt_TEE \
	xt_time \
	xt_TPROXY \
	ledtrig-netdev \
"

DRIVER_LOAD_ALL_MACHINES =  " \
	atmel_usba_udc \
	ledtrig-default-on \
	ledtrig-heartbeat \
	ledtrig-timer \
"

KERNEL_MODULE_AUTOLOAD_mtcdt += " \
	g_serial \
	softdog \
"

KERNEL_MODULE_AUTOLOAD_mtcdt += " \
	${NET_LOAD_ALL_MACHINES} \
	${DRIVER_LOAD_ALL_MACHINES} \
"
KERNEL_MODULE_AUTOLOAD_mtrv1 += " \
	${NET_LOAD_ALL_MACHINES} \
	${DRIVER_LOAD_ALL_MACHINES} \
"
KERNEL_MODULE_AUTOLOAD_mtr += " \
	${NET_LOAD_ALL_MACHINES} \
	${DRIVER_LOAD_ALL_MACHINES} \
"
KERNEL_MODULE_AUTOLOAD_mtcap += " \
	${NET_LOAD_ALL_MACHINES} \
	${DRIVER_LOAD_ALL_MACHINES} \
"
KERNEL_MODULE_AUTOLOAD_mtre += " \
	${NET_LOAD_ALL_MACHINES} \
	${DRIVER_LOAD_ALL_MACHINES} \
"

# Never delete /boot, as it poisons the overlay
# and you cannot get it back.
pkg_preinst_kernel-image-uimage() {
    set -x
    if [ -d /boot ] ; then
        cd /boot
        rm -rf /boot/{*,.*} 2>/dev/null || true
    else
        mkdir -m 0755 /boot
    fi
    mkdir -m 0755 /var/volatile/boot 2>/dev/null || true
    mount -o bind /var/volatile/boot /boot
}

pkg_prerm_kernel-image-uimage() {
        umount -lf /boot || true
        rm -rf /var/volatile/boot || true
        rm -rf /boot/{*,.*} 2>/dev/null || true
}

PACKAGES =+ "kernel-image-uimage-inst"
# Not sure how to get the name below generated automatically
RDEPENDS_kernel-image-uimage-inst += "kernel-image-uimage-${PV}"
ALLOW_EMPTY_kernel-image-uimage-inst = "1"

pkg_postinst_kernel-image-uimage-inst() {
	# Only installs all the kernel on the device (D is defined in bitbake)
	if [[ -z "$D" ]] ; then
	    logger -s -p user.info -t opkg "Upgrading kernel ${PV} -- poweroff will create an unbootable device"
	    set -x
	    kernel_mtd="/dev/$(cat /proc/mtd | grep '\"uImage\"' | cut -d : -f 1)"
	    flash_erase ${kernel_mtd} 0 0
	    if nandwrite -p ${kernel_mtd} /boot/uImage-${PV} ; then
                echo 'Kernel image update is successful'
            fi
	    set +x
	fi
}