├── README.md ├── buildroot ├── Config.in ├── README.md ├── board │ ├── vocore2 │ │ ├── busybox │ │ │ └── busybox-extra.config │ │ ├── genimage.cfg │ │ ├── linux │ │ │ ├── linux.config │ │ │ └── patches │ │ │ │ └── device-tree.patch │ │ ├── post-build.sh │ │ └── post-image.sh │ └── vocore2_flasher │ │ ├── busybox │ │ └── busybox-extra.config │ │ └── linux │ │ ├── linux.config │ │ └── patches │ │ └── device-tree.patch ├── configs │ ├── vocore2_defconfig │ └── vocore2_flasher_defconfig ├── external.desc ├── external.mk └── package │ └── mt76-firmware │ ├── Config.in │ ├── mt76-firmware.hash │ └── mt76-firmware.mk ├── docker ├── Dockerfile └── apt-sources.list ├── openwrt.1806 ├── .config ├── 0043-spi-add-mt7621-support.patch ├── 0045-i2c-add-mt7621-driver.patch ├── 811-spi-gpio-chip-select.patch ├── 812-support-gd25q256.patch ├── 815-sdcard-pinmux-i2si2c.patch ├── README.md ├── add-kmod-regmap-i2c.patch ├── config-4.14 ├── es8388 │ ├── 000-openwrt-compatible-sound.patch │ └── 810-es8388-support.patch ├── fbusb-dep.mk ├── mt7628 │ ├── Makefile │ ├── config.in │ ├── files │ │ ├── ant1 │ │ ├── ant2 │ │ ├── mt7628.dat │ │ ├── ralink.sh │ │ ├── w2factory.ko │ │ └── wireless │ ├── openwrt │ │ ├── 000-vocore2-compatible.patch │ │ ├── 080-iwinfo-compatible-ralink.patch │ │ └── luci │ │ │ └── 010-luci-vocore2-compatible.patch │ └── patches │ │ └── 001-fix-kernel-compatible.patch ├── v2u_apply.sh ├── v2u_defconfig └── vocore2-5ports-setup.patch ├── openwrt.1907 ├── .config ├── 0045-i2c-add-mt7621-driver.patch ├── 0306-spi-flash-factory-id.patch ├── 0810-sound-es8388-aplay.patch ├── 0822-mt76-read-factory-eeprom.patch ├── 0882-pinctrl-fix-gpio-name.patch ├── config-4.14 ├── v2u_apply.sh ├── v2u_defconfig ├── vocore2-5ports-setup.patch ├── vocore2-default-banner.patch ├── vocore2-default-enable-fbcon.patch ├── vocore2-default-enable-sdcard.patch ├── vocore2-default-enable-wireless.patch ├── vocore2-default-lan-address.patch ├── vocore2-default-password.patch ├── vocore2-fixmaster-es8388.patch └── vocore2-fixmaster-sdcard.patch ├── openwrt.2102 ├── 0810-sound-es8388-aplay.patch ├── v2u_apply.sh ├── v2u_defconfig ├── vocore2-default-enable-wireless.patch ├── vocore2-fixmaster-es8388.patch └── vocore2-sdcard-support.patch ├── openwrt.2305 ├── clk │ ├── openwrt │ │ ├── 0001-Delete-reset-controller-driver.patch │ │ └── 0002-mt7628-dts-config-apply-clk-changes.patch │ └── patch-5.15 │ │ ├── 905-dt-bindings-clock-add-mtmips-SoCs-system-controller.patch │ │ ├── 906-clk-ralink-add-clock-and-reset-driver-for-MTMIPS-SoC.patch │ │ ├── 907-mips-ralink-rt288x-remove-clock-related-code.patch │ │ ├── 908-mips-ralink-rt305x-remove-clock-related-code.patch │ │ ├── 909-mips-ralink-rt3883-remove-clock-related-code.patch │ │ ├── 910-mips-ralink-mt7620-remove-clock-related-code.patch │ │ ├── 911-MIPS-ralink-mt7621-avoid-to-init-common-ralink-reset.patch │ │ ├── 912-mips-ralink-remove-reset-related-code.patch │ │ ├── 913-mips-ralink-get-cpu-rate-from-new-driver-code.patch │ │ ├── 914-mt7628-clk-improve.patch │ │ └── 915-mt7628-i2s-improve-set-refclk.patch ├── menu.config ├── sound │ ├── openwrt │ │ ├── vocore2-fixmaster-es8388.patch │ │ └── vocore2-support-es8388.patch │ └── patch-5.15 │ │ ├── 0000-pinmux-gpio0-refclk.patch │ │ ├── 0810-sound-es8388-aplay.patch │ │ ├── 900-ASoC-soc-pcm-add-option-to-start-DMA-after-DAI.patch │ │ ├── 901-ASoC-add-new-trigger-ordering-method.patch │ │ ├── 902-ASoC-remove-old-trigger-ordering-method.patch │ │ └── 903-ASOC-mt7620-specify-trigger-stop.patch ├── video │ ├── openwrt │ │ └── vocore2-enable-video.patch │ ├── package │ │ └── mpro │ │ │ ├── Makefile │ │ │ └── src │ │ │ ├── Makefile │ │ │ └── mpro.c │ └── patch-5.15 │ │ └── 904-openwrt-drm-hack.patch ├── vocore2-default-banner.patch ├── vocore2-default-password.patch ├── vocore2-default-wireless.patch └── vocore2-devicetree-sdcard.patch ├── openwrt.2410 ├── config.default ├── vocore2-default-banner.patch ├── vocore2-default-password.patch ├── vocore2-default-wireless.patch └── vocore2-devicetree-sdcard.patch ├── tools ├── README.md └── makeself ├── uboot └── vocore2_defconfig └── utils ├── ated ├── Makefile └── src │ ├── Makefile │ ├── ate-ext.c │ ├── ate.c │ ├── cmd_io │ └── eth.c │ ├── include │ ├── ate.h │ ├── cmd_io │ │ └── eth.h │ ├── os_ioctl │ │ └── ioctl2driver.h │ ├── precomp.h │ └── thread_model │ │ ├── ipc_socket.h │ │ ├── multi_fork.h │ │ └── multi_thread.h │ ├── os_ioctl │ └── ioctl2driver.c │ └── thread_model │ ├── ipc_socket.c │ ├── multi_fork.c │ └── multi_thread.c ├── dosbox ├── Makefile └── patches │ └── 000-keyboard-scancodes.patch ├── fb-test-app └── Makefile ├── fbusb ├── Makefile └── src │ ├── Kconfig │ ├── Makefile │ ├── README.md │ ├── doc │ └── install_on_raspbian.md │ └── fbusb.c ├── ffmpeg ├── Config.in └── Makefile ├── hidapi ├── Makefile └── patches │ └── 010-add-iconv-linkage.patch ├── i2c-tools ├── Makefile └── i2c-tools-3.1.2.tar.xz ├── libftdi1 ├── Makefile └── patches │ ├── 100-fix-x86_64-build.patch │ └── 101-use-findSWIG.patch ├── libsdl ├── Makefile └── patches │ ├── 000-support-hid-mouse.patch │ └── 001-automake-compat.patch ├── libserialport └── Makefile ├── luci-app-zerotier ├── .gitattributes ├── .gitignore ├── Makefile ├── README.md ├── luasrc │ ├── controller │ │ └── zerotier.lua │ ├── model │ │ └── cbi │ │ │ └── zerotier │ │ │ ├── info.lua │ │ │ └── settings.lua │ └── view │ │ └── zerotier │ │ └── zerotier_status.htm ├── po │ └── zh-cn │ │ └── zerotier.po └── root │ └── etc │ ├── init.d │ └── zerotier │ ├── uci-defaults │ └── 40_luci-zerotier │ └── zerotier │ └── zerotier.log ├── lvgl-fb-demo ├── Makefile └── patches │ ├── change-fb-size.patch │ ├── color-depth-16.patch │ ├── disable-FBIOBLANK.patch │ └── fix-touchscreen.patch ├── mem ├── Makefile └── src │ ├── Makefile │ └── mem.c ├── memtester └── Makefile ├── mt7628tool ├── Makefile └── src │ ├── README.md │ ├── makefile │ └── mt7628tool.c ├── openocd ├── Makefile └── patches │ ├── 100-bind-localhost-only.patch │ └── 101-cve-2018-5704-css-fix.patch ├── paho.mqtt.c ├── Makefile └── patches │ └── 001-fix-cross-compile-macos.patch └── shellinabox ├── LICENSE ├── Makefile ├── README.md ├── files └── shellinaboxd.init └── patches └── 001-fix-compile-issue.patch /buildroot/Config.in: -------------------------------------------------------------------------------- 1 | source "$BR2_EXTERNAL_VOCORE2_PATH/package/mt76-firmware/Config.in" 2 | -------------------------------------------------------------------------------- /buildroot/README.md: -------------------------------------------------------------------------------- 1 | buildroot is use for test mainline linux kernel, don't use it in production. 2 | 3 | # flash layout 4 | 5 | please see board/vocore2/genimage.cfg 6 | 7 | # vocore2 flasher 8 | 9 | enable bitbang spi driver, using another VoCore2 to recover your bricked VoCore2. 10 | 11 | note: after flash, you must need checksum!!! 12 | -------------------------------------------------------------------------------- /buildroot/board/vocore2/busybox/busybox-extra.config: -------------------------------------------------------------------------------- 1 | # spi nor flash 2 | CONFIG_FLASH_ERASEALL=y 3 | CONFIG_FLASH_LOCK=y 4 | CONFIG_FLASH_UNLOCK=y 5 | CONFIG_FLASHCP=y 6 | 7 | # file transfer 8 | CONFIG_RX=y 9 | 10 | # telnet server 11 | CONFIG_TELNETD=y 12 | 13 | # network timer sync 14 | CONFIG_NTPD=y 15 | -------------------------------------------------------------------------------- /buildroot/board/vocore2/genimage.cfg: -------------------------------------------------------------------------------- 1 | # The Flash image 2 | 3 | flash nor-16M-256 { 4 | pebsize = 4K 5 | numpebs = 4K 6 | minimum-io-unit-size = 256 7 | } 8 | 9 | image flash_16M.bin { 10 | flash { 11 | } 12 | flashtype = "nor-16M-256" 13 | 14 | partition uboot { 15 | image = "u-boot-with-spl.bin" 16 | size = 192K 17 | } 18 | 19 | partition kernel { 20 | image = "uImage" 21 | offset = 320K 22 | size = 3776K 23 | } 24 | 25 | partition rootfs { 26 | image = "rootfs.squashfs" 27 | offset = 4096K 28 | size = 8192K 29 | } 30 | 31 | size = 16M 32 | } 33 | -------------------------------------------------------------------------------- /buildroot/board/vocore2/linux/linux.config: -------------------------------------------------------------------------------- 1 | # CONFIG_LOCALVERSION_AUTO is not set 2 | # CONFIG_SYSVIPC is not set 3 | # CONFIG_POSIX_MQUEUE is not set 4 | # CONFIG_CROSS_MEMORY_ATTACH is not set 5 | CONFIG_NO_HZ_IDLE=y 6 | CONFIG_HIGH_RES_TIMERS=y 7 | CONFIG_PREEMPT=y 8 | CONFIG_IKCONFIG=m 9 | CONFIG_IKCONFIG_PROC=y 10 | CONFIG_LOG_BUF_SHIFT=14 11 | CONFIG_CC_OPTIMIZE_FOR_SIZE=y 12 | CONFIG_EMBEDDED=y 13 | CONFIG_RALINK=y 14 | CONFIG_SOC_MT7620=y 15 | CONFIG_DTB_VOCORE2=y 16 | CONFIG_CPU_MIPS32_R2=y 17 | CONFIG_HZ_100=y 18 | CONFIG_MIPS_CMDLINE_DTB_EXTEND=y 19 | CONFIG_MIPS_ELF_APPENDED_DTB=y 20 | # CONFIG_SUSPEND is not set 21 | CONFIG_MODULES=y 22 | CONFIG_MODULE_UNLOAD=y 23 | CONFIG_NET=y 24 | CONFIG_PACKET=y 25 | CONFIG_UNIX=y 26 | CONFIG_INET=y 27 | CONFIG_IPV6=m 28 | CONFIG_WIRELESS=y 29 | CONFIG_CFG80211=m 30 | CONFIG_NL80211_TESTMODE=y 31 | CONFIG_MAC80211=m 32 | CONFIG_DEVTMPFS=y 33 | CONFIG_NETDEVICES=y 34 | CONFIG_PCI=y 35 | # CONFIG_VGA_ARB is not set 36 | # CONFIG_PCIEASPM is not set 37 | CONFIG_WLAN=y 38 | CONFIG_WLAN_VENDOR_MEDIATEK=y 39 | CONFIG_MT7603E=m 40 | CONFIG_LEGACY_PTY_COUNT=2 41 | CONFIG_SERIAL_8250=y 42 | CONFIG_SERIAL_8250_CONSOLE=y 43 | CONFIG_SERIAL_8250_NR_UARTS=3 44 | CONFIG_SERIAL_8250_RUNTIME_UARTS=3 45 | CONFIG_SERIAL_OF_PLATFORM=y 46 | CONFIG_PINCTRL=y 47 | CONFIG_PINCTRL_RALINK=y 48 | CONFIG_PINCTRL_MT7620=y 49 | # CONFIG_PINCTRL_SINGLE is not set 50 | CONFIG_GPIOLIB=y 51 | CONFIG_GPIO_SYSFS=y 52 | CONFIG_GPIO_MT7621=y 53 | CONFIG_I2C=y 54 | CONFIG_I2C_MT7621=y 55 | CONFIG_SPI=y 56 | CONFIG_SPI_MT7621=y 57 | CONFIG_MTD=y 58 | CONFIG_MTD_BLOCK_RO=y 59 | CONFIG_MTD_SPI_NOR=y 60 | CONFIG_MTD_ROM=y 61 | CONFIG_MTD_PHYSMAP=y 62 | CONFIG_MTD_PHYSMAP_OF=y 63 | CONFIG_WATCHDOG=y 64 | CONFIG_MT7621_WDT=y 65 | CONFIG_USB=m 66 | CONFIG_USB_EHCI_HCD=m 67 | CONFIG_USB_EHCI_HCD_PLATFORM=m 68 | CONFIG_SCSI=m 69 | CONFIG_BLK_DEV_SD=m 70 | CONFIG_USB_STORAGE=m 71 | CONFIG_MEMORY=y 72 | CONFIG_PHY_RALINK_USB=y 73 | CONFIG_PROC_KCORE=y 74 | CONFIG_PARTITION_ADVANCED=y 75 | CONFIG_MSDOS_PARTITION=y 76 | CONFIG_VFAT_FS=m 77 | CONFIG_TMPFS=y 78 | CONFIG_MISC_FILESYSTEMS=y 79 | CONFIG_SQUASHFS=y 80 | CONFIG_SQUASHFS_XZ=y 81 | CONFIG_SQUASHFS_4K_DEVBLK_SIZE=y 82 | CONFIG_JFFS2_FS=y 83 | CONFIG_NLS=m 84 | CONFIG_NLS_ASCII=m 85 | CONFIG_PRINTK_TIME=y 86 | CONFIG_MAGIC_SYSRQ=y 87 | CONFIG_PANIC_TIMEOUT=10 88 | CONFIG_STACKTRACE=y 89 | -------------------------------------------------------------------------------- /buildroot/board/vocore2/post-build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -u 4 | set -e 5 | 6 | -------------------------------------------------------------------------------- /buildroot/board/vocore2/post-image.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | set -u 5 | 6 | BOARD_DIR="$(dirname $0)" 7 | GENIMAGE_CFG="${BOARD_DIR}/genimage.cfg" 8 | GENIMAGE_TMP="${BUILD_DIR}/genimage.tmp" 9 | 10 | rm -rf "${GENIMAGE_TMP}" 11 | 12 | genimage \ 13 | --rootpath "${TARGET_DIR}" \ 14 | --tmppath "${GENIMAGE_TMP}" \ 15 | --inputpath "${BINARIES_DIR}" \ 16 | --outputpath "${BINARIES_DIR}" \ 17 | --config "${GENIMAGE_CFG}" 18 | 19 | cd $BINARIES_DIR 20 | -------------------------------------------------------------------------------- /buildroot/board/vocore2_flasher/busybox/busybox-extra.config: -------------------------------------------------------------------------------- 1 | # spi nor flash 2 | CONFIG_FLASH_ERASEALL=y 3 | CONFIG_FLASH_LOCK=y 4 | CONFIG_FLASH_UNLOCK=y 5 | CONFIG_FLASHCP=y 6 | 7 | # file transfer 8 | CONFIG_RX=y 9 | -------------------------------------------------------------------------------- /buildroot/board/vocore2_flasher/linux/linux.config: -------------------------------------------------------------------------------- 1 | # CONFIG_LOCALVERSION_AUTO is not set 2 | # CONFIG_SYSVIPC is not set 3 | # CONFIG_POSIX_MQUEUE is not set 4 | # CONFIG_CROSS_MEMORY_ATTACH is not set 5 | CONFIG_NO_HZ_IDLE=y 6 | CONFIG_HIGH_RES_TIMERS=y 7 | CONFIG_PREEMPT=y 8 | CONFIG_IKCONFIG=y 9 | CONFIG_IKCONFIG_PROC=y 10 | CONFIG_LOG_BUF_SHIFT=14 11 | CONFIG_CC_OPTIMIZE_FOR_SIZE=y 12 | CONFIG_BLK_DEV_INITRD=y 13 | CONFIG_RD_LZMA=y 14 | CONFIG_INITRAMFS_COMPRESSION_LZMA=y 15 | CONFIG_EMBEDDED=y 16 | CONFIG_RALINK=y 17 | CONFIG_SOC_MT7620=y 18 | CONFIG_DTB_VOCORE2=y 19 | CONFIG_CPU_MIPS32_R2=y 20 | CONFIG_HZ_100=y 21 | CONFIG_MIPS_CMDLINE_DTB_EXTEND=y 22 | CONFIG_MIPS_ELF_APPENDED_DTB=y 23 | # CONFIG_SUSPEND is not set 24 | # CONFIG_MODULES is not set 25 | # CONFIG_NET is not set 26 | CONFIG_DEVTMPFS=y 27 | # CONFIG_VGA_ARB is not set 28 | # CONFIG_PCIEASPM is not set 29 | CONFIG_LEGACY_PTY_COUNT=2 30 | CONFIG_SERIAL_8250=y 31 | CONFIG_SERIAL_8250_CONSOLE=y 32 | CONFIG_SERIAL_8250_NR_UARTS=3 33 | CONFIG_SERIAL_8250_RUNTIME_UARTS=3 34 | CONFIG_SERIAL_OF_PLATFORM=y 35 | CONFIG_PINCTRL=y 36 | CONFIG_PINCTRL_RALINK=y 37 | CONFIG_PINCTRL_MT7620=y 38 | # CONFIG_PINCTRL_SINGLE is not set 39 | CONFIG_GPIOLIB=y 40 | CONFIG_GPIO_SYSFS=y 41 | CONFIG_GPIO_MT7621=y 42 | CONFIG_I2C=y 43 | CONFIG_I2C_MT7621=y 44 | CONFIG_SPI=y 45 | CONFIG_SPI_MT7621=y 46 | CONFIG_SPI_GPIO=y 47 | CONFIG_MTD=y 48 | CONFIG_MTD_SPI_NOR=y 49 | CONFIG_WATCHDOG=y 50 | CONFIG_MT7621_WDT=y 51 | CONFIG_USB=y 52 | CONFIG_USB_EHCI_HCD=y 53 | CONFIG_USB_EHCI_HCD_PLATFORM=y 54 | CONFIG_SCSI=y 55 | CONFIG_BLK_DEV_SD=y 56 | CONFIG_USB_STORAGE=y 57 | CONFIG_MEMORY=y 58 | CONFIG_PHY_RALINK_USB=y 59 | CONFIG_PROC_KCORE=y 60 | CONFIG_PARTITION_ADVANCED=y 61 | CONFIG_MSDOS_PARTITION=y 62 | CONFIG_VFAT_FS=y 63 | CONFIG_TMPFS=y 64 | CONFIG_PRINTK_TIME=y 65 | CONFIG_MAGIC_SYSRQ=y 66 | CONFIG_PANIC_TIMEOUT=10 67 | # CONFIG_CRYPTO is not set 68 | CONFIG_NLS=y 69 | CONFIG_NLS_DEFAULT="utf8" 70 | CONFIG_NLS_CODEPAGE_437=y 71 | CONFIG_NLS_ASCII=y 72 | CONFIG_NLS_ISO8859_1=y 73 | CONFIG_NLS_UTF8=y 74 | -------------------------------------------------------------------------------- /buildroot/configs/vocore2_defconfig: -------------------------------------------------------------------------------- 1 | # target 2 | BR2_mipsel=y 3 | BR2_mips_32r2=y 4 | 5 | # toolchain 6 | BR2_TOOLCHAIN_BUILDROOT_VENDOR="mt76x8" 7 | BR2_TOOLCHAIN_BUILDROOT_MUSL=y 8 | BR2_PACKAGE_HOST_GDB=y 9 | 10 | # build options 11 | BR2_ENABLE_LTO=y 12 | 13 | # system configuration 14 | BR2_TARGET_GENERIC_HOSTNAME="vocore2" 15 | 16 | # kernel 17 | BR2_LINUX_KERNEL=y 18 | BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y 19 | BR2_LINUX_KERNEL_PATCH="$(BR2_EXTERNAL_VOCORE2_PATH)/board/vocore2/linux/patches/" 20 | BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_VOCORE2_PATH)/board/vocore2/linux/linux.config" 21 | BR2_LINUX_KERNEL_LZMA=y 22 | 23 | # firmware 24 | BR2_PACKAGE_MT76_FIRMWARE=y 25 | BR2_PACKAGE_MT76_FIRMWARE_MT7628=y 26 | 27 | # package 28 | BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_VOCORE2_PATH)/board/vocore2/busybox/busybox-extra.config" 29 | BR2_PACKAGE_WIRELESS_REGDB=y 30 | BR2_PACKAGE_WIRELESS_TOOLS=y 31 | BR2_PACKAGE_WPA_SUPPLICANT=y 32 | BR2_PACKAGE_HOSTAPD=y 33 | 34 | # image 35 | BR2_ROOTFS_POST_BUILD_SCRIPT="$(BR2_EXTERNAL_VOCORE2_PATH)/board/vocore2/post-build.sh" 36 | BR2_ROOTFS_POST_IMAGE_SCRIPT="$(BR2_EXTERNAL_VOCORE2_PATH)/board/vocore2/post-image.sh" 37 | # BR2_TARGET_ROOTFS_TAR is not set 38 | BR2_TARGET_ROOTFS_SQUASHFS=y 39 | BR2_TARGET_ROOTFS_SQUASHFS_PAD=y 40 | BR2_TARGET_ROOTFS_SQUASHFS4_XZ=y 41 | 42 | # uboot 43 | BR2_TARGET_UBOOT=y 44 | BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG=y 45 | BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_VOCORE2_PATH)/../uboot/vocore2_defconfig" 46 | BR2_TARGET_UBOOT_NEEDS_DTC=y 47 | # BR2_TARGET_UBOOT_FORMAT_BIN is not set 48 | BR2_TARGET_UBOOT_FORMAT_CUSTOM=y 49 | BR2_TARGET_UBOOT_FORMAT_CUSTOM_NAME="u-boot-with-spl.bin" 50 | 51 | # host 52 | BR2_PACKAGE_HOST_GENIMAGE=y 53 | -------------------------------------------------------------------------------- /buildroot/configs/vocore2_flasher_defconfig: -------------------------------------------------------------------------------- 1 | # target 2 | BR2_mipsel=y 3 | BR2_mips_32r2=y 4 | 5 | # toolchain 6 | BR2_TOOLCHAIN_BUILDROOT_VENDOR="mt76x8" 7 | BR2_TOOLCHAIN_BUILDROOT_MUSL=y 8 | BR2_PACKAGE_HOST_GDB=y 9 | 10 | # build options 11 | BR2_ENABLE_LTO=y 12 | 13 | # system configuration 14 | BR2_TARGET_GENERIC_HOSTNAME="vocore2_flasher" 15 | 16 | # kernel 17 | BR2_LINUX_KERNEL=y 18 | BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y 19 | BR2_LINUX_KERNEL_PATCH="$(BR2_EXTERNAL_VOCORE2_PATH)/board/vocore2_flasher/linux/patches/" 20 | BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="$(BR2_EXTERNAL_VOCORE2_PATH)/board/vocore2_flasher/linux/linux.config" 21 | BR2_LINUX_KERNEL_LZMA=y 22 | 23 | # package 24 | BR2_PACKAGE_BUSYBOX_CONFIG_FRAGMENT_FILES="$(BR2_EXTERNAL_VOCORE2_PATH)/board/vocore2_flasher/busybox/busybox-extra.config" 25 | 26 | # image 27 | # BR2_TARGET_ROOTFS_TAR is not set 28 | BR2_TARGET_ROOTFS_INITRAMFS=y 29 | -------------------------------------------------------------------------------- /buildroot/external.desc: -------------------------------------------------------------------------------- 1 | name: VOCORE2 2 | desc: use buildroot build vocore2 firmware 3 | -------------------------------------------------------------------------------- /buildroot/external.mk: -------------------------------------------------------------------------------- 1 | include $(sort $(wildcard $(BR2_EXTERNAL_VOCORE2_PATH)/package/*/*.mk)) 2 | -------------------------------------------------------------------------------- /buildroot/package/mt76-firmware/Config.in: -------------------------------------------------------------------------------- 1 | config BR2_PACKAGE_MT76_FIRMWARE 2 | bool "mt76-firmware" 3 | help 4 | This package provides various binary firmware files (closed 5 | binary blobs) for mt76 devices's WLAN cards. 6 | 7 | https://github.com/openwrt/mt76 8 | 9 | if BR2_PACKAGE_MT76_FIRMWARE 10 | 11 | 12 | config BR2_PACKAGE_MT76_FIRMWARE_MT7628 13 | bool "mt7628 firmware" 14 | help 15 | Firmware for mt7628's wifi mcu. 16 | 17 | endif 18 | -------------------------------------------------------------------------------- /buildroot/package/mt76-firmware/mt76-firmware.hash: -------------------------------------------------------------------------------- 1 | sha256 078b6d2b5759261f089f4a5010e69989c0956a3e8dd25fbe2dd64fdd71f3b255 mt76-firmware-679254c50f279fe4f1e3ae1fb943f0d1ecdac4ab-br1.tar.gz 2 | -------------------------------------------------------------------------------- /buildroot/package/mt76-firmware/mt76-firmware.mk: -------------------------------------------------------------------------------- 1 | ################################################################################ 2 | # 3 | # mt76-firmware 4 | # 5 | ################################################################################ 6 | 7 | MT76_FIRMWARE_VERSION = 679254c50f279fe4f1e3ae1fb943f0d1ecdac4ab 8 | MT76_FIRMWARE_SITE = https://github.com/openwrt/mt76 9 | MT76_FIRMWARE_SITE_METHOD = git 10 | 11 | # mt7628 12 | ifeq ($(BR2_PACKAGE_MT76_FIRMWARE_MT7628),y) 13 | MT76_FIRMWARE_FILES += firmware/mt7603_e1.bin 14 | MT76_FIRMWARE_FILES += firmware/mt7603_e2.bin 15 | MT76_FIRMWARE_FILES += firmware/mt7628_e1.bin 16 | MT76_FIRMWARE_FILES += firmware/mt7628_e2.bin 17 | endif 18 | 19 | ifneq ($(MT76_FIRMWARE_FILES),) 20 | define MT76_FIRMWARE_INSTALL_FILES 21 | cd $(@D) && \ 22 | $(TAR) cf install.tar $(sort $(MT76_FIRMWARE_FILES)) && \ 23 | $(TAR) xf install.tar -C $(TARGET_DIR)/lib/ 24 | endef 25 | endif 26 | 27 | define MT76_FIRMWARE_INSTALL_TARGET_CMDS 28 | mkdir -p $(TARGET_DIR)/lib/firmware/ 29 | $(MT76_FIRMWARE_INSTALL_FILES) 30 | endef 31 | 32 | define MT76_FIRMWARE_INSTALL_IMAGES_CMDS 33 | $(call MT76_FIRMWARE_INSTALL_FW, $(BINARIES_DIR)) 34 | endef 35 | 36 | $(eval $(generic-package)) 37 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM debian:bullseye-20210902 2 | 3 | ENV DEBIAN_FRONTEND noninteractive 4 | 5 | # This repository can be a bit slow at times. Don't panic... 6 | COPY apt-sources.list /etc/apt/sources.list 7 | 8 | RUN apt update -y && \ 9 | apt install -y --no-install-recommends \ 10 | bc bison build-essential bzip2 ca-certificates ccache clang cmake \ 11 | cpio curl cvs diffutils ecj fastjar file findutils flex gawk \ 12 | gcc-multilib gettext git gkermit grep gzip java-propose-classpath \ 13 | libelf-dev libncurses5-dev libssl-dev locales lrzsz mercurial \ 14 | python2 python2-dev python3 python3-dev rsync screen sed subversion \ 15 | swig tar time tmux unzip util-linux wget xsltproc xz-utils zlib1g-dev \ 16 | nvi cscope openssh-client dropbear-bin sparse indent\ 17 | && \ 18 | apt autoremove -y && \ 19 | apt clean -y 20 | -------------------------------------------------------------------------------- /docker/apt-sources.list: -------------------------------------------------------------------------------- 1 | # Latest just before 20210817T000000Z: 2 | deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20210902T205533Z/ bullseye main 3 | deb [check-valid-until=no] http://snapshot.debian.org/archive/debian-security/20210902T193650Z/ bullseye-security main 4 | deb [check-valid-until=no] http://snapshot.debian.org/archive/debian/20210902T205533Z/ bullseye-updates main 5 | -------------------------------------------------------------------------------- /openwrt.1806/811-spi-gpio-chip-select.patch: -------------------------------------------------------------------------------- 1 | --- a/drivers/spi/spi-mt7621.c 2 | +++ b/drivers/spi/spi-mt7621.c 3 | @@ -15,6 +15,7 @@ 4 | #include 5 | #include 6 | #include 7 | +#include 8 | #include 9 | #include 10 | 11 | @@ -92,9 +93,14 @@ 12 | 13 | rs->pending_write = 0; 14 | 15 | + if (cs >= 2) { /* gpio chip select mode */ 16 | + enable = (spi->mode & SPI_CS_HIGH) ? enable : !enable; 17 | + gpio_set_value_cansleep(spi->cs_gpio, enable); 18 | + } else { 19 | if (enable) 20 | polar = BIT(cs); 21 | mt7621_spi_write(rs, MT7621_SPI_POLAR, polar); 22 | + } 23 | } 24 | 25 | static int mt7621_spi_prepare(struct spi_device *spi, unsigned int speed) 26 | @@ -311,9 +317,16 @@ 27 | return -EINVAL; 28 | } 29 | 30 | + if (spi->chip_select >= 2 && gpio_is_valid(spi->cs_gpio)) 31 | + gpio_request_one(spi->cs_gpio, GPIOF_OUT_INIT_HIGH, dev_name(&spi->dev)); 32 | + 33 | return 0; 34 | } 35 | 36 | +static void mt7621_spi_cleanup(struct spi_device *spi) 37 | +{ 38 | + gpio_free(spi->cs_gpio); 39 | +} 40 | static const struct of_device_id mt7621_spi_match[] = { 41 | { .compatible = "ralink,mt7621-spi" }, 42 | {}, 43 | @@ -360,10 +373,11 @@ 44 | master->mode_bits = SPI_LSB_FIRST; 45 | master->flags = SPI_CONTROLLER_HALF_DUPLEX; 46 | master->setup = mt7621_spi_setup; 47 | + master->cleanup = mt7621_spi_cleanup; 48 | master->transfer_one_message = mt7621_spi_transfer_one_message; 49 | master->bits_per_word_mask = SPI_BPW_MASK(8); 50 | master->dev.of_node = pdev->dev.of_node; 51 | - master->num_chipselect = 2; 52 | + master->num_chipselect = of_gpio_named_count(pdev->dev.of_node, "cs-gpios"); 53 | 54 | dev_set_drvdata(&pdev->dev, master); 55 | 56 | -------------------------------------------------------------------------------- /openwrt.1806/812-support-gd25q256.patch: -------------------------------------------------------------------------------- 1 | --- a/drivers/mtd/spi-nor/spi-nor.c 2 | +++ b/drivers/mtd/spi-nor/spi-nor.c 3 | @@ -93,6 +93,7 @@ 4 | * Like SPI_NOR_4B_OPCODES, but for read 5 | * op code only. 6 | */ 7 | + int (*quad_enable)(struct spi_nor *nor); 8 | }; 9 | 10 | #define JEDEC_MFR(info) ((info)->id[0]) 11 | @@ -992,6 +993,7 @@ 12 | * For historical (and compatibility) reasons (before we got above config) some 13 | * old entries may be missing 4K flag. 14 | */ 15 | +static int macronix_quad_enable(struct spi_nor *nor); 16 | static const struct flash_info spi_nor_ids[] = { 17 | /* Atmel -- some are (confusingly) marketed as "DataFlash" */ 18 | { "at25fs010", INFO(0x1f6601, 0, 32 * 1024, 4, SECT_4K) }, 19 | @@ -1065,6 +1067,12 @@ 20 | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB) 21 | }, 22 | { 23 | + "gd25q256", INFO(0xc84019, 0, 64 * 1024, 512, 24 | + SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | 25 | + SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_4B_OPCODES) 26 | + .quad_enable = macronix_quad_enable, 27 | + }, 28 | + { 29 | "gd25q512", INFO(0xc84020, 0, 64 * 1024, 1024, 30 | SECT_4K | SPI_NOR_DUAL_READ | SPI_NOR_QUAD_READ | 31 | SPI_NOR_HAS_LOCK | SPI_NOR_HAS_TB | SPI_NOR_4B_OPCODES) 32 | @@ -2530,6 +2538,9 @@ 33 | } 34 | } 35 | 36 | + if (info->quad_enable) 37 | + params->quad_enable = info->quad_enable; 38 | + 39 | /* Override the parameters with data read from SFDP tables. */ 40 | nor->addr_width = 0; 41 | nor->mtd.erasesize = 0; 42 | -------------------------------------------------------------------------------- /openwrt.1806/815-sdcard-pinmux-i2si2c.patch: -------------------------------------------------------------------------------- 1 | --- a/drivers/mmc/host/mtk-mmc/sd.c 2 | +++ b/drivers/mmc/host/mtk-mmc/sd.c 3 | @@ -2739,7 +2739,7 @@ 4 | struct msdc_host *host; 5 | struct msdc_hw *hw; 6 | int ret, irq; 7 | - u32 reg; 8 | + u32 reg, reg1; 9 | 10 | printk("MTK MSDC device init.\n"); 11 | mtk_sd_device.dev.platform_data = &msdc0_hw; 12 | @@ -2754,10 +2754,12 @@ 13 | //#elif defined (CONFIG_RALINK_MT7628) 14 | /* TODO: maybe omitted when RAether already toggle AGPIO_CFG */ 15 | reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x3c)); 16 | - reg |= 0x1e << 16; 17 | + reg &= ~(0x1e << 16); 18 | sdr_write32((volatile u32*)(RALINK_SYSCTL_BASE + 0x3c), reg); 19 | + reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3<<0) & ~(0x3<<6) & ~(0x3<<10) & ~(0x1<<15) & ~(0x3<<20) | (0x1<<0) | (0x1<<6) | (0x1<<10) | (0x1<<15) | (0x1<<20); 20 | + reg1 = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x1340)) | (0x1<<11); //Normal mode(AP mode) , SDXC CLK=PAD_GPIO0=GPIO11, driving = 8mA 21 | + sdr_write32((volatile u32*)(RALINK_SYSCTL_BASE + 0x1340), reg1); 22 | 23 | - reg = sdr_read32((volatile u32*)(RALINK_SYSCTL_BASE + 0x60)) & ~(0x3<<10); 24 | #if defined (CONFIG_MTK_MMC_EMMC_8BIT) 25 | reg |= 0x3<<26 | 0x3<<28 | 0x3<<30; 26 | msdc0_hw.data_pins = 8, 27 | -------------------------------------------------------------------------------- /openwrt.1806/README.md: -------------------------------------------------------------------------------- 1 | 0043-spi-add-mt7621-support.patch 2 | (recommend)this patch is used to support full duplex in SPI mode. 3 | 4 | 0045-i2c-add-mt7621-driver.patch 5 | (recommend)better driver for I2C, full support for i2c-tools features. 6 | 7 | 810-es8388-support.patch 8 | (optional)support es8388 sound chip. 9 | 10 | 811-spi-gpio-chip-select.patch 11 | (optional)support more than two SPI device, CS pins function from GPIO, depends on patch 0043. 12 | 13 | 815-sdcard-pinmux-i2si2c.patch 14 | (optional)pinmux SDXC interface from ethernet port 3,4 to I2C/I2S, detail please check vocore.io/v2.html, pins map. 15 | -------------------------------------------------------------------------------- /openwrt.1806/add-kmod-regmap-i2c.patch: -------------------------------------------------------------------------------- 1 | diff --git a/package/kernel/linux/modules/other.mk b/package/kernel/linux/modules/other.mk 2 | index ecf222a..35d1853 100644 3 | --- a/package/kernel/linux/modules/other.mk 4 | +++ b/package/kernel/linux/modules/other.mk 5 | @@ -1112,3 +1112,13 @@ define KernelPackage/it87-wdt/description 6 | endef 7 | 8 | $(eval $(call KernelPackage,it87-wdt)) 9 | + 10 | +define KernelPackage/regmap-i2c 11 | + SUBMENU:=$(OTHER_MENU) 12 | + TITLE:=regmap i2c 13 | + KCONFIG:=CONFIG_REGMAP_I2c 14 | + FILES:=$(LINUX_DIR)/drivers/base/regmap-i2c.ko 15 | + AUTOLOAD:=$(call AutoLoad,50,regmap-i2c.ko,1) 16 | +endef 17 | + 18 | +$(eval $(call KernelPackage,regmap-i2c)) 19 | -------------------------------------------------------------------------------- /openwrt.1806/es8388/000-openwrt-compatible-sound.patch: -------------------------------------------------------------------------------- 1 | --- a/target/linux/ramips/modules.mk 2 | +++ b/target/linux/ramips/modules.mk 3 | @@ -136,3 +136,28 @@ 4 | endef 5 | 6 | $(eval $(call KernelPackage,sound-mt7620)) 7 | + 8 | +define KernelPackage/sound-mt7628 9 | + TITLE:=MT7628 PCM/I2S Alsa Driver 10 | + DEPENDS:=@TARGET_ramips +kmod-sound-soc-core +kmod-regmap +kmod-dma-ralink @!TARGET_ramips_rt288x 11 | + KCONFIG:= \ 12 | + CONFIG_SND_RALINK_SOC_I2S \ 13 | + CONFIG_SND_SIMPLE_CARD \ 14 | + CONFIG_SND_SIMPLE_CARD_UTILS \ 15 | + CONFIG_SND_SOC_ES8328 \ 16 | + CONFIG_SND_SOC_ES8328_I2C 17 | + FILES:= \ 18 | + $(LINUX_DIR)/sound/soc/ralink/snd-soc-ralink-i2s.ko \ 19 | + $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card.ko \ 20 | + $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card-utils.ko \ 21 | + $(LINUX_DIR)/sound/soc/codecs/snd-soc-es8328.ko \ 22 | + $(LINUX_DIR)/sound/soc/codecs/snd-soc-es8328-i2c.ko 23 | + AUTOLOAD:=$(call AutoLoad,90,snd-soc-es8328 snd-soc-es8328-i2c snd-soc-ralink-i2s snd-soc-simple-card) 24 | + $(call AddDepends/sound) 25 | +endef 26 | + 27 | +define KernelPackage/sound-mt7628/description 28 | + Alsa modules for ralink i2s controller. 29 | +endef 30 | + 31 | +$(eval $(call KernelPackage,sound-mt7628)) 32 | --- a/target/linux/ramips/dts/VOCORE2.dtsi 33 | +++ b/target/linux/ramips/dts/VOCORE2.dtsi 34 | @@ -12,9 +12,13 @@ 35 | &pinctrl { 36 | state_default: pinctrl0 { 37 | gpio { 38 | - ralink,group = "wled_an", "refclk", "wdt"; 39 | + ralink,group = "wled_an", "wdt"; 40 | ralink,function = "gpio"; 41 | }; 42 | + refclk { 43 | + ralink,group = "gpio0"; 44 | + ralink,function = "gpio refclk"; 45 | + }; 46 | }; 47 | }; 48 | 49 | @@ -33,6 +37,7 @@ 50 | }; 51 | 52 | &i2s { 53 | + #sound-dai-cells = <0>; 54 | status = "okay"; 55 | }; 56 | 57 | --- a/target/linux/ramips/dts/VOCORE2.dts 58 | +++ b/target/linux/ramips/dts/VOCORE2.dts 59 | @@ -16,6 +16,45 @@ 60 | gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; 61 | }; 62 | }; 63 | + 64 | + sound { 65 | + compatible = "simple-audio-card"; 66 | + simple-audio-card,name = "soundcard"; 67 | + simple-audio-card,format = "i2s"; 68 | + simple-audio-card,bitclock-master = <&sound_master>; 69 | + simple-audio-card,frame-master = <&sound_master>; 70 | + simple-audio-card,mclk-fs = <272>; 71 | + simple-audio-card,widgets = 72 | + "Microphone", "Microphone Jack", 73 | + "Headphone", "Headphone Jack"; 74 | + simple-audio-card,routing = 75 | + "LINPUT1", "Microphone Jack", 76 | + "RINPUT1", "Microphone Jack", 77 | + "Microphone Jack", "Mic Bias", 78 | + "Headphone Jack", "LOUT1", 79 | + "Headphone Jack", "ROUT1"; 80 | + 81 | + simple-audio-card,cpu { 82 | + sound-dai = <&i2s>; 83 | + }; 84 | + 85 | + sound_master:simple-audio-card,codec { 86 | + sound-dai = <&codec>; 87 | + }; 88 | + }; 89 | +}; 90 | + 91 | +&i2c { 92 | + status = "okay"; 93 | + 94 | + codec: es8388@10 { 95 | + #sound-dai-cells = <0>; 96 | + compatible = "everest,es8328"; 97 | + reg = <0x10>; 98 | + 99 | + clocks = <&clkctrl 20>; 100 | + clock-names = "refclk"; 101 | + }; 102 | }; 103 | 104 | &spi0 { 105 | -------------------------------------------------------------------------------- /openwrt.1806/fbusb-dep.mk: -------------------------------------------------------------------------------- 1 | # for openwrt 18 2 | define KernelPackage/fb-sys-ram 3 | SUBMENU:=$(VIDEO_MENU) 4 | TITLE:=Framebuffer in system RAM support 5 | DEPENDS:=+kmod-fb 6 | KCONFIG:= \ 7 | CONFIG_FB_SYS_COPYAREA \ 8 | CONFIG_FB_SYS_FILLRECT \ 9 | CONFIG_FB_SYS_IMAGEBLIT 10 | FILES:= \ 11 | $(LINUX_DIR)/drivers/video/fbdev/core/syscopyarea.ko \ 12 | $(LINUX_DIR)/drivers/video/fbdev/core/sysfillrect.ko \ 13 | $(LINUX_DIR)/drivers/video/fbdev/core/sysimgblt.ko 14 | AUTOLOAD:=$(call AutoLoad,07,syscopyarea sysfillrect sysimgblt) 15 | endef 16 | 17 | define KernelPackage/fb-sys-ram/description 18 | Kernel support for framebuffers in system RAM 19 | endef 20 | 21 | $(eval $(call KernelPackage,fb-sys-ram)) 22 | 23 | define KernelPackage/fb-tft 24 | SUBMENU:=$(VIDEO_MENU) 25 | TITLE:=Support for small TFT LCD display modules 26 | DEPENDS:= \ 27 | @GPIO_SUPPORT +kmod-backlight \ 28 | +kmod-fb +kmod-fb-sys-fops +kmod-fb-sys-ram +kmod-spi-bitbang 29 | KCONFIG:= \ 30 | CONFIG_FB_BACKLIGHT=y \ 31 | CONFIG_FB_DEFERRED_IO=y \ 32 | CONFIG_FB_TFT 33 | FILES:= \ 34 | $(LINUX_DIR)/drivers/staging/fbtft/fbtft.ko 35 | AUTOLOAD:=$(call AutoLoad,08,fbtft) 36 | endef 37 | 38 | define KernelPackage/fb-tft/description 39 | Support for small TFT LCD display modules 40 | endef 41 | 42 | $(eval $(call KernelPackage,fb-tft)) 43 | -------------------------------------------------------------------------------- /openwrt.1806/mt7628/Makefile: -------------------------------------------------------------------------------- 1 | # All rights reserved. 2 | # 3 | # This is free software, licensed under the GNU General Public License v2. 4 | # See /LICENSE for more information. 5 | 6 | include $(TOPDIR)/rules.mk 7 | include $(INCLUDE_DIR)/kernel.mk 8 | 9 | PKG_NAME:=mt7628 10 | P4REV:=120395 11 | PKG_VERSION:=p4rev-$(P4REV) 12 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 13 | PKG_SOURCE_URL:=https://github.com/saviourxx/openwrt_dl/raw/master/ \ 14 | https://github.com/guoxiaoqiao/mtk-openwrt-sdk/raw/master/dl/ \ 15 | http://vonger.cn/misc/vocore2/ 16 | PKG_MD5SUM:=873ac1eccb0a9f5ca1c8c1b5e9ff5197 17 | PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) 18 | 19 | PKG_KCONFIG:= \ 20 | MT_WIFI MT_WIFI_PATH FIRST_IF_EEPROM_PROM FIRST_IF_EEPROM_EFUSE \ 21 | FIRST_IF_EEPROM_FLASH RT_FIRST_CARD_EEPROM RT_SECOND_CARD_EEPROM \ 22 | MULTI_INF_SUPPORT WIFI_BASIC_FUNC WSC_INCLUDED WSC_V2_SUPPORT \ 23 | DOT11N_DRAFT3 DOT11W_PMF_SUPPORT LLTD_SUPPORT QOS_DLS_SUPPORT \ 24 | WAPI_SUPPORT IGMP_SNOOP_SUPPORT BLOCK_NET_IF RATE_ADAPTION \ 25 | NEW_RATE_ADAPT_SUPPORT AGS_SUPPORT IDS_SUPPORT WIFI_WORKQUEUE \ 26 | WIFI_SKB_RECYCLE LED_CONTROL_SUPPORT ATE_SUPPORT MEMORY_OPTIMIZATION \ 27 | UAPSD RLT_MAC RLT_BBP RLT_RF RTMP_MAC RTMP_BBP RTMP_RF RTMP_PCI_SUPPORT \ 28 | RTMP_USB_SUPPORT RTMP_RBUS_SUPPORT WIFI_MODE_AP WIFI_MODE_STA \ 29 | WIFI_MODE_BOTH MT_AP_SUPPORT WDS_SUPPORT MBSS_SUPPORT \ 30 | NEW_MBSSID_MODE ENHANCE_NEW_MBSSID_MODE APCLI_SUPPORT \ 31 | MAC_REPEATER_SUPPORT CON_WPS_SUPPORT LLTD_SUPPORT COC_SUPPORT MT_MAC SNIFFER_SUPPORT 32 | PKG_CONFIG_DEPENDS:=$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c))) 33 | 34 | include $(INCLUDE_DIR)/package.mk 35 | 36 | TAR_CMD=$(HOST_TAR) -C $(1)/ $(TAR_OPTIONS) 37 | 38 | define KernelPackage/mt7628 39 | TITLE:=MTK MT7628 wifi driver 40 | FILES:=$(PKG_BUILD_DIR)/build/mt7628.ko 41 | SUBMENU:=Wireless Drivers 42 | MENU:=1 43 | AUTOLOAD:=$(call AutoLoad,98,mt7628) 44 | endef 45 | 46 | define KernelPackage/mt7628/config 47 | source "$(SOURCE)/config.in" 48 | endef 49 | 50 | define Build/Compile 51 | $(MAKE) -C "$(LINUX_DIR)" V=1 \ 52 | CROSS_COMPILE="$(TARGET_CROSS)" \ 53 | ARCH="$(LINUX_KARCH)" \ 54 | SUBDIRS="$(PKG_BUILD_DIR)/build/" \ 55 | $(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_MT7628_$c),CONFIG_$(c)=$(CONFIG_MT7628_$(c))))\ 56 | modules 57 | endef 58 | 59 | define KernelPackage/mt7628/install 60 | $(INSTALL_DIR) $(1)/usr/bin 61 | $(INSTALL_BIN) ./files/ant1 $(1)/usr/bin 62 | $(INSTALL_BIN) ./files/ant2 $(1)/usr/bin 63 | $(INSTALL_DIR) $(1)/lib/netifd/wireless 64 | $(INSTALL_BIN) ./files/ralink.sh $(1)/lib/netifd/wireless/ 65 | $(INSTALL_DIR) $(1)/etc/config 66 | $(INSTALL_BIN) ./files/wireless $(1)/etc/config/ 67 | $(INSTALL_DIR) $(1)/etc/wireless/mt7628/ 68 | $(INSTALL_BIN) ./files/mt7628.dat $(1)/etc/wireless/mt7628/ 69 | echo p$(P4REV) > $(1)/etc/wireless/mt7628/version 70 | endef 71 | 72 | $(eval $(call KernelPackage,mt7628)) 73 | -------------------------------------------------------------------------------- /openwrt.1806/mt7628/config.in: -------------------------------------------------------------------------------- 1 | if PACKAGE_kmod-mt7628 2 | 3 | config MT7628_RT_FIRST_CARD 4 | int 5 | default 7628 6 | 7 | config MT7628_MT_WIFI 8 | bool 9 | select MT7628_WIFI_BASIC_FUNC 10 | default y 11 | 12 | config MT7628_MT_WIFI_PATH 13 | string 14 | depends on MT7628_MT_WIFI 15 | default "rlt_wifi" 16 | 17 | menu "WiFi Generic Feature Options" 18 | 19 | config MT7628_FIRST_IF_EEPROM_FLASH 20 | bool 21 | default y 22 | 23 | config MT7628_RT_FIRST_CARD_EEPROM 24 | string 25 | default "flash" 26 | 27 | 28 | config MT7628_SECOND_IF_EEPROM_FLASH 29 | bool 30 | default y 31 | 32 | config MT7628_RT_SECOND_CARD_EEPROM 33 | string 34 | default "flash" 35 | 36 | config MT7628_MULTI_INF_SUPPORT 37 | bool 38 | default n 39 | 40 | config MT7628_WIFI_BASIC_FUNC 41 | bool "Basic Functions" 42 | select WIRELESS_EXT 43 | select WEXT_SPY 44 | select WEXT_PRIV 45 | 46 | config MT7628_WSC_INCLUDED 47 | bool "WSC (WiFi Simple Config)" 48 | default y 49 | 50 | config MT7628_WSC_V2_SUPPORT 51 | bool "WSC V2(WiFi Simple Config Version 2.0)" 52 | default y 53 | 54 | config MT7628_DOT11N_DRAFT3 55 | bool "802.11n Draft3" 56 | default y 57 | 58 | config MT7628_DOT11W_PMF_SUPPORT 59 | bool "PMF" 60 | default y 61 | 62 | config MT7628_LLTD_SUPPORT 63 | bool "LLTD (Link Layer Topology Discovery Protocol)" 64 | default n 65 | 66 | config MT7628_QOS_DLS_SUPPORT 67 | bool "802.11e DLS ((Direct-Link Setup) Support" 68 | default n 69 | 70 | config MT7628_WAPI_SUPPORT 71 | bool "WAPI Support" 72 | default n 73 | 74 | #config MT7628_CARRIER_DETECTION_SUPPORT 75 | # bool "Carrier Detect" 76 | # default n 77 | 78 | config MT7628_IGMP_SNOOP_SUPPORT 79 | bool "IGMP snooping" 80 | default n 81 | 82 | config MT7628_BLOCK_NET_IF 83 | bool "NETIF Block" 84 | default n 85 | help 86 | Support Net interface block while Tx-Sw queue full 87 | 88 | config MT7628_RATE_ADAPTION 89 | bool "New Rate Adaptation support" 90 | default y 91 | 92 | config MT7628_NEW_RATE_ADAPT_SUPPORT 93 | bool "Intelligent Rate Adaption" 94 | default y 95 | 96 | config MT7628_AGS_SUPPORT 97 | bool "Adaptive Group Switching" 98 | default n 99 | 100 | config MT7628_IDS_SUPPORT 101 | bool "IDS (Intrusion Detection System) Support" 102 | default n 103 | 104 | config MT7628_WIFI_WORK_QUEUE 105 | bool "Work Queue" 106 | default n 107 | 108 | config MT7628_WIFI_SKB_RECYCLE 109 | bool "SKB Recycle(Linux)" 110 | default n 111 | 112 | #config MT7628_RTMP_FLASH_SUPPORT 113 | # bool "Flash Support" 114 | # default y 115 | 116 | config MT7628_LED_CONTROL_SUPPORT 117 | bool "LED Support" 118 | default n 119 | 120 | config MT7628_ATE_SUPPORT 121 | bool "ATE/QA Support" 122 | default n 123 | 124 | config MT7628_MEMORY_OPTIMIZATION 125 | bool "Memory Optimization" 126 | default n 127 | 128 | config MT7628_UAPSD 129 | bool "UAPSD support" 130 | default y 131 | 132 | # 133 | # Section for chip architectures 134 | # 135 | config MT7628_MT_MAC 136 | bool 137 | default y 138 | 139 | # 140 | # Section for interfaces 141 | # 142 | config MT7628_RTMP_PCI_SUPPORT 143 | bool 144 | 145 | config MT7628_RTMP_USB_SUPPORT 146 | bool 147 | 148 | config MT7628_RTMP_RBUS_SUPPORT 149 | bool 150 | 151 | endmenu 152 | 153 | menu "WiFi Operation Modes" 154 | config MT7628_WIFI_MODE_AP 155 | bool 156 | default y 157 | 158 | config MT7628_MT_AP_SUPPORT 159 | bool #"Ralink RT2860 802.11n AP support" 160 | # depends on NET_RADIO 161 | select WIRELESS_EXT 162 | select WEXT_SPY 163 | select WEXT_PRIV 164 | default y 165 | 166 | config MT7628_WDS_SUPPORT 167 | bool "WDS" 168 | depends on MT7628_MT_AP_SUPPORT 169 | 170 | config MT7628_MBSS_SUPPORT 171 | bool "MBSSID" 172 | depends on MT7628_MT_AP_SUPPORT 173 | default y 174 | 175 | config MT7628_NEW_MBSSID_MODE 176 | bool "New MBSSID MODE" 177 | depends on MT7628_MT_AP_SUPPORT && MT7628_WMBSS_SUPPORT 178 | depends on RALINK_RT3883 || RALINK_RT3352 || RALINK_RT5350 || RALINK_RT6352 || RALINK_MT7620 179 | default y 180 | 181 | config MT7628_ENHANCE_NEW_MBSSID_MODE 182 | bool "Enhanced MBSSID mode" 183 | depends on MT7628_NEW_MBSSID_MODE 184 | default y 185 | 186 | config MT7628_APCLI_SUPPORT 187 | bool "AP-Client Support" 188 | depends on MT7628_MT_AP_SUPPORT 189 | 190 | config MT7628_MAC_REPEATER_SUPPORT 191 | bool "MAC Repeater Support" 192 | depends on MT7628_MT_AP_SUPPORT 193 | depends on MT7628_APCLI_SUPPORT 194 | depends on RALINK_RT6352 || RALINK_MT7620 || RALINK_MT7603E || MT7628_MT_AP_SUPPORT 195 | default n 196 | 197 | config MT7628_SNIFFER_SUPPORT 198 | bool "SNIFFER" 199 | depends on MT7628_MT_AP_SUPPORT 200 | default n 201 | 202 | #config MT7628_DOT11R_FT_SUPPORT 203 | # bool "802.11r Fast BSS Transition" 204 | # depends on MT7628_MT_AP_SUPPORT 205 | 206 | #config MT7628_DOT11K_RRM_SUPPORT 207 | # bool "802.11k Radio Resource Management" 208 | # depends on MT7628_MT_AP_SUPPORT 209 | 210 | config MT7628_CON_WPS_SUPPORT 211 | bool "Concurrent WPS Support" 212 | depends on MT7628_MT_AP_SUPPORT 213 | depends on MT7628_APCLI_SUPPORT 214 | depends on MT7628_WSC_INCLUDED 215 | depends on MT7628_WSC_V2_SUPPORT 216 | default n 217 | 218 | config MT7628_LLTD_SUPPORT 219 | bool "LLTD (Link Layer Topology Discovery Protocol)" 220 | depends on MT7628_MT_AP_SUPPORT 221 | 222 | #config MT7628_COC_SUPPORT 223 | # bool "CoC Support" 224 | # depends on MT7628_MT_AP_SUPPORT 225 | # default n 226 | 227 | #config MT7628_ RT2860V2_SNMP 228 | # bool "Net-SNMP Support" 229 | # depends on MT7628_MT_AP_SUPPORT 230 | 231 | #config MT7628_MCAST_RATE_SPECIFIC 232 | # bool "User specific tx rate of mcast pkt" 233 | # depends on MT7628_MT_AP_SUPPORT 234 | 235 | #config MT7628_EXT_BUILD_CHANNEL_LIST 236 | # bool "Extension Channel List" 237 | # depends on MT7628_MT_AP_SUPPORT 238 | 239 | #config MT7628_AUTO_CH_SELECT_ENHANCE 240 | # bool "Auto Channel Selection Enhancement" 241 | # depends on MT7628_MT_AP_SUPPORT 242 | 243 | config MT7628_AIREPLAY_SUPPORT 244 | bool "Airplay Support" 245 | depends on MT7628_MT_AP_SUPPORT 246 | default n 247 | endmenu 248 | 249 | endif 250 | -------------------------------------------------------------------------------- /openwrt.1806/mt7628/files/ant1: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # change_byte [input file name] [byte position] [value of byte] 4 | change_byte() { 5 | dd if=$1 of=/tmp/cbtmpf bs=1 count=$2 2> /dev/null 6 | echo -ne "\x$3" >> /tmp/cbtmpf; 7 | let "pos=$2+1"; 8 | dd if=$1 of=/tmp/cbtmpf bs=1 skip=$pos seek=$pos 2> /dev/null 9 | mv /tmp/cbtmpf $1 10 | } 11 | 12 | echo setting to one antenna... 13 | insmod w2factory.ko 14 | cp /dev/mtd2 /tmp/mtd2 15 | change_byte /tmp/mtd2 52 11 16 | mtd -e factory write /tmp/mtd2 factory 2> /dev/null 17 | echo done, please call "firstboot -y" to make it valid. 18 | -------------------------------------------------------------------------------- /openwrt.1806/mt7628/files/ant2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # change_byte [input file name] [byte position] [value of byte] 4 | change_byte() { 5 | dd if=$1 of=/tmp/cbtmpf bs=1 count=$2 2> /dev/null 6 | echo -ne "\x$3" >> /tmp/cbtmpf; 7 | let "pos=$2+1"; 8 | dd if=$1 of=/tmp/cbtmpf bs=1 skip=$pos seek=$pos 2> /dev/null 9 | mv /tmp/cbtmpf $1 10 | } 11 | 12 | echo setting to two antennas... 13 | insmod w2factory.ko 14 | cp /dev/mtd2 /tmp/mtd2 15 | change_byte /tmp/mtd2 52 22 16 | mtd -e factory write /tmp/mtd2 factory 2> /dev/null 17 | echo done, please call "firstboot -y" to make it valid. 18 | -------------------------------------------------------------------------------- /openwrt.1806/mt7628/files/mt7628.dat: -------------------------------------------------------------------------------- 1 | #The word of "Default" must not be removed 2 | Default 3 | CountryRegion=1 4 | CountryRegionABand=0 5 | CountryCode= 6 | BssidNum=1 7 | SSID1=VoCore2 8 | SSID2= 9 | SSID3= 10 | SSID4= 11 | WirelessMode=9 12 | TxRate=0 13 | Channel=6 14 | BasicRate=15 15 | BeaconPeriod=100 16 | DtimPeriod=1 17 | TxPower=100 18 | DisableOLBC=0 19 | BGProtection=0 20 | MaxStaNum=0 21 | TxPreamble=0 22 | RTSThreshold=2347 23 | FragThreshold=2346 24 | TxBurst=0 25 | PktAggregate=0 26 | TurboRate=0 27 | WmmCapable=1 28 | APSDCapable=1 29 | DLSCapable=0 30 | APAifsn=3;7;1;1 31 | APCwmin=4;4;3;2 32 | APCwmax=6;10;4;3 33 | APTxop=0;0;94;47 34 | APACM=0;0;0;0 35 | BSSAifsn=3;7;2;2 36 | BSSCwmin=4;4;3;2 37 | BSSCwmax=10;10;4;3 38 | BSSTxop=0;0;94;47 39 | BSSACM=0;0;0;0 40 | AckPolicy=0;0;0;0 41 | NoForwarding=0 42 | NoForwardingBTNBSSID=0 43 | HideSSID=0 44 | StationKeepAlive=0 45 | ShortSlot=1 46 | AutoChannelSelect=0 47 | IEEE8021X=0 48 | IEEE80211H=0 49 | CSPeriod=10 50 | WirelessEvent=0 51 | IdsEnable=0 52 | AuthFloodThreshold=32 53 | AssocReqFloodThreshold=32 54 | ReassocReqFloodThreshold=32 55 | ProbeReqFloodThreshold=32 56 | DisassocFloodThreshold=32 57 | DeauthFloodThreshold=32 58 | EapReqFooldThreshold=32 59 | PreAuth=0 60 | AuthMode=OPEN 61 | EncrypType=NONE 62 | RekeyInterval=0 63 | RekeyMethod=DISABLE 64 | PMKCachePeriod=10 65 | WPAPSK1= 66 | WPAPSK2= 67 | WPAPSK3= 68 | WPAPSK4= 69 | DefaultKeyID=1 70 | Key1Type=1;1;1;1 71 | Key1Str1= 72 | Key1Str2= 73 | Key1Str3= 74 | Key1Str4= 75 | Key2Type=1;1;1;1 76 | Key2Str1= 77 | Key2Str2= 78 | Key2Str3= 79 | Key2Str4= 80 | Key3Type=1;1;1;1 81 | Key3Str1= 82 | Key3Str2= 83 | Key3Str3= 84 | Key3Str4= 85 | Key4Type=1;1;1;1 86 | Key4Str1= 87 | Key4Str2= 88 | Key4Str3= 89 | Key4Str4= 90 | HSCounter=0 91 | AccessPolicy0=0 92 | AccessControlList0= 93 | AccessPolicy1=0 94 | AccessControlList1= 95 | AccessPolicy2=0 96 | AccessControlList2= 97 | AccessPolicy3=0 98 | AccessControlList3= 99 | WdsEnable=0 100 | WdsEncrypType=NONE 101 | WdsList=EOF 102 | WdsKey= 103 | RADIUS_Server=192.168.2.3 104 | RADIUS_Port=1812 105 | RADIUS_Key=ralink 106 | own_ip_addr=192.168.5.234 107 | EAPifname=br-lan 108 | PreAuthifname=br-lan 109 | HT_HTC=0 110 | HT_RDG=0 111 | HT_EXTCHA=0 112 | HT_LinkAdapt=0 113 | HT_OpMode=0 114 | HT_MpduDensity=5 115 | HT_BW=1 116 | HT_AutoBA=1 117 | HT_AMSDU=0 118 | HT_BAWinSize=64 119 | HT_GI=1 120 | HT_MCS=33 121 | 122 | # WPS stuff 123 | # 1 = enrollee, 2 = proxy, 4 = registrar (bitmask) 124 | # This value is enabled later on, for WPA only 125 | WscConfMode=0 126 | # 1 = disabled, 2 = enabled 127 | WscConfStatus=2 128 | # 2 = PBC, 1 = PIN 129 | WscMode = 2 130 | 131 | HT_TxStream=2 132 | HT_RxStream=2 133 | -------------------------------------------------------------------------------- /openwrt.1806/mt7628/files/ralink.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . /lib/netifd/netifd-wireless.sh 3 | 4 | init_wireless_driver "$@" 5 | maclist="" 6 | force_channel="" 7 | 8 | drv_ralink_init_device_config() { 9 | config_add_string country variant log_level short_preamble 10 | config_add_boolean noscan 11 | config_add_int channel 12 | } 13 | 14 | drv_ralink_init_iface_config() { 15 | config_add_string 'auth_server:host' 16 | config_add_string auth_secret 17 | config_add_int 'auth_port:port' 18 | 19 | config_add_string ifname apname mode ssid encryption key key1 key2 key3 key4 wps_pushbutton macfilter led 20 | config_add_boolean hidden isolate 21 | config_add_array 'maclist:list(macaddr)' 22 | } 23 | 24 | drv_ralink_cleanup() { 25 | logger drv_ralink_cleanup 26 | } 27 | 28 | ralink_setup_ap(){ 29 | local name="$1" 30 | local eap=0 31 | 32 | json_select config 33 | json_get_vars mode ifname ssid encryption key key1 key2 key3 key4 wps_pushbutton server port hidden isolate macfilter 34 | json_get_values maclist maclist 35 | 36 | ifconfig $ifname up 37 | 38 | [ -z "$force_channel" ] || iwpriv $ifname set Channel=$force_channel 39 | [ "$isolate" = 1 ] || isolate=0 40 | iwpriv $ifname set NoForwarding=$isolate 41 | iwpriv $ifname set NoForwardingBTNBSSID=$isolate 42 | iwpriv $ifname set NoForwardingMBCast=$isolate 43 | 44 | [ "$hidden" = 1 ] || hidden=0 45 | iwpriv $ifname set HideSSID=$hidden 46 | 47 | wsc_methods=0 48 | wsc_mode=0 49 | case "$encryption" in 50 | psk*|mixed*) 51 | local enc="WPA2PSK" 52 | case "$encryption" in 53 | psk | psk+*) enc=WPAPSK;; 54 | psk2 | psk2*) enc=WPA2PSK;; 55 | mixed*) enc=WPAPSKWPA2PSK;; 56 | wpa | wpa+*) eap=1; enc=WPA;; 57 | wpa2*) eap=1; enc=WPA2;; 58 | esac 59 | local crypto="AES" 60 | case "$encryption" in 61 | *tkip+aes*) crypto=TKIPAES;; 62 | *tkip*) crypto=TKIP;; 63 | esac 64 | [ "$eap" = "1" ] && { 65 | iwpriv $ifname set RADIUS_Server=$server 66 | iwpriv $ifname set RADIUS_Port=$port 67 | iwpriv $ifname set RADIUS_Key=$key 68 | iwpriv $ifname set own_ip_addr=192.168.1.1 69 | iwpriv $ifname set IEEE8021X=0 70 | iwpriv $ifname set EAPifname=eth0.2 71 | iwpriv $ifname set PreAuthIfname=br-lan 72 | } 73 | iwpriv $ifname set AuthMode=$enc 74 | iwpriv $ifname set EncrypType=$crypto 75 | iwpriv $ifname set IEEE8021X=0 76 | iwpriv $ifname set "SSID=${ssid}" 77 | [ "$eap" = "1" ] || iwpriv $ifname set "WPAPSK=${key}" 78 | iwpriv $ifname set DefaultKeyID=2 79 | iwpriv $ifname set "SSID=${ssid}" 80 | if [ "$wps_pushbutton" == "1" ]; then 81 | wsc_methods=128 82 | wsc_mode=7 83 | fi 84 | ;; 85 | wep) 86 | iwpriv $ifname set AuthMode=WEPAUTO 87 | iwpriv $ifname set EncrypType=WEP 88 | iwpriv $ifname set IEEE8021X=0 89 | for idx in 1 2 3 4; do 90 | json_get_var keyn key${idx} 91 | [ -n "$keyn" ] && iwpriv $ifname set "Key${idx}=${keyn}" 92 | done 93 | iwpriv $ifname set DefaultKeyID=${key} 94 | iwpriv $ifname set "SSID=${ssid}" 95 | ;; 96 | none) 97 | iwpriv $ifname set "SSID=${ssid}" 98 | ;; 99 | esac 100 | 101 | iwpriv $ifname set WscConfMode=$wsc_mode 102 | iwpriv $ifname set WscConfStatus=2 103 | iwpriv $ifname set WscMode=2 104 | iwpriv $ifname set ACLClearAll=1 105 | [ -n "$maclist" ] && { 106 | for m in ${maclist}; do 107 | logger iwpriv $ifname set ACLAddEntry="$m" 108 | iwpriv $ifname set ACLAddEntry="$m" 109 | done 110 | } 111 | case "$macfilter" in 112 | allow) 113 | iwpriv $ifname set AccessPolicy=1 114 | ;; 115 | deny) 116 | iwpriv $ifname set AccessPolicy=2 117 | ;; 118 | *) 119 | iwpriv $ifname set AccessPolicy=0 120 | ;; 121 | esac 122 | json_select .. 123 | 124 | 125 | wireless_add_vif "$name" "$ifname" 126 | } 127 | 128 | ralink_get_channel() { 129 | iwpriv ra0 get_site_survey | grep "\<$1\>" | awk '{print $1}' | head -1 130 | } 131 | 132 | ralink_setup_sta(){ 133 | local name="$1" 134 | 135 | json_select config 136 | json_get_vars mode apname ifname ssid encryption key key1 key2 key3 key4 disabled 137 | 138 | [ "$disabled" = "1" ] && return 139 | 140 | ifconfig $ifname up 141 | 142 | key= 143 | case "$encryption" in 144 | psk*|mixed*) json_get_vars key;; 145 | wep) json_get_var key key1;; 146 | esac 147 | json_select .. 148 | 149 | iwpriv ra0 set SiteSurvey=1 150 | sleep 1 151 | 152 | channel=$(ralink_get_channel $ssid) 153 | [ ! -n "$channel" ] && return 154 | iwpriv ra0 set Channel=$channel 155 | 156 | iwpriv $ifname set ApCliEnable=0 157 | #iwpriv $ifname set ApCliAuthMode=WPA2PSK 158 | #iwpriv $ifname set ApCliEncrypType=AES 159 | 160 | case "$encryption" in 161 | psk*|mixed*) 162 | local enc="WPA2PSK" 163 | case "$encryption" in 164 | psk | psk+*) enc=WPAPSK;; 165 | psk2 | psk2*) enc=WPA2PSK;; 166 | mixed*) enc=WPAPSKWPA2PSK;; 167 | wpa | wpa+*) eap=1; enc=WPA;; 168 | wpa2*) eap=1; enc=WPA2;; 169 | esac 170 | local crypto="AES" 171 | case "$encryption" in 172 | *tkip+aes*) crypto=TKIPAES;; 173 | *tkip*) crypto=TKIP;; 174 | esac 175 | #[ "$eap" = "1" ] && { 176 | # No settings here for now 177 | #} 178 | iwpriv $ifname set ApCliAuthMode=$enc 179 | iwpriv $ifname set ApCliEncrypType=$crypto 180 | ;; 181 | wep) 182 | iwpriv $ifname set ApCliAuthMode=WEP 183 | iwpriv $ifname set ApCliEncrypType=WEP 184 | ;; 185 | none) 186 | iwpriv $ifname set ApCliAuthMode=NONE 187 | iwpriv $ifname set ApCliEncrypType=NONE 188 | ;; 189 | esac 190 | 191 | iwpriv $ifname set "ApCliSsid=$ssid" 192 | iwpriv $ifname set "ApCliWPAPSK=$key" 193 | iwpriv $ifname set ApCliEnable=1 194 | 195 | wireless_add_vif "$name" "$ifname" 196 | } 197 | 198 | drv_ralink_setup() { 199 | local ifname="$1" 200 | local bcn_active=0 201 | wmode=9 202 | VHT=0 203 | VHT_SGI=0 204 | HT=0 205 | EXTCHA=0 206 | 207 | sta_disabled="$(uci get wireless.sta.disabled)" 208 | 209 | [ "${sta_disabled}" = "1" ] && bcn_active=1 210 | 211 | json_select config 212 | json_get_vars variant country channel htmode log_level short_preamble noscan:0 213 | json_select .. 214 | 215 | [ "$short_preamble" = 1 ] || short_preamble=0 216 | 217 | case ${htmode:-none} in 218 | HT20) 219 | wmode=10 220 | HT=0 221 | ;; 222 | HT40) 223 | wmode=10 224 | HT=1 225 | EXTCHA=1 226 | ;; 227 | VHT20) 228 | wmode=15 229 | HT=0 230 | VHT=0 231 | VHT_SGI=1 232 | ;; 233 | VHT40) 234 | wmode=15 235 | HT=1 236 | VHT=0 237 | VHT_SGI=1 238 | EXTCHA=1 239 | ;; 240 | VHT80) 241 | wmode=15 242 | HT=1 243 | VHT=1 244 | VHT_SGI=1 245 | EXTCHA=1 246 | ;; 247 | *) 248 | case $hwmode in 249 | a) wmode=2;; 250 | g) wmode=3;; 251 | esac 252 | ;; 253 | esac 254 | 255 | if [ "$auto_channel" -gt 0 ]; then 256 | force_channel="" 257 | channel=0 258 | auto_channel=3 259 | else 260 | force_channel=$channel 261 | auto_channel=0 262 | fi 263 | 264 | coex=1 265 | [ "$noscan" -gt 0 ] && coex=0 266 | 267 | for_each_interface "ap" ralink_setup_ap 268 | for_each_interface "sta" ralink_setup_sta 269 | wireless_set_up 270 | } 271 | 272 | ralink_teardown() { 273 | json_select config 274 | json_get_vars ifname 275 | json_select .. 276 | 277 | iwpriv apcli0 set ApCliEnable=0 278 | ifconfig $ifname down 279 | } 280 | 281 | drv_ralink_teardown() { 282 | wireless_process_kill_all 283 | for_each_interface "ap sta" ralink_teardown 284 | } 285 | 286 | add_driver ralink 287 | 288 | -------------------------------------------------------------------------------- /openwrt.1806/mt7628/files/w2factory.ko: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vonger/vocore2/bf45a2ed014f7a850e2ad00b05f43f6114711d45/openwrt.1806/mt7628/files/w2factory.ko -------------------------------------------------------------------------------- /openwrt.1806/mt7628/files/wireless: -------------------------------------------------------------------------------- 1 | config wifi-device ra0 2 | option type ralink 3 | option variant mt7628 4 | option country CN 5 | option hwmode 11g 6 | option htmode HT40 7 | option channel auto 8 | option disabled 0 9 | 10 | config wifi-iface ap 11 | option device ra0 12 | option mode ap 13 | option network lan 14 | option ifname ra0 15 | option ssid VoCore2 16 | option encryption none 17 | 18 | config wifi-iface sta 19 | option device ra0 20 | option mode sta 21 | option network wwan 22 | option ifname apcli0 23 | option ssid "" 24 | option key "" 25 | option encryption psk2 26 | option disabled 1 27 | 28 | -------------------------------------------------------------------------------- /openwrt.1806/mt7628/openwrt/080-iwinfo-compatible-ralink.patch: -------------------------------------------------------------------------------- 1 | --- a/Makefile 2 | +++ b/Makefile 3 | @@ -4,7 +4,7 @@ 4 | 5 | IWINFO_LIB = libiwinfo.so 6 | IWINFO_LIB_LDFLAGS = $(LDFLAGS) -shared 7 | -IWINFO_LIB_OBJ = iwinfo_utils.o iwinfo_wext.o iwinfo_wext_scan.o iwinfo_lib.o 8 | +IWINFO_LIB_OBJ = iwinfo_utils.o iwinfo_wext.o iwinfo_ralink.o iwinfo_lib.o 9 | 10 | IWINFO_LUA = iwinfo.so 11 | IWINFO_LUA_LDFLAGS = $(LDFLAGS) -shared -L. -liwinfo -llua 12 | --- a/iwinfo_ralink.c 13 | +++ b/iwinfo_ralink.c 14 | @@ -0,0 +1,196 @@ 15 | +/* 16 | + * iwinfo - Wireless Information Library - Linux Wireless Extension Backend 17 | + * 18 | + * Copyright (C) 2009-2010 Jo-Philipp Wich 19 | + * 20 | + * The iwinfo library is free software: you can redistribute it and/or 21 | + * modify it under the terms of the GNU General Public License version 2 22 | + * as published by the Free Software Foundation. 23 | + * 24 | + * The iwinfo library is distributed in the hope that it will be useful, 25 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of 26 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 27 | + * See the GNU General Public License for more details. 28 | + * 29 | + * You should have received a copy of the GNU General Public License along 30 | + * with the iwinfo library. If not, see http://www.gnu.org/licenses/. 31 | + * 32 | + * Parts of this code are derived from the Linux wireless tools, iwlib.c, 33 | + * iwlist.c and iwconfig.c in particular. 34 | + */ 35 | + 36 | +#include "iwinfo.h" 37 | +#include "iwinfo_wext.h" 38 | + 39 | +#include 40 | +#include 41 | +#include 42 | +#include 43 | +#include 44 | + 45 | +#define BUFFER_SIZE 0x4000 46 | + 47 | +int system_arg(const char *fmt, ...) 48 | +{ 49 | + char cmd[BUFFER_SIZE]; 50 | + va_list valist; 51 | + 52 | + va_start(valist, fmt); 53 | + vsnprintf(cmd, BUFFER_SIZE, fmt, valist); 54 | + va_end(valist); 55 | + 56 | + return system(cmd); 57 | +} 58 | + 59 | +int system_s(char *res, int size, const char *cmd) 60 | +{ 61 | + FILE *fp = popen(cmd, "r"); 62 | + if (fp == NULL) 63 | + return -1; 64 | + fread(res, size, 1, fp); 65 | + return pclose(fp); 66 | +} 67 | + 68 | +int system_arg_s(char *res, int size, const char *fmt, ...) 69 | +{ 70 | + char cmd[BUFFER_SIZE]; 71 | + va_list valist; 72 | + 73 | + va_start(valist, fmt); 74 | + vsnprintf(cmd, BUFFER_SIZE, fmt, valist); 75 | + va_end(valist); 76 | + 77 | + return system_s(res, size, cmd); 78 | +} 79 | + 80 | +char* trimt(char *src) 81 | +{ 82 | + size_t len = strlen(src); 83 | + char *cp1 = src + len - 1; 84 | + if(len == 0) 85 | + return src; 86 | + while(' ' == *cp1) { 87 | + *cp1 = '\0'; 88 | + cp1--; 89 | + } 90 | + return src; 91 | +} 92 | + 93 | +uint8_t hex2int(char x) 94 | +{ 95 | + if (x >= '0' && x <= '9') 96 | + return x - '0'; 97 | + if (x >= 'A' && x <= 'F') 98 | + return x - 'A' + 10; 99 | + if (x >= 'a' && x <= 'f') 100 | + return x - 'a' + 10; 101 | + return 0; 102 | +} 103 | + 104 | +void format_mac(uint8_t *out, const char *mac) 105 | +{ 106 | + out[0] = (hex2int(mac[0]) << 4) + hex2int(mac[1]); 107 | + out[1] = (hex2int(mac[3]) << 4) + hex2int(mac[4]); 108 | + out[2] = (hex2int(mac[6]) << 4) + hex2int(mac[7]); 109 | + out[3] = (hex2int(mac[9]) << 4) + hex2int(mac[10]); 110 | + out[4] = (hex2int(mac[12]) << 4) + hex2int(mac[13]); 111 | + out[5] = (hex2int(mac[15]) << 4) + hex2int(mac[16]); 112 | +} 113 | + 114 | +uint8_t format_quality(int8_t rssi) 115 | +{ 116 | + if (rssi >= -50) 117 | + return 100; 118 | + else if (rssi >= -80) /* between -50 ~ -80dbm*/ 119 | + return (24 + ((rssi + 80) * 26) / 10); 120 | + else if (rssi >= -90) /* between -80 ~ -90dbm*/ 121 | + return (((rssi + 90) * 26) / 10); 122 | + /* < -90 dbm*/ 123 | + return 0; 124 | +} 125 | + 126 | +int wext_get_scanlist(const char *ifname, char *buf, int *len) 127 | +{ 128 | + char res[BUFFER_SIZE] = {0}; 129 | + 130 | + system_arg("iwpriv %s set SiteSurvey=1", ifname); 131 | + sleep(1); 132 | + system_arg_s(res, BUFFER_SIZE, "iwpriv %s get_site_survey", ifname); 133 | + 134 | + *len = 0; // output buffer length is zero. 135 | + 136 | + char *line, *curt = strdup(res); 137 | + int count = 0; 138 | + for (line = strsep(&curt, "\n"); line != NULL; line = strsep(&curt, "\n")) { 139 | + if (count++ < 2 || *line == 0) 140 | + continue; 141 | + 142 | + char pos = 0, *curl = strdup(line), colid = 0; 143 | + int index[] = {4, 33, 20, 23, 9, 8, -1}; 144 | + struct iwinfo_scanlist_entry *e = 145 | + (struct iwinfo_scanlist_entry *)(buf + *len); 146 | + memset(e, 0, sizeof(struct iwinfo_scanlist_entry)); 147 | + 148 | + for (colid = 0; index[colid] >= 0; colid++) { 149 | + char col[64] = {0}; 150 | + 151 | + memcpy(col, curl + pos, index[colid]); 152 | + trimt(col); 153 | + pos += index[colid]; 154 | + 155 | + // channel, ssid, mac, encrypt, signal, proto ... 156 | + switch (colid) { 157 | + case 0: // channel 158 | + e->channel = atoi(col); 159 | + break; 160 | + 161 | + case 1: // ssid 162 | + snprintf(e->ssid, sizeof(e->ssid), "%s", col); 163 | + break; 164 | + 165 | + case 2: // mac 166 | + format_mac(e->mac, col); 167 | + break; 168 | + 169 | + case 3: 170 | + e->crypto.enabled = strstr(col, "NONE") ? 0 : 1; 171 | + 172 | + if (strstr(col, "TKIP")) 173 | + e->crypto.group_ciphers |= IWINFO_CIPHER_TKIP; 174 | + if (strstr(col, "AES")) 175 | + e->crypto.group_ciphers |= IWINFO_CIPHER_CCMP; // FIXME? 176 | + 177 | + if (strstr(col, "WPA1")) 178 | + e->crypto.wpa_version |= 1; 179 | + if (strstr(col, "WPA2")) 180 | + e->crypto.wpa_version |= 2; 181 | + 182 | + if (strstr(col, "PSK")) 183 | + e->crypto.auth_suites = IWINFO_KMGMT_PSK; 184 | + // 802.1X and NONE also is a choice of suite, not supported. 185 | + break; 186 | + 187 | + case 4: 188 | + e->signal = atoi(col); 189 | + e->quality = format_quality(e->signal); 190 | + e->quality_max = 100; 191 | + break; 192 | + 193 | + case 5: // deal with other.. 194 | + e->mode = IWINFO_OPMODE_MASTER; 195 | + break; 196 | + 197 | + default: 198 | + break; 199 | + } 200 | + } 201 | + free(curl); 202 | + 203 | + // move to next. 204 | + *len += sizeof(struct iwinfo_scanlist_entry); 205 | + } 206 | + free(curt); 207 | + return 0; 208 | +} 209 | + 210 | + 211 | -------------------------------------------------------------------------------- /openwrt.1806/mt7628/openwrt/luci/010-luci-vocore2-compatible.patch: -------------------------------------------------------------------------------- 1 | --- a/feeds/luci/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua 2 | +++ b/feeds/luci/modules/luci-mod-admin-full/luasrc/model/cbi/admin_network/wifi.lua 3 | @@ -633,6 +633,8 @@ 4 | encr:value("none", "No Encryption") 5 | encr:value("wep-open", translate("WEP Open System"), {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}, {mode="ahdemo"}, {mode="wds"}) 6 | encr:value("wep-shared", translate("WEP Shared Key"), {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}, {mode="ahdemo"}, {mode="wds"}) 7 | +encr:value("psk", "WPA-PSK", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}) 8 | +encr:value("psk2", "WPA2-PSK", {mode="ap"}, {mode="sta"}, {mode="ap-wds"}, {mode="sta-wds"}, {mode="adhoc"}) 9 | 10 | if hwtype == "mac80211" or hwtype == "prism2" then 11 | local supplicant = fs.access("/usr/sbin/wpa_supplicant") 12 | -------------------------------------------------------------------------------- /openwrt.1806/v2u_apply.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | # network custom 6 | patch -p1 < ./package/vocore2/openwrt.1907/vocore2-default-lan-address.patch 7 | patch -p1 < ./package/vocore2/openwrt.1907/vocore2-default-enable-wireless.patch 8 | 9 | # sound 10 | patch -p1 < ./package/vocore2/openwrt.1806/es8388/000-openwrt-compatible-sound.patch 11 | cp ./package/vocore2/openwrt.1806/es8388/810-es8388-support.patch ./target/linux/ramips/patches-4.14/ 12 | 13 | # spi 14 | cp ./package/vocore2/openwrt.1806/0043-spi-add-mt7621-support.patch ./target/linux/ramips/patches-4.14 15 | cp ./package/vocore2/openwrt.1806/811-spi-gpio-chip-select.patch ./target/linux/ramips/patches-4.14 16 | 17 | # kernel custom 18 | cp ./package/vocore2/openwrt.1806/config-4.14 ./target/linux/ramips/mt76x8/ 19 | 20 | exit 0 21 | -------------------------------------------------------------------------------- /openwrt.1806/v2u_defconfig: -------------------------------------------------------------------------------- 1 | # target 2 | CONFIG_TARGET_ramips=y 3 | CONFIG_TARGET_ramips_mt76x8=y 4 | CONFIG_TARGET_ramips_mt76x8_DEVICE_vocore2=y 5 | 6 | # images 7 | CONFIG_TARGET_ROOTFS_INITRAMFS=y 8 | CONFIG_TARGET_ROOTFS_SQUASHFS=y 9 | 10 | # debug & driver 11 | CONFIG_KERNEL_DEVMEM=y 12 | CONFIG_KERNEL_DEVKMEM=y 13 | CONFIG_PACKAGE_mem=y 14 | CONFIG_PACKAGE_mt7628tool=y 15 | 16 | # serial port 17 | CONFIG_PACKAGE_gkermit=y 18 | CONFIG_PACKAGE_lrzsz=y 19 | 20 | # sound 21 | CONFIG_PACKAGE_kmod-i2c-core=y 22 | CONFIG_PACKAGE_kmod-i2c-mt7628=y 23 | CONFIG_PACKAGE_kmod-sound-mt7628=y 24 | CONFIG_PACKAGE_alsa-utils=y 25 | 26 | # usbdisk 27 | CONFIG_PACKAGE_kmod-usb-storage=y 28 | 29 | # sdcard 30 | CONFIG_PACKAGE_kmod-sdhci-mt7620=y 31 | 32 | # filesystem 33 | CONFIG_PACKAGE_kmod-fs-vfat=y 34 | 35 | # wireless network 36 | CONFIG_PACKAGE_kmod-mt76=y 37 | 38 | # web config 39 | CONFIG_PACKAGE_luci=y 40 | -------------------------------------------------------------------------------- /openwrt.1806/vocore2-5ports-setup.patch: -------------------------------------------------------------------------------- 1 | diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network 2 | index 50d3a89bd8..f2745409e7 100755 3 | --- a/target/linux/ramips/base-files/etc/board.d/02_network 4 | +++ b/target/linux/ramips/base-files/etc/board.d/02_network 5 | @@ -354,8 +354,9 @@ ramips_setup_interfaces() 6 | ;; 7 | vocore2|\ 8 | vocore2lite) 9 | + mem 0x1000003c 0xe001ff # 5 port setup 10 | ucidef_add_switch "switch0" \ 11 | - "0:lan" "2:lan" "6t@eth0" 12 | + "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0" 13 | ;; 14 | f5d8235-v1|\ 15 | tew-714tru|\ 16 | diff --git a/target/linux/ramips/dts/VOCORE2.dtsi b/target/linux/ramips/dts/VOCORE2.dtsi 17 | index f7aec8e1f5..3fb0ee7f2e 100644 18 | --- a/target/linux/ramips/dts/VOCORE2.dtsi 19 | +++ b/target/linux/ramips/dts/VOCORE2.dtsi 20 | @@ -4,7 +4,7 @@ 21 | compatible = "vocore,vocore2", "mediatek,mt7628an-soc"; 22 | 23 | chosen { 24 | - bootargs = "console=ttyS2,115200"; 25 | + bootargs = "console=ttyS0,115200"; 26 | }; 27 | }; 28 | 29 | @@ -28,26 +28,13 @@ 30 | }; 31 | 32 | &esw { 33 | - mediatek,portmap = <0x7>; 34 | - mediatek,portdisable = <0x3a>; 35 | -}; 36 | - 37 | -&i2s { 38 | - status = "okay"; 39 | + mediatek,portmap = <0x3e>; 40 | }; 41 | 42 | &gdma { 43 | status = "okay"; 44 | }; 45 | 46 | -&pwm { 47 | - status = "okay"; 48 | -}; 49 | - 50 | &uart1 { 51 | status = "okay"; 52 | }; 53 | - 54 | -&uart2 { 55 | - status = "okay"; 56 | -}; 57 | -------------------------------------------------------------------------------- /openwrt.1907/0306-spi-flash-factory-id.patch: -------------------------------------------------------------------------------- 1 | --- a/drivers/mtd/devices/m25p80.c 2 | +++ b/drivers/mtd/devices/m25p80.c 3 | @@ -27,6 +27,18 @@ 4 | #include 5 | #include 6 | 7 | +static ssize_t m25p80_fid(struct device *dev, struct device_attribute *attr, char *buf) 8 | +{ 9 | + struct spi_device *spi = to_spi_device(dev); 10 | + u8 code[5] = {0}, fid[8]; 11 | + 12 | + code[0] = 0x4b; 13 | + if (spi_write_then_read(spi, &code, 5, fid, 8) < 0) 14 | + return sprintf(buf, "\n"); 15 | + return sprintf(buf, "%08X%08X\n", ((u32 *)fid)[0], ((u32 *)fid)[1]); 16 | +} 17 | +static DEVICE_ATTR(fid, S_IRUGO, m25p80_fid, NULL); 18 | + 19 | #define MAX_CMD_SIZE 6 20 | struct m25p { 21 | struct spi_device *spi; 22 | @@ -298,6 +310,7 @@ 23 | if (ret) 24 | return ret; 25 | 26 | + device_create_file(&spi->dev, &dev_attr_fid); 27 | return mtd_device_register(&nor->mtd, data ? data->parts : NULL, 28 | data ? data->nr_parts : 0); 29 | } 30 | -------------------------------------------------------------------------------- /openwrt.1907/0822-mt76-read-factory-eeprom.patch: -------------------------------------------------------------------------------- 1 | diff --git a/mt7603/init.c b/mt7603/init.c 2 | index 9419659..f9f17ed 100644 3 | --- a/mt7603/init.c 4 | +++ b/mt7603/init.c 5 | @@ -277,6 +277,9 @@ mt7603_init_hardware(struct mt7603_dev *dev) 6 | if (ret < 0) 7 | return ret; 8 | 9 | + if (((u8*)dev->mt76.eeprom.data)[MT_EE_NIC_CONF_0] == 0x11) 10 | + dev->mt76.antenna_mask = 1; 11 | + 12 | ret = mt7603_dma_init(dev); 13 | if (ret) 14 | return ret; 15 | -------------------------------------------------------------------------------- /openwrt.1907/0882-pinctrl-fix-gpio-name.patch: -------------------------------------------------------------------------------- 1 | +++ a/arch/mips/ralink/mt7620.c 2 | --- b/arch/mips/ralink/mt7620.c 3 | @@ -187,7 +187,7 @@ 4 | static struct rt2880_pmx_func gpio_grp_mt7628[] = { 5 | FUNC("pcie", 3, 11, 1), 6 | - FUNC("refclk", 2, 11, 1), 7 | + FUNC("gpio refclk", 2, 11, 1), 8 | FUNC("gpio", 1, 11, 1), 9 | FUNC("gpio", 0, 11, 1), 10 | }; 11 | 12 | @@ -334,7 +334,7 @@ 13 | 1, MT7628_GPIO_MODE_CS1), 14 | GRP_G("spis", spis_grp_mt7628, MT7628_GPIO_MODE_MASK, 15 | 1, MT7628_GPIO_MODE_SPIS), 16 | - GRP_G("gpio", gpio_grp_mt7628, MT7628_GPIO_MODE_MASK, 17 | + GRP_G("gpio0", gpio_grp_mt7628, MT7628_GPIO_MODE_MASK, 18 | 1, MT7628_GPIO_MODE_GPIO), 19 | GRP_G("wled_an", wled_an_grp_mt7628, MT7628_GPIO_MODE_MASK, 20 | 1, MT7628_GPIO_MODE_WLED_AN), 21 | -------------------------------------------------------------------------------- /openwrt.1907/v2u_apply.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | # network custom 6 | patch -p1 < ./package/vocore2/openwrt.1907/vocore2-default-lan-address.patch 7 | patch -p1 < ./package/vocore2/openwrt.1907/vocore2-default-enable-wireless.patch 8 | 9 | # sdcard 10 | patch -p1 < ./package/vocore2/openwrt.1907/vocore2-fixmaster-sdcard.patch 11 | patch -p1 < ./package/vocore2/openwrt.1907/vocore2-default-enable-sdcard.patch 12 | 13 | # sound 14 | patch -p1 < ./package/vocore2/openwrt.1907/vocore2-fixmaster-es8388.patch 15 | cp ./package/vocore2/openwrt.1907/0045-i2c-add-mt7621-driver.patch ./target/linux/ramips/patches-4.14 16 | cp ./package/vocore2/openwrt.1907/0810-sound-es8388-aplay.patch ./target/linux/ramips/patches-4.14 17 | cp ./package/vocore2/openwrt.1907/0882-pinctrl-fix-gpio-name.patch ./target/linux/ramips/patches-4.14 18 | 19 | exit 0 20 | -------------------------------------------------------------------------------- /openwrt.1907/v2u_defconfig: -------------------------------------------------------------------------------- 1 | # target 2 | CONFIG_TARGET_ramips=y 3 | CONFIG_TARGET_ramips_mt76x8=y 4 | CONFIG_TARGET_ramips_mt76x8_DEVICE_vocore2=y 5 | 6 | # images 7 | CONFIG_TARGET_ROOTFS_INITRAMFS=y 8 | CONFIG_TARGET_ROOTFS_SQUASHFS=y 9 | 10 | # debug & driver 11 | CONFIG_KERNEL_DEVMEM=y 12 | CONFIG_KERNEL_DEVKMEM=y 13 | CONFIG_PACKAGE_mem=y 14 | CONFIG_PACKAGE_mt7628tool=y 15 | 16 | # serial port 17 | CONFIG_PACKAGE_gkermit=y 18 | CONFIG_PACKAGE_lrzsz=y 19 | 20 | # sound 21 | CONFIG_PACKAGE_kmod-i2c-core=y 22 | CONFIG_PACKAGE_kmod-i2c-mt7628=y 23 | CONFIG_PACKAGE_kmod-sound-mt7628=y 24 | CONFIG_PACKAGE_alsa-utils=y 25 | 26 | # usbdisk 27 | CONFIG_PACKAGE_kmod-usb-storage=y 28 | 29 | # sdcard 30 | CONFIG_PACKAGE_kmod-sdhci-mt7620=y 31 | 32 | # filesystem 33 | CONFIG_PACKAGE_kmod-fs-vfat=y 34 | 35 | # wireless network 36 | CONFIG_PACKAGE_kmod-mt76=y 37 | 38 | # web config 39 | CONFIG_PACKAGE_luci=y 40 | -------------------------------------------------------------------------------- /openwrt.1907/vocore2-5ports-setup.patch: -------------------------------------------------------------------------------- 1 | diff --git a/target/linux/ramips/dts/VOCORE2.dtsi b/target/linux/ramips/dts/VOCORE2.dtsi 2 | index 4e32ed5a35..8d3293992e 100644 3 | --- a/target/linux/ramips/dts/VOCORE2.dtsi 4 | +++ b/target/linux/ramips/dts/VOCORE2.dtsi 5 | @@ -4,7 +4,7 @@ 6 | compatible = "vocore,vocore2", "mediatek,mt7628an-soc"; 7 | 8 | chosen { 9 | - bootargs = "console=ttyS2,115200"; 10 | + bootargs = "console=ttyS0,115200"; 11 | }; 12 | }; 13 | 14 | @@ -27,26 +27,13 @@ 15 | }; 16 | 17 | &esw { 18 | - mediatek,portmap = <0x7>; 19 | - mediatek,portdisable = <0x3a>; 20 | -}; 21 | - 22 | -&i2s { 23 | - status = "okay"; 24 | + mediatek,portmap = <0x3e>; 25 | }; 26 | 27 | &gdma { 28 | status = "okay"; 29 | }; 30 | 31 | -&pwm { 32 | - status = "okay"; 33 | -}; 34 | - 35 | &uart1 { 36 | status = "okay"; 37 | }; 38 | - 39 | -&uart2 { 40 | - status = "okay"; 41 | -}; 42 | diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network 43 | index 8ca1831afe..8fac3b7f90 100755 44 | --- a/target/linux/ramips/base-files/etc/board.d/02_network 45 | +++ b/target/linux/ramips/base-files/etc/board.d/02_network 46 | @@ -431,8 +431,9 @@ ramips_setup_interfaces() 47 | ;; 48 | vocore2|\ 49 | vocore2lite) 50 | + mem 0x1000003c 0xe001ff # 5 port setup 51 | ucidef_add_switch "switch0" \ 52 | - "0:lan" "2:lan" "6t@eth0" 53 | + "0:wan" "1:lan" "2:lan" "3:lan" "4:lan" "6t@eth0" 54 | ;; 55 | f5d8235-v1|\ 56 | f5d8235-v2|\ 57 | -------------------------------------------------------------------------------- /openwrt.1907/vocore2-default-banner.patch: -------------------------------------------------------------------------------- 1 | diff --git a/package/base-files/files/etc/banner b/package/base-files/files/etc/banner 2 | index f3af3c014f..8a41d28756 100644 3 | --- a/package/base-files/files/etc/banner 4 | +++ b/package/base-files/files/etc/banner 5 | @@ -1,8 +1,9 @@ 6 | - _______ ________ __ 7 | - | |.-----.-----.-----.| | | |.----.| |_ 8 | - | - || _ | -__| || | | || _|| _| 9 | - |_______|| __|_____|__|__||________||__| |____| 10 | - |__| W I R E L E S S F R E E D O M 11 | + _ __ ______ ___ 12 | + | | / /____ / ____/____ _____ ___ |__ \ 13 | + | | / // __ \ / / / __ \ / ___// _ \ __/ / 14 | + | |/ // /_/ // /___ / /_/ // / / __// __/ 15 | + |___/ \____/ \____/ \____//_/ \___//____/ 16 | + 17 | ----------------------------------------------------- 18 | %D %V, %C 19 | ----------------------------------------------------- 20 | -------------------------------------------------------------------------------- /openwrt.1907/vocore2-default-enable-fbcon.patch: -------------------------------------------------------------------------------- 1 | --- a/target/linux/ramips/dts/VOCORE2.dtsi 2 | +++ b/target/linux/ramips/dts/VOCORE2.dtsi 3 | @@ -4,7 +4,7 @@ 4 | compatible = "vocore,vocore2", "mediatek,mt7628an-soc"; 5 | 6 | chosen { 7 | - bootargs = "console=ttyS2,115200"; 8 | + bootargs = "console=ttyS2,115200 console=tty0 fbcon=rotate:1"; 9 | }; 10 | }; 11 | 12 | -------------------------------------------------------------------------------- /openwrt.1907/vocore2-default-enable-sdcard.patch: -------------------------------------------------------------------------------- 1 | --- a/target/linux/ramips/dts/VOCORE2.dts 2 | +++ b/target/linux/ramips/dts/VOCORE2.dts 3 | @@ -64,3 +64,8 @@ 4 | }; 5 | }; 6 | }; 7 | + 8 | +&sdhci { 9 | + status = "okay"; 10 | + mediatek,cd-poll; 11 | +}; 12 | -------------------------------------------------------------------------------- /openwrt.1907/vocore2-default-enable-wireless.patch: -------------------------------------------------------------------------------- 1 | diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh 2 | index 511a9188db..3832bd6998 100644 3 | --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh 4 | +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh 5 | @@ -113,13 +113,13 @@ detect_mac80211() { 6 | set wireless.radio${devidx}.hwmode=11${mode_band} 7 | ${dev_id} 8 | ${ht_capab} 9 | - set wireless.radio${devidx}.disabled=1 10 | + set wireless.radio${devidx}.disabled=0 11 | 12 | set wireless.default_radio${devidx}=wifi-iface 13 | set wireless.default_radio${devidx}.device=radio${devidx} 14 | set wireless.default_radio${devidx}.network=lan 15 | set wireless.default_radio${devidx}.mode=ap 16 | - set wireless.default_radio${devidx}.ssid=OpenWrt 17 | + set wireless.default_radio${devidx}.ssid=VoCore2-`hexdump -C /dev/mtd2 | head -1 | awk '{print $10$11}'` 18 | set wireless.default_radio${devidx}.encryption=none 19 | EOF 20 | uci -q commit wireless 21 | -------------------------------------------------------------------------------- /openwrt.1907/vocore2-default-lan-address.patch: -------------------------------------------------------------------------------- 1 | diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate 2 | index 3bf48d7216..e0e76f1292 100755 3 | --- a/package/base-files/files/bin/config_generate 4 | +++ b/package/base-files/files/bin/config_generate 5 | @@ -100,7 +100,7 @@ generate_network() { 6 | static) 7 | local ipad 8 | case "$1" in 9 | - lan) ipad=${ipaddr:-"192.168.1.1"} ;; 10 | + lan) ipad=${ipaddr:-"192.168.61.1"} ;; 11 | *) ipad=${ipaddr:-"192.168.$((addr_offset++)).1"} ;; 12 | esac 13 | 14 | -------------------------------------------------------------------------------- /openwrt.1907/vocore2-default-password.patch: -------------------------------------------------------------------------------- 1 | diff --git a/package/base-files/files/etc/shadow b/package/base-files/files/etc/shadow 2 | index 4b4154f21f..9eef634405 100644 3 | --- a/package/base-files/files/etc/shadow 4 | +++ b/package/base-files/files/etc/shadow 5 | @@ -1,4 +1,4 @@ 6 | -root::0:0:99999:7::: 7 | +root:$1$D5k7lRVZ$71Jw2pHBawdA3eafF1DBm0:17641:0:99999:7::: 8 | daemon:*:0:0:99999:7::: 9 | ftp:*:0:0:99999:7::: 10 | network:*:0:0:99999:7::: 11 | -------------------------------------------------------------------------------- /openwrt.1907/vocore2-fixmaster-es8388.patch: -------------------------------------------------------------------------------- 1 | --- a/target/linux/ramips/modules.mk 2 | +++ b/target/linux/ramips/modules.mk 3 | @@ -136,3 +136,28 @@ 4 | endef 5 | 6 | $(eval $(call KernelPackage,sound-mt7620)) 7 | + 8 | +define KernelPackage/sound-mt7628 9 | + TITLE:=MT7628 PCM/I2S Alsa Driver 10 | + DEPENDS:=@TARGET_ramips +kmod-sound-soc-core +kmod-regmap-i2c +kmod-dma-ralink @!TARGET_ramips_rt288x 11 | + KCONFIG:= \ 12 | + CONFIG_SND_RALINK_SOC_I2S \ 13 | + CONFIG_SND_SIMPLE_CARD \ 14 | + CONFIG_SND_SIMPLE_CARD_UTILS \ 15 | + CONFIG_SND_SOC_ES8328 \ 16 | + CONFIG_SND_SOC_ES8328_I2C 17 | + FILES:= \ 18 | + $(LINUX_DIR)/sound/soc/ralink/snd-soc-ralink-i2s.ko \ 19 | + $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card.ko \ 20 | + $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card-utils.ko \ 21 | + $(LINUX_DIR)/sound/soc/codecs/snd-soc-es8328.ko \ 22 | + $(LINUX_DIR)/sound/soc/codecs/snd-soc-es8328-i2c.ko 23 | + AUTOLOAD:=$(call AutoLoad,90,snd-soc-es8328 snd-soc-es8328-i2c snd-soc-ralink-i2s snd-soc-simple-card) 24 | + $(call AddDepends/sound) 25 | +endef 26 | + 27 | +define KernelPackage/sound-mt7628/description 28 | + Alsa modules for ralink i2s controller. 29 | +endef 30 | + 31 | +$(eval $(call KernelPackage,sound-mt7628)) 32 | --- a/target/linux/ramips/dts/VOCORE2.dtsi 33 | +++ b/target/linux/ramips/dts/VOCORE2.dtsi 34 | @@ -12,9 +12,13 @@ 35 | &pinctrl { 36 | state_default: pinctrl0 { 37 | gpio { 38 | - ralink,group = "wled_an", "refclk", "wdt"; 39 | + ralink,group = "wled_an", "wdt"; 40 | ralink,function = "gpio"; 41 | }; 42 | + refclk { 43 | + ralink,group = "gpio0"; 44 | + ralink,function = "gpio refclk"; 45 | + }; 46 | }; 47 | }; 48 | 49 | @@ -33,6 +37,7 @@ 50 | }; 51 | 52 | &i2s { 53 | + #sound-dai-cells = <0>; 54 | status = "okay"; 55 | }; 56 | 57 | --- a/target/linux/ramips/dts/VOCORE2.dts 58 | +++ b/target/linux/ramips/dts/VOCORE2.dts 59 | @@ -23,6 +23,45 @@ 60 | gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; 61 | }; 62 | }; 63 | + 64 | + sound { 65 | + compatible = "simple-audio-card"; 66 | + simple-audio-card,name = "soundcard"; 67 | + simple-audio-card,format = "i2s"; 68 | + simple-audio-card,bitclock-master = <&sound_master>; 69 | + simple-audio-card,frame-master = <&sound_master>; 70 | + simple-audio-card,mclk-fs = <272>; 71 | + simple-audio-card,widgets = 72 | + "Microphone", "Microphone Jack", 73 | + "Headphone", "Headphone Jack"; 74 | + simple-audio-card,routing = 75 | + "LINPUT1", "Microphone Jack", 76 | + "RINPUT1", "Microphone Jack", 77 | + "Microphone Jack", "Mic Bias", 78 | + "Headphone Jack", "LOUT1", 79 | + "Headphone Jack", "ROUT1"; 80 | + 81 | + simple-audio-card,cpu { 82 | + sound-dai = <&i2s>; 83 | + }; 84 | + 85 | + sound_master:simple-audio-card,codec { 86 | + sound-dai = <&codec>; 87 | + }; 88 | + }; 89 | +}; 90 | + 91 | +&i2c { 92 | + status = "okay"; 93 | + 94 | + codec: es8388@10 { 95 | + #sound-dai-cells = <0>; 96 | + compatible = "everest,es8328"; 97 | + reg = <0x10>; 98 | + 99 | + clocks = <&clkctrl 20>; 100 | + clock-names = "refclk"; 101 | + }; 102 | }; 103 | 104 | &spi0 { 105 | -------------------------------------------------------------------------------- /openwrt.2102/v2u_apply.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -eu 4 | 5 | # network custom 6 | patch -p1 < ./package/vocore2/openwrt.1907/vocore2-default-lan-address.patch 7 | patch -p1 < ./package/vocore2/openwrt.2102/vocore2-default-enable-wireless.patch 8 | 9 | # sdcard 10 | patch -p1 < ./package/vocore2/openwrt.2102/vocore2-sdcard-support.patch 11 | 12 | # sound 13 | patch -p1 < ./package/vocore2/openwrt.2102/vocore2-fixmaster-es8388.patch 14 | cp ./package/vocore2/openwrt.2102/0810-sound-es8388-aplay.patch ./target/linux/ramips/patches-5.4/ 15 | cp ./package/vocore2/openwrt.1907/0882-pinctrl-fix-gpio-name.patch ./target/linux/ramips/patches-5.4/ 16 | 17 | exit 0 18 | -------------------------------------------------------------------------------- /openwrt.2102/v2u_defconfig: -------------------------------------------------------------------------------- 1 | # target 2 | CONFIG_TARGET_ramips=y 3 | CONFIG_TARGET_ramips_mt76x8=y 4 | CONFIG_TARGET_ramips_mt76x8_DEVICE_vocore_vocore2=y 5 | 6 | # images 7 | CONFIG_TARGET_ROOTFS_INITRAMFS=y 8 | CONFIG_TARGET_ROOTFS_SQUASHFS=y 9 | 10 | # debug & driver 11 | CONFIG_KERNEL_DEVMEM=y 12 | CONFIG_KERNEL_DEVKMEM=y 13 | CONFIG_PACKAGE_mem=y 14 | CONFIG_PACKAGE_mt7628tool=y 15 | 16 | # serial port 17 | CONFIG_PACKAGE_gkermit=y 18 | CONFIG_PACKAGE_lrzsz=y 19 | 20 | # sound 21 | CONFIG_PACKAGE_kmod-i2c-core=y 22 | CONFIG_PACKAGE_kmod-i2c-mt7628=y 23 | CONFIG_PACKAGE_kmod-sound-mt7628=y 24 | CONFIG_PACKAGE_alsa-utils=y 25 | 26 | # usbdisk 27 | CONFIG_PACKAGE_kmod-usb-storage=y 28 | 29 | # sdcard 30 | CONFIG_PACKAGE_kmod-sdhci-mt7620=y 31 | 32 | # filesystem 33 | CONFIG_PACKAGE_kmod-fs-vfat=y 34 | 35 | # wireless network 36 | CONFIG_PACKAGE_kmod-mt76=y 37 | 38 | # web config 39 | CONFIG_PACKAGE_luci=y 40 | -------------------------------------------------------------------------------- /openwrt.2102/vocore2-default-enable-wireless.patch: -------------------------------------------------------------------------------- 1 | diff --git a/package/kernel/mac80211/files/lib/wifi/mac80211.sh b/package/kernel/mac80211/files/lib/wifi/mac80211.sh 2 | index 6aa46b0c74..8b58992717 100644 3 | --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh 4 | +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh 5 | @@ -174,13 +174,13 @@ detect_mac80211() { 6 | set wireless.radio${devidx}.channel=${channel} 7 | set wireless.radio${devidx}.band=${mode_band} 8 | set wireless.radio${devidx}.htmode=$htmode 9 | - set wireless.radio${devidx}.disabled=1 10 | + set wireless.radio${devidx}.disabled=0 11 | 12 | set wireless.default_radio${devidx}=wifi-iface 13 | set wireless.default_radio${devidx}.device=radio${devidx} 14 | set wireless.default_radio${devidx}.network=lan 15 | set wireless.default_radio${devidx}.mode=ap 16 | - set wireless.default_radio${devidx}.ssid=OpenWrt 17 | + set wireless.default_radio${devidx}.ssid=VoCore2-`hexdump -C /dev/mtd2 | head -1 | awk '{print $10$11}'` 18 | set wireless.default_radio${devidx}.encryption=none 19 | EOF 20 | uci -q commit wireless 21 | -------------------------------------------------------------------------------- /openwrt.2102/vocore2-fixmaster-es8388.patch: -------------------------------------------------------------------------------- 1 | --- a/target/linux/ramips/modules.mk 2 | +++ b/target/linux/ramips/modules.mk 3 | @@ -136,3 +136,28 @@ 4 | endef 5 | 6 | $(eval $(call KernelPackage,sound-mt7620)) 7 | + 8 | +define KernelPackage/sound-mt7628 9 | + TITLE:=MT7628 PCM/I2S Alsa Driver 10 | + DEPENDS:=@TARGET_ramips +kmod-sound-soc-core +kmod-regmap-i2c +kmod-dma-ralink @!TARGET_ramips_rt288x 11 | + KCONFIG:= \ 12 | + CONFIG_SND_RALINK_SOC_I2S \ 13 | + CONFIG_SND_SIMPLE_CARD \ 14 | + CONFIG_SND_SIMPLE_CARD_UTILS \ 15 | + CONFIG_SND_SOC_ES8328 \ 16 | + CONFIG_SND_SOC_ES8328_I2C 17 | + FILES:= \ 18 | + $(LINUX_DIR)/sound/soc/ralink/snd-soc-ralink-i2s.ko \ 19 | + $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card.ko \ 20 | + $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card-utils.ko \ 21 | + $(LINUX_DIR)/sound/soc/codecs/snd-soc-es8328.ko \ 22 | + $(LINUX_DIR)/sound/soc/codecs/snd-soc-es8328-i2c.ko 23 | + AUTOLOAD:=$(call AutoLoad,90,snd-soc-es8328 snd-soc-es8328-i2c snd-soc-ralink-i2s snd-soc-simple-card) 24 | + $(call AddDepends/sound) 25 | +endef 26 | + 27 | +define KernelPackage/sound-mt7628/description 28 | + Alsa modules for ralink i2s controller. 29 | +endef 30 | + 31 | +$(eval $(call KernelPackage,sound-mt7628)) 32 | --- a/target/linux/ramips/dts/mt7628an_vocore_vocore2.dts 33 | +++ b/target/linux/ramips/dts/mt7628an_vocore_vocore2.dts 34 | @@ -23,6 +23,45 @@ 35 | gpios = <&gpio1 12 GPIO_ACTIVE_HIGH>; 36 | }; 37 | }; 38 | + 39 | + sound { 40 | + compatible = "simple-audio-card"; 41 | + simple-audio-card,name = "soundcard"; 42 | + simple-audio-card,format = "i2s"; 43 | + simple-audio-card,bitclock-master = <&sound_master>; 44 | + simple-audio-card,frame-master = <&sound_master>; 45 | + simple-audio-card,mclk-fs = <272>; 46 | + simple-audio-card,widgets = 47 | + "Microphone", "Microphone Jack", 48 | + "Headphone", "Headphone Jack"; 49 | + simple-audio-card,routing = 50 | + "LINPUT1", "Microphone Jack", 51 | + "RINPUT1", "Microphone Jack", 52 | + "Microphone Jack", "Mic Bias", 53 | + "Headphone Jack", "LOUT1", 54 | + "Headphone Jack", "ROUT1"; 55 | + 56 | + simple-audio-card,cpu { 57 | + sound-dai = <&i2s>; 58 | + }; 59 | + 60 | + sound_master:simple-audio-card,codec { 61 | + sound-dai = <&codec>; 62 | + }; 63 | + }; 64 | +}; 65 | + 66 | +&i2c { 67 | + status = "okay"; 68 | + 69 | + codec: es8388@10 { 70 | + #sound-dai-cells = <0>; 71 | + compatible = "everest,es8328"; 72 | + reg = <0x10>; 73 | + 74 | + clocks = <&clkctrl 20>; 75 | + clock-names = "refclk"; 76 | + }; 77 | }; 78 | 79 | &spi0 { 80 | diff --git a/target/linux/ramips/dts/mt7628an_vocore_vocore2.dtsi b/target/linux/ramips/dts/mt7628an_vocore_vocore2.dtsi 81 | index 9100e0225e..78d59ba026 100644 82 | --- a/target/linux/ramips/dts/mt7628an_vocore_vocore2.dtsi 83 | +++ b/target/linux/ramips/dts/mt7628an_vocore_vocore2.dtsi 84 | @@ -56,9 +56,13 @@ 85 | 86 | &state_default { 87 | gpio { 88 | - groups = "wled_an", "refclk", "wdt"; 89 | + groups = "wled_an", "wdt"; 90 | function = "gpio"; 91 | }; 92 | + refclk { 93 | + groups = "gpio0"; 94 | + function = "gpio refclk"; 95 | + }; 96 | }; 97 | 98 | &wmac { 99 | @@ -78,6 +82,7 @@ 100 | }; 101 | 102 | &i2s { 103 | + #sound-dai-cells = <0>; 104 | status = "okay"; 105 | }; 106 | 107 | -------------------------------------------------------------------------------- /openwrt.2102/vocore2-sdcard-support.patch: -------------------------------------------------------------------------------- 1 | --- a/target/linux/ramips/dts/mt7628an_vocore_vocore2.dts 2 | +++ b/target/linux/ramips/dts/mt7628an_vocore_vocore2.dts 3 | @@ -60,3 +60,8 @@ 4 | }; 5 | }; 6 | }; 7 | + 8 | +&sdhci { 9 | + status = "okay"; 10 | + mediatek,cd-poll; 11 | +}; 12 | -------------------------------------------------------------------------------- /openwrt.2305/clk/openwrt/0001-Delete-reset-controller-driver.patch: -------------------------------------------------------------------------------- 1 | From 9bce8d98a4e839ef2fe388f5fd23a9137051f8c7 Mon Sep 17 00:00:00 2001 2 | From: ieiao 3 | Date: Fri, 24 May 2024 15:45:09 +0800 4 | Subject: [PATCH 1/1] Delete reset controller driver 5 | 6 | --- 7 | .../110-reset_controller_driver.patch | 61 ------------------- 8 | 1 file changed, 61 deletions(-) 9 | delete mode 100644 target/linux/ramips/patches-5.15/110-reset_controller_driver.patch 10 | 11 | diff --git a/target/linux/ramips/patches-5.15/110-reset_controller_driver.patch b/target/linux/ramips/patches-5.15/110-reset_controller_driver.patch 12 | deleted file mode 100644 13 | index 6c923d70c3..0000000000 14 | --- a/target/linux/ramips/patches-5.15/110-reset_controller_driver.patch 15 | +++ /dev/null 16 | @@ -1,61 +0,0 @@ 17 | ---- a/arch/mips/ralink/reset.c 18 | -+++ b/arch/mips/ralink/reset.c 19 | -@@ -11,6 +11,7 @@ 20 | - #include 21 | - #include 22 | - #include 23 | -+#include 24 | - 25 | - #include 26 | - 27 | -@@ -65,21 +66,39 @@ static const struct reset_control_ops re 28 | - .deassert = ralink_deassert_device, 29 | - }; 30 | - 31 | --static struct reset_controller_dev reset_dev = { 32 | -- .ops = &reset_ops, 33 | -- .owner = THIS_MODULE, 34 | -- .nr_resets = 32, 35 | -- .of_reset_n_cells = 1, 36 | -+static int ralink_reset_probe(struct platform_device *pdev) 37 | -+{ 38 | -+ struct reset_controller_dev *rcdev; 39 | -+ 40 | -+ rcdev = devm_kzalloc(&pdev->dev, sizeof(*rcdev), GFP_KERNEL); 41 | -+ if (!rcdev) 42 | -+ return -ENOMEM; 43 | -+ 44 | -+ rcdev->ops = &reset_ops; 45 | -+ rcdev->owner = THIS_MODULE; 46 | -+ rcdev->nr_resets = 32; 47 | -+ rcdev->of_reset_n_cells = 1; 48 | -+ rcdev->of_node = pdev->dev.of_node; 49 | -+ 50 | -+ return devm_reset_controller_register(&pdev->dev, rcdev); 51 | -+} 52 | -+ 53 | -+static const struct of_device_id ralink_reset_dt_ids[] = { 54 | -+ { .compatible = "ralink,rt2880-reset" }, 55 | -+ {} 56 | -+}; 57 | -+ 58 | -+static struct platform_driver ralink_reset_driver = { 59 | -+ .probe = ralink_reset_probe, 60 | -+ .driver = { 61 | -+ .name = "ralink-reset", 62 | -+ .of_match_table = ralink_reset_dt_ids, 63 | -+ } 64 | - }; 65 | - 66 | - void ralink_rst_init(void) 67 | - { 68 | -- reset_dev.of_node = of_find_compatible_node(NULL, NULL, 69 | -- "ralink,rt2880-reset"); 70 | -- if (!reset_dev.of_node) 71 | -- pr_err("Failed to find reset controller node"); 72 | -- else 73 | -- reset_controller_register(&reset_dev); 74 | -+ platform_driver_register(&ralink_reset_driver); 75 | - } 76 | - 77 | - static void ralink_restart(char *command) 78 | -- 79 | 2.39.2 80 | 81 | -------------------------------------------------------------------------------- /openwrt.2305/clk/patch-5.15/905-dt-bindings-clock-add-mtmips-SoCs-system-controller.patch: -------------------------------------------------------------------------------- 1 | From 612616e6381929e7f9e303f8b8ad3655cc101516 Mon Sep 17 00:00:00 2001 2 | From: Sergio Paracuellos 3 | Date: Mon, 19 Jun 2023 06:09:33 +0200 4 | Subject: [PATCH 1/8] dt-bindings: clock: add mtmips SoCs system controller 5 | 6 | Adds device tree binding documentation for system controller node present 7 | in Mediatek MIPS and Ralink SOCs. This node is a clock and reset provider 8 | for the rest of the world. This covers RT2880, RT3050, RT3052, RT3350, 9 | RT3883, RT5350, MT7620, MT7628 and MT7688 SoCs. 10 | 11 | Reviewed-by: Rob Herring 12 | Acked-by: Stephen Boyd 13 | Signed-off-by: Sergio Paracuellos 14 | Signed-off-by: Thomas Bogendoerfer 15 | --- 16 | .../bindings/clock/mediatek,mtmips-sysc.yaml | 64 +++++++++++++++++++ 17 | 1 file changed, 64 insertions(+) 18 | create mode 100644 Documentation/devicetree/bindings/clock/mediatek,mtmips-sysc.yaml 19 | 20 | diff --git a/Documentation/devicetree/bindings/clock/mediatek,mtmips-sysc.yaml b/Documentation/devicetree/bindings/clock/mediatek,mtmips-sysc.yaml 21 | new file mode 100644 22 | index 0000000000000..ba7ffc5b16a0f 23 | --- /dev/null 24 | +++ b/Documentation/devicetree/bindings/clock/mediatek,mtmips-sysc.yaml 25 | @@ -0,0 +1,64 @@ 26 | +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 27 | +%YAML 1.2 28 | +--- 29 | +$id: http://devicetree.org/schemas/clock/mediatek,mtmips-sysc.yaml# 30 | +$schema: http://devicetree.org/meta-schemas/core.yaml# 31 | + 32 | +title: MTMIPS SoCs System Controller 33 | + 34 | +maintainers: 35 | + - Sergio Paracuellos 36 | + 37 | +description: | 38 | + MediaTek MIPS and Ralink SoCs provides a system controller to allow 39 | + to access to system control registers. These registers include clock 40 | + and reset related ones so this node is both clock and reset provider 41 | + for the rest of the world. 42 | + 43 | + These SoCs have an XTAL from where the cpu clock is 44 | + provided as well as derived clocks for the bus and the peripherals. 45 | + 46 | +properties: 47 | + compatible: 48 | + items: 49 | + - enum: 50 | + - ralink,mt7620-sysc 51 | + - ralink,mt7628-sysc 52 | + - ralink,mt7688-sysc 53 | + - ralink,rt2880-sysc 54 | + - ralink,rt3050-sysc 55 | + - ralink,rt3052-sysc 56 | + - ralink,rt3352-sysc 57 | + - ralink,rt3883-sysc 58 | + - ralink,rt5350-sysc 59 | + - const: syscon 60 | + 61 | + reg: 62 | + maxItems: 1 63 | + 64 | + '#clock-cells': 65 | + description: 66 | + The first cell indicates the clock number. 67 | + const: 1 68 | + 69 | + '#reset-cells': 70 | + description: 71 | + The first cell indicates the reset bit within the register. 72 | + const: 1 73 | + 74 | +required: 75 | + - compatible 76 | + - reg 77 | + - '#clock-cells' 78 | + - '#reset-cells' 79 | + 80 | +additionalProperties: false 81 | + 82 | +examples: 83 | + - | 84 | + syscon@0 { 85 | + compatible = "ralink,rt5350-sysc", "syscon"; 86 | + reg = <0x0 0x100>; 87 | + #clock-cells = <1>; 88 | + #reset-cells = <1>; 89 | + }; 90 | -- 91 | 2.39.2 92 | 93 | -------------------------------------------------------------------------------- /openwrt.2305/clk/patch-5.15/907-mips-ralink-rt288x-remove-clock-related-code.patch: -------------------------------------------------------------------------------- 1 | From ffcdf47379eae86dc8f8f02c62994dacf2c9038e Mon Sep 17 00:00:00 2001 2 | From: Sergio Paracuellos 3 | Date: Mon, 19 Jun 2023 06:09:35 +0200 4 | Subject: [PATCH 3/8] mips: ralink: rt288x: remove clock related code 5 | 6 | A properly clock driver for ralink SoCs has been added. Hence there is no 7 | need to have clock related code in 'arch/mips/ralink' folder anymore. 8 | 9 | Signed-off-by: Sergio Paracuellos 10 | Signed-off-by: Thomas Bogendoerfer 11 | --- 12 | arch/mips/include/asm/mach-ralink/rt288x.h | 10 ------- 13 | arch/mips/ralink/rt288x.c | 31 ---------------------- 14 | 2 files changed, 41 deletions(-) 15 | 16 | diff --git a/arch/mips/include/asm/mach-ralink/rt288x.h b/arch/mips/include/asm/mach-ralink/rt288x.h 17 | index 66a999cd1d800..66d190358e3a2 100644 18 | --- a/arch/mips/include/asm/mach-ralink/rt288x.h 19 | +++ b/arch/mips/include/asm/mach-ralink/rt288x.h 20 | @@ -18,7 +18,6 @@ 21 | #define SYSC_REG_CHIP_NAME1 0x04 22 | #define SYSC_REG_CHIP_ID 0x0c 23 | #define SYSC_REG_SYSTEM_CONFIG 0x10 24 | -#define SYSC_REG_CLKCFG 0x30 25 | 26 | #define RT2880_CHIP_NAME0 0x38325452 27 | #define RT2880_CHIP_NAME1 0x20203038 28 | @@ -27,15 +26,6 @@ 29 | #define CHIP_ID_ID_SHIFT 8 30 | #define CHIP_ID_REV_MASK 0xff 31 | 32 | -#define SYSTEM_CONFIG_CPUCLK_SHIFT 20 33 | -#define SYSTEM_CONFIG_CPUCLK_MASK 0x3 34 | -#define SYSTEM_CONFIG_CPUCLK_250 0x0 35 | -#define SYSTEM_CONFIG_CPUCLK_266 0x1 36 | -#define SYSTEM_CONFIG_CPUCLK_280 0x2 37 | -#define SYSTEM_CONFIG_CPUCLK_300 0x3 38 | - 39 | -#define CLKCFG_SRAM_CS_N_WDT BIT(9) 40 | - 41 | #define RT2880_SDRAM_BASE 0x08000000 42 | #define RT2880_MEM_SIZE_MIN 2 43 | #define RT2880_MEM_SIZE_MAX 128 44 | diff --git a/arch/mips/ralink/rt288x.c b/arch/mips/ralink/rt288x.c 45 | index 456ba0b2599eb..0c6a87452dd15 100644 46 | --- a/arch/mips/ralink/rt288x.c 47 | +++ b/arch/mips/ralink/rt288x.c 48 | @@ -21,37 +21,6 @@ 49 | 50 | static struct ralink_soc_info *soc_info_ptr; 51 | 52 | -void __init ralink_clk_init(void) 53 | -{ 54 | - unsigned long cpu_rate, wmac_rate = 40000000; 55 | - u32 t = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG); 56 | - t = ((t >> SYSTEM_CONFIG_CPUCLK_SHIFT) & SYSTEM_CONFIG_CPUCLK_MASK); 57 | - 58 | - switch (t) { 59 | - case SYSTEM_CONFIG_CPUCLK_250: 60 | - cpu_rate = 250000000; 61 | - break; 62 | - case SYSTEM_CONFIG_CPUCLK_266: 63 | - cpu_rate = 266666667; 64 | - break; 65 | - case SYSTEM_CONFIG_CPUCLK_280: 66 | - cpu_rate = 280000000; 67 | - break; 68 | - case SYSTEM_CONFIG_CPUCLK_300: 69 | - cpu_rate = 300000000; 70 | - break; 71 | - } 72 | - 73 | - ralink_clk_add("cpu", cpu_rate); 74 | - ralink_clk_add("300100.timer", cpu_rate / 2); 75 | - ralink_clk_add("300120.watchdog", cpu_rate / 2); 76 | - ralink_clk_add("300500.uart", cpu_rate / 2); 77 | - ralink_clk_add("300900.i2c", cpu_rate / 2); 78 | - ralink_clk_add("300c00.uartlite", cpu_rate / 2); 79 | - ralink_clk_add("400000.ethernet", cpu_rate / 2); 80 | - ralink_clk_add("480000.wmac", wmac_rate); 81 | -} 82 | - 83 | void __init ralink_of_remap(void) 84 | { 85 | rt_sysc_membase = plat_of_remap_node("ralink,rt2880-sysc"); 86 | -- 87 | 2.39.2 88 | 89 | -------------------------------------------------------------------------------- /openwrt.2305/clk/patch-5.15/908-mips-ralink-rt305x-remove-clock-related-code.patch: -------------------------------------------------------------------------------- 1 | From daf73c70f69386fb15960526772ef584a4efcaf2 Mon Sep 17 00:00:00 2001 2 | From: Sergio Paracuellos 3 | Date: Mon, 19 Jun 2023 06:09:36 +0200 4 | Subject: [PATCH 4/8] mips: ralink: rt305x: remove clock related code 5 | 6 | A properly clock driver for ralink SoCs has been added. Hence there is no 7 | need to have clock related code in 'arch/mips/ralink' folder anymore. 8 | 9 | Signed-off-by: Sergio Paracuellos 10 | Signed-off-by: Thomas Bogendoerfer 11 | --- 12 | arch/mips/include/asm/mach-ralink/rt305x.h | 21 ------ 13 | arch/mips/ralink/rt305x.c | 78 ---------------------- 14 | 2 files changed, 99 deletions(-) 15 | 16 | diff --git a/arch/mips/include/asm/mach-ralink/rt305x.h b/arch/mips/include/asm/mach-ralink/rt305x.h 17 | index ef58f7bff9578..4fc5c279cd75c 100644 18 | --- a/arch/mips/include/asm/mach-ralink/rt305x.h 19 | +++ b/arch/mips/include/asm/mach-ralink/rt305x.h 20 | @@ -67,26 +67,9 @@ static inline int soc_is_rt5350(void) 21 | #define CHIP_ID_ID_SHIFT 8 22 | #define CHIP_ID_REV_MASK 0xff 23 | 24 | -#define RT305X_SYSCFG_CPUCLK_SHIFT 18 25 | -#define RT305X_SYSCFG_CPUCLK_MASK 0x1 26 | -#define RT305X_SYSCFG_CPUCLK_LOW 0x0 27 | -#define RT305X_SYSCFG_CPUCLK_HIGH 0x1 28 | - 29 | #define RT305X_SYSCFG_SRAM_CS0_MODE_SHIFT 2 30 | -#define RT305X_SYSCFG_CPUCLK_MASK 0x1 31 | #define RT305X_SYSCFG_SRAM_CS0_MODE_WDT 0x1 32 | 33 | -#define RT3352_SYSCFG0_CPUCLK_SHIFT 8 34 | -#define RT3352_SYSCFG0_CPUCLK_MASK 0x1 35 | -#define RT3352_SYSCFG0_CPUCLK_LOW 0x0 36 | -#define RT3352_SYSCFG0_CPUCLK_HIGH 0x1 37 | - 38 | -#define RT5350_SYSCFG0_CPUCLK_SHIFT 8 39 | -#define RT5350_SYSCFG0_CPUCLK_MASK 0x3 40 | -#define RT5350_SYSCFG0_CPUCLK_360 0x0 41 | -#define RT5350_SYSCFG0_CPUCLK_320 0x2 42 | -#define RT5350_SYSCFG0_CPUCLK_300 0x3 43 | - 44 | #define RT5350_SYSCFG0_DRAM_SIZE_SHIFT 12 45 | #define RT5350_SYSCFG0_DRAM_SIZE_MASK 7 46 | #define RT5350_SYSCFG0_DRAM_SIZE_2M 0 47 | @@ -117,13 +100,9 @@ static inline int soc_is_rt5350(void) 48 | 49 | #define RT3352_SYSC_REG_SYSCFG0 0x010 50 | #define RT3352_SYSC_REG_SYSCFG1 0x014 51 | -#define RT3352_SYSC_REG_CLKCFG1 0x030 52 | #define RT3352_SYSC_REG_RSTCTRL 0x034 53 | #define RT3352_SYSC_REG_USB_PS 0x05c 54 | 55 | -#define RT3352_CLKCFG0_XTAL_SEL BIT(20) 56 | -#define RT3352_CLKCFG1_UPHY0_CLK_EN BIT(18) 57 | -#define RT3352_CLKCFG1_UPHY1_CLK_EN BIT(20) 58 | #define RT3352_RSTCTRL_UHST BIT(22) 59 | #define RT3352_RSTCTRL_UDEV BIT(25) 60 | #define RT3352_SYSCFG1_USB0_HOST_MODE BIT(10) 61 | diff --git a/arch/mips/ralink/rt305x.c b/arch/mips/ralink/rt305x.c 62 | index d8dcc5cc66cc8..9cffe69dd11d9 100644 63 | --- a/arch/mips/ralink/rt305x.c 64 | +++ b/arch/mips/ralink/rt305x.c 65 | @@ -56,84 +56,6 @@ static unsigned long rt5350_get_mem_size(void) 66 | return ret; 67 | } 68 | 69 | -void __init ralink_clk_init(void) 70 | -{ 71 | - unsigned long cpu_rate, sys_rate, wdt_rate, uart_rate; 72 | - unsigned long wmac_rate = 40000000; 73 | - 74 | - u32 t = rt_sysc_r32(SYSC_REG_SYSTEM_CONFIG); 75 | - 76 | - if (soc_is_rt305x() || soc_is_rt3350()) { 77 | - t = (t >> RT305X_SYSCFG_CPUCLK_SHIFT) & 78 | - RT305X_SYSCFG_CPUCLK_MASK; 79 | - switch (t) { 80 | - case RT305X_SYSCFG_CPUCLK_LOW: 81 | - cpu_rate = 320000000; 82 | - break; 83 | - case RT305X_SYSCFG_CPUCLK_HIGH: 84 | - cpu_rate = 384000000; 85 | - break; 86 | - } 87 | - sys_rate = uart_rate = wdt_rate = cpu_rate / 3; 88 | - } else if (soc_is_rt3352()) { 89 | - t = (t >> RT3352_SYSCFG0_CPUCLK_SHIFT) & 90 | - RT3352_SYSCFG0_CPUCLK_MASK; 91 | - switch (t) { 92 | - case RT3352_SYSCFG0_CPUCLK_LOW: 93 | - cpu_rate = 384000000; 94 | - break; 95 | - case RT3352_SYSCFG0_CPUCLK_HIGH: 96 | - cpu_rate = 400000000; 97 | - break; 98 | - } 99 | - sys_rate = wdt_rate = cpu_rate / 3; 100 | - uart_rate = 40000000; 101 | - } else if (soc_is_rt5350()) { 102 | - t = (t >> RT5350_SYSCFG0_CPUCLK_SHIFT) & 103 | - RT5350_SYSCFG0_CPUCLK_MASK; 104 | - switch (t) { 105 | - case RT5350_SYSCFG0_CPUCLK_360: 106 | - cpu_rate = 360000000; 107 | - sys_rate = cpu_rate / 3; 108 | - break; 109 | - case RT5350_SYSCFG0_CPUCLK_320: 110 | - cpu_rate = 320000000; 111 | - sys_rate = cpu_rate / 4; 112 | - break; 113 | - case RT5350_SYSCFG0_CPUCLK_300: 114 | - cpu_rate = 300000000; 115 | - sys_rate = cpu_rate / 3; 116 | - break; 117 | - default: 118 | - BUG(); 119 | - } 120 | - uart_rate = 40000000; 121 | - wdt_rate = sys_rate; 122 | - } else { 123 | - BUG(); 124 | - } 125 | - 126 | - if (soc_is_rt3352() || soc_is_rt5350()) { 127 | - u32 val = rt_sysc_r32(RT3352_SYSC_REG_SYSCFG0); 128 | - 129 | - if (!(val & RT3352_CLKCFG0_XTAL_SEL)) 130 | - wmac_rate = 20000000; 131 | - } 132 | - 133 | - ralink_clk_add("cpu", cpu_rate); 134 | - ralink_clk_add("sys", sys_rate); 135 | - ralink_clk_add("10000900.i2c", uart_rate); 136 | - ralink_clk_add("10000a00.i2s", uart_rate); 137 | - ralink_clk_add("10000b00.spi", sys_rate); 138 | - ralink_clk_add("10000b40.spi", sys_rate); 139 | - ralink_clk_add("10000100.timer", wdt_rate); 140 | - ralink_clk_add("10000120.watchdog", wdt_rate); 141 | - ralink_clk_add("10000500.uart", uart_rate); 142 | - ralink_clk_add("10000c00.uartlite", uart_rate); 143 | - ralink_clk_add("10100000.ethernet", sys_rate); 144 | - ralink_clk_add("10180000.wmac", wmac_rate); 145 | -} 146 | - 147 | void __init ralink_of_remap(void) 148 | { 149 | rt_sysc_membase = plat_of_remap_node("ralink,rt3050-sysc"); 150 | -- 151 | 2.39.2 152 | 153 | -------------------------------------------------------------------------------- /openwrt.2305/clk/patch-5.15/909-mips-ralink-rt3883-remove-clock-related-code.patch: -------------------------------------------------------------------------------- 1 | From 7cd1bb48885449a9323c7ff0f10012925e93b4e1 Mon Sep 17 00:00:00 2001 2 | From: Sergio Paracuellos 3 | Date: Mon, 19 Jun 2023 06:09:37 +0200 4 | Subject: [PATCH 5/8] mips: ralink: rt3883: remove clock related code 5 | 6 | A properly clock driver for ralink SoCs has been added. Hence there is no 7 | need to have clock related code in 'arch/mips/ralink' folder anymore. 8 | 9 | Signed-off-by: Sergio Paracuellos 10 | Signed-off-by: Thomas Bogendoerfer 11 | --- 12 | arch/mips/include/asm/mach-ralink/rt3883.h | 8 ---- 13 | arch/mips/ralink/rt3883.c | 44 ---------------------- 14 | 2 files changed, 52 deletions(-) 15 | 16 | diff --git a/arch/mips/include/asm/mach-ralink/rt3883.h b/arch/mips/include/asm/mach-ralink/rt3883.h 17 | index ad25d5e8d2dc0..4a835b1789253 100644 18 | --- a/arch/mips/include/asm/mach-ralink/rt3883.h 19 | +++ b/arch/mips/include/asm/mach-ralink/rt3883.h 20 | @@ -92,14 +92,6 @@ 21 | #define RT3883_REVID_VER_ID_SHIFT 8 22 | #define RT3883_REVID_ECO_ID_MASK 0x0f 23 | 24 | -#define RT3883_SYSCFG0_DRAM_TYPE_DDR2 BIT(17) 25 | -#define RT3883_SYSCFG0_CPUCLK_SHIFT 8 26 | -#define RT3883_SYSCFG0_CPUCLK_MASK 0x3 27 | -#define RT3883_SYSCFG0_CPUCLK_250 0x0 28 | -#define RT3883_SYSCFG0_CPUCLK_384 0x1 29 | -#define RT3883_SYSCFG0_CPUCLK_480 0x2 30 | -#define RT3883_SYSCFG0_CPUCLK_500 0x3 31 | - 32 | #define RT3883_SYSCFG1_USB0_HOST_MODE BIT(10) 33 | #define RT3883_SYSCFG1_PCIE_RC_MODE BIT(8) 34 | #define RT3883_SYSCFG1_PCI_HOST_MODE BIT(7) 35 | diff --git a/arch/mips/ralink/rt3883.c b/arch/mips/ralink/rt3883.c 36 | index cca887af378fb..14c56993611ab 100644 37 | --- a/arch/mips/ralink/rt3883.c 38 | +++ b/arch/mips/ralink/rt3883.c 39 | @@ -21,50 +21,6 @@ 40 | 41 | static struct ralink_soc_info *soc_info_ptr; 42 | 43 | -void __init ralink_clk_init(void) 44 | -{ 45 | - unsigned long cpu_rate, sys_rate; 46 | - u32 syscfg0; 47 | - u32 clksel; 48 | - u32 ddr2; 49 | - 50 | - syscfg0 = rt_sysc_r32(RT3883_SYSC_REG_SYSCFG0); 51 | - clksel = ((syscfg0 >> RT3883_SYSCFG0_CPUCLK_SHIFT) & 52 | - RT3883_SYSCFG0_CPUCLK_MASK); 53 | - ddr2 = syscfg0 & RT3883_SYSCFG0_DRAM_TYPE_DDR2; 54 | - 55 | - switch (clksel) { 56 | - case RT3883_SYSCFG0_CPUCLK_250: 57 | - cpu_rate = 250000000; 58 | - sys_rate = (ddr2) ? 125000000 : 83000000; 59 | - break; 60 | - case RT3883_SYSCFG0_CPUCLK_384: 61 | - cpu_rate = 384000000; 62 | - sys_rate = (ddr2) ? 128000000 : 96000000; 63 | - break; 64 | - case RT3883_SYSCFG0_CPUCLK_480: 65 | - cpu_rate = 480000000; 66 | - sys_rate = (ddr2) ? 160000000 : 120000000; 67 | - break; 68 | - case RT3883_SYSCFG0_CPUCLK_500: 69 | - cpu_rate = 500000000; 70 | - sys_rate = (ddr2) ? 166000000 : 125000000; 71 | - break; 72 | - } 73 | - 74 | - ralink_clk_add("cpu", cpu_rate); 75 | - ralink_clk_add("10000100.timer", sys_rate); 76 | - ralink_clk_add("10000120.watchdog", sys_rate); 77 | - ralink_clk_add("10000500.uart", 40000000); 78 | - ralink_clk_add("10000900.i2c", 40000000); 79 | - ralink_clk_add("10000a00.i2s", 40000000); 80 | - ralink_clk_add("10000b00.spi", sys_rate); 81 | - ralink_clk_add("10000b40.spi", sys_rate); 82 | - ralink_clk_add("10000c00.uartlite", 40000000); 83 | - ralink_clk_add("10100000.ethernet", sys_rate); 84 | - ralink_clk_add("10180000.wmac", 40000000); 85 | -} 86 | - 87 | void __init ralink_of_remap(void) 88 | { 89 | rt_sysc_membase = plat_of_remap_node("ralink,rt3883-sysc"); 90 | -- 91 | 2.39.2 92 | 93 | -------------------------------------------------------------------------------- /openwrt.2305/clk/patch-5.15/911-MIPS-ralink-mt7621-avoid-to-init-common-ralink-reset.patch: -------------------------------------------------------------------------------- 1 | From 76ce51798cb16738a4a28a6662e7344aaf7ef769 Mon Sep 17 00:00:00 2001 2 | From: Sergio Paracuellos 3 | Date: Sat, 17 Dec 2022 08:48:06 +0100 4 | Subject: [PATCH 1/1] MIPS: ralink: mt7621: avoid to init common ralink reset 5 | controller 6 | 7 | Commit 38a8553b0a22 ("clk: ralink: make system controller node a reset provider") 8 | make system controller a reset provider for mt7621 ralink SoCs. Ralink init code 9 | also tries to start previous common reset controller which at the end tries to 10 | find device tree node 'ralink,rt2880-reset'. mt7621 device tree file is not 11 | using at all this node anymore. Hence avoid to init this common reset controller 12 | for mt7621 ralink SoCs to avoid 'Failed to find reset controller node' boot 13 | error trace error. 14 | 15 | Fixes: 64b2d6ffff86 ("staging: mt7621-dts: align resets with binding documentation") 16 | Signed-off-by: Sergio Paracuellos 17 | Signed-off-by: Thomas Bogendoerfer 18 | --- 19 | arch/mips/ralink/of.c | 4 +++- 20 | 1 file changed, 3 insertions(+), 1 deletion(-) 21 | 22 | diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c 23 | index ea8072acf8d94..01c132bc33d54 100644 24 | --- a/arch/mips/ralink/of.c 25 | +++ b/arch/mips/ralink/of.c 26 | @@ -21,6 +21,7 @@ 27 | #include 28 | #include 29 | #include 30 | +#include 31 | 32 | #include "common.h" 33 | 34 | @@ -81,7 +82,8 @@ static int __init plat_of_setup(void) 35 | __dt_register_buses(soc_info.compatible, "palmbus"); 36 | 37 | /* make sure that the reset controller is setup early */ 38 | - ralink_rst_init(); 39 | + if (ralink_soc != MT762X_SOC_MT7621AT) 40 | + ralink_rst_init(); 41 | 42 | return 0; 43 | } 44 | -- 45 | 2.39.2 46 | 47 | -------------------------------------------------------------------------------- /openwrt.2305/clk/patch-5.15/912-mips-ralink-remove-reset-related-code.patch: -------------------------------------------------------------------------------- 1 | From 201ddc05777cd8e084b508bcdda22214bfe2895e Mon Sep 17 00:00:00 2001 2 | From: Sergio Paracuellos 3 | Date: Mon, 19 Jun 2023 06:09:39 +0200 4 | Subject: [PATCH 7/8] mips: ralink: remove reset related code 5 | 6 | A proper clock driver for ralink SoCs has been added. This driver is also 7 | a reset provider for the SoC. Hence there is no need to have reset related 8 | code in 'arch/mips/ralink' folder anymore. The only code that remains is 9 | the one related with mips_reboot_setup where a PCI reset is performed. 10 | We maintain this because I cannot test old ralink board with PCI to be 11 | sure all works if we remove also this code. 12 | 13 | Signed-off-by: Sergio Paracuellos 14 | Signed-off-by: Thomas Bogendoerfer 15 | --- 16 | arch/mips/ralink/common.h | 2 -- 17 | arch/mips/ralink/of.c | 4 --- 18 | arch/mips/ralink/reset.c | 61 --------------------------------------- 19 | 3 files changed, 67 deletions(-) 20 | 21 | diff --git a/arch/mips/ralink/common.h b/arch/mips/ralink/common.h 22 | index fcdfc9dc62105..b0d6714429667 100644 23 | --- a/arch/mips/ralink/common.h 24 | +++ b/arch/mips/ralink/common.h 25 | @@ -23,8 +23,6 @@ extern struct ralink_soc_info soc_info; 26 | 27 | extern void ralink_of_remap(void); 28 | 29 | -extern void ralink_rst_init(void); 30 | - 31 | extern void __init prom_soc_init(struct ralink_soc_info *soc_info); 32 | 33 | __iomem void *plat_of_remap_node(const char *node); 34 | diff --git a/arch/mips/ralink/of.c b/arch/mips/ralink/of.c 35 | index 4d06de77d92a6..df29e6c896aa6 100644 36 | --- a/arch/mips/ralink/of.c 37 | +++ b/arch/mips/ralink/of.c 38 | @@ -81,10 +81,6 @@ static int __init plat_of_setup(void) 39 | { 40 | __dt_register_buses(soc_info.compatible, "palmbus"); 41 | 42 | - /* make sure that the reset controller is setup early */ 43 | - if (ralink_soc != MT762X_SOC_MT7621AT) 44 | - ralink_rst_init(); 45 | - 46 | return 0; 47 | } 48 | 49 | diff --git a/arch/mips/ralink/reset.c b/arch/mips/ralink/reset.c 50 | index 274d33078c5eb..4875637ef4697 100644 51 | --- a/arch/mips/ralink/reset.c 52 | +++ b/arch/mips/ralink/reset.c 53 | @@ -10,7 +10,6 @@ 54 | #include 55 | #include 56 | #include 57 | -#include 58 | 59 | #include 60 | 61 | @@ -22,66 +21,6 @@ 62 | #define RSTCTL_RESET_PCI BIT(26) 63 | #define RSTCTL_RESET_SYSTEM BIT(0) 64 | 65 | -static int ralink_assert_device(struct reset_controller_dev *rcdev, 66 | - unsigned long id) 67 | -{ 68 | - u32 val; 69 | - 70 | - if (id == 0) 71 | - return -1; 72 | - 73 | - val = rt_sysc_r32(SYSC_REG_RESET_CTRL); 74 | - val |= BIT(id); 75 | - rt_sysc_w32(val, SYSC_REG_RESET_CTRL); 76 | - 77 | - return 0; 78 | -} 79 | - 80 | -static int ralink_deassert_device(struct reset_controller_dev *rcdev, 81 | - unsigned long id) 82 | -{ 83 | - u32 val; 84 | - 85 | - if (id == 0) 86 | - return -1; 87 | - 88 | - val = rt_sysc_r32(SYSC_REG_RESET_CTRL); 89 | - val &= ~BIT(id); 90 | - rt_sysc_w32(val, SYSC_REG_RESET_CTRL); 91 | - 92 | - return 0; 93 | -} 94 | - 95 | -static int ralink_reset_device(struct reset_controller_dev *rcdev, 96 | - unsigned long id) 97 | -{ 98 | - ralink_assert_device(rcdev, id); 99 | - return ralink_deassert_device(rcdev, id); 100 | -} 101 | - 102 | -static const struct reset_control_ops reset_ops = { 103 | - .reset = ralink_reset_device, 104 | - .assert = ralink_assert_device, 105 | - .deassert = ralink_deassert_device, 106 | -}; 107 | - 108 | -static struct reset_controller_dev reset_dev = { 109 | - .ops = &reset_ops, 110 | - .owner = THIS_MODULE, 111 | - .nr_resets = 32, 112 | - .of_reset_n_cells = 1, 113 | -}; 114 | - 115 | -void ralink_rst_init(void) 116 | -{ 117 | - reset_dev.of_node = of_find_compatible_node(NULL, NULL, 118 | - "ralink,rt2880-reset"); 119 | - if (!reset_dev.of_node) 120 | - pr_err("Failed to find reset controller node"); 121 | - else 122 | - reset_controller_register(&reset_dev); 123 | -} 124 | - 125 | static void ralink_restart(char *command) 126 | { 127 | if (IS_ENABLED(CONFIG_PCI)) { 128 | -- 129 | 2.39.2 130 | 131 | -------------------------------------------------------------------------------- /openwrt.2305/clk/patch-5.15/913-mips-ralink-get-cpu-rate-from-new-driver-code.patch: -------------------------------------------------------------------------------- 1 | From ad38c17b0c26ae2108b50ac1eb0281a2e1ce08e9 Mon Sep 17 00:00:00 2001 2 | From: Sergio Paracuellos 3 | Date: Mon, 19 Jun 2023 06:09:40 +0200 4 | Subject: [PATCH 8/8] mips: ralink: get cpu rate from new driver code 5 | 6 | At very early stage on boot, there is a need to set 'mips_hpt_frequency'. 7 | This timer frequency is a half of the CPU frequency. To get clocks properly 8 | set we need to call to 'of_clk_init()' and properly get cpu clock frequency 9 | afterwards. Depending on the SoC, CPU clock index and compatible differs, so 10 | use them to get the proper clock frm the clock provider. Hence, adapt code 11 | to be aligned with new clock driver. 12 | 13 | Signed-off-by: Sergio Paracuellos 14 | Signed-off-by: Thomas Bogendoerfer 15 | --- 16 | arch/mips/ralink/clk.c | 61 +++++++++++++++++++++++++++++++++++------- 17 | 1 file changed, 52 insertions(+), 9 deletions(-) 18 | 19 | diff --git a/arch/mips/ralink/clk.c b/arch/mips/ralink/clk.c 20 | index 5b02bb7e0829c..9db73fcac522e 100644 21 | --- a/arch/mips/ralink/clk.c 22 | +++ b/arch/mips/ralink/clk.c 23 | @@ -11,29 +11,72 @@ 24 | #include 25 | #include 26 | #include 27 | +#include 28 | 29 | #include 30 | 31 | #include "common.h" 32 | 33 | -void ralink_clk_add(const char *dev, unsigned long rate) 34 | +static const char *clk_cpu(int *idx) 35 | { 36 | - struct clk *clk = clk_register_fixed_rate(NULL, dev, NULL, 0, rate); 37 | - 38 | - if (!clk) 39 | - panic("failed to add clock"); 40 | - 41 | - clkdev_create(clk, NULL, "%s", dev); 42 | + switch (ralink_soc) { 43 | + case RT2880_SOC: 44 | + *idx = 0; 45 | + return "ralink,rt2880-sysc"; 46 | + case RT3883_SOC: 47 | + *idx = 0; 48 | + return "ralink,rt3883-sysc"; 49 | + case RT305X_SOC_RT3050: 50 | + *idx = 0; 51 | + return "ralink,rt3050-sysc"; 52 | + case RT305X_SOC_RT3052: 53 | + *idx = 0; 54 | + return "ralink,rt3052-sysc"; 55 | + case RT305X_SOC_RT3350: 56 | + *idx = 1; 57 | + return "ralink,rt3350-sysc"; 58 | + case RT305X_SOC_RT3352: 59 | + *idx = 1; 60 | + return "ralink,rt3352-sysc"; 61 | + case RT305X_SOC_RT5350: 62 | + *idx = 1; 63 | + return "ralink,rt5350-sysc"; 64 | + case MT762X_SOC_MT7620A: 65 | + *idx = 2; 66 | + return "ralink,mt7620-sysc"; 67 | + case MT762X_SOC_MT7620N: 68 | + *idx = 2; 69 | + return "ralink,mt7620-sysc"; 70 | + case MT762X_SOC_MT7628AN: 71 | + *idx = 1; 72 | + return "ralink,mt7628-sysc"; 73 | + case MT762X_SOC_MT7688: 74 | + *idx = 1; 75 | + return "ralink,mt7688-sysc"; 76 | + default: 77 | + *idx = -1; 78 | + return "invalid"; 79 | + } 80 | } 81 | 82 | void __init plat_time_init(void) 83 | { 84 | + struct of_phandle_args clkspec; 85 | + const char *compatible; 86 | struct clk *clk; 87 | + int cpu_clk_idx; 88 | 89 | ralink_of_remap(); 90 | 91 | - ralink_clk_init(); 92 | - clk = clk_get_sys("cpu", NULL); 93 | + compatible = clk_cpu(&cpu_clk_idx); 94 | + if (cpu_clk_idx == -1) 95 | + panic("unable to get CPU clock index"); 96 | + 97 | + of_clk_init(NULL); 98 | + clkspec.np = of_find_compatible_node(NULL, NULL, compatible); 99 | + clkspec.args_count = 1; 100 | + clkspec.args[0] = cpu_clk_idx; 101 | + clk = of_clk_get_from_provider(&clkspec); 102 | if (IS_ERR(clk)) 103 | panic("unable to get CPU clock, err=%ld", PTR_ERR(clk)); 104 | pr_info("CPU Clock: %ldMHz\n", clk_get_rate(clk) / 1000000); 105 | -- 106 | 2.39.2 107 | 108 | -------------------------------------------------------------------------------- /openwrt.2305/clk/patch-5.15/915-mt7628-i2s-improve-set-refclk.patch: -------------------------------------------------------------------------------- 1 | Index: linux-5.15.153/sound/soc/ralink/ralink-i2s.c 2 | =================================================================== 3 | --- linux-5.15.153.orig/sound/soc/ralink/ralink-i2s.c 4 | +++ linux-5.15.153/sound/soc/ralink/ralink-i2s.c 5 | @@ -128,6 +128,8 @@ struct ralink_i2s { 6 | struct device *dev; 7 | void __iomem *regs; 8 | struct clk *clk; 9 | + struct clk *refclk; 10 | + struct clk *refclk_parent; 11 | struct regmap *regmap; 12 | u32 flags; 13 | unsigned int fmt; 14 | @@ -747,11 +749,6 @@ static void mt7628_refclk_setup(void) 15 | { 16 | uint32_t data; 17 | 18 | - /* set i2s and refclk digital pad */ 19 | - data = rt_sysc_r32(0x3c); 20 | - data |= 0x1f; 21 | - rt_sysc_w32(data, 0x3c); 22 | - 23 | /* Adjust REFCLK0's driving strength */ 24 | data = rt_sysc_r32(0x1354); 25 | data &= ~(0x1 << 5); 26 | @@ -760,11 +757,6 @@ static void mt7628_refclk_setup(void) 27 | data |= ~(0x1 << 5); 28 | rt_sysc_w32(data, 0x1364); 29 | 30 | - /* set refclk output 12Mhz clock */ 31 | - data = rt_sysc_r32(0x2c); 32 | - data &= ~(0x7 << 9); 33 | - data |= 0x1 << 9; 34 | - rt_sysc_w32(data, 0x2c); 35 | } 36 | 37 | struct rt_i2s_data { 38 | @@ -814,6 +806,7 @@ static int ralink_i2s_probe(struct platf 39 | int irq, ret; 40 | u32 dma_req; 41 | struct rt_i2s_data *data; 42 | + const char *refclk_source; 43 | 44 | i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); 45 | if (!i2s) 46 | @@ -871,7 +864,7 @@ static int ralink_i2s_probe(struct platf 47 | } 48 | #endif 49 | 50 | - i2s->clk = devm_clk_get(&pdev->dev, NULL); 51 | + i2s->clk = devm_clk_get(&pdev->dev, "i2s"); 52 | if (IS_ERR(i2s->clk)) { 53 | dev_err(&pdev->dev, "no clock defined\n"); 54 | return PTR_ERR(i2s->clk); 55 | @@ -881,6 +874,33 @@ static int ralink_i2s_probe(struct platf 56 | if (ret) 57 | return ret; 58 | 59 | + i2s->refclk = devm_clk_get(&pdev->dev, "refclk"); 60 | + if (IS_ERR(i2s->refclk)) { 61 | + dev_err(&pdev->dev, "no refclk defined\n"); 62 | + return PTR_ERR(i2s->refclk); 63 | + } 64 | + 65 | + if (of_property_read_string(np, "refclk-source", &refclk_source)) { 66 | + dev_err(&pdev->dev, "no refclk-source define\n"); 67 | + return -EINVAL; 68 | + } 69 | + 70 | + i2s->refclk_parent = devm_clk_get(&pdev->dev, refclk_source); 71 | + if (IS_ERR(i2s->refclk_parent)) { 72 | + dev_err(&pdev->dev, "no refclk parent defined\n"); 73 | + return PTR_ERR(i2s->refclk_parent); 74 | + } 75 | + 76 | + ret = clk_set_parent(i2s->refclk, i2s->refclk_parent); 77 | + if (ret) { 78 | + dev_err(&pdev->dev, "Error %d setting refclk parent clock\n", ret); 79 | + return ret; 80 | + } 81 | + 82 | + ret = clk_prepare_enable(i2s->refclk); 83 | + if (ret) 84 | + return ret; 85 | + 86 | ralink_i2s_init_dma_data(i2s, res); 87 | 88 | ret = device_reset(&pdev->dev); 89 | -------------------------------------------------------------------------------- /openwrt.2305/sound/openwrt/vocore2-fixmaster-es8388.patch: -------------------------------------------------------------------------------- 1 | --- a/target/linux/ramips/modules.mk 2 | +++ b/target/linux/ramips/modules.mk 3 | @@ -136,3 +136,28 @@ 4 | endef 5 | 6 | $(eval $(call KernelPackage,sound-mt7620)) 7 | + 8 | +define KernelPackage/sound-mt7628 9 | + TITLE:=MT7628 PCM/I2S Alsa Driver 10 | + DEPENDS:=@TARGET_ramips +kmod-sound-soc-core +kmod-regmap-i2c +kmod-dma-ralink @!TARGET_ramips_rt288x 11 | + KCONFIG:= \ 12 | + CONFIG_SND_RALINK_SOC_I2S \ 13 | + CONFIG_SND_SIMPLE_CARD \ 14 | + CONFIG_SND_SIMPLE_CARD_UTILS \ 15 | + CONFIG_SND_SOC_ES8328 \ 16 | + CONFIG_SND_SOC_ES8328_I2C 17 | + FILES:= \ 18 | + $(LINUX_DIR)/sound/soc/ralink/snd-soc-ralink-i2s.ko \ 19 | + $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card.ko \ 20 | + $(LINUX_DIR)/sound/soc/generic/snd-soc-simple-card-utils.ko \ 21 | + $(LINUX_DIR)/sound/soc/codecs/snd-soc-es8328.ko \ 22 | + $(LINUX_DIR)/sound/soc/codecs/snd-soc-es8328-i2c.ko 23 | + AUTOLOAD:=$(call AutoLoad,90,snd-soc-es8328 snd-soc-es8328-i2c snd-soc-ralink-i2s snd-soc-simple-card) 24 | + $(call AddDepends/sound) 25 | +endef 26 | + 27 | +define KernelPackage/sound-mt7628/description 28 | + Alsa modules for ralink i2s controller. 29 | +endef 30 | + 31 | +$(eval $(call KernelPackage,sound-mt7628)) 32 | -------------------------------------------------------------------------------- /openwrt.2305/sound/openwrt/vocore2-support-es8388.patch: -------------------------------------------------------------------------------- 1 | --- a/target/linux/ramips/dts/mt7628an_vocore_vocore2.dtsi 2 | +++ b/target/linux/ramips/dts/mt7628an_vocore_vocore2.dtsi 3 | @@ -56,9 +56,13 @@ 4 | 5 | &state_default { 6 | gpio { 7 | - groups = "wled_an", "refclk", "wdt"; 8 | + groups = "wled_an", "wdt"; 9 | function = "gpio"; 10 | }; 11 | + refclk { 12 | + groups = "gpio0"; 13 | + function = "gpio refclk"; 14 | + }; 15 | }; 16 | 17 | &wmac { 18 | @@ -78,6 +82,7 @@ 19 | }; 20 | 21 | &i2s { 22 | + #sound-dai-cells = <0>; 23 | status = "okay"; 24 | }; 25 | 26 | --- a/target/linux/ramips/dts/mt7628an_vocore_vocore2.dts 27 | +++ b/target/linux/ramips/dts/mt7628an_vocore_vocore2.dts 28 | @@ -19,10 +19,49 @@ 29 | gpios = <&gpio 44 GPIO_ACTIVE_HIGH>; 30 | }; 31 | }; 32 | + 33 | + sound { 34 | + compatible = "simple-audio-card"; 35 | + simple-audio-card,name = "soundcard"; 36 | + simple-audio-card,format = "i2s"; 37 | + simple-audio-card,bitclock-master = <&sound_master>; 38 | + simple-audio-card,frame-master = <&sound_master>; 39 | + simple-audio-card,mclk-fs = <272>; 40 | + simple-audio-card,widgets = 41 | + "Microphone", "Microphone Jack", 42 | + "Headphone", "Headphone Jack"; 43 | + simple-audio-card,routing = 44 | + "LINPUT1", "Microphone Jack", 45 | + "RINPUT1", "Microphone Jack", 46 | + "Microphone Jack", "Mic Bias", 47 | + "Headphone Jack", "LOUT1", 48 | + "Headphone Jack", "ROUT1"; 49 | + 50 | + simple-audio-card,cpu { 51 | + sound-dai = <&i2s>; 52 | + }; 53 | + 54 | + sound_master:simple-audio-card,codec { 55 | + sound-dai = <&codec>; 56 | + }; 57 | + }; 58 | +}; 59 | + 60 | +&i2c { 61 | + status = "okay"; 62 | + 63 | + codec: es8388@10 { 64 | + #sound-dai-cells = <0>; 65 | + compatible = "everest,es8328"; 66 | + reg = <0x10>; 67 | + 68 | + clocks = <&clkctrl 20>; 69 | + clock-names = "refclk"; 70 | + }; 71 | }; 72 | 73 | &firmware { 74 | - reg = <0x50000 0xfb0000>; 75 | + reg = <0x50000 0x1fb0000>; 76 | }; 77 | 78 | &sdhci { 79 | -------------------------------------------------------------------------------- /openwrt.2305/sound/patch-5.15/0000-pinmux-gpio0-refclk.patch: -------------------------------------------------------------------------------- 1 | --- a/drivers/pinctrl/ralink/pinctrl-mt7620.c 2 | +++ b/drivers/pinctrl/ralink/pinctrl-mt7620.c 3 | @@ -189,7 +189,7 @@ 4 | 5 | static struct ralink_pmx_func gpio_grp_mt76x8[] = { 6 | FUNC("pcie", 3, 11, 1), 7 | - FUNC("refclk", 2, 11, 1), 8 | + FUNC("gpio refclk", 2, 11, 1), 9 | FUNC("gpio", 1, 11, 1), 10 | FUNC("gpio", 0, 11, 1), 11 | }; 12 | @@ -333,7 +333,7 @@ 13 | 1, MT76X8_GPIO_MODE_CS1), 14 | GRP_G("spis", spis_grp_mt76x8, MT76X8_GPIO_MODE_MASK, 15 | 1, MT76X8_GPIO_MODE_SPIS), 16 | - GRP_G("gpio", gpio_grp_mt76x8, MT76X8_GPIO_MODE_MASK, 17 | + GRP_G("gpio0", gpio_grp_mt76x8, MT76X8_GPIO_MODE_MASK, 18 | 1, MT76X8_GPIO_MODE_GPIO), 19 | GRP_G("wled_an", wled_an_grp_mt76x8, MT76X8_GPIO_MODE_MASK, 20 | 1, MT76X8_GPIO_MODE_WLED_AN), 21 | -------------------------------------------------------------------------------- /openwrt.2305/sound/patch-5.15/900-ASoC-soc-pcm-add-option-to-start-DMA-after-DAI.patch: -------------------------------------------------------------------------------- 1 | From 54fc4b72b630e1cb92a21140084c6852babbb234 Mon Sep 17 00:00:00 2001 2 | From: Claudiu Beznea 3 | Date: Tue, 28 Feb 2023 13:01:43 +0200 4 | Subject: [PATCH 1/1] ASoC: soc-pcm: add option to start DMA after DAI 5 | 6 | Add option to start DMA component after DAI trigger. This is done 7 | by filling the new struct snd_soc_component_driver::start_dma_last. 8 | 9 | Signed-off-by: Claudiu Beznea 10 | Link: https://lore.kernel.org/r/20230228110145.3770525-2-claudiu.beznea@microchip.com 11 | Signed-off-by: Mark Brown 12 | --- 13 | include/sound/soc-component.h | 2 ++ 14 | sound/soc/soc-pcm.c | 27 ++++++++++++++++++++++----- 15 | 2 files changed, 24 insertions(+), 5 deletions(-) 16 | 17 | diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h 18 | index 3203d35bc8c15..0814ed1438640 100644 19 | --- a/include/sound/soc-component.h 20 | +++ b/include/sound/soc-component.h 21 | @@ -190,6 +190,8 @@ struct snd_soc_component_driver { 22 | bool use_dai_pcm_id; /* use DAI link PCM ID as PCM device number */ 23 | int be_pcm_base; /* base device ID for all BE PCMs */ 24 | 25 | + unsigned int start_dma_last; 26 | + 27 | #ifdef CONFIG_DEBUG_FS 28 | const char *debugfs_prefix; 29 | #endif 30 | diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c 31 | index 005b179a770a0..5eb056b942ce8 100644 32 | --- a/sound/soc/soc-pcm.c 33 | +++ b/sound/soc/soc-pcm.c 34 | @@ -1088,22 +1088,39 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, 35 | static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 36 | { 37 | struct snd_soc_pcm_runtime *rtd = asoc_substream_to_rtd(substream); 38 | - int ret = -EINVAL, _ret = 0; 39 | + struct snd_soc_component *component; 40 | + int ret = -EINVAL, _ret = 0, start_dma_last = 0, i; 41 | int rollback = 0; 42 | 43 | switch (cmd) { 44 | case SNDRV_PCM_TRIGGER_START: 45 | case SNDRV_PCM_TRIGGER_RESUME: 46 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: 47 | + /* Do we need to start dma last? */ 48 | + for_each_rtd_components(rtd, i, component) { 49 | + if (component->driver->start_dma_last) { 50 | + start_dma_last = 1; 51 | + break; 52 | + } 53 | + } 54 | + 55 | ret = snd_soc_link_trigger(substream, cmd, 0); 56 | if (ret < 0) 57 | goto start_err; 58 | 59 | - ret = snd_soc_pcm_component_trigger(substream, cmd, 0); 60 | - if (ret < 0) 61 | - goto start_err; 62 | + if (start_dma_last) { 63 | + ret = snd_soc_pcm_dai_trigger(substream, cmd, 0); 64 | + if (ret < 0) 65 | + goto start_err; 66 | + 67 | + ret = snd_soc_pcm_component_trigger(substream, cmd, 0); 68 | + } else { 69 | + ret = snd_soc_pcm_component_trigger(substream, cmd, 0); 70 | + if (ret < 0) 71 | + goto start_err; 72 | 73 | - ret = snd_soc_pcm_dai_trigger(substream, cmd, 0); 74 | + ret = snd_soc_pcm_dai_trigger(substream, cmd, 0); 75 | + } 76 | start_err: 77 | if (ret < 0) 78 | rollback = 1; 79 | -- 80 | 2.39.2 81 | 82 | -------------------------------------------------------------------------------- /openwrt.2305/sound/patch-5.15/902-ASoC-remove-old-trigger-ordering-method.patch: -------------------------------------------------------------------------------- 1 | From 099770e2dae04579670947aaf8b5c70ef6a4cb6a Mon Sep 17 00:00:00 2001 2 | From: Kuninori Morimoto 3 | Date: Thu, 8 Jun 2023 06:49:11 +0000 4 | Subject: [PATCH 1/1] ASoC: remove old trigger ordering method 5 | 6 | All drivers switch to use generic trigger ordering method. 7 | Let's remove old method. 8 | 9 | Signed-off-by: Kuninori Morimoto 10 | Link: https://lore.kernel.org/r/87legufnyy.wl-kuninori.morimoto.gx@renesas.com 11 | Signed-off-by: Mark Brown 12 | --- 13 | include/sound/soc-component.h | 2 -- 14 | include/sound/soc.h | 6 ------ 15 | sound/soc/soc-pcm.c | 10 ---------- 16 | 3 files changed, 18 deletions(-) 17 | 18 | diff --git a/include/sound/soc-component.h b/include/sound/soc-component.h 19 | index c7733382757b4..87f248a062718 100644 20 | --- a/include/sound/soc-component.h 21 | +++ b/include/sound/soc-component.h 22 | @@ -199,8 +199,6 @@ struct snd_soc_component_driver { 23 | bool use_dai_pcm_id; /* use DAI link PCM ID as PCM device number */ 24 | int be_pcm_base; /* base device ID for all BE PCMs */ 25 | 26 | - unsigned int start_dma_last; 27 | - 28 | #ifdef CONFIG_DEBUG_FS 29 | const char *debugfs_prefix; 30 | #endif 31 | diff --git a/include/sound/soc.h b/include/sound/soc.h 32 | index 49442583d46db..52bb64d427f5d 100644 33 | --- a/include/sound/soc.h 34 | +++ b/include/sound/soc.h 35 | @@ -762,12 +762,6 @@ struct snd_soc_dai_link { 36 | /* Do not create a PCM for this DAI link (Backend link) */ 37 | unsigned int ignore:1; 38 | 39 | - /* This flag will reorder stop sequence. By enabling this flag 40 | - * DMA controller stop sequence will be invoked first followed by 41 | - * CPU DAI driver stop sequence 42 | - */ 43 | - unsigned int stop_dma_first:1; 44 | - 45 | #ifdef CONFIG_SND_SOC_TOPOLOGY 46 | struct snd_soc_dobj dobj; /* For topology */ 47 | #endif 48 | diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c 49 | index a10c928debe3c..fd45a7433c24f 100644 50 | --- a/sound/soc/soc-pcm.c 51 | +++ b/sound/soc/soc-pcm.c 52 | @@ -1111,16 +1111,6 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) 53 | stop < 0 || stop >= SND_SOC_TRIGGER_ORDER_MAX) 54 | return -EINVAL; 55 | 56 | - /* REMOVE ME */ 57 | - for_each_rtd_components(rtd, i, component) { 58 | - if (component->driver->start_dma_last) { 59 | - start = SND_SOC_TRIGGER_ORDER_LDC; 60 | - break; 61 | - } 62 | - } 63 | - if (rtd->dai_link->stop_dma_first) 64 | - stop = SND_SOC_TRIGGER_ORDER_LDC; 65 | - 66 | /* 67 | * START 68 | */ 69 | -- 70 | 2.39.2 71 | 72 | -------------------------------------------------------------------------------- /openwrt.2305/sound/patch-5.15/903-ASOC-mt7620-specify-trigger-stop.patch: -------------------------------------------------------------------------------- 1 | Index: linux-5.15.153/sound/soc/ralink/ralink-i2s.c 2 | =================================================================== 3 | --- linux-5.15.153.orig/sound/soc/ralink/ralink-i2s.c 4 | +++ linux-5.15.153/sound/soc/ralink/ralink-i2s.c 5 | @@ -536,6 +536,7 @@ static const struct snd_dmaengine_pcm_co 6 | 7 | static const struct snd_soc_component_driver ralink_i2s_component = { 8 | .name = DRV_NAME, 9 | + .trigger_stop = SND_SOC_TRIGGER_ORDER_LDC, 10 | }; 11 | 12 | static bool ralink_i2s_readable_reg(struct device *dev, unsigned int reg) 13 | -------------------------------------------------------------------------------- /openwrt.2305/video/openwrt/vocore2-enable-video.patch: -------------------------------------------------------------------------------- 1 | diff --git a/package/kernel/linux/modules/video.mk b/package/kernel/linux/modules/video.mk 2 | index f1e61f33a5..a0490e9b61 100644 3 | --- a/package/kernel/linux/modules/video.mk 4 | +++ b/package/kernel/linux/modules/video.mk 5 | @@ -277,7 +277,8 @@ define KernelPackage/drm-kms-helper 6 | +kmod-fb-cfb-fillrect +kmod-fb-cfb-imgblt +kmod-fb-sys-ram 7 | KCONFIG:= \ 8 | CONFIG_DRM_KMS_HELPER \ 9 | - CONFIG_DRM_KMS_FB_HELPER=y 10 | + CONFIG_DRM_KMS_FB_HELPER=y \ 11 | + CONFIG_DRM_FBDEV_OVERALLOC=100 12 | FILES:=$(LINUX_DIR)/drivers/gpu/drm/drm_kms_helper.ko 13 | AUTOLOAD:=$(call AutoProbe,drm_kms_helper) 14 | endef 15 | @@ -288,6 +289,20 @@ endef 16 | 17 | $(eval $(call KernelPackage,drm-kms-helper)) 18 | 19 | +define KernelPackage/drm-gem-shmem-helper 20 | + SUBMENU:=$(VIDEO_MENU) 21 | + TITLE:=GEM shmem helper 22 | + DEPENDS:=@DISPLAY_SUPPORT +kmod-drm +kmod-drm-kms-helper +kmod-backlight 23 | + KCONFIG:= \ 24 | + CONFIG_DRM_GEM_SHMEM_HELPER=y 25 | +endef 26 | + 27 | +define KernelPackage/drm-gem-shmem-helper/description 28 | + DRM GEM shmem helper. 29 | +endef 30 | + 31 | +$(eval $(call KernelPackage,drm-gem-shmem-helper)) 32 | + 33 | define KernelPackage/drm-amdgpu 34 | SUBMENU:=$(VIDEO_MENU) 35 | TITLE:=AMDGPU DRM support 36 | 37 | -------------------------------------------------------------------------------- /openwrt.2305/video/package/mpro/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | include $(INCLUDE_DIR)/kernel.mk 3 | 4 | PKG_NAME:=mpro 5 | PKG_VERSION:=v1 6 | PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) 7 | 8 | include $(INCLUDE_DIR)/package.mk 9 | 10 | define KernelPackage/mpro 11 | TITLE:=MPRO DRM driver 12 | FILES:=$(PKG_BUILD_DIR)/mpro.ko 13 | SECTION:=vocore2 14 | CATEGORY:=VoCore2 15 | KCONFIG:= \ 16 | CONFIG_DRM_FBDEV_EMULATION=y 17 | AUTOLOAD:=$(call AutoLoad,99,mpro) 18 | DEPENDS:=+kmod-drm +kmod-drm-kms-helper +kmod-drm-gem-shmem-helper +kmod-usb-core 19 | endef 20 | 21 | define KernelPackage/mpro/description 22 | MPRO DRM driver. 23 | endef 24 | 25 | MAKE_OPTS := \ 26 | ARCH="$(LINUX_KARCH)" \ 27 | CROSS_COMPILE="$(TARGET_CROSS)" \ 28 | SUBDIRS="$(PKG_BUILD_DIR)" \ 29 | M="$(PKG_BUILD_DIR)" 30 | 31 | define Build/Prepare 32 | mkdir -p $(PKG_BUILD_DIR) 33 | $(CP) ./src/* $(PKG_BUILD_DIR)/ 34 | endef 35 | 36 | define Build/Compile 37 | $(MAKE) -C "$(LINUX_DIR)" $(MAKE_OPTS) modules 38 | endef 39 | 40 | $(eval $(call KernelPackage,mpro)) 41 | -------------------------------------------------------------------------------- /openwrt.2305/video/package/mpro/src/Makefile: -------------------------------------------------------------------------------- 1 | obj-m += mpro.o 2 | -------------------------------------------------------------------------------- /openwrt.2305/video/patch-5.15/904-openwrt-drm-hack.patch: -------------------------------------------------------------------------------- 1 | Index: linux-5.15.153/drivers/gpu/drm/Kconfig 2 | =================================================================== 3 | --- linux-5.15.153.orig/drivers/gpu/drm/Kconfig 4 | +++ linux-5.15.153/drivers/gpu/drm/Kconfig 5 | @@ -80,7 +80,7 @@ config DRM_DEBUG_SELFTEST 6 | If in doubt, say "N". 7 | 8 | config DRM_KMS_HELPER 9 | - tristate 10 | + tristate "KMS helper" 11 | depends on DRM 12 | help 13 | CRTC helpers for KMS drivers. 14 | @@ -210,7 +210,7 @@ config DRM_KMS_CMA_HELPER 15 | Choose this if you need the KMS CMA helper functions 16 | 17 | config DRM_GEM_SHMEM_HELPER 18 | - bool 19 | + bool "SHMEM helper" 20 | depends on DRM 21 | help 22 | Choose this if you need the GEM shmem helper functions 23 | -------------------------------------------------------------------------------- /openwrt.2305/vocore2-default-banner.patch: -------------------------------------------------------------------------------- 1 | diff --git a/package/base-files/files/etc/banner b/package/base-files/files/etc/banner 2 | index f3af3c014f..8a41d28756 100644 3 | --- a/package/base-files/files/etc/banner 4 | +++ b/package/base-files/files/etc/banner 5 | @@ -1,8 +1,9 @@ 6 | - _______ ________ __ 7 | - | |.-----.-----.-----.| | | |.----.| |_ 8 | - | - || _ | -__| || | | || _|| _| 9 | - |_______|| __|_____|__|__||________||__| |____| 10 | - |__| W I R E L E S S F R E E D O M 11 | + _ __ ______ ___ 12 | + | | / /____ / ____/____ _____ ___ |__ \ 13 | + | | / // __ \ / / / __ \ / ___// _ \ __/ / 14 | + | |/ // /_/ // /___ / /_/ // / / __// __/ 15 | + |___/ \____/ \____/ \____//_/ \___//____/ 16 | + 17 | ----------------------------------------------------- 18 | %D %V, %C 19 | ----------------------------------------------------- 20 | -------------------------------------------------------------------------------- /openwrt.2305/vocore2-default-password.patch: -------------------------------------------------------------------------------- 1 | --- a/package/base-files/files/etc/shadow 2 | +++ b/package/base-files/files/etc/shadow 3 | @@ -1,4 +1,4 @@ 4 | -root:::0:99999:7::: 5 | +root:$1$29tD8ir5$iStWCLZgBBK4IjdsdUb6H1:19989:0:99999:7::: 6 | daemon:*:0:0:99999:7::: 7 | ftp:*:0:0:99999:7::: 8 | network:*:0:0:99999:7::: 9 | -------------------------------------------------------------------------------- /openwrt.2305/vocore2-default-wireless.patch: -------------------------------------------------------------------------------- 1 | --- a/package/kernel/mac80211/files/lib/wifi/mac80211.sh 2 | +++ b/package/kernel/mac80211/files/lib/wifi/mac80211.sh 3 | @@ -203,13 +203,13 @@ detect_mac80211() { 4 | set wireless.${name}.channel=${channel} 5 | set wireless.${name}.band=${mode_band} 6 | set wireless.${name}.htmode=$htmode 7 | - set wireless.${name}.disabled=1 8 | + set wireless.${name}.disabled=0 9 | 10 | set wireless.default_${name}=wifi-iface 11 | set wireless.default_${name}.device=${name} 12 | set wireless.default_${name}.network=lan 13 | set wireless.default_${name}.mode=ap 14 | - set wireless.default_${name}.ssid=OpenWrt 15 | + set wireless.default_${name}.ssid=VoCore2-`hexdump -C /dev/mtd2 | head -1 | awk '{print $9$10$11}'` 16 | set wireless.default_${name}.encryption=none 17 | EOF 18 | uci -q commit wireless 19 | -------------------------------------------------------------------------------- /openwrt.2305/vocore2-devicetree-sdcard.patch: -------------------------------------------------------------------------------- 1 | --- a/target/linux/ramips/dts/mt7628an_vocore_vocore2.dts 2 | +++ b/target/linux/ramips/dts/mt7628an_vocore_vocore2.dts 3 | @@ -60,3 +60,8 @@ 4 | }; 5 | }; 6 | }; 7 | + 8 | +&sdhci { 9 | + status = "okay"; 10 | + mediatek,cd-poll; 11 | +}; 12 | -------------------------------------------------------------------------------- /openwrt.2410/vocore2-default-banner.patch: -------------------------------------------------------------------------------- 1 | diff --git a/package/base-files/files/etc/banner b/package/base-files/files/etc/banner 2 | index f3af3c014f..8a41d28756 100644 3 | --- a/package/base-files/files/etc/banner 4 | +++ b/package/base-files/files/etc/banner 5 | @@ -1,8 +1,9 @@ 6 | - _______ ________ __ 7 | - | |.-----.-----.-----.| | | |.----.| |_ 8 | - | - || _ | -__| || | | || _|| _| 9 | - |_______|| __|_____|__|__||________||__| |____| 10 | - |__| W I R E L E S S F R E E D O M 11 | + _ __ ______ ___ 12 | + | | / /____ / ____/____ _____ ___ |__ \ 13 | + | | / // __ \ / / / __ \ / ___// _ \ __/ / 14 | + | |/ // /_/ // /___ / /_/ // / / __// __/ 15 | + |___/ \____/ \____/ \____//_/ \___//____/ 16 | + 17 | ----------------------------------------------------- 18 | %D %V, %C 19 | ----------------------------------------------------- 20 | -------------------------------------------------------------------------------- /openwrt.2410/vocore2-default-password.patch: -------------------------------------------------------------------------------- 1 | --- a/package/base-files/files/etc/shadow 2 | +++ b/package/base-files/files/etc/shadow 3 | @@ -1,4 +1,4 @@ 4 | -root:::0:99999:7::: 5 | +root:$1$29tD8ir5$iStWCLZgBBK4IjdsdUb6H1:19989:0:99999:7::: 6 | daemon:*:0:0:99999:7::: 7 | ftp:*:0:0:99999:7::: 8 | network:*:0:0:99999:7::: 9 | -------------------------------------------------------------------------------- /openwrt.2410/vocore2-default-wireless.patch: -------------------------------------------------------------------------------- 1 | --- a/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc 2 | +++ b/package/network/config/wifi-scripts/files/lib/wifi/mac80211.uc 3 | @@ -98,13 +98,13 @@ 4 | set ${s}.htmode='${htmode}' 5 | set ${s}.country='${country || ''}' 6 | set ${s}.num_global_macaddr='${num_global_macaddr || ''}' 7 | -set ${s}.disabled='${defaults ? 0 : 1}' 8 | +set ${s}.disabled='${defaults ? 1 : 0}' 9 | 10 | set ${si}=wifi-iface 11 | set ${si}.device='${name}' 12 | set ${si}.network='lan' 13 | set ${si}.mode='ap' 14 | -set ${si}.ssid='${defaults?.ssid || "OpenWrt"}' 15 | +set ${si}.ssid='${defaults?.ssid || "VoCore2"}' 16 | set ${si}.encryption='${defaults?.encryption || "none"}' 17 | set ${si}.key='${defaults?.key || ""}' 18 | 19 | -------------------------------------------------------------------------------- /openwrt.2410/vocore2-devicetree-sdcard.patch: -------------------------------------------------------------------------------- 1 | --- a/target/linux/ramips/dts/mt7628an_vocore_vocore2.dts 2 | +++ b/target/linux/ramips/dts/mt7628an_vocore_vocore2.dts 3 | @@ -60,3 +60,8 @@ 4 | }; 5 | }; 6 | }; 7 | + 8 | +&sdhci { 9 | + status = "okay"; 10 | + mediatek,cd-poll; 11 | +}; 12 | -------------------------------------------------------------------------------- /tools/README.md: -------------------------------------------------------------------------------- 1 | # some tools use for embedded develop 2 | 3 | - makeself: encode binary file use hex string, and create self extra script 4 | -------------------------------------------------------------------------------- /tools/makeself: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -eu 3 | if [ "$#" != "2" ] 4 | then 5 | echo "Usage: $0 filein fileout" 6 | exit 1 7 | fi 8 | SELF=$(realpath $0) 9 | FILEIN=${1} 10 | FILEOUT=${2} 11 | PAYLOAD_LINE=$(awk '/^__TEMPLATE__/ { print NR + 1; exit 0; }' $SELF) 12 | tail -n +$PAYLOAD_LINE $SELF > $FILEOUT 13 | md5sum $FILEIN >> $FILEOUT 14 | cat $FILEIN | od -v -A n --endian=big -t x1 | tr -d ' \n' >> $FILEOUT 15 | chmod +x $FILEOUT 16 | exit 0 17 | __TEMPLATE__ 18 | #!/bin/sh 19 | tail -n +8 $0 | while read -n 2 hex 20 | do 21 | echo -ne "\x$hex" >> $1 22 | done 23 | exit 0 24 | -------------------------------------------------------------------------------- /uboot/vocore2_defconfig: -------------------------------------------------------------------------------- 1 | CONFIG_MIPS=y 2 | CONFIG_SKIP_LOWLEVEL_INIT=y 3 | CONFIG_SYS_MALLOC_LEN=0x1000000 4 | CONFIG_SPL_LIBCOMMON_SUPPORT=y 5 | CONFIG_SPL_LIBGENERIC_SUPPORT=y 6 | CONFIG_OPTIMIZE_INLINING=y 7 | CONFIG_SPL_OPTIMIZE_INLINING=y 8 | CONFIG_CC_OPTIMIZE_FOR_SIZE=y 9 | CONFIG_NR_DRAM_BANKS=1 10 | CONFIG_ENV_SIZE=0x1000 11 | CONFIG_ENV_OFFSET=0x30000 12 | CONFIG_ENV_SECT_SIZE=0x10000 13 | CONFIG_ENV_VARS_UBOOT_CONFIG=y 14 | CONFIG_REMAKE_ELF=y # generate elf file with devictree append, allow run in qemu 15 | CONFIG_DEFAULT_DEVICE_TREE="vocore_vocore2" 16 | CONFIG_SYS_BOOTCOUNT_ADDR=0xb000006c 17 | CONFIG_SPL_SYS_MALLOC_F_LEN=0x40000 18 | CONFIG_SPL=y 19 | CONFIG_SYS_BOOTCOUNT_SINGLEWORD=y 20 | CONFIG_ARCH_MTMIPS=y 21 | CONFIG_SOC_MT7628=y 22 | CONFIG_BOARD_VOCORE2=y 23 | CONFIG_MIPS_CACHE_SETUP=y 24 | CONFIG_MIPS_CACHE_DISABLE=y 25 | CONFIG_RESTORE_EXCEPTION_VECTOR_BASE=y 26 | CONFIG_MIPS_BOOT_FDT=y 27 | CONFIG_SYS_BOOT_GET_CMDLINE=y 28 | CONFIG_SYS_BOOT_GET_KBD=y 29 | CONFIG_SYS_LOAD_ADDR=0x81000000 30 | # CONFIG_FIT is not set 31 | # CONFIG_FIT_SIGNATURE is not set 32 | CONFIG_LEGACY_IMAGE_FORMAT=y 33 | CONFIG_OF_STDOUT_VIA_ALIAS=y 34 | CONFIG_LOGLEVEL=8 35 | # CONFIG_DISPLAY_BOARDINFO is not set 36 | # CONFIG_DISPLAY_BOARDINFO_LATE is not set 37 | CONFIG_SPL_SYS_MALLOC_SIMPLE=y 38 | CONFIG_SPL_NOR_SUPPORT=y 39 | # CONFIG_HUSH_PARSER is not set 40 | # CONFIG_CMDLINE_EDITING is not set 41 | # CONFIG_AUTO_COMPLETE is not set 42 | # CONFIG_SYS_LONGHELP is not set 43 | # CONFIG_SYS_XTRACE is not set 44 | # CONFIG_CMD_LICENSE is not set 45 | # CONFIG_CMD_LOADS is not set 46 | # CONFIG_CMD_CONSOLE is not set 47 | # CONFIG_CMD_BDI is not set 48 | # CONFIG_CMD_RANDOM is not set 49 | CONFIG_BOOTM_LINUX=y 50 | CONFIG_BOOTM_NETBSD=y 51 | CONFIG_BOOTM_PLAN9=y 52 | # CONFIG_BOOTM_RTEMS is not set 53 | # CONFIG_BOOTM_VXWORKS is not set 54 | # CONFIG_CMD_ELF is not set 55 | # CONFIG_CMD_XIMG is not set 56 | # CONFIG_CMD_CRC32 is not set 57 | # CONFIG_ISO_PARTITION is not set 58 | # CONFIG_SPL_DOS_PARTITION is not set 59 | # CONFIG_INPUT is not set 60 | # CONFIG_POWER is not set 61 | CONFIG_DOS_PARTITION=y 62 | CONFIG_CMD_MEMINFO=y 63 | CONFIG_CMD_FLASH=y 64 | CONFIG_CMD_GPIO=y 65 | CONFIG_CMD_MMC=y 66 | CONFIG_CMD_MTD=y 67 | # CONFIG_CMD_PART is not set 68 | CONFIG_CMD_SPI=y 69 | CONFIG_CMD_USB=y 70 | CONFIG_CMD_WDT=y 71 | CONFIG_NET=y 72 | CONFIG_CMD_TFTPBOOT=y 73 | # CONFIG_CMD_BOOTP is not set 74 | # CONFIG_CMD_NFS is not set 75 | CONFIG_CMD_FAT=y 76 | # CONFIG_CMD_FS_GENERIC is not set 77 | CONFIG_CMD_MTDPARTS=y 78 | CONFIG_MTDIDS_DEFAULT="nor0=spi0.0" 79 | CONFIG_MTDPARTS_DEFAULT="spi0.0:192k(u-boot),64k(env),64k(factory),-(kernel)" 80 | CONFIG_ENV_IS_IN_SPI_FLASH=y 81 | CONFIG_SYS_RELOC_GD_ENV_ADDR=y 82 | CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG=y 83 | # CONFIG_VERSION_VARIABLE is not set 84 | CONFIG_NET_RANDOM_ETHADDR=y 85 | CONFIG_SPL_DM=y 86 | # CONFIG_DM_DEVICE_REMOVE is not set 87 | CONFIG_BOOTCOUNT_LIMIT=y 88 | # CONFIG_LED is not set 89 | # CONFIG_LED_BLINK is not set 90 | # CONFIG_LED_GPIO is not set 91 | # CONFIG_CMD_LED is not set 92 | CONFIG_MMC=y 93 | # CONFIG_MMC_HW_PARTITIONING is not set 94 | # CONFIG_SPL_DM_MMC is not set 95 | CONFIG_MMC_MTK=y 96 | CONFIG_MTD=y 97 | CONFIG_SPI_FLASH_SFDP_SUPPORT=y 98 | CONFIG_SPI_FLASH_GIGADEVICE=y 99 | CONFIG_SPI_FLASH_MACRONIX=y 100 | CONFIG_SPI_FLASH_SPANSION=y 101 | CONFIG_SPI_FLASH_STMICRO=y 102 | CONFIG_SPI_FLASH_WINBOND=y 103 | CONFIG_SPI_FLASH_MTD=y 104 | CONFIG_MT7628_ETH=y 105 | CONFIG_PHY=y 106 | CONFIG_MT76X8_USB_PHY=y 107 | CONFIG_SPECIFY_CONSOLE_INDEX=y 108 | CONFIG_CONS_INDEX=3 109 | CONFIG_SPI=y 110 | CONFIG_MT7621_SPI=y 111 | CONFIG_USB=y 112 | CONFIG_USB_EHCI_HCD=y 113 | CONFIG_USB_EHCI_GENERIC=y 114 | CONFIG_USB_STORAGE=y 115 | CONFIG_WDT=y 116 | CONFIG_WDT_MT7621=y 117 | CONFIG_FAT_WRITE=y 118 | CONFIG_LZMA=y 119 | CONFIG_SPL_LZMA=y 120 | # CONFIG_REGEX is not set 121 | CONFIG_SYS_MIPS_TIMER_FREQ=290000000 122 | CONFIG_SPL_BSS_START_ADDR=0x80010000 123 | CONFIG_SPL_BSS_MAX_SIZE=0x10000 124 | -------------------------------------------------------------------------------- /utils/ated/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # hua.shao@mediatek.com 3 | # 4 | # MTK Property Software. 5 | # 6 | 7 | include $(TOPDIR)/rules.mk 8 | 9 | PKG_NAME:=ated 10 | PKG_RELEASE:=1 11 | 12 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) 13 | PKG_KCONFIG:=RALINK_MT7620 RALINK_MT7621 RALINK_MT7628 14 | PKG_CONFIG_DEPENDS:=$(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),CONFIG_$(c))) 15 | 16 | 17 | include $(INCLUDE_DIR)/package.mk 18 | include $(INCLUDE_DIR)/kernel.mk 19 | 20 | define Package/ated 21 | SECTION:=vocore2 22 | CATEGORY:=VoCore2 23 | TITLE:=ATE Daemon 24 | endef 25 | 26 | define Package/ated/description 27 | ATE Daemon 28 | endef 29 | 30 | define Build/Prepare 31 | mkdir -p $(PKG_BUILD_DIR) 32 | $(CP) ./src/* $(PKG_BUILD_DIR)/ 33 | endef 34 | 35 | TARGET_CFLAGS += \ 36 | $(foreach c, $(PKG_KCONFIG),$(if $(CONFIG_$c),-DCONFIG_$(c)=$(CONFIG_$c))) 37 | 38 | #MAKE_FLAGS += \ 39 | CFLAGS="$(TARGET_CFLAGS)" 40 | 41 | define Package/ated/install 42 | $(INSTALL_DIR) $(1)/bin 43 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/ated $(1)/bin 44 | endef 45 | 46 | 47 | $(eval $(call BuildPackage,ated)) 48 | 49 | -------------------------------------------------------------------------------- /utils/ated/src/Makefile: -------------------------------------------------------------------------------- 1 | ################################################################# 2 | # Compile Options 3 | # v - 1:Old Agent,2:Agent with new packet format 4 | # P = 1 for PC, p = 2 for APSOC 5 | # m = 1 for pthread, m = 2 for fork, m = 3 for IPC socket 6 | # Note: 7 | # If you use v=1, then m=0 8 | ################################################################# 9 | v ?= 2 10 | m ?= 3#APSOC has SDK dependency please use 3 11 | ################################################################# 12 | AGENT_VERSION = $(v) 13 | MULTI_PROC = $(m) 14 | #ifeq ($(PLATFORM),2) 15 | #NVDIR = $(ROOTDIR)/lib/libnvram 16 | #CFLAGS += -I$(NVDIR) 17 | #LDFLAGS += -lnvram 18 | #endif 19 | 20 | EXEC = ated 21 | SRCS = ate.c 22 | INCLUDE = ./include 23 | THREAD_MODEL = ./thread_model 24 | IOCTL = ./os_ioctl 25 | CMD_IO = ./cmd_io 26 | ifeq ($(AGENT_VERSION),2) 27 | SRCS = ate-ext.c 28 | ETH = $(CMD_IO)/eth.c 29 | DRI = $(IOCTL)/ioctl2driver.c 30 | endif 31 | CFLAGS += -I$(INCLUDE) 32 | #EXTRA_CFLAGS += -DDBG 33 | ########################### PLATFROM RELATED ################################ 34 | #PLATFORM = 5VT 35 | #PLATFORM = STAR 36 | #PLATFORM = INF_TWINPASS 37 | #PLATFORM = BROADCOM 38 | PLATFORM = APSOC 39 | #PLATFORM = TC3162U 40 | #PLATFORM = PC 41 | 42 | ifeq ($(PLATFORM),5VT) 43 | #Please fix the PATH to fit your environment... 44 | CROSS_COMPILE = /opt/crosstool/uClibc/bin/arm-linux- 45 | endif 46 | 47 | ifeq ($(PLATFORM),STAR) 48 | #Please fix the PATH to fit your environment... 49 | CROSS_COMPILE = /opt/star/tools/arm-linux/bin/arm-linux- 50 | endif 51 | 52 | ifeq ($(PLATFORM),INF_TWINPASS) 53 | #Please fix the PATH to fit your environment... 54 | CROSS_COMPILE = /opt/uclibc-toolchain/ifx-lxdb-1-1/gcc-3.3.6/toolchain-mips/bin/mips-linux-uclibc- 55 | EXTRA_CFLAGS += -Dbig_endian 56 | endif 57 | 58 | ifeq ($(PLATFORM),BROADCOM) 59 | #Please fix the PATH to fit your environment... 60 | CROSS_COMPILE = /opt/uclibc-toolchain/bin/mips-linux-uclibc- 61 | EXTRA_CFLAGS += -Dbig_endian 62 | endif 63 | 64 | ifeq ($(PLATFORM), TC3162U) 65 | STRIP = $(CROSS_COMPILE)strip 66 | EXTRA_CFLAGS += -Dbig_endian 67 | endif 68 | 69 | ifeq ($(PLATFORM),APSOC) 70 | CROSS_COMPILE += -DMT_ATED_APSOC 71 | endif 72 | 73 | ifeq ($(PLATFORM),PC) 74 | CROSS_COMPILE = 75 | endif 76 | ################# Thread Model ############################### 77 | ifeq ($(MULTI_PROC),1) 78 | $(info ************ MULTI-PROCESS WITH PTHREAD ************) 79 | EXTRA_CFLAGS += -DMT_ATED_THREAD=1 80 | LDFLAGS += -pthread 81 | MULTI = $(THREAD_MODEL)/multi_thread.c 82 | endif 83 | ifeq ($(MULTI_PROC),2) 84 | $(info ************ MULTI-PROCESS WITH FORK ************) 85 | EXTRA_CFLAGS += -DMT_ATED_SHM=1 86 | LDLIBS += -lrt 87 | LDFLAGS += -pthread 88 | MULTI = $(THREAD_MODEL)/multi_fork.c 89 | endif 90 | ifeq ($(MULTI_PROC),3) 91 | $(info ************ MULTI-PROCESS WITH IPC SOCKET ************) 92 | EXTRA_CFLAGS += -DMT_ATED_IPC_SOCK=1 93 | MULTI = $(THREAD_MODEL)/ipc_socket.c 94 | endif 95 | 96 | ################## Main ############################### 97 | CC := $(CROSS_COMPILE)gcc 98 | LD := $(CROSS_COMPILE)ld 99 | 100 | all: $(EXEC) 101 | 102 | ifeq ($(PLATFORM),PC) 103 | ifeq ($(AGENT_VERSION),1) 104 | $(EXEC): $(SRCS) 105 | $(CC) -v -Wall -Werror $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ $(SRCS) $(LDLIBS) 106 | else 107 | $(EXEC): $(SRCS) $(ETH) $(DRI) $(MULTI) 108 | $(CC) -v -Wall -Werror $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ $(SRCS) $(ETH) $(DRI) $(MULTI) $(LDLIBS) 109 | endif# Version 110 | else 111 | ifeq ($(PLATFORM),APSOC) 112 | ifeq ($(AGENT_VERSION),1) 113 | $(EXEC): $(SRCS) 114 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ $(SRCS) $(LDLIBS) 115 | else 116 | $(EXEC): $(SRCS) $(ETH) $(DRI) $(MULTI) 117 | $(CC) -v -Wall $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ $(SRCS) $(ETH) $(DRI) $(MULTI) $(LDLIBS) 118 | endif#Version 119 | else 120 | ifeq ($(AGENT_VERSION),1) 121 | $(EXEC): $(SRCS) 122 | $(CC) -v -Wall $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ $(SRCS) $(LDLIBS) 123 | cp ated /tftpboot 124 | else 125 | $(EXEC): $(SRCS) $(ETH) $(DRI) $(MULTI) 126 | $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(LDFLAGS) -o $@ $(SRCS) $(ETH) $(DRI) $(MULTI) $(LDLIBS) 127 | ifeq ($(PLATFORM), TC3162U) 128 | $(STRIP) -s $(EXEC) 129 | else 130 | cp ated /tftpboot 131 | endif 132 | endif#Version 133 | endif 134 | endif 135 | 136 | 137 | 138 | clean: 139 | -rm -f $(EXEC) *.o 140 | 141 | -------------------------------------------------------------------------------- /utils/ated/src/cmd_io/eth.c: -------------------------------------------------------------------------------- 1 | #include "precomp.h" 2 | int sock_eth = -1; 3 | unsigned char packet[PKT_BUF_SIZE]; 4 | static const char broadcast_addr[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 5 | static char my_eth_addr[6]; 6 | struct HOST_IF *hfd; 7 | static int if_index; 8 | 9 | int init_eth(struct HOST_IF *fd,char *bridge_ifname) 10 | { 11 | struct ifreq ifr; 12 | struct sockaddr_ll addr; 13 | int s; 14 | s = socket(AF_INET, SOCK_DGRAM, 0); 15 | if ((sock_eth=socket(PF_PACKET, SOCK_RAW, cpu2be16/*htons*/(ETH_P_RACFG))) < 0) 16 | { 17 | perror("socket"); 18 | return -1; 19 | } 20 | 21 | os_memset(&ifr, 0, sizeof(ifr)); 22 | #ifdef CONFIG_LAN_WAN_SUPPORT 23 | os_memcpy(ifr.ifr_name, "eth0.1" , 7); 24 | #else 25 | os_memcpy(ifr.ifr_name, bridge_ifname , os_strlen(bridge_ifname)); 26 | #endif 27 | if (ioctl(sock_eth, SIOCGIFINDEX, &ifr) != 0) 28 | { 29 | perror("ioctl(SIOCGIFINDEX)(eth_sock)"); 30 | goto close; 31 | } 32 | 33 | os_memset(&addr, 0, sizeof(addr)); 34 | addr.sll_family = AF_PACKET; 35 | addr.sll_ifindex = ifr.ifr_ifindex; 36 | if_index = ifr.ifr_ifindex; 37 | 38 | if (bind(sock_eth, (struct sockaddr *) &addr, sizeof(addr)) < 0) 39 | { 40 | perror("bind"); 41 | goto close; 42 | } 43 | 44 | os_memset(&ifr.ifr_hwaddr.sa_data, 0, ETH_ALEN); 45 | /*get the eth_addr from kernel and put it into ifreq structure*/ 46 | if (ioctl(sock_eth, SIOCGIFHWADDR, &ifr) != 0) 47 | { 48 | perror("ioctl(SIOCGIFHWADDR)(eth_sock)"); 49 | goto close; 50 | } 51 | if(fd->need_set_mac){ 52 | os_memcpy(&ifr.ifr_hwaddr.sa_data, &fd->ownmac, ETH_ALEN); 53 | ate_printf(MSG_INFO,"Set Own Mac: %02x:%02x:%02x:%02x:%02x:%02x\n", (unsigned char) ifr.ifr_hwaddr.sa_data[0], (unsigned char) ifr.ifr_hwaddr.sa_data[1], (unsigned char) ifr.ifr_hwaddr.sa_data[2], (unsigned char) ifr.ifr_hwaddr.sa_data[3], (unsigned char) ifr.ifr_hwaddr.sa_data[4], (unsigned char) ifr.ifr_hwaddr.sa_data[5]); 54 | if (ioctl(s, SIOCSIFHWADDR, &ifr) != 0) 55 | { 56 | perror("ioctl(SIOCSIFHWADDR)(eth_sock)"); 57 | goto close; 58 | } 59 | ifr.ifr_flags |= IFF_PROMISC; 60 | if( ioctl(s, SIOCSIFFLAGS, &ifr) != 0 ) 61 | { 62 | perror("ioctl for IFF_PROMISC failed."); 63 | return (-1); 64 | } 65 | } 66 | os_memcpy(my_eth_addr, ifr.ifr_hwaddr.sa_data, 6); 67 | 68 | ate_printf(MSG_INFO,"Open Ethernet socket success\n"); 69 | fd->rev_cmd = &rev_cmd_eth; 70 | fd->rsp2host = &rsp2host_eth; 71 | fd->close = &close_eth; 72 | hfd = fd; 73 | os_memset(hfd->da, 0, ETH_ALEN); 74 | return sock_eth; 75 | close: 76 | close(sock_eth); 77 | return (-1); 78 | } 79 | 80 | int rev_cmd_eth(unsigned char *buf, int size) 81 | { 82 | int recv_len = recvfrom(sock_eth, packet, PKT_BUF_SIZE, 0, NULL, NULL); 83 | struct ethhdr *ehdr = (struct ethhdr *)packet; 84 | if(recv_len >= (ETH_HLEN + RA_CFG_HLEN)) { 85 | if ((ehdr->h_proto == cpu2be16/*htons*/(ETH_P_RACFG)) && 86 | ((strncmp(my_eth_addr, (char *)ehdr->h_dest, 6) == 0) || 87 | (strncmp(broadcast_addr, (char *)ehdr->h_dest, 6) == 0))) 88 | { 89 | os_memcpy(buf, packet, recv_len); 90 | return recv_len - 14; 91 | } 92 | goto err; 93 | } 94 | err: 95 | ate_printf(MSG_ERROR,"packet len is too short!\n"); 96 | return 0; 97 | } 98 | 99 | int rsp2host_eth(unsigned char *data, int size) 100 | { 101 | struct ethhdr *ehdr; 102 | struct sockaddr_ll socket_address; 103 | int result = 0; 104 | int length = 0; 105 | unsigned char da[ETH_ALEN]; 106 | 107 | os_memset(da, 0, ETH_ALEN); 108 | os_memcpy(packet, data, size); 109 | /* respond to QA by broadcast frame */ 110 | ehdr = (struct ethhdr *)&packet[0]; 111 | os_memcpy(da, ehdr->h_source, ETH_ALEN); 112 | if(hfd->unicast) 113 | os_memcpy(packet, da, ETH_ALEN); 114 | else 115 | os_memcpy(&packet[0], broadcast_addr, 6); 116 | os_memcpy(ehdr->h_source, my_eth_addr, 6); 117 | ehdr->h_proto = cpu2be16/*htons*/(ETH_P_RACFG); 118 | // determine the length to send and send Ack 119 | length = size; 120 | if (length < 60) { 121 | length = 60; 122 | } else if (length > 1514) { 123 | ate_printf(MSG_ERROR,"response ethernet length is too long\n"); 124 | return -1; 125 | } 126 | socket_address.sll_family = PF_PACKET; 127 | socket_address.sll_protocol = cpu2be16/*htons*/(ETH_P_RACFG); 128 | socket_address.sll_ifindex = if_index; 129 | socket_address.sll_pkttype = PACKET_BROADCAST; 130 | socket_address.sll_hatype = ARPHRD_ETHER; 131 | socket_address.sll_halen = ETH_ALEN; 132 | 133 | bzero(&socket_address.sll_addr[0], 8); 134 | os_memcpy(&socket_address.sll_addr[0], broadcast_addr, 6); 135 | result = sendto(sock_eth, &packet[0], length, 0, (struct sockaddr *)&socket_address, sizeof(socket_address)); 136 | return result; 137 | } 138 | 139 | int close_eth() 140 | { 141 | ate_printf(MSG_DEBUG,"Ethernet Socket Is Closed\n"); 142 | close(sock_eth); 143 | return 0; 144 | } 145 | -------------------------------------------------------------------------------- /utils/ated/src/include/cmd_io/eth.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include /*Get MAC Address from kernel*/ 7 | 8 | int init_eth(struct HOST_IF *fd, char *bridge_ifname); 9 | int rev_cmd_eth(unsigned char *buf, int size); 10 | int rsp2host_eth(unsigned char *data, int size); 11 | int close_eth(); -------------------------------------------------------------------------------- /utils/ated/src/include/os_ioctl/ioctl2driver.h: -------------------------------------------------------------------------------- 1 | #include "ate.h" 2 | #include 3 | #include 4 | #include 5 | 6 | int init_if_ioctl(struct DRI_IF *fd,char *driver_ifname); 7 | int send_ioctl(struct DRI_IF *fd,unsigned char *pkt, int size); 8 | int close_ioctl(struct DRI_IF *fd); 9 | -------------------------------------------------------------------------------- /utils/ated/src/include/precomp.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #ifdef DBG 9 | #include 10 | #endif // DBG // 11 | 12 | #include 13 | #include 14 | #include 15 | #include "ate.h" 16 | #include "cmd_io/eth.h" /*For Ethernet*/ 17 | #include "os_ioctl/ioctl2driver.h" 18 | #include 19 | #include 20 | #include 21 | #ifdef MT_ATED_THREAD 22 | #include 23 | #include "thread_model/multi_thread.h" 24 | #elif MT_ATED_SHM 25 | #include "thread_model/multi_fork.h" 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #elif MT_ATED_IPC_SOCK 34 | #include "thread_model/ipc_socket.h" 35 | #endif 36 | 37 | #ifdef MT_ATED_APSOC 38 | #include "linux/autoconf.h" 39 | #include "nvram.h" 40 | #endif 41 | 42 | -------------------------------------------------------------------------------- /utils/ated/src/include/thread_model/ipc_socket.h: -------------------------------------------------------------------------------- 1 | #ifndef __MULTI_IPC_SOCK_H_ 2 | #define __MULTI_IPC_SOCK_H_ 3 | 4 | extern struct MULTI_PROC_OPS ipc_sock_ops; 5 | #define PIPE_READ 0 6 | #define PIPE_WRITE 1 7 | /* struc define */ 8 | struct MULTI_PROC_SOCK { 9 | /* Common Part for Private Data*/ 10 | struct cmd_queue q; 11 | /* IPC Socket Specific */ 12 | int pid; 13 | int fd[2]; /* 0:Read, 1:Write*/ 14 | int sock; 15 | int conn; 16 | }; 17 | /* Prototype */ 18 | int multi_proc_init(void **dri_if, int idx, int dri_if_num, void *pkt_proc_logic); 19 | int ipc_sock_insert_q(void *dri_if, unsigned char *pkt, int len); 20 | int ipc_sock_lock_q(void *dri_if); 21 | int ipc_sock_unlock_q(void *dri_if); 22 | int ipc_sock_wait_data(void *dri_if); 23 | int ipc_sock_sig_data(void *dri_if); 24 | int ipc_sock_close(void *dri_if); 25 | 26 | #endif /* End of MULTI_IPC_SOCK_H define */ 27 | -------------------------------------------------------------------------------- /utils/ated/src/include/thread_model/multi_fork.h: -------------------------------------------------------------------------------- 1 | #ifndef __MULTI_FORK_H_ 2 | #define __MULTI_FORK_H_ 3 | /* Constant Define */ 4 | #define SEM_ACC_MODE 0600 5 | #define WAIT_CMD_DELAY 5*1000 6 | //#define SHM_NOT_POSIX 1 7 | #include 8 | /* struc define */ 9 | struct MULTI_PROC_FORKS { 10 | /* Common Part for Private Data*/ 11 | struct cmd_queue q; 12 | /* Fork Specific */ 13 | int pid; 14 | #ifdef SHM_NOT_POSIX /* For shm_get */ 15 | int shmem_id; 16 | int lock; /* For semaphor Id */ 17 | #else /* For shm_open */ 18 | int shm_fd; 19 | sem_t lock; 20 | #endif 21 | }; 22 | 23 | 24 | union semun { 25 | int val; /* value for SETVAL */ 26 | struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ 27 | unsigned short *array; /* array for GETALL & SETALL */ 28 | struct seminfo *__buf; /* buffer for IPC_INFO */ 29 | void *__pad; 30 | }; 31 | /* Prototype */ 32 | int multi_proc_init(void **dri_if, int idx, int dri_if_num, void *pkt_proc_logic); 33 | int fork_insert_q(void *dri_if, unsigned char *pkt, int len); 34 | int fork_lock_q(void *dri_if); 35 | int fork_unlock_q(void *dri_if); 36 | int fork_wait_data(void *dri_if); 37 | int fork_sig_data(void *dri_if); 38 | int fork_close(void *dri_if); 39 | 40 | extern struct MULTI_PROC_OPS fork_ops; 41 | #endif /* __MULTI_FORK_H_*/ 42 | -------------------------------------------------------------------------------- /utils/ated/src/include/thread_model/multi_thread.h: -------------------------------------------------------------------------------- 1 | #ifndef __MULTI_THREAD_H_ 2 | #define __MULTI_THREAD_H_ 3 | 4 | extern struct MULTI_PROC_OPS thread_ops; 5 | /* struc define */ 6 | struct MULTI_PROC_THREADS { 7 | /* Common Part for Private Data*/ 8 | struct cmd_queue q; 9 | /* pthread Specific */ 10 | pthread_t thread; 11 | pthread_mutex_t lock; 12 | pthread_cond_t cond; 13 | }; 14 | /* Prototype */ 15 | int multi_proc_init(void **dri_if, int idx, int dri_if_num, void *pkt_proc_logic); 16 | int thread_insert_q(void *dri_if, unsigned char *pkt, int len); 17 | int thread_lock_q(void *dri_if); 18 | int thread_unlock_q(void *dri_if); 19 | int thread_wait_data(void *dri_if); 20 | int thread_sig_data(void *dri_if); 21 | int thread_close(void *dri_if); 22 | /* Variables */ 23 | //extern struct MULTI_PROC_OPS thread_ops; 24 | #if 0 25 | = { 26 | .multi_proc_init = thread_init, 27 | .multi_insert_q = thread_insert_q, 28 | .multi_lock_q = thread_lock_q, 29 | .multi_unlock_q = thread_unlock_q, 30 | .multi_wait_data = thread_wait_data, 31 | .multi_sig_data = thread_sig_data, 32 | .multi_proc_close = thread_close, 33 | }; 34 | #endif 35 | 36 | #endif /* End of MULTI_THREAD_H define */ 37 | -------------------------------------------------------------------------------- /utils/ated/src/os_ioctl/ioctl2driver.c: -------------------------------------------------------------------------------- 1 | #include "precomp.h" 2 | /* Functions */ 3 | int init_if_ioctl(struct DRI_IF *fd,char *driver_ifname) 4 | { 5 | struct ifreq ifr; 6 | fd->send = &send_ioctl; 7 | fd->close = &close_ioctl; 8 | fd->sock_ioctl = socket(AF_INET, SOCK_DGRAM, 0); 9 | if (fd->sock_ioctl < 0) { 10 | ate_printf(MSG_ERROR,"Socket error in IOCTL\n"); 11 | return 0; 12 | } 13 | 14 | os_memset(fd->ifname, 0, IFNAMSIZ+1); 15 | os_memcpy(fd->ifname, driver_ifname, os_strlen(driver_ifname)); 16 | 17 | /* Get MAC Address*/ 18 | ifr.ifr_addr.sa_family = AF_INET; 19 | os_memcpy(ifr.ifr_name , driver_ifname , os_strlen(driver_ifname)); 20 | ioctl(fd->sock_ioctl, SIOCGIFHWADDR, &ifr); 21 | os_memcpy(fd->mac, ifr.ifr_hwaddr.sa_data, 6); 22 | return fd->sock_ioctl; 23 | } 24 | 25 | int send_ioctl(struct DRI_IF *fd,unsigned char *pkt, int size) 26 | { 27 | struct iwreq pwrq; 28 | bzero(&pwrq, sizeof(pwrq)); 29 | pwrq.u.data.pointer = (caddr_t) pkt; 30 | pwrq.u.data.length = size + RA_CFG_HLEN; 31 | os_strncpy(pwrq.ifr_name, fd->ifname, IFNAMSIZ); 32 | return ioctl(fd->sock_ioctl, RTPRIV_IOCTL_ATE, &pwrq); 33 | } 34 | 35 | int close_ioctl(struct DRI_IF *fd) 36 | { 37 | int ret; 38 | 39 | ate_printf(MSG_INFO,"Close IOCTL Socket\n"); 40 | ret = close(fd->sock_ioctl); 41 | 42 | return ret; 43 | } 44 | 45 | -------------------------------------------------------------------------------- /utils/ated/src/thread_model/ipc_socket.c: -------------------------------------------------------------------------------- 1 | #include "precomp.h" 2 | /* Variables */ 3 | struct MULTI_PROC_OPS ipc_sock_ops = { 4 | .multi_proc_init = multi_proc_init, 5 | .multi_insert_q = ipc_sock_insert_q, 6 | .multi_lock_q = ipc_sock_lock_q, 7 | .multi_unlock_q = ipc_sock_unlock_q, 8 | .multi_wait_data = ipc_sock_wait_data, 9 | .multi_sig_data = ipc_sock_sig_data, 10 | .multi_proc_close = ipc_sock_close, 11 | }; 12 | #define ADDRESS "ATED_SOCK" 13 | /* Prive Function Prototype */ 14 | /* Functions */ 15 | int multi_proc_init(void **dri_if, int idx, int dri_if_num, void *pkt_proc_logic) 16 | { 17 | struct DRI_IF **a_ifs = (struct DRI_IF **)dri_if; 18 | struct DRI_IF *p_if = a_ifs[idx]; 19 | struct MULTI_PROC_SOCK *priv_data = NULL; 20 | void (*handler)(void *arg) = pkt_proc_logic; 21 | int pid; 22 | int i; 23 | 24 | priv_data =(struct MULTI_PROC_SOCK *)malloc(sizeof(struct MULTI_PROC_SOCK)); 25 | ate_printf(MSG_INFO,"%d, malloc priv_data\n", getpid()); 26 | if(!priv_data) 27 | return -1; 28 | p_if->priv_data = priv_data; 29 | /* Open PIPE */ 30 | pipe(priv_data->fd); 31 | /* Init Queue */ 32 | priv_data->q.served = 0; 33 | priv_data->q.un_served = 0; 34 | for(i=0;iq.cmd_len[i] = -1; 36 | os_memset(&priv_data->q.cmd_arr[i],0,PKT_BUF_SIZE); 37 | } 38 | pid = fork(); 39 | switch(pid){ 40 | case -1: 41 | perror("fork"); 42 | exit(1); 43 | case 0: 44 | priv_data->pid = getpid(); 45 | close(priv_data->fd[PIPE_WRITE]); 46 | break; 47 | default: 48 | priv_data->pid = pid; 49 | close(priv_data->fd[PIPE_READ]); 50 | return 0; 51 | } 52 | 53 | if(pkt_proc_logic != NULL) 54 | handler(p_if); 55 | 56 | return 0; 57 | } 58 | 59 | int ipc_sock_insert_q(void *dri_if, unsigned char *pkt, int len) 60 | { 61 | struct DRI_IF *p_if = dri_if; 62 | struct MULTI_PROC_SOCK *priv_data = (struct MULTI_PROC_SOCK *)p_if->priv_data; 63 | int out; 64 | struct cmd_queue *q = &priv_data->q; 65 | int *served = &q->served; 66 | int ret = 0; 67 | 68 | out = priv_data->fd[PIPE_WRITE]; 69 | ate_printf(MSG_DEBUG, "[%d]PIPE write %d data\n",priv_data->pid,len); 70 | ret = write(out, pkt, len); 71 | if(ret < 0){ 72 | ate_printf(MSG_ERROR, "[%d]PIPE write ERR %d\n",priv_data->pid, ret); 73 | } 74 | *served = (*served + 1)%CMD_QUEUE_SIZE; 75 | 76 | return ret; 77 | 78 | } 79 | 80 | int ipc_sock_wait_data(void *dri_if) 81 | { 82 | struct DRI_IF *p_if = (struct DRI_IF *)dri_if; 83 | struct MULTI_PROC_SOCK *priv_data = p_if->priv_data; 84 | struct cmd_queue *q = &priv_data->q; 85 | int fd = priv_data->fd[PIPE_READ]; 86 | int *un_served = &q->un_served; 87 | int count = 0; 88 | unsigned char buf[PKT_BUF_SIZE]; 89 | 90 | fd_set set; 91 | FD_ZERO(&set); 92 | FD_SET(fd, &set); 93 | count = select(FD_SETSIZE, &set, NULL, NULL, NULL); 94 | if(count == 0){ 95 | ate_printf(MSG_ERROR,"IPC_SOCK_WAIT_DATA: Nothing\n"); 96 | }else if(count < 0){ 97 | ate_printf(MSG_ERROR, "IPC_SOCK_WAIT_DATA: Error\n"); 98 | }else{ 99 | count = read(fd, buf, PKT_BUF_SIZE); 100 | if(count < 0){ 101 | if( errno != EINTR){ 102 | ate_printf(MSG_ERROR, "PIPE Read Error, errno: 0x%x\n", errno); 103 | //exit(0); 104 | }else{ 105 | ate_printf(MSG_ERROR, "PIPE Read INTERRUPTED, errno: 0x%x\n", errno); 106 | } 107 | } else if(count == 0){ 108 | return 0; 109 | } else if((q->cmd_len[*un_served])!=-1){ 110 | ate_printf(MSG_ERROR, "CMD Q is full\n"); 111 | return -1; 112 | } 113 | ate_printf(MSG_INFO, "[%d]PIPE Read %d bytes\n",getpid(),count); 114 | os_memcpy(q->cmd_arr[*un_served], buf, PKT_BUF_SIZE); 115 | q->cmd_len[*un_served] = count; 116 | *un_served = (*un_served + 1)%CMD_QUEUE_SIZE; 117 | } 118 | return count; 119 | } 120 | 121 | 122 | int ipc_sock_lock_q(void *dri_if) 123 | { 124 | return 0; 125 | } 126 | 127 | int ipc_sock_unlock_q(void *dri_if) 128 | { 129 | return 0; 130 | } 131 | 132 | int ipc_sock_sig_data(void *dri_if) 133 | { 134 | return 0; 135 | } 136 | 137 | int ipc_sock_close(void *dri_if) 138 | { 139 | struct DRI_IF *p_if = (struct DRI_IF *)dri_if; 140 | struct MULTI_PROC_SOCK *priv_data = p_if->priv_data; 141 | int pid = priv_data->pid; 142 | int my_pid = getpid(); 143 | int *fd = priv_data->fd; 144 | int status; 145 | int ret = 0; 146 | 147 | close(fd[PIPE_READ]); 148 | close(fd[PIPE_WRITE]); 149 | if(priv_data){ 150 | ate_printf(MSG_INFO,"%d, free priv_data\n", getpid()); 151 | free(priv_data); 152 | } 153 | 154 | if(my_pid == pid) { 155 | ate_printf(MSG_INFO,"Forked sub-process is terminating at (%s)\n",p_if->ifname); 156 | exit(0); 157 | } else { 158 | kill(pid, SIGTERM); 159 | ate_printf(MSG_INFO,"%d, wait child(%d)\n", getpid(), pid); 160 | waitpid( pid ,&status, 0); 161 | ate_printf(MSG_INFO,"%d, child finish\n", getpid()); 162 | } 163 | 164 | return ret; 165 | } 166 | -------------------------------------------------------------------------------- /utils/ated/src/thread_model/multi_thread.c: -------------------------------------------------------------------------------- 1 | #include "precomp.h" 2 | /* Variables */ 3 | //static struct MULTI_PROC_THREADS *threads = NULL; 4 | //static struct MULTI_PROC_THREADS **a_threads; 5 | struct MULTI_PROC_OPS thread_ops = { 6 | .multi_proc_init = multi_proc_init, 7 | .multi_insert_q = thread_insert_q, 8 | .multi_lock_q = thread_lock_q, 9 | .multi_unlock_q = thread_unlock_q, 10 | .multi_wait_data = thread_wait_data, 11 | .multi_sig_data = thread_sig_data, 12 | .multi_proc_close = thread_close, 13 | }; 14 | /* Functions */ 15 | int multi_proc_init(void **dri_if, int idx, int dri_if_num, void *pkt_proc_logic) 16 | { 17 | int ret = 0; 18 | int i = 0; 19 | struct DRI_IF **a_ifs = (struct DRI_IF **)dri_if; 20 | struct DRI_IF *p_if = a_ifs[idx]; 21 | struct MULTI_PROC_THREADS *t = NULL; 22 | pthread_attr_t attr; 23 | if(t == NULL){ 24 | t = malloc(sizeof(struct MULTI_PROC_THREADS)); 25 | if(t == NULL){ 26 | ate_printf(MSG_ERROR, "Cannot allocate memory for multi-threading\n"); 27 | return -1; 28 | } 29 | // a_threads = &threads; 30 | } 31 | /* Init parameter in Queue */ 32 | t->q.un_served = 0; 33 | t->q.served = 0; 34 | for(i=0;iq.cmd_arr[i], 0, PKT_BUF_SIZE); 36 | } 37 | /* Lock Init */ 38 | pthread_cond_init(&t->cond, NULL); 39 | pthread_attr_init(&attr); 40 | pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); 41 | if(pthread_mutex_init(&t->lock,NULL)!=0){ 42 | ate_printf(MSG_DEBUG, "Lock in messege queue is failed to initialize(Dri_if[%s])\n",p_if->ifname); 43 | } 44 | ate_printf(MSG_DEBUG, "Lock in messege queue is success to initialize(Dri_if[%s])\n",p_if->ifname); 45 | /* ptread init */ 46 | ret = pthread_create(&t->thread, &attr, pkt_proc_logic, (void *)p_if); 47 | if(ret != 0){ 48 | ate_printf(MSG_DEBUG, "Thread initial fail (%s)\n",p_if->ifname); 49 | return -1; 50 | } 51 | // p_if->ops = &thread_ops; 52 | p_if->priv_data = t; 53 | return ret; 54 | } 55 | 56 | int thread_insert_q(void *dri_if, unsigned char *pkt, int len) 57 | { 58 | struct DRI_IF *p_if = dri_if; 59 | struct COMMON_PRIV *priv_data; 60 | struct cmd_queue *q; 61 | priv_data = (struct COMMON_PRIV *)p_if->priv_data; 62 | q = &priv_data->q; 63 | os_memcpy(q->cmd_arr[q->un_served],pkt,len); 64 | return len; 65 | } 66 | 67 | int thread_lock_q(void *dri_if) 68 | { 69 | struct DRI_IF *p_if = (struct DRI_IF *)dri_if; 70 | struct MULTI_PROC_THREADS *t_thread = (struct MULTI_PROC_THREADS *)p_if->priv_data; 71 | ate_printf(MSG_ERROR,"Lock\n"); 72 | return pthread_mutex_lock(&t_thread->lock); 73 | } 74 | 75 | int thread_unlock_q(void *dri_if) 76 | { 77 | struct DRI_IF *p_if = (struct DRI_IF *)dri_if; 78 | struct MULTI_PROC_THREADS *t_thread = (struct MULTI_PROC_THREADS *)p_if->priv_data; 79 | ate_printf(MSG_ERROR,"Un-lock\n"); 80 | return pthread_mutex_unlock(&t_thread->lock); 81 | } 82 | 83 | int thread_wait_data(void *dri_if) 84 | { 85 | struct DRI_IF *p_if = (struct DRI_IF *)dri_if; 86 | struct MULTI_PROC_THREADS *t_thread = (struct MULTI_PROC_THREADS *)p_if->priv_data; 87 | return pthread_cond_wait(&t_thread->cond, &t_thread->lock); 88 | } 89 | 90 | int thread_sig_data(void *dri_if) 91 | { 92 | struct DRI_IF *p_if = (struct DRI_IF *)dri_if; 93 | struct MULTI_PROC_THREADS *t_thread = (struct MULTI_PROC_THREADS *)p_if->priv_data; 94 | if(p_if->status == 0) 95 | return pthread_cond_signal(&t_thread->cond); 96 | return 1; /* For nothing is serving */ 97 | } 98 | 99 | int thread_close(void *dri_if) 100 | { 101 | struct DRI_IF *p_if = (struct DRI_IF *)dri_if; 102 | struct MULTI_PROC_THREADS *t_thread = (struct MULTI_PROC_THREADS *)p_if->priv_data; 103 | pthread_mutex_unlock(&t_thread->lock); 104 | pthread_mutex_destroy(&t_thread->lock); 105 | ate_printf(MSG_DEBUG,"Leave thread(%s)\n",p_if->ifname); 106 | return 0; 107 | } 108 | -------------------------------------------------------------------------------- /utils/dosbox/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=dosbox 4 | PKG_VERSION:=0.74-2 5 | PKG_RELEASE:=1 6 | 7 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 8 | PKG_SOURCE_URL:=@SF/$(PKG_NAME) 9 | PKG_MD5SUM:=7110ee24a45a2b4951ad52eb1a3722be 10 | 11 | include $(INCLUDE_DIR)/package.mk 12 | 13 | define Package/dosbox 14 | SECTION:=utils 15 | CATEGORY:=Utilities 16 | TITLE:=DOSBox 17 | URL:=http://www.dosbox.com 18 | DEPENDS:=+libsdl +libstdcpp 19 | endef 20 | 21 | define Package/dosbox/description 22 | DOSBox is an emulator program which emulates an IBM PC compatible computer 23 | running a DOS operating system. Many IBM PC compatible graphics and sound cards 24 | are also emulated. 25 | endef 26 | 27 | define Build/Configure 28 | ( cd $(PKG_BUILD_DIR); \ 29 | TARGET_CC="$(TARGET_CROSS)gcc" \ 30 | ./configure --host=mipsel-openwrt-linux \ 31 | ) 32 | endef 33 | 34 | define Build/InstallDev 35 | endef 36 | 37 | define Package/dosbox/install 38 | $(INSTALL_DIR) $(1)/usr/bin 39 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/dosbox $(1)/usr/bin 40 | endef 41 | 42 | 43 | $(eval $(call BuildPackage,dosbox)) 44 | -------------------------------------------------------------------------------- /utils/dosbox/patches/000-keyboard-scancodes.patch: -------------------------------------------------------------------------------- 1 | diff -Naur a/src/gui/sdl_mapper.cpp b/src/gui/sdl_mapper.cpp 2 | --- a/src/gui/sdl_mapper.cpp 2018-08-28 14:57:06.000000000 +0800 3 | +++ b/src/gui/sdl_mapper.cpp 2019-03-18 09:25:56.530088844 +0800 4 | @@ -2394,7 +2394,7 @@ 5 | 6 | usescancodes = false; 7 | 8 | - if (section->Get_bool("usescancodes")) { 9 | + if (0) { 10 | usescancodes=true; 11 | 12 | /* Note: table has to be tested/updated for various OSs */ 13 | -------------------------------------------------------------------------------- /utils/fb-test-app/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=fb-test-app 4 | PKG_RELEASE:=$(AUTORELEASE) 5 | 6 | PKG_SOURCE_PROTO:=git 7 | PKG_SOURCE_URL:=https://github.com/andy-shev/fb-test-app.git 8 | PKG_SOURCE_DATE:=20210901 9 | PKG_SOURCE_VERSION:=e8fa7f17d643190cb2119284d02cd3c5281ca87d 10 | PKG_MIRROR_HASH:=86be55835f31ade6140f2482433949cde85c1b274dac9f41f36111dcfbd37feb 11 | 12 | include $(INCLUDE_DIR)/package.mk 13 | 14 | define Package/fb-test-app 15 | SECTION:=utils 16 | CATEGORY:=Utilities 17 | TITLE:=fb test app 18 | endef 19 | 20 | define Package/fb-test-app/install 21 | $(INSTALL_DIR) $(1)/usr/bin 22 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/perf $(1)/usr/bin/fb-test-perf 23 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/rect $(1)/usr/bin/fb-test-rect 24 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/fb-test $(1)/usr/bin/fb-test 25 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/offset $(1)/usr/bin/fb-test-offset 26 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/fb-string $(1)/usr/bin/fb-test-string 27 | endef 28 | 29 | $(eval $(call BuildPackage,fb-test-app)) 30 | -------------------------------------------------------------------------------- /utils/fbusb/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | include $(INCLUDE_DIR)/kernel.mk 3 | 4 | PKG_NAME:=fbusb 5 | PKG_VERSION:=v5 6 | PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION) 7 | 8 | include $(INCLUDE_DIR)/package.mk 9 | 10 | define KernelPackage/fbusb 11 | TITLE:=USB framebuffer 12 | FILES:=$(PKG_BUILD_DIR)/fbusb.ko 13 | SECTION:=vocore2 14 | CATEGORY:=VoCore2 15 | AUTOLOAD:=$(call AutoLoad,01,fbusb) 16 | DEPENDS:=+kmod-usb-core +kmod-usb-hid +kmod-fb +kmod-fb-tft 17 | endef 18 | 19 | define KernelPackage/fbusb/description 20 | USB framebuffer, /dev/fb0 21 | endef 22 | 23 | MAKE_OPTS:= \ 24 | ARCH="$(LINUX_KARCH)" \ 25 | CROSS_COMPILE="$(TARGET_CROSS)" \ 26 | SUBDIRS="$(PKG_BUILD_DIR)" \ 27 | M="$(PKG_BUILD_DIR)" 28 | 29 | 30 | 31 | define Build/Prepare 32 | mkdir -p $(PKG_BUILD_DIR) 33 | $(CP) ./src/* $(PKG_BUILD_DIR)/ 34 | endef 35 | 36 | define Build/Compile 37 | $(MAKE) -C "$(LINUX_DIR)" $(MAKE_OPTS) modules 38 | endef 39 | 40 | $(eval $(call KernelPackage,fbusb)) 41 | -------------------------------------------------------------------------------- /utils/fbusb/src/Kconfig: -------------------------------------------------------------------------------- 1 | menuconfig FB_VOCORE_FBUSB 2 | tristate "Support for vocore screen" 3 | depends on FB && USB 4 | select FB_SYS_COPYAREA 5 | select FB_SYS_FILLRECT 6 | select FB_SYS_IMAGEBLIT 7 | select FB_SYS_FOPS 8 | -------------------------------------------------------------------------------- /utils/fbusb/src/Makefile: -------------------------------------------------------------------------------- 1 | obj-m += fbusb.o 2 | -------------------------------------------------------------------------------- /utils/fbusb/src/README.md: -------------------------------------------------------------------------------- 1 | # Compile Example 2 | 3 | make -C /Volumes/OpenWrt/vocore2/build_dir/target-mipsel_24kc_musl/linux-ramips_mt76x8/linux-4.14.131 M=$PWD CROSS_COMPILE="/Volumes/OpenWrt/vocore2/staging_dir/toolchain-mipsel_24kc_gcc-7.3.0_musl/bin/mipsel-openwrt-linux-" ARCH="mips" modules 4 | 5 | because framebuffer only support 16bit or 32bit color, so it is very slow to convert data from 32bit to 24bit or from 16bit to 24bit, new version solve this problem. 6 | If you want better colors, need to use libusb send data to the screen, and make it in R-G-B-R-G-B... order. R,G,B each takes one byte. 7 | -------------------------------------------------------------------------------- /utils/fbusb/src/doc/install_on_raspbian.md: -------------------------------------------------------------------------------- 1 | # install vocore screen driver on raspbian 2 | 3 | ## upgrade the system 4 | 5 | ``` 6 | sudo apt update && sudo apt upgrade -y 7 | ``` 8 | 9 | ## install kernel headers and build tools 10 | 11 | ``` 12 | sudo apt install raspberrypi-kernel-headers build-essential -y 13 | ``` 14 | 15 | ## reboot for use new kernel 16 | 17 | ``` 18 | sudo reboot 19 | ``` 20 | 21 | ## download & compile & install driver 22 | 23 | ``` 24 | git clone https://github.com/Vonger/vocore2 # download source code 25 | cd vocore2 26 | cd utils/fbusb/src 27 | make -C /usr/src/linux-headers-`uname -r`/ M=`pwd` modules # compile 28 | sudo mkdir -p /lib/modules/`uname -r`/extra 29 | sudo cp fbusb.ko /lib/modules/`uname -r`/extra/ # install module 30 | sudo depmod -a # for autoloading 31 | ``` 32 | 33 | ## install xorg configuration file 34 | 35 | ``` 36 | sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.bak # backup origin config file 37 | sudo nano /etc/X11/xorg.conf 38 | ``` 39 | 40 | please paste: 41 | 42 | ``` 43 | Section "Device" 44 | Identifier "vocore screen" 45 | Driver "fbturbo" 46 | Option "fbdev" "/dev/fb0" 47 | 48 | Option "SwapbuffersWait" "true" 49 | EndSection 50 | ``` 51 | 52 | Use 53 | 54 | ``` 55 | Ctrl+X 56 | y 57 | Enter 58 | ``` 59 | 60 | to save file 61 | 62 | ## ready for use 63 | 64 | 1. plugout hdmi cable 65 | 66 | 2. connect vocore screen 67 | 68 | 3. reboot raspberrypi board 69 | 70 | 4. the graphic will display on vocore screen by default (test on rpi4) 71 | 72 | ## note 73 | 74 | some screen is small, like your old android 2.3 phone 75 | 76 | you may be need tune the ui, like android app 77 | 78 | eg: button need big size easy to tap 79 | 80 | there is some suggest project: 81 | 82 | * https://plasma-mobile.org/ 83 | 84 | * https://sxmo.org/ 85 | 86 | * XFCE4 87 | -------------------------------------------------------------------------------- /utils/hidapi/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=hidapi 11 | PKG_VERSION:=0.8.0-rc1 12 | PKG_RELEASE:=2 13 | 14 | PKG_SOURCE_PROTO:=git 15 | PKG_SOURCE_URL:=https://github.com/signal11/hidapi.git 16 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) 17 | PKG_SOURCE_VERSION:=hidapi-$(PKG_VERSION) 18 | PKG_SOURCE:=$(PKG_SOURCE_VERSION).tar.gz 19 | PKG_MIRROR_HASH:=95b39035f94c35b0c360ec2e02a01fe25e971490135d7137f163974d4a88471f 20 | PKG_LICENSE:=BSD-3-Clause 21 | PKG_LICENSE_FILES:=LICENSE-bsd.txt 22 | 23 | PKG_MAINTAINER:=Paul Fertser 24 | 25 | include $(INCLUDE_DIR)/package.mk 26 | include $(INCLUDE_DIR)/nls.mk 27 | 28 | define Package/hidapi 29 | SECTION:=libs 30 | CATEGORY:=Libraries 31 | DEPENDS:=+libusb-1.0 +librt $(ICONV_DEPENDS) 32 | TITLE:=Library to talk to HID devices 33 | URL:=http://www.signal11.us/oss/hidapi/ 34 | endef 35 | 36 | define Package/hidapi/description 37 | HIDAPI is a multi-platform library which allows an application to interface 38 | with USB and Bluetooth HID-Class devices on Windows, Linux, FreeBSD, and Mac 39 | OS X. HIDAPI can be either built as a shared library (.so or .dll) or 40 | can be embedded directly into a target application by adding a single source 41 | file (per platform) and a single header. 42 | endef 43 | 44 | define Build/Configure 45 | endef 46 | 47 | MAKE_PATH=libusb 48 | MAKE_FLAGS+=-f Makefile.linux 49 | TARGET_CFLAGS+=$(FPIC) 50 | 51 | define Build/Compile 52 | $(call Build/Compile/Default, libhidapi-libusb.so) 53 | mv $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so \ 54 | $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so.0 55 | ln -s libhidapi-libusb.so.0 $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so 56 | sed 's^@prefix@^/usr^; \ 57 | s^@exec_prefix@^/usr^; \ 58 | s^@libdir@^$$$${exec_prefix}/lib^; \ 59 | s^@includedir@^$$$${prefix}/include^' \ 60 | < $(PKG_BUILD_DIR)/pc/hidapi-libusb.pc.in \ 61 | > $(PKG_BUILD_DIR)/pc/hidapi-libusb.pc 62 | endef 63 | 64 | define Build/InstallDev 65 | $(INSTALL_DIR) $(1)/usr/include/hidapi 66 | $(CP) $(PKG_BUILD_DIR)/hidapi/hidapi.h $(1)/usr/include/hidapi/ 67 | $(INSTALL_DIR) $(1)/usr/lib 68 | $(CP) $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so* $(1)/usr/lib/ 69 | $(INSTALL_DIR) $(1)/usr/lib/pkgconfig/ 70 | $(CP) $(PKG_BUILD_DIR)/pc/hidapi-libusb.pc $(1)/usr/lib/pkgconfig/ 71 | endef 72 | 73 | define Package/hidapi/install 74 | $(INSTALL_DIR) $(1)/usr/lib 75 | $(CP) $(PKG_BUILD_DIR)/libusb/libhidapi-libusb.so* $(1)/usr/lib/ 76 | endef 77 | 78 | $(eval $(call BuildPackage,hidapi)) 79 | -------------------------------------------------------------------------------- /utils/hidapi/patches/010-add-iconv-linkage.patch: -------------------------------------------------------------------------------- 1 | Index: hidapi-0.8.0-rc1/libusb/Makefile.linux 2 | =================================================================== 3 | --- hidapi-0.8.0-rc1.orig/libusb/Makefile.linux 4 | +++ hidapi-0.8.0-rc1/libusb/Makefile.linux 5 | @@ -22,7 +22,7 @@ COBJS_LIBUSB = hid.o 6 | COBJS = $(COBJS_LIBUSB) 7 | CPPOBJS = ../hidtest/hidtest.o 8 | OBJS = $(COBJS) $(CPPOBJS) 9 | -LIBS_USB = `pkg-config libusb-1.0 --libs` -lrt -lpthread 10 | +LIBS_USB = `pkg-config libusb-1.0 --libs` -lrt -lpthread -liconv 11 | LIBS = $(LIBS_USB) 12 | INCLUDES ?= -I../hidapi `pkg-config libusb-1.0 --cflags` 13 | 14 | @@ -33,7 +33,7 @@ hidtest-libusb: $(COBJS_LIBUSB) $(CPPOBJ 15 | 16 | # Shared Libs 17 | libhidapi-libusb.so: $(COBJS_LIBUSB) 18 | - $(CC) $(LDFLAGS) $(LIBS_USB) -shared -fpic -Wl,-soname,$@.0 $^ -o $@ 19 | + $(CC) $(LDFLAGS) $^ $(LIBS_USB) -shared -fpic -Wl,-soname,$@.0 -o $@ 20 | 21 | # Objects 22 | $(COBJS): %.o: %.c 23 | -------------------------------------------------------------------------------- /utils/i2c-tools/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2007-2015 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=i2c-tools 11 | PKG_VERSION:=3.1.2 12 | PKG_RELEASE:=1 13 | 14 | PKG_SOURCE_URL:=@KERNEL/software/utils/i2c-tools 15 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz 16 | PKG_HASH:=6d6079153cd49a62d4addacef4c092db1a46ba60b2807070a3fbe050262aef87 17 | 18 | PKG_MAINTAINER:=Daniel Golle 19 | PKG_LICENSE:=GPLv2 20 | PKG_LICENSE_FILES:=COPYING 21 | 22 | include $(INCLUDE_DIR)/package.mk 23 | 24 | define Package/i2c/Default 25 | URL:=http://lm-sensors.org/wiki/I2CTools 26 | TITLE:=I2C 27 | endef 28 | 29 | define Package/i2c-tools 30 | $(call Package/i2c/Default) 31 | SECTION:=utils 32 | CATEGORY:=Utilities 33 | TITLE+=tools for Linux 34 | endef 35 | 36 | define Package/i2c-tools/description 37 | This package contains an heterogeneous set of I2C tools for Linux. These tools 38 | were originally part of the lm-sensors package. 39 | endef 40 | 41 | define Build/Compile 42 | $(MAKE) -C $(PKG_BUILD_DIR) \ 43 | LINUX="$(LINUX_DIR)" \ 44 | CC="$(TARGET_CC)" \ 45 | STAGING_DIR="$(STAGING_DIR)" \ 46 | LDFLAGS="$(TARGET_LDFLAGS)" \ 47 | CFLAGS="$(TARGET_CFLAGS)" 48 | endef 49 | 50 | define Package/i2c-tools/install 51 | $(INSTALL_DIR) $(1)/usr/sbin 52 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/i2cdetect $(1)/usr/sbin/ 53 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/i2cdump $(1)/usr/sbin/ 54 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/i2cset $(1)/usr/sbin/ 55 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/tools/i2cget $(1)/usr/sbin/ 56 | endef 57 | 58 | 59 | $(eval $(call BuildPackage,i2c-tools)) 60 | -------------------------------------------------------------------------------- /utils/i2c-tools/i2c-tools-3.1.2.tar.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vonger/vocore2/bf45a2ed014f7a850e2ad00b05f43f6114711d45/utils/i2c-tools/i2c-tools-3.1.2.tar.xz -------------------------------------------------------------------------------- /utils/libftdi1/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2014-2017 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=libftdi1 11 | PKG_VERSION:=1.4 12 | PKG_RELEASE:=6 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 15 | PKG_SOURCE_URL:=http://www.intra2net.com/en/developer/libftdi/download/ 16 | PKG_HASH:=ec36fb49080f834690c24008328a5ef42d3cf584ef4060f3a35aa4681cb31b74 17 | 18 | PKG_MAINTAINER:=Álvaro Fernández Rojas 19 | PKG_LICENSE:=LGPL-2.1-only 20 | PKG_LICENSE_FILES:=COPYING.LIB 21 | 22 | CMAKE_INSTALL:=1 23 | PKG_BUILD_PARALLEL:=1 24 | PKG_USE_MIPS16:=0 25 | 26 | include $(INCLUDE_DIR)/package.mk 27 | include $(INCLUDE_DIR)/cmake.mk 28 | 29 | define Package/libftdi1 30 | SECTION:=libs 31 | CATEGORY:=Libraries 32 | DEPENDS:=+libusb-1.0 33 | TITLE:=Library to talk to FTDI chips 34 | URL:=http://www.intra2net.com/en/developer/libftdi/ 35 | endef 36 | 37 | define Package/libftdi1/description 38 | libFTDI - FTDI USB driver with bitbang mode 39 | libFTDI is an open source library to talk to FTDI chips: FT232BM, FT245BM, FT2232C, FT2232H, FT4232H, FT2232D and FT245R, including the popular bitbang mode. 40 | The library is linked with your program in userspace, no kernel driver required. 41 | endef 42 | 43 | define Package/ftdi_eeprom 44 | SECTION:=utils 45 | CATEGORY:=Utilities 46 | DEPENDS:=+confuse +libftdi1 47 | TITLE:=Tool for reading/erasing/flashing FTDI USB chip eeproms 48 | URL:=http://www.intra2net.com/en/developer/libftdi/ 49 | endef 50 | 51 | define Package/ftdi_eeprom/description 52 | ftdi_eeprom is a small tool for reading/erasing/flashing FTDI USB chip 53 | eeproms. It uses libftdi to access the chip, so you will need to have 54 | the required permissions on the device. 55 | 56 | The ftdi_sio module should not be loaded. 57 | 58 | You have to unplug and replug your device to get the new values to be 59 | read. Otherwise, you will still get the old values. 60 | endef 61 | 62 | CMAKE_OPTIONS += \ 63 | -DBoost_NO_BOOST_CMAKE=ON \ 64 | -DBUILD_TESTS=OFF \ 65 | -DEXAMPLES=OFF 66 | 67 | define Build/InstallDev 68 | $(call Build/InstallDev/cmake,$(1)) 69 | $(SED) 's,/usr/bin,/usr,g' $(1)/usr/lib/pkgconfig/libftdi1.pc 70 | $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libftdi1.pc 71 | $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libftdi1.pc 72 | $(SED) 's,/usr/bin,/usr,g' $(1)/usr/lib/pkgconfig/libftdipp1.pc 73 | $(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libftdipp1.pc 74 | $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libftdipp1.pc 75 | endef 76 | 77 | define Package/libftdi1/install 78 | $(INSTALL_DIR) $(1)/usr/bin 79 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/libftdi1-config $(1)/usr/bin/ 80 | $(INSTALL_DIR) $(1)/usr/lib 81 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libftdi1.so.* $(1)/usr/lib/ 82 | endef 83 | 84 | define Package/ftdi_eeprom/install 85 | $(INSTALL_DIR) $(1)/usr/bin 86 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ftdi_eeprom $(1)/usr/bin/ 87 | endef 88 | 89 | $(eval $(call BuildPackage,libftdi1)) 90 | $(eval $(call BuildPackage,ftdi_eeprom)) 91 | -------------------------------------------------------------------------------- /utils/libftdi1/patches/100-fix-x86_64-build.patch: -------------------------------------------------------------------------------- 1 | --- a/CMakeLists.txt 2 | +++ b/CMakeLists.txt 3 | @@ -55,7 +55,7 @@ if ( NOT DEFINED LIB_SUFFIX ) 4 | AND NOT EXISTS "/etc/debian_version" 5 | AND NOT EXISTS "/etc/arch-release" ) 6 | if ( "${CMAKE_SIZEOF_VOID_P}" EQUAL "8" ) 7 | - set ( LIB_SUFFIX 64 ) 8 | + set ( LIB_SUFFIX "" ) 9 | endif () 10 | endif () 11 | endif () 12 | -------------------------------------------------------------------------------- /utils/libftdi1/patches/101-use-findSWIG.patch: -------------------------------------------------------------------------------- 1 | --- a/python/CMakeLists.txt 2 | +++ b/python/CMakeLists.txt 3 | @@ -3,7 +3,7 @@ option ( LINK_PYTHON_LIBRARY "Link again 4 | 5 | if ( PYTHON_BINDINGS ) 6 | # workaround for cmake bug #0013449 7 | - if ( NOT DEFINED CMAKE_FIND_ROOT_PATH ) 8 | + if ( NOT DEFINED CMAKE_FIND_ROOT_PATH OR CMAKE_VERSION VERSION_GREATER_EQUAL 3.0.0 ) 9 | find_package ( SWIG ) 10 | else () 11 | find_program ( SWIG_EXECUTABLE NAMES swig2.0 swig ) 12 | -------------------------------------------------------------------------------- /utils/libsdl/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2010 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=SDL 11 | PKG_VERSION:=1.2.15 12 | PKG_RELEASE:=2 13 | 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 15 | PKG_SOURCE_URL:=http://www.libsdl.org/release/ 16 | PKG_MD5SUM:=9d96df8417572a2afb781a7c4c811a85 17 | 18 | PKG_FIXUP:=autoreconf 19 | PKG_INSTALL:=1 20 | 21 | PKG_CONFIG_DEPENDS:=CONFIG_AUDIO_SUPPORT 22 | 23 | include $(INCLUDE_DIR)/package.mk 24 | 25 | define Package/libsdl 26 | SECTION:=libs 27 | CATEGORY:=Libraries 28 | TITLE:=Simple DirectMedia Layer 29 | URL:=http://www.libsdl.org 30 | DEPENDS:=+zlib +libpthread +AUDIO_SUPPORT:alsa-lib 31 | endef 32 | 33 | define Package/libsdl/description 34 | SDL is a library that allows programs portable low level access to a video 35 | framebuffer, audio output, mouse, and keyboard. 36 | endef 37 | 38 | CONFIGURE_ARGS+= \ 39 | --enable-libc \ 40 | --enable-video \ 41 | --enable-events \ 42 | --enable-joystick \ 43 | --enable-cdrom \ 44 | --enable-threads \ 45 | --enable-timers \ 46 | --enable-file \ 47 | --enable-loadso \ 48 | --enable-cpuinfo \ 49 | --enable-assembly \ 50 | --disable-oss \ 51 | --disable-alsatest \ 52 | --enable-alsa-shared \ 53 | --disable-esd \ 54 | --disable-esdtest \ 55 | --enable-esd-shared \ 56 | --disable-pulseaudio \ 57 | --enable-pulseaudio-shared \ 58 | --disable-arts \ 59 | --enable-arts-shared \ 60 | --disable-nas \ 61 | --enable-nas-shared \ 62 | --disable-diskaudio \ 63 | --disable-dummyaudio \ 64 | --disable-mintaudio \ 65 | --disable-nasm \ 66 | --disable-altivec \ 67 | --disable-ipod \ 68 | --disable-nanox \ 69 | --disable-video-x11 \ 70 | --enable-x11-shared \ 71 | --enable-dga \ 72 | --enable-video-dga \ 73 | --enable-video-x11-dgamouse \ 74 | --enable-video-x11-vm \ 75 | --enable-video-x11-xv \ 76 | --disable-video-x11-xinerama \ 77 | --disable-video-x11-xme \ 78 | --disable-video-x11-xrandr \ 79 | --disable-video-photon \ 80 | --disable-video-carbon \ 81 | --disable-video-cocoa \ 82 | --enable-video-fbcon \ 83 | --enable-directfb-shared \ 84 | --disable-video-ps2gs \ 85 | --disable-video-ps3 \ 86 | --disable-video-ggi \ 87 | --disable-video-svga \ 88 | --disable-video-vgl \ 89 | --disable-video-wscons \ 90 | --disable-video-aalib \ 91 | --disable-video-caca \ 92 | --disable-video-qtopia \ 93 | --disable-video-picogui \ 94 | --disable-video-xbios \ 95 | --disable-video-gem \ 96 | --disable-video-dummy \ 97 | --disable-video-opengl \ 98 | --disable-osmesa-shared \ 99 | --disable-screensaver \ 100 | --enable-input-events \ 101 | --disable-input-tslib \ 102 | --enable-pth \ 103 | --enable-pthreads \ 104 | --enable-pthread-sem \ 105 | --disable-stdio-redirect \ 106 | --disable-directx \ 107 | --enable-sdl-dlopen \ 108 | --disable-atari-ldg \ 109 | --disable-clock_gettime \ 110 | --without-x \ 111 | --disable-rpath \ 112 | 113 | ifneq ($(CONFIG_AUDIO_SUPPORT),) 114 | CONFIGURE_ARGS+= \ 115 | --enable-audio \ 116 | --enable-alsa 117 | else 118 | CONFIGURE_ARGS+= \ 119 | --disable-audio \ 120 | --disable-alsa 121 | endif 122 | 123 | CONFIGURE_VARS+= \ 124 | ac_cv_path_DIRECTFBCONFIG=no \ 125 | 126 | define Build/InstallDev 127 | $(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib/pkgconfig 128 | $(CP) \ 129 | $(PKG_INSTALL_DIR)/usr/include/SDL* \ 130 | $(1)/usr/include/ 131 | $(CP) \ 132 | $(PKG_INSTALL_DIR)/usr/lib/libSDL*.{a,so*} \ 133 | $(1)/usr/lib/ 134 | $(INSTALL_DATA) \ 135 | $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/* \ 136 | $(1)/usr/lib/pkgconfig 137 | 138 | 139 | $(INSTALL_DIR) $(1)/usr/share/aclocal 140 | $(INSTALL_DATA) \ 141 | $(PKG_INSTALL_DIR)/usr/share/aclocal/* \ 142 | $(1)/usr/share/aclocal/ 143 | 144 | $(INSTALL_DIR) $(1)/usr/bin 145 | $(INSTALL_BIN) \ 146 | $(PKG_INSTALL_DIR)/usr/bin/sdl-config \ 147 | $(1)/usr/bin/ 148 | 149 | $(SED) 's,^\(exec_prefix\|prefix\)=.*,\1=\"$(STAGING_DIR)/usr/\",g' \ 150 | $(1)/usr/bin/sdl-config 151 | 152 | $(INSTALL_DIR) $(1)/host/bin 153 | ln -sf ../../usr/bin/sdl-config $(1)/host/bin/ 154 | endef 155 | 156 | define Package/libsdl/install 157 | $(INSTALL_DIR) $(1)/usr/lib 158 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/libSDL*.so.* $(1)/usr/lib/ 159 | endef 160 | 161 | $(eval $(call BuildPackage,libsdl)) 162 | -------------------------------------------------------------------------------- /utils/libsdl/patches/000-support-hid-mouse.patch: -------------------------------------------------------------------------------- 1 | diff -Nbaur --suppress-blank-empty a/src/video/fbcon/SDL_fbevents.c b/src/video/fbcon/SDL_fbevents.c 2 | --- a/src/video/fbcon/SDL_fbevents.c 2012-01-19 14:30:06.000000000 +0800 3 | +++ b/src/video/fbcon/SDL_fbevents.c 2019-03-18 16:43:05.990704860 +0800 4 | @@ -324,6 +324,7 @@ 5 | MOUSE_BM, 6 | MOUSE_ELO, 7 | MOUSE_TSLIB, 8 | + MOUSE_HID, 9 | NUM_MOUSE_DRVS 10 | } mouse_drv = MOUSE_NONE; 11 | 12 | @@ -594,6 +595,19 @@ 13 | } 14 | 15 | /* STD MICE */ 16 | + if (mousedrv && (SDL_strcmp(mousedrv, "HID") == 0)) { 17 | + const char hidmice[] = "/dev/input/event0"; 18 | + if (mousedev == NULL) 19 | + mousedev = hidmice; 20 | + mouse_fd = open(mousedev, O_RDWR|O_NOCTTY|O_NDELAY); 21 | + if (mouse_fd >= 0) { 22 | + mouse_drv = MOUSE_HID; 23 | + fcntl(mouse_fd, F_SETFL, O_ASYNC|O_NONBLOCK); 24 | + } else { 25 | + mouse_drv = MOUSE_NONE; 26 | + } 27 | + return mouse_fd; 28 | + } 29 | 30 | if ( mousedev == NULL ) { 31 | /* FIXME someday... allow multiple mice in this driver */ 32 | @@ -776,6 +790,9 @@ 33 | switch (mouse_drv) { 34 | case MOUSE_NONE: 35 | break; /* carry on to read from device and discard it. */ 36 | + case MOUSE_HID: 37 | + packetsize = 16; /* timeval, type, code, value */ 38 | + break; 39 | case MOUSE_MSC: 40 | packetsize = 5; 41 | break; 42 | @@ -829,6 +846,24 @@ 43 | switch (mouse_drv) { 44 | case MOUSE_NONE: /* shouldn't actually hit this. */ 45 | break; /* just throw everything away. */ 46 | + case MOUSE_HID: { 47 | + Uint16 t = *(Uint16 *)(mousebuf + i + 8); 48 | + Uint16 c = *(Uint16 *)(mousebuf + i + 10); 49 | + int v = *(int *)(mousebuf + i + 12); 50 | + if (t == 2) { /* EV_REL */ 51 | + if (c == 0) 52 | + dx = v; 53 | + if (c == 1) 54 | + dy = v; 55 | + } else if (t == 1 && v == 1) { /* EV_KEY */ 56 | + if (c == 0x110) /* BTN_LEFT */ 57 | + button |= 0x04; 58 | + if (c == 0x111) /* BTN_RIGHT */ 59 | + button |= 0x01; 60 | + if (c == 0x112) /* BTN_MIDDLE */ 61 | + button |= 0x02; 62 | + } 63 | + break; } 64 | case MOUSE_MSC: 65 | /* MSC protocol has 0x80 in high byte */ 66 | if ( (mousebuf[i] & 0xF8) != 0x80 ) { 67 | -------------------------------------------------------------------------------- /utils/libsdl/patches/001-automake-compat.patch: -------------------------------------------------------------------------------- 1 | --- /dev/null 2 | +++ b/Makefile.am 3 | @@ -0,0 +1,2 @@ 4 | +SUBDIRS = . 5 | +ACLOCAL_AMFLAGS = -I . -I acinclude 6 | -------------------------------------------------------------------------------- /utils/libserialport/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=libserialport 4 | PKG_VERSION:=0.1.1 5 | 6 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 7 | PKG_SOURCE_URL:=http://sigrok.org/download/source/libserialport/$(PKG_NAME)-$(PKG_VERSION).tar.gz 8 | PKG_MD5SUM:=b93f0325a6157198152b5bd7e8182b51 9 | 10 | include $(INCLUDE_DIR)/package.mk 11 | 12 | define Package/libserialport 13 | SECTION:=libs 14 | CATEGORY:=Libraries 15 | TITLE:=A library for serial port. 16 | endef 17 | 18 | define Package/libserialport/description 19 | A library for serial port. 20 | endef 21 | 22 | define Package/libserialport/install 23 | $(INSTALL_DIR) $(1)/usr/lib 24 | $(CP) $(PKG_BUILD_DIR)/.libs/libserialport.so* $(1)/usr/lib/ 25 | endef 26 | 27 | $(eval $(call BuildPackage,libserialport)) 28 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.bak 3 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2008-2014 The LuCI Team 3 | # 4 | # This is free software, licensed under the Apache License, Version 2.0 . 5 | # 6 | 7 | include $(TOPDIR)/rules.mk 8 | 9 | LUCI_TITLE:=LuCI for Zerotier 10 | LUCI_DEPENDS:=+zerotier +luci-compat 11 | LUCI_PKGARCH:=all 12 | PKG_VERSION:=1.0 13 | PKG_RELEASE:=16 14 | 15 | include $(TOPDIR)/feeds/luci/luci.mk 16 | 17 | # call BuildPackage - OpenWrt buildroot signature 18 | 19 | 20 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/README.md: -------------------------------------------------------------------------------- 1 | # luci-app-zerotier 2 | 3 | import from https://github.com/rufengsuixing/luci-app-zerotier/releases/tag/1.0-16 4 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/luasrc/controller/zerotier.lua: -------------------------------------------------------------------------------- 1 | module("luci.controller.zerotier",package.seeall) 2 | 3 | function index() 4 | if not nixio.fs.access("/etc/config/zerotier")then 5 | return 6 | end 7 | 8 | entry({"admin","vpn"}, firstchild(), "VPN", 45).dependent = false 9 | 10 | entry({"admin", "vpn", "zerotier"},firstchild(), _("ZeroTier")).dependent = false 11 | 12 | entry({"admin", "vpn", "zerotier", "general"},cbi("zerotier/settings"), _("Base Setting"), 1) 13 | entry({"admin", "vpn", "zerotier", "log"},form("zerotier/info"), _("Interface Info"), 2) 14 | 15 | entry({"admin","vpn","zerotier","status"},call("act_status")) 16 | end 17 | 18 | function act_status() 19 | local e={} 20 | e.running=luci.sys.call("pgrep /usr/bin/zerotier-one >/dev/null")==0 21 | luci.http.prepare_content("application/json") 22 | luci.http.write_json(e) 23 | end 24 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/luasrc/model/cbi/zerotier/info.lua: -------------------------------------------------------------------------------- 1 | local fs = require "nixio.fs" 2 | local conffile = "/tmp/zero.info" 3 | 4 | f = SimpleForm("logview") 5 | 6 | t = f:field(TextValue, "conf") 7 | t.rmempty = true 8 | t.rows = 15 9 | function t.cfgvalue() 10 | luci.sys.exec("ifconfig $(ifconfig | grep zt | awk '{print $1}') > /tmp/zero.info") 11 | return fs.readfile(conffile) or "" 12 | end 13 | t.readonly="readonly" 14 | 15 | return f -------------------------------------------------------------------------------- /utils/luci-app-zerotier/luasrc/model/cbi/zerotier/settings.lua: -------------------------------------------------------------------------------- 1 | 2 | a=Map("zerotier",translate("ZeroTier"),translate("Zerotier is an open source, cross-platform and easy to use virtual LAN")) 3 | a:section(SimpleSection).template = "zerotier/zerotier_status" 4 | 5 | t=a:section(NamedSection,"sample_config","zerotier") 6 | t.anonymous=true 7 | t.addremove=false 8 | 9 | e=t:option(Flag,"enabled",translate("Enable")) 10 | e.default=0 11 | e.rmempty=false 12 | 13 | e=t:option(DynamicList,"join",translate('ZeroTier Network ID')) 14 | e.password=true 15 | e.rmempty=false 16 | 17 | e=t:option(Flag,"nat",translate("Auto NAT Clients")) 18 | e.default=0 19 | e.rmempty=false 20 | 21 | e = t:option(MultiValue, "access", translate("Zerotier access control")) 22 | e.default="lanfwzt ztfwwan ztfwlan" 23 | e.rmempty=false 24 | e:value("lanfwzt",translate("lan access zerotier")) 25 | e:value("wanfwzt",translate("wan access zerotier")) 26 | e:value("ztfwwan",translate("remote access wan")) 27 | e:value("ztfwlan",translate("remote access lan")) 28 | e.widget = "checkbox" 29 | 30 | e=t:option(DummyValue,"opennewwindow" , 31 | translate("")) 32 | e.description = translate("Create or manage your zerotier network, and auth clients who could access") 33 | 34 | return a 35 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/luasrc/view/zerotier/zerotier_status.htm: -------------------------------------------------------------------------------- 1 | 17 | 18 |
19 |

20 | <%:Collecting data...%> 21 |

22 |
23 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/po/zh-cn/zerotier.po: -------------------------------------------------------------------------------- 1 | msgid "" 2 | msgstr "" 3 | "MIME-Version: 1.0\n" 4 | "Content-Type: text/plain; charset=UTF-8\n" 5 | "Content-Transfer-Encoding: 8bit\n" 6 | "X-Generator: Gtranslator 2.91.7\n" 7 | "Plural-Forms: nplurals=1; plural=0;\n" 8 | 9 | msgid "Zerotier is an open source, cross-platform and easy to use virtual LAN" 10 | msgstr "Zerotier是一个开源,跨平台,而且适合内网穿透互联的傻瓜配置虚拟 VPN LAN" 11 | 12 | msgid "Auto NAT Clients" 13 | msgstr "自动允许客户端NAT" 14 | 15 | msgid "Allow zerotier clients access your LAN network" 16 | msgstr "允许Zerotier的拨入客户端访问路由器LAN资源(需要在 Zerotier管理页面设定到LAN网段的路由表)" 17 | 18 | msgid "Create or manage your zerotier network, and auth clients who could access" 19 | msgstr "点击跳转到Zerotier官网管理平台,新建或者管理网络,并允许客户端接入访问你私人网路(新接入的节点默认不允许访问)" 20 | 21 | msgid "Interface Info" 22 | msgstr "接口信息" 23 | 24 | msgid "Zerotier access control" 25 | msgstr "Zerotier 准入控制" 26 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/root/etc/init.d/zerotier: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | 3 | START=90 4 | 5 | USE_PROCD=1 6 | 7 | PROG=/usr/bin/zerotier-one 8 | CONFIG_PATH=/var/lib/zerotier-one 9 | 10 | section_enabled() { 11 | config_get_bool enabled "$1" 'enabled' 0 12 | [ $enabled -gt 0 ] 13 | } 14 | service_triggers() { 15 | procd_add_reload_trigger zerotier 16 | } 17 | start_instance() { 18 | local cfg="$1" 19 | local port secret config_path 20 | local ARGS="" 21 | 22 | if ! section_enabled "$cfg"; then 23 | echo "disabled in config" 24 | return 1 25 | fi 26 | 27 | [ -d /etc/config/zero ] || mkdir -p /etc/config/zero 28 | config_path=/etc/config/zero 29 | 30 | config_get_bool port $cfg 'port' 31 | config_get secret $cfg 'secret' 32 | 33 | # Remove existing link or folder 34 | rm -rf $CONFIG_PATH 35 | 36 | # Create link from CONFIG_PATH to config_path 37 | if [ -n "$config_path" -a "$config_path" != $CONFIG_PATH ]; then 38 | if [ ! -d "$config_path" ]; then 39 | echo "ZeroTier config_path does not exist: $config_path" 40 | return 41 | fi 42 | 43 | ln -s $config_path $CONFIG_PATH 44 | fi 45 | 46 | mkdir -p $CONFIG_PATH/networks.d 47 | 48 | if [ -n "$port" ]; then 49 | ARGS="$ARGS -p$port" 50 | fi 51 | 52 | if [ "$secret" = "generate" ]; then 53 | echo "Generate secret - please wait..." 54 | local sf="/tmp/zt.$cfg.secret" 55 | 56 | zerotier-idtool generate "$sf" > /dev/null 57 | [ $? -ne 0 ] && return 1 58 | 59 | secret="$(cat $sf)" 60 | rm "$sf" 61 | 62 | uci set zerotier.$cfg.secret="$secret" 63 | uci commit zerotier 64 | fi 65 | 66 | if [ -n "$secret" ]; then 67 | echo "$secret" > $CONFIG_PATH/identity.secret 68 | # make sure there is not previous identity.public 69 | rm -f $CONFIG_PATH/identity.public 70 | fi 71 | 72 | add_join() { 73 | # an (empty) config file will cause ZT to join a network 74 | touch $CONFIG_PATH/networks.d/$1.conf 75 | } 76 | 77 | config_list_foreach $cfg 'join' add_join 78 | 79 | procd_open_instance 80 | procd_set_param command $PROG $ARGS $CONFIG_PATH 81 | procd_set_param stderr 1 82 | procd_close_instance 83 | ( 84 | [ -f "/var/run/zerotier.wait.pid" ] && return 85 | touch /var/run/zerotier.wait.pid 86 | while [ "$(ifconfig | grep zt | awk '{print $1}')" = "" ] 87 | do 88 | sleep 1 89 | done 90 | zt0=$(ifconfig | grep zt | awk '{print $1}') 91 | echo "zt interface $zt0 is started!" 92 | if [ -z "$(uci get network.zerotier)" ]; then 93 | uci set network.zerotier=interface 94 | uci set network.zerotier.proto='static' 95 | fi 96 | if [ "$nat" == "1" ]; then 97 | if [ -z "$(uci get firewall.ztzone)" ]; then 98 | uci set firewall.ztzone=zone 99 | uci set firewall.ztzone.input='ACCEPT' 100 | uci set firewall.ztzone.output='ACCEPT' 101 | uci set firewall.ztzone.forward='REJECT' 102 | uci set firewall.ztzone.masq='1' 103 | uci set firewall.ztzone.name='zerotier' 104 | uci set firewall.ztzone.network='zerotier' 105 | fi 106 | else 107 | uci delete firewall.ztzone 108 | fi 109 | if [ "${access//ztfwlan/}" != "$access" ]; then 110 | uci set firewall.ztfwlan=forwarding 111 | uci set firewall.ztfwlan.dest='lan' 112 | uci set firewall.ztfwlan.src='zerotier' 113 | else 114 | uci delete firewall.ztfwlan 115 | fi 116 | if [ "${access//ztfwwan/}" != "$access" ]; then 117 | uci set firewall.ztfwwan=forwarding 118 | uci set firewall.ztfwwan.dest='wan' 119 | uci set firewall.ztfwwan.src='zerotier' 120 | else 121 | uci delete firewall.ztfwwan 122 | fi 123 | if [ "${access//lanfwzt/}" != "$access" ]; then 124 | uci set firewall.lanfwzt=forwarding 125 | uci set firewall.lanfwzt.dest='zerotier' 126 | uci set firewall.lanfwzt.src='lan' 127 | else 128 | uci delete firewall.lanfwzt 129 | fi 130 | if [ "${access//wanfwzt/}" != "$access" ]; then 131 | uci set firewall.wanfwzt=forwarding 132 | uci set firewall.wanfwzt.dest='zerotier' 133 | uci set firewall.wanfwzt.src='wan' 134 | else 135 | uci delete firewall.wanfwzt 136 | fi 137 | uci set network.zerotier.ifname="$zt0" 138 | [ -n "$(uci changes network)" ] && uci commit network && /etc/init.d/network reload 139 | [ -n "$(uci changes firewall)" ] && uci commit firewall && /etc/init.d/firewall reload 140 | rm /var/run/zerotier.wait.pid 141 | ) & 142 | } 143 | 144 | start_service() { 145 | config_load 'zerotier' 146 | config_foreach start_instance 'zerotier' 147 | } 148 | 149 | stop_instance() { 150 | rm -f /tmp/zero.log 151 | local cfg="$1" 152 | 153 | # Remove existing link or folder 154 | rm -rf $CONFIG_PATH 155 | } 156 | 157 | stop_service() { 158 | config_load 'zerotier' 159 | config_foreach stop_instance 'zerotier' 160 | } 161 | 162 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/root/etc/uci-defaults/40_luci-zerotier: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | uci -q batch <<-EOF >/dev/null 4 | delete ucitrack.@zerotier[-1] 5 | add ucitrack zerotier 6 | set ucitrack.@zerotier[-1].init=zerotier 7 | commit ucitrack 8 | EOF 9 | 10 | rm -f /tmp/luci-indexcache 11 | exit 0 12 | -------------------------------------------------------------------------------- /utils/luci-app-zerotier/root/etc/zerotier/zerotier.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Vonger/vocore2/bf45a2ed014f7a850e2ad00b05f43f6114711d45/utils/luci-app-zerotier/root/etc/zerotier/zerotier.log -------------------------------------------------------------------------------- /utils/lvgl-fb-demo/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=lvgl-fb-demo 4 | PKG_RELEASE:=$(AUTORELEASE) 5 | 6 | PKG_SOURCE_PROTO:=git 7 | PKG_SOURCE_URL:=https://github.com/lvgl/lv_port_linux_frame_buffer.git 8 | PKG_SOURCE_DATE:=2022-09-17 9 | PKG_SOURCE_VERSION:=a2384b74cec9ffd7407d12ed64a8326b5696f309 10 | PKG_MIRROR_HASH:=641cf757d63a99c130d8482eb12a6c8682012004fc08f8a4002342dc3c54b063 11 | 12 | include $(INCLUDE_DIR)/package.mk 13 | 14 | define Package/lvgl-fb-demo 15 | SECTION:=vocore2 16 | CATEGORY:=VoCore2 17 | TITLE:=lvgl framebuffer demo 18 | endef 19 | 20 | define Package/lvgl-fb-demo/install 21 | $(INSTALL_DIR) $(1)/usr/bin 22 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/demo $(1)/usr/bin/lvgl-fb-demo 23 | endef 24 | 25 | $(eval $(call BuildPackage,lvgl-fb-demo)) 26 | -------------------------------------------------------------------------------- /utils/lvgl-fb-demo/patches/change-fb-size.patch: -------------------------------------------------------------------------------- 1 | diff --git a/main.c b/main.c 2 | index 33cd734..9138682 100644 3 | --- a/main.c 4 | +++ b/main.c 5 | @@ -29,8 +29,8 @@ int main(void) 6 | lv_disp_drv_init(&disp_drv); 7 | disp_drv.draw_buf = &disp_buf; 8 | disp_drv.flush_cb = fbdev_flush; 9 | - disp_drv.hor_res = 800; 10 | - disp_drv.ver_res = 480; 11 | + disp_drv.hor_res = 480; 12 | + disp_drv.ver_res = 800; 13 | lv_disp_drv_register(&disp_drv); 14 | 15 | evdev_init(); 16 | -------------------------------------------------------------------------------- /utils/lvgl-fb-demo/patches/color-depth-16.patch: -------------------------------------------------------------------------------- 1 | diff --git a/lv_conf.h b/lv_conf.h 2 | index 3137b1a..3f36997 100644 3 | --- a/lv_conf.h 4 | +++ b/lv_conf.h 5 | @@ -30,7 +30,7 @@ extern uint32_t custom_tick_get(void); 6 | *====================*/ 7 | 8 | /*Color depth: 1 (1 byte per pixel), 8 (RGB332), 16 (RGB565), 32 (ARGB8888)*/ 9 | -#define LV_COLOR_DEPTH 32 10 | +#define LV_COLOR_DEPTH 16 11 | 12 | /*Swap the 2 bytes of RGB565 color. Useful if the display has an 8-bit interface (e.g. SPI)*/ 13 | #define LV_COLOR_16_SWAP 0 14 | -------------------------------------------------------------------------------- /utils/lvgl-fb-demo/patches/disable-FBIOBLANK.patch: -------------------------------------------------------------------------------- 1 | diff --git a/lv_drivers/display/fbdev.c b/lv_drivers/display/fbdev.c 2 | index fe8d2ff..7ca425a 100644 3 | --- a/lv_drivers/display/fbdev.c 4 | +++ b/lv_drivers/display/fbdev.c 5 | @@ -98,11 +98,13 @@ void fbdev_init(void) 6 | } 7 | LV_LOG_INFO("The framebuffer device was opened successfully"); 8 | 9 | +/* 10 | // Make sure that the display is on. 11 | if (ioctl(fbfd, FBIOBLANK, FB_BLANK_UNBLANK) != 0) { 12 | perror("ioctl(FBIOBLANK)"); 13 | return; 14 | } 15 | +*/ 16 | 17 | #if USE_BSD_FBDEV 18 | struct fbtype fb; 19 | -------------------------------------------------------------------------------- /utils/lvgl-fb-demo/patches/fix-touchscreen.patch: -------------------------------------------------------------------------------- 1 | diff --git a/lv_drv_conf.h b/lv_drv_conf.h 2 | index d40e703..aa5b7d5 100644 3 | --- a/lv_drv_conf.h 4 | +++ b/lv_drv_conf.h 5 | @@ -447,7 +447,7 @@ 6 | #endif 7 | 8 | #if USE_EVDEV || USE_BSD_EVDEV 9 | -# define EVDEV_NAME "/dev/input/event10" /*You can use the "evtest" Linux tool to get the list of devices and test them*/ 10 | +# define EVDEV_NAME "/dev/input/event0" /*You can use the "evtest" Linux tool to get the list of devices and test them*/ 11 | # define EVDEV_SWAP_AXES 0 /*Swap the x and y axes of the touchscreen*/ 12 | 13 | # define EVDEV_CALIBRATE 0 /*Scale and offset the touchscreen coordinates by using maximum and minimum values for each axis*/ 14 | -------------------------------------------------------------------------------- /utils/mem/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=mem 4 | PKG_RELEASE:=1 5 | 6 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) 7 | PKG_CONFIG_DEPENDS:= 8 | 9 | include $(INCLUDE_DIR)/package.mk 10 | include $(INCLUDE_DIR)/kernel.mk 11 | 12 | define Package/mem 13 | SECTION:=vocore2 14 | CATEGORY:=VoCore2 15 | TITLE:=Modify registers from user space 16 | endef 17 | 18 | define Package/mem/description 19 | used to read/write main chip register. 20 | endef 21 | 22 | define Build/Prepare 23 | mkdir -p $(PKG_BUILD_DIR) 24 | $(CP) ./src/* $(PKG_BUILD_DIR)/ 25 | endef 26 | 27 | define Build/Configure 28 | endef 29 | 30 | define Package/mem/install 31 | $(INSTALL_DIR) $(1)/usr/bin 32 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/mem $(1)/usr/bin 33 | endef 34 | 35 | $(eval $(call BuildPackage,mem)) 36 | 37 | -------------------------------------------------------------------------------- /utils/mem/src/Makefile: -------------------------------------------------------------------------------- 1 | EXEC = mem 2 | OBJS = mem.o 3 | 4 | all: $(EXEC) 5 | 6 | $(EXEC): $(OBJS) 7 | $(CC) $(LDFLAGS) -o $@ $(OBJS) 8 | 9 | clean: 10 | -rm -f $(EXEC) *.elf *.gdb *.o 11 | -------------------------------------------------------------------------------- /utils/mem/src/mem.c: -------------------------------------------------------------------------------- 1 | // author: Vonger Chin 2 | // date: May.29, 2015 3 | // compile: gcc mem.c -o mem 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #define PAGE_SIZE 4096 13 | 14 | void bit_print(const unsigned char* s, FILE *fp) 15 | { 16 | uint32_t d = *(uint32_t *)s; 17 | int i; 18 | 19 | for (i = 31; i >= 16; i--) 20 | fprintf(fp, "%02d:%d ", i, (d >> i) & 0x1); 21 | fprintf(fp, "\n"); 22 | for (i = 15; i >= 0; i--) 23 | fprintf(fp, "%02d:%d ", i, (d >> i) & 0x1); 24 | fprintf(fp, "\n"); 25 | } 26 | 27 | void hex_print(const unsigned char* s, int size, FILE *fp) 28 | { 29 | int i = 0, n = 0, c = 0, p = 0; 30 | 31 | // default print to stdout. 32 | if (fp == NULL) 33 | fp = stdout; 34 | 35 | while(1) { 36 | n = size > 0x10 ? 0x10 : size; 37 | size -= n; 38 | 39 | p += fprintf(fp, "%08X: ", c); 40 | for(i = 0; i < n; i++) { 41 | if(i == 8) { 42 | p += fprintf(fp, " "); 43 | } 44 | p += fprintf(fp, "%02X ", *(s + c + i)); 45 | } 46 | for(i = n; i < 0x10; i++) { 47 | if(i == 8) { 48 | p += fprintf(fp, " "); 49 | } 50 | p += fprintf(fp, " "); 51 | } 52 | p += fprintf(fp, " "); 53 | for(i = 0; i < n; i++) { 54 | if(*(s + c + i) >= 0x20 && *(s + c + i) <= 0x7E) { 55 | p += fprintf(fp, "%c", *(s + c + i)); 56 | } else { 57 | p += fprintf(fp, "."); 58 | } 59 | } 60 | p += fprintf(fp, "\n"); 61 | if(size <= 0) { 62 | break; 63 | } 64 | c += n; 65 | } 66 | } 67 | 68 | // if c is not a valid char, return 0. 69 | #define hexchar2int(c) \ 70 | ((c >= '0' && c <= '9') ? (c - '0') : ((c >= 'A' && c <= 'F') ? \ 71 | c - 'A' + 0xA : ((c >= 'a' && c <= 'f') ? c - 'a' + 0xA : 0))) 72 | 73 | #define octchar2int(c) \ 74 | ((c >= '0' && c <= '7') ? (c - '0') : 0) 75 | 76 | #define decchar2int(c) \ 77 | ((c >= '0' && c <= '9') ? (c - '0') : 0) 78 | 79 | 80 | // convert string to unsigned int. 81 | // hex: 0x, oct: 0, bin: ...b, dec: normal. 82 | unsigned int atou(char* s) 83 | { 84 | char *p = s, *e = s; 85 | unsigned int r = 0; 86 | 87 | while(*e != '\0') 88 | e++; 89 | 90 | if(*p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X')) { 91 | // hex: skip first 0x or 0X header. 92 | p += 2; 93 | 94 | while(p != e) { 95 | r <<= 4; 96 | r += hexchar2int(*p); 97 | p++; 98 | } 99 | } else if((e - p) >= 2 && *(e - 1) == 'b') { 100 | // bin: ignore last b. 101 | e--; 102 | 103 | while(p != e) { 104 | r <<= 1; 105 | r += (*p == '0' ? 0 : 1); 106 | p++; 107 | } 108 | } else if(*p == '0') { 109 | // oct: skip first 0 header. 110 | p += 1; 111 | 112 | while(p != e) { 113 | r <<= 3; 114 | r += octchar2int(*p); 115 | p++; 116 | } 117 | } else { 118 | // dec: we do not need to deal the number. 119 | while(p != e) { 120 | r *= 10; 121 | r += decchar2int(*p); 122 | p++; 123 | } 124 | } 125 | 126 | return r; 127 | } 128 | 129 | 130 | // convert string to unsigned int. 131 | // hex: 0x, oct: 0, bin: ...b, dec: normal. 132 | unsigned int atox(char* s) 133 | { 134 | char *p = s, *e = s; 135 | unsigned int r = 0; 136 | 137 | while(*e != '\0') 138 | e++; 139 | 140 | if(*p == '0' && (*(p + 1) == 'x' || *(p + 1) == 'X')) { 141 | // hex: skip first 0x or 0X header. 142 | p += 2; 143 | 144 | while(p != e) { 145 | r <<= 4; 146 | r += ((*p >= '0' && *p <= '9') ? (*p - '0') : ((*p >= 'A' && *p <= 'F') ? 147 | *p - 'A' + 0xA : ((*p >= 'a' && *p <= 'f') ? *p - 'a' + 0xA : 0))); 148 | p++; 149 | } 150 | } else if((e - p) >= 2 && *(e - 1) == 'b') { 151 | // bin: ignore last b. 152 | e--; 153 | 154 | while(p != e) { 155 | r <<= 1; 156 | r += (*p == '0' ? 0 : 1); 157 | p++; 158 | } 159 | } else if(*p == '0') { 160 | // oct: skip first 0 header. 161 | p += 1; 162 | 163 | while(p != e) { 164 | r <<= 3; 165 | r += ((*p >= '0' && *p <= '7') ? (*p - '0') : 0); 166 | p++; 167 | } 168 | } else { 169 | // dec: we do not need to deal the number. 170 | while(p != e) { 171 | r *= 10; 172 | r += ((*p >= '0' && *p <= '9') ? (*p - '0') : 0); 173 | p++; 174 | } 175 | } 176 | 177 | return r; 178 | } 179 | 180 | 181 | // get one page, system memory map by page number. 182 | unsigned char *mmap_page(unsigned int page) 183 | { 184 | int fd = -1; 185 | unsigned char *mem = NULL; 186 | 187 | fd = open("/dev/mem", O_RDWR); 188 | if(fd < 0) 189 | return NULL; 190 | 191 | mem = (unsigned char *)mmap(0, PAGE_SIZE, 192 | PROT_READ | PROT_WRITE, MAP_SHARED, fd, page * PAGE_SIZE); 193 | close(fd); 194 | 195 | return mem; 196 | } 197 | 198 | int main(int argc, char *argv[]) 199 | { 200 | unsigned char *mem = NULL; 201 | unsigned int pos = 0, page = 0; 202 | unsigned int addr = 0, size = 0, data = 0; 203 | int bitmode = 0; 204 | 205 | if (argc == 1) { 206 | printf("usage: mem [addr] [value] [bit]\n"); 207 | return 0; 208 | } 209 | 210 | // show address data in 32 bit, for read only. 211 | if (!strncmp(argv[argc - 1], "bit", 3)) { 212 | bitmode = 1; 213 | argc--; 214 | } 215 | 216 | switch(argc) { 217 | case 2: { // memory show mode. 218 | addr = atou(argv[1]); 219 | size = 0x40; 220 | 221 | page = addr / PAGE_SIZE; 222 | pos = addr % PAGE_SIZE; 223 | 224 | if(size + pos > PAGE_SIZE) { 225 | size = PAGE_SIZE - pos; 226 | printf("warning: size exceed one page, resize to %d.\n", size); 227 | } 228 | 229 | mem = mmap_page(page); 230 | if(mem == NULL) { 231 | printf("can not map memory.\n"); 232 | return -1; 233 | } 234 | 235 | // print request memory area. 236 | if (bitmode) 237 | bit_print(mem + pos, stdout); 238 | else 239 | hex_print(mem + pos, size, stdout); 240 | 241 | munmap(mem, PAGE_SIZE); 242 | break; } 243 | 244 | case 3: // memory set mode. 245 | addr = atou(argv[1]); 246 | data = atou(argv[2]); 247 | 248 | page = addr / PAGE_SIZE; 249 | pos = addr % PAGE_SIZE; 250 | 251 | mem = mmap_page(page); 252 | if(mem == NULL) { 253 | printf("can not map memory.\n"); 254 | return -1; 255 | } 256 | 257 | printf("0x%08X: 0x%08X => ", addr, *(unsigned int *)(mem + pos)); 258 | *((unsigned int *)(mem + pos)) = data; 259 | printf("0x%08X\n", *(unsigned int *)(mem + pos)); 260 | 261 | munmap(mem, PAGE_SIZE); 262 | break; 263 | 264 | default: 265 | printf("usage: \n" 266 | "\tmem [addr]: show 0x40 bytes at addr.\n" 267 | "\tmem [addr] [data]: set addr with data(32bit).\n"); 268 | break; 269 | } 270 | return 0; 271 | } 272 | 273 | -------------------------------------------------------------------------------- /utils/memtester/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=memtester 4 | PKG_VERSION:=4.5.1 5 | 6 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 7 | PKG_SOURCE_URL:=https://gentoo.osuosl.org/distfiles/ 8 | PKG_MD5SUM:=1bc22c01e987d6a67fac39dc5656a4d3 9 | 10 | include $(INCLUDE_DIR)/package.mk 11 | 12 | define Package/memtester 13 | SECTION:=utils 14 | CATEGORY:=Utilities 15 | TITLE:=memory test program, userspace 16 | endef 17 | 18 | define Build/Compile 19 | sed -i -e "s/^cc/$(TARGET_CC)/" $(PKG_BUILD_DIR)/conf-cc 20 | sed -i -e "s/^cc/$(TARGET_CC)/" $(PKG_BUILD_DIR)/conf-ld 21 | $(MAKE) -C $(PKG_BUILD_DIR) 22 | endef 23 | 24 | 25 | define Package/memtester/install 26 | $(INSTALL_DIR) $(1)/usr/bin 27 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/memtester $(1)/usr/bin/memtester 28 | endef 29 | 30 | $(eval $(call BuildPackage,memtester)) 31 | -------------------------------------------------------------------------------- /utils/mt7628tool/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=mt7628tool 4 | PKG_RELEASE:=1 5 | 6 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) 7 | PKG_CONFIG_DEPENDS:= CONFIG_KERNEL_DEVMEM 8 | 9 | include $(INCLUDE_DIR)/package.mk 10 | include $(INCLUDE_DIR)/kernel.mk 11 | 12 | define Package/mt7628tool 13 | SECTION:=vocore2 14 | CATEGORY:=VoCore2 15 | TITLE:=mt7628 tool 16 | endef 17 | 18 | define Package/mt7628tool/description 19 | use for get mt7628's temperature, etc. 20 | need /dev/mem 21 | endef 22 | 23 | define Build/Prepare 24 | mkdir -p $(PKG_BUILD_DIR) 25 | $(CP) ./src/* $(PKG_BUILD_DIR)/ 26 | endef 27 | 28 | define Build/Configure 29 | endef 30 | 31 | define Package/mt7628tool/install 32 | $(INSTALL_DIR) $(1)/usr/bin 33 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/mt7628tool $(1)/usr/bin 34 | endef 35 | 36 | $(eval $(call BuildPackage,mt7628tool)) 37 | 38 | -------------------------------------------------------------------------------- /utils/mt7628tool/src/README.md: -------------------------------------------------------------------------------- 1 | # mt7628 tool 2 | 3 | ## get temperature 4 | 5 | ``` 6 | mt7628tool temperature 7 | ``` 8 | -------------------------------------------------------------------------------- /utils/mt7628tool/src/makefile: -------------------------------------------------------------------------------- 1 | CFLAGS += -Wall -Wextra 2 | 3 | PREFIX ?= /usr/local 4 | 5 | all: mt7628tool 6 | 7 | mt7628tool: 8 | $(CC) $(CFLAGS) mt7628tool.c -o mt7628tool 9 | 10 | clean: 11 | rm -fv mt7628tool 12 | -------------------------------------------------------------------------------- /utils/openocd/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (C) 2015 OpenWrt.org 3 | # 4 | # This is free software, licensed under the GNU General Public License v2. 5 | # See /LICENSE for more information. 6 | # 7 | 8 | include $(TOPDIR)/rules.mk 9 | 10 | PKG_NAME:=openocd 11 | PKG_SOURCE_VERSION:=0.10.0 12 | PKG_VERSION:=v$(PKG_SOURCE_VERSION) 13 | PKG_RELEASE:=2 14 | 15 | PKG_SOURCE_URL:=@SF/openocd 16 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_SOURCE_VERSION).tar.bz2 17 | PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_SOURCE_VERSION) 18 | PKG_HASH:=7312e7d680752ac088b8b8f2b5ba3ff0d30e0a78139531847be4b75c101316ae 19 | PKG_LICENSE:=GPL-2.0 20 | PKG_LICENSE_FILES:=COPYING 21 | 22 | PKG_MAINTAINER:=Paul Fertser 23 | PKG_CPE_ID:=cpe:/a:openocd:open_on-chip_debugger 24 | 25 | PKG_BUILD_PARALLEL:=1 26 | PKG_INSTALL:=1 27 | PKG_FIXUP:=autoreconf 28 | 29 | include $(INCLUDE_DIR)/package.mk 30 | include $(INCLUDE_DIR)/nls.mk 31 | 32 | define Package/openocd 33 | SECTION:=utils 34 | CATEGORY:=Utilities 35 | TITLE:=OpenOCD Utility 36 | URL:=http://openocd.sf.net/ 37 | DEPENDS:=+libusb-1.0 +libusb-compat +libftdi1 +hidapi 38 | endef 39 | 40 | define Package/openocd/description 41 | OpenOCD provides on-chip programming and debugging support with a 42 | layered architecture of JTAG interface and TAP support including: 43 | 44 | - (X)SVF playback to facilitate automated boundary scan and FPGA/CPLD 45 | programming; 46 | - debug target support (e.g. ARM, MIPS): single-stepping, 47 | breakpoints/watchpoints, gprof profiling, etc; 48 | - flash chip drivers (e.g. CFI, NAND, internal flash); 49 | - embedded TCL interpreter for easy scripting. 50 | 51 | Several network interfaces are available for interacting with OpenOCD: 52 | telnet, TCL, and GDB. The GDB server enables OpenOCD to function as a 53 | "remote target" for source-level debugging of embedded systems using 54 | the GNU GDB program (and the others who talk GDB protocol, e.g. IDA 55 | Pro). 56 | endef 57 | 58 | CONFIGURE_ARGS += \ 59 | --prefix="/usr" \ 60 | --disable-werror \ 61 | MAKEINFO=true \ 62 | --enable-dummy \ 63 | --enable-sysfsgpio 64 | 65 | define Build/Compile 66 | +$(MAKE_VARS) \ 67 | $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) 68 | endef 69 | 70 | define Package/openocd/install 71 | $(INSTALL_DIR) $(1)/usr/bin 72 | $(INSTALL_DIR) $(1)/usr/share/openocd 73 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openocd $(1)/usr/bin/ 74 | $(CP) $(PKG_INSTALL_DIR)/usr/share/openocd/scripts $(1)/usr/share/openocd 75 | endef 76 | 77 | $(eval $(call BuildPackage,openocd)) 78 | -------------------------------------------------------------------------------- /utils/openocd/patches/100-bind-localhost-only.patch: -------------------------------------------------------------------------------- 1 | Subject: Bind to IPv4 localhost by default 2 | Origin: other, http://openocd.zylin.com/#/c/4331/2 3 | Last-Update: 2018-01-18 4 | 5 | From f8630b0b15e30dc6c51270006a4e075c79cf466a Mon Sep 17 00:00:00 2001 6 | From: Paul Fertser 7 | Date: Sat, 13 Jan 2018 16:22:10 +0300 8 | Subject: [PATCH] server: bind to IPv4 localhost by default 9 | 10 | Since OpenOCD basically allows to perform arbitrary actions on behalf of 11 | the running user, it makes sense to restrict the exposure by default. 12 | 13 | If you need network connectivity and your environment is safe enough, 14 | use "bindto 0.0.0.0" to switch to the old behaviour. 15 | 16 | Change-Id: I4a4044b90d0ecb30118cea96fc92a7bcff0924e0 17 | Signed-off-by: Paul Fertser 18 | --- 19 | 20 | diff --git a/doc/openocd.texi b/doc/openocd.texi 21 | index 7f5b72e..5c7f465 100644 22 | --- a/doc/openocd.texi 23 | +++ b/doc/openocd.texi 24 | @@ -7017,7 +7017,7 @@ 25 | 26 | @deffn Command bindto [name] 27 | Specify address by name on which to listen for incoming TCP/IP connections. 28 | -By default, OpenOCD will listen on all available interfaces. 29 | +By default, OpenOCD will listen on the loopback interface only. 30 | @end deffn 31 | 32 | @anchor{targetstatehandling} 33 | diff --git a/src/server/server.c b/src/server/server.c 34 | index 1e52e97..ea1e898 100644 35 | --- a/src/server/server.c 36 | +++ b/src/server/server.c 37 | @@ -259,7 +259,7 @@ 38 | c->sin.sin_family = AF_INET; 39 | 40 | if (bindto_name == NULL) 41 | - c->sin.sin_addr.s_addr = INADDR_ANY; 42 | + c->sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); 43 | else { 44 | hp = gethostbyname(bindto_name); 45 | if (hp == NULL) { 46 | -------------------------------------------------------------------------------- /utils/openocd/patches/101-cve-2018-5704-css-fix.patch: -------------------------------------------------------------------------------- 1 | Subject: Prevent some forms of Cross Protocol Scripting attacks 2 | Author: Andreas Fritiofson 3 | Origin: other, http://openocd.zylin.com/#/c/4335/ 4 | Bug-Debian: https://bugs.debian.org/887488 5 | Last-Update: 2018-01-18 6 | 7 | From 3a223ca3ebc7ac24d7726a0cd58e5695bc813657 Mon Sep 17 00:00:00 2001 8 | From: Andreas Fritiofson 9 | Date: Sat, 13 Jan 2018 21:00:47 +0100 10 | Subject: [PATCH] CVE-2018-5704: Prevent some forms of Cross Protocol Scripting attacks 11 | 12 | OpenOCD can be targeted by a Cross Protocol Scripting attack from 13 | a web browser running malicious code, such as the following PoC: 14 | 15 | var x = new XMLHttpRequest(); 16 | x.open("POST", "http://127.0.0.1:4444", true); 17 | x.send("exec xcalc\r\n"); 18 | 19 | This mitigation should provide some protection from browser-based 20 | attacks and is based on the corresponding fix in Redis: 21 | 22 | https://github.com/antirez/redis/blob/8075572207b5aebb1385c4f233f5302544439325/src/networking.c#L1758 23 | 24 | Change-Id: Ia96ebe19b74b5805dc228bf7364c7971a90a4581 25 | Signed-off-by: Andreas Fritiofson 26 | Reported-by: Josef Gajdusek 27 | --- 28 | 29 | diff --git a/src/server/startup.tcl b/src/server/startup.tcl 30 | index 64ace40..dd1b31e 100644 31 | --- a/src/server/startup.tcl 32 | +++ b/src/server/startup.tcl 33 | @@ -8,3 +8,14 @@ 34 | # one target 35 | reset halt 36 | } 37 | + 38 | +proc prevent_cps {} { 39 | + echo "Possible SECURITY ATTACK detected." 40 | + echo "It looks like somebody is sending POST or Host: commands to OpenOCD." 41 | + echo "This is likely due to an attacker attempting to use Cross Protocol Scripting" 42 | + echo "to compromise your OpenOCD instance. Connection aborted." 43 | + exit 44 | +} 45 | + 46 | +proc POST {args} { prevent_cps } 47 | +proc Host: {args} { prevent_cps } 48 | -------------------------------------------------------------------------------- /utils/paho.mqtt.c/Makefile: -------------------------------------------------------------------------------- 1 | include $(TOPDIR)/rules.mk 2 | 3 | PKG_NAME:=paho.mqtt.c 4 | PKG_VERSION:=1.3.1 5 | PKG_RELEASE:=1 6 | 7 | PKG_SOURCE_URL:=https://github.com/eclipse/paho.mqtt.c/archive/ 8 | PKG_SOURCE:=v$(PKG_VERSION).zip 9 | PKG_MD5SUM:=e53729db4585b41d0661065667503048 10 | 11 | include $(INCLUDE_DIR)/package.mk 12 | 13 | define Package/paho.mqtt.c 14 | SECTION:=utils 15 | CATEGORY:=Utilities 16 | TITLE+=paho.mqtt.c for OpenWrt 17 | DEPENDS:=+libopenssl 18 | endef 19 | 20 | define Package/paho.mqtt.c/description 21 | endef 22 | 23 | define Build/Compile 24 | $(MAKE) -C $(PKG_BUILD_DIR) \ 25 | LINUX="$(LINUX_DIR)" \ 26 | CC="$(TARGET_CC)" \ 27 | STAGING_DIR="$(STAGING_DIR)" \ 28 | LDFLAGS="$(TARGET_LDFLAGS)" \ 29 | CFLAGS="$(TARGET_CFLAGS)" 30 | endef 31 | 32 | define Package/paho.mqtt.c/install 33 | $(INSTALL_DIR) $(1)/usr/lib 34 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/build/output/*s.so.* $(1)/usr/lib/ 35 | endef 36 | 37 | 38 | $(eval $(call BuildPackage,paho.mqtt.c)) 39 | -------------------------------------------------------------------------------- /utils/paho.mqtt.c/patches/001-fix-cross-compile-macos.patch: -------------------------------------------------------------------------------- 1 | --- a/Makefile 2 | +++ b/Makefile 3 | @@ -37,6 +37,7 @@ 4 | MACHINETYPE ?= $(shell uname -m) 5 | build.level = $(shell date) 6 | endif # OS 7 | +OSTYPE = linux 8 | ifeq ($(OSTYPE),linux) 9 | OSTYPE = Linux 10 | endif 11 | -------------------------------------------------------------------------------- /utils/shellinabox/Makefile: -------------------------------------------------------------------------------- 1 | 2 | include $(TOPDIR)/rules.mk 3 | 4 | PKG_NAME:=shellinabox 5 | PKG_VERSION:=2.19 6 | PKG_RELEASE:=$(PKG_SOURCE_VERSION) 7 | 8 | PKG_SOURCE_PROTO:=git 9 | PKG_SOURCE_URL:=https://github.com/shellinabox/shellinabox.git 10 | PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION) 11 | PKG_SOURCE_VERSION:=05b2d3630c48dc9bca678d8158fce486c583c26b 12 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz 13 | 14 | PKG_FIXUP:=autoreconf 15 | 16 | include $(INCLUDE_DIR)/package.mk 17 | 18 | define Package/shellinabox 19 | SECTION:=net 20 | CATEGORY:=Network 21 | TITLE:=a web based terminal emulator 22 | URL:=https://github.com/shellinabox/shellinabox 23 | DEPENDS:=+zlib +libopenssl +busybox +@BUSYBOX_CUSTOM +@BUSYBOX_CONFIG_LOGIN 24 | endef 25 | 26 | define Package/shellinabox/description 27 | Shell In A Box implements a web server that 28 | can export arbitrary command line tools to 29 | a web based terminal emulator. This emulator 30 | is accessible to any JavaScript and CSS 31 | enabled web browser and does not require any additional browser plugins. 32 | endef 33 | 34 | CONFIGURE_ARGS += --disable-utmp 35 | 36 | define Package/shellinabox/install 37 | $(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/shellinabox 38 | $(INSTALL_BIN) $(PKG_BUILD_DIR)/shellinaboxd $(1)/usr/sbin 39 | $(INSTALL_BIN) ./files/shellinaboxd.init $(1)/etc/init.d/shellinaboxd 40 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/shellinabox/*.css $(1)/etc/shellinabox 41 | $(PKG_BUILD_DIR)/make-chained-cert.sh > $(1)/etc/shellinabox/certificate.pem 42 | endef 43 | 44 | $(eval $(call BuildPackage,shellinabox)) 45 | -------------------------------------------------------------------------------- /utils/shellinabox/README.md: -------------------------------------------------------------------------------- 1 | # shellinabox 2 | OpenWrt packet of shellinabox 3 | 4 | $ git clone https://github.com/paradislover/shellinabox.git 5 | 6 | $ make package/shellinabox/compile 7 | -------------------------------------------------------------------------------- /utils/shellinabox/files/shellinaboxd.init: -------------------------------------------------------------------------------- 1 | #!/bin/sh /etc/rc.common 2 | # Copyright (C) 2015 snqu.com 3 | 4 | USE_PROCD=1 5 | START=99 6 | 7 | BIN=/usr/sbin/shellinaboxd 8 | 9 | start_service() { 10 | procd_open_instance 11 | procd_set_param command $BIN -u root -c /etc/shellinabox \ 12 | --css=/etc/shellinabox/black-on-white.css \ 13 | --css=/etc/shellinabox/white-on-black.css \ 14 | --user-css Normal:+/etc/shellinabox/black-on-white.css,Reverse:-/etc/shellinabox/white-on-black.css 15 | procd_close_instance 16 | } 17 | 18 | -------------------------------------------------------------------------------- /utils/shellinabox/patches/001-fix-compile-issue.patch: -------------------------------------------------------------------------------- 1 | diff --git a/shellinabox/launcher.c b/shellinabox/launcher.c 2 | index ba54b36..c802e00 100644 3 | --- a/shellinabox/launcher.c 4 | +++ b/shellinabox/launcher.c 5 | @@ -769,7 +769,7 @@ void closeAllFds(int *exceptFds, int num) { 6 | } 7 | 8 | #if !defined(HAVE_PTSNAME_R) 9 | -static int ptsname_r(int fd, char *buf, size_t buflen) { 10 | +int ptsname_r(int fd, char *buf, size_t buflen) { 11 | // It is unfortunate that ptsname_r is not universally available. 12 | // For the time being, this is not a big problem, as ShellInABox is 13 | // single-threaded (and so is the launcher process). But if this 14 | --------------------------------------------------------------------------------