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 = "6cb5b8839e5f8b9bdd69273bd396ded4f0edd09e" SRCREV_sama7g5ek = "d67f0979dcc377863060e803a2280b7a7e1a22c0" PR = "r2" KERNEL_VERSION = "${PV}" KERNEL_REVISION = "${PR}" EXTRAVERSION = "" S = "${WORKDIR}/git" KBRANCH = "linux-5.4-at91" KBRANCH_sama7g5ek-sd = "sama7g5_early" KBRANCH_sama7g5ek-emmc = "sama7g5_early" SRC_URI = "git://github.com/linux4sam/linux-at91.git;protocol=https;branch=${KBRANCH}" 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://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 \ " SRC_URI_append_mtrv1 = "\ ${COMMON_PATCHES} \ " 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}/linux-at91-5.4.81/mts-dts/${MACHINE}.dts ${S}/arch/${ARCH}/boot/dts/ cp -f ${THISDIR}/linux-at91-5.4.81/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() { 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 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 }