summaryrefslogtreecommitdiff
path: root/recipes-kernel/linux/linux-at91_4.9.87.bb
blob: 3b10efde3ded0207cabfeb40613dcf68dee1e0a2 (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
# AUTOLOADs are in inc files now.
require driver.inc
require crypto.inc
require net.inc

SECTION = "kernel"
DESCRIPTION = "Linux kernel for Atmel ARM SoCs (aka AT91)"
SUMMARY = "Linux kernel for Atmel ARM SoCs (aka AT91)"
LICENSE = "GPLv2"
LIC_FILES_CHKSUM = "file://COPYING;md5=d7810fab7487fb0aad327b76f1be7cd7"

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


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

PR = "r16"
PKGR_kernel-module-i2c-at91 = "${PR}a${EXTENDPRAUTO}"
PKGR_kernel-module-atmel-mci = "${PR}a${EXTENDPRAUTO}"
KERNEL_VERSION = "${PV}"
KERNEL_REVISION = "${PR}"
EXTRAVERSION = ""

SAMV = "linux4sam_5.8"
S = "${WORKDIR}/linux-at91-${SAMV}"

SRCREV = "29796588eb6a4c89795baaea3035764d15d0e44a"

KBRANCH = "linux-4.9-at91"
#SRC_URI = "git://github.com/linux4sam/linux-at91.git;protocol=git;branch=${KBRANCH}"
SRC_URI = "https://github.com/linux4sam/linux-at91/archive/${SAMV}.tar.gz"
SRC_URI[md5sum] = "09002b6b7e5a654d65ddf3fcc9574add"
SRC_URI[sha256sum] = "eaff5fdba506bef95ca57db1a53e19b6807bc9b090f97d3348b1712708c32d4e"

COMMON_PATCHES = " \
		  file://defconfig \
		  file://linux-4.9-pps-gpio.patch \
		  file://linux-4.9-at91sam9_wdt-10second-timeout.patch \
		  file://linux-4.9-spidev_squack.patch \
		  file://linux-4.9-add-num_accessory_ports-config-option.patch \
		  file://linux-4.9-cdc-acm-ignore-exar-devices.patch \
		  file://EXTRAVERSION.patch \
		  file://linux-4.9-ledtrig-netdev.patch \
		  file://linux-4.9-addl-time-for-pmeccerrloc.patch \
		  file://950-0090-OF-DT-Overlay-configfs-interface.patch \
		  file://linux-4.9-led-core-Fix-brightness-setting-when-setting-delay_off-0.patch \
		  file://linux-4.9-linux4sam-usb-serial-option.patch \
		  file://0001-linux-4.9-quectel_qmi_wwan_support.patch \
		  file://0002-linux-4.9-telit_print_qmi_wwan.patch \
		  file://make-kernel-reproducible.patch \
		  file://linux-4.9-atmel-mci-end.patch \
		  file://i2c-at91.conf \
		 "


SRC_URI_append_mtcdt = "\
            ${COMMON_PATCHES} \
            file://mtcdt.dts \
            file://mt-at91.h \
            file://linux-4.9-mtcdt-device-tree.patch \
            file://linux-4.9-mtcdt-atmel-multidrop.patch \
            file://linux-4.9-rs485-atmel-crtscts.patch \
            "
SRC_URI_append_mtrv1 = "\
            ${COMMON_PATCHES} \
            file://linux-4.9-mtrv1-device-tree.patch \
            "
SRC_URI_append_mtcap = "\
            ${COMMON_PATCHES} \
            file://linux-4.9-mtcap-device-tree.patch \
            "
SRC_URI_append_mtr = "\
            ${COMMON_PATCHES} \
            file://linux-4.9-mtr-device-tree.patch \
            file://fix-atmel-mci-reg-overloading.patch \
            file://wl12xx_enable_disable.patch \
            "
SRC_URI_append_mtre = "\
            ${COMMON_PATCHES} \
            file://linux-4.9-mtre-device-tree.patch \
            "
KERNEL_MODULE_AUTOLOAD_mtcap_append += "i2c-dev"
KERNEL_MODULE_AUTOLOAD_mtcdt_append += "i2c-dev"
KERNEL_MODULE_AUTOLOAD_append += "softdog"

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

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

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
}

# 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
}

kernel_do_configure_append() {
	rm -f ${B}/.scmversion ${S}/.scmversion
	cd ${S}; git status; cd -
}
kernel_do_configure_append_mtcdt() {
	cp ${WORKDIR}/mtcdt.dts ${S}/arch/arm/boot/dts
	cp ${WORKDIR}/mt-at91.h ${S}/arch/arm/boot/dts/include/dt-bindings/gpio
}

KERNEL_MODULE_PACKAGE_SUFFIX=""

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

pkg_preinst_kernel-image-uimage() {
    set -x
    mkdir -m 0755 /var/volatile/boot 2>/dev/null || true
    ls /boot || true
    ls -l /boot | true
    rm -rf /boot
    mkdir /boot
    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 || true
}

PACKAGES =+ "kernel-image-uimage-inst kernel-dt-bindings-dev"
# 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
}

do_install_append() {
        install -d -m 0755  ${D}${includedir}/linux
        cp -a ${STAGING_KERNEL_DIR}/include/dt-bindings ${D}${includedir}/linux/
        install -d -m 0755 ${STAGING_DIR_TARGET}/${includedir}/linux
        cp -a ${STAGING_KERNEL_DIR}/include/dt-bindings ${STAGING_DIR_TARGET}/${includedir}/linux
        install -d -m 0755 ${D}${sysconfdir}/modprobe.d
        install -m 0644 ${WORKDIR}/i2c-at91.conf ${D}${sysconfdir}/modprobe.d
}

FILES_kernel-dt-bindings-dev = "/usr/include/linux/dt-bindings"
FILES_kernel-module-i2c-at91 += "${sysconfdir}/modprobe.d/i2c-at91.conf"