├── recipes-connectivity ├── bluetooth │ ├── files │ │ ├── rockpi-e-rk3328 │ │ │ └── blacklist-bt.conf │ │ ├── rockpi-s-rk3308 │ │ │ ├── install_module_hci_uart │ │ │ ├── install-module-hci-uart.service │ │ │ └── rtl8723ds-btfw-load.service │ │ └── broadcom-bluetooth │ │ │ ├── brcm-btfw-update.service │ │ │ ├── brcm-btfw-load.service │ │ │ └── update-brcm-btfw-load-service.sh │ ├── bluetooth-rockpi-e.bb │ ├── bluetooth-rockpi-s.bb │ └── bluetooth-broadcom.bb └── networkmanager │ ├── networkmanager │ └── NetworkManager.conf │ └── networkmanager_1.18.4.bbappend ├── recipes-bsp ├── u-boot │ ├── files │ │ ├── rockpi-px30 │ │ │ ├── uEnv.txt │ │ │ └── boot.cmd │ │ ├── rockpi-e-rk3328 │ │ │ ├── uEnv.txt │ │ │ └── boot.cmd │ │ ├── rockpi-s-rk3308 │ │ │ ├── uEnv.txt │ │ │ └── boot.cmd │ │ ├── rockpi-n10-rk3399pro │ │ │ ├── uEnv.txt │ │ │ └── boot.cmd │ │ ├── 0001-Use-local-command.h-file-instead-of-system-file.patch │ │ ├── 0002-Suppress-maybe-uninitialized-warning.patch │ │ └── 0001-Makefile-disable-gcc9-s-address-of-packed-member-war.patch │ ├── u-boot-rockpi-e.bb │ ├── u-boot-common-radxa.inc │ ├── u-boot-rockpi-s.bb │ ├── u-boot-rockpi-4.bb │ ├── u-boot-rockpi-px30.bb │ ├── u-boot-rockpi-n10.bb │ ├── u-boot-mkimage-radxa.bb │ └── u-boot-rockpi.inc ├── resize-helper │ ├── files │ │ ├── resize-helper.service │ │ └── resize-helper │ └── resize-helper.bb └── rk-binary │ ├── radxa-binary-native_git.bb │ └── radxa-binary-loader_git.bb ├── recipes-core ├── busybox │ ├── busybox_%.bbappend │ └── busybox │ │ └── 0001-Add-support-reboot-loader-command.patch ├── images │ ├── radxa-console-image.bb │ ├── radxa-minimal-image.bb │ └── radxa-desktop-image.bb ├── udev │ ├── udev-extraconf │ │ └── 10-rk.rules │ └── udev-extraconf_%.bbappend └── packagegroups │ └── packagegroup-radxa-console.bb ├── conf ├── machine │ ├── rockpi-4a-rk3399.conf │ ├── rockpi-4b-rk3399.conf │ ├── rockpi-4c-rk3399.conf │ ├── include │ │ └── rockpi-4.inc │ ├── rockpi-px30.conf │ ├── rockpi-s-rk3308.conf │ ├── rockpi-e-rk3328.conf │ └── rockpi-n10-rk3399pro.conf ├── layer.conf ├── bblayers.conf.sample └── local.conf.sample ├── recipes-devtools ├── brcm-tools │ ├── files │ │ ├── Makefile │ │ ├── dhd_priv.c │ │ └── brcm_patchram_plus1.c │ └── brcm-tools.bb ├── rtl-tools │ ├── files │ │ ├── Makefile │ │ ├── hciattach.h │ │ └── hciattach.c │ └── rtl-tools.bb ├── mraa-radxa │ └── mraa-radxa_git.bb └── create-ap │ └── create-ap_git.bb ├── recipes-kernel ├── linux │ ├── files │ │ ├── 0001-Makefile-disable-gcc9-s-address-of-packed-member-war.patch │ │ ├── 0001-Fix-GCC-9-Wmissing-attributes-warnings-error.patch │ │ └── 0001-UPSTREAM-arm64-vdso-Define-vdso_-start-end-as-array.patch │ ├── linux-rockpi-e_4.4.bb │ ├── linux-rockpi-4_4.4.bb │ ├── linux-rockpi-s_4.4.bb │ ├── linux-rockpi-px30_4.4.bb │ └── linux-rockpi-n10_4.4.bb ├── kernel-module-headers │ ├── kernel-module-headers.bb │ └── files │ │ └── gen_mod_headers └── rkwifibt-firmware │ └── rkwifibt-firmware.bb ├── LICENSE ├── README.md └── classes └── rockchip-radxa-gpt-img.bbclass /recipes-connectivity/bluetooth/files/rockpi-e-rk3328/blacklist-bt.conf: -------------------------------------------------------------------------------- 1 | blacklist btusb 2 | blacklist btrtl 3 | blacklist btbcm 4 | blacklist btintel 5 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/rockpi-px30/uEnv.txt: -------------------------------------------------------------------------------- 1 | verbosity=7 2 | fdtfile=px30-rock-pi.dtb 3 | console=ttyS1,1500000n8 4 | kernelimg=Image 5 | rootuuid=b921b045-1df0-41c3-af44-4c6f280d3fae 6 | -------------------------------------------------------------------------------- /recipes-connectivity/networkmanager/networkmanager/NetworkManager.conf: -------------------------------------------------------------------------------- 1 | [main] 2 | plugins=ifupdown,keyfile 3 | 4 | [ifupdown] 5 | managed=true 6 | 7 | [device] 8 | wifi.scan-rand-mac-address=no -------------------------------------------------------------------------------- /recipes-core/busybox/busybox_%.bbappend: -------------------------------------------------------------------------------- 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" 2 | 3 | SRC_URI += " \ 4 | file://0001-Add-support-reboot-loader-command.patch \ 5 | " 6 | 7 | BUSYBOX_SPLIT_SUID = "0" 8 | 9 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/rockpi-e-rk3328/uEnv.txt: -------------------------------------------------------------------------------- 1 | verbosity=7 2 | fdtfile=rk3328-rock-pi-e.dtb 3 | console=ttyS2,1500000n8 4 | overlays=rk3328-uart2 5 | kernelimg=Image 6 | rootuuid=b921b045-1df0-41c3-af44-4c6f280d3fae 7 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/rockpi-s-rk3308/uEnv.txt: -------------------------------------------------------------------------------- 1 | verbosity=7 2 | fdtfile=rk3308-rock-pi-s.dtb 3 | console=ttyS0,1500000n8 4 | overlays=rk3308-uart0 5 | kernelimg=Image 6 | rootuuid=b921b045-1df0-41c3-af44-4c6f280d3fae 7 | -------------------------------------------------------------------------------- /recipes-connectivity/bluetooth/files/rockpi-s-rk3308/install_module_hci_uart: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | version=`uname -r` 4 | insmod /lib/modules/${version}/kernel/drivers/bluetooth/hci_uart.ko 5 | echo "install hci_uart.ko" 6 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/rockpi-n10-rk3399pro/uEnv.txt: -------------------------------------------------------------------------------- 1 | verbosity=7 2 | fdtfile=rk3399pro-rockpi-n10-linux.dtb 3 | console=ttyS2,1500000n8 4 | overlays=rk3399pro-uart2 5 | kernelimg=Image 6 | rootuuid=b921b045-1df0-41c3-af44-4c6f280d3fae 7 | -------------------------------------------------------------------------------- /conf/machine/rockpi-4a-rk3399.conf: -------------------------------------------------------------------------------- 1 | #@TYPE: Machine 2 | #@NAME: RockPi-4a machine 3 | #@DESCRIPTION: RockPi-4a development board config file 4 | 5 | require conf/machine/include/rockpi-4.inc 6 | 7 | KERNEL_DEVICETREE = "rockchip/rk3399-rock-pi-4a.dtb" 8 | UBOOT_MACHINE = "rock-pi-4a-rk3399_defconfig" 9 | -------------------------------------------------------------------------------- /recipes-connectivity/bluetooth/files/broadcom-bluetooth/brcm-btfw-update.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Set device and firmware for Broadcom Bluetooth 3 | Before=broadcom-btfw-load.service 4 | [Service] 5 | ExecStart=/usr/bin/update-brcm-btfw-load-service.sh 6 | [Install] 7 | WantedBy=multi-user.target 8 | -------------------------------------------------------------------------------- /recipes-core/images/radxa-console-image.bb: -------------------------------------------------------------------------------- 1 | require radxa-minimal-image.bb 2 | 3 | SUMMARY = "Basic console image for Radxa boards" 4 | 5 | IMAGE_FEATURES += "package-management ssh-server-openssh hwcodecs" 6 | 7 | CORE_IMAGE_BASE_INSTALL += " \ 8 | packagegroup-radxa-console \ 9 | " 10 | -------------------------------------------------------------------------------- /recipes-connectivity/networkmanager/networkmanager_1.18.4.bbappend: -------------------------------------------------------------------------------- 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" 2 | 3 | SRC_URI += " file://NetworkManager.conf" 4 | 5 | FILES_${PN} += " \ 6 | ${sysconfdir}/NetworkManager/NetworkManager.conf \ 7 | " 8 | 9 | do_install_append () { 10 | install -m 0644 ${WORKDIR}/NetworkManager.conf ${D}${sysconfdir}/NetworkManager/ 11 | } 12 | -------------------------------------------------------------------------------- /recipes-core/udev/udev-extraconf/10-rk.rules: -------------------------------------------------------------------------------- 1 | KERNEL=="hevc-service", MODE="0666", GROUP="video" 2 | KERNEL=="rkvdec", MODE="0666", GROUP="video" 3 | KERNEL=="mali0", MODE="0666", GROUP="video" 4 | KERNEL=="mali", MODE="0666", GROUP="video" 5 | KERNEL=="vpu-service", MODE="0666", GROUP="video" 6 | KERNEL=="vpu_service", MODE="0666", GROUP="video" 7 | KERNEL=="media*", MODE="0666", GROUP="video" 8 | -------------------------------------------------------------------------------- /recipes-core/udev/udev-extraconf_%.bbappend: -------------------------------------------------------------------------------- 1 | # extra configuration udev rules 2 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" 3 | 4 | SRC_URI_append = " \ 5 | file://10-rk.rules \ 6 | " 7 | 8 | do_install_prepend () { 9 | install -d ${D}${sysconfdir}/udev/rules.d 10 | install -m 0644 ${WORKDIR}/*.rules ${D}${sysconfdir}/udev/rules.d 11 | } 12 | 13 | PACKAGE_ARCH = "${MACHINE_ARCH}" 14 | -------------------------------------------------------------------------------- /recipes-connectivity/bluetooth/files/rockpi-s-rk3308/install-module-hci-uart.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Install HCI UART Module 3 | Before=rtl8723ds-btfw-load.service 4 | [Service] 5 | Type=oneshot 6 | #ExecStartPre= 7 | ExecStart=/usr/bin/install_module_hci_uart 8 | #ExecStartPost= 9 | #Restart=on-failure 10 | #RestartSec=2 11 | #StandardOutput=null 12 | [Install] 13 | WantedBy=multi-user.target 14 | -------------------------------------------------------------------------------- /conf/layer.conf: -------------------------------------------------------------------------------- 1 | # We have a conf and classes directory, append to BBPATH 2 | BBPATH .= ":${LAYERDIR}" 3 | 4 | # We have a recipes directory, add to BBFILES 5 | BBFILES += "${LAYERDIR}/recipes*/*/*.bb ${LAYERDIR}/recipes*/*/*.bbappend" 6 | 7 | BBFILE_COLLECTIONS += "meta-radxa" 8 | BBFILE_PATTERN_meta-radxa := "^${LAYERDIR}/" 9 | BBFILE_PRIORITY_meta-radxa = "1" 10 | 11 | LAYERSERIES_COMPAT_meta-radxa = "zeus" 12 | -------------------------------------------------------------------------------- /recipes-core/images/radxa-minimal-image.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Minimal image for Radxa boards" 2 | 3 | IMAGE_FEATURES += "splash" 4 | 5 | LICENSE = "MIT" 6 | 7 | inherit core-image distro_features_check extrausers 8 | 9 | # let's make sure we have a good image.. 10 | REQUIRED_DISTRO_FEATURES = "pam systemd" 11 | 12 | CORE_IMAGE_BASE_INSTALL += " \ 13 | kernel-modules \ 14 | " 15 | 16 | EXTRA_USERS_PARAMS = "usermod -P rock root;" 17 | -------------------------------------------------------------------------------- /recipes-devtools/brcm-tools/files/Makefile: -------------------------------------------------------------------------------- 1 | CC ?= $(CROSS_COMPILE)gcc 2 | 3 | IFLAGS := -g -Wall 4 | 5 | DFLAGS += -DLIB 6 | 7 | #DFLAGS += -DIL_BIGENDIAN 8 | 9 | obj-dhd_priv = dhd_priv.o 10 | 11 | DHD_PRIV := dhd_priv 12 | 13 | CFLAGS += $(IFLAGS) $(DFLAGS) 14 | 15 | all: $(DHD_PRIV) 16 | 17 | $(DHD_PRIV): $(obj-dhd_priv) 18 | $(CC) -o $@ $(obj-dhd_priv) $(CFLAGS) $(LDFLAGS) 19 | 20 | clean: 21 | -rm -f $(DHD_HPRIV) *.o 22 | -------------------------------------------------------------------------------- /recipes-core/images/radxa-desktop-image.bb: -------------------------------------------------------------------------------- 1 | require radxa-console-image.bb 2 | 3 | SUMMARY = "Basic desktop image for Radxa boards" 4 | 5 | IMAGE_FEATURES += "x11" 6 | 7 | # make sure we boot to desktop 8 | # by default and without x11-base in IMAGE_FEATURES we default to multi-user.target 9 | SYSTEMD_DEFAULT_TARGET = "graphical.target" 10 | 11 | CORE_IMAGE_BASE_INSTALL += " \ 12 | openbox \ 13 | packagegroup-xfce-extended \ 14 | lxdm \ 15 | " 16 | -------------------------------------------------------------------------------- /recipes-bsp/resize-helper/files/resize-helper.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Resize root filesystem to fit available disk space 3 | Wants=systemd-udevd.service systemd-udev-trigger.service 4 | After=systemd-remount-fs.service systemd-udevd.service 5 | 6 | [Service] 7 | Type=oneshot 8 | ExecStartPre=-/bin/udevadm settle 9 | ExecStart=-/usr/sbin/resize-helper 10 | ExecStartPost=/bin/systemctl disable resize-helper.service 11 | 12 | [Install] 13 | WantedBy=basic.target -------------------------------------------------------------------------------- /conf/machine/rockpi-4b-rk3399.conf: -------------------------------------------------------------------------------- 1 | #@TYPE: Machine 2 | #@NAME: RockPi-4b machine 3 | #@DESCRIPTION: RockPi-4b development board config file 4 | 5 | require conf/machine/include/rockpi-4.inc 6 | 7 | KERNEL_DEVICETREE = "rockchip/rk3399-rock-pi-4b.dtb" 8 | UBOOT_MACHINE = "rock-pi-4b-rk3399_defconfig" 9 | 10 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "\ 11 | brcm-tools \ 12 | rkwifibt-firmware-ap6256-wifi \ 13 | rkwifibt-firmware-ap6256-bt \ 14 | bluetooth-broadcom \ 15 | " -------------------------------------------------------------------------------- /conf/machine/rockpi-4c-rk3399.conf: -------------------------------------------------------------------------------- 1 | #@TYPE: Machine 2 | #@NAME: RockPi-4c machine 3 | #@DESCRIPTION: RockPi-4c development board config file 4 | 5 | require conf/machine/include/rockpi-4.inc 6 | 7 | KERNEL_DEVICETREE = "rockchip/rk3399-rock-pi-4c.dtb" 8 | UBOOT_MACHINE = "rock-pi-4c-rk3399_defconfig" 9 | 10 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "\ 11 | brcm-tools \ 12 | rkwifibt-firmware-ap6256-wifi \ 13 | rkwifibt-firmware-ap6256-bt \ 14 | bluetooth-broadcom \ 15 | " -------------------------------------------------------------------------------- /recipes-bsp/u-boot/u-boot-rockpi-e.bb: -------------------------------------------------------------------------------- 1 | DEFAULT_PREFERENCE = "1" 2 | 3 | DESCRIPTION = "RockPi-E U-Boot" 4 | LIC_FILES_CHKSUM = "file://Licenses/README;md5=30503fd321432fc713238f582193b78e" 5 | 6 | include u-boot-rockpi.inc 7 | 8 | SRC_URI = " \ 9 | git://github.com/radxa/u-boot.git;branch=stable-4.4-rockpie; \ 10 | file://0001-Use-local-command.h-file-instead-of-system-file.patch \ 11 | file://${MACHINE}/boot.cmd \ 12 | file://${MACHINE}/uEnv.txt \ 13 | " 14 | 15 | SRCREV = "7b93f1b8bce4106266d4a38dde96fd8080faccea" 16 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/u-boot-common-radxa.inc: -------------------------------------------------------------------------------- 1 | HOMEPAGE = "https://github.com/radxa/u-boot" 2 | SECTION = "bootloaders" 3 | DEPENDS += "flex-native bison-native" 4 | 5 | LICENSE = "GPLv2+" 6 | LIC_FILES_CHKSUM = "file://Licenses/README;md5=30503fd321432fc713238f582193b78e" 7 | PE = "1" 8 | 9 | SRC_URI = " \ 10 | git://github.com/radxa/u-boot.git;branch=stable-4.4-rockpie; \ 11 | file://0001-Use-local-command.h-file-instead-of-system-file.patch \ 12 | " 13 | SRCREV = "7b93f1b8bce4106266d4a38dde96fd8080faccea" 14 | 15 | S = "${WORKDIR}/git" 16 | -------------------------------------------------------------------------------- /recipes-devtools/rtl-tools/files/Makefile: -------------------------------------------------------------------------------- 1 | CC ?= $(CROSS_COMPILE)gcc 2 | 3 | all: rtk_hciattach 4 | 5 | rtk_hciattach: hciattach.c hciattach_rtk.o 6 | $(CC) -o rtk_hciattach hciattach.c hciattach_rtk.o $(CFLAGS) $(LDFLAGS) 7 | 8 | hciattach_rtk.o:hciattach_rtk.c 9 | $(CC) -c hciattach_rtk.c $(CFLAGS) $(LDFLAGS) 10 | 11 | clean: 12 | rm -f *.o rtk_hciattach tags cscope.* 13 | 14 | tags: FORCE 15 | ctags -R 16 | find ./ -name "*.h" -o -name "*.c" -o -name "*.cc" -o -name "*.cpp" > cscope.files 17 | cscope -bkq -i cscope.files 18 | PHONY += FORCE 19 | FORCE: 20 | -------------------------------------------------------------------------------- /recipes-connectivity/bluetooth/files/rockpi-s-rk3308/rtl8723ds-btfw-load.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Load RTL8723DS Bluetooth firmware 3 | Requires=bluetooth.service install-module-hci-uart.service 4 | After=bluetooth.service install-module-hci-uart.service 5 | [Service] 6 | #Type=forking 7 | #ExecStartPre=/usr/sbin/rfkill block bluetooth 8 | ExecStartPre=/usr/sbin/rfkill unblock bluetooth 9 | ExecStart=/usr/bin/rtk_hciattach -n -s 115200 /dev/ttyS4 rtk_h5 & 10 | #Restart=on-failure 11 | #RestartSec=2 12 | #StandardOutput=null 13 | [Install] 14 | WantedBy=multi-user.target 15 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/u-boot-rockpi-s.bb: -------------------------------------------------------------------------------- 1 | DEFAULT_PREFERENCE = "1" 2 | 3 | DESCRIPTION = "RockPi-S U-Boot" 4 | LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6" 5 | 6 | include u-boot-rockpi.inc 7 | 8 | SRC_URI = " \ 9 | git://github.com/radxa/u-boot.git;branch=stable-4.4-rockpis; \ 10 | file://0001-Use-local-command.h-file-instead-of-system-file.patch \ 11 | file://0001-Makefile-disable-gcc9-s-address-of-packed-member-war.patch \ 12 | file://${MACHINE}/boot.cmd \ 13 | file://${MACHINE}/uEnv.txt \ 14 | " 15 | 16 | SRCREV = "c93a0fc70993c12e605b1312577252ca9cdec6c8" 17 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/u-boot-rockpi-4.bb: -------------------------------------------------------------------------------- 1 | DEFAULT_PREFERENCE = "1" 2 | 3 | DESCRIPTION = "RockPi-4 U-Boot" 4 | LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6" 5 | 6 | include u-boot-rockpi.inc 7 | 8 | SRC_URI = " \ 9 | git://github.com/radxa/u-boot.git;branch=rk3399-pie-gms-express-baseline; \ 10 | file://0001-Use-local-command.h-file-instead-of-system-file.patch \ 11 | file://0001-Makefile-disable-gcc9-s-address-of-packed-member-war.patch \ 12 | file://0002-Suppress-maybe-uninitialized-warning.patch \ 13 | " 14 | 15 | SRCREV = "04d66f4b45a47531b5ff6cdbddcdc2cc35fa7aea" 16 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/u-boot-rockpi-px30.bb: -------------------------------------------------------------------------------- 1 | DEFAULT_PREFERENCE = "1" 2 | 3 | DESCRIPTION = "RockPi-PX30 U-Boot" 4 | LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6" 5 | 6 | include u-boot-rockpi.inc 7 | 8 | SRC_URI = " \ 9 | git://github.com/radxa/u-boot.git;branch=stable-4.4-px30; \ 10 | file://0001-Use-local-command.h-file-instead-of-system-file.patch \ 11 | file://0001-Makefile-disable-gcc9-s-address-of-packed-member-war.patch \ 12 | file://${MACHINE}/boot.cmd \ 13 | file://${MACHINE}/uEnv.txt \ 14 | " 15 | 16 | SRCREV = "cfc37de87bc064b2d6d384566e24c5e4245f113a" 17 | -------------------------------------------------------------------------------- /recipes-devtools/rtl-tools/rtl-tools.bb: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019, Fuzhou Rockchip Electronics Co., Ltd 2 | # Released under the MIT license (see COPYING.MIT for the terms) 3 | 4 | DESCRIPTION = "Realtek develop tools" 5 | SECTION = "devel" 6 | LICENSE = "GPLv2" 7 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" 8 | 9 | SRC_URI = " \ 10 | file://hciattach.c \ 11 | file://hciattach.h \ 12 | file://hciattach_rtk.c \ 13 | file://Makefile \ 14 | " 15 | 16 | S = "${WORKDIR}" 17 | 18 | do_install() { 19 | install -d ${D}${bindir} 20 | install -m 0755 rtk_hciattach ${D}${bindir} 21 | } 22 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/u-boot-rockpi-n10.bb: -------------------------------------------------------------------------------- 1 | DEFAULT_PREFERENCE = "1" 2 | 3 | DESCRIPTION = "RockPi-N10 U-Boot" 4 | LIC_FILES_CHKSUM = "file://Licenses/README;md5=a2c678cfd4a4d97135585cad908541c6" 5 | 6 | include u-boot-rockpi.inc 7 | 8 | SRC_URI = " \ 9 | git://github.com/radxa/u-boot.git;branch=rk3399-pie-gms-express-baseline; \ 10 | file://0001-Use-local-command.h-file-instead-of-system-file.patch \ 11 | file://0001-Makefile-disable-gcc9-s-address-of-packed-member-war.patch \ 12 | file://0002-Suppress-maybe-uninitialized-warning.patch \ 13 | file://${MACHINE}/boot.cmd \ 14 | file://${MACHINE}/uEnv.txt \ 15 | " 16 | 17 | SRCREV = "7c49a7da79caf2f68bc1074dfa21864d7f23b9e1" 18 | -------------------------------------------------------------------------------- /conf/bblayers.conf.sample: -------------------------------------------------------------------------------- 1 | # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf 2 | # changes incompatibly 3 | POKY_BBLAYERS_CONF_VERSION = "2" 4 | 5 | BBPATH = "${TOPDIR}" 6 | BBFILES ?= "" 7 | 8 | BBLAYERS ?= " \ 9 | ${TOPDIR}/../meta \ 10 | ${TOPDIR}/../meta-poky \ 11 | ${TOPDIR}/../meta-yocto-bsp \ 12 | ${TOPDIR}/../meta-openembedded/meta-oe \ 13 | ${TOPDIR}/../meta-openembedded/meta-networking \ 14 | ${TOPDIR}/../meta-openembedded/meta-python \ 15 | ${TOPDIR}/../meta-openembedded/meta-multimedia \ 16 | ${TOPDIR}/../meta-openembedded/meta-gnome \ 17 | ${TOPDIR}/../meta-openembedded/meta-xfce \ 18 | ${TOPDIR}/../meta-radxa \ 19 | " 20 | -------------------------------------------------------------------------------- /conf/machine/include/rockpi-4.inc: -------------------------------------------------------------------------------- 1 | SOC_FAMILY = "rk3399" 2 | 3 | require conf/machine/include/arm/arch-armv8a.inc 4 | require conf/machine/include/soc-family.inc 5 | 6 | MACHINEOVERRIDES =. "mali-gpu:mali-midgard:" 7 | 8 | PREFERRED_PROVIDER_virtual/kernel = "linux-rockpi-4" 9 | PREFERRED_VERSION_linux-rockchip = "4.4" 10 | 11 | SERIAL_CONSOLES = "1500000;ttyFIQ0" 12 | KERNEL_IMAGETYPE = "Image" 13 | KBUILD_DEFCONFIG = "rockchip_linux_defconfig" 14 | 15 | PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot-rockpi-4" 16 | 17 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "\ 18 | kernel-modules \ 19 | resize-helper \ 20 | " 21 | 22 | IMAGE_FSTYPES += "rockchip-radxa-gpt-img" 23 | IMAGE_CLASSES += "rockchip-radxa-gpt-img" 24 | -------------------------------------------------------------------------------- /recipes-connectivity/bluetooth/files/broadcom-bluetooth/brcm-btfw-load.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Load Broadcom Bluetooth firmware 3 | #Requires=display-manager.service 4 | After=display-manager.service 5 | [Service] 6 | #Type=dbus 7 | #blkusName=org.bluez 8 | #ExecStartPre=/usr/sbin/rfkill block bluetooth 9 | ExecStartPre=/usr/sbin/rfkill unblock bluetooth 10 | ExecStart=/usr/bin/brcm_patchram_plus --enable_hci --no2bytes --use_baudrate_for_downloade --tosleep 200000 --baudrate 1500000 --patchram /system/etc/firmware/BCM4345C5.hcd /dev/ttyS0 > /dev/null 2>&1 & 11 | ExecStop=/usr/bin/killall brcm_patchram_plus 12 | Restart=on-failure 13 | RestartSec=2 14 | StandardOutput=null 15 | [Install] 16 | WantedBy=multi-user.target 17 | -------------------------------------------------------------------------------- /recipes-devtools/brcm-tools/brcm-tools.bb: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019, Fuzhou Rockchip Electronics Co., Ltd 2 | # Released under the MIT license (see COPYING.MIT for the terms) 3 | 4 | DESCRIPTION = "Broadcom develop tools" 5 | SECTION = "devel" 6 | LICENSE = "Apache-2.0" 7 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10" 8 | 9 | SRC_URI = " \ 10 | file://dhd_priv.c \ 11 | file://brcm_patchram_plus1.c \ 12 | file://Makefile \ 13 | " 14 | 15 | S = "${WORKDIR}" 16 | 17 | do_compile_append() { 18 | ${CC} ${CFLAGS} ${LDFLAGS} brcm_patchram_plus1.c -o brcm_patchram_plus 19 | } 20 | 21 | do_install() { 22 | install -d ${D}${bindir} 23 | install -m 0755 dhd_priv ${D}${bindir} 24 | install -m 0755 brcm_patchram_plus ${D}${bindir} 25 | } 26 | -------------------------------------------------------------------------------- /recipes-core/packagegroups/packagegroup-radxa-console.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Organize packages to avoid duplication across all images" 2 | 3 | PACKAGE_ARCH = "${MACHINE_ARCH}" 4 | 5 | inherit packagegroup 6 | 7 | # contains basic dependencies, that can work without graphics/display 8 | RDEPENDS_packagegroup-radxa-console = "\ 9 | alsa-utils-aplay \ 10 | coreutils \ 11 | cpufrequtils \ 12 | hostapd \ 13 | htop \ 14 | iptables \ 15 | iproute2 \ 16 | kernel-modules \ 17 | networkmanager \ 18 | networkmanager-nmtui \ 19 | openssh-sftp-server \ 20 | bluez5 \ 21 | dialog \ 22 | kernel-module-headers \ 23 | i2c-tools \ 24 | sudo \ 25 | net-tools \ 26 | findutils \ 27 | mraa-radxa-dev \ 28 | mraa-radxa-utils \ 29 | " 30 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/0001-Use-local-command.h-file-instead-of-system-file.patch: -------------------------------------------------------------------------------- 1 | From 17172fd2f8646271db29a5440ea5ff08480b45b9 Mon Sep 17 00:00:00 2001 2 | From: nishantpoorswani 3 | Date: Sun, 17 May 2020 22:28:37 +0530 4 | Subject: [PATCH] Use local command.h file instead of system file 5 | 6 | Signed-off-by: nishantpoorswani 7 | --- 8 | include/bootm.h | 2 +- 9 | 1 file changed, 1 insertion(+), 1 deletion(-) 10 | 11 | diff --git a/include/bootm.h b/include/bootm.h 12 | index 49813772ce..82848eb50b 100644 13 | --- a/include/bootm.h 14 | +++ b/include/bootm.h 15 | @@ -8,7 +8,7 @@ 16 | #ifndef _BOOTM_H 17 | #define _BOOTM_H 18 | 19 | -#include 20 | +#include "command.h" 21 | #include 22 | 23 | #define BOOTM_ERR_RESET (-1) 24 | -- 25 | 2.26.2 26 | 27 | -------------------------------------------------------------------------------- /recipes-bsp/rk-binary/radxa-binary-native_git.bb: -------------------------------------------------------------------------------- 1 | inherit native deploy 2 | 3 | DESCRIPTION = "Rockchip-Radxa binary tools" 4 | 5 | LICENSE = "BINARY" 6 | LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=564e729dd65db6f65f911ce0cd340cf9" 7 | NO_GENERIC_LICENSE[BINARY] = "LICENSE.TXT" 8 | 9 | SRC_URI = "git://github.com/radxa/rkbin.git;branch=master;" 10 | SRCREV = "fb4ce829b87a9a5738ff6ebc9951768c86ad75c1" 11 | 12 | S = "${WORKDIR}/git" 13 | 14 | do_install () { 15 | install -d ${D}/${bindir} 16 | install -m 0755 "${S}/tools/trust_merger" ${D}/${bindir} 17 | install -m 0755 "${S}/tools/firmwareMerger" ${D}/${bindir} 18 | 19 | install -m 0755 "${S}/tools/kernelimage" ${D}/${bindir} 20 | install -m 0755 "${S}/tools/loaderimage" ${D}/${bindir} 21 | 22 | install -m 0755 "${S}/tools/mkkrnlimg" ${D}/${bindir} 23 | install -m 0755 "${S}/tools/resource_tool" ${D}/${bindir} 24 | 25 | } 26 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/0002-Suppress-maybe-uninitialized-warning.patch: -------------------------------------------------------------------------------- 1 | From f730bf4efe2c7889d809d3b423225f636d3ee7a2 Mon Sep 17 00:00:00 2001 2 | From: nishantpoorswani 3 | Date: Sat, 22 Aug 2020 12:47:17 +0530 4 | Subject: [PATCH] Suppress maybe-uninitialized warning 5 | 6 | Signed-off-by: nishantpoorswani 7 | --- 8 | Makefile | 1 + 9 | 1 file changed, 1 insertion(+) 10 | 11 | diff --git a/Makefile b/Makefile 12 | index c51e37149a..24f1921254 100644 13 | --- a/Makefile 14 | +++ b/Makefile 15 | @@ -606,6 +606,7 @@ endif 16 | 17 | KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral) 18 | KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) 19 | +KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) 20 | 21 | # turn jbsr into jsr for m68k 22 | ifeq ($(ARCH),m68k) 23 | -- 24 | 2.26.2 25 | 26 | -------------------------------------------------------------------------------- /recipes-connectivity/bluetooth/bluetooth-rockpi-e.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Disable loading of specific BT driver modules for ROCKPi-E" 2 | DESCRIPTION = "Disable loading of specific BT driver modules for ROCKPi-E" 3 | SECTION = "devel" 4 | 5 | LICENSE = "GPLv2" 6 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" 7 | 8 | SRC_URI = " \ 9 | file://${MACHINE}/blacklist-bt.conf;name=blacklist-bt-conf \ 10 | " 11 | 12 | SRC_URI[blacklist-bt-conf.md5sum] = "a6702394f1b71a3466edae4e20e3ba7e" 13 | 14 | S = "${WORKDIR}" 15 | 16 | inherit systemd 17 | 18 | RDEPENDS_${PN} += "bluez5 usbutils" 19 | 20 | do_install() { 21 | install -d ${D}${sysconfdir} 22 | install -d ${D}${sysconfdir}/modprobe.d 23 | install -m 0644 ${WORKDIR}/${MACHINE}/blacklist-bt.conf ${D}${sysconfdir}/modprobe.d/blacklist-bt.conf 24 | } 25 | 26 | FILES_${PN} += "/etc/modprobe.d/blacklist-bt.conf" 27 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/0001-Makefile-disable-gcc9-s-address-of-packed-member-war.patch: -------------------------------------------------------------------------------- 1 | From 59dafb1ffcea607776ea645f8491e4348bfc02c4 Mon Sep 17 00:00:00 2001 2 | From: nishantpoorswani 3 | Date: Fri, 7 Aug 2020 22:31:01 +0530 4 | Subject: [PATCH] Makefile: disable gcc9's address-of-packed-member warning 5 | error 6 | 7 | Signed-off-by: nishantpoorswani 8 | --- 9 | Makefile | 1 + 10 | 1 file changed, 1 insertion(+) 11 | 12 | diff --git a/Makefile b/Makefile 13 | index 7060da1c5f..16a2c76db7 100644 14 | --- a/Makefile 15 | +++ b/Makefile 16 | @@ -605,6 +605,7 @@ ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-stack-usage.sh $(CC)),y) 17 | endif 18 | 19 | KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral) 20 | +KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) 21 | 22 | # turn jbsr into jsr for m68k 23 | ifeq ($(ARCH),m68k) 24 | -- 25 | 2.26.2 26 | 27 | -------------------------------------------------------------------------------- /recipes-bsp/resize-helper/resize-helper.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Resize root filesystem to fit available disk space" 2 | DESCRIPTION = "Resize root filesystem to fit available disk space" 3 | SECTION = "admin" 4 | 5 | LICENSE = "GPLv2" 6 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" 7 | 8 | SRC_URI = " \ 9 | file://resize-helper.service;name=resize-helper-service \ 10 | file://resize-helper;name=resize-helper-script \ 11 | " 12 | SRC_URI[resize-helper-service] = "007b61d7e194deec006531ede89c393a" 13 | SRC_URI[resize-helper-script] = "9e359c1cce25f89114befc48213f7ea8" 14 | 15 | inherit systemd 16 | 17 | RDEPENDS_${PN} += "e2fsprogs-resize2fs gptfdisk parted util-linux udev" 18 | 19 | do_install() { 20 | install -d ${D}${systemd_system_unitdir} 21 | install -m 0644 ${WORKDIR}/resize-helper.service ${D}${systemd_system_unitdir} 22 | install -d ${D}${sbindir} 23 | install -m 0755 ${WORKDIR}/resize-helper ${D}${sbindir} 24 | } 25 | 26 | SYSTEMD_SERVICE_${PN} = "resize-helper.service" -------------------------------------------------------------------------------- /conf/machine/rockpi-px30.conf: -------------------------------------------------------------------------------- 1 | #@TYPE: Machine 2 | #@NAME: RockPi-PX30 machine 3 | #@DESCRIPTION: RockPi-PX30 development board config file 4 | 5 | SOC_FAMILY = "px30" 6 | 7 | DEFAULTTUNE ?= "cortexa35-crypto" 8 | require conf/machine/include/tune-cortexa35.inc 9 | require conf/machine/include/soc-family.inc 10 | 11 | MACHINEOVERRIDES =. "mali-gpu:mali-midgard:" 12 | 13 | PREFERRED_PROVIDER_virtual/kernel = "linux-rockpi-px30" 14 | PREFERRED_VERSION_linux-rockchip = "4.4" 15 | 16 | SERIAL_CONSOLES = "1500000;ttyS1" 17 | KERNEL_IMAGETYPE = "Image" 18 | KBUILD_DEFCONFIG = "px30_linux_defconfig" 19 | 20 | PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot-rockpi-px30" 21 | 22 | KERNEL_DEVICETREE = "rockchip/px30-rock-pi.dtb" 23 | UBOOT_MACHINE = "rock-pi-px30_defconfig" 24 | 25 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "\ 26 | kernel-modules \ 27 | rtl-tools \ 28 | rkwifibt-firmware-rtl8723du-bt \ 29 | resize-helper \ 30 | " 31 | 32 | IMAGE_FSTYPES += "rockchip-radxa-gpt-img" 33 | IMAGE_CLASSES += "rockchip-radxa-gpt-img" 34 | -------------------------------------------------------------------------------- /recipes-kernel/linux/files/0001-Makefile-disable-gcc9-s-address-of-packed-member-war.patch: -------------------------------------------------------------------------------- 1 | From e93b0c4f9ebee1043104f0d68efe9abd682fa708 Mon Sep 17 00:00:00 2001 2 | From: Stephen 3 | Date: Mon, 21 Sep 2020 15:07:15 +0800 4 | Subject: [PATCH] Makefile: disable gcc9's address-of-packed-member warning 5 | error 6 | 7 | Signed-off-by: Stephen 8 | --- 9 | Makefile | 1 + 10 | 1 file changed, 1 insertion(+) 11 | 12 | diff --git a/Makefile b/Makefile 13 | index 6246746..71fd6a5 100644 14 | --- a/Makefile 15 | +++ b/Makefile 16 | @@ -671,6 +671,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) 17 | KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) 18 | KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) 19 | KBUILD_CFLAGS += $(call cc-disable-warning, attribute-alias) 20 | +KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) 21 | 22 | ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE 23 | KBUILD_CFLAGS += $(call cc-option,-Oz,-Os) 24 | -- 25 | 2.7.4 26 | 27 | -------------------------------------------------------------------------------- /conf/machine/rockpi-s-rk3308.conf: -------------------------------------------------------------------------------- 1 | #@TYPE: Machine 2 | #@NAME: RockPi-S machine 3 | #@DESCRIPTION: RockPi-S development board config file 4 | 5 | SOC_FAMILY = "rk3308" 6 | 7 | DEFAULTTUNE ?= "cortexa35-crypto" 8 | require conf/machine/include/tune-cortexa35.inc 9 | require conf/machine/include/soc-family.inc 10 | 11 | MACHINEOVERRIDES =. "mali-gpu:mali-midgard:" 12 | 13 | PREFERRED_PROVIDER_virtual/kernel = "linux-rockpi-s" 14 | PREFERRED_VERSION_linux-rockchip = "4.4" 15 | 16 | SERIAL_CONSOLES = "1500000;ttyS0" 17 | KERNEL_IMAGETYPE = "Image" 18 | KBUILD_DEFCONFIG = "rk3308_linux_defconfig" 19 | 20 | PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot-rockpi-s" 21 | 22 | KERNEL_DEVICETREE = "rockchip/rk3308-rock-pi-s.dtb" 23 | UBOOT_MACHINE = "rock-pi-s-rk3308_defconfig" 24 | 25 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "\ 26 | kernel-modules \ 27 | rtl-tools \ 28 | rkwifibt-firmware-rtl8723ds-bt \ 29 | bluetooth-rockpi-s \ 30 | resize-helper \ 31 | " 32 | IMAGE_FSTYPES += "rockchip-radxa-gpt-img" 33 | IMAGE_CLASSES += "rockchip-radxa-gpt-img" 34 | -------------------------------------------------------------------------------- /conf/machine/rockpi-e-rk3328.conf: -------------------------------------------------------------------------------- 1 | #@TYPE: Machine 2 | #@NAME: RockPi-e machine 3 | #@DESCRIPTION: RockPi-e development board config file 4 | 5 | SOC_FAMILY = "rk3328" 6 | 7 | DEFAULTTUNE ?= "cortexa53-crypto" 8 | require conf/machine/include/tune-cortexa53.inc 9 | require conf/machine/include/soc-family.inc 10 | 11 | MACHINEOVERRIDES =. "mali-gpu:mali-midgard:" 12 | 13 | PREFERRED_PROVIDER_virtual/kernel = "linux-rockpi-e" 14 | PREFERRED_VERSION_linux-rockchip = "4.4" 15 | 16 | SERIAL_CONSOLES = "1500000;ttyS2" 17 | KERNEL_IMAGETYPE = "Image" 18 | KBUILD_DEFCONFIG = "rockchip_linux_defconfig" 19 | 20 | PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot-rockpi-e" 21 | 22 | KERNEL_DEVICETREE = "rockchip/rk3328-rock-pi-e.dtb" 23 | UBOOT_MACHINE = "rock-pi-e-rk3328_defconfig" 24 | 25 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "\ 26 | kernel-modules \ 27 | rtl-tools \ 28 | rkwifibt-firmware-rtl8723du-bt \ 29 | rkwifibt-firmware-rtl8821cu-bt \ 30 | bluetooth-rockpi-e \ 31 | resize-helper \ 32 | " 33 | IMAGE_FSTYPES += "rockchip-radxa-gpt-img" 34 | IMAGE_CLASSES += "rockchip-radxa-gpt-img" 35 | -------------------------------------------------------------------------------- /recipes-kernel/linux/linux-rockpi-e_4.4.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Linux kernel for RockPi-E" 2 | 3 | require recipes-kernel/linux/linux-yocto.inc 4 | 5 | # We need mkimage for the overlays 6 | DEPENDS += "openssl-native u-boot-mkimage-radxa-native" 7 | 8 | do_compile[depends] += "u-boot-mkimage-radxa-native:do_populate_sysroot" 9 | 10 | SRC_URI = " \ 11 | git://github.com/radxa/kernel.git;branch=stable-4.4-rockpie; \ 12 | " 13 | 14 | SRCREV = "615ae743115011bbe1cd1edc5c9118bf95527f54" 15 | LINUX_VERSION = "4.4.194" 16 | 17 | # Override local version in order to use the one generated by linux build system 18 | # And not "yocto-standard" 19 | LINUX_VERSION_EXTENSION = "" 20 | PR = "r1" 21 | PV = "${LINUX_VERSION}" 22 | 23 | # Include only supported boards for now 24 | COMPATIBLE_MACHINE = "(rk3036|rk3066|rk3288|rk3328|rk3399|rk3308)" 25 | deltask kernel_configme 26 | 27 | do_compile_append() { 28 | oe_runmake dtbs 29 | } 30 | 31 | do_deploy_append() { 32 | install -d ${DEPLOYDIR}/overlays 33 | install -m 644 ${WORKDIR}/linux-rockpi_e_rk3328-standard-build/arch/arm64/boot/dts/rockchip/overlay/* ${DEPLOYDIR}/overlays 34 | } 35 | 36 | -------------------------------------------------------------------------------- /recipes-kernel/linux/linux-rockpi-4_4.4.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Linux kernel for RockPi-4" 2 | 3 | require recipes-kernel/linux/linux-yocto.inc 4 | 5 | DEPENDS += "openssl-native" 6 | 7 | SRC_URI = " \ 8 | git://github.com/radxa/kernel.git;branch=release-4.4-rockpi4; \ 9 | file://0001-Fix-GCC-9-Wmissing-attributes-warnings-error.patch \ 10 | " 11 | 12 | SRCREV = "b04eccb4588e333bdaf3ba7e6e4186d2ebe53770" 13 | LINUX_VERSION = "4.4.154" 14 | 15 | # Override local version in order to use the one generated by linux build system 16 | # And not "yocto-standard" 17 | LINUX_VERSION_EXTENSION = "" 18 | PR = "r1" 19 | PV = "${LINUX_VERSION}" 20 | 21 | # Include only supported boards for now 22 | COMPATIBLE_MACHINE = "(rk3036|rk3066|rk3288|rk3328|rk3399|rk3308)" 23 | deltask kernel_configme 24 | 25 | do_compile_append() { 26 | oe_runmake dtbs 27 | } 28 | 29 | do_deploy_append() { 30 | install -d ${DEPLOYDIR}/overlays 31 | install -m 644 ${WORKDIR}/linux-rockpi_4*/arch/arm64/boot/dts/rockchip/overlays-rockpi4/* ${DEPLOYDIR}/overlays 32 | install -m 644 ${S}/arch/arm64/boot/dts/rockchip/overlays-rockpi4/hw_intfc.conf ${DEPLOYDIR}/ 33 | } 34 | -------------------------------------------------------------------------------- /recipes-kernel/linux/linux-rockpi-s_4.4.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Linux kernel for RockPi-S" 2 | 3 | require recipes-kernel/linux/linux-yocto.inc 4 | 5 | # We need mkimage for the overlays 6 | DEPENDS += "openssl-native u-boot-mkimage-radxa-native" 7 | 8 | do_compile[depends] += "u-boot-mkimage-radxa-native:do_populate_sysroot" 9 | 10 | SRC_URI = " \ 11 | git://github.com/radxa/kernel.git;branch=stable-4.4-rockpis; \ 12 | file://0001-Fix-GCC-9-Wmissing-attributes-warnings-error.patch \ 13 | " 14 | 15 | SRCREV = "6b7accbc999b6caa8ef603b9d904c99694d0bf41" 16 | LINUX_VERSION = "4.4.143" 17 | 18 | # Override local version in order to use the one generated by linux build system 19 | # And not "yocto-standard" 20 | LINUX_VERSION_EXTENSION = "" 21 | PR = "r1" 22 | PV = "${LINUX_VERSION}" 23 | 24 | # Include only supported boards for now 25 | COMPATIBLE_MACHINE = "(rk3036|rk3066|rk3288|rk3328|rk3399|rk3308)" 26 | deltask kernel_configme 27 | 28 | do_compile_append() { 29 | oe_runmake dtbs 30 | } 31 | 32 | do_deploy_append() { 33 | install -d ${DEPLOYDIR}/overlays 34 | install -m 644 ${WORKDIR}/linux-rockpi_s_rk3308-standard-build/arch/arm64/boot/dts/rockchip/overlay/* ${DEPLOYDIR}/overlays 35 | } 36 | -------------------------------------------------------------------------------- /recipes-kernel/linux/linux-rockpi-px30_4.4.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Linux kernel for RockPi-PX30" 2 | 3 | require recipes-kernel/linux/linux-yocto.inc 4 | 5 | # We need mkimage for the overlays 6 | DEPENDS += "openssl-native u-boot-mkimage-radxa-native" 7 | 8 | do_compile[depends] += "u-boot-mkimage-radxa-native:do_populate_sysroot" 9 | 10 | SRC_URI = " \ 11 | git://github.com/radxa/kernel.git;branch=stable-4.4-px30; \ 12 | file://0001-Fix-GCC-9-Wmissing-attributes-warnings-error.patch \ 13 | " 14 | 15 | SRCREV = "dc47906e88166ae315f0472743de4d80f2bea786" 16 | LINUX_VERSION = "4.4.189" 17 | 18 | # Override local version in order to use the one generated by linux build system 19 | # And not "yocto-standard" 20 | LINUX_VERSION_EXTENSION = "" 21 | PR = "r1" 22 | PV = "${LINUX_VERSION}" 23 | 24 | # Include only supported boards for now 25 | COMPATIBLE_MACHINE = "(px30|rk3036|rk3066|rk3288|rk3328|rk3399|rk3308)" 26 | deltask kernel_configme 27 | 28 | do_compile_append() { 29 | oe_runmake dtbs 30 | } 31 | 32 | do_deploy_append() { 33 | # install -d ${DEPLOYDIR}/overlays 34 | # install -m 644 ${WORKDIR}/linux-rockpi_px30-standard-build/arch/arm64/boot/dts/rockchip/overlay/* ${DEPLOYDIR}/overlays 35 | } 36 | 37 | -------------------------------------------------------------------------------- /conf/machine/rockpi-n10-rk3399pro.conf: -------------------------------------------------------------------------------- 1 | #@TYPE: Machine 2 | #@NAME: RockPi-n10 machine 3 | #@DESCRIPTION: RockPi-n10 development board config file 4 | 5 | SOC_FAMILY = "rk3399pro" 6 | 7 | require conf/machine/include/arm/arch-armv8a.inc 8 | require conf/machine/include/soc-family.inc 9 | 10 | MACHINEOVERRIDES =. "mali-gpu:mali-midgard:" 11 | 12 | PREFERRED_PROVIDER_virtual/kernel = "linux-rockpi-n10" 13 | PREFERRED_VERSION_linux-rockchip = "4.4" 14 | 15 | SERIAL_CONSOLES = "1500000;ttyS2" 16 | KERNEL_IMAGETYPE = "Image" 17 | KBUILD_DEFCONFIG = "rockchip_linux_defconfig" 18 | 19 | PREFERRED_PROVIDER_virtual/bootloader ?= "u-boot-rockpi-n10" 20 | 21 | KERNEL_DEVICETREE = "rockchip/rk3399pro-rockpi-n10-linux.dtb" 22 | UBOOT_MACHINE = "rk3399pro-rockpi-n10-linux_defconfig" 23 | 24 | MACHINE_ESSENTIAL_EXTRA_RRECOMMENDS += "\ 25 | kernel-modules \ 26 | brcm-tools \ 27 | rkwifibt-firmware-ap6236-wifi \ 28 | rkwifibt-firmware-ap6236-bt \ 29 | rkwifibt-firmware-ap6256-wifi \ 30 | rkwifibt-firmware-ap6256-bt \ 31 | rkwifibt-firmware-ap6398s-wifi \ 32 | rkwifibt-firmware-ap6398s-bt \ 33 | bluetooth-broadcom \ 34 | " 35 | 36 | IMAGE_FSTYPES += "rockchip-radxa-gpt-img" 37 | IMAGE_CLASSES += "rockchip-radxa-gpt-img" 38 | -------------------------------------------------------------------------------- /recipes-kernel/linux/linux-rockpi-n10_4.4.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Linux kernel for RockPi-N10" 2 | 3 | require recipes-kernel/linux/linux-yocto.inc 4 | 5 | # We need mkimage for the overlays 6 | DEPENDS += "openssl-native u-boot-mkimage-radxa-native" 7 | 8 | SRC_URI = " \ 9 | git://github.com/radxa/kernel.git;branch=rk3399pro-toybrick-stable; \ 10 | file://0001-UPSTREAM-arm64-vdso-Define-vdso_-start-end-as-array.patch \ 11 | file://0001-Makefile-disable-gcc9-s-address-of-packed-member-war.patch \ 12 | file://0001-Fix-GCC-9-Wmissing-attributes-warnings-error.patch \ 13 | " 14 | 15 | SRCREV = "c36a21e2be755919e8b406069206e67126b7e712" 16 | LINUX_VERSION = "4.4.167" 17 | 18 | # Override local version in order to use the one generated by linux build system 19 | # And not "yocto-standard" 20 | LINUX_VERSION_EXTENSION = "" 21 | PR = "r1" 22 | PV = "${LINUX_VERSION}" 23 | 24 | # Include only supported boards for now 25 | COMPATIBLE_MACHINE = "(rk3036|rk3066|rk3288|rk3328|rk3399|rk3308|rk3399pro)" 26 | deltask kernel_configme 27 | 28 | do_compile_append() { 29 | oe_runmake dtbs 30 | } 31 | 32 | do_deploy_append() { 33 | install -d ${DEPLOYDIR}/overlays 34 | install -m 644 ${WORKDIR}/linux-rockpi_n10_rk3399pro-standard-build/arch/arm64/boot/dts/rockchip/overlay/* ${DEPLOYDIR}/overlays 35 | } 36 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/u-boot-mkimage-radxa.bb: -------------------------------------------------------------------------------- 1 | require u-boot-common-radxa.inc 2 | 3 | SUMMARY = "U-Boot bootloader image creation tool" 4 | DEPENDS += "openssl" 5 | 6 | EXTRA_OEMAKE_class-target = 'CROSS_COMPILE="${TARGET_PREFIX}" CC="${CC} ${CFLAGS} ${LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" STRIP=true V=1' 7 | EXTRA_OEMAKE_class-native = 'CC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" STRIP=true V=1' 8 | EXTRA_OEMAKE_class-nativesdk = 'CROSS_COMPILE="${HOST_PREFIX}" CC="${CC} ${CFLAGS} ${LDFLAGS}" HOSTCC="${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" STRIP=true V=1' 9 | 10 | do_compile () { 11 | oe_runmake sandbox_defconfig 12 | 13 | # Disable CONFIG_CMD_LICENSE, license.h is not used by tools and 14 | # generating it requires bin2header tool, which for target build 15 | # is built with target tools and thus cannot be executed on host. 16 | sed -i "s/CONFIG_CMD_LICENSE=.*/# CONFIG_CMD_LICENSE is not set/" .config 17 | 18 | oe_runmake cross_tools NO_SDL=1 19 | } 20 | 21 | do_install () { 22 | install -d ${D}${bindir} 23 | install -m 0755 tools/mkimage ${D}${bindir}/uboot-mkimage 24 | ln -sf uboot-mkimage ${D}${bindir}/mkimage 25 | } 26 | 27 | RDEPENDS_${PN} += "dtc" 28 | 29 | BBCLASSEXTEND = "native nativesdk" 30 | -------------------------------------------------------------------------------- /recipes-connectivity/bluetooth/bluetooth-rockpi-s.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Systemd service to setup BT for RockPi-S" 2 | DESCRIPTION = "Load Realtek Bluetooth Driver and Firmware for RTL8723DS chip" 3 | SECTION = "devel" 4 | 5 | LICENSE = "GPLv2" 6 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" 7 | 8 | SRC_URI = " \ 9 | file://${MACHINE}/install-module-hci-uart.service;name=btmodule-rockpis-service \ 10 | file://${MACHINE}/rtl8723ds-btfw-load.service;name=btfw-rockpis-service \ 11 | file://${MACHINE}/install_module_hci_uart;name=btmodule-rockpis-script \ 12 | " 13 | SRC_URI[btmodule-rockpis-service.md5sum] = "0dc7fac039b3c1625e17bccd3d406770" 14 | SRC_URI[btfw-rockpis-service.md5sum] = "78a4765dfdab9bc044f01bc1e0dc20ff" 15 | SRC_URI[btmodule-rockpis-script.md5sum] = "e141e4ed81aa3c0cd634808cc2e5c740" 16 | 17 | S = "${WORKDIR}" 18 | 19 | inherit systemd 20 | 21 | RDEPENDS_${PN} += "bluez5" 22 | 23 | do_install() { 24 | install -d ${D}${systemd_system_unitdir} 25 | install -m 0644 ${WORKDIR}/${MACHINE}/install-module-hci-uart.service ${D}${systemd_system_unitdir} 26 | install -m 0644 ${WORKDIR}/${MACHINE}/rtl8723ds-btfw-load.service ${D}${systemd_system_unitdir} 27 | install -d ${D}${bindir} 28 | install -m 0755 ${WORKDIR}/${MACHINE}/install_module_hci_uart ${D}${bindir}/install_module_hci_uart 29 | } 30 | 31 | SYSTEMD_SERVICE_${PN} = "install-module-hci-uart.service rtl8723ds-btfw-load.service" 32 | -------------------------------------------------------------------------------- /recipes-connectivity/bluetooth/bluetooth-broadcom.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Systemd service to setup BT for Broadcom Bluetooth chips" 2 | DESCRIPTION = "Load Broadcom Bluetooth Chips Firmware" 3 | SECTION = "devel" 4 | 5 | LICENSE = "GPLv2" 6 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6" 7 | 8 | SRC_URI = " \ 9 | file://broadcom-bluetooth/brcm-btfw-load.service;name=brcm-btfw-load-service \ 10 | file://broadcom-bluetooth/brcm-btfw-update.service;name=brcm-btfw-update-service \ 11 | file://broadcom-bluetooth/update-brcm-btfw-load-service.sh;name=update-brcm-btfw-load-service-script \ 12 | " 13 | SRC_URI[brcm-btfw-load-service.md5sum] = "8e2c44ed070ef4544a12f702575fbc37" 14 | SRC_URI[brcm-btfw-update-service.md5sum] = "0762eb091d41d24a709a1679d1ce38f6" 15 | SRC_URI[update-brcm-btfw-load-service-script.md5sum] = "865e47d2d247b9435d73a78369b82c14" 16 | 17 | inherit systemd 18 | 19 | RDEPENDS_${PN} += "bluez5" 20 | 21 | do_install() { 22 | install -d ${D}${systemd_system_unitdir} 23 | install -m 0644 ${WORKDIR}/broadcom-bluetooth/brcm-btfw-load.service ${D}${systemd_system_unitdir} 24 | install -m 0644 ${WORKDIR}/broadcom-bluetooth/brcm-btfw-update.service ${D}${systemd_system_unitdir} 25 | install -d ${D}${bindir} 26 | install -m 0755 ${WORKDIR}/broadcom-bluetooth/update-brcm-btfw-load-service.sh ${D}${bindir}/update-brcm-btfw-load-service.sh 27 | } 28 | 29 | SYSTEMD_SERVICE_${PN} = "brcm-btfw-load.service brcm-btfw-update.service" 30 | -------------------------------------------------------------------------------- /recipes-devtools/mraa-radxa/mraa-radxa_git.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Linux Library for low speed I/O Communication" 2 | HOMEPAGE = "https://github.com/radxa/mraa" 3 | SECTION = "libs" 4 | 5 | LICENSE = "MIT" 6 | LIC_FILES_CHKSUM = "file://COPYING;md5=91e7de50a8d3cf01057f318d72460acd" 7 | 8 | SRCREV = "06b2be27c77abf5b5b7af4644151049d60e54053" 9 | PV = "2.1.0+git${SRCPV}" 10 | 11 | SRC_URI = "git://github.com/radxa/mraa.git;protocol=http \ 12 | " 13 | 14 | S = "${WORKDIR}/git" 15 | 16 | # CMakeLists.txt checks the architecture, only x86 and ARM supported for now 17 | COMPATIBLE_HOST = "(x86_64.*|i.86.*|aarch64.*|arm.*)-linux" 18 | 19 | inherit cmake distutils3-base 20 | 21 | DEPENDS += "json-c" 22 | 23 | EXTRA_OECMAKE_append = " -DINSTALLTOOLS:BOOL=ON -DFIRMATA=ON -DCMAKE_SKIP_RPATH=ON \ 24 | -DPYTHON3_PACKAGES_PATH:PATH=${baselib}/python${PYTHON_BASEVERSION}/site-packages \ 25 | -DBUILDSWIGNODE=OFF \ 26 | " 27 | 28 | # Prepend mraa-utils to make sure bindir ends up in there 29 | PACKAGES =+ "${PN}-utils" 30 | 31 | FILES_${PN}-doc += "${datadir}/mraa/examples/" 32 | 33 | FILES_${PN}-utils = "${bindir}/" 34 | 35 | PACKAGECONFIG ??= "python" 36 | 37 | PACKAGECONFIG[python] = "-DBUILDSWIGPYTHON=ON, -DBUILDSWIGPYTHON=OFF, swig-native ${PYTHON_PN}," 38 | PACKAGECONFIG[ft4222] = "-DUSBPLAT=ON -DFTDI4222=ON, -DUSBPLAT=OFF -DFTDI4222=OFF,, libft4222" 39 | 40 | FILES_${PYTHON_PN}-${PN} = "${PYTHON_SITEPACKAGES_DIR}/" 41 | RDEPENDS_${PYTHON_PN}-${PN} += "${PYTHON_PN}" 42 | -------------------------------------------------------------------------------- /recipes-devtools/create-ap/create-ap_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Create AP" 2 | SECTION = "devel" 3 | LICENSE = "BSD" 4 | LIC_FILES_CHKSUM = "file://LICENSE;md5=47819091dc3777f6899ac4e6dbff2613" 5 | 6 | SRC_URI = "git://github.com/oblique/create_ap.git;branch=master;" 7 | SRCREV = "${AUTOREV}" 8 | 9 | SRC_URI[md5sum] = "dc6c5a027508ffa09d2c3c2ed152e14a" 10 | SRC_URI[sha256sum] = "d86f0d46f044bf0f2b76e8e90e02e4f778d4e873aec82cffa5914839eb356744" 11 | 12 | S = "${WORKDIR}/git" 13 | 14 | inherit systemd 15 | 16 | RDEPENDS_${PN} += "bash util-linux procps hostapd iw dnsmasq" 17 | 18 | do_install() { 19 | install -d ${D}/${bindir} 20 | install -d ${D}/${bindir}/create_ap 21 | install -m 0755 "${S}/create_ap" ${D}/${bindir}/create_ap/create_ap 22 | 23 | install -d ${D}/${sysconfdir} 24 | install -m 0644 "${S}/create_ap.conf" ${D}/${sysconfdir}/create_ap.conf 25 | 26 | install -d ${D}/${systemd_system_unitdir} 27 | install -m 0644 "${S}/create_ap.service" ${D}/${systemd_system_unitdir}/create_ap.service 28 | 29 | install -d ${D}/${datadir} 30 | install -d ${D}/${datadir}/bash-completion/completions 31 | install -m 0644 "${S}/bash_completion" ${D}/${datadir}/bash-completion/completions/create_ap 32 | 33 | install -d ${D}/${docdir} 34 | install -d ${D}/${docdir}/create_ap 35 | install -m 0644 "${S}/README.md" ${D}/${docdir}/create_ap/README.md 36 | } 37 | 38 | FILES_${PN} += "\ 39 | ${datadir}/bash-completion/* \ 40 | " 41 | 42 | SYSTEMD_SERVICE_${PN} = "create_ap.service" 43 | 44 | do_configure[noexec] = "1" 45 | do_compile[noexec] = "1" 46 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/u-boot-rockpi.inc: -------------------------------------------------------------------------------- 1 | require recipes-bsp/u-boot/u-boot.inc 2 | 3 | HOMEPAGE = "https://github.com/radxa/u-boot" 4 | LICENSE = "GPLv2+" 5 | COMPATIBLE_MACHINE = "(px30|rk3036|rk3066|rk3188|rk3288|rk3328|rk3399|rk3308|rk3399pro)" 6 | SECTION = "bootloaders" 7 | DEPENDS = "dtc-native bc-native swig-native bison-native coreutils-native" 8 | 9 | S = "${WORKDIR}/git" 10 | 11 | # u-boot will build native python module 12 | inherit pythonnative 13 | 14 | do_configure () { 15 | if [ -z "${UBOOT_CONFIG}" ]; then 16 | if [ -n "${UBOOT_MACHINE}" ]; then 17 | oe_runmake -C ${S} O=${B} ${UBOOT_MACHINE} 18 | else 19 | oe_runmake -C ${S} O=${B} oldconfig 20 | fi 21 | echo ${PWD} 22 | ${S}/scripts/kconfig/merge_config.sh -m .config ${@" ".join(find_cfgs(d))} 23 | cml1_do_configure 24 | fi 25 | } 26 | 27 | do_compile_prepend () { 28 | export STAGING_INCDIR=${STAGING_INCDIR_NATIVE}; 29 | export STAGING_LIBDIR=${STAGING_LIBDIR_NATIVE}; 30 | } 31 | 32 | do_compile_append () { 33 | # copy to default search path 34 | if [ ${SPL_BINARY} ]; then 35 | cp ${B}/spl/${SPL_BINARY} ${B}/ 36 | fi 37 | if [ -f "${WORKDIR}/${MACHINE}/boot.cmd" ]; then 38 | cp ${WORKDIR}/${MACHINE}/boot.cmd ${WORKDIR}/boot.cmd 39 | ${B}/tools/mkimage -C none -A arm -T script -d ${WORKDIR}/boot.cmd ${WORKDIR}/boot.scr 40 | fi 41 | } 42 | 43 | do_deploy_append() { 44 | cp -a ${B}/tools/mkimage ${DEPLOY_DIR_IMAGE} 45 | if [ -f "${WORKDIR}/${MACHINE}/uEnv.txt" ]; then 46 | install -D -m 644 ${WORKDIR}/${MACHINE}/uEnv.txt ${DEPLOYDIR}/ 47 | fi 48 | if [ -f "${WORKDIR}/boot.scr" ]; then 49 | install -D -m 644 ${WORKDIR}/boot.scr ${DEPLOYDIR}/ 50 | fi 51 | if [ -f "${WORKDIR}/boot.cmd" ]; then 52 | install -D -m 644 ${WORKDIR}/boot.cmd ${DEPLOYDIR}/ 53 | fi 54 | } 55 | -------------------------------------------------------------------------------- /recipes-devtools/rtl-tools/files/hciattach.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * BlueZ - Bluetooth protocol stack for Linux 4 | * 5 | * Copyright (C) 2003-2009 Marcel Holtmann 6 | * 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License as published by 10 | * the Free Software Foundation; either version 2 of the License, or 11 | * (at your option) any later version. 12 | * 13 | * This program is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | * GNU General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU General Public License 19 | * along with this program; if not, write to the Free Software 20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 21 | * 22 | */ 23 | 24 | #include 25 | 26 | #ifndef N_HCI 27 | #define N_HCI 15 28 | #endif 29 | 30 | #define HCIUARTSETPROTO _IOW('U', 200, int) 31 | #define HCIUARTGETPROTO _IOR('U', 201, int) 32 | #define HCIUARTGETDEVICE _IOR('U', 202, int) 33 | #define HCIUARTSETFLAGS _IOW('U', 203, int) 34 | #define HCIUARTGETFLAGS _IOR('U', 204, int) 35 | 36 | #define HCI_UART_H4 0 37 | #define HCI_UART_BCSP 1 38 | #define HCI_UART_3WIRE 2 39 | #define HCI_UART_H4DS 3 40 | #define HCI_UART_LL 4 41 | #define HCI_UART_RAW_DEVICE 0 42 | 43 | int read_hci_event(int fd, unsigned char* buf, int size); 44 | int set_speed(int fd, struct termios *ti, int speed); 45 | /* 46 | int texas_init(int fd, struct termios *ti); 47 | int texas_post(int fd, struct termios *ti); 48 | int texasalt_init(int fd, int speed, struct termios *ti); 49 | int stlc2500_init(int fd, bdaddr_t *bdaddr); 50 | int bgb2xx_init(int dd, bdaddr_t *bdaddr); 51 | */ 52 | 53 | //Realtek_add_start 54 | //add realtek init and post process for realtek Bluetooth chip 55 | int rtk_init(int fd, int proto, int speed, struct termios *ti); 56 | int rtk_post(int fd, int proto, struct termios *ti); 57 | //Realtek_add_end 58 | -------------------------------------------------------------------------------- /recipes-devtools/brcm-tools/files/dhd_priv.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #define VERSION "1.2" 14 | 15 | #define TAG "dhd_priv: " 16 | #if defined(ANDROID) 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include "cutils/misc.h" 22 | #include "cutils/log.h" 23 | #define DHD_PRINTF(...) {__android_log_print(ANDROID_LOG_DEBUG,TAG ,__VA_ARGS__); printf(__VA_ARGS__);} 24 | #else 25 | #define DHD_PRINTF printf 26 | #endif 27 | 28 | typedef struct dhd_priv_cmd { 29 | char *buf; 30 | int used_len; 31 | int total_len; 32 | } dhd_priv_cmd; 33 | 34 | /* 35 | terence 20161127 36 | */ 37 | 38 | int 39 | main(int argc, char **argv) 40 | { 41 | struct ifreq ifr; 42 | dhd_priv_cmd priv_cmd; 43 | int ret = 0; 44 | int ioctl_sock; /* socket for ioctl() use */ 45 | char buf[500]=""; 46 | int i=0; 47 | 48 | DHD_PRINTF(TAG "Version = %s\n", VERSION); 49 | 50 | DHD_PRINTF("argv: "); 51 | while (argv[i]) { 52 | DHD_PRINTF("%s ", argv[i]); 53 | i++; 54 | } 55 | DHD_PRINTF("\n"); 56 | 57 | if (!argv[1]) { 58 | DHD_PRINTF("Please input right cmd\n"); 59 | return 0; 60 | } 61 | 62 | while (*++argv) { 63 | strcat(buf, *argv); 64 | if (*(argv+1)) 65 | strcat(buf, " "); 66 | } 67 | 68 | ioctl_sock = socket(PF_INET, SOCK_DGRAM, 0); 69 | if (ioctl_sock < 0) { 70 | DHD_PRINTF(TAG "socket(PF_INET,SOCK_DGRAM)\n"); 71 | return -1; 72 | } 73 | 74 | memset(&ifr, 0, sizeof(ifr)); 75 | memset(&priv_cmd, 0, sizeof(priv_cmd)); 76 | strncpy(ifr.ifr_name, "wlan0", sizeof(ifr.ifr_name)); 77 | 78 | priv_cmd.buf = buf; 79 | priv_cmd.used_len = 500; 80 | priv_cmd.total_len = 500; 81 | ifr.ifr_data = &priv_cmd; 82 | 83 | if ((ret = ioctl(ioctl_sock, SIOCDEVPRIVATE + 1, &ifr)) < 0) { 84 | DHD_PRINTF(TAG "failed to issue private commands %d\n", ret); 85 | } else { 86 | DHD_PRINTF(TAG "buf = %s, len = %d, ret = %d\n", buf, strlen(buf), ret); 87 | } 88 | 89 | close(ioctl_sock); 90 | return ret; 91 | } 92 | 93 | -------------------------------------------------------------------------------- /recipes-core/busybox/busybox/0001-Add-support-reboot-loader-command.patch: -------------------------------------------------------------------------------- 1 | From 927e8ba2001ace97467033e6ab40deda742f1160 Mon Sep 17 00:00:00 2001 2 | From: Cody Xie 3 | Date: Sat, 7 Jan 2017 11:02:06 +0800 4 | Subject: [PATCH 9/9] Add support reboot loader command. 5 | 6 | Signed-off-by: huaping.liao 7 | Signed-off-by: Cody Xie 8 | --- 9 | init/halt.c | 9 ++++++++- 10 | init/init.c | 5 +++++ 11 | 2 files changed, 13 insertions(+), 1 deletion(-) 12 | 13 | diff --git a/init/halt.c b/init/halt.c 14 | index 572d751..6b5c975 100644 15 | --- a/init/halt.c 16 | +++ b/init/halt.c 17 | @@ -103,7 +103,8 @@ int halt_main(int argc UNUSED_PARAM, char **argv) 18 | RB_POWER_OFF, 19 | RB_AUTOBOOT 20 | }; 21 | - static const smallint signals[] = { SIGUSR1, SIGUSR2, SIGTERM }; 22 | + // add SIGPWR for reboot loader 23 | + static const smallint signals[] = { SIGUSR1, SIGUSR2, SIGTERM, SIGPWR }; 24 | 25 | int delay = 0; 26 | int which, flags, rc; 27 | @@ -139,6 +140,12 @@ int halt_main(int argc UNUSED_PARAM, char **argv) 28 | /* talk to linuxrc */ 29 | /* bbox init/linuxrc assumed */ 30 | pid_t *pidlist = find_pid_by_name("linuxrc"); 31 | + //set reboot parameter 32 | + if (signals[which] == SIGTERM) { 33 | + if (argc > 1 && strstr(argv[1], "loader") != NULL) { 34 | + which++; 35 | + } 36 | + } 37 | if (pidlist[0] > 0) 38 | rc = kill(pidlist[0], signals[which]); 39 | if (ENABLE_FEATURE_CLEAN_UP) 40 | diff --git a/init/init.c b/init/init.c 41 | index 6eb76b8..169d8c2 100644 42 | --- a/init/init.c 43 | +++ b/init/init.c 44 | @@ -801,6 +802,7 @@ static void run_shutdown_and_kill_processes(void) 45 | */ 46 | 47 | /* The SIGPWR/SIGUSR[12]/SIGTERM handler */ 48 | +#define RB_AUTOBOOT_CMD 0xa1b2c3d4 49 | static void halt_reboot_pwoff(int sig) NORETURN; 50 | static void halt_reboot_pwoff(int sig) 51 | { 52 | @@ -825,6 +827,9 @@ static void halt_reboot_pwoff(int sig) 53 | } else if (sig == SIGUSR2) { 54 | m = "poweroff"; 55 | rb = RB_POWER_OFF; 56 | + } else if (sig == SIGPWR) { 57 | + m = "reboot loader"; 58 | + rb = RB_AUTOBOOT_CMD; 59 | } 60 | message(L_CONSOLE, "Requesting system %s", m); 61 | pause_and_low_level_reboot(rb); 62 | -- 63 | 2.7.4 64 | -------------------------------------------------------------------------------- /recipes-connectivity/bluetooth/files/broadcom-bluetooth/update-brcm-btfw-load-service.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | FIRMWARE="/system/etc/firmware" 4 | 5 | found=0 6 | MMC=("mmc0" " mmc1" " mmc2") 7 | for mmc in ${MMC[@]} 8 | do 9 | if [[ -f /sys/bus/sdio/devices/${mmc}:0001:1/vendor ]] && [[ -f /sys/bus/sdio/devices/${mmc}:0001:1/device ]]; then 10 | VENDOR=$(cat /sys/bus/sdio/devices/${mmc}:0001:1/vendor) 11 | DEVICE=$(cat /sys/bus/sdio/devices/${mmc}:0001:1/device) 12 | found=1 13 | break 14 | fi 15 | done 16 | 17 | if [[ "$found" == "0" ]]; then 18 | echo "Do not need to load Bluetooth firmware." 19 | echo "Exit." 20 | exit 0 21 | fi 22 | 23 | echo "VENDOR=$VENDOR" 24 | echo "DEVICE=$DEVICE" 25 | 26 | BT_UART="$(strings /sys/firmware/fdt | grep bt_uart)" 27 | if [[ -n ${BT_UART} ]]; then 28 | NUMBER=$(echo "${BT_UART}" | cut -d "_" -f2 | cut -d "t" -f2) 29 | BT_UART="/dev/ttyS${NUMBER}" 30 | else 31 | exit 0 32 | fi 33 | echo "BT_UART: ${BT_UART}" 34 | 35 | if [[ "$VENDOR" == "0x02d0" ]]; then 36 | # ap6236 37 | if [[ "$DEVICE" == "0xa9a6" ]]; then 38 | FIRMWARE="$FIRMWARE/BCM4343B0.hcd" 39 | echo "load ap6236 bt firmware" 40 | # ap6256 41 | elif [[ "$DEVICE" == "0xa9bf" ]]; then 42 | FIRMWARE="$FIRMWARE/BCM4345C5.hcd" 43 | echo "load ap6256 bt firmware" 44 | # ap6398s 45 | elif [[ "$DEVICE" == "0x4359" ]]; then 46 | FIRMWARE="$FIRMWARE/BCM4359C0.hcd" 47 | echo "load ap6398s bt firmware" 48 | fi 49 | fi 50 | 51 | echo "Update file /lib/systemd/system/brcm-btfw-load.service" 52 | 53 | cat > /lib/systemd/system/brcm-btfw-load.service < /dev/null 2>&1 & 64 | ExecStop=/usr/bin/killall brcm_patchram_plus 65 | Restart=on-failure 66 | RestartSec=2 67 | StandardOutput=null 68 | [Install] 69 | WantedBy=multi-user.target 70 | EOF 71 | -------------------------------------------------------------------------------- /recipes-kernel/linux/files/0001-Fix-GCC-9-Wmissing-attributes-warnings-error.patch: -------------------------------------------------------------------------------- 1 | From 72ed8cca076dff8767132fb38227d626237f1ebe Mon Sep 17 00:00:00 2001 2 | From: nishantpoorswani 3 | Date: Wed, 28 Oct 2020 16:17:55 +0530 4 | Subject: [PATCH] GCC 9 adds the -Wmissing-attributes warnings(enabled by 5 | -Wall), which trigger for all the init/cleanup_module aliases in the kernel 6 | (defined by the module_init/exit macros), ending up being very noisy. 7 | 8 | These aliases point to the __init/__exit functions of a module, 9 | which are defined as __cold (among other attributes). However, 10 | the aliases themselves do not have the __cold attribute. 11 | 12 | Since the compiler behaves differently when compiling a __cold 13 | function as well as when compiling paths leading to calls 14 | to __cold functions, the warning is trying to point out 15 | the possibly-forgotten attribute in the alias. 16 | 17 | In order to keep the warning enabled, we choose to silence 18 | the warning by marking the aliases as __cold. This is possible 19 | marking either the extern declaration, the definition, or both. 20 | In order to avoid changing the behavior of callers, we do it 21 | only in the definition of the aliases (since those are not 22 | seen by any other TU). 23 | 24 | Ref: https://lore.kernel.org/lkml/20190123173707.GA16603@gmail.com/ 25 | 26 | Signed-off-by: nishantpoorswani 27 | --- 28 | include/linux/module.h | 4 ++-- 29 | 1 file changed, 2 insertions(+), 2 deletions(-) 30 | 31 | diff --git a/include/linux/module.h b/include/linux/module.h 32 | index d79e1e55c1d4..fe9352361d5b 100644 33 | --- a/include/linux/module.h 34 | +++ b/include/linux/module.h 35 | @@ -127,13 +127,13 @@ extern void cleanup_module(void); 36 | #define module_init(initfn) \ 37 | static inline initcall_t __maybe_unused __inittest(void) \ 38 | { return initfn; } \ 39 | - int init_module(void) __attribute__((alias(#initfn))); 40 | + int init_module(void) __cold __attribute__((alias(#initfn))); 41 | 42 | /* This is only required if you want to be unloadable. */ 43 | #define module_exit(exitfn) \ 44 | static inline exitcall_t __maybe_unused __exittest(void) \ 45 | { return exitfn; } \ 46 | - void cleanup_module(void) __attribute__((alias(#exitfn))); 47 | + void cleanup_module(void) __cold __attribute__((alias(#exitfn))); 48 | 49 | #endif 50 | 51 | -- 52 | 2.26.2 53 | 54 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/rockpi-e-rk3328/boot.cmd: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT THIS FILE 2 | # 3 | # Please edit /boot/uEnv.txt to set supported parameters 4 | # 5 | 6 | setenv load_addr "0x05000000" 7 | setenv overlay_error "false" 8 | # default values 9 | setenv overlay_prefix "rockchip" 10 | setenv verbosity "1" 11 | setenv console " " 12 | setenv rootfstype "ext4" 13 | setenv docker_optimizations "on" 14 | 15 | echo "Boot script loaded from ${devtype} ${devnum}" 16 | 17 | if test -e ${devtype} ${devnum}:1 ${prefix}uEnv.txt; then 18 | load ${devtype} ${devnum}:1 ${load_addr} ${prefix}uEnv.txt 19 | env import -t ${load_addr} ${filesize} 20 | fi 21 | 22 | setenv bootargs "console=tty1 console=${console} rw root=PARTUUID=${rootuuid} rootfstype=${rootfstype} init=/sbin/init rootwait" 23 | 24 | if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1"; fi 25 | 26 | load ${devtype} ${devnum}:1 ${kernel_addr_r} ${prefix}${kernelimg} 27 | 28 | load ${devtype} ${devnum}:1 ${fdt_addr_r} ${prefix}${fdtfile} 29 | fdt addr ${fdt_addr_r} 30 | fdt resize 65536 31 | for overlay_file in ${overlays}; do 32 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlays/${overlay_file}.dtbo; then 33 | echo "Applying kernel provided DT overlay ${overlay_file}.dtbo" 34 | fdt apply ${load_addr} || setenv overlay_error "true" 35 | fi 36 | done 37 | for overlay_file in ${user_overlays}; do 38 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then 39 | echo "Applying user provided DT overlay ${overlay_file}.dtbo" 40 | fdt apply ${load_addr} || setenv overlay_error "true" 41 | fi 42 | done 43 | if test "${overlay_error}" = "true"; then 44 | echo "Error applying DT overlays, restoring original DT" 45 | load ${devtype} ${devnum}:1 ${fdt_addr_r} ${prefix}${fdtfile} 46 | else 47 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlays/${overlay_prefix}-fixup.scr; then 48 | echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)" 49 | source ${load_addr} 50 | fi 51 | if test -e ${devtype} ${devnum}:1 ${prefix}overlay-user/fixup.scr; then 52 | load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlay-user/fixup.scr 53 | echo "Applying user provided fixup script (overlay-user/fixup.scr)" 54 | source ${load_addr} 55 | fi 56 | fi 57 | booti ${kernel_addr_r} - ${fdt_addr_r} 58 | # Recompile with: 59 | # mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr 60 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/rockpi-px30/boot.cmd: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT THIS FILE 2 | # 3 | # Please edit /boot/uEnv.txt to set supported parameters 4 | # 5 | 6 | setenv load_addr "0x05000000" 7 | setenv overlay_error "false" 8 | # default values 9 | setenv overlay_prefix "rockchip" 10 | setenv verbosity "1" 11 | setenv console " " 12 | setenv rootfstype "ext4" 13 | setenv docker_optimizations "off" 14 | 15 | echo "Boot script loaded from ${devtype} ${devnum}" 16 | 17 | if test -e ${devtype} ${devnum}:1 ${prefix}uEnv.txt; then 18 | load ${devtype} ${devnum}:1 ${load_addr} ${prefix}uEnv.txt 19 | env import -t ${load_addr} ${filesize} 20 | fi 21 | 22 | setenv bootargs "console=tty1 console=${console} rw root=PARTUUID=${rootuuid} rootfstype=${rootfstype} init=/sbin/init rootwait" 23 | 24 | if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1"; fi 25 | 26 | load ${devtype} ${devnum}:1 ${kernel_addr_r} ${prefix}${kernelimg} 27 | 28 | load ${devtype} ${devnum}:1 ${fdt_addr_r} ${prefix}${fdtfile} 29 | fdt addr ${fdt_addr_r} 30 | fdt resize 65536 31 | for overlay_file in ${overlays}; do 32 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlays/${overlay_file}.dtbo; then 33 | echo "Applying kernel provided DT overlay ${overlay_file}.dtbo" 34 | fdt apply ${load_addr} || setenv overlay_error "true" 35 | fi 36 | done 37 | for overlay_file in ${user_overlays}; do 38 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then 39 | echo "Applying user provided DT overlay ${overlay_file}.dtbo" 40 | fdt apply ${load_addr} || setenv overlay_error "true" 41 | fi 42 | done 43 | if test "${overlay_error}" = "true"; then 44 | echo "Error applying DT overlays, restoring original DT" 45 | load ${devtype} ${devnum}:1 ${fdt_addr_r} ${prefix}${fdtfile} 46 | else 47 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlays/${overlay_prefix}-fixup.scr; then 48 | echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)" 49 | source ${load_addr} 50 | fi 51 | if test -e ${devtype} ${devnum}:1 ${prefix}overlay-user/fixup.scr; then 52 | load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlay-user/fixup.scr 53 | echo "Applying user provided fixup script (overlay-user/fixup.scr)" 54 | source ${load_addr} 55 | fi 56 | fi 57 | booti ${kernel_addr_r} - ${fdt_addr_r} 58 | # Recompile with: 59 | # mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr 60 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/rockpi-s-rk3308/boot.cmd: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT THIS FILE 2 | # 3 | # Please edit /boot/uEnv.txt to set supported parameters 4 | # 5 | 6 | setenv load_addr "0x05000000" 7 | setenv overlay_error "false" 8 | # default values 9 | setenv overlay_prefix "rockchip" 10 | setenv verbosity "1" 11 | setenv console " " 12 | setenv rootfstype "ext4" 13 | setenv docker_optimizations "off" 14 | 15 | echo "Boot script loaded from ${devtype} ${devnum}" 16 | 17 | if test -e ${devtype} ${devnum}:1 ${prefix}uEnv.txt; then 18 | load ${devtype} ${devnum}:1 ${load_addr} ${prefix}uEnv.txt 19 | env import -t ${load_addr} ${filesize} 20 | fi 21 | 22 | setenv bootargs "console=tty1 console=${console} rw root=PARTUUID=${rootuuid} rootfstype=${rootfstype} init=/sbin/init rootwait" 23 | 24 | if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1"; fi 25 | 26 | load ${devtype} ${devnum}:1 ${kernel_addr_r} ${prefix}${kernelimg} 27 | 28 | load ${devtype} ${devnum}:1 ${fdt_addr_r} ${prefix}${fdtfile} 29 | fdt addr ${fdt_addr_r} 30 | fdt resize 65536 31 | for overlay_file in ${overlays}; do 32 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlays/${overlay_file}.dtbo; then 33 | echo "Applying kernel provided DT overlay ${overlay_file}.dtbo" 34 | fdt apply ${load_addr} || setenv overlay_error "true" 35 | fi 36 | done 37 | for overlay_file in ${user_overlays}; do 38 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then 39 | echo "Applying user provided DT overlay ${overlay_file}.dtbo" 40 | fdt apply ${load_addr} || setenv overlay_error "true" 41 | fi 42 | done 43 | if test "${overlay_error}" = "true"; then 44 | echo "Error applying DT overlays, restoring original DT" 45 | load ${devtype} ${devnum}:1 ${fdt_addr_r} ${prefix}${fdtfile} 46 | else 47 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlays/${overlay_prefix}-fixup.scr; then 48 | echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)" 49 | source ${load_addr} 50 | fi 51 | if test -e ${devtype} ${devnum}:1 ${prefix}overlay-user/fixup.scr; then 52 | load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlay-user/fixup.scr 53 | echo "Applying user provided fixup script (overlay-user/fixup.scr)" 54 | source ${load_addr} 55 | fi 56 | fi 57 | booti ${kernel_addr_r} - ${fdt_addr_r} 58 | # Recompile with: 59 | # mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr 60 | -------------------------------------------------------------------------------- /recipes-bsp/u-boot/files/rockpi-n10-rk3399pro/boot.cmd: -------------------------------------------------------------------------------- 1 | # DO NOT EDIT THIS FILE 2 | # 3 | # Please edit /boot/uEnv.txt to set supported parameters 4 | # 5 | 6 | setenv load_addr "0x05000000" 7 | setenv overlay_error "false" 8 | # default values 9 | setenv overlay_prefix "rockchip" 10 | setenv verbosity "1" 11 | setenv console " " 12 | setenv rootfstype "ext4" 13 | setenv docker_optimizations "on" 14 | 15 | echo "Boot script loaded from ${devtype} ${devnum}" 16 | 17 | if test -e ${devtype} ${devnum}:1 ${prefix}uEnv.txt; then 18 | load ${devtype} ${devnum}:1 ${load_addr} ${prefix}uEnv.txt 19 | env import -t ${load_addr} ${filesize} 20 | fi 21 | 22 | setenv bootargs "console=tty1 console=${console} rw root=PARTUUID=${rootuuid} rootfstype=${rootfstype} init=/sbin/init rootwait" 23 | 24 | if test "${docker_optimizations}" = "on"; then setenv bootargs "${bootargs} cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory swapaccount=1"; fi 25 | 26 | load ${devtype} ${devnum}:1 ${kernel_addr_r} ${prefix}${kernelimg} 27 | 28 | load ${devtype} ${devnum}:1 ${fdt_addr_r} ${prefix}${fdtfile} 29 | fdt addr ${fdt_addr_r} 30 | fdt resize 65536 31 | for overlay_file in ${overlays}; do 32 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlays/${overlay_file}.dtbo; then 33 | echo "Applying kernel provided DT overlay ${overlay_file}.dtbo" 34 | fdt apply ${load_addr} || setenv overlay_error "true" 35 | fi 36 | done 37 | for overlay_file in ${user_overlays}; do 38 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlay-user/${overlay_file}.dtbo; then 39 | echo "Applying user provided DT overlay ${overlay_file}.dtbo" 40 | fdt apply ${load_addr} || setenv overlay_error "true" 41 | fi 42 | done 43 | if test "${overlay_error}" = "true"; then 44 | echo "Error applying DT overlays, restoring original DT" 45 | load ${devtype} ${devnum}:1 ${fdt_addr_r} ${prefix}${fdtfile} 46 | else 47 | if load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlays/${overlay_prefix}-fixup.scr; then 48 | echo "Applying kernel provided DT fixup script (${overlay_prefix}-fixup.scr)" 49 | source ${load_addr} 50 | fi 51 | if test -e ${devtype} ${devnum}:1 ${prefix}overlay-user/fixup.scr; then 52 | load ${devtype} ${devnum}:1 ${load_addr} ${prefix}overlay-user/fixup.scr 53 | echo "Applying user provided fixup script (overlay-user/fixup.scr)" 54 | source ${load_addr} 55 | fi 56 | fi 57 | booti ${kernel_addr_r} - ${fdt_addr_r} 58 | # Recompile with: 59 | # mkimage -C none -A arm -T script -d /boot/boot.cmd /boot/boot.scr 60 | -------------------------------------------------------------------------------- /recipes-kernel/linux/files/0001-UPSTREAM-arm64-vdso-Define-vdso_-start-end-as-array.patch: -------------------------------------------------------------------------------- 1 | From b0d48dba0caf1e6aa55e0a5076bb97c729a2db33 Mon Sep 17 00:00:00 2001 2 | From: Kees Cook 3 | Date: Mon, 5 Jun 2017 21:52:30 -0700 4 | Subject: [PATCH] UPSTREAM: arm64, vdso: Define vdso_{start,end} as array 5 | 6 | Adjust vdso_{start|end} to be char arrays to avoid compile-time analysis 7 | that flags "too large" memcmp() calls with CONFIG_FORTIFY_SOURCE. 8 | 9 | Cc: Jisheng Zhang 10 | Acked-by: Catalin Marinas 11 | Suggested-by: Mark Rutland 12 | Signed-off-by: Kees Cook 13 | Signed-off-by: Will Deacon 14 | (cherry picked from commit dbbb08f500d6146398b794fdc68a8e811366b451) 15 | 16 | Change-Id: Ibec1756944779b7da3965855697ee2d797f6c611 17 | Signed-off-by: Randy Li 18 | --- 19 | arch/arm64/kernel/vdso.c | 10 +++++----- 20 | 1 file changed, 5 insertions(+), 5 deletions(-) 21 | 22 | diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c 23 | index 46fa4de..a6f1df6 100644 24 | --- a/arch/arm64/kernel/vdso.c 25 | +++ b/arch/arm64/kernel/vdso.c 26 | @@ -36,7 +36,7 @@ 27 | #include 28 | #include 29 | 30 | -extern char vdso_start, vdso_end; 31 | +extern char vdso_start[], vdso_end[]; 32 | static unsigned long vdso_pages; 33 | static struct page **vdso_pagelist; 34 | 35 | @@ -116,14 +116,14 @@ static int __init vdso_init(void) 36 | int i; 37 | unsigned long pfn; 38 | 39 | - if (memcmp(&vdso_start, "\177ELF", 4)) { 40 | + if (memcmp(vdso_start, "\177ELF", 4)) { 41 | pr_err("vDSO is not a valid ELF object!\n"); 42 | return -EINVAL; 43 | } 44 | 45 | - vdso_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT; 46 | + vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT; 47 | pr_info("vdso: %ld pages (%ld code @ %p, %ld data @ %p)\n", 48 | - vdso_pages + 1, vdso_pages, &vdso_start, 1L, vdso_data); 49 | + vdso_pages + 1, vdso_pages, vdso_start, 1L, vdso_data); 50 | 51 | /* Allocate the vDSO pagelist, plus a page for the data. */ 52 | vdso_pagelist = kcalloc(vdso_pages + 1, sizeof(struct page *), 53 | @@ -136,7 +136,7 @@ static int __init vdso_init(void) 54 | 55 | 56 | /* Grab the vDSO code pages. */ 57 | - pfn = sym_to_pfn(&vdso_start); 58 | + pfn = sym_to_pfn(vdso_start); 59 | 60 | for (i = 0; i < vdso_pages; i++) 61 | vdso_pagelist[i + 1] = pfn_to_page(pfn + i); 62 | -- 63 | 2.7.4 64 | 65 | -------------------------------------------------------------------------------- /recipes-bsp/rk-binary/radxa-binary-loader_git.bb: -------------------------------------------------------------------------------- 1 | DESCRIPTION = "Rockchip-Radxa binary loader" 2 | 3 | LICENSE = "BINARY" 4 | LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=564e729dd65db6f65f911ce0cd340cf9" 5 | NO_GENERIC_LICENSE[BINARY] = "LICENSE.TXT" 6 | 7 | DEPENDS = "radxa-binary-native" 8 | 9 | SRC_URI = "git://github.com/radxa/rkbin.git;branch=master;" 10 | SRCREV = "fb4ce829b87a9a5738ff6ebc9951768c86ad75c1" 11 | 12 | S = "${WORKDIR}/git" 13 | 14 | LOADER_px30 ?= "bin/rk33/px30_loader_v1.14.120.bin" 15 | LOADER_rk3308 ?= "bin/rk33/rk3308_loader_uart0_m0_emmc_port_support_sd_20190717.bin" 16 | LOADER_rk3328 ?= "bin/rk33/rk3328_loader_ddr333_v1.16.250.bin" 17 | LOADER_rk3399 ?= "bin/rk33/rk3399_loader_v1.12.112.bin" 18 | LOADER_rk3399pro ?= "bin/rk33/rk3399pro_loader_v1.20.115.bin" 19 | 20 | MINILOADER_px30 ?= "bin/rk33/px30_miniloader_v1.20.bin" 21 | MINILOADER_rk3308 ?= "bin/rk33/rk3308_miniloader_emmc_port_support_sd_20190717.bin" 22 | MINILOADER_rk3328 ?= "bin/rk33/rk322xh_miniloader_v2.50.bin" 23 | MINILOADER_rk3399 ?= "bin/rk33/rk3399_miniloader_v1.19.bin" 24 | MINILOADER_rk3399pro ?= "bin/rk33/rk3399pro_miniloader_v1.15.bin" 25 | 26 | DDR_px30 ?= "bin/rk33/px30_ddr_333MHz_v1.14.bin" 27 | DDR_rk3308 ?= "bin/rk33/rk3308_ddr_589MHz_uart0_m0_v1.26.bin" 28 | DDR_rk3328 ?= "bin/rk33/rk3328_ddr_333MHz_v1.16.bin" 29 | DDR_rk3399 ?= "bin/rk33/rk3399_ddr_800MHz_v1.20.bin" 30 | DDR_rk3399pro ?= "bin/rk33/rk3399_ddr_800MHz_v1.20.bin" 31 | 32 | BL31_px30 ?= "bin/rk33/px30_bl31_v1.18.elf" 33 | BL31_rk3308 ?= "bin/rk33/rk3308_bl31_v2.10.elf" 34 | BL31_rk3328 ?= "bin/rk33/rk322xh_bl31_v1.42.elf" 35 | BL31_rk3399 ?= "bin/rk33/rk3399_bl31_v1.26.elf" 36 | BL31_rk3399pro ?= "bin/rk33/rk3399pro_bl31_v1.22.elf" 37 | 38 | inherit deploy 39 | 40 | DDR_BIN = "ddr.bin" 41 | LOADER_BIN = "loader.bin" 42 | MINILOADER_BIN = "miniloader.bin" 43 | ATF_BIN = "atf.bin" 44 | UBOOT_IMG = "uboot.img" 45 | BL31_ELF = "bl31.elf" 46 | 47 | RKBINARY_DEPLOY_DIR = "${DEPLOYDIR}/radxa-binary" 48 | 49 | do_deploy () { 50 | install -d ${RKBINARY_DEPLOY_DIR} 51 | [ ${DDR} ] && cp ${S}/${DDR} ${RKBINARY_DEPLOY_DIR}/${DDR_BIN} 52 | [ ${MINILOADER} ] && cp ${S}/${MINILOADER} ${RKBINARY_DEPLOY_DIR}/${MINILOADER_BIN} 53 | [ ${LOADER} ] && cp ${S}/${LOADER} ${RKBINARY_DEPLOY_DIR}/${LOADER_BIN} 54 | [ ${ATF} ] && cp ${S}/${ATF} ${RKBINARY_DEPLOY_DIR}/${ATF_BIN} 55 | [ ${BL31} ] && cp ${S}/${BL31} ${RKBINARY_DEPLOY_DIR}/${BL31_ELF} 56 | } 57 | 58 | addtask deploy before do_build after do_compile 59 | 60 | do_package[noexec] = "1" 61 | do_packagedata[noexec] = "1" 62 | do_package_write[noexec] = "1" 63 | do_package_write_ipk[noexec] = "1" 64 | do_package_write_rpm[noexec] = "1" 65 | do_package_write_deb[noexec] = "1" 66 | do_package_write_tar[noexec] = "1" 67 | -------------------------------------------------------------------------------- /recipes-kernel/kernel-module-headers/kernel-module-headers.bb: -------------------------------------------------------------------------------- 1 | SUMMARY = "Linux kernel modules headers" 2 | DESCRIPTION = "This recipe generates a kernel modules headers archive from \ 3 | the linux kernel source. The headers are needed for OOT module building \ 4 | and are taking up less space than the entire linux kernel source tree. \ 5 | " 6 | SECTION = "devel/kernel" 7 | LICENSE = "MIT" 8 | LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" 9 | 10 | DEPENDS += " \ 11 | virtual/kernel \ 12 | bc-native \ 13 | bison-native \ 14 | openssl \ 15 | openssl-native \ 16 | util-linux-native \ 17 | elfutils-native \ 18 | util-linux \ 19 | elfutils \ 20 | " 21 | 22 | SRC_URI = "file://gen_mod_headers" 23 | 24 | S = "${WORKDIR}" 25 | B = "${WORKDIR}" 26 | 27 | inherit deploy kernel-arch 28 | 29 | HOSTCC = "${BUILD_CC} ${BUILD_CFLAGS} ${BUILD_LDFLAGS}" 30 | 31 | do_configure[noexec] = "1" 32 | 33 | do_compile() { 34 | mkdir -p kernel_modules_headers 35 | chmod +x ${S}/gen_mod_headers 36 | ${S}/gen_mod_headers ./kernel_modules_headers ${STAGING_KERNEL_DIR} ${STAGING_KERNEL_BUILDDIR} ${ARCH} ${TARGET_PREFIX} "${CC}" "${HOSTCC}" 37 | 38 | # Sanity test 39 | 40 | file_output=$(find kernel_modules_headers/ | xargs file | grep ELF) 41 | echo "$file_output" | while read -r a; do 42 | if echo "$a" | grep -Fiq "sysroot" ; then 43 | bbwarn "$a" 44 | bbwarn "Sysroot keyword found in interpreter ELF files" 45 | exit 1 46 | fi 47 | done 48 | 49 | tar -czf ${B}/kernel_modules_headers.tar.gz kernel_modules_headers 50 | } 51 | 52 | do_install() { 53 | install -d ${D}/usr/src/linux-headers 54 | cd kernel_modules_headers 55 | find . -type f -exec install -D "{}" "${D}/usr/src/linux-headers/{}" \; 56 | } 57 | 58 | do_deploy() { 59 | cp ${B}/kernel_modules_headers.tar.gz ${DEPLOYDIR} 60 | rm -rf ${B}/kernel_modules_headers 61 | } 62 | 63 | do_compile[depends] += "virtual/kernel:do_deploy virtual/kernel:do_patch" 64 | addtask deploy before do_package after do_install 65 | 66 | PACKAGE_ARCH = "${MACHINE_ARCH}" 67 | FILES_${PN} += "/usr/src/*" 68 | 69 | # Tools inside the headers package are slightly special. 70 | # Skip some QA checks. We are interested in the arch check only. 71 | INSANE_SKIP_${PN} = "file-rdeps ldflags staticdev already-stripped" 72 | 73 | # gen_mod_headers uses host tools on the build machine while running 74 | # make modules_prepare. gcc on the build host might not support the 75 | # -fmacro-prefix-map option which is quite recent and introduced in 76 | # Yocto since warrior. Remove it for this recipe 77 | DEBUG_PREFIX_MAP_remove = "-fmacro-prefix-map=${WORKDIR}=/usr/src/debug/${PN}/${EXTENDPE}${PV}-${PR}" 78 | -------------------------------------------------------------------------------- /recipes-bsp/resize-helper/files/resize-helper: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) Fathi Boudra 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 1. Redistributions of source code must retain the above copyright 9 | # notice, this list of conditions and the following disclaimer. 10 | # 2. Redistributions in binary form must reproduce the above copyright 11 | # notice, this list of conditions and the following disclaimer in the 12 | # documentation and/or other materials provided with the distribution. 13 | # 14 | # THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 15 | # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17 | # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 18 | # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 | # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 | # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 | # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 | # SUCH DAMAGE. 25 | 26 | # we must be root 27 | [ $(whoami) = "root" ] || { echo "E: You must be root" && exit 1; } 28 | 29 | # we must have few tools 30 | SGDISK=$(which sgdisk) || { echo "E: You must have sgdisk" && exit 1; } 31 | PARTED=$(which parted) || { echo "E: You must have parted" && exit 1; } 32 | PARTPROBE=$(which partprobe) || { echo "E: You must have partprobe" && exit 1; } 33 | RESIZE2FS=$(which resize2fs) || { echo "E: You must have resize2fs" && exit 1; } 34 | BLKID=$(which blkid) || { echo "E: You must have blkid" && exit 1; } 35 | 36 | # find root device 37 | ROOT_DEVICE=$(findmnt / -o source -n) 38 | # prune root device (for example UUID) 39 | ROOT_DEVICE=$(realpath ${ROOT_DEVICE}) 40 | # get the partition number and type 41 | ROOT_PART_NAME=$(echo "$ROOT_DEVICE" | cut -d "/" -f 3) 42 | DEVICE_NAME=$(echo /sys/block/*/"${ROOT_PART_NAME}" | cut -d "/" -f 4) 43 | DEVICE="/dev/${DEVICE_NAME}" 44 | PART_ENTRY_NUMBER=$(cat "/sys/block/${DEVICE_NAME}/${ROOT_PART_NAME}/partition") 45 | PART_TABLE_TYPE=$(${BLKID} -o value -s PTTYPE "${DEVICE}") 46 | DEVICE_SIZE=$(cat "/sys/block/${DEVICE_NAME}/size") 47 | END_SIZE=$((DEVICE_SIZE - 1)) 48 | 49 | # in case the root device is not on a partitioned media 50 | if [ "x$PART_ENTRY_NUMBER" = "x" ]; then 51 | ${RESIZE2FS} "${ROOT_DEVICE}" 52 | exit 0 53 | fi 54 | 55 | if [ "$PART_TABLE_TYPE" = "gpt" ]; then 56 | ${SGDISK} -e ${DEVICE} 57 | ${PARTPROBE} 58 | fi 59 | ${PARTED} ${DEVICE} resizepart ${PART_ENTRY_NUMBER} 100% 60 | ${PARTPROBE} 61 | ${RESIZE2FS} "${ROOT_DEVICE}" -------------------------------------------------------------------------------- /recipes-kernel/rkwifibt-firmware/rkwifibt-firmware.bb: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2019, Fuzhou Rockchip Electronics Co., Ltd 2 | 3 | SUMMARY = "Rockchip WIFI/BT firmware files" 4 | SECTION = "kernel" 5 | 6 | LICENSE = "Apache-2.0" 7 | LIC_FILES_CHKSUM = "file://NOTICE;md5=9645f39e9db895a4aa6e02cb57294595" 8 | 9 | SRCREV = "${AUTOREV}" 10 | SRC_URI = "git://github.com/nishantpoorswani/rkwifibt.git" 11 | 12 | S = "${WORKDIR}/git" 13 | 14 | inherit allarch deploy 15 | 16 | do_install() { 17 | install -d ${D}/system/etc/firmware/ 18 | install -m 0644 ${S}/firmware/broadcom/AP6236/*/* \ 19 | -t ${D}/system/etc/firmware/ 20 | install -m 0644 ${S}/firmware/broadcom/AP6255/*/* \ 21 | -t ${D}/system/etc/firmware/ 22 | install -m 0644 ${S}/firmware/broadcom/AP6256/*/* \ 23 | -t ${D}/system/etc/firmware/ 24 | install -m 0644 ${S}/firmware/broadcom/AP6356/*/* \ 25 | -t ${D}/system/etc/firmware/ 26 | install -m 0644 ${S}/firmware/broadcom/AP6398S/*/* \ 27 | -t ${D}/system/etc/firmware/ 28 | install -d ${D}${base_libdir}/firmware/rtlbt/ 29 | install -m 0644 ${S}/realtek/RTL8723DS/* -t ${D}${base_libdir}/firmware/rtlbt/ 30 | install -m 0644 ${S}/realtek/RTL8723DU/* -t ${D}${base_libdir}/firmware/ 31 | install -m 0644 ${S}/realtek/RTL8821CU/* -t ${D}${base_libdir}/firmware/ 32 | } 33 | 34 | PACKAGES =+ " \ 35 | ${PN}-ap6236-wifi \ 36 | ${PN}-ap6236-bt \ 37 | ${PN}-ap6255-wifi \ 38 | ${PN}-ap6255-bt \ 39 | ${PN}-ap6256-wifi \ 40 | ${PN}-ap6256-bt \ 41 | ${PN}-ap6356-wifi \ 42 | ${PN}-ap6356-bt \ 43 | ${PN}-ap6398s-wifi \ 44 | ${PN}-ap6398s-bt \ 45 | ${PN}-rtl8723ds-bt \ 46 | ${PN}-rtl8723du-bt \ 47 | ${PN}-rtl8821cu-bt \ 48 | " 49 | 50 | FILES_${PN}-ap6236-wifi = " \ 51 | system/etc/firmware/fw_bcm43436b0.bin \ 52 | system/etc/firmware/nvram_ap6236.txt \ 53 | " 54 | 55 | FILES_${PN}-ap6236-bt = " \ 56 | system/etc/firmware/BCM4343B0.hcd \ 57 | " 58 | 59 | FILES_${PN}-ap6255-wifi = " \ 60 | system/etc/firmware/fw_bcm43455c0_ag.bin \ 61 | system/etc/firmware/fw_bcm43455c0_ag_p2p.bin \ 62 | system/etc/firmware/nvram_ap6255.txt \ 63 | " 64 | 65 | FILES_${PN}-ap6255-bt = " \ 66 | system/etc/firmware/BCM4345C0.hcd \ 67 | " 68 | 69 | FILES_${PN}-ap6256-wifi = " \ 70 | system/etc/firmware/fw_bcm43456c5_ag.bin \ 71 | system/etc/firmware/fw_bcm43456c5_ag_p2p.bin \ 72 | system/etc/firmware/nvram_ap6256.txt \ 73 | " 74 | 75 | FILES_${PN}-ap6256-bt = " \ 76 | system/etc/firmware/BCM4345C5.hcd \ 77 | " 78 | 79 | FILES_${PN}-ap6356-wifi = " \ 80 | system/etc/firmware/fw_bcm4356a2_ag.bin \ 81 | system/etc/firmware/nvram_ap6356.txt \ 82 | " 83 | 84 | FILES_${PN}-ap6356-bt = " \ 85 | system/etc/firmware/BCM4356A2.hcd \ 86 | " 87 | 88 | FILES_${PN}-ap6398s-wifi = " \ 89 | system/etc/firmware/fw_bcm4359c0_ag.bin \ 90 | system/etc/firmware/fw_bcm4359c0_ag_p2p.bin \ 91 | system/etc/firmware/nvram_ap6398s.txt \ 92 | " 93 | 94 | FILES_${PN}-ap6398s-bt = " \ 95 | system/etc/firmware/BCM4359C0.hcd \ 96 | " 97 | 98 | FILES_${PN}-rtl8723ds-bt = " \ 99 | ${base_libdir}/firmware/rtlbt/rtl8723d_config \ 100 | ${base_libdir}/firmware/rtlbt/rtl8723d_fw \ 101 | " 102 | 103 | FILES_${PN}-rtl8723du-bt = " \ 104 | ${base_libdir}/firmware/rtl8723du_config \ 105 | ${base_libdir}/firmware/rtl8723du_fw \ 106 | " 107 | 108 | FILES_${PN}-rtl8821cu-bt = " \ 109 | ${base_libdir}/firmware/rtl8821cu_config \ 110 | ${base_libdir}/firmware/rtl8821cu_fw \ 111 | " 112 | 113 | FILES_${PN} = "*" 114 | 115 | # Make it depend on all of the split-out packages. 116 | python () { 117 | pn = d.getVar('PN') 118 | firmware_pkgs = oe.utils.packages_filter_out_system(d) 119 | d.appendVar('RDEPENDS_' + pn, ' ' + ' '.join(firmware_pkgs)) 120 | } 121 | 122 | INSANE_SKIP_${PN} += "arch" 123 | -------------------------------------------------------------------------------- /conf/local.conf.sample: -------------------------------------------------------------------------------- 1 | # 2 | # This file is your local configuration file and is where all local user settings 3 | # are placed. The comments in this file give some guide to the options a new user 4 | # to the system might want to change but pretty much any configuration option can 5 | # be set in this file. More adventurous users can look at local.conf.extended 6 | # which contains other examples of configuration which can be placed in this file 7 | # but new users likely won't need any of them initially. 8 | # 9 | # Lines starting with the '#' character are commented out and in some cases the 10 | # default values are provided as comments to show people example syntax. Enabling 11 | # the option is a question of removing the # character and making any change to the 12 | # variable as required. 13 | 14 | # 15 | # Machine Selection 16 | # 17 | # You need to select a specific machine to target the build with. 18 | #MACHINE ?= "rockpi-4a-rk3399" 19 | #MACHINE ?= "rockpi-4b-rk3399" 20 | #MACHINE ?= "rockpi-4c-rk3399" 21 | #MACHINE ?= "rockpi-e-rk3328" 22 | #MACHINE ?= "rockpi-n10-rk3399pro" 23 | #MACHINE ?= "rockpi-px30" 24 | #MACHINE ?= "rockpi-s-rk3308" 25 | 26 | DISTRO ?= "poky" 27 | # 28 | # Package Management configuration 29 | # 30 | # This variable lists which packaging formats to enable. Multiple package backends 31 | # can be enabled at once and the first item listed in the variable will be used 32 | # to generate the root filesystems. 33 | # Options are: 34 | # - 'package_deb' for debian style deb files 35 | # - 'package_ipk' for ipk files are used by opkg (a debian style embedded package manager) 36 | # - 'package_rpm' for rpm style packages 37 | # E.g.: PACKAGE_CLASSES ?= "package_rpm package_deb package_ipk" 38 | # We default to rpm: 39 | PACKAGE_CLASSES ?= "package_rpm" 40 | 41 | # We default to enabling the debugging tweaks. 42 | EXTRA_IMAGE_FEATURES ?= "debug-tweaks" 43 | # 44 | # Additional image features 45 | # 46 | # The following is a list of additional classes to use when building images which 47 | # enable extra features. Some available options which can be included in this variable 48 | # are: 49 | # - 'buildstats' collect build statistics 50 | # - 'image-mklibs' to reduce shared library files size for an image 51 | # - 'image-prelink' in order to prelink the filesystem image 52 | # NOTE: if listing mklibs & prelink both, then make sure mklibs is before prelink 53 | # NOTE: mklibs also needs to be explicitly enabled for a given image, see local.conf.extended 54 | USER_CLASSES ?= "buildstats image-mklibs image-prelink" 55 | 56 | # 57 | # Interactive shell configuration 58 | # 59 | # Under certain circumstances the system may need input from you and to do this it 60 | # can launch an interactive shell. It needs to do this since the build is 61 | # multithreaded and needs to be able to handle the case where more than one parallel 62 | # process may require the user's attention. The default is iterate over the available 63 | # terminal types to find one that works. 64 | # 65 | # Examples of the occasions this may happen are when resolving patches which cannot 66 | # be applied, to use the devshell or the kernel menuconfig 67 | # 68 | # Supported values are auto, gnome, xfce, rxvt, screen, konsole (KDE 3.x only), none 69 | # Note: currently, Konsole support only works for KDE 3.x due to the way 70 | # newer Konsole versions behave 71 | #OE_TERMINAL = "auto" 72 | # By default disable interactive patch resolution (tasks will just fail instead): 73 | PATCHRESOLVE = "noop" 74 | 75 | # 76 | # Disk Space Monitoring during the build 77 | # 78 | # Monitor the disk space during the build. If there is less that 1GB of space or less 79 | # than 100K inodes in any key build location (TMPDIR, DL_DIR, SSTATE_DIR), gracefully 80 | # shutdown the build. If there is less that 100MB or 1K inodes, perform a hard abort 81 | # of the build. The reason for this is that running completely out of space can corrupt 82 | # files and damages the build in ways which may not be easily recoverable. 83 | # It's necesary to monitor /tmp, if there is no space left the build will fail 84 | # with very exotic errors. 85 | BB_DISKMON_DIRS ??= "\ 86 | STOPTASKS,${TMPDIR},1G,100K \ 87 | STOPTASKS,${DL_DIR},1G,100K \ 88 | STOPTASKS,${SSTATE_DIR},1G,100K \ 89 | STOPTASKS,/tmp,100M,100K \ 90 | ABORT,${TMPDIR},100M,1K \ 91 | ABORT,${DL_DIR},100M,1K \ 92 | ABORT,${SSTATE_DIR},100M,1K \ 93 | ABORT,/tmp,10M,1K" 94 | 95 | # CONF_VERSION is increased each time build/conf/ changes incompatibly and is used to 96 | # track the version of this file when it was generated. This can safely be ignored if 97 | # this doesn't mean anything to you. 98 | CONF_VERSION = "1" 99 | 100 | DISTRO_FEATURES_append = " pam systemd x11" 101 | VIRTUAL-RUNTIME_init_manager = "systemd" 102 | PACKAGECONFIG_append_pn-systemd = " resolved networkd" 103 | DISTRO_FEATURES_remove = "wayland" 104 | 105 | # Uncomment the following line to add the extra packages 106 | #IMAGE_INSTALL_append = " create-ap" 107 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /recipes-kernel/kernel-module-headers/files/gen_mod_headers: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e; set -o pipefail 3 | 4 | # Heavily based on PKGBUILD from 5 | # https://www.archlinux.org/packages/core/x86_64/linux/ 6 | 7 | function error() 8 | { 9 | echo $(basename $0): $@ >&2 10 | } 11 | 12 | function fatal() 13 | { 14 | error $@ 15 | exit 1 16 | } 17 | 18 | function usage() 19 | { 20 | echo "usage: $(basename $0) [target dir] [linux source dir] [objects dir] ">&2 21 | 22 | exit 1 23 | } 24 | 25 | # See http://stackoverflow.com/a/4774063 26 | function get_full_path() 27 | { 28 | echo "$( cd "$1" ; pwd -P )" 29 | } 30 | 31 | function push() 32 | { 33 | pushd $@ >/dev/null 34 | } 35 | 36 | function push_linux() 37 | { 38 | push $linux_dir 39 | } 40 | 41 | function pop() 42 | { 43 | popd >/dev/null 44 | } 45 | 46 | function copy_dir() 47 | { 48 | from="$1" 49 | to="$2" 50 | 51 | if [[ -d "$from" ]]; then 52 | cp -a "$from" "$to" 53 | fi 54 | } 55 | 56 | function copy_mkdir() 57 | { 58 | local target_dir="$1" 59 | local rel_path="$2" 60 | 61 | mkdir -p "$target_dir/$(dirname $rel_path)" 62 | cp "$rel_path" "$target_dir/$rel_path" 63 | } 64 | 65 | [[ $# -ge 3 ]] || usage 66 | 67 | # Generate target dir if doesn't exist. 68 | install -dm755 $1 69 | 70 | target_dir=$(get_full_path $1) 71 | linux_dir=$(get_full_path $2) 72 | # The directory containing .config and Module.symvers. 73 | obj_dir=$(get_full_path $3) 74 | karch=${4:-x86} 75 | prefix=$5 76 | hostcc="${6:-${prefix}gcc}" 77 | hostcc_native="${7:-${prefix}gcc}" 78 | 79 | # FIXME: We assume host arch == x86. 80 | if [[ "$karch" != "x86" ]]; then 81 | [[ -n $prefix ]] || fatal "Non-x86 arch but no prefix specified." 82 | fi 83 | 84 | build_opts="" 85 | # Regardless of target arch, if a prefix is specified we are cross-compiling. 86 | [[ -z "$prefix" ]] || build_opts="ARCH=$karch CROSS_COMPILE=$prefix" 87 | 88 | karch_dir="arch/$karch" 89 | target_karch_dir="$target_dir/$karch_dir" 90 | 91 | [[ -f "${obj_dir}/.config" ]] || fatal "Missing kernel configuration." 92 | [[ -f "${obj_dir}/Module.symvers" ]] || fatal "Missing Module.symvers." 93 | 94 | # Copy in .config and Module.symvers so we can specify O=$target_dir. 95 | cp "${obj_dir}/.config" "${obj_dir}/Module.symvers" "$target_dir" 96 | 97 | extra_header_dirs="drivers/md net/mac80211 drivers/media/dvb-core include/config/dvb \ 98 | drivers/media/dvb-frontends drivers/media/usb/dvb-usb drivers/media/tuners" 99 | 100 | push_linux 101 | trap pop EXIT 102 | 103 | [[ -d "$karch_dir" ]] || fatal "Unrecognised karch: $karch" 104 | 105 | echo Running modules_prepare... 106 | make HOSTCC="$hostcc_native" O="$target_dir" $build_opts modules_prepare 107 | 108 | echo Copying required files... 109 | 110 | if [[ -n "$prefix" ]]; then 111 | # Move host arch script binaries so we can fix them up later. We don't want to 112 | # keep host binaries in place when we copy in source, we'll compile target arch 113 | # versions later. 114 | mv "$target_dir"/scripts "$target_dir"/xscripts 115 | if [ -d "$target_dir/tools" ]; then 116 | mv "$target_dir"/tools "$target_dir"/xtools 117 | fi 118 | fi 119 | 120 | for f in Makefile kernel/Makefile Documentation/DocBook/Makefile; do 121 | # DocBook support is removed in 4.13 122 | if [ -f "$f" ]; then 123 | install -D -m644 "$f" "$target_dir/$f" 124 | fi 125 | done 126 | 127 | # Arch Linux copies only specific directories, however the difference is 31M 128 | # vs. 37M (~168k compressed) so for future-proofing I think it's not much more 129 | # of a cost to just copy everything. 130 | find include -mindepth 1 -maxdepth 1 -type d | \ 131 | xargs -I {} cp -a "{}" "$target_dir/include" 132 | 133 | for d in include $extra_header_dirs; do 134 | [ -d "$d" ] && mkdir -p "$target_dir/$d" 135 | done 136 | 137 | # Configure arch/ directory. 138 | mkdir -p "$target_karch_dir" 139 | copy_dir "$karch_dir/include" "$target_karch_dir" 140 | copy_dir "$karch_dir/tools" "$target_karch_dir" 141 | for f in $(find $karch_dir -iname '*.h' -o -name 'Makefile' -o -iname '*.tbl' -o -iname '*.sh'); do 142 | copy_mkdir "$target_dir" "$f" 143 | done 144 | 145 | for f in $(find security -iname '*.h'); do 146 | copy_mkdir "$target_dir" "$f" 147 | done 148 | 149 | # Copy over tools include as some builds require this. 150 | mkdir -p "$target_dir/tools" 151 | copy_dir tools/include "$target_dir/tools" 152 | copy_dir tools/objtool "$target_dir/tools" 153 | copy_dir tools/lib "$target_dir/tools" 154 | copy_dir tools/scripts "$target_dir/tools" 155 | copy_dir tools/build "$target_dir/tools" 156 | cp tools/Makefile "$target_dir/tools" 157 | 158 | copy_dir scripts "$target_dir" 159 | # Don't strip binaries as only makes 200kb difference... 160 | 161 | mkdir -p "$target_karch_dir/kernel" 162 | cp "$karch_dir/Makefile" "$target_karch_dir" 163 | 164 | # May as well always copy these if available. 165 | for f in Makefile_32.cpu kernel/asm-offsets.s; do 166 | p="$karch_dir/$f" 167 | [ -f $p ] && cp "$p" "$target_karch_dir/$f" 168 | done 169 | 170 | # Address sources with this kind of hacks 171 | # https://github.com/raspberrypi/linux/commit/a66649dab35033bd67988670fa60c268b0444cda 172 | mkdir -p "$target_karch_dir/kernel/vdso" 173 | for f in gettimeofday.S note.S sigreturn.S; do 174 | p="$karch_dir//kernel/vdso/$f" 175 | [ -f $p ] && cp "$p" "$target_karch_dir/kernel/vdso/$f" 176 | done 177 | 178 | # Copy in extra headers. Directories already created above. 179 | for d in $extra_header_dirs; do 180 | [ -d "$d" ] && (cp $d/*.h "$target_dir/$d" || true) 181 | done 182 | 183 | # Specific required files. 184 | 185 | if [[ -e drivers/media/i2c/msp3400-driver.h ]]; then 186 | mkdir -p "$target_dir/drivers/media/i2c/" 187 | cp drivers/media/i2c/msp3400-driver.h "$target_dir/drivers/media/i2c/" 188 | fi 189 | 190 | # Copy in Kconfig files. 191 | for f in $(find . -name "Kconfig*"); do 192 | copy_mkdir "$target_dir" "$f" 193 | done 194 | 195 | # Fix arm64 file reference 196 | if [ "$karch" = "arm64" ] && [ -f "$karch_dir/include/asm/opcodes.h" ]; then 197 | copy_mkdir "$target_dir" "./arch/arm/include/asm/opcodes.h" 198 | fi 199 | 200 | # copy module.lds, vdso.lds and Makefile if they exist 201 | if [ "$karch" = "arm64" ]; then 202 | if [ -f "arch/arm64/kernel/module.lds" ]; then 203 | copy_mkdir "$target_dir" "./arch/arm64/kernel/module.lds" 204 | fi 205 | if [ -f "arch/arm64/kernel/vdso/vdso.lds" ]; then 206 | copy_mkdir "$target_dir" "./arch/arm64/kernel/vdso/vdso.lds" 207 | fi 208 | if [ -f "lib/vdso/Makefile" ]; then 209 | copy_mkdir "$target_dir" "./lib/vdso/Makefile" 210 | fi 211 | fi 212 | 213 | # copy module.lds if it exists 214 | if [ "$karch" = "arm" ] && [ -f "arch/arm/kernel/module.lds" ]; then 215 | copy_mkdir "$target_dir" "./arch/arm/kernel/module.lds" 216 | fi 217 | 218 | if [[ -n "$prefix" ]]; then 219 | echo Fixing up script binaries... 220 | 221 | push "$target_dir" 222 | 223 | # Make some backups so we can restore sanity after we're done. 224 | cp scripts/basic/Makefile .backup.basic.Makefile 225 | cp scripts/Kbuild.include .backup.kbuild.Makefile.include 226 | cp scripts/Makefile.build .backup.Makefile.build 227 | cp scripts/mod/Makefile .backup.mod.Makefile 228 | cp scripts/kconfig/Makefile .backup.kconfig.Makefile 229 | if [[ -e tools/build/Makefile ]]; then 230 | cp tools/build/Makefile .backup.tools.build.Makefile 231 | fi 232 | 233 | # Fixup Makefile's so they reference our host arch binaries in xscripts. 234 | # We only need a few fixups since we're only building scripts here. 235 | sed -i 's|$(obj)/fixdep|x$(obj)/fixdep|' scripts/basic/Makefile 236 | sed -i 's|scripts/basic/fixdep|xscripts/basic/fixdep|' scripts/Kbuild.include 237 | sed -i 's|scripts/basic/fixdep|xscripts/basic/fixdep|' scripts/Makefile.build 238 | sed -i 's|$(obj)/mk_elfconfig|x$(obj)/mk_elfconfig|' scripts/mod/Makefile 239 | sed -i 's|$(obj)/conf|x$(obj)/conf|' scripts/kconfig/Makefile 240 | 241 | echo Building script binaries for target arch... 242 | make HOSTCC="$hostcc" HOSTLD="$LD" $build_opts scripts 243 | # for kernel 5.0.3 the following also builds scripts/mod which was removed from "make scripts" (see https://patchwork.kernel.org/patch/10690901/) 244 | # (The following make alters utsrelease.h at least on some machines - Variscite mx8m - let's make a backup and restore it after) 245 | cp include/generated/utsrelease.h include/generated/utsrelease.h.bkp 246 | make HOSTCC="$hostcc" HOSTLD="$LD" $build_opts prepare0 247 | mv include/generated/utsrelease.h.bkp include/generated/utsrelease.h 248 | 249 | if [[ -e xtools/objtool/fixdep ]]; then 250 | if [[ -e tools/build/Makefile ]]; then 251 | # let's use the native fixdep for the target objtool compilation 252 | cp xtools/objtool/fixdep tools/objtool/ 253 | 254 | # let's make sure that objtool compilation won't overwrite the native fixdep we just copied so we rename it to fixdep_temp 255 | sed -i 's|$(QUIET_LINK)$(HOSTCC) $(LDFLAGS) -o $@ $<|$(QUIET_LINK)$(HOSTCC) $(LDFLAGS) -o fixdep_temp $<|' tools/build/Makefile 256 | 257 | # trying to apply the previous sed in context of 4.18 kernel 258 | sed -i 's|$(QUIET_LINK)$(HOSTCC) $(HOSTLDFLAGS) -o $@ $<|$(QUIET_LINK)$(HOSTCC) $(HOSTLDFLAGS) -o fixdep_temp $<|' tools/build/Makefile 259 | # trying to apply the previous sed in context of 5.0.3 kernel 260 | sed -i 's|$(QUIET_LINK)$(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o $@ $<|$(QUIET_LINK)$(HOSTCC) $(KBUILD_HOSTLDFLAGS) -o fixdep_temp $<|' tools/build/Makefile 261 | fi 262 | 263 | echo Building objtool for target 264 | make -C tools/objtool HOSTCC="$hostcc" HOSTLD="$LD" $build_opts 265 | rm -rf tools/objtool/fixdep tools/objtool/fixdep_temp 266 | mv .backup.tools.build.Makefile tools/build/Makefile 267 | 268 | if [[ -e tools/build/Makefile ]]; then 269 | echo Building fixdep for target 270 | make -C tools/build HOSTCC="$hostcc" HOSTLD="$LD" $build_opts 271 | 272 | # move the target fixdep to the expected location 273 | mv tools/build/fixdep tools/objtool/ 274 | fi 275 | fi 276 | 277 | echo Cleaning up directory... 278 | 279 | # Reinstate pristine Makefile's. 280 | mv .backup.basic.Makefile scripts/basic/Makefile 281 | mv .backup.kbuild.Makefile.include scripts/Kbuild.include 282 | mv .backup.Makefile.build scripts/Makefile.build 283 | mv .backup.mod.Makefile scripts/mod/Makefile 284 | mv .backup.kconfig.Makefile scripts/kconfig/Makefile 285 | 286 | # Clean up host script bins. 287 | rm -rf xscripts 288 | if [ -d xtools ]; then 289 | rm -rf xtools 290 | fi 291 | 292 | # Remove unneeded binary and object files 293 | rm -rf arch/x86/tools/relocs arch/x86/tools/relocs*.o 294 | 295 | pop 296 | fi 297 | 298 | echo Done! 299 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Meta-radxa 2 | 3 | # Table of contents 4 | 5 | 1. [Introduction](#introduction) 6 | 2. [Dependencies](#dependencies) 7 | 3. [List of Radxa Boards supported](#list_of_boards_supported) 8 | 4. [Using the meta-radxa layer](#meta_radxa_usage) 9 | 1. [Step 1:Fetching the Source](#source_fetch) 10 | 2. [Step 2:Setting up the Environment](#setup) 11 | 3. [Step 3:Bblayers.conf Setup](#bblayers.conf_setup) 12 | 4. [Step 4:Local.conf Setup](#local.conf_setup) 13 | 5. [Step 5:Building the Image](#build_image) 14 | 5. [Serial Console](#serial_console) 15 | 6. [Login Details](#login) 16 | 7. [Networking](#networking) 17 | 1. [Wifi Connectivity](#wifi) 18 | 2. [Bluetooth Connectivity](#bluetooth) 19 | 8. [Release Info](#release_info) 20 | 9. [Change Log](#change_log) 21 | 10. [Contributing](#contributing) 22 | 11. [Reporting Bugs](#bugs) 23 | 12. [Maintainers](#maintainers) 24 | 25 | 26 | ## Introduction 27 | 28 | The OpenEmbedded/Yocto Project BSP layer for the Radxa machines 29 | 30 | ## Dependencies 31 | 32 | The meta-radxa layer depends on: 33 | 34 | URI: git://git.yoctoproject.org/poky 35 | branch: zeus 36 | 37 | URI: git://git.openembedded.org/meta-openembedded 38 | layers: meta-oe meta-networking meta-python meta-multimedia meta-gnome meta-xfce 39 | branch: zeus 40 | 41 | ## List of Radxa Boards supported 42 | 43 | 1) RockPi-4A (Tested by Stephen Chan from Radxa Team) 44 | 2) RockPi-4B (Tested by Stephen Chan from Radxa Team) 45 | 3) RockPi-4C (Tested by Stephen Chan from Radxa Team) 46 | 4) RockPi-E 47 | 5) RockPi-N10 48 | 6) RockPi-PX30 49 | 7) RockPi-S 50 | 51 | ## Using the meta-radxa layer 52 | 53 | ### Step 1: Fetching the source 54 | 55 | Fetch the source using the commands given below: 56 | 57 |
~ $ mkdir yocto
 58 | ~ $ cd yocto
 59 | ~/yocto $ git clone git://git.yoctoproject.org/poky -b zeus
 60 | ~/yocto $ cd poky
 61 | ~/yocto/poky $ git clone git://git.openembedded.org/meta-openembedded.git -b zeus
 62 | ~/yocto/poky $ git clone https://github.com/nishantpoorswani/meta-radxa.git -b zeus
 63 | 
64 | 65 | ### Step 2: Setting up the Environment 66 | 67 |
 ~/yocto/poky $ source oe-init-build-env
 68 | 
69 | 70 | #### Step 3: Bblayers.conf Setup 71 | 72 | * You can simply copy the bblayers.conf.sample present in meta-radxa/conf folder to the build/conf folder and rename it to bblayers.conf 73 | 74 |
OR
75 | 76 | * Add the layers manually as given below to the bblayers.conf in the build/conf folder 77 | 78 |
  ${TOPDIR}/../meta \
 79 |   ${TOPDIR}/../meta-poky \
 80 |   ${TOPDIR}/../meta-yocto-bsp \
 81 |   ${TOPDIR}/../meta-openembedded/meta-oe \
 82 |   ${TOPDIR}/../meta-openembedded/meta-networking \
 83 |   ${TOPDIR}/../meta-openembedded/meta-python \
 84 |   ${TOPDIR}/../meta-openembedded/meta-multimedia \ 
 85 |   ${TOPDIR}/../meta-openembedded/meta-gnome \
 86 |   ${TOPDIR}/../meta-openembedded/meta-xfce \
 87 |   ${TOPDIR}/../meta-radxa \
 88 | 
89 | 90 | ### Step 4: Local.conf Setup 91 | 92 | * You can simply copy the local.conf.sample present in meta-radxa/conf folder to the build/conf folder and rename it to local.conf and uncomment the machine for which you want to build an image 93 | 94 |
OR
95 | 96 | * Add the following lines in the build/conf/local.conf 97 | 98 | ``` 99 | MACHINE ?= "xxxx" 100 | DISTRO_FEATURES_append = " pam systemd x11" 101 | VIRTUAL-RUNTIME_init_manager = "systemd" 102 | PACKAGECONFIG_append_pn-systemd = " resolved networkd" 103 | DISTRO_FEATURES_remove = "wayland" 104 | ``` 105 | 106 | **Replace xxxx with the machine you want to build the image for. All supported machines can be found in meta-radxa/conf/machine.** 107 | 108 | ### Step 5: Building the Image 109 | 110 | * If you wish to build a minimal image use the command given below: 111 | ``` 112 | ~/yocto/poky/build $ bitbake -k radxa-minimal-image 113 | ``` 114 |
OR
115 | 116 | * If you wish to build a console image use the command given below: 117 | 118 | ``` 119 | ~/yocto/poky/build $ bitbake -k radxa-console-image 120 | ``` 121 |
OR
122 | 123 | * If you wish to build a desktop image use the command given below: 124 | 125 | ``` 126 | ~/yocto/poky/build $ bitbake -k radxa-desktop-image 127 | ``` 128 | 129 | **At the end of a successful build, you should have a gpt.img image in build/tmp/deploy/images/MACHINE/ folder. The gpt.img can be directly flashed on the sd-card** 130 | 131 | ## Serial Console 132 | 133 | The Serial Console for RockPi-4, RockPi-E and RockPi-N10 is enabled on UART-2. The Serial Console for RockPi-S is enabled on UART-0. 134 | 135 | **Helpful Links:** 136 | 137 | + GPIO Pinout for RockPi-4 (https://wiki.radxa.com/Rockpi4/hardware/gpio) 138 | + GPIO Pinout for RockPi-E (https://wiki.radxa.com/RockpiE/hardware/rockpiE#gpio) 139 | + GPIO Pinout for RockPi-N10 (https://wiki.radxa.com/RockpiN10/hardware/rockpiN10#gpio) 140 | + GPIO Pinout for RockPi-S (https://wiki.radxa.com/RockpiS/hardware/gpio) 141 | + RockPi-4 Serial Console Setup (https://wiki.radxa.com/Rockpi4/dev/serial-console) 142 | + RockPi-E Serial Console Setup (https://wiki.radxa.com/RockpiE/dev/serial-console) 143 | + RockPi-N10 Serial Console Setup (https://wiki.radxa.com/RockpiN10/dev/serial-console) 144 | + RockPi-S Serial Console Setup (https://wiki.radxa.com/RockpiS/dev/serial-console) 145 | 146 | ## Login Details 147 | 148 | ``` 149 | Username: root 150 | Password: rock 151 | ``` 152 | 153 | ## Networking 154 | 155 | **Network Devices available:** 156 | 157 | + Wifi 158 | + Ethernet 159 | + Bluetooth 160 | 161 | ### Wifi Connectivity 162 | 163 | + Using Commandline Based GUI(nmtui) [Available on console and desktop images] 164 | 165 | nmtui is a curses based GUI. You can start it by running the following command: 166 | 167 | ``` 168 | nmtui 169 | ``` 170 | 171 | + Using Commandline Utility(nmcli) [Available on console and desktop images] 172 | 173 | nmcli is a command-line tool for controlling NetworkManager and reporting network status. 174 | 175 | **List available devices** 176 | 177 | ``` 178 | nmcli dev 179 | ``` 180 | 181 | **Turn on Wifi** 182 | 183 | ``` 184 | nmcli r wifi on 185 | ``` 186 | 187 | **Scanning different devices** 188 | 189 | ``` 190 | nmcli dev wifi 191 | ``` 192 | 193 | **Connect to WiFi Hotspot** 194 | 195 | ``` 196 | nmcli dev wifi connect "SSID" password "PASSWORD" 197 | ``` 198 | 199 | ***Note:You need to replace “SSID” and “Password” with your actual WiFi’s SSID and password.*** 200 | 201 | ### Bluetooth Connectivity 202 | 203 | + Bluetooth on RockPi-4B/RockPi-4C 204 | 205 | **Activating bluetooth:** 206 | 207 | ``` 208 | hciconfig hci0 up 209 | ``` 210 | 211 | **Check Bluetooth device:** 212 | 213 | ``` 214 | $ hciconfig 215 | hci0: Type: Primary Bus: UART 216 | BD Address: 43:45:C5:00:1F:AC ACL MTU: 1021:8 SCO MTU: 64:1 217 | UP RUNNING 218 | RX bytes:876 acl:0 sco:0 events:62 errors:0 219 | TX bytes:4755 acl:0 sco:0 commands:62 errors:0 220 | ``` 221 | 222 | + Bluetooth on RockPi-E 223 | 224 | **Manual setup for bluetooth:** 225 | 226 | Bluetooth is activated by default on the RockPi-E 227 | 228 | **Check Bluetooth device:** 229 | 230 | ``` 231 | $ hciconfig 232 | hci0: Type: Primary Bus: USB 233 | BD Address: 74:EE:2A:55:23:F7 ACL MTU: 1021:8 SCO MTU: 255:12 234 | UP RUNNING 235 | RX bytes:40357 acl:34 sco:0 events:814 errors:0 236 | TX bytes:216782 acl:379 sco:0 commands:101 errors:0 237 | ``` 238 | 239 | + Bluetooth on RockPi-N10 240 | 241 | **Activating bluetooth:** 242 | 243 | ``` 244 | hciconfig hci0 up 245 | ``` 246 | 247 | **Check Bluetooth device:** 248 | 249 | ``` 250 | $ hciconfig 251 | hci0: Type: Primary Bus: UART 252 | BD Address: 22:22:70:B2:10:6F ACL MTU: 1021:8 SCO MTU: 255:12 253 | UP RUNNING 254 | RX bytes:1399 acl:0 sco:0 events:45 errors:0 255 | TX bytes:3458 acl:0 sco:0 commands:45 errors:0 256 | ``` 257 | 258 | + Bluetooth on RockPi-S 259 | 260 | **Activating bluetooth:** 261 | 262 | ``` 263 | hciconfig hci0 up 264 | ``` 265 | 266 | **Check Bluetooth device:** 267 | 268 | ``` 269 | $ hciconfig 270 | hci0: Type: Primary Bus: UART 271 | BD Address: 22:22:70:B2:10:6F ACL MTU: 1021:8 SCO MTU: 255:12 272 | UP RUNNING 273 | RX bytes:1399 acl:0 sco:0 events:45 errors:0 274 | TX bytes:3458 acl:0 sco:0 commands:45 errors:0 275 | ``` 276 | 277 | ## Release Info 278 | 279 | 1. RockPi-4 280 | 281 | + Kernel version: 4.4.154-109-b04eccb4588e333bdaf3ba7e6e4186d2ebe53770 282 | + U-Boot version: 2017.09-04d66f4b45a47531b5ff6cdbddcdc2cc35fa7aea 283 | 284 | 2. RockPi-E 285 | 286 | + Kernel version: 4.4.194-12-615ae743115011bbe1cd1edc5c9118bf95527f54 287 | + U-Boot version: 2019.10-7b93f1b8bce4106266d4a38dde96fd8080faccea 288 | 289 | 3. RockPi-N10 290 | 291 | + Kernel version: 4.4.167-c36a21e2be755919e8b406069206e67126b7e712 292 | + U-Boot version: 2017.09-7c49a7da79caf2f68bc1074dfa21864d7f23b9e1 293 | 294 | 4. RockPi-PX30 295 | 296 | + Kernel version: 4.4.189-dc47906e88166ae315f0472743de4d80f2bea786 297 | + U-Boot version: 2017.09-cfc37de87bc064b2d6d384566e24c5e4245f113a 298 | 299 | 5. RockPi-S 300 | 301 | + Kernel version: 4.4.143-55-6b7accbc999b6caa8ef603b9d904c99694d0bf41 302 | + U-Boot version: 2017.09-233a23e3ed0b3e5250253ee455c3c5df2080f99c 303 | 304 | ## Change Log 305 | 306 | + Added board support for RockPi-N10 307 | + Added board support for RockPi-PX30 308 | + Added board support for RockPi-4A 309 | + Added board support for RockPi-4C 310 | + RockPi-4 Kernel updated to 4.4.154-109-b04eccb4588e333bdaf3ba7e6e4186d2ebe53770 311 | + RockPi-4 U-Boot branch updated from stable-4.4-rockpi4 to rk3399-pie-gms-express-baseline 312 | + RockPi-4 U-Boot updated to 2017.09-04d66f4b45a47531b5ff6cdbddcdc2cc35fa7aea 313 | + RockPi-4 boards support SPI + NVME booting 314 | + RockPi-4b dtb changed from rockpi-4b-linux.dtb to rk3399-rock-pi-4b.dtb 315 | + RockPi-S Kernel updated to 4.4.143-55-6b7accbc999b6caa8ef603b9d904c99694d0bf41 316 | + RockPi-S U-Boot updated to 2017.09-c93a0fc70993c12e605b1312577252ca9cdec6c8 317 | + RockPi-S and RockPi-E gpt images have now been updated to use the 2 partition instead of the tradition 5 partition 318 | + Use ttySx as debuger console instead of ttyFIQ0 for RockPi-S and RockPi-E 319 | + Major Reorganization in U-Boot recipes. New structure will make it easier for adding new boards 320 | + Added recipe for making desktop images 321 | + Added recipe for setting up BT firmware and driver at boot for Rockpi-4, RockPi-E, RockPi-N10 and RockPi-S 322 | + Added recipe for kernel-headers, file-system resize at boot, mraa and create-ap 323 | 324 | ## Contributing 325 | 326 | Please use github for pull requests: https://github.com/nishantpoorswani/meta-radxa/pulls 327 | 328 | ## Reporting bugs 329 | 330 | The github issue tracker (https://github.com/nishantpoorswani/meta-radxa/issues) is being used to keep track of bugs. 331 | 332 | ## Maintainers 333 | 334 | * Nishant Poorswani 335 | -------------------------------------------------------------------------------- /classes/rockchip-radxa-gpt-img.bbclass: -------------------------------------------------------------------------------- 1 | # Create an image that can be written onto a SD card using dd. 2 | 3 | inherit image_types 4 | 5 | # Use an uncompressed ext4 by default as rootfs 6 | IMG_ROOTFS_TYPE = "ext4" 7 | IMG_ROOTFS = "${IMGDEPLOYDIR}/${IMAGE_BASENAME}-${MACHINE}.${IMG_ROOTFS_TYPE}" 8 | 9 | # This image depends on the rootfs image 10 | IMAGE_TYPEDEP_rockchip-radxa-gpt-img = "${IMG_ROOTFS_TYPE}" 11 | 12 | GPTIMG = "${IMAGE_BASENAME}-${MACHINE}-gpt.img" 13 | BOOT_IMG = "${IMAGE_BASENAME}-${MACHINE}-boot.img" 14 | IDBLOADER = "idbloader.img" 15 | 16 | # Get From radxa-binary loader 17 | DDR_BIN = "radxa-binary/ddr.bin" 18 | LOADER_BIN = "radxa-binary/loader.bin" 19 | MINILOADER_BIN = "radxa-binary/miniloader.bin" 20 | ATF_BIN = "radxa-binary/atf.bin" 21 | BL31_ELF = "radxa-binary/bl31.elf" 22 | TRUST_IMG = "trust.img" 23 | # Not from radxa-binary 24 | UBOOT_IMG = "u-boot.img" 25 | 26 | GPTIMG_APPEND_px30 = "console=tty1 console=ttyS1,1500000n8 rw \ 27 | root=PARTUUID=b921b045-1d rootfstype=ext4 init=/sbin/init rootwait" 28 | GPTIMG_APPEND_rk3308 = "console=tty1 console=ttyFIQ0,1500000n8 rw \ 29 | root=PARTUUID=b921b045-1d rootfstype=ext4 init=/sbin/init rootwait" 30 | GPTIMG_APPEND_rk3328 = "console=tty1 console=ttyS2,1500000n8 rw \ 31 | root=PARTUUID=b921b045-1d rootfstype=ext4 init=/sbin/init rootwait" 32 | GPTIMG_APPEND_rk3399 = "console=tty1 console=ttyFIQ0,1500000n8 rw \ 33 | root=PARTUUID=b921b045-1d rootfstype=ext4 init=/sbin/init rootwait" 34 | GPTIMG_APPEND_rk3399pro = "console=tty1 console=ttyS2,1500000n8 rw \ 35 | root=PARTUUID=b921b045-1d rootfstype=ext4 init=/sbin/init rootwait" 36 | 37 | # default partitions [in Sectors] 38 | # More info at http://rockchip.wikidot.com/partitions 39 | LOADER1_SIZE = "8000" 40 | RESERVED1_SIZE = "128" 41 | RESERVED2_SIZE = "8192" 42 | LOADER2_SIZE = "8192" 43 | ATF_SIZE = "8192" 44 | BOOT_SIZE = "229376" 45 | 46 | # WORKROUND: miss recipeinfo 47 | do_image_rockchip_radxa_gpt_img[depends] += " \ 48 | radxa-binary-loader:do_populate_lic \ 49 | virtual/bootloader:do_populate_lic" 50 | 51 | do_image_rockchip_radxa_gpt_img[depends] += " \ 52 | parted-native:do_populate_sysroot \ 53 | mtools-native:do_populate_sysroot \ 54 | gptfdisk-native:do_populate_sysroot \ 55 | dosfstools-native:do_populate_sysroot \ 56 | radxa-binary-native:do_populate_sysroot \ 57 | radxa-binary-loader:do_deploy \ 58 | virtual/kernel:do_deploy \ 59 | virtual/bootloader:do_deploy" 60 | 61 | PER_CHIP_IMG_GENERATION_COMMAND_px30 = "generate_px30_loader_image" 62 | PER_CHIP_IMG_GENERATION_COMMAND_rk3308 = "generate_rk3308_loader_image" 63 | PER_CHIP_IMG_GENERATION_COMMAND_rk3328 = "generate_rk3328_loader_image" 64 | PER_CHIP_IMG_GENERATION_COMMAND_rk3399 = "generate_rk3399_loader_image" 65 | PER_CHIP_IMG_GENERATION_COMMAND_rk3399pro = "generate_rk3399pro_loader_image" 66 | 67 | IMAGE_CMD_rockchip-radxa-gpt-img () { 68 | # Change to image directory 69 | cd ${DEPLOY_DIR_IMAGE} 70 | 71 | # Remove the existing image 72 | rm -f "${GPTIMG}" 73 | rm -f "${BOOT_IMG}" 74 | 75 | create_rk_image 76 | 77 | ${PER_CHIP_IMG_GENERATION_COMMAND} 78 | 79 | cd ${DEPLOY_DIR_IMAGE} 80 | if [ -f ${WORKDIR}/${BOOT_IMG} ]; then 81 | cp ${WORKDIR}/${BOOT_IMG} ./ 82 | fi 83 | } 84 | 85 | create_rk_image () { 86 | 87 | # last dd rootfs will extend gpt image to fit the size, 88 | # but this will overrite the backup table of GPT 89 | # will cause corruption error for GPT 90 | IMG_ROOTFS_SIZE=$(stat -L --format="%s" ${IMG_ROOTFS}) 91 | 92 | GPTIMG_MIN_SIZE=$(expr $IMG_ROOTFS_SIZE + \( ${LOADER1_SIZE} + ${RESERVED1_SIZE} + ${RESERVED2_SIZE} + ${LOADER2_SIZE} + ${ATF_SIZE} + ${BOOT_SIZE} + 35 \) \* 512 ) 93 | 94 | GPT_IMAGE_SIZE=$(expr $GPTIMG_MIN_SIZE \/ 1024 \/ 1024 + 2) 95 | 96 | # Initialize sdcard image file 97 | dd if=/dev/zero of=${GPTIMG} bs=1M count=0 seek=$GPT_IMAGE_SIZE 98 | 99 | # Create partition table 100 | parted -s ${GPTIMG} mklabel gpt 101 | 102 | # Create vendor defined partitions 103 | LOADER1_START=64 104 | RESERVED1_START=$(expr ${LOADER1_START} + ${LOADER1_SIZE}) 105 | RESERVED2_START=$(expr ${RESERVED1_START} + ${RESERVED1_SIZE}) 106 | LOADER2_START=$(expr ${RESERVED2_START} + ${RESERVED2_SIZE}) 107 | ATF_START=$(expr ${LOADER2_START} + ${LOADER2_SIZE}) 108 | BOOT_START=$(expr ${ATF_START} + ${ATF_SIZE}) 109 | ROOTFS_START=$(expr ${BOOT_START} + ${BOOT_SIZE}) 110 | 111 | # Make 5 partitions only for rocki-4b 112 | if [ "${SOC_FAMILY}" = "rk3399" ]; then 113 | 114 | parted -s ${GPTIMG} unit s mkpart loader1 ${LOADER1_START} $(expr ${RESERVED1_START} - 1) 115 | # parted -s ${GPTIMG} unit s mkpart reserved1 ${RESERVED1_START} $(expr ${RESERVED2_START} - 1) 116 | # parted -s ${GPTIMG} unit s mkpart reserved2 ${RESERVED2_START} $(expr ${LOADER2_START} - 1) 117 | parted -s ${GPTIMG} unit s mkpart loader2 ${LOADER2_START} $(expr ${ATF_START} - 1) 118 | parted -s ${GPTIMG} unit s mkpart trust ${ATF_START} $(expr ${BOOT_START} - 1) 119 | BOOT_PART=4 120 | ROOT_PART=5 121 | else 122 | BOOT_PART=1 123 | ROOT_PART=2 124 | fi 125 | 126 | # Create boot partition and mark it as bootable 127 | parted -s ${GPTIMG} unit s mkpart boot ${BOOT_START} $(expr ${ROOTFS_START} - 1) 128 | parted -s ${GPTIMG} set ${BOOT_PART} boot on 129 | 130 | # Create rootfs partition 131 | parted -s ${GPTIMG} -- unit s mkpart rootfs ${ROOTFS_START} -34s 132 | 133 | parted ${GPTIMG} print 134 | 135 | # mark the boot partition as UEFI boot 136 | BOOT_UUID="C12A7328-F81F-11D2-BA4B-00A0C93EC93B" 137 | 138 | # Change boot partuuid 139 | gdisk ${GPTIMG} <${WORKDIR}/extlinux.conf <>${DEPLOY_DIR_IMAGE}/${IDBLOADER} 222 | cat >${DEPLOY_DIR_IMAGE}/trust.ini <>${DEPLOY_DIR_IMAGE}/${IDBLOADER} 260 | cat >${DEPLOY_DIR_IMAGE}/trust.ini <>${DEPLOY_DIR_IMAGE}/${IDBLOADER} 298 | cat >${DEPLOY_DIR_IMAGE}/trust.ini <>${DEPLOY_DIR_IMAGE}/${IDBLOADER} 337 | cat >${DEPLOY_DIR_IMAGE}/trust.ini <>${DEPLOY_DIR_IMAGE}/${IDBLOADER} 376 | cat >${DEPLOY_DIR_IMAGE}/trust.ini < to print a debug log 29 | ** <--patchram patchram_file> 30 | ** <--baudrate baud_rate> 31 | ** <--bd_addr bd_address> 32 | ** <--enable_lpm> 33 | ** <--enable_hci> 34 | ** <--use_baudrate_for_download> 35 | ** <--scopcm=sco_routing,pcm_interface_rate,frame_type, 36 | ** sync_mode,clock_mode,lsb_first,fill_bits, 37 | ** fill_method,fill_num,right_justify> 38 | ** 39 | ** Where 40 | ** 41 | ** sco_routing is 0 for PCM, 1 for Transport, 42 | ** 2 for Codec and 3 for I2S, 43 | ** 44 | ** pcm_interface_rate is 0 for 128KBps, 1 for 45 | ** 256 KBps, 2 for 512KBps, 3 for 1024KBps, 46 | ** and 4 for 2048Kbps, 47 | ** 48 | ** frame_type is 0 for short and 1 for long, 49 | ** 50 | ** sync_mode is 0 for slave and 1 for master, 51 | ** 52 | ** clock_mode is 0 for slabe and 1 for master, 53 | ** 54 | ** lsb_first is 0 for false aand 1 for true, 55 | ** 56 | ** fill_bits is the value in decimal for unused bits, 57 | ** 58 | ** fill_method is 0 for 0's and 1 for 1's, 2 for 59 | ** signed and 3 for programmable, 60 | ** 61 | ** fill_num is the number or bits to fill, 62 | ** 63 | ** right_justify is 0 for false and 1 for true 64 | ** 65 | ** <--i2s=i2s_enable,is_master,sample_rate,clock_rate> 66 | ** 67 | ** Where 68 | ** 69 | ** i2s_enable is 0 for disable and 1 for enable, 70 | ** 71 | ** is_master is 0 for slave and 1 for master, 72 | ** 73 | ** sample_rate is 0 for 8KHz, 1 for 16Khz and 74 | ** 2 for 4 KHz, 75 | ** 76 | ** clock_rate is 0 for 128KHz, 1 for 256KHz, 3 for 77 | ** 1024 KHz and 4 for 2048 KHz. 78 | ** 79 | ** <--no2bytes skips waiting for two byte confirmation 80 | ** before starting patchram download. Newer chips 81 | ** do not generate these two bytes.> 82 | ** <--tosleep=number of microsseconds to sleep before 83 | ** patchram download begins.> 84 | ** uart_device_name 85 | ** 86 | ** For example: 87 | ** 88 | ** brcm_patchram_plus -d --patchram \ 89 | ** BCM2045B2_002.002.011.0348.0349.hcd /dev/ttyHS0 90 | ** 91 | ** It will return 0 for success and a number greater than 0 92 | ** for any errors. 93 | ** 94 | ** For Android, this program invoked using a 95 | ** "system(2)" call from the beginning of the bt_enable 96 | ** function inside the file 97 | ** system/bluetooth/bluedroid/bluetooth.c. 98 | ** 99 | ** If the Android system property "ro.bt.bcm_bdaddr_path" is 100 | ** set, then the bd_addr will be read from this path. 101 | ** This is overridden by --bd_addr on the command line. 102 | ** 103 | ******************************************************************************/ 104 | 105 | // TODO: Integrate BCM support into Bluez hciattach 106 | 107 | #include 108 | #include 109 | #include 110 | 111 | #include 112 | #include 113 | #include 114 | 115 | #include 116 | #include 117 | 118 | #ifdef ANDROID 119 | #include 120 | #else 121 | #include 122 | #include 123 | #include 124 | #endif 125 | 126 | #include 127 | #include 128 | 129 | #ifdef ANDROID 130 | #include 131 | #define LOG_TAG "brcm_patchram_plus" 132 | #include 133 | #undef printf 134 | #define printf ALOGD 135 | #undef fprintf 136 | #define fprintf(x, ...) \ 137 | { if(x==stderr) ALOGE(__VA_ARGS__); else fprintf(x, __VA_ARGS__); } 138 | 139 | #endif //ANDROID 140 | 141 | #ifndef N_HCI 142 | #define N_HCI 15 143 | #endif 144 | 145 | #define HCIUARTSETPROTO _IOW('U', 200, int) 146 | #define HCIUARTGETPROTO _IOR('U', 201, int) 147 | #define HCIUARTGETDEVICE _IOR('U', 202, int) 148 | #define AP_NAME_SUFFIX_LEN 18 149 | 150 | #define HCI_UART_H4 0 151 | #define HCI_UART_BCSP 1 152 | #define HCI_UART_3WIRE 2 153 | #define HCI_UART_H4DS 3 154 | #define HCI_UART_LL 4 155 | 156 | typedef unsigned char uchar; 157 | 158 | int uart_fd = -1; 159 | int hcdfile_fd = -1; 160 | int termios_baudrate = 0; 161 | int bdaddr_flag = 0; 162 | int enable_lpm = 0; 163 | int enable_hci = 0; 164 | int use_baudrate_for_download = 0; 165 | int debug = 0; 166 | int scopcm = 0; 167 | int i2s = 0; 168 | int no2bytes = 0; 169 | int tosleep = 0; 170 | 171 | struct termios termios; 172 | uchar buffer[1024]; 173 | 174 | uchar hci_reset[] = { 0x01, 0x03, 0x0c, 0x00 }; 175 | 176 | uchar hci_download_minidriver[] = { 0x01, 0x2e, 0xfc, 0x00 }; 177 | 178 | uchar hci_update_baud_rate[] = { 0x01, 0x18, 0xfc, 0x06, 0x00, 0x00, 179 | 0x00, 0x00, 0x00, 0x00 }; 180 | 181 | uchar hci_write_bd_addr[] = { 0x01, 0x01, 0xfc, 0x06, 182 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 183 | 184 | uchar hci_write_sleep_mode[] = { 0x01, 0x27, 0xfc, 0x0c, 185 | 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 186 | 0x00, 0x00 }; 187 | 188 | uchar hci_write_sco_pcm_int[] = 189 | { 0x01, 0x1C, 0xFC, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 }; 190 | 191 | uchar hci_write_pcm_data_format[] = 192 | { 0x01, 0x1e, 0xFC, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00 }; 193 | 194 | uchar hci_write_i2spcm_interface_param[] = 195 | { 0x01, 0x6d, 0xFC, 0x04, 0x00, 0x00, 0x00, 0x00 }; 196 | 197 | int 198 | parse_patchram(char *optarg) 199 | { 200 | char *p; 201 | 202 | if (!(p = strrchr(optarg, '.'))) { 203 | fprintf(stderr, "file %s not an HCD file\n", optarg); 204 | exit(3); 205 | } 206 | 207 | p++; 208 | 209 | if (strcasecmp("hcd", p) != 0) { 210 | fprintf(stderr, "file %s not an HCD file\n", optarg); 211 | exit(4); 212 | } 213 | 214 | if ((hcdfile_fd = open(optarg, O_RDONLY)) == -1) { 215 | fprintf(stderr, "file %s could not be opened, error %d\n", optarg, errno); 216 | exit(5); 217 | } 218 | 219 | return(0); 220 | } 221 | 222 | void 223 | BRCM_encode_baud_rate(uint baud_rate, uchar *encoded_baud) 224 | { 225 | if(baud_rate == 0 || encoded_baud == NULL) { 226 | fprintf(stderr, "Baudrate not supported!"); 227 | return; 228 | } 229 | 230 | encoded_baud[3] = (uchar)(baud_rate >> 24); 231 | encoded_baud[2] = (uchar)(baud_rate >> 16); 232 | encoded_baud[1] = (uchar)(baud_rate >> 8); 233 | encoded_baud[0] = (uchar)(baud_rate & 0xFF); 234 | } 235 | 236 | typedef struct { 237 | int baud_rate; 238 | int termios_value; 239 | } tBaudRates; 240 | 241 | tBaudRates baud_rates[] = { 242 | { 115200, B115200 }, 243 | { 230400, B230400 }, 244 | { 460800, B460800 }, 245 | { 500000, B500000 }, 246 | { 576000, B576000 }, 247 | { 921600, B921600 }, 248 | { 1000000, B1000000 }, 249 | { 1152000, B1152000 }, 250 | { 1500000, B1500000 }, 251 | { 2000000, B2000000 }, 252 | { 2500000, B2500000 }, 253 | { 3000000, B3000000 }, 254 | #ifndef __CYGWIN__ 255 | { 3500000, B3500000 }, 256 | { 4000000, B4000000 } 257 | #endif 258 | }; 259 | 260 | int 261 | validate_baudrate(int baud_rate, int *value) 262 | { 263 | unsigned int i; 264 | 265 | for (i = 0; i < (sizeof(baud_rates) / sizeof(tBaudRates)); i++) { 266 | if (baud_rates[i].baud_rate == baud_rate) { 267 | *value = baud_rates[i].termios_value; 268 | return(1); 269 | } 270 | } 271 | 272 | return(0); 273 | } 274 | 275 | int 276 | parse_baudrate(char *optarg) 277 | { 278 | int baudrate = atoi(optarg); 279 | 280 | if (validate_baudrate(baudrate, &termios_baudrate)) { 281 | BRCM_encode_baud_rate(baudrate, &hci_update_baud_rate[6]); 282 | } 283 | 284 | return(0); 285 | } 286 | 287 | int 288 | parse_bdaddr(char *optarg) 289 | { 290 | int bd_addr[6]; 291 | int i; 292 | 293 | sscanf(optarg, "%02X:%02X:%02X:%02X:%02X:%02X", 294 | &bd_addr[5], &bd_addr[4], &bd_addr[3], 295 | &bd_addr[2], &bd_addr[1], &bd_addr[0]); 296 | 297 | for (i = 0; i < 6; i++) { 298 | hci_write_bd_addr[4 + i] = bd_addr[i]; 299 | } 300 | 301 | bdaddr_flag = 1; 302 | 303 | return(0); 304 | } 305 | 306 | int 307 | readApName(char *name, int len) 308 | { 309 | FILE* devInfo = NULL; 310 | 311 | if(len < AP_NAME_SUFFIX_LEN) { 312 | return -1; 313 | } 314 | 315 | devInfo = fopen("/data/cfg/device_info.txt","rb+"); 316 | if(devInfo) { 317 | fseek(devInfo, 36, SEEK_SET); 318 | fread(name, 1, AP_NAME_SUFFIX_LEN, devInfo); 319 | fclose(devInfo); 320 | // is default value or not 321 | if(0 == strncmp(name, "11:22:33:44:55:66", 17)) { 322 | return -1; 323 | } 324 | } else { 325 | return -1; 326 | } 327 | 328 | return 0; 329 | } 330 | 331 | int 332 | writeApName(const char* name, int len) 333 | { 334 | FILE* devInfo = NULL; 335 | char nameBuf[AP_NAME_SUFFIX_LEN] = {0}; 336 | 337 | if(len < 17) { 338 | return; 339 | } 340 | 341 | if(0 != strncmp(name, "11:22:33:44:55", 17)) { 342 | devInfo = fopen("/data/cfg/device_info.txt","rb+"); 343 | if(devInfo) { 344 | fseek(devInfo, 36, SEEK_SET); 345 | snprintf(nameBuf, AP_NAME_SUFFIX_LEN, "%s", name); 346 | fwrite(nameBuf, 1, AP_NAME_SUFFIX_LEN, devInfo); 347 | fflush(devInfo); 348 | fsync(fileno(devInfo)); 349 | fclose(devInfo); 350 | } 351 | system("cp /data/cfg/device_info.txt /data/cfg/device_info"); 352 | } 353 | } 354 | 355 | int 356 | parse_bdaddr_rand(char *optarg) 357 | { 358 | int bd_addr[6]; 359 | int i,j; 360 | char optargtest[18]; 361 | 362 | char mh[]=":"; 363 | char metachar[]="ABCDEF0123456789"; 364 | if(0 != readApName(optargtest,AP_NAME_SUFFIX_LEN)){ 365 | srand(time(NULL)); 366 | for(j=0;j<17;j++){ 367 | if(j%3 == 2){ 368 | optargtest[j]= mh[0]; 369 | }else{ 370 | optargtest[j] = metachar[rand()%16]; 371 | } 372 | } 373 | optargtest[17]="\0"; 374 | 375 | writeApName(optargtest,AP_NAME_SUFFIX_LEN); 376 | } 377 | 378 | sscanf(optargtest, "%02X:%02X:%02X:%02X:%02X:%02X", 379 | &bd_addr[5], &bd_addr[4], &bd_addr[3], 380 | &bd_addr[2], &bd_addr[1], &bd_addr[0]); 381 | 382 | for (i = 0; i < 6; i++) { 383 | hci_write_bd_addr[4 + i] = bd_addr[i]; 384 | } 385 | 386 | bdaddr_flag = 1; 387 | 388 | return(0); 389 | } 390 | 391 | int 392 | parse_enable_lpm(char *optarg) 393 | { 394 | enable_lpm = 1; 395 | return(0); 396 | } 397 | 398 | int 399 | parse_use_baudrate_for_download(char *optarg) 400 | { 401 | use_baudrate_for_download = 1; 402 | return(0); 403 | } 404 | 405 | int 406 | parse_enable_hci(char *optarg) 407 | { 408 | enable_hci = 1; 409 | return(0); 410 | } 411 | 412 | int 413 | parse_scopcm(char *optarg) 414 | { 415 | int param[10]; 416 | int ret; 417 | int i; 418 | 419 | ret = sscanf(optarg, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", 420 | ¶m[0], ¶m[1], ¶m[2], ¶m[3], ¶m[4], 421 | ¶m[5], ¶m[6], ¶m[7], ¶m[8], ¶m[9]); 422 | 423 | if (ret != 10) { 424 | return(1); 425 | } 426 | 427 | scopcm = 1; 428 | 429 | for (i = 0; i < 5; i++) { 430 | hci_write_sco_pcm_int[4 + i] = param[i]; 431 | } 432 | 433 | for (i = 0; i < 5; i++) { 434 | hci_write_pcm_data_format[4 + i] = param[5 + i]; 435 | } 436 | 437 | return(0); 438 | } 439 | 440 | int 441 | parse_i2s(char *optarg) 442 | { 443 | int param[4]; 444 | int ret; 445 | int i; 446 | 447 | ret = sscanf(optarg, "%d,%d,%d,%d", ¶m[0], ¶m[1], ¶m[2], 448 | ¶m[3]); 449 | 450 | if (ret != 4) { 451 | return(1); 452 | } 453 | 454 | i2s = 1; 455 | 456 | for (i = 0; i < 4; i++) { 457 | hci_write_i2spcm_interface_param[4 + i] = param[i]; 458 | } 459 | 460 | return(0); 461 | } 462 | 463 | int 464 | parse_no2bytes(char *optarg) 465 | { 466 | no2bytes = 1; 467 | return(0); 468 | } 469 | 470 | int 471 | parse_tosleep(char *optarg) 472 | { 473 | tosleep = atoi(optarg); 474 | 475 | if (tosleep <= 0) { 476 | return(1); 477 | } 478 | 479 | return(0); 480 | } 481 | 482 | void 483 | usage(char *argv0) 484 | { 485 | printf("Usage %s:\n", argv0); 486 | printf("\t<-d> to print a debug log\n"); 487 | printf("\t<--patchram patchram_file>\n"); 488 | printf("\t<--baudrate baud_rate>\n"); 489 | printf("\t<--bd_addr bd_address>\n"); 490 | printf("\t<--enable_lpm>\n"); 491 | printf("\t<--enable_hci>\n"); 492 | printf("\t<--use_baudrate_for_download> - Uses the\n"); 493 | printf("\t\tbaudrate for downloading the firmware\n"); 494 | printf("\t<--scopcm=sco_routing,pcm_interface_rate,frame_type,\n"); 495 | printf("\t\tsync_mode,clock_mode,lsb_first,fill_bits,\n"); 496 | printf("\t\tfill_method,fill_num,right_justify>\n"); 497 | printf("\n\t\tWhere\n"); 498 | printf("\n\t\tsco_routing is 0 for PCM, 1 for Transport,\n"); 499 | printf("\t\t2 for Codec and 3 for I2S,\n"); 500 | printf("\n\t\tpcm_interface_rate is 0 for 128KBps, 1 for\n"); 501 | printf("\t\t256 KBps, 2 for 512KBps, 3 for 1024KBps,\n"); 502 | printf("\t\tand 4 for 2048Kbps,\n"); 503 | printf("\n\t\tframe_type is 0 for short and 1 for long,\n"); 504 | printf("\t\tsync_mode is 0 for slave and 1 for master,\n"); 505 | printf("\n\t\tclock_mode is 0 for slabe and 1 for master,\n"); 506 | printf("\n\t\tlsb_first is 0 for false aand 1 for true,\n"); 507 | printf("\n\t\tfill_bits is the value in decimal for unused bits,\n"); 508 | printf("\n\t\tfill_method is 0 for 0's and 1 for 1's, 2 for\n"); 509 | printf("\t\tsigned and 3 for programmable,\n"); 510 | printf("\n\t\tfill_num is the number or bits to fill,\n"); 511 | printf("\n\t\tright_justify is 0 for false and 1 for true\n"); 512 | printf("\n\t<--i2s=i2s_enable,is_master,sample_rate,clock_rate>\n"); 513 | printf("\n\t\tWhere\n"); 514 | printf("\n\t\ti2s_enable is 0 for disable and 1 for enable,\n"); 515 | printf("\n\t\tis_master is 0 for slave and 1 for master,\n"); 516 | printf("\n\t\tsample_rate is 0 for 8KHz, 1 for 16Khz and\n"); 517 | printf("\t\t2 for 4 KHz,\n"); 518 | printf("\n\t\tclock_rate is 0 for 128KHz, 1 for 256KHz, 3 for\n"); 519 | printf("\t\t1024 KHz and 4 for 2048 KHz.\n\n"); 520 | printf("\t<--no2bytes skips waiting for two byte confirmation\n"); 521 | printf("\t\tbefore starting patchram download. Newer chips\n"); 522 | printf("\t\tdo not generate these two bytes.>\n"); 523 | printf("\t<--tosleep=microseconds>\n"); 524 | printf("\tuart_device_name\n"); 525 | } 526 | 527 | int 528 | parse_cmd_line(int argc, char **argv) 529 | { 530 | int c; 531 | int ret = 0; 532 | 533 | typedef int (*PFI)(); 534 | 535 | PFI parse[] = { parse_patchram, parse_baudrate, 536 | parse_bdaddr,parse_bdaddr_rand, parse_enable_lpm, parse_enable_hci, 537 | parse_use_baudrate_for_download, 538 | parse_scopcm, parse_i2s, parse_no2bytes, parse_tosleep}; 539 | 540 | while (1) { 541 | int this_option_optind = optind ? optind : 1; 542 | int option_index = 0; 543 | 544 | static struct option long_options[] = { 545 | {"patchram", 1, 0, 0}, 546 | {"baudrate", 1, 0, 0}, 547 | {"bd_addr", 1, 0, 0}, 548 | {"bd_addr_rand", 0, 0, 0}, 549 | {"enable_lpm", 0, 0, 0}, 550 | {"enable_hci", 0, 0, 0}, 551 | {"use_baudrate_for_download", 0, 0, 0}, 552 | {"scopcm", 1, 0, 0}, 553 | {"i2s", 1, 0, 0}, 554 | {"no2bytes", 0, 0, 0}, 555 | {"tosleep", 1, 0, 0}, 556 | {0, 0, 0, 0} 557 | }; 558 | 559 | c = getopt_long_only (argc, argv, "d", long_options, 560 | &option_index); 561 | 562 | if (c == -1) { 563 | break; 564 | } 565 | 566 | switch (c) { 567 | case 0: 568 | if (debug) { 569 | printf ("option %s", 570 | long_options[option_index].name); 571 | if (optarg) 572 | printf (" with arg %s", optarg); 573 | printf ("\n"); 574 | } 575 | 576 | ret = (*parse[option_index])(optarg); 577 | 578 | break; 579 | case 'd': 580 | debug = 1; 581 | break; 582 | 583 | case '?': 584 | //nobreak 585 | default: 586 | usage(argv[0]); 587 | break; 588 | } 589 | 590 | if (ret) { 591 | usage(argv[0]); 592 | break; 593 | } 594 | } 595 | 596 | if (ret) { 597 | return(1); 598 | } 599 | 600 | if (optind < argc) { 601 | if (debug) 602 | printf ("%s \n", argv[optind]); 603 | if ((uart_fd = open(argv[optind], O_RDWR | O_NOCTTY)) == -1) { 604 | fprintf(stderr, "port %s could not be opened, error %d\n", 605 | argv[2], errno); 606 | } 607 | } 608 | 609 | return(0); 610 | } 611 | 612 | void 613 | init_uart() 614 | { 615 | tcflush(uart_fd, TCIOFLUSH); 616 | tcgetattr(uart_fd, &termios); 617 | 618 | #ifndef __CYGWIN__ 619 | cfmakeraw(&termios); 620 | #else 621 | termios.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP 622 | | INLCR | IGNCR | ICRNL | IXON); 623 | termios.c_oflag &= ~OPOST; 624 | termios.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); 625 | termios.c_cflag &= ~(CSIZE | PARENB); 626 | termios.c_cflag |= CS8; 627 | #endif 628 | 629 | termios.c_cflag |= CRTSCTS; 630 | tcsetattr(uart_fd, TCSANOW, &termios); 631 | tcflush(uart_fd, TCIOFLUSH); 632 | tcsetattr(uart_fd, TCSANOW, &termios); 633 | tcflush(uart_fd, TCIOFLUSH); 634 | tcflush(uart_fd, TCIOFLUSH); 635 | cfsetospeed(&termios, B115200); 636 | cfsetispeed(&termios, B115200); 637 | tcsetattr(uart_fd, TCSANOW, &termios); 638 | } 639 | 640 | void 641 | dump(uchar *out, int len) 642 | { 643 | int i; 644 | 645 | for (i = 0; i < len; i++) { 646 | if (i && !(i % 16)) { 647 | fprintf(stderr, "\n"); 648 | } 649 | 650 | fprintf(stderr, "%02x ", out[i]); 651 | } 652 | 653 | fprintf(stderr, "\n"); 654 | } 655 | 656 | void 657 | read_event(int fd, uchar *buffer) 658 | { 659 | int i = 0; 660 | int len = 3; 661 | int count; 662 | 663 | while ((count = read(fd, &buffer[i], len)) < len) { 664 | i += count; 665 | len -= count; 666 | //fprintf(stderr, "received11 %d\n", count); 667 | } 668 | 669 | i += count; 670 | len = buffer[2]; 671 | //fprintf(stderr, "received22 %d\n", count); 672 | 673 | while ((count = read(fd, &buffer[i], len)) < len) { 674 | i += count; 675 | len -= count; 676 | } 677 | //fprintf(stderr, "received33 %d\n", count); 678 | 679 | if (debug) { 680 | count += i; 681 | 682 | fprintf(stderr, "received %d\n", count); 683 | dump(buffer, count); 684 | } 685 | } 686 | 687 | void 688 | hci_send_cmd(uchar *buf, int len) 689 | { 690 | if (debug) { 691 | fprintf(stderr, "writing\n"); 692 | dump(buf, len); 693 | } 694 | 695 | write(uart_fd, buf, len); 696 | } 697 | 698 | void 699 | expired(int sig) 700 | { 701 | hci_send_cmd(hci_reset, sizeof(hci_reset)); 702 | alarm(4); 703 | } 704 | 705 | void 706 | proc_reset() 707 | { 708 | signal(SIGALRM, expired); 709 | 710 | fprintf(stderr, "proc_reset"); 711 | 712 | hci_send_cmd(hci_reset, sizeof(hci_reset)); 713 | 714 | alarm(4); 715 | 716 | read_event(uart_fd, buffer); 717 | 718 | alarm(0); 719 | } 720 | 721 | void 722 | proc_patchram() 723 | { 724 | int len; 725 | 726 | hci_send_cmd(hci_download_minidriver, sizeof(hci_download_minidriver)); 727 | 728 | fprintf(stderr, "send hci_download_minidriver"); 729 | 730 | read_event(uart_fd, buffer); 731 | 732 | if (!no2bytes) { 733 | read(uart_fd, &buffer[0], 2); 734 | } 735 | 736 | if (tosleep) { 737 | usleep(tosleep); 738 | } 739 | 740 | while (read(hcdfile_fd, &buffer[1], 3)) { 741 | buffer[0] = 0x01; 742 | 743 | len = buffer[3]; 744 | 745 | read(hcdfile_fd, &buffer[4], len); 746 | 747 | hci_send_cmd(buffer, len + 4); 748 | 749 | read_event(uart_fd, buffer); 750 | } 751 | usleep(200000); 752 | 753 | if (use_baudrate_for_download) { 754 | cfsetospeed(&termios, B115200); 755 | cfsetispeed(&termios, B115200); 756 | tcsetattr(uart_fd, TCSANOW, &termios); 757 | } 758 | proc_reset(); 759 | } 760 | 761 | void 762 | proc_baudrate() 763 | { 764 | hci_send_cmd(hci_update_baud_rate, sizeof(hci_update_baud_rate)); 765 | 766 | read_event(uart_fd, buffer); 767 | 768 | usleep(200000); 769 | 770 | cfsetospeed(&termios, termios_baudrate); 771 | cfsetispeed(&termios, termios_baudrate); 772 | tcsetattr(uart_fd, TCSANOW, &termios); 773 | 774 | if (debug) { 775 | fprintf(stderr, "Done setting baudrate\n"); 776 | } 777 | } 778 | 779 | void 780 | proc_bdaddr() 781 | { 782 | hci_send_cmd(hci_write_bd_addr, sizeof(hci_write_bd_addr)); 783 | 784 | read_event(uart_fd, buffer); 785 | } 786 | 787 | void 788 | proc_enable_lpm() 789 | { 790 | hci_send_cmd(hci_write_sleep_mode, sizeof(hci_write_sleep_mode)); 791 | 792 | read_event(uart_fd, buffer); 793 | } 794 | 795 | void 796 | proc_scopcm() 797 | { 798 | hci_send_cmd(hci_write_sco_pcm_int, 799 | sizeof(hci_write_sco_pcm_int)); 800 | 801 | read_event(uart_fd, buffer); 802 | 803 | hci_send_cmd(hci_write_pcm_data_format, 804 | sizeof(hci_write_pcm_data_format)); 805 | 806 | read_event(uart_fd, buffer); 807 | } 808 | 809 | void 810 | proc_i2s() 811 | { 812 | hci_send_cmd(hci_write_i2spcm_interface_param, 813 | sizeof(hci_write_i2spcm_interface_param)); 814 | 815 | read_event(uart_fd, buffer); 816 | } 817 | 818 | void 819 | proc_enable_hci() 820 | { 821 | int i = N_HCI; 822 | int proto = HCI_UART_H4; 823 | if (ioctl(uart_fd, TIOCSETD, &i) < 0) { 824 | fprintf(stderr, "Can't set line discipline\n"); 825 | return; 826 | } 827 | 828 | if (ioctl(uart_fd, HCIUARTSETPROTO, proto) < 0) { 829 | fprintf(stderr, "Can't set hci protocol\n"); 830 | return; 831 | } 832 | fprintf(stderr, "Done setting line discpline\n"); 833 | return; 834 | } 835 | 836 | #ifdef ANDROID 837 | void 838 | read_default_bdaddr() 839 | { 840 | int sz; 841 | int fd; 842 | 843 | char path[PROPERTY_VALUE_MAX]; 844 | 845 | char bdaddr[18]; 846 | int len = 17; 847 | memset(bdaddr, 0, (len + 1) * sizeof(char)); 848 | 849 | property_get("ro.bt.bdaddr_path", path, ""); 850 | if (path[0] == 0) 851 | return; 852 | 853 | fd = open(path, O_RDONLY); 854 | if (fd < 0) { 855 | fprintf(stderr, "open(%s) failed: %s (%d)", path, strerror(errno), 856 | errno); 857 | return; 858 | } 859 | 860 | sz = read(fd, bdaddr, len); 861 | if (sz < 0) { 862 | fprintf(stderr, "read(%s) failed: %s (%d)", path, strerror(errno), 863 | errno); 864 | close(fd); 865 | return; 866 | } else if (sz != len) { 867 | fprintf(stderr, "read(%s) unexpected size %d", path, sz); 868 | close(fd); 869 | return; 870 | } 871 | 872 | if (debug) { 873 | printf("Read default bdaddr of %s\n", bdaddr); 874 | } 875 | 876 | parse_bdaddr(bdaddr); 877 | } 878 | #endif 879 | 880 | 881 | int 882 | main (int argc, char **argv) 883 | { 884 | #ifdef ANDROID 885 | read_default_bdaddr(); 886 | #endif 887 | 888 | if (parse_cmd_line(argc, argv)) { 889 | exit(1); 890 | } 891 | 892 | if (uart_fd < 0) { 893 | exit(2); 894 | } 895 | 896 | init_uart(); 897 | 898 | proc_reset(); 899 | 900 | if (use_baudrate_for_download) { 901 | if (termios_baudrate) { 902 | proc_baudrate(); 903 | } 904 | } 905 | 906 | if (hcdfile_fd > 0) { 907 | proc_patchram(); 908 | } 909 | 910 | if (termios_baudrate) { 911 | proc_baudrate(); 912 | } 913 | 914 | if (bdaddr_flag) { 915 | proc_bdaddr(); 916 | } 917 | 918 | if (enable_lpm) { 919 | proc_enable_lpm(); 920 | } 921 | 922 | if (scopcm) { 923 | proc_scopcm(); 924 | } 925 | 926 | if (i2s) { 927 | proc_i2s(); 928 | } 929 | 930 | if (enable_hci) { 931 | proc_enable_hci(); 932 | 933 | while (1) { 934 | sleep(UINT_MAX); 935 | } 936 | } 937 | 938 | exit(0); 939 | } 940 | -------------------------------------------------------------------------------- /recipes-devtools/rtl-tools/files/hciattach.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * BlueZ - Bluetooth protocol stack for Linux 4 | * 5 | * Copyright (C) 2000-2001 Qualcomm Incorporated 6 | * Copyright (C) 2002-2003 Maxim Krasnyansky 7 | * Copyright (C) 2002-2010 Marcel Holtmann 8 | * 9 | * 10 | * This program is free software; you can redistribute it and/or modify 11 | * it under the terms of the GNU General Public License as published by 12 | * the Free Software Foundation; either version 2 of the License, or 13 | * (at your option) any later version. 14 | * 15 | * This program is distributed in the hope that it will be useful, 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | * GNU General Public License for more details. 19 | * 20 | * You should have received a copy of the GNU General Public License 21 | * along with this program; if not, write to the Free Software 22 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 | * 24 | */ 25 | 26 | #ifdef HAVE_CONFIG_H 27 | #include 28 | #endif 29 | 30 | #define _GNU_SOURCE 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include "hciattach.h" 49 | 50 | #ifdef NEED_PPOLL 51 | #include "ppoll.h" 52 | #endif 53 | 54 | struct uart_t { 55 | char *type; 56 | int m_id; 57 | int p_id; 58 | int proto; 59 | int init_speed; 60 | int speed; 61 | int flags; 62 | int pm; 63 | char *bdaddr; 64 | int (*init) (int fd, struct uart_t *u, struct termios *ti); 65 | int (*post) (int fd, struct uart_t *u, struct termios *ti); 66 | }; 67 | 68 | #define FLOW_CTL 0x0001 69 | #define ENABLE_PM 1 70 | #define DISABLE_PM 0 71 | 72 | static volatile sig_atomic_t __io_canceled = 0; 73 | 74 | static void sig_hup(int sig) 75 | { 76 | printf("sig hup.\n"); 77 | } 78 | 79 | static void sig_term(int sig) 80 | { 81 | switch (sig) { 82 | case SIGINT: 83 | printf("sig int.\n"); 84 | break; 85 | case SIGTERM: 86 | printf("sig term.\n"); 87 | break; 88 | } 89 | __io_canceled = 1; 90 | } 91 | 92 | static void sig_alarm(int sig) 93 | { 94 | fprintf(stderr, "Initialization timed out.\n"); 95 | exit(1); 96 | } 97 | 98 | static int uart_speed(int s) 99 | { 100 | switch (s) { 101 | case 9600: 102 | return B9600; 103 | case 19200: 104 | return B19200; 105 | case 38400: 106 | return B38400; 107 | case 57600: 108 | return B57600; 109 | case 115200: 110 | return B115200; 111 | case 230400: 112 | return B230400; 113 | case 460800: 114 | return B460800; 115 | case 500000: 116 | return B500000; 117 | case 576000: 118 | return B576000; 119 | case 921600: 120 | return B921600; 121 | case 1000000: 122 | return B1000000; 123 | case 1152000: 124 | return B1152000; 125 | case 1500000: 126 | return B1500000; 127 | case 2000000: 128 | return B2000000; 129 | #ifdef B2500000 130 | case 2500000: 131 | return B2500000; 132 | #endif 133 | #ifdef B3000000 134 | case 3000000: 135 | return B3000000; 136 | #endif 137 | #ifdef B3500000 138 | case 3500000: 139 | return B3500000; 140 | #endif 141 | #ifdef B4000000 142 | case 4000000: 143 | return B4000000; 144 | #endif 145 | default: 146 | return B57600; 147 | } 148 | } 149 | 150 | int set_speed(int fd, struct termios *ti, int speed) 151 | { 152 | if (cfsetospeed(ti, uart_speed(speed)) < 0) 153 | return -errno; 154 | 155 | if (cfsetispeed(ti, uart_speed(speed)) < 0) 156 | return -errno; 157 | 158 | if (tcsetattr(fd, TCSANOW, ti) < 0) 159 | return -errno; 160 | 161 | return 0; 162 | } 163 | 164 | /* 165 | * Read an HCI event from the given file descriptor. 166 | */ 167 | int read_hci_event(int fd, unsigned char* buf, int size) 168 | { 169 | int remain, r; 170 | int count = 0; 171 | 172 | if (size <= 0) 173 | return -1; 174 | 175 | /* The first byte identifies the packet type. For HCI event packets, it 176 | * should be 0x04, so we read until we get to the 0x04. */ 177 | while (1) { 178 | r = read(fd, buf, 1); 179 | if (r <= 0) 180 | return -1; 181 | if (buf[0] == 0x04) 182 | break; 183 | } 184 | count++; 185 | 186 | /* The next two bytes are the event code and parameter total length. */ 187 | while (count < 3) { 188 | r = read(fd, buf + count, 3 - count); 189 | if (r <= 0) 190 | return -1; 191 | count += r; 192 | } 193 | 194 | /* Now we read the parameters. */ 195 | if (buf[2] < (size - 3)) 196 | remain = buf[2]; 197 | else 198 | remain = size - 3; 199 | 200 | while ((count - 3) < remain) { 201 | r = read(fd, buf + count, remain - (count - 3)); 202 | if (r <= 0) 203 | return -1; 204 | count += r; 205 | } 206 | 207 | return count; 208 | } 209 | 210 | #if 0 211 | /* 212 | * Ericsson specific initialization 213 | */ 214 | static int ericsson(int fd, struct uart_t *u, struct termios *ti) 215 | { 216 | struct timespec tm = {0, 50000}; 217 | char cmd[5]; 218 | 219 | cmd[0] = HCI_COMMAND_PKT; 220 | cmd[1] = 0x09; 221 | cmd[2] = 0xfc; 222 | cmd[3] = 0x01; 223 | 224 | switch (u->speed) { 225 | case 57600: 226 | cmd[4] = 0x03; 227 | break; 228 | case 115200: 229 | cmd[4] = 0x02; 230 | break; 231 | case 230400: 232 | cmd[4] = 0x01; 233 | break; 234 | case 460800: 235 | cmd[4] = 0x00; 236 | break; 237 | case 921600: 238 | cmd[4] = 0x20; 239 | break; 240 | case 2000000: 241 | cmd[4] = 0x25; 242 | break; 243 | case 3000000: 244 | cmd[4] = 0x27; 245 | break; 246 | case 4000000: 247 | cmd[4] = 0x2B; 248 | break; 249 | default: 250 | cmd[4] = 0x03; 251 | u->speed = 57600; 252 | fprintf(stderr, "Invalid speed requested, using %d bps instead\n", u->speed); 253 | break; 254 | } 255 | 256 | /* Send initialization command */ 257 | if (write(fd, cmd, 5) != 5) { 258 | perror("Failed to write init command"); 259 | return -1; 260 | } 261 | 262 | nanosleep(&tm, NULL); 263 | return 0; 264 | } 265 | 266 | /* 267 | * Digianswer specific initialization 268 | */ 269 | static int digi(int fd, struct uart_t *u, struct termios *ti) 270 | { 271 | struct timespec tm = {0, 50000}; 272 | char cmd[5]; 273 | 274 | /* DigiAnswer set baud rate command */ 275 | cmd[0] = HCI_COMMAND_PKT; 276 | cmd[1] = 0x07; 277 | cmd[2] = 0xfc; 278 | cmd[3] = 0x01; 279 | 280 | switch (u->speed) { 281 | case 57600: 282 | cmd[4] = 0x08; 283 | break; 284 | case 115200: 285 | cmd[4] = 0x09; 286 | break; 287 | default: 288 | cmd[4] = 0x09; 289 | u->speed = 115200; 290 | break; 291 | } 292 | 293 | /* Send initialization command */ 294 | if (write(fd, cmd, 5) != 5) { 295 | perror("Failed to write init command"); 296 | return -1; 297 | } 298 | 299 | nanosleep(&tm, NULL); 300 | return 0; 301 | } 302 | 303 | static int texas(int fd, struct uart_t *u, struct termios *ti) 304 | { 305 | return texas_init(fd, ti); 306 | } 307 | 308 | static int texas2(int fd, struct uart_t *u, struct termios *ti) 309 | { 310 | return texas_post(fd, ti); 311 | } 312 | 313 | static int texasalt(int fd, struct uart_t *u, struct termios *ti) 314 | { 315 | return texasalt_init(fd, u->speed, ti); 316 | } 317 | #endif 318 | 319 | 320 | 321 | static int read_check(int fd, void *buf, int count) 322 | { 323 | int res; 324 | 325 | do { 326 | res = read(fd, buf, count); 327 | if (res != -1) { 328 | buf += res; 329 | count -= res; 330 | } 331 | } while (count && (errno == 0 || errno == EINTR)); 332 | 333 | if (count) 334 | return -1; 335 | 336 | return 0; 337 | } 338 | 339 | /* 340 | * BCSP specific initialization 341 | */ 342 | static int serial_fd; 343 | static int bcsp_max_retries = 10; 344 | 345 | static void bcsp_tshy_sig_alarm(int sig) 346 | { 347 | unsigned char bcsp_sync_pkt[10] = {0xc0,0x00,0x41,0x00,0xbe,0xda,0xdc,0xed,0xed,0xc0}; 348 | static int retries = 0; 349 | 350 | if (retries < bcsp_max_retries) { 351 | retries++; 352 | if (write(serial_fd, &bcsp_sync_pkt, 10) < 0) 353 | return; 354 | alarm(1); 355 | return; 356 | } 357 | 358 | tcflush(serial_fd, TCIOFLUSH); 359 | fprintf(stderr, "BCSP initialization timed out\n"); 360 | exit(1); 361 | } 362 | 363 | static void bcsp_tconf_sig_alarm(int sig) 364 | { 365 | unsigned char bcsp_conf_pkt[10] = {0xc0,0x00,0x41,0x00,0xbe,0xad,0xef,0xac,0xed,0xc0}; 366 | static int retries = 0; 367 | 368 | if (retries < bcsp_max_retries){ 369 | retries++; 370 | if (write(serial_fd, &bcsp_conf_pkt, 10) < 0) 371 | return; 372 | alarm(1); 373 | return; 374 | } 375 | 376 | tcflush(serial_fd, TCIOFLUSH); 377 | fprintf(stderr, "BCSP initialization timed out\n"); 378 | exit(1); 379 | } 380 | 381 | static int bcsp(int fd, struct uart_t *u, struct termios *ti) 382 | { 383 | unsigned char byte, bcsph[4], bcspp[4], 384 | bcsp_sync_resp_pkt[10] = {0xc0,0x00,0x41,0x00,0xbe,0xac,0xaf,0xef,0xee,0xc0}, 385 | bcsp_conf_resp_pkt[10] = {0xc0,0x00,0x41,0x00,0xbe,0xde,0xad,0xd0,0xd0,0xc0}, 386 | bcspsync[4] = {0xda, 0xdc, 0xed, 0xed}, 387 | bcspsyncresp[4] = {0xac,0xaf,0xef,0xee}, 388 | bcspconf[4] = {0xad,0xef,0xac,0xed}, 389 | bcspconfresp[4] = {0xde,0xad,0xd0,0xd0}; 390 | struct sigaction sa; 391 | int len; 392 | 393 | if (set_speed(fd, ti, u->speed) < 0) { 394 | perror("Can't set default baud rate"); 395 | return -1; 396 | } 397 | 398 | ti->c_cflag |= PARENB; 399 | ti->c_cflag &= ~(PARODD); 400 | 401 | if (tcsetattr(fd, TCSANOW, ti) < 0) { 402 | perror("Can't set port settings"); 403 | return -1; 404 | } 405 | 406 | alarm(0); 407 | 408 | serial_fd = fd; 409 | memset(&sa, 0, sizeof(sa)); 410 | sa.sa_flags = SA_NOCLDSTOP; 411 | sa.sa_handler = bcsp_tshy_sig_alarm; 412 | sigaction(SIGALRM, &sa, NULL); 413 | 414 | /* State = shy */ 415 | 416 | bcsp_tshy_sig_alarm(0); 417 | while (1) { 418 | do { 419 | if (read_check(fd, &byte, 1) == -1){ 420 | perror("Failed to read"); 421 | return -1; 422 | } 423 | } while (byte != 0xC0); 424 | 425 | do { 426 | if ( read_check(fd, &bcsph[0], 1) == -1){ 427 | perror("Failed to read"); 428 | return -1; 429 | } 430 | } while (bcsph[0] == 0xC0); 431 | 432 | if ( read_check(fd, &bcsph[1], 3) == -1){ 433 | perror("Failed to read"); 434 | return -1; 435 | } 436 | 437 | if (((bcsph[0] + bcsph[1] + bcsph[2]) & 0xFF) != (unsigned char)~bcsph[3]) 438 | continue; 439 | if (bcsph[1] != 0x41 || bcsph[2] != 0x00) 440 | continue; 441 | 442 | if (read_check(fd, &bcspp, 4) == -1){ 443 | perror("Failed to read"); 444 | return -1; 445 | } 446 | 447 | if (!memcmp(bcspp, bcspsync, 4)) { 448 | if (write(fd, &bcsp_sync_resp_pkt,10) < 0) 449 | return -1; 450 | } else if (!memcmp(bcspp, bcspsyncresp, 4)) 451 | break; 452 | } 453 | 454 | /* State = curious */ 455 | 456 | alarm(0); 457 | sa.sa_handler = bcsp_tconf_sig_alarm; 458 | sigaction(SIGALRM, &sa, NULL); 459 | alarm(1); 460 | 461 | while (1) { 462 | do { 463 | if (read_check(fd, &byte, 1) == -1){ 464 | perror("Failed to read"); 465 | return -1; 466 | } 467 | } while (byte != 0xC0); 468 | 469 | do { 470 | if (read_check(fd, &bcsph[0], 1) == -1){ 471 | perror("Failed to read"); 472 | return -1; 473 | } 474 | } while (bcsph[0] == 0xC0); 475 | 476 | if (read_check(fd, &bcsph[1], 3) == -1){ 477 | perror("Failed to read"); 478 | return -1; 479 | } 480 | 481 | if (((bcsph[0] + bcsph[1] + bcsph[2]) & 0xFF) != (unsigned char)~bcsph[3]) 482 | continue; 483 | 484 | if (bcsph[1] != 0x41 || bcsph[2] != 0x00) 485 | continue; 486 | 487 | if (read_check(fd, &bcspp, 4) == -1){ 488 | perror("Failed to read"); 489 | return -1; 490 | } 491 | 492 | if (!memcmp(bcspp, bcspsync, 4)) 493 | len = write(fd, &bcsp_sync_resp_pkt, 10); 494 | else if (!memcmp(bcspp, bcspconf, 4)) 495 | len = write(fd, &bcsp_conf_resp_pkt, 10); 496 | else if (!memcmp(bcspp, bcspconfresp, 4)) 497 | break; 498 | else 499 | continue; 500 | 501 | if (len < 0) 502 | return -errno; 503 | } 504 | 505 | /* State = garrulous */ 506 | 507 | return 0; 508 | } 509 | 510 | #if 0 511 | /* 512 | * CSR specific initialization 513 | * Inspired strongly by code in OpenBT and experimentations with Brainboxes 514 | * Pcmcia card. 515 | * Jean Tourrilhes - 14.11.01 516 | */ 517 | static int csr(int fd, struct uart_t *u, struct termios *ti) 518 | { 519 | struct timespec tm = {0, 10000000}; /* 10ms - be generous */ 520 | unsigned char cmd[30]; /* Command */ 521 | unsigned char resp[30]; /* Response */ 522 | int clen = 0; /* Command len */ 523 | static int csr_seq = 0; /* Sequence number of command */ 524 | int divisor; 525 | 526 | /* It seems that if we set the CSR UART speed straight away, it 527 | * won't work, the CSR UART gets into a state where we can't talk 528 | * to it anymore. 529 | * On the other hand, doing a read before setting the CSR speed 530 | * seems to be ok. 531 | * Therefore, the strategy is to read the build ID (useful for 532 | * debugging) and only then set the CSR UART speed. Doing like 533 | * this is more complex but at least it works ;-) 534 | * The CSR UART control may be slow to wake up or something because 535 | * every time I read its speed, its bogus... 536 | * Jean II */ 537 | 538 | /* Try to read the build ID of the CSR chip */ 539 | clen = 5 + (5 + 6) * 2; 540 | /* HCI header */ 541 | cmd[0] = HCI_COMMAND_PKT; 542 | cmd[1] = 0x00; /* CSR command */ 543 | cmd[2] = 0xfc; /* MANUFACTURER_SPEC */ 544 | cmd[3] = 1 + (5 + 6) * 2; /* len */ 545 | /* CSR MSG header */ 546 | cmd[4] = 0xC2; /* first+last+channel=BCC */ 547 | /* CSR BCC header */ 548 | cmd[5] = 0x00; /* type = GET-REQ */ 549 | cmd[6] = 0x00; /* - msB */ 550 | cmd[7] = 5 + 4; /* len */ 551 | cmd[8] = 0x00; /* - msB */ 552 | cmd[9] = csr_seq & 0xFF;/* seq num */ 553 | cmd[10] = (csr_seq >> 8) & 0xFF; /* - msB */ 554 | csr_seq++; 555 | cmd[11] = 0x19; /* var_id = CSR_CMD_BUILD_ID */ 556 | cmd[12] = 0x28; /* - msB */ 557 | cmd[13] = 0x00; /* status = STATUS_OK */ 558 | cmd[14] = 0x00; /* - msB */ 559 | /* CSR BCC payload */ 560 | memset(cmd + 15, 0, 6 * 2); 561 | 562 | /* Send command */ 563 | do { 564 | if (write(fd, cmd, clen) != clen) { 565 | perror("Failed to write init command (GET_BUILD_ID)"); 566 | return -1; 567 | } 568 | 569 | /* Read reply. */ 570 | if (read_hci_event(fd, resp, 100) < 0) { 571 | perror("Failed to read init response (GET_BUILD_ID)"); 572 | return -1; 573 | } 574 | 575 | /* Event code 0xFF is for vendor-specific events, which is 576 | * what we're looking for. */ 577 | } while (resp[1] != 0xFF); 578 | 579 | #ifdef CSR_DEBUG 580 | { 581 | char temp[512]; 582 | int i; 583 | for (i=0; i < rlen; i++) 584 | sprintf(temp + (i*3), "-%02X", resp[i]); 585 | fprintf(stderr, "Reading CSR build ID %d [%s]\n", rlen, temp + 1); 586 | // In theory, it should look like : 587 | // 04-FF-13-FF-01-00-09-00-00-00-19-28-00-00-73-00-00-00-00-00-00-00 588 | } 589 | #endif 590 | /* Display that to user */ 591 | fprintf(stderr, "CSR build ID 0x%02X-0x%02X\n", 592 | resp[15] & 0xFF, resp[14] & 0xFF); 593 | 594 | /* Try to read the current speed of the CSR chip */ 595 | clen = 5 + (5 + 4)*2; 596 | /* -- HCI header */ 597 | cmd[3] = 1 + (5 + 4)*2; /* len */ 598 | /* -- CSR BCC header -- */ 599 | cmd[9] = csr_seq & 0xFF; /* seq num */ 600 | cmd[10] = (csr_seq >> 8) & 0xFF; /* - msB */ 601 | csr_seq++; 602 | cmd[11] = 0x02; /* var_id = CONFIG_UART */ 603 | cmd[12] = 0x68; /* - msB */ 604 | 605 | #ifdef CSR_DEBUG 606 | /* Send command */ 607 | do { 608 | if (write(fd, cmd, clen) != clen) { 609 | perror("Failed to write init command (GET_BUILD_ID)"); 610 | return -1; 611 | } 612 | 613 | /* Read reply. */ 614 | if (read_hci_event(fd, resp, 100) < 0) { 615 | perror("Failed to read init response (GET_BUILD_ID)"); 616 | return -1; 617 | } 618 | 619 | /* Event code 0xFF is for vendor-specific events, which is 620 | * what we're looking for. */ 621 | } while (resp[1] != 0xFF); 622 | 623 | { 624 | char temp[512]; 625 | int i; 626 | for (i=0; i < rlen; i++) 627 | sprintf(temp + (i*3), "-%02X", resp[i]); 628 | fprintf(stderr, "Reading CSR UART speed %d [%s]\n", rlen, temp+1); 629 | } 630 | #endif 631 | 632 | if (u->speed > 1500000) { 633 | fprintf(stderr, "Speed %d too high. Remaining at %d baud\n", 634 | u->speed, u->init_speed); 635 | u->speed = u->init_speed; 636 | } else if (u->speed != 57600 && uart_speed(u->speed) == B57600) { 637 | /* Unknown speed. Why oh why can't we just pass an int to the kernel? */ 638 | fprintf(stderr, "Speed %d unrecognised. Remaining at %d baud\n", 639 | u->speed, u->init_speed); 640 | u->speed = u->init_speed; 641 | } 642 | if (u->speed == u->init_speed) 643 | return 0; 644 | 645 | /* Now, create the command that will set the UART speed */ 646 | /* CSR BCC header */ 647 | cmd[5] = 0x02; /* type = SET-REQ */ 648 | cmd[6] = 0x00; /* - msB */ 649 | cmd[9] = csr_seq & 0xFF; /* seq num */ 650 | cmd[10] = (csr_seq >> 8) & 0xFF;/* - msB */ 651 | csr_seq++; 652 | 653 | divisor = (u->speed*64+7812)/15625; 654 | 655 | /* No parity, one stop bit -> divisor |= 0x0000; */ 656 | cmd[15] = (divisor) & 0xFF; /* divider */ 657 | cmd[16] = (divisor >> 8) & 0xFF; /* - msB */ 658 | /* The rest of the payload will be 0x00 */ 659 | 660 | #ifdef CSR_DEBUG 661 | { 662 | char temp[512]; 663 | int i; 664 | for(i = 0; i < clen; i++) 665 | sprintf(temp + (i*3), "-%02X", cmd[i]); 666 | fprintf(stderr, "Writing CSR UART speed %d [%s]\n", clen, temp + 1); 667 | // In theory, it should look like : 668 | // 01-00-FC-13-C2-02-00-09-00-03-00-02-68-00-00-BF-0E-00-00-00-00-00-00 669 | // 01-00-FC-13-C2-02-00-09-00-01-00-02-68-00-00-D8-01-00-00-00-00-00-00 670 | } 671 | #endif 672 | 673 | /* Send the command to set the CSR UART speed */ 674 | if (write(fd, cmd, clen) != clen) { 675 | perror("Failed to write init command (SET_UART_SPEED)"); 676 | return -1; 677 | } 678 | 679 | nanosleep(&tm, NULL); 680 | return 0; 681 | } 682 | 683 | /* 684 | * Silicon Wave specific initialization 685 | * Thomas Moser 686 | */ 687 | static int swave(int fd, struct uart_t *u, struct termios *ti) 688 | { 689 | struct timespec tm = { 0, 500000 }; 690 | char cmd[10], rsp[100]; 691 | int r; 692 | 693 | // Silicon Wave set baud rate command 694 | // see HCI Vendor Specific Interface from Silicon Wave 695 | // first send a "param access set" command to set the 696 | // appropriate data fields in RAM. Then send a "HCI Reset 697 | // Subcommand", e.g. "soft reset" to make the changes effective. 698 | 699 | cmd[0] = HCI_COMMAND_PKT; // it's a command packet 700 | cmd[1] = 0x0B; // OCF 0x0B = param access set 701 | cmd[2] = 0xfc; // OGF bx111111 = vendor specific 702 | cmd[3] = 0x06; // 6 bytes of data following 703 | cmd[4] = 0x01; // param sub command 704 | cmd[5] = 0x11; // tag 17 = 0x11 = HCI Transport Params 705 | cmd[6] = 0x03; // length of the parameter following 706 | cmd[7] = 0x01; // HCI Transport flow control enable 707 | cmd[8] = 0x01; // HCI Transport Type = UART 708 | 709 | switch (u->speed) { 710 | case 19200: 711 | cmd[9] = 0x03; 712 | break; 713 | case 38400: 714 | cmd[9] = 0x02; 715 | break; 716 | case 57600: 717 | cmd[9] = 0x01; 718 | break; 719 | case 115200: 720 | cmd[9] = 0x00; 721 | break; 722 | default: 723 | u->speed = 115200; 724 | cmd[9] = 0x00; 725 | break; 726 | } 727 | 728 | /* Send initialization command */ 729 | if (write(fd, cmd, 10) != 10) { 730 | perror("Failed to write init command"); 731 | return -1; 732 | } 733 | 734 | // We should wait for a "GET Event" to confirm the success of 735 | // the baud rate setting. Wait some time before reading. Better: 736 | // read with timeout, parse data 737 | // until correct answer, else error handling ... todo ... 738 | 739 | nanosleep(&tm, NULL); 740 | 741 | r = read(fd, rsp, sizeof(rsp)); 742 | if (r > 0) { 743 | // guess it's okay, but we should parse the reply. But since 744 | // I don't react on an error anyway ... todo 745 | // Response packet format: 746 | // 04 Event 747 | // FF Vendor specific 748 | // 07 Parameter length 749 | // 0B Subcommand 750 | // 01 Setevent 751 | // 11 Tag specifying HCI Transport Layer Parameter 752 | // 03 length 753 | // 01 flow on 754 | // 01 Hci Transport type = Uart 755 | // xx Baud rate set (see above) 756 | } else { 757 | // ups, got error. 758 | return -1; 759 | } 760 | 761 | // we probably got the reply. Now we must send the "soft reset" 762 | // which is standard HCI RESET. 763 | 764 | cmd[0] = HCI_COMMAND_PKT; // it's a command packet 765 | cmd[1] = 0x03; 766 | cmd[2] = 0x0c; 767 | cmd[3] = 0x00; 768 | 769 | /* Send reset command */ 770 | if (write(fd, cmd, 4) != 4) { 771 | perror("Can't write Silicon Wave reset cmd."); 772 | return -1; 773 | } 774 | 775 | nanosleep(&tm, NULL); 776 | 777 | // now the uart baud rate on the silicon wave module is set and effective. 778 | // change our own baud rate as well. Then there is a reset event comming in 779 | // on the *new* baud rate. This is *undocumented*! The packet looks like this: 780 | // 04 FF 01 0B (which would make that a confirmation of 0x0B = "Param 781 | // subcommand class". So: change to new baud rate, read with timeout, parse 782 | // data, error handling. BTW: all param access in Silicon Wave is done this way. 783 | // Maybe this code would belong in a seperate file, or at least code reuse... 784 | 785 | return 0; 786 | } 787 | 788 | /* 789 | * ST Microelectronics specific initialization 790 | * Marcel Holtmann 791 | */ 792 | static int st(int fd, struct uart_t *u, struct termios *ti) 793 | { 794 | struct timespec tm = {0, 50000}; 795 | char cmd[5]; 796 | 797 | /* ST Microelectronics set baud rate command */ 798 | cmd[0] = HCI_COMMAND_PKT; 799 | cmd[1] = 0x46; // OCF = Hci_Cmd_ST_Set_Uart_Baud_Rate 800 | cmd[2] = 0xfc; // OGF = Vendor specific 801 | cmd[3] = 0x01; 802 | 803 | switch (u->speed) { 804 | case 9600: 805 | cmd[4] = 0x09; 806 | break; 807 | case 19200: 808 | cmd[4] = 0x0b; 809 | break; 810 | case 38400: 811 | cmd[4] = 0x0d; 812 | break; 813 | case 57600: 814 | cmd[4] = 0x0e; 815 | break; 816 | case 115200: 817 | cmd[4] = 0x10; 818 | break; 819 | case 230400: 820 | cmd[4] = 0x12; 821 | break; 822 | case 460800: 823 | cmd[4] = 0x13; 824 | break; 825 | case 921600: 826 | cmd[4] = 0x14; 827 | break; 828 | default: 829 | cmd[4] = 0x10; 830 | u->speed = 115200; 831 | break; 832 | } 833 | 834 | /* Send initialization command */ 835 | if (write(fd, cmd, 5) != 5) { 836 | perror("Failed to write init command"); 837 | return -1; 838 | } 839 | 840 | nanosleep(&tm, NULL); 841 | return 0; 842 | } 843 | 844 | static int stlc2500(int fd, struct uart_t *u, struct termios *ti) 845 | { 846 | bdaddr_t bdaddr; 847 | unsigned char resp[10]; 848 | int n; 849 | int rvalue; 850 | 851 | /* STLC2500 has an ericsson core */ 852 | rvalue = ericsson(fd, u, ti); 853 | if (rvalue != 0) 854 | return rvalue; 855 | 856 | #ifdef STLC2500_DEBUG 857 | fprintf(stderr, "Setting speed\n"); 858 | #endif 859 | if (set_speed(fd, ti, u->speed) < 0) { 860 | perror("Can't set baud rate"); 861 | return -1; 862 | } 863 | 864 | #ifdef STLC2500_DEBUG 865 | fprintf(stderr, "Speed set...\n"); 866 | #endif 867 | 868 | /* Read reply */ 869 | if ((n = read_hci_event(fd, resp, 10)) < 0) { 870 | fprintf(stderr, "Failed to set baud rate on chip\n"); 871 | return -1; 872 | } 873 | 874 | #ifdef STLC2500_DEBUG 875 | for (i = 0; i < n; i++) { 876 | fprintf(stderr, "resp[%d] = %02x\n", i, resp[i]); 877 | } 878 | #endif 879 | 880 | str2ba(u->bdaddr, &bdaddr); 881 | return stlc2500_init(fd, &bdaddr); 882 | } 883 | 884 | static int bgb2xx(int fd, struct uart_t *u, struct termios *ti) 885 | { 886 | bdaddr_t bdaddr; 887 | 888 | str2ba(u->bdaddr, &bdaddr); 889 | 890 | return bgb2xx_init(fd, &bdaddr); 891 | } 892 | 893 | /* 894 | * Broadcom specific initialization 895 | * Extracted from Jungo openrg 896 | */ 897 | static int bcm2035(int fd, struct uart_t *u, struct termios *ti) 898 | { 899 | int n; 900 | unsigned char cmd[30], resp[30]; 901 | 902 | /* Reset the BT Chip */ 903 | memset(cmd, 0, sizeof(cmd)); 904 | memset(resp, 0, sizeof(resp)); 905 | cmd[0] = HCI_COMMAND_PKT; 906 | cmd[1] = 0x03; 907 | cmd[2] = 0x0c; 908 | cmd[3] = 0x00; 909 | 910 | /* Send command */ 911 | if (write(fd, cmd, 4) != 4) { 912 | fprintf(stderr, "Failed to write reset command\n"); 913 | return -1; 914 | } 915 | 916 | /* Read reply */ 917 | if ((n = read_hci_event(fd, resp, 4)) < 0) { 918 | fprintf(stderr, "Failed to reset chip\n"); 919 | return -1; 920 | } 921 | 922 | if (u->bdaddr != NULL) { 923 | /* Set BD_ADDR */ 924 | memset(cmd, 0, sizeof(cmd)); 925 | memset(resp, 0, sizeof(resp)); 926 | cmd[0] = HCI_COMMAND_PKT; 927 | cmd[1] = 0x01; 928 | cmd[2] = 0xfc; 929 | cmd[3] = 0x06; 930 | str2ba(u->bdaddr, (bdaddr_t *) (cmd + 4)); 931 | 932 | /* Send command */ 933 | if (write(fd, cmd, 10) != 10) { 934 | fprintf(stderr, "Failed to write BD_ADDR command\n"); 935 | return -1; 936 | } 937 | 938 | /* Read reply */ 939 | if ((n = read_hci_event(fd, resp, 10)) < 0) { 940 | fprintf(stderr, "Failed to set BD_ADDR\n"); 941 | return -1; 942 | } 943 | } 944 | 945 | /* Read the local version info */ 946 | memset(cmd, 0, sizeof(cmd)); 947 | memset(resp, 0, sizeof(resp)); 948 | cmd[0] = HCI_COMMAND_PKT; 949 | cmd[1] = 0x01; 950 | cmd[2] = 0x10; 951 | cmd[3] = 0x00; 952 | 953 | /* Send command */ 954 | if (write(fd, cmd, 4) != 4) { 955 | fprintf(stderr, "Failed to write \"read local version\" " 956 | "command\n"); 957 | return -1; 958 | } 959 | 960 | /* Read reply */ 961 | if ((n = read_hci_event(fd, resp, 4)) < 0) { 962 | fprintf(stderr, "Failed to read local version\n"); 963 | return -1; 964 | } 965 | 966 | /* Read the local supported commands info */ 967 | memset(cmd, 0, sizeof(cmd)); 968 | memset(resp, 0, sizeof(resp)); 969 | cmd[0] = HCI_COMMAND_PKT; 970 | cmd[1] = 0x02; 971 | cmd[2] = 0x10; 972 | cmd[3] = 0x00; 973 | 974 | /* Send command */ 975 | if (write(fd, cmd, 4) != 4) { 976 | fprintf(stderr, "Failed to write \"read local supported " 977 | "commands\" command\n"); 978 | return -1; 979 | } 980 | 981 | /* Read reply */ 982 | if ((n = read_hci_event(fd, resp, 4)) < 0) { 983 | fprintf(stderr, "Failed to read local supported commands\n"); 984 | return -1; 985 | } 986 | 987 | /* Set the baud rate */ 988 | memset(cmd, 0, sizeof(cmd)); 989 | memset(resp, 0, sizeof(resp)); 990 | cmd[0] = HCI_COMMAND_PKT; 991 | cmd[1] = 0x18; 992 | cmd[2] = 0xfc; 993 | cmd[3] = 0x02; 994 | switch (u->speed) { 995 | case 57600: 996 | cmd[4] = 0x00; 997 | cmd[5] = 0xe6; 998 | break; 999 | case 230400: 1000 | cmd[4] = 0x22; 1001 | cmd[5] = 0xfa; 1002 | break; 1003 | case 460800: 1004 | cmd[4] = 0x22; 1005 | cmd[5] = 0xfd; 1006 | break; 1007 | case 921600: 1008 | cmd[4] = 0x55; 1009 | cmd[5] = 0xff; 1010 | break; 1011 | default: 1012 | /* Default is 115200 */ 1013 | cmd[4] = 0x00; 1014 | cmd[5] = 0xf3; 1015 | break; 1016 | } 1017 | fprintf(stderr, "Baud rate parameters: DHBR=0x%2x,DLBR=0x%2x\n", 1018 | cmd[4], cmd[5]); 1019 | 1020 | /* Send command */ 1021 | if (write(fd, cmd, 6) != 6) { 1022 | fprintf(stderr, "Failed to write \"set baud rate\" command\n"); 1023 | return -1; 1024 | } 1025 | 1026 | if ((n = read_hci_event(fd, resp, 6)) < 0) { 1027 | fprintf(stderr, "Failed to set baud rate\n"); 1028 | return -1; 1029 | } 1030 | 1031 | return 0; 1032 | } 1033 | #endif 1034 | 1035 | static int realtek_init(int fd, struct uart_t *u, struct termios *ti) 1036 | { 1037 | 1038 | fprintf(stderr, "Realtek Bluetooth init uart with init speed:%d, final_speed:%d, type:HCI UART %s\n", u->init_speed, u->speed, (u->proto == HCI_UART_H4)? "H4":"H5" ); 1039 | return rtk_init(fd, u->proto, u->speed, ti); 1040 | } 1041 | 1042 | static int realtek_post(int fd, struct uart_t *u, struct termios *ti) 1043 | { 1044 | fprintf(stderr, "Realtek Bluetooth post process\n"); 1045 | return rtk_post(fd, u->proto, ti); 1046 | } 1047 | 1048 | struct uart_t uart[] = { 1049 | { "any", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200, FLOW_CTL, DISABLE_PM, NULL, NULL }, 1050 | { "bcsp", 0x0000, 0x0000, HCI_UART_BCSP, 115200, 115200, 0, DISABLE_PM, NULL, bcsp }, 1051 | 1052 | #if 0 1053 | { "ericsson", 0x0000, 0x0000, HCI_UART_H4, 57600, 115200, FLOW_CTL, NULL, ericsson }, 1054 | { "digi", 0x0000, 0x0000, HCI_UART_H4, 9600, 115200, FLOW_CTL, NULL, digi }, 1055 | 1056 | 1057 | /* Xircom PCMCIA cards: Credit Card Adapter and Real Port Adapter */ 1058 | { "xircom", 0x0105, 0x080a, HCI_UART_H4, 115200, 115200, FLOW_CTL, NULL, NULL }, 1059 | 1060 | /* CSR Casira serial adapter or BrainBoxes serial dongle (BL642) */ 1061 | { "csr", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200, FLOW_CTL, NULL, csr }, 1062 | 1063 | /* BrainBoxes PCMCIA card (BL620) */ 1064 | { "bboxes", 0x0160, 0x0002, HCI_UART_H4, 115200, 460800, FLOW_CTL, NULL, csr }, 1065 | 1066 | /* Silicon Wave kits */ 1067 | { "swave", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200, FLOW_CTL, NULL, swave }, 1068 | 1069 | /* Texas Instruments Bluelink (BRF) modules */ 1070 | { "texas", 0x0000, 0x0000, HCI_UART_LL, 115200, 115200, FLOW_CTL, NULL, texas, texas2 }, 1071 | { "texasalt", 0x0000, 0x0000, HCI_UART_LL, 115200, 115200, FLOW_CTL, NULL, texasalt, NULL }, 1072 | 1073 | /* ST Microelectronics minikits based on STLC2410/STLC2415 */ 1074 | { "st", 0x0000, 0x0000, HCI_UART_H4, 57600, 115200, FLOW_CTL, NULL, st }, 1075 | 1076 | /* ST Microelectronics minikits based on STLC2500 */ 1077 | { "stlc2500", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200, FLOW_CTL, "00:80:E1:00:AB:BA", stlc2500 }, 1078 | 1079 | /* Philips generic Ericsson IP core based */ 1080 | { "philips", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200, FLOW_CTL, NULL, NULL }, 1081 | 1082 | /* Philips BGB2xx Module */ 1083 | { "bgb2xx", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200, FLOW_CTL, "BD:B2:10:00:AB:BA", bgb2xx }, 1084 | 1085 | /* Sphinx Electronics PICO Card */ 1086 | { "picocard", 0x025e, 0x1000, HCI_UART_H4, 115200, 115200, FLOW_CTL, NULL, NULL }, 1087 | 1088 | /* Inventel BlueBird Module */ 1089 | { "inventel", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200, FLOW_CTL, NULL, NULL }, 1090 | 1091 | /* COM One Platinium Bluetooth PC Card */ 1092 | { "comone", 0xffff, 0x0101, HCI_UART_BCSP, 115200, 115200, 0, NULL, bcsp }, 1093 | 1094 | /* TDK Bluetooth PC Card and IBM Bluetooth PC Card II */ 1095 | { "tdk", 0x0105, 0x4254, HCI_UART_BCSP, 115200, 115200, 0, NULL, bcsp }, 1096 | 1097 | /* Socket Bluetooth CF Card (Rev G) */ 1098 | { "socket", 0x0104, 0x0096, HCI_UART_BCSP, 230400, 230400, 0, NULL, bcsp }, 1099 | 1100 | /* 3Com Bluetooth Card (Version 3.0) */ 1101 | { "3com", 0x0101, 0x0041, HCI_UART_H4, 115200, 115200, FLOW_CTL, NULL, csr }, 1102 | 1103 | /* AmbiCom BT2000C Bluetooth PC/CF Card */ 1104 | { "bt2000c", 0x022d, 0x2000, HCI_UART_H4, 57600, 460800, FLOW_CTL, NULL, csr }, 1105 | 1106 | /* Zoom Bluetooth PCMCIA Card */ 1107 | { "zoom", 0x0279, 0x950b, HCI_UART_BCSP, 115200, 115200, 0, NULL, bcsp }, 1108 | 1109 | /* Sitecom CN-504 PCMCIA Card */ 1110 | { "sitecom", 0x0279, 0x950b, HCI_UART_BCSP, 115200, 115200, 0, NULL, bcsp }, 1111 | 1112 | /* Billionton PCBTC1 PCMCIA Card */ 1113 | { "billionton", 0x0279, 0x950b, HCI_UART_BCSP, 115200, 115200, 0, NULL, bcsp }, 1114 | 1115 | /* Broadcom BCM2035 */ 1116 | { "bcm2035", 0x0A5C, 0x2035, HCI_UART_H4, 115200, 460800, FLOW_CTL, NULL, bcm2035 }, 1117 | 1118 | #endif 1119 | 1120 | /* Realtek Bluetooth H4*/ 1121 | /* H4 will set 115200 baudrate and flow control enable by default*/ 1122 | { "rtk_h4", 0x0000, 0x0000, HCI_UART_H4, 115200, 115200, 0, DISABLE_PM, NULL, realtek_init, realtek_post}, 1123 | 1124 | /* Realtek Bluetooth H5*/ 1125 | /* H5 will set 115200 baudrate and flow control disable by default */ 1126 | { "rtk_h5", 0x0000, 0x0000, HCI_UART_3WIRE, 115200,115200, 0, DISABLE_PM, NULL, realtek_init, realtek_post}, 1127 | 1128 | { NULL, 0 } 1129 | }; 1130 | 1131 | static struct uart_t * get_by_id(int m_id, int p_id) 1132 | { 1133 | int i; 1134 | for (i = 0; uart[i].type; i++) { 1135 | if (uart[i].m_id == m_id && uart[i].p_id == p_id) 1136 | return &uart[i]; 1137 | } 1138 | return NULL; 1139 | } 1140 | 1141 | static struct uart_t * get_by_type(char *type) 1142 | { 1143 | int i; 1144 | for (i = 0; uart[i].type; i++) { 1145 | if (!strcmp(uart[i].type, type)) 1146 | return &uart[i]; 1147 | } 1148 | return NULL; 1149 | } 1150 | 1151 | /* Initialize UART driver */ 1152 | static int init_uart(char *dev, struct uart_t *u, int send_break, int raw) 1153 | { 1154 | struct termios ti; 1155 | int fd, i; 1156 | unsigned long flags = 0; 1157 | 1158 | if (raw) 1159 | flags |= 1 << HCI_UART_RAW_DEVICE; 1160 | 1161 | fd = open(dev, O_RDWR | O_NOCTTY); 1162 | if (fd < 0) { 1163 | perror("Can't open serial port"); 1164 | return -1; 1165 | } 1166 | 1167 | tcflush(fd, TCIOFLUSH); 1168 | 1169 | if (tcgetattr(fd, &ti) < 0) { 1170 | perror("Can't get port settings"); 1171 | return -1; 1172 | } 1173 | 1174 | cfmakeraw(&ti); 1175 | 1176 | ti.c_cflag |= CLOCAL; 1177 | if (u->flags & FLOW_CTL) 1178 | ti.c_cflag |= CRTSCTS; 1179 | else 1180 | ti.c_cflag &= ~CRTSCTS; 1181 | 1182 | if (tcsetattr(fd, TCSANOW, &ti) < 0) { 1183 | perror("Can't set port settings"); 1184 | return -1; 1185 | } 1186 | 1187 | /* Set initial baudrate */ 1188 | if (set_speed(fd, &ti, u->init_speed) < 0) { 1189 | perror("Can't set initial baud rate"); 1190 | return -1; 1191 | } 1192 | 1193 | tcflush(fd, TCIOFLUSH); 1194 | 1195 | if (send_break) { 1196 | tcsendbreak(fd, 0); 1197 | usleep(500000); 1198 | } 1199 | 1200 | if (u->init && u->init(fd, u, &ti) < 0) 1201 | return -1; 1202 | 1203 | tcflush(fd, TCIOFLUSH); 1204 | 1205 | /* Set actual baudrate */ 1206 | if (set_speed(fd, &ti, u->speed) < 0) { 1207 | perror("Can't set baud rate"); 1208 | return -1; 1209 | } 1210 | 1211 | /* Set TTY to N_HCI line discipline */ 1212 | i = N_HCI; 1213 | if (ioctl(fd, TIOCSETD, &i) < 0) { 1214 | perror("Can't set line discipline"); 1215 | return -1; 1216 | } 1217 | 1218 | if (flags && ioctl(fd, HCIUARTSETFLAGS, flags) < 0) { 1219 | perror("Can't set UART flags"); 1220 | return -1; 1221 | } 1222 | 1223 | if (ioctl(fd, HCIUARTSETPROTO, u->proto) < 0) { 1224 | perror("Can't set device"); 1225 | return -1; 1226 | } 1227 | 1228 | if (u->post && u->post(fd, u, &ti) < 0) 1229 | return -1; 1230 | 1231 | return fd; 1232 | } 1233 | 1234 | static void usage(void) 1235 | { 1236 | printf("hciattach - HCI UART driver initialization utility\n"); 1237 | printf("Usage:\n"); 1238 | printf("\thciattach [-n] [-p] [-b] [-r] [-t timeout] [-s initial_speed] [speed] [flow|noflow] [bdaddr]\n"); 1239 | printf("\thciattach -l\n"); 1240 | } 1241 | 1242 | int main(int argc, char *argv[]) 1243 | { 1244 | struct uart_t *u = NULL; 1245 | int detach, printpid, raw, opt, i, n, ld, err; 1246 | int to = 10; 1247 | int init_speed = 0; 1248 | int send_break = 0; 1249 | pid_t pid; 1250 | struct sigaction sa; 1251 | struct pollfd p; 1252 | sigset_t sigs; 1253 | char dev[PATH_MAX]; 1254 | 1255 | detach = 1; 1256 | printpid = 0; 1257 | raw = 0; 1258 | 1259 | while ((opt=getopt(argc, argv, "bnpt:s:lr")) != EOF) { 1260 | switch(opt) { 1261 | case 'b': 1262 | send_break = 1; 1263 | break; 1264 | 1265 | case 'n': 1266 | detach = 0; 1267 | break; 1268 | 1269 | case 'p': 1270 | printpid = 1; 1271 | break; 1272 | 1273 | case 't': 1274 | to = atoi(optarg); 1275 | break; 1276 | 1277 | case 's': 1278 | init_speed = atoi(optarg); 1279 | break; 1280 | 1281 | case 'l': 1282 | for (i = 0; uart[i].type; i++) { 1283 | printf("%-10s0x%04x,0x%04x\n", uart[i].type, 1284 | uart[i].m_id, uart[i].p_id); 1285 | } 1286 | exit(0); 1287 | 1288 | case 'r': 1289 | raw = 1; 1290 | break; 1291 | 1292 | default: 1293 | usage(); 1294 | exit(1); 1295 | } 1296 | } 1297 | 1298 | n = argc - optind; 1299 | if (n < 2) { 1300 | usage(); 1301 | exit(1); 1302 | } 1303 | 1304 | for (n = 0; optind < argc; n++, optind++) { 1305 | char *opt; 1306 | 1307 | opt = argv[optind]; 1308 | 1309 | switch(n) { 1310 | case 0: 1311 | dev[0] = 0; 1312 | if (!strchr(opt, '/')) 1313 | strcpy(dev, "/dev/"); 1314 | strcat(dev, opt); 1315 | break; 1316 | 1317 | case 1: 1318 | if (strchr(argv[optind], ',')) { 1319 | int m_id, p_id; 1320 | sscanf(argv[optind], "%x,%x", &m_id, &p_id); 1321 | u = get_by_id(m_id, p_id); 1322 | } else { 1323 | u = get_by_type(opt); 1324 | } 1325 | 1326 | if (!u) { 1327 | fprintf(stderr, "Unknown device type or id\n"); 1328 | exit(1); 1329 | } 1330 | 1331 | break; 1332 | 1333 | case 2: 1334 | u->speed = atoi(argv[optind]); 1335 | break; 1336 | 1337 | case 3: 1338 | if (!strcmp("flow", argv[optind])) 1339 | u->flags |= FLOW_CTL; 1340 | else 1341 | u->flags &= ~FLOW_CTL; 1342 | break; 1343 | 1344 | case 4: 1345 | if (!strcmp("sleep", argv[optind])) 1346 | u->pm = ENABLE_PM; 1347 | else 1348 | u->pm = DISABLE_PM; 1349 | break; 1350 | 1351 | case 5: 1352 | u->bdaddr = argv[optind]; 1353 | break; 1354 | } 1355 | } 1356 | 1357 | if (!u) { 1358 | fprintf(stderr, "Unknown device type or id\n"); 1359 | exit(1); 1360 | } 1361 | 1362 | /* If user specified a initial speed, use that instead of 1363 | the hardware's default */ 1364 | if (init_speed) 1365 | u->init_speed = init_speed; 1366 | 1367 | memset(&sa, 0, sizeof(sa)); 1368 | sa.sa_flags = SA_NOCLDSTOP; 1369 | sa.sa_handler = sig_alarm; 1370 | sigaction(SIGALRM, &sa, NULL); 1371 | 1372 | /* 10 seconds should be enough for initialization */ 1373 | alarm(to); 1374 | bcsp_max_retries = to; 1375 | 1376 | n = init_uart(dev, u, send_break, raw); 1377 | if (n < 0) { 1378 | perror("Can't initialize device"); 1379 | exit(1); 1380 | } 1381 | 1382 | printf("Device setup complete\n"); 1383 | 1384 | alarm(0); 1385 | 1386 | memset(&sa, 0, sizeof(sa)); 1387 | sa.sa_flags = SA_NOCLDSTOP; 1388 | sa.sa_handler = SIG_IGN; 1389 | sigaction(SIGCHLD, &sa, NULL); 1390 | sigaction(SIGPIPE, &sa, NULL); 1391 | 1392 | sa.sa_handler = sig_term; 1393 | sigaction(SIGTERM, &sa, NULL); 1394 | sigaction(SIGINT, &sa, NULL); 1395 | 1396 | sa.sa_handler = sig_hup; 1397 | sigaction(SIGHUP, &sa, NULL); 1398 | 1399 | if (detach) { 1400 | if ((pid = fork())) { 1401 | if (printpid) 1402 | printf("%d\n", pid); 1403 | return 0; 1404 | } 1405 | 1406 | for (i = 0; i < 20; i++) 1407 | if (i != n) 1408 | close(i); 1409 | } 1410 | 1411 | p.fd = n; 1412 | p.events = POLLERR | POLLHUP; 1413 | 1414 | sigfillset(&sigs); 1415 | sigdelset(&sigs, SIGCHLD); 1416 | sigdelset(&sigs, SIGPIPE); 1417 | sigdelset(&sigs, SIGTERM); 1418 | sigdelset(&sigs, SIGINT); 1419 | sigdelset(&sigs, SIGHUP); 1420 | 1421 | while (!__io_canceled) { 1422 | p.revents = 0; 1423 | err = ppoll(&p, 1, NULL, &sigs); 1424 | if (err < 0 && errno == EINTR) { 1425 | printf("Got EINTR.\n"); 1426 | continue; 1427 | } if (err) 1428 | break; 1429 | } 1430 | 1431 | /* Restore TTY line discipline */ 1432 | printf("Restore TTY line discipline\n"); 1433 | ld = N_TTY; 1434 | if (ioctl(n, TIOCSETD, &ld) < 0) { 1435 | perror("Can't restore line discipline"); 1436 | exit(1); 1437 | } 1438 | 1439 | return 0; 1440 | } 1441 | --------------------------------------------------------------------------------