diff --git a/.github/workflows/Openwrt-AutoBuild.yml b/.github/workflows/Openwrt-AutoBuild.yml index b8426e3b2496..0ddeaa956159 100644 --- a/.github/workflows/Openwrt-AutoBuild.yml +++ b/.github/workflows/Openwrt-AutoBuild.yml @@ -118,7 +118,7 @@ jobs: ( sudo -E apt-get -qq update sudo -E apt-get -qq install build-essential clang flex g++ gawk gcc-multilib gettext \ git libncurses5-dev libssl-dev python3-distutils rsync unzip zlib1g-dev swig libpython3-dev aria2 jq subversion qemu-utils ccache rename libelf-dev device-tree-compiler - sudo -E apt-get -qq purge azure-cli ghc* zulu* hhvm llvm* firefox powershell openjdk* dotnet* google* mysql* php* android* + sudo -E apt-get -qq purge azure-cli ghc* zulu* llvm* firefox powershell openjdk* dotnet* google* mysql* php* android* sudo rm -rf /etc/apt/sources.list.d/* /usr/share/dotnet /usr/local/lib/android /opt/ghc sudo -E apt-get -qq autoremove --purge sudo -E apt-get -qq clean ) & @@ -203,6 +203,15 @@ jobs: find "devices/${{matrix.target}}/patches" -maxdepth 1 -type f -name '*.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -B --merge -p1 -E --forward" #git apply devices/${{matrix.target}}/patches/*.patch fi + sed -i '$a \ + CONFIG_CPU_FREQ_GOV_POWERSAVE=y \ + CONFIG_CPU_FREQ_GOV_USERSPACE=y \ + CONFIG_CPU_FREQ_GOV_ONDEMAND=y \ + CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y \ + CONFIG_CRYPTO_CHACHA20_NEON=y \ + CONFIG_CRYPTO_CHACHA20POLY1305=y \ + CONFIG_FAT_DEFAULT_IOCHARSET="utf8" \ + ' `find target/linux -path "target/linux/*/config-*"` - name: Default PPPOE Setting if: env.PPPOE_USERNAME && env.PPPOE_PASSWD diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 000000000000..eac633f69040 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,18 @@ +name: Docker Image CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the Docker image + run: docker build . --file Dockerfile --tag my-image-name:$(date +%s) diff --git a/README.md b/README.md index a0780aa44c04..1446750ac4ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ #### 一分钟在线编译定制专属固件: [supes.top](https://supes.top) #### 支持200+设备: -X86/64, 友善 NanoPi、R2S、R4S、R4SE、R5S、R2C、NEO3, 斐讯 N1、K2P、K3, 树莓派 4B、3B/3B+、2B, 电犀牛r68s、r66s, 香橙派 R1 Plus、R1 Plus LTS, 红米AX6, 小米AX3600, 小米AX9000, 红米AX6S/小米AX3200, 红米AC2100, 小米AC2100, 斐讯K3, 360V6, 玩客云, 极路由 HIWIFI HC5962(极路由4、B70)、HC5661A、HC5761A、HC5861B, 小米4, 小米 R3G, 小米 R3P, newifi-d2 (新路由3), 小娱XY-C5, 竞斗云2.0(P&W R619AC), GL.iNet GL-MT1300、GL-AX1800、GL-AXT1800、GL-microuter-N300、GL-MT300N V2, 小米CR660X(CR6606/CR6608/CR6609), 小米4A千兆版, 小米 R3G-v2, 小米青春版Nano, 迅雷下载宝 timecloud, 优酷 yk-l2, 有华 wr1200js, 向日葵 X3A, 华硕 ASUS RT-ACRH17、RT-AC58u/RT-ACRH13、RT-ac85p、RT-n56u-b1、RT-AC88U、RT-AC1200、RT-AC1200 V2, 网件 NETGEAR R6220、R6260、R6120、R6700-v2、R6800、R6850、R6900-v2、R7450、wndr3700-v5, H1 Box, 贝壳云P1, 我家云lL Pro, x96 Max, 微加云V-Plus, 章鱼星球ZYXQ, GT-King, Odroid N2, MXQ Pro+, 京东无线宝JDCloud RE-SP-01B, Linksys WRT1200AC、WRT1900AC v1、WRT1900AC v2、WRT3200ACM、WRT1900ACS v1、WRT1900ACS v2、WRT32X、EA7500 v2 等 +X86/64, 友善 NanoPi、R2S、R4S、R4SE、R5S、R2C、R5C、R6S、NEO3, 斐讯 N1、K2P、K3, 树莓派 4B、3B/3B+、2B, 电犀牛r68s、r66s, 香橙派 R1 Plus、R1 Plus LTS, 红米AX6, 小米AX3600, 小米AX9000, 红米AX6000, 红米AX6S/小米AX3200, 红米AC2100, 小米AC2100, 斐讯K3, 360V6, 玩客云, 极路由 HIWIFI HC5962(极路由4、B70)、HC5661A、HC5761A、HC5861B, 小米4, 小米 R3G, 小米 R3P, newifi-d2 (新路由3), 小娱XY-C5, 竞斗云2.0(P&W R619AC), GL.iNet GL-MT1300、GL-AX1800、GL-AXT1800、GL-microuter-N300、GL-MT300N V2, 小米CR660X(CR6606/CR6608/CR6609), 小米4A千兆版, 小米 R3G-v2, 小米青春版Nano, 迅雷下载宝 timecloud, 优酷 yk-l2, 有华 wr1200js, 向日葵 X3A, 华硕 ASUS RT-ACRH17、RT-AC58u/RT-ACRH13、RT-ac85p、RT-n56u-b1、RT-AC88U、RT-AC1200、RT-AC1200 V2, 网件 NETGEAR R6220、R6260、R6120、R6700-v2、R6800、R6850、R6900-v2、R7450、wndr3700-v5, H1 Box, 贝壳云P1, 我家云lL Pro, x96 Max, 微加云V-Plus, 章鱼星球ZYXQ, GT-King, Odroid N2, MXQ Pro+, 京东无线宝JDCloud RE-SP-01B, Linksys WRT1200AC、WRT1900AC v1、WRT1900AC v2、WRT3200ACM、WRT1900ACS v1、WRT1900ACS v2、WRT32X、EA7500 v2 等 [1]: https://img.shields.io/badge/license-GPLV2-brightgreen.svg [2]: /LICENSE @@ -31,22 +31,18 @@ X86/64, 友善 NanoPi、R2S、R4S、R4SE、R5S、R2C、NEO3, 斐讯 N1、K2P、K + 自建插件仓库囊括了市面上几乎所有开源插件,插件库日更,系统自动更新所有已安装插件. -+ 通过[supes.top](https://supes.top)在线定制专属固件, 无需任何专业知识, 一分钟生成. 同时支持github云编译和本地一键编译. ++ 通过[supes.top](https://supes.top)在线定制专属固件, 无需任何专业知识, 一分钟生成. 同时支持github云编译. + 后台一键OTA更新固件,省去了每次固件升级都需要找固件,下载固件,上传固件等繁琐操作. + 后台一键设置旁路由,一键开关IPv6. -+ 支持在线安装Kmod内核模块. - -+ 重构版SSR-PLUS,国内外智能DNS解析,支持DOH,Trojan-Go等 ++ 支持在线安装全部Kmod内核模块. + 替换 Uhttpd 为 Nginx, 支持 反向代理; WebDAV等诸多玩法. + 性能,友好度,易用性,插件,以及针对国内特殊环境等的自定义优化, 开箱即用 -+ 自定制清爽Material风格新主题Edge - ## 2. **固件** 固件生成有3种方式:在线定制化生成、GitHub编译、本地化编译。 @@ -67,31 +63,6 @@ X86/64, 友善 NanoPi、R2S、R4S、R4SE、R5S、R2C、NEO3, 斐讯 N1、K2P、K ### 2.3 **GitHub结合浏览器插件编译** 请在支持油猴的浏览器中安装 [脚本](https://greasyfork.org/scripts/407616-github-actions-trigger/code/Github%20Actions%20Trigger.user.js) ,仓库右上角会出现 x86_64 Actions,K2P Actions等按钮,点击对应按钮即可.更多玩法 [repo-dispatcher](https://github.com/tete1030/github-repo-dispatcher) -### 2.4 **本地化编译** - -#### 注意: - -1. **不**要用 **root** 用户 git 和编译!!! - -2. 国内用户编译前请准备好梯子,使用大陆白名单或全局模式 - -3. 请使用Ubuntu 64bit,推荐 Ubuntu 18 或 Ubuntu 20 - -#### 首次编译: - -``` -screen -S openwrt -bash -c "$(curl -fsSL https://git.io/opbuild.sh)" -``` - -#### 二次编译: - -``` -screen -S openwrt -bash -c "$(curl -fsSL https://git.io/rebuild.sh)" -``` - - ## 3. **使用** ### 3.1 **后台** diff --git a/devices/armvirt_pcat/.config b/devices/armvirt_pcat/.config deleted file mode 100644 index c1df83b7488c..000000000000 --- a/devices/armvirt_pcat/.config +++ /dev/null @@ -1,10 +0,0 @@ -CONFIG_TARGET_armvirt_pcat=y -CONFIG_TARGET_armvirt_pcat_64=y -CONFIG_TARGET_armvirt_pcat_64_Default=y -CONFIG_TARGET_ROOTFS_SQUASHFS=y -CONFIG_TARGET_IMAGES_GZIP=y - -CONFIG_PACKAGE_luci-ssl=n # uhttpd服务 -CONFIG_PACKAGE_luci-ssl-nginx=y # nginx - - diff --git a/devices/armvirt_pcat/diy.sh b/devices/armvirt_pcat/diy.sh deleted file mode 100644 index 1430c53a991b..000000000000 --- a/devices/armvirt_pcat/diy.sh +++ /dev/null @@ -1,16 +0,0 @@ - - -SHELL_FOLDER=$(dirname $(readlink -f "$0")) -bash $SHELL_FOLDER/../common/kernel_5.15.sh - -mv -f target/linux/armvirt target/linux/armvirt_pcat - -#svn co https://github.com/photonicat/rockchip_rk3568_openwrt_packages/trunk/utils/pcat-manager feeds/packages/utils/pcat-manager -#ln -sf $SHELL_FOLDER/../../feeds/packages/utils/pcat-manager package/feeds/packages/pcat-manager - - -svn co https://github.com/photonicat/rockchip_rk3568_openwrt/trunk/files files - -mv -f $SHELL_FOLDER/network files/etc/config/ - - diff --git a/devices/armvirt_pcat/network b/devices/armvirt_pcat/network deleted file mode 100644 index ec548943019b..000000000000 --- a/devices/armvirt_pcat/network +++ /dev/null @@ -1,64 +0,0 @@ - -config interface 'loopback' - option ifname 'lo' - option proto 'static' - option ipaddr '127.0.0.1' - option netmask '255.0.0.0' - -config globals 'globals' - option ula_prefix 'fd1e:7270:ea04::/48' - -config interface 'lan' - option proto 'static' - option netmask '255.255.248.0' - option ip6assign '60' - option ipaddr '10.0.0.1' - option device 'br-lan' - -config interface 'wan' - option ifname 'eth0' - option proto 'dhcp' - option metric '1' - -config interface 'wan6' - option ifname 'eth0' - option proto 'dhcpv6' - option metric '2' - -config interface 'VPN' - option ifname 'ipsec0' - option proto 'static' - option ipaddr '10.10.10.1' - option netmask '255.255.255.0' - -config interface 'vpn0' - option ifname 'tun0' - option proto 'none' - -config interface 'wwan_5g' - option proto 'dhcp' - option ifname 'usb0' - option metric '10' - option auto '0' - -config interface 'wwan_5g_v6' - option proto 'dhcpv6' - option ifname 'usb0' - option metric '11' - option auto '0' - -config interface 'wwan_lte' - option proto 'dhcp' - option ifname 'wwan0' - option metric '12' - -config interface 'wwan_lte_v6' - option proto 'dhcpv6' - option ifname 'wwan0' - option metric '13' - -config device - option name 'br-lan' - option type 'bridge' - list ports 'eth1' - diff --git a/devices/armvirt_pcat/patches/fix.patch b/devices/armvirt_pcat/patches/fix.patch deleted file mode 100644 index 821bc703253c..000000000000 --- a/devices/armvirt_pcat/patches/fix.patch +++ /dev/null @@ -1,21 +0,0 @@ ---- a/target/linux/armvirt_pcat/Makefile -+++ b/target/linux/armvirt_pcat/Makefile -@@ -4,15 +4,15 @@ - - include $(TOPDIR)/rules.mk - --BOARD:=armvirt -+BOARD:=armvirt_pcat - BOARDNAME:=QEMU ARM Virtual Machine - FEATURES:=fpu pci rtc usb --FEATURES+=cpiogz ext4 ramdisk squashfs targz -+FEATURES+=cpiogz ext4 ramdisk squashfs targz boot-part rootfs-part - - KERNEL_PATCHVER:=5.15 - - include $(INCLUDE_DIR)/target.mk - --DEFAULT_PACKAGES += mkf2fs e2fsprogs -+DEFAULT_PACKAGES += mkf2fs e2fsprogs blkid pcat-manager -luci-app-gpsysupgrade - - $(eval $(call BuildTarget)) \ No newline at end of file diff --git a/devices/common/diy.sh b/devices/common/diy.sh index d7fc8fc7b320..a69d97b0e79c 100644 --- a/devices/common/diy.sh +++ b/devices/common/diy.sh @@ -30,7 +30,7 @@ while [ "$status" == "in_progress" ];do status=$(curl -H "Authorization: token $REPO_TOKEN" -s "https://api.github.com/repos/kiddin9/openwrt-packages/actions/runs" | jq -r '.workflow_runs[0].status') done -mv -f feeds/kiddin9/{r81*,igb-intel} tmp/ +mv -f feeds/kiddin9/r81* tmp/ sed -i "s/192.168.1/10.0.0/" package/feeds/kiddin9/base-files/files/bin/config_generate sed -i "s/192.168.1/10.0.0/" package/base-files/files/bin/config_generate @@ -51,16 +51,6 @@ sed -i 's/max_requests 3/max_requests 20/g' package/network/services/uhttpd/file #rm -rf ./feeds/packages/lang/{golang,node} sed -i "s/tty\(0\|1\)::askfirst/tty\1::respawn/g" target/linux/*/base-files/etc/inittab -sed -i '$a \ -CONFIG_CPU_FREQ_GOV_POWERSAVE=y \ -CONFIG_CPU_FREQ_GOV_USERSPACE=y \ -CONFIG_CPU_FREQ_GOV_ONDEMAND=y \ -CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y \ -CONFIG_CRYPTO_CHACHA20_NEON=y \ -CONFIG_CRYPTO_CHACHA20POLY1305=y \ -CONFIG_FAT_DEFAULT_IOCHARSET="utf8" \ -' `find target/linux -path "target/linux/*/config-*"` - date=`date +%m.%d.%Y` sed -i -e "/\(# \)\?REVISION:=/c\REVISION:=$date" -e '/VERSION_CODE:=/c\VERSION_CODE:=$(REVISION)' include/version.mk diff --git a/devices/common/patches/fix.patch b/devices/common/patches/fix.patch index 9921852c840f..526af5da2829 100644 --- a/devices/common/patches/fix.patch +++ b/devices/common/patches/fix.patch @@ -53,7 +53,23 @@ KERNEL_PREFIX = $$(DEVICE_IMG_PREFIX) KERNEL_SUFFIX := -kernel.bin KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX) -@@ -567,7 +606,7 @@ define Device/Build/kernel +@@ -472,7 +511,6 @@ define Device/Check + endif + endef + +-ifndef IB + define Device/Build/initramfs + $(call Device/Export,$(KDIR)/tmp/$$(KERNEL_INITRAMFS_IMAGE),$(1)) + $$(_TARGET): $$(if $$(KERNEL_INITRAMFS),$(BIN_DIR)/$$(KERNEL_INITRAMFS_IMAGE) \ +@@ -519,7 +557,6 @@ define Device/Build/initramfs + SUPPORTED_DEVICES="$$(SUPPORTED_DEVICES)" \ + $(TOPDIR)/scripts/json_add_image_info.py $$@ + endef +-endif + + define Device/Build/compile + $$(_COMPILE_TARGET): $(KDIR)/$(1) +@@ -568,7 +605,7 @@ define Device/Build/kernel endef define Device/Build/image @@ -62,7 +78,7 @@ $$(_TARGET): $(if $(CONFIG_JSON_OVERVIEW_IMAGE_INFO), \ $(BUILD_DIR)/json_info_files/$(call DEVICE_IMG_NAME,$(1),$(2)).json, \ $(BIN_DIR)/$(call DEVICE_IMG_NAME,$(1),$(2))$$(GZ_SUFFIX)) -@@ -677,6 +716,8 @@ define Device/Build +@@ -678,6 +715,8 @@ define Device/Build $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1))) $(call Device/Build/kernel,$(1)) @@ -79,28 +95,15 @@ if output: - default_packages, output["arch_packages"] = run( -+ default_packages, output["arch_packages"], output["kernel_version"], output["initramfs"] = run( ++ default_packages, output["arch_packages"], output["kernel_version"] = run( [ "make", "--no-print-directory", -@@ -55,6 +55,8 @@ def get_initial_output(image_info): +@@ -55,6 +55,7 @@ def get_initial_output(image_info): "target/linux/", "val.DEFAULT_PACKAGES", "val.ARCH_PACKAGES", + "val.LINUX_VERSION", -+ "val.KERNEL_INITRAMFS", ], stdout=PIPE, - stderr=PIPE, - - ---- a/rules.mk -+++ b/rules.mk -@@ -59,6 +59,7 @@ _SINGLE=export MAKEFLAGS=$(space); - CFLAGS:= - ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH))))) - ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) -+KERNEL_INITRAMFS:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_INITRAMFS)) - BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) - SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) - TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) \ No newline at end of file + stderr=PIPE, \ No newline at end of file diff --git a/devices/common/patches/imagebuilder.patch b/devices/common/patches/imagebuilder.patch index ade6db412cb8..360e28509aae 100644 --- a/devices/common/patches/imagebuilder.patch +++ b/devices/common/patches/imagebuilder.patch @@ -1,6 +1,6 @@ --- a/target/imagebuilder/Makefile +++ b/target/imagebuilder/Makefile -@@ -38,13 +38,15 @@ $(BIN_DIR)/$(IB_NAME).tar.xz: clean +@@ -38,13 +38,16 @@ $(BIN_DIR)/$(IB_NAME).tar.xz: clean ./files/repositories.conf \ $(TMP_DIR)/.targetinfo \ $(TMP_DIR)/.packageinfo \ @@ -16,6 +16,7 @@ + $(SED) 's/^src\/gz \(.*\) https.*top\/\(packages.*\)/src \1 file:\/\/www\/wwwroot\/op.supes.top\/\2/' $(PKG_BUILD_DIR)/repositories.conf + $(SED) 's/^src\/gz \(.*\) https.*top\/\(targets.*\)/src \1 file:\/\/www\/wwwroot\/op.supes.top\/releases\/\2/' $(PKG_BUILD_DIR)/repositories.conf + $(SED) 's/\/kiddin9//' $(PKG_BUILD_DIR)/repositories.conf ++ $(SED) '/openwrt_core/d' $(PKG_BUILD_DIR)/repositories.conf $(INSTALL_DIR) $(PKG_BUILD_DIR)/packages # create an empty package index so `opkg` doesn't report an error diff --git a/devices/ipq60xx_generic/.config b/devices/ipq60xx_generic/.config index 9cbb0420304e..17d2b474bf68 100644 --- a/devices/ipq60xx_generic/.config +++ b/devices/ipq60xx_generic/.config @@ -3,11 +3,61 @@ CONFIG_TARGET_ipq60xx=y CONFIG_TARGET_ipq60xx_generic=y CONFIG_TARGET_MULTI_PROFILE=y CONFIG_TARGET_ALL_PROFILES=y +CONFIG_TARGET_DEVICE_ipq60xx_generic_DEVICE_glinet_gl-ax1800=n +CONFIG_TARGET_DEVICE_ipq60xx_generic_DEVICE_glinet_gl-axt1800=n CONFIG_PACKAGE_dockerd=n +CONFIG_GCC_USE_VERSION_7=y +CONFIG_PACKAGE_kmod-dm-raid=n +CONFIG_PACKAGE_kmod-dm=n +CONFIG_PACKAGE_kmod-fs-xfs=n +CONFIG_PACKAGE_kmod-fs-btrfs=n +CONFIG_PACKAGE_kmod-qca-nss-drv-bridge-mgr=n +CONFIG_PACKAGE_kmod-qca-nss-drv-vlan-mgr=n +CONFIG_PACKAGE_kmod-drm-ttm=n +CONFIG_PACKAGE_kmod-drm-kms-helper=n +CONFIG_PACKAGE_kmod-gigaset=n +CONFIG_PACKAGE_kmod-isdn4linux=n +CONFIG_PACKAGE_kmod-video-pwc=n +CONFIG_PACKAGE_kmod-mmc-spi=n +CONFIG_PACKAGE_kmod-scsi-cdrom=n +CONFIG_PACKAGE_kmod-scsi-generic=n +CONFIG_PACKAGE_kmod-scsi-tape=n +CONFIG_PACKAGE_kmod-sound-core=n +CONFIG_PACKAGE_kmod-iio-hmc5843=n +CONFIG_PACKAGE_kmod-ledtrig-netdev=n +CONFIG_PACKAGE_kmod-tg3=n +CONFIG_PACKAGE_kmod-be2net=n +CONFIG_PACKAGE_kmod-bmp085-spi=n +CONFIG_PACKAGE_kmod-mac80211-hwsim=n +CONFIG_PACKAGE_kmod-ath3k=n +CONFIG_PACKAGE_kmod-ath5k=n +CONFIG_PACKAGE_kmod-ath6kl-sdio=n +CONFIG_PACKAGE_kmod-ath6kl-usb=n +CONFIG_PACKAGE_kmod-ath9k=n +CONFIG_PACKAGE_kmod-ath10k=n +CONFIG_PACKAGE_kmod-ath10k-ct=n +CONFIG_PACKAGE_kmod-ath10k-ct-smallbuffers=n +CONFIG_PACKAGE_kmod-crypto-qcrypto=n +CONFIG_PACKAGE_kmod-gl-mifi-mcu=n +CONFIG_PACKAGE_kmod-mdio-netlink=n +CONFIG_PACKAGE_kmod-nf-nathelper-extra=n +CONFIG_PACKAGE_kmod-nf-ipvs-sip=n +CONFIG_PACKAGE_kmod-nf-nathelper-extra=n +CONFIG_PACKAGE_kmod-usb-serial-xr_usb_serial_common=n +CONFIG_PACKAGE_kmod-ovpn-dco=n +CONFIG_PACKAGE_spidev-test=n +CONFIG_PACKAGE_kmod-lib80211=n +CONFIG_PACKAGE_kmod-carl9170=n +CONFIG_PACKAGE_kmod-batman-adv=n +CONFIG_PACKAGE_kmod-rtl8812au-ct=n +CONFIG_PACKAGE_kmod-rtl8821cu=n +CONFIG_PACKAGE_kmod-rtl88x2bu=n +CONFIG_SECCOMP=n + CONFIG_PACKAGE_luci-ssl=y # uhttpd服务 diff --git a/devices/ipq60xx_generic/diy.sh b/devices/ipq60xx_generic/diy.sh index f78393d00a90..57537c2fad67 100644 --- a/devices/ipq60xx_generic/diy.sh +++ b/devices/ipq60xx_generic/diy.sh @@ -1,17 +1,41 @@ #!/bin/bash shopt -s extglob -rm -rf package/system/opkg && mv -f feeds/kiddin9/opkg package/system/ -rm -rf package/feeds/kiddin9/{firewall,rtl*,nft-fullcone,fullconenat} package/kernel/mt76 toolchain/musl - -rm -rf target/imagebuilder -svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/target/imagebuilder target/imagebuilder - -rm -rf toolchain/musl -svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/toolchain/musl toolchain/musl +rm -rf package/boot/uboot-envtools package/kernel package/firmware/ath11k* package/qca target/linux/generic target/linux/ipq60xx package/network/config/netifd feeds/kiddin9/fullconenat toolchain tools/squashfskit4 +svn export --force https://github.com/coolsnowwolf/openwrt-gl-ax1800/trunk/package/boot/uboot-envtools package/boot/uboot-envtools +svn export --force https://github.com/coolsnowwolf/openwrt-gl-ax1800/trunk/package/firmware/ath11k-firmware package/firmware/ath11k-firmware +svn export --force https://github.com/coolsnowwolf/openwrt-gl-ax1800/trunk/package/qca package/qca +svn co https://github.com/coolsnowwolf/openwrt-gl-ax1800/trunk/target/linux/generic target/linux/generic +svn co https://github.com/coolsnowwolf/openwrt-gl-ax1800/trunk/target/linux/ipq60xx target/linux/ipq60xx +wget -P dl/ https://github.com/coolsnowwolf/openwrt-gl-ax1800/raw/master/dl/linux-4.4.60.tar.xz +svn co https://github.com/coolsnowwolf/openwrt-gl-ax1800/trunk/package/kernel package/kernel svn co https://github.com/coolsnowwolf/openwrt-gl-ax1800/trunk/package/network/services/fullconenat feeds/kiddin9/fullconenat +svn co https://github.com/coolsnowwolf/openwrt-gl-ax1800/trunk/package/network/config/netifd package/network/config/netifd +svn co https://github.com/coolsnowwolf/openwrt-gl-ax1800/trunk/toolchain toolchain +svn co https://github.com/coolsnowwolf/openwrt-gl-ax1800/trunk/tools/squashfskit4 tools/squashfskit4 +rm -rf target/linux/generic/files +rm -rf package/network/config/netifd/patches -rm -rf devices/common/patches/{targets.patch,kernel-defaults.patch,fix.patch,iptables.patch,disable_flock.patch} +curl -sfL https://raw.githubusercontent.com/coolsnowwolf/openwrt-gl-ax1800/master/include/netfilter.mk -o include/netfilter.mk +curl -sfL https://raw.githubusercontent.com/coolsnowwolf/openwrt-gl-ax1800/master/include/quilt.mk -o include/quilt.mk + +rm -rf toolchain/.svn +rm -rf feeds/kiddin9/{rtl*,fullconenat-nft,shortcut-fe,netifd} package/kernel/mt76 toolchain/musl package/feeds/packages/{xtables-addons,openvswitch} +svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/toolchain/musl toolchain/musl +svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/toolchain/glibc toolchain/glibc +sed -i "s/5.4.0/4.4.0/" toolchain/glibc/common.mk +echo ' +CONFIG_PNP_DEBUG_MESSAGES=y +CONFIG_PINCTRL_BAYTRAIL=n +CONFIG_PINCTRL_CHERRYVIEW=n +CONFIG_PINCTRL_BROXTON=n +CONFIG_PINCTRL_SUNRISEPOINT=n +CONFIG_PINCTRL_QDF2XXX=n +CONFIG_GPIO_AMDPT=n +CONFIG_PCC=n +CONFIG_PMIC_OPREGION=n +CCONFIG_RYPTO_CRC32_ARM64=n +' >> ./target/linux/ipq60xx/config-4.4 diff --git a/devices/ipq60xx_generic/diy/include/kernel-4.4 b/devices/ipq60xx_generic/diy/include/kernel-4.4 new file mode 100644 index 000000000000..3c26f837e980 --- /dev/null +++ b/devices/ipq60xx_generic/diy/include/kernel-4.4 @@ -0,0 +1,2 @@ +LINUX_VERSION-4.4 = .60 +LINUX_KERNEL_HASH-4.4.60 = 10f619f7f9ab9f2776d0e34d37138b1ca14e9a026b91790dbdb1eb6c8d15edc6 diff --git a/devices/ipq60xx_generic/diy/package/firmware/ath11k-firmware/files/board-2.bin.IPQ6018 b/devices/ipq60xx_generic/diy/package/firmware/ath11k-firmware/files/board-2.bin.IPQ6018 new file mode 100644 index 000000000000..cf26728896d4 Binary files /dev/null and b/devices/ipq60xx_generic/diy/package/firmware/ath11k-firmware/files/board-2.bin.IPQ6018 differ diff --git a/devices/ipq60xx_generic/diy/package/system/fstools/patches/fix.patch b/devices/ipq60xx_generic/diy/package/system/fstools/patches/fix.patch new file mode 100644 index 000000000000..4ba316af70d7 --- /dev/null +++ b/devices/ipq60xx_generic/diy/package/system/fstools/patches/fix.patch @@ -0,0 +1,11 @@ +--- a/libfstools/overlay.c ++++ b/libfstools/overlay.c +@@ -33,4 +33,8 @@ + #define SWITCH_JFFS2 "/tmp/.switch_jffs2" + ++#ifndef GLOB_ONLYDIR ++#define GLOB_ONLYDIR 0 ++#endif ++ + static bool keep_sysupgrade; + diff --git a/devices/ipq60xx_generic/feeds.conf b/devices/ipq60xx_generic/feeds.conf deleted file mode 100644 index a8d00ca45e0c..000000000000 --- a/devices/ipq60xx_generic/feeds.conf +++ /dev/null @@ -1,4 +0,0 @@ -src-git packages https://github.com/kiddin9/packages.git;openwrt-22.03 -src-git luci https://git.openwrt.org/project/luci.git;openwrt-22.03 -src-git routing https://git.openwrt.org/feed/routing.git;openwrt-22.03 -src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master diff --git a/devices/ipq60xx_generic/patches/fix.patch b/devices/ipq60xx_generic/patches/fix.patch index f9ef17bf7d68..2d02af2fd954 100644 --- a/devices/ipq60xx_generic/patches/fix.patch +++ b/devices/ipq60xx_generic/patches/fix.patch @@ -1,3 +1,90 @@ +--- a/rules.mk ++++ b/rules.mk +@@ -136,8 +136,12 @@ else + TOOLCHAIN_DIR_NAME:=toolchain-$(GNU_TARGET_NAME) + endif + +-ifeq ($(or $(CONFIG_EXTERNAL_TOOLCHAIN),$(CONFIG_TARGET_uml)),) +- iremap = -f$(if $(CONFIG_REPRODUCIBLE_DEBUG_INFO),file,macro)-prefix-map=$(1)=$(2) ++ifeq ($(or $(CONFIG_EXTERNAL_TOOLCHAIN),$(CONFIG_GCC_VERSION_4_8),$(CONFIG_TARGET_uml)),) ++ ifeq ($(CONFIG_GCC_USE_EMBEDDED_PATH_REMAP),y) ++ iremap = -fmacro-prefix-map=$(1)=$(2) ++ else ++ iremap = -iremap$(1):$(2) ++ endif + endif + + PACKAGE_DIR:=$(BIN_DIR)/packages + +--- a/include/image.mk ++++ b/include/image.mk +@@ -152,21 +152,6 @@ ifdef CONFIG_TARGET_IMAGES_GZIP + endef + endif + +- +-# Disable noisy checks by default as in upstream +-DTC_FLAGS += \ +- -Wno-unit_address_vs_reg \ +- -Wno-simple_bus_reg \ +- -Wno-unit_address_format \ +- -Wno-pci_bridge \ +- -Wno-pci_device_bus_num \ +- -Wno-pci_device_reg \ +- -Wno-avoid_unnecessary_addr_size \ +- -Wno-alias_paths \ +- -Wno-graph_child_address \ +- -Wno-graph_port \ +- -Wno-unique_unit_address +- + define Image/pad-to + dd if=$(1) of=$(1).new bs=$(2) conv=sync + mv $(1).new $(1) + +--- a/package/network/utils/iptables/Makefile ++++ b/package/network/utils/iptables/Makefile +@@ -784,7 +784,6 @@ $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m))) + $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m))) + $(eval $(call BuildPlugin,iptables-mod-rpfilter,$(IPT_RPFILTER-m))) + $(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m))) +-$(eval $(call BuildPlugin,iptables-mod-socket,$(IPT_SOCKET-m))) + $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m))) + $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m))) + $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m))) + +--- a/include/target.mk ++++ b/include/target.mk +@@ -147,10 +147,17 @@ ifneq ($(TARGET_BUILD)$(if $(DUMP),,1),) + endif + + GENERIC_PLATFORM_DIR := $(TOPDIR)/target/linux/generic ++ifeq ($(CONFIG_TARGET_ipq60xx),y) ++GENERIC_BACKPORT_DIR := ++GENERIC_PATCH_DIR := ++GENERIC_HACK_DIR := ++GENERIC_FILES_DIR := ++else + GENERIC_BACKPORT_DIR := $(GENERIC_PLATFORM_DIR)/backport$(if $(wildcard $(GENERIC_PLATFORM_DIR)/backport-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) + GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/pending$(if $(wildcard $(GENERIC_PLATFORM_DIR)/pending-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) + GENERIC_HACK_DIR := $(GENERIC_PLATFORM_DIR)/hack$(if $(wildcard $(GENERIC_PLATFORM_DIR)/hack-$(KERNEL_PATCHVER)),-$(KERNEL_PATCHVER)) + GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(KERNEL_PATCHVER)),"$(dir)") ++endif + + __config_name_list = $(1)/config-$(KERNEL_PATCHVER) $(1)/config-default + __config_list = $(firstword $(wildcard $(call __config_name_list,$(1)))) + +--- a/package/kernel/mac80211/ath.mk ++++ b/package/kernel/mac80211/ath.mk +@@ -282,7 +282,7 @@ define KernelPackage/ath11k + TITLE:=Atheros 802.11ax wireless cards support + URL:=https://wireless.wiki.kernel.org/en/users/drivers/ath11k + DEPENDS+= @TARGET_ipq60xx +kmod-ath +@DRIVER_11N_SUPPORT +@DRIVER_11AC_SUPPORT \ +- +@DRIVER_11AX_SUPPORT +@DRIVER_11W_SUPPORT +kmod-qca-nss-drv ++ +@DRIVER_11AX_SUPPORT +@DRIVER_11W_SUPPORT +kmod-qca-nss-drv +kmod-hwmon-core + FILES:= \ + $(PKG_BUILD_DIR)/drivers/net/wireless/ath/ath11k/ath11k.ko + endef + --- a/target/linux/ipq60xx/Makefile +++ b/target/linux/ipq60xx/Makefile @@ -16,7 +16,7 @@ include $(INCLUDE_DIR)/target.mk @@ -10,6 +97,18 @@ kmod-qca-nss-drv-pppoe kmod-qca-nss-ecm uboot-envtools +--- a/package/network/config/netifd/Makefile ++++ b/package/network/config/netifd/Makefile +@@ -5,7 +5,7 @@ PKG_RELEASE:=1 + + PKG_SOURCE_PROTO:=git + PKG_SOURCE_URL=$(PROJECT_GIT)/project/netifd.git +-PKG_SOURCE_DATE:=2021-06-04 ++PKG_SOURCE_DATE:=2023-06-04 + PKG_SOURCE_VERSION:=50381d0a2998f6c0fc4823f0c2aa4206063d549e + PKG_MIRROR_HASH:=2718df3d3538c93ac77accf55716fb341741df3d231aac59e04dd1f80f558889 + PKG_MAINTAINER:=Felix Fietkau + --- a/target/linux/ipq60xx/image/Makefile +++ b/target/linux/ipq60xx/image/Makefile @@ -104,7 +104,7 @@ define Device/qihoo_v6 @@ -20,111 +119,4 @@ + DEVICE_TITLE := Qihoo 360 V6 DEVICE_PACKAGES := ath11k-wifi-qihoo-v6 kmod-usb3 kmod-usb-phy-msm endef - TARGET_DEVICES += qihoo_v6 - ---- a/include/image.mk -+++ b/include/image.mk -@@ -300,6 +300,44 @@ ifdef CONFIG_TARGET_ROOTFS_TARGZ - endef - endif - -+define Device/Build/targz -+ $$(_TARGET): $(if $(CONFIG_JSON_OVERVIEW_IMAGE_INFO), \ -+ $(BUILD_DIR)/json_info_files/$$(ROOTFSTZ).json, \ -+ $(BIN_DIR)/$$(ROOTFSTZ)) -+ -+ $(call Device/Export,$(BUILD_DIR)/json_info_files/$$(ROOTFSTZ).json,$(1)) -+ -+ $(BUILD_DIR)/json_info_files/$$(ROOTFSTZ).json: $(BIN_DIR)/$$(ROOTFSTZ) -+ @mkdir -p $$(shell dirname $$@) -+ DEVICE_ID="$(1)" \ -+ SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \ -+ FILE_NAME="$$(notdir $$^)" \ -+ FILE_DIR="$(BIN_DIR)" \ -+ FILE_TYPE="rootfs" \ -+ FILE_FILESYSTEM="rootfs" \ -+ DEVICE_IMG_PREFIX="$$(DEVICE_IMG_PREFIX)" \ -+ DEVICE_VENDOR="$$(DEVICE_VENDOR)" \ -+ DEVICE_MODEL="$$(DEVICE_MODEL)" \ -+ DEVICE_VARIANT="$$(DEVICE_VARIANT)" \ -+ DEVICE_ALT0_VENDOR="$$(DEVICE_ALT0_VENDOR)" \ -+ DEVICE_ALT0_MODEL="$$(DEVICE_ALT0_MODEL)" \ -+ DEVICE_ALT0_VARIANT="$$(DEVICE_ALT0_VARIANT)" \ -+ DEVICE_ALT1_VENDOR="$$(DEVICE_ALT1_VENDOR)" \ -+ DEVICE_ALT1_MODEL="$$(DEVICE_ALT1_MODEL)" \ -+ DEVICE_ALT1_VARIANT="$$(DEVICE_ALT1_VARIANT)" \ -+ DEVICE_ALT2_VENDOR="$$(DEVICE_ALT2_VENDOR)" \ -+ DEVICE_ALT2_MODEL="$$(DEVICE_ALT2_MODEL)" \ -+ DEVICE_ALT2_VARIANT="$$(DEVICE_ALT2_VARIANT)" \ -+ DEVICE_TITLE="$$(DEVICE_TITLE)" \ -+ DEVICE_PACKAGES="$$(DEVICE_PACKAGES)" \ -+ TARGET="$(BOARD)" \ -+ SUBTARGET="$(if $(SUBTARGET),$(SUBTARGET),generic)" \ -+ VERSION_NUMBER="$(VERSION_NUMBER)" \ -+ VERSION_CODE="$(VERSION_CODE)" \ -+ SUPPORTED_DEVICES="$$(SUPPORTED_DEVICES)" \ -+ $(TOPDIR)/scripts/json_add_image_info.py $$@ -+endef -+ - ifdef CONFIG_TARGET_ROOTFS_CPIOGZ - define Image/Build/cpiogz - ( cd $(TARGET_DIR); find . | $(STAGING_DIR_HOST)/bin/cpio -o -H newc -R 0:0 | gzip -9n >$(BIN_DIR)/$(IMG_ROOTFS).cpio.gz ) -@@ -367,6 +405,7 @@ define Device/Init - DEVICE_IMG_PREFIX := $(IMG_PREFIX)-$(1) - DEVICE_IMG_NAME = $$(DEVICE_IMG_PREFIX)-$$(1)-$$(2) - IMAGE_SIZE := -+ ROOTFSTZ = $$(DEVICE_IMG_PREFIX)-rootfs.tar.gz - KERNEL_PREFIX = $$(DEVICE_IMG_PREFIX) - KERNEL_SUFFIX := -kernel.bin - KERNEL_INITRAMFS_SUFFIX = $$(KERNEL_SUFFIX) -@@ -567,7 +606,7 @@ define Device/Build/kernel - endef - - define Device/Build/image -- GZ_SUFFIX := $(if $(filter %dtb %gz,$(2)),,$(if $(and $(findstring ext4,$(1)),$(CONFIG_TARGET_IMAGES_GZIP)),.gz)) -+ GZ_SUFFIX := $(if $(filter %dtb %gz,$(2)),,$(if $(and $(findstring ext4,$(1)),$(findstring img,$(2)),$(CONFIG_TARGET_IMAGES_GZIP)),.gz)) - $$(_TARGET): $(if $(CONFIG_JSON_OVERVIEW_IMAGE_INFO), \ - $(BUILD_DIR)/json_info_files/$(call DEVICE_IMG_NAME,$(1),$(2)).json, \ - $(BIN_DIR)/$(call DEVICE_IMG_NAME,$(1),$(2))$$(GZ_SUFFIX)) -@@ -677,6 +716,8 @@ define Device/Build - $(if $(CONFIG_TARGET_ROOTFS_INITRAMFS),$(call Device/Build/initramfs,$(1))) - $(call Device/Build/kernel,$(1)) - -+ $(if $(CONFIG_TARGET_ROOTFS_TARGZ),$(call Device/Build/targz,$(PROFILE_SANITIZED))) -+ - $$(eval $$(foreach compile,$$(COMPILE), \ - $$(call Device/Build/compile,$$(compile),$(1)))) - - ---- a/scripts/json_overview_image_info.py -+++ b/scripts/json_overview_image_info.py -@@ -47,7 +47,7 @@ def get_initial_output(image_info): - - - if output: -- default_packages, output["arch_packages"] = run( -+ default_packages, output["arch_packages"], output["kernel_version"], output["initramfs"] = run( - [ - "make", - "--no-print-directory", -@@ -55,6 +55,8 @@ def get_initial_output(image_info): - "target/linux/", - "val.DEFAULT_PACKAGES", - "val.ARCH_PACKAGES", -+ "val.LINUX_VERSION", -+ "val.KERNEL_INITRAMFS", - ], - stdout=PIPE, - stderr=PIPE, - - ---- a/rules.mk -+++ b/rules.mk -@@ -59,6 +59,7 @@ _SINGLE=export MAKEFLAGS=$(space); - CFLAGS:= - ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH))))) - ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) -+KERNEL_INITRAMFS:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_INITRAMFS)) - BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) - SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) - TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) \ No newline at end of file + TARGET_DEVICES += qihoo_v6 \ No newline at end of file diff --git a/devices/ipq60xx_generic/patches/kernel-defaults.patch b/devices/ipq60xx_generic/patches/kernel-defaults.patch deleted file mode 100644 index 01aeb0df9e2f..000000000000 --- a/devices/ipq60xx_generic/patches/kernel-defaults.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- a/include/kernel-defaults.mk -+++ b/include/kernel-defaults.mk -@@ -114,6 +114,7 @@ endef - - define Kernel/CompileModules/Default - rm -f $(LINUX_DIR)/vmlinux $(LINUX_DIR)/System.map -+ +$(KERNEL_MAKE) olddefconfig - +$(KERNEL_MAKE) modules - endef \ No newline at end of file diff --git a/devices/ipq60xx_generic/patches/targets.patch b/devices/ipq60xx_generic/patches/targets.patch deleted file mode 100644 index 6034c7fd5155..000000000000 --- a/devices/ipq60xx_generic/patches/targets.patch +++ /dev/null @@ -1,34 +0,0 @@ ---- a/include/target.mk -+++ b/include/target.mk -@@ -17,7 +17,7 @@ DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fs - # For nas targets - DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm - # For router targets --DEFAULT_PACKAGES.router:=dnsmasq-full iptables ip6tables ppp ppp-mod-pppoe firewall odhcpd-ipv6only odhcp6c luci luci-lib-ipkg -+DEFAULT_PACKAGES.router:=dnsmasq-full iptables ip6tables ppp ppp-mod-pppoe firewall odhcpd-ipv6only odhcp6c luci luci-lib-ipkg kmod-ipt-offload kmod-ipt-nat kmod-ipt-nat6 - DEFAULT_PACKAGES.bootloader:= - - ifneq ($(DUMP),) -@@ -55,6 +55,22 @@ ifneq ($(filter 4.9,$(KERNEL_PATCHVER)),) - DEFAULT_PACKAGES.router:=$(filter-out kmod-ipt-offload,$(DEFAULT_PACKAGES.router)) - endif - -+ifneq ($(CONFIG_SMALL_FLASH),) -+ DEFAULT_PACKAGES+=-coremark -htop -bash -openssh-sftp-server -+endif -+ -+ifeq ($(ARCH),arm) -+ DEFAULT_PACKAGES+=autocore-arm luci-app-cpufreq -+endif -+ -+ifeq ($(ARCH),aarch64) -+ DEFAULT_PACKAGES+=autocore-arm luci-app-cpufreq -+endif -+ -+ifneq ($(CONFIG_USB_SUPPORT),) -+ DEFAULT_PACKAGES+=automount -+endif -+ - # Add device specific packages (here below to allow device type set from subtarget) - DEFAULT_PACKAGES += $(DEFAULT_PACKAGES.$(DEVICE_TYPE)) - \ No newline at end of file diff --git a/devices/ipq60xx_generic/settings.ini b/devices/ipq60xx_generic/settings.ini deleted file mode 100644 index 72031043133b..000000000000 --- a/devices/ipq60xx_generic/settings.ini +++ /dev/null @@ -1,2 +0,0 @@ -REPO_URL="https://github.com/coolsnowwolf/openwrt-gl-ax1800" -REPO_BRANCH="master" diff --git a/devices/ipq807x/diy.sh b/devices/ipq807x/diy.sh index ad7f64c851b6..fd43e84a58a0 100644 --- a/devices/ipq807x/diy.sh +++ b/devices/ipq807x/diy.sh @@ -9,16 +9,6 @@ svn co https://github.com/coolsnowwolf/lede/trunk/target/linux/generic/hack-5.15 rm -rf feeds/kiddin9/{rtl8821cu,rtl88x2bu} package/kernel/mt76 -sed -i "s/tty\(0\|1\)::askfirst/tty\1::respawn/g" target/linux/*/base-files/etc/inittab - - -sed -i '$a \ -CONFIG_CPU_FREQ_GOV_POWERSAVE=y \ -CONFIG_CPU_FREQ_GOV_USERSPACE=y \ -CONFIG_CPU_FREQ_GOV_ONDEMAND=y \ -CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y \ -' target/linux/ipq807x/config-5.15 - echo " CONFIG_PACKAGE_kmod-ipt-coova=n CONFIG_PACKAGE_kmod-pf-ring=n diff --git a/devices/ipq807x/patches/default_packages.patch b/devices/ipq807x/patches/default_packages.patch index f8947aa7aff9..31187c5b980b 100644 --- a/devices/ipq807x/patches/default_packages.patch +++ b/devices/ipq807x/patches/default_packages.patch @@ -1,18 +1,6 @@ ---- a/target/linux/ipq807x/Makefile -+++ b/target/linux/ipq807x/Makefile -@@ -12,7 +12,7 @@ KERNEL_PATCHVER:=5.15 - - include $(INCLUDE_DIR)/target.mk - DEFAULT_PACKAGES += \ -- kmod-usb3 kmod-usb-dwc3 kmod-usb-dwc3-qcom \ -+ kmod-qca-nss-drv nss-firmware-ipq8074 qca-ssdk-shell \ - kmod-leds-gpio kmod-gpio-button-hotplug \ - libwolfsslcpu-crypto kmod-qca-nss-dp \ - ath11k-firmware-ipq8074 kmod-ath11k-ahb \ - --- a/target/linux/ipq807x/image/generic.mk +++ b/target/linux/ipq807x/image/generic.mk -@@ -74,7 +74,7 @@ define Device/qnap_301w +@@ -68,7 +68,7 @@ define Device/qnap_301w IMAGES += factory.bin sysupgrade.bin IMAGE/factory.bin := append-rootfs | pad-rootfs | pad-to 64k IMAGE/sysupgrade.bin/squashfs := append-rootfs | pad-to 64k | sysupgrade-tar rootfs=$$$$@ | append-metadata @@ -21,11 +9,12 @@ endef TARGET_DEVICES += qnap_301w -@@ -109,6 +109,6 @@ define Device/xiaomi_ax9000 - DEVICE_DTS_CONFIG := config@hk14 +@@ -109,7 +109,7 @@ define Device/xiaomi_ax9000 SOC := ipq8072 + KERNEL_SIZE := 57344k DEVICE_PACKAGES := ipq-wifi-xiaomi_ax9000 kmod-ath11k-pci ath11k-firmware-qcn9074 \ - kmod-ath10k-ct ath10k-firmware-qca9887-ct + kmod-ath10k-ct ath10k-firmware-qca9887-ct kmod-usb3 kmod-usb-dwc3 kmod-usb-dwc3-qcom - endef - TARGET_DEVICES += xiaomi_ax9000 \ No newline at end of file + ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),) + ARTIFACTS := initramfs-factory.ubi + ARTIFACT/initramfs-factory.ubi := append-image-stage initramfs-uImage.itb | ubinize-kernel \ No newline at end of file diff --git a/devices/ipq807x/patches/usb3.patch b/devices/ipq807x/patches/usb3.patch deleted file mode 100644 index d40660132d11..000000000000 --- a/devices/ipq807x/patches/usb3.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/package/kernel/linux/modules/usb.mk -+++ b/package/kernel/linux/modules/usb.mk -@@ -494,7 +494,7 @@ $(eval $(call KernelPackage,usb-dwc3)) - - define KernelPackage/usb-dwc3-qcom - TITLE:=DWC3 Qualcomm USB driver -- DEPENDS:=@(TARGET_ipq40xx||TARGET_ipq806x) +kmod-usb-dwc3 -+ DEPENDS:=@(TARGET_ipq40xx||TARGET_ipq806x||TARGET_ipq807x) +kmod-usb-dwc3 - KCONFIG:= CONFIG_USB_DWC3_QCOM - FILES:= $(LINUX_DIR)/drivers/usb/dwc3/dwc3-qcom.ko - AUTOLOAD:=$(call AutoLoad,53,dwc3-qcom,1) \ No newline at end of file diff --git a/devices/ipq807x/settings.ini b/devices/ipq807x/settings.ini index 6bf165f393b5..384642f5f17a 100644 --- a/devices/ipq807x/settings.ini +++ b/devices/ipq807x/settings.ini @@ -1,2 +1,2 @@ REPO_URL="https://github.com/robimarko/openwrt" -REPO_BRANCH="ipq807x-2023-01-03-1333" +REPO_BRANCH="ipq807x-5.15-pr-nss-drv" diff --git a/devices/ipq807x_ipq60xx/diy.sh b/devices/ipq807x_ipq60xx/diy.sh index 2f8a55a29bc2..2b81a527550f 100644 --- a/devices/ipq807x_ipq60xx/diy.sh +++ b/devices/ipq807x_ipq60xx/diy.sh @@ -6,21 +6,23 @@ SHELL_FOLDER=$(dirname $(readlink -f "$0")) rm -rf target/linux/ipq807x mv -f ../feeds/ipq807x/ipq807x target/linux/ +rm -rf package/feeds +./scripts/feeds install -a -p gl_feeds_common -f +./scripts/feeds install -a -p ipq807x -f ./scripts/feeds install -a -p wifi_ax -f +./scripts/feeds install -a -p kiddin9 -f ./scripts/feeds install -a -rm -rf package/feeds/wifi_ax/hostapd - sed -i "/gl_feeds_common/d" feeds.conf sed -i "/ipq807x/d" feeds.conf sed -i "/wifi_ax/d" feeds.conf -rm -rf package/feeds/kiddin9/{firewall,rtl*,base-files,netifd,nft-fullcone,mbedtls,oaf,shortcut-fe,simulated-driver,fast-classifier,fullconenat} +rm -rf package/feeds/kiddin9/{firewall,rtl*,base-files,netifd,fullconenat-nft,fullconenat-nft,mbedtls,oaf,shortcut-fe,simulated-driver,fast-classifier,fullconenat} rm -rf package/kernel/{ath10k-ct,mt76,rtl8812au-ct} -rm -rf feeds/packages/net/xtables-addons package/feeds/packages/openvswitch package/feeds/routing/batman-adv +rm -rf feeds/packages/net/xtables-addons package/feeds/packages/{openvswitch,ksmbd} package/feeds/routing/batman-adv -rm -rf devices/common/patches/{glinet,imagebuilder.patch,iptables.patch,targets.patch,kernel-defaults.patch,disable_flock.patch} +rm -rf devices/common/patches/{glinet,imagebuilder.patch,fix.patch,iptables.patch,targets.patch,kernel-defaults.patch,disable_flock.patch} rm -rf toolchain/musl diff --git a/devices/ipq807x_ipq60xx/patches/0999-depends.patch b/devices/ipq807x_ipq60xx/patches/0999-depends.patch index 4aa0abc56525..47f728d0d691 100644 --- a/devices/ipq807x_ipq60xx/patches/0999-depends.patch +++ b/devices/ipq807x_ipq60xx/patches/0999-depends.patch @@ -22,7 +22,7 @@ kmod-qca-nss-drv \ kmod-usb-phy-ipq807x kmod-usb-dwc3-of-simple \ - kmod-ath11k-ahb kmod-qrtr_mproc wpad \ -+ kmod-ath11k-ahb kmod-qrtr_mproc wpad-basic-wolfssl \ ++ kmod-ath11k-ahb kmod-qrtr_mproc wpad-openssl \ kmod-gpio-button-hotplug \ qca-thermald-10.4 qca-ssdk-shell kmod-qca-nss-drv-bridge-mgr \ uboot-envtools \ No newline at end of file diff --git a/devices/ipq807x_ipq60xx/patches/imagebuilder.patch b/devices/ipq807x_ipq60xx/patches/imagebuilder.patch index 2aaed7a0f32d..342c1cbeefa0 100644 --- a/devices/ipq807x_ipq60xx/patches/imagebuilder.patch +++ b/devices/ipq807x_ipq60xx/patches/imagebuilder.patch @@ -96,27 +96,15 @@ if output: - default_packages, output["arch_packages"] = run( -+ default_packages, output["arch_packages"], output["kernel_version"], output["initramfs"] = run( ++ default_packages, output["arch_packages"], output["kernel_version"] = run( [ "make", "--no-print-directory", -@@ -55,6 +55,8 @@ def get_initial_output(image_info): +@@ -55,6 +55,7 @@ def get_initial_output(image_info): "target/linux/", "val.DEFAULT_PACKAGES", "val.ARCH_PACKAGES", + "val.LINUX_VERSION", -+ "val.KERNEL_INITRAMFS", ], stdout=PIPE, stderr=PIPE, - ---- a/rules.mk -+++ b/rules.mk -@@ -59,6 +59,7 @@ _SINGLE=export MAKEFLAGS=$(space); - CFLAGS:= - ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH))))) - ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) -+KERNEL_INITRAMFS:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_INITRAMFS)) - BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) - SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) - TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) diff --git a/devices/mediatek_gl_mt7981/.config b/devices/mediatek_gl_mt7981/.config index 969a9eb65d2d..585ed9480f96 100644 --- a/devices/mediatek_gl_mt7981/.config +++ b/devices/mediatek_gl_mt7981/.config @@ -2,7 +2,10 @@ CONFIG_TARGET_mediatek_gl=y CONFIG_TARGET_mediatek_gl_mt7981=y CONFIG_TARGET_MULTI_PROFILE=y -CONFIG_TARGET_DEVICE_mediatek_gl_mt7981_DEVICE_glinet_gl-mt2500=y +CONFIG_TARGET_ALL_PROFILES=y + +#CONFIG_TARGET_DEVICE_mediatek_gl_mt7981_DEVICE_glinet_gl-mt2500=y +#CONFIG_TARGET_DEVICE_mediatek_gl_mt7981_DEVICE_glinet_gl-mt3000=y CONFIG_PACKAGE_kmod-nft-fullcone=n CONFIG_PACKAGE_kmod-ax25=n diff --git a/devices/mediatek_gl_mt7981/diy.sh b/devices/mediatek_gl_mt7981/diy.sh index 77e46cf4dba3..8640f82d51f4 100644 --- a/devices/mediatek_gl_mt7981/diy.sh +++ b/devices/mediatek_gl_mt7981/diy.sh @@ -4,9 +4,16 @@ shopt -s extglob SHELL_FOLDER=$(dirname $(readlink -f "$0")) +rm -rf package/feeds +./scripts/feeds install -a -p gl_feed_mtk -f +./scripts/feeds install -a -p gl_feed_common -f +./scripts/feeds install -a -p gl_feed_21_02 -f +./scripts/feeds install -a -p kiddin9 -f +./scripts/feeds install -a + rm -rf package/feeds/kiddin9/{firewall,rtl*,base-files,netifd} -rm -rf devices/common/patches/{glinet,imagebuilder.patch,iptables.patch,targets.patch,kernel-defaults.patch,disable_flock.patch} +rm -rf devices/common/patches/{imagebuilder.patch,fix.patch,iptables.patch,targets.patch,kernel-defaults.patch,disable_flock.patch} sed -i "s/BOARD:=mediatek$/BOARD:=mediatek_gl/" target/linux/mediatek/Makefile @@ -17,7 +24,7 @@ rm -rf toolchain/musl svn co https://github.com/openwrt/openwrt/branches/openwrt-22.03/toolchain/musl toolchain/musl -sed -i "/mtk_openwrt_feed/d" feeds.conf +sed -i "/gl_feed_mtk/d" feeds.conf sed -i "/gl_feed_common/d" feeds.conf sed -i "/gl_feed_21_02/d" feeds.conf diff --git a/devices/mediatek_gl_mt7981/feeds.conf b/devices/mediatek_gl_mt7981/feeds.conf index c6d6fd39210a..f2be0f7c3383 100644 --- a/devices/mediatek_gl_mt7981/feeds.conf +++ b/devices/mediatek_gl_mt7981/feeds.conf @@ -2,6 +2,6 @@ src-git packages https://git.openwrt.org/feed/packages.git;openwrt-21.02 src-git luci https://git.openwrt.org/project/luci.git;openwrt-21.02 src-git routing https://git.openwrt.org/feed/routing.git;openwrt-21.02 src-git kiddin9 https://github.com/kiddin9/openwrt-packages.git;master -src-git mtk_openwrt_feed https://git01.mediatek.com/openwrt/feeds/mtk-openwrt-feeds.git^df3fc79 -src-git gl_feed_common https://github.com/gl-inet/gl-feeds.git;common +src-git gl_feed_mtk https://github.com/gl-inet/gl-feeds.git;mtk +src-git gl_feed_common https://github.com/gl-inet/gl-feeds.git^f86ec7f77b7a36c96a9b5a9b7fea30ccc9ac5fe6 src-git gl_feed_21_02 https://github.com/gl-inet/gl-feeds.git^032786d5ff300ebdd83fb1b5fec5344b3da04953 diff --git a/devices/mediatek_gl_mt7981/patches/0999-depends.patch b/devices/mediatek_gl_mt7981/patches/0999-depends.patch index 78c903d93e01..2caefa2ec291 100644 --- a/devices/mediatek_gl_mt7981/patches/0999-depends.patch +++ b/devices/mediatek_gl_mt7981/patches/0999-depends.patch @@ -1,10 +1,43 @@ +--- a/target/linux/mediatek_gl/Makefile ++++ a/target/linux/mediatek_gl/Makefile +@@ -10,9 +10,9 @@ + + KERNEL_PATCHVER:=5.4 + KERNEL_TESTING_PATCHVER:=5.4 + + include $(INCLUDE_DIR)/target.mk + DEFAULT_PACKAGES += \ +- kmod-leds-gpio kmod-gpio-button-hotplug ++ kmod-leds-gpio kmod-gpio-button-hotplug wpad-basic-wolfssl ethtool iwinfo wireless-tools kmod-mediatek_hnat mii_mgr mtkhnat_util regs fwdd kmod-mtfwd kmod-mtqos + + $(eval $(call BuildTarget)) + --- a/target/linux/mediatek_gl/image/mt7981.mk +++ b/target/linux/mediatek_gl/image/mt7981.mk -@@ -219,6 +219,6 @@ +@@ -175,13 +175,13 @@ + define Device/glinet_gl-mt3000 + DEVICE_VENDOR := GL.iNet + DEVICE_MODEL := GL-MT3000 + DEVICE_DTS := mt7981-gl-mt3000 + DEVICE_DTS_DIR := $(DTS_DIR)/mediatek + SUPPORTED_DEVICES := glinet,mt3000-snand +- DEVICE_PACKAGES := kmod-hwmon-pwmfan ++ DEVICE_PACKAGES := kmod-hwmon-pwmfan gl-sdk4-mtk-wifi-v2 kmod-conninfra-mt7981-ko kmod-mt-wifi-mt7981-ko kmod-warp-mt7981-ko kmod-gl-sdk4-fan 8021xd + UBINIZE_OPTS := -E 5 + BLOCKSIZE := 128k + PAGESIZE := 2048 + IMAGE_SIZE := 65536k + KERNEL_IN_UBI := 1 + IMAGES := factory.img sysupgrade.tar +@@ -215,10 +215,10 @@ + define Device/glinet_gl-mt2500 + DEVICE_VENDOR := GL.iNet + DEVICE_MODEL := GL-MT2500 + DEVICE_DTS := mt7981-gl-mt2500 SUPPORTED_DEVICES := glinet,mt2500-emmc DEVICE_DTS_DIR := $(DTS_DIR)/mediatek - DEVICE_PACKAGES := mkf2fs kmod-mmc kmod-fs-f2fs gdisk -+ DEVICE_PACKAGES := mkf2fs kmod-mmc kmod-fs-f2fs gdisk wpad-basic-wolfssl mii_mgr losetup e2fsprogs blockdev blkid kmod-nls-cp437 regs switch mtk_factory_rw ethtool kmod-mediatek_hnat mtkhnat_util mmc-utils ++ DEVICE_PACKAGES := mkf2fs kmod-mmc kmod-fs-f2fs gdisk losetup e2fsprogs blockdev blkid kmod-nls-cp437 mtk_factory_rw mmc-utils IMAGE/sysupgrade.bin := sysupgrade-tar | append-gl-metadata endef - TARGET_DEVICES += glinet_gl-mt2500 \ No newline at end of file + TARGET_DEVICES += glinet_gl-mt2500 diff --git a/devices/mediatek_gl_mt7981/patches/imagebuilder.patch b/devices/mediatek_gl_mt7981/patches/imagebuilder.patch index 2aaed7a0f32d..342c1cbeefa0 100644 --- a/devices/mediatek_gl_mt7981/patches/imagebuilder.patch +++ b/devices/mediatek_gl_mt7981/patches/imagebuilder.patch @@ -96,27 +96,15 @@ if output: - default_packages, output["arch_packages"] = run( -+ default_packages, output["arch_packages"], output["kernel_version"], output["initramfs"] = run( ++ default_packages, output["arch_packages"], output["kernel_version"] = run( [ "make", "--no-print-directory", -@@ -55,6 +55,8 @@ def get_initial_output(image_info): +@@ -55,6 +55,7 @@ def get_initial_output(image_info): "target/linux/", "val.DEFAULT_PACKAGES", "val.ARCH_PACKAGES", + "val.LINUX_VERSION", -+ "val.KERNEL_INITRAMFS", ], stdout=PIPE, stderr=PIPE, - ---- a/rules.mk -+++ b/rules.mk -@@ -59,6 +59,7 @@ _SINGLE=export MAKEFLAGS=$(space); - CFLAGS:= - ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH))))) - ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) -+KERNEL_INITRAMFS:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_INITRAMFS)) - BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) - SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) - TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) diff --git a/devices/mediatek_mt7981/diy.sh b/devices/mediatek_mt7981/diy.sh index dcf6050b3a8d..14404507586d 100644 --- a/devices/mediatek_mt7981/diy.sh +++ b/devices/mediatek_mt7981/diy.sh @@ -6,7 +6,7 @@ SHELL_FOLDER=$(dirname $(readlink -f "$0")) rm -rf package/feeds/kiddin9/rtl* -rm -rf devices/common/patches/{glinet,imagebuilder.patch,iptables.patch,kernel-defaults.patch,targets.patch} +rm -rf devices/common/patches/{glinet,fix.patch,iptables.patch,kernel-defaults.patch,targets.patch} rm -rf toolchain/musl diff --git a/devices/mediatek_mt7981/patches/fix.patch b/devices/mediatek_mt7981/patches/fix.patch new file mode 100644 index 000000000000..eb8a9b6869dc --- /dev/null +++ b/devices/mediatek_mt7981/patches/fix.patch @@ -0,0 +1,31 @@ +--- a/scripts/json_overview_image_info.py ++++ b/scripts/json_overview_image_info.py +@@ -47,7 +47,7 @@ def get_initial_output(image_info): + + + if output: +- default_packages, output["arch_packages"] = run( ++ default_packages, output["arch_packages"], output["kernel_version"], output["initramfs"] = run( + [ + "make", + "--no-print-directory", +@@ -55,6 +55,8 @@ def get_initial_output(image_info): + "target/linux/", + "val.DEFAULT_PACKAGES", + "val.ARCH_PACKAGES", ++ "val.LINUX_VERSION", ++ "val.KERNEL_INITRAMFS", + ], + stdout=PIPE, + stderr=PIPE, + +--- a/rules.mk ++++ b/rules.mk +@@ -59,6 +59,7 @@ _SINGLE=export MAKEFLAGS=$(space); + CFLAGS:= + ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH))))) + ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) ++KERNEL_INITRAMFS:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_INITRAMFS)) + BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) + SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) + TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) diff --git a/devices/mediatek_mt7981/patches/imagebuilder.patch b/devices/mediatek_mt7981/patches/imagebuilder.patch deleted file mode 100644 index 2aaed7a0f32d..000000000000 --- a/devices/mediatek_mt7981/patches/imagebuilder.patch +++ /dev/null @@ -1,122 +0,0 @@ ---- a/target/imagebuilder/Makefile -+++ b/target/imagebuilder/Makefile -@@ -38,13 +38,15 @@ $(BIN_DIR)/$(IB_NAME).tar.xz: clean - ./files/repositories.conf \ - $(TMP_DIR)/.targetinfo \ - $(TMP_DIR)/.packageinfo \ -- $(PKG_BUILD_DIR)/ -+ $(TOPDIR)/files \ -+ $(PKG_BUILD_DIR)/ || true - --ifeq ($(CONFIG_IB_STANDALONE),) - echo '## Remote package repositories' >> $(PKG_BUILD_DIR)/repositories.conf - $(call FeedSourcesAppend,$(PKG_BUILD_DIR)/repositories.conf) - $(VERSION_SED_SCRIPT) $(PKG_BUILD_DIR)/repositories.conf --endif -+ $(SED) 's/^src\/gz \(.*\) https.*top\/\(packages.*\)/src \1 file:\/\/www\/wwwroot\/op.supes.top\/\2/' $(PKG_BUILD_DIR)/repositories.conf -+ $(SED) 's/^src\/gz \(.*\) https.*top\/\(targets.*\)/src \1 file:\/\/www\/wwwroot\/op.supes.top\/releases\/\2/' $(PKG_BUILD_DIR)/repositories.conf -+ $(SED) 's/\/kiddin9//' $(PKG_BUILD_DIR)/repositories.conf - - $(INSTALL_DIR) $(PKG_BUILD_DIR)/packages - # create an empty package index so `opkg` doesn't report an error - ---- a/target/imagebuilder/files/Makefile -+++ b/target/imagebuilder/files/Makefile -@@ -115,17 +115,32 @@ BUILD_PACKAGES:=$(filter-out $(filter -%,$(BUILD_PACKAGES)) $(patsubst -%,%,$(fi - PACKAGES:= - - _call_image: staging_dir/host/.prereq-build -+ [ "$(DATE)" ] && DATE="$(DATE)" || DATE="`date +'%m.%d.%Y'`"; \ -+ mkdir -p $(USER_FILES)/etc/uci-defaults || true; \ -+ echo -e " \ -+ sed -i \"s/[0-9]\+.[0-9]\+.[0-9]\{4\}/$$DATE/\" /etc/openwrt_release \n \ -+ sed -i \"s/DISTRIB_ID=.*/DISTRIB_ID='$(PARTSIZE)'/\" /etc/openwrt_release \n \ -+ sed -i \"s/OpenWrt .* by/OpenWrt $$DATE by/\" /etc/banner \n \ -+ echo \"$$DATE\" >/etc/openwrt_version \n \ -+ "> $(USER_FILES)/etc/uci-defaults/99-version; \ - echo 'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))' - echo 'Packages: $(BUILD_PACKAGES)' - echo - rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG) - mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR) -+ if [[ "$(USER_PROFILE)" =~ (DEVICE_phicomm_k2p|DEVICE_asus_rt-n56u-b1|DEVICE_thunder_timecloud|DEVICE_youku_yk-l2|DEVICE_youhua_wr1200js|DEVICE_oraybox_x3a|DEVICE_netgear_wndr3700-v5|DEVICE_xiaomi_mi-router-4a-gigabit|DEVICE_xiaomi_mi-router-3g-v2|DEVICE_jcg_y2|DEVICE_glinet_gl-mt300a|DEVICE_glinet_gl-mt750|DEVICE_hiwifi_hc5661|DEVICE_hiwifi_hc5761|DEVICE_hiwifi_hc5861|DEVICE_lenovo_newifi-y1|DEVICE_lenovo_newifi-y1s|DEVICE_xiaomi_miwifi-mini|DEVICE_youku_yk-l1c|DEVICE_jdcloud_luban) || "$(TARGETID)" == "ramips/mt76x8" ]]; then \ -+ echo "src/gz openwrt_smflash https://op.supes.top/packages/mipsel_24kc/small_flash" >>$(TOPDIR)/repositories.conf; \ -+ else \ -+ sed -i "/smflash/d" $(TOPDIR)/repositories.conf; \ -+ fi - $(MAKE) package_reload - $(MAKE) package_install - $(MAKE) -s prepare_rootfs - $(MAKE) -s build_image - $(MAKE) -s json_overview_image_info - $(MAKE) -s checksum -+ rm -rf $(KERNEL_BUILD_DIR)/tmp -+ rm -rf $(KERNEL_BUILD_DIR)/root.* - - _call_manifest: FORCE - rm -rf $(TARGET_DIR) -@@ -166,7 +181,14 @@ package_install: FORCE - @echo Installing packages... - $(OPKG) install $(firstword $(wildcard $(LINUX_DIR)/libc_*.ipk $(PACKAGE_DIR)/libc_*.ipk)) - $(OPKG) install $(firstword $(wildcard $(LINUX_DIR)/kernel_*.ipk $(PACKAGE_DIR)/kernel_*.ipk)) -- $(OPKG) install $(BUILD_PACKAGES) -+ for p in $(BUILD_PACKAGES); do \ -+ if [[ $$p == luci-app-* && "`$(OPKG) list | grep luci-i18n-\`echo $$p | cut -d - -f 3-\`-zh-cn`" ]]; then \ -+ packages+="luci-i18n-`echo $$p | cut -d - -f 3-`-zh-cn "; \ -+ fi \ -+ done; \ -+ $(OPKG) install --force-overwrite --force-checksum --force-depends $(BUILD_PACKAGES) luci-i18n-base-zh-cn luci-i18n-base-en; \ -+ $(OPKG) install $$packages || true -+ $(OPKG) install --force-overwrite --force-checksum --force-depends --force-maintainer --force-reinstall my-default-settings - - prepare_rootfs: FORCE - @echo -@@ -180,12 +202,15 @@ prepare_rootfs: FORCE - ) \ - ) - $(call prepare_rootfs,$(TARGET_DIR),$(USER_FILES),$(DISABLED_SERVICES)) -+ if [[ "$(USER_PROFILE)" =~ (DEVICE_phicomm_k2p|DEVICE_asus_rt-n56u-b1|DEVICE_thunder_timecloud|DEVICE_youku_yk-l2|DEVICE_youhua_wr1200js|DEVICE_oraybox_x3a|DEVICE_netgear_wndr3700-v5|DEVICE_xiaomi_mi-router-4a-gigabit|DEVICE_xiaomi_mi-router-3g-v2|DEVICE_jcg_y2|DEVICE_glinet_gl-mt300a|DEVICE_glinet_gl-mt750|DEVICE_hiwifi_hc5661|DEVICE_hiwifi_hc5761|DEVICE_hiwifi_hc5861|DEVICE_lenovo_newifi-y1|DEVICE_lenovo_newifi-y1s|DEVICE_xiaomi_miwifi-mini|DEVICE_youku_yk-l1c|DEVICE_jdcloud_luban) || "$(TARGETID)" == "ramips/mt76x8" ]]; then \ -+ echo "src/gz openwrt_smflash https://op.supes.top/packages/mipsel_24kc/small_flash" >>$(BUILD_DIR)/root-ramips/etc/opkg/distfeeds.conf; \ -+ fi - - build_image: FORCE - @echo - @echo Building images... - rm -rf $(BUILD_DIR)/json_info_files/ -- $(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)" \ -+ nice -n 19 $(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)" \ - $(if $(USER_PROFILE),PROFILE="$(USER_PROFILE)") - - $(BIN_DIR)/profiles.json: FORCE - ---- a/scripts/json_overview_image_info.py -+++ b/scripts/json_overview_image_info.py -@@ -47,7 +47,7 @@ def get_initial_output(image_info): - - - if output: -- default_packages, output["arch_packages"] = run( -+ default_packages, output["arch_packages"], output["kernel_version"], output["initramfs"] = run( - [ - "make", - "--no-print-directory", -@@ -55,6 +55,8 @@ def get_initial_output(image_info): - "target/linux/", - "val.DEFAULT_PACKAGES", - "val.ARCH_PACKAGES", -+ "val.LINUX_VERSION", -+ "val.KERNEL_INITRAMFS", - ], - stdout=PIPE, - stderr=PIPE, - ---- a/rules.mk -+++ b/rules.mk -@@ -59,6 +59,7 @@ _SINGLE=export MAKEFLAGS=$(space); - CFLAGS:= - ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH))))) - ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) -+KERNEL_INITRAMFS:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_INITRAMFS)) - BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) - SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) - TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) diff --git a/devices/mediatek_mt7981/patches/iptables-mod-socket.patch b/devices/mediatek_mt7981/patches/iptables-mod-socket.patch new file mode 100644 index 000000000000..0398c93b6a6c --- /dev/null +++ b/devices/mediatek_mt7981/patches/iptables-mod-socket.patch @@ -0,0 +1,40 @@ +--- a/package/network/utils/iptables/Makefile ++++ b/package/network/utils/iptables/Makefile +@@ -388,6 +388,19 @@ iptables extension for triggering a LED. + + endef + ++define Package/iptables-mod-socket ++$(call Package/iptables/Module, +kmod-ipt-socket) ++ TITLE:=Socket match iptables extensions ++endef ++ ++define Package/iptables-mod-socket/description ++Socket match iptables extensions. ++ ++ Matches: ++ - socket ++ ++endef ++ + define Package/iptables-mod-tproxy + $(call Package/iptables/Module, +kmod-ipt-tproxy) + TITLE:=Transparent proxy iptables extensions +@@ -396,9 +409,6 @@ endef + define Package/iptables-mod-tproxy/description + Transparent proxy iptables extensions. + +- Matches: +- - socket +- + Targets: + - TPROXY + +@@ -721,6 +731,7 @@ $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m))) + $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m))) + $(eval $(call BuildPlugin,iptables-mod-rpfilter,$(IPT_RPFILTER-m))) + $(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m))) ++$(eval $(call BuildPlugin,iptables-mod-socket,$(IPT_SOCKET-m))) + $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m))) + $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m))) + $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m))) \ No newline at end of file diff --git a/devices/mediatek_mt7981/patches/targets.patch b/devices/mediatek_mt7981/patches/targets.patch index 4025b23f3719..170f75f95f9d 100644 --- a/devices/mediatek_mt7981/patches/targets.patch +++ b/devices/mediatek_mt7981/patches/targets.patch @@ -1,14 +1,5 @@ --- a/include/target.mk +++ b/include/target.mk -@@ -10,7 +10,7 @@ __target_inc=1 - DEVICE_TYPE?=router - - # Default packages - the really basic set --DEFAULT_PACKAGES:=\ -+DEFAULT_PACKAGES:=luci-app-advanced luci-app-firewall luci-app-gpsysupgrade luci-app-opkg luci-app-upnp luci-app-autoreboot luci-app-wizard luci-base luci-compat luci-lib-ipkg luci-lib-fs coremark wget-ssl curl htop nano zram-swap kmod-lib-zstd kmod-tcp-bbr bash openssh-sftp-server block-mount resolveip ds-lite swconfig \ - base-files \ - ca-bundle \ - dropbear \ @@ -46,28 +46,31 @@ DEFAULT_PACKAGES.router:=\ dnsmasq-full \ firewall \ @@ -55,13 +46,4 @@ + target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1)))) ifeq ($(DUMP),) - PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD) -@@ -205,7 +208,7 @@ LINUX_RECONF_DIFF = $(SCRIPT_DIR)/kconfig.pl - '>' $(call __linux_confcmd,$(filt - ifeq ($(DUMP),1) - BuildTarget=$(BuildTargets/DumpCurrent) - -- CPU_CFLAGS = -Os -pipe -+ CPU_CFLAGS = -O2 -pipe - ifneq ($(findstring mips,$(ARCH)),) - ifneq ($(findstring mips64,$(ARCH)),) - CPU_TYPE ?= mips64 \ No newline at end of file + PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD) \ No newline at end of file diff --git a/devices/mediatek_mt7986/diy.sh b/devices/mediatek_mt7986/diy.sh index dcf6050b3a8d..14404507586d 100644 --- a/devices/mediatek_mt7986/diy.sh +++ b/devices/mediatek_mt7986/diy.sh @@ -6,7 +6,7 @@ SHELL_FOLDER=$(dirname $(readlink -f "$0")) rm -rf package/feeds/kiddin9/rtl* -rm -rf devices/common/patches/{glinet,imagebuilder.patch,iptables.patch,kernel-defaults.patch,targets.patch} +rm -rf devices/common/patches/{glinet,fix.patch,iptables.patch,kernel-defaults.patch,targets.patch} rm -rf toolchain/musl diff --git a/devices/mediatek_mt7986/patches/fix.patch b/devices/mediatek_mt7986/patches/fix.patch new file mode 100644 index 000000000000..eb8a9b6869dc --- /dev/null +++ b/devices/mediatek_mt7986/patches/fix.patch @@ -0,0 +1,31 @@ +--- a/scripts/json_overview_image_info.py ++++ b/scripts/json_overview_image_info.py +@@ -47,7 +47,7 @@ def get_initial_output(image_info): + + + if output: +- default_packages, output["arch_packages"] = run( ++ default_packages, output["arch_packages"], output["kernel_version"], output["initramfs"] = run( + [ + "make", + "--no-print-directory", +@@ -55,6 +55,8 @@ def get_initial_output(image_info): + "target/linux/", + "val.DEFAULT_PACKAGES", + "val.ARCH_PACKAGES", ++ "val.LINUX_VERSION", ++ "val.KERNEL_INITRAMFS", + ], + stdout=PIPE, + stderr=PIPE, + +--- a/rules.mk ++++ b/rules.mk +@@ -59,6 +59,7 @@ _SINGLE=export MAKEFLAGS=$(space); + CFLAGS:= + ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH))))) + ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) ++KERNEL_INITRAMFS:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_INITRAMFS)) + BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) + SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) + TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) diff --git a/devices/mediatek_mt7986/patches/imagebuilder.patch b/devices/mediatek_mt7986/patches/imagebuilder.patch deleted file mode 100644 index 2aaed7a0f32d..000000000000 --- a/devices/mediatek_mt7986/patches/imagebuilder.patch +++ /dev/null @@ -1,122 +0,0 @@ ---- a/target/imagebuilder/Makefile -+++ b/target/imagebuilder/Makefile -@@ -38,13 +38,15 @@ $(BIN_DIR)/$(IB_NAME).tar.xz: clean - ./files/repositories.conf \ - $(TMP_DIR)/.targetinfo \ - $(TMP_DIR)/.packageinfo \ -- $(PKG_BUILD_DIR)/ -+ $(TOPDIR)/files \ -+ $(PKG_BUILD_DIR)/ || true - --ifeq ($(CONFIG_IB_STANDALONE),) - echo '## Remote package repositories' >> $(PKG_BUILD_DIR)/repositories.conf - $(call FeedSourcesAppend,$(PKG_BUILD_DIR)/repositories.conf) - $(VERSION_SED_SCRIPT) $(PKG_BUILD_DIR)/repositories.conf --endif -+ $(SED) 's/^src\/gz \(.*\) https.*top\/\(packages.*\)/src \1 file:\/\/www\/wwwroot\/op.supes.top\/\2/' $(PKG_BUILD_DIR)/repositories.conf -+ $(SED) 's/^src\/gz \(.*\) https.*top\/\(targets.*\)/src \1 file:\/\/www\/wwwroot\/op.supes.top\/releases\/\2/' $(PKG_BUILD_DIR)/repositories.conf -+ $(SED) 's/\/kiddin9//' $(PKG_BUILD_DIR)/repositories.conf - - $(INSTALL_DIR) $(PKG_BUILD_DIR)/packages - # create an empty package index so `opkg` doesn't report an error - ---- a/target/imagebuilder/files/Makefile -+++ b/target/imagebuilder/files/Makefile -@@ -115,17 +115,32 @@ BUILD_PACKAGES:=$(filter-out $(filter -%,$(BUILD_PACKAGES)) $(patsubst -%,%,$(fi - PACKAGES:= - - _call_image: staging_dir/host/.prereq-build -+ [ "$(DATE)" ] && DATE="$(DATE)" || DATE="`date +'%m.%d.%Y'`"; \ -+ mkdir -p $(USER_FILES)/etc/uci-defaults || true; \ -+ echo -e " \ -+ sed -i \"s/[0-9]\+.[0-9]\+.[0-9]\{4\}/$$DATE/\" /etc/openwrt_release \n \ -+ sed -i \"s/DISTRIB_ID=.*/DISTRIB_ID='$(PARTSIZE)'/\" /etc/openwrt_release \n \ -+ sed -i \"s/OpenWrt .* by/OpenWrt $$DATE by/\" /etc/banner \n \ -+ echo \"$$DATE\" >/etc/openwrt_version \n \ -+ "> $(USER_FILES)/etc/uci-defaults/99-version; \ - echo 'Building images for $(BOARD)$(if $($(USER_PROFILE)_NAME), - $($(USER_PROFILE)_NAME))' - echo 'Packages: $(BUILD_PACKAGES)' - echo - rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG) - mkdir -p $(TARGET_DIR) $(BIN_DIR) $(TMP_DIR) $(DL_DIR) -+ if [[ "$(USER_PROFILE)" =~ (DEVICE_phicomm_k2p|DEVICE_asus_rt-n56u-b1|DEVICE_thunder_timecloud|DEVICE_youku_yk-l2|DEVICE_youhua_wr1200js|DEVICE_oraybox_x3a|DEVICE_netgear_wndr3700-v5|DEVICE_xiaomi_mi-router-4a-gigabit|DEVICE_xiaomi_mi-router-3g-v2|DEVICE_jcg_y2|DEVICE_glinet_gl-mt300a|DEVICE_glinet_gl-mt750|DEVICE_hiwifi_hc5661|DEVICE_hiwifi_hc5761|DEVICE_hiwifi_hc5861|DEVICE_lenovo_newifi-y1|DEVICE_lenovo_newifi-y1s|DEVICE_xiaomi_miwifi-mini|DEVICE_youku_yk-l1c|DEVICE_jdcloud_luban) || "$(TARGETID)" == "ramips/mt76x8" ]]; then \ -+ echo "src/gz openwrt_smflash https://op.supes.top/packages/mipsel_24kc/small_flash" >>$(TOPDIR)/repositories.conf; \ -+ else \ -+ sed -i "/smflash/d" $(TOPDIR)/repositories.conf; \ -+ fi - $(MAKE) package_reload - $(MAKE) package_install - $(MAKE) -s prepare_rootfs - $(MAKE) -s build_image - $(MAKE) -s json_overview_image_info - $(MAKE) -s checksum -+ rm -rf $(KERNEL_BUILD_DIR)/tmp -+ rm -rf $(KERNEL_BUILD_DIR)/root.* - - _call_manifest: FORCE - rm -rf $(TARGET_DIR) -@@ -166,7 +181,14 @@ package_install: FORCE - @echo Installing packages... - $(OPKG) install $(firstword $(wildcard $(LINUX_DIR)/libc_*.ipk $(PACKAGE_DIR)/libc_*.ipk)) - $(OPKG) install $(firstword $(wildcard $(LINUX_DIR)/kernel_*.ipk $(PACKAGE_DIR)/kernel_*.ipk)) -- $(OPKG) install $(BUILD_PACKAGES) -+ for p in $(BUILD_PACKAGES); do \ -+ if [[ $$p == luci-app-* && "`$(OPKG) list | grep luci-i18n-\`echo $$p | cut -d - -f 3-\`-zh-cn`" ]]; then \ -+ packages+="luci-i18n-`echo $$p | cut -d - -f 3-`-zh-cn "; \ -+ fi \ -+ done; \ -+ $(OPKG) install --force-overwrite --force-checksum --force-depends $(BUILD_PACKAGES) luci-i18n-base-zh-cn luci-i18n-base-en; \ -+ $(OPKG) install $$packages || true -+ $(OPKG) install --force-overwrite --force-checksum --force-depends --force-maintainer --force-reinstall my-default-settings - - prepare_rootfs: FORCE - @echo -@@ -180,12 +202,15 @@ prepare_rootfs: FORCE - ) \ - ) - $(call prepare_rootfs,$(TARGET_DIR),$(USER_FILES),$(DISABLED_SERVICES)) -+ if [[ "$(USER_PROFILE)" =~ (DEVICE_phicomm_k2p|DEVICE_asus_rt-n56u-b1|DEVICE_thunder_timecloud|DEVICE_youku_yk-l2|DEVICE_youhua_wr1200js|DEVICE_oraybox_x3a|DEVICE_netgear_wndr3700-v5|DEVICE_xiaomi_mi-router-4a-gigabit|DEVICE_xiaomi_mi-router-3g-v2|DEVICE_jcg_y2|DEVICE_glinet_gl-mt300a|DEVICE_glinet_gl-mt750|DEVICE_hiwifi_hc5661|DEVICE_hiwifi_hc5761|DEVICE_hiwifi_hc5861|DEVICE_lenovo_newifi-y1|DEVICE_lenovo_newifi-y1s|DEVICE_xiaomi_miwifi-mini|DEVICE_youku_yk-l1c|DEVICE_jdcloud_luban) || "$(TARGETID)" == "ramips/mt76x8" ]]; then \ -+ echo "src/gz openwrt_smflash https://op.supes.top/packages/mipsel_24kc/small_flash" >>$(BUILD_DIR)/root-ramips/etc/opkg/distfeeds.conf; \ -+ fi - - build_image: FORCE - @echo - @echo Building images... - rm -rf $(BUILD_DIR)/json_info_files/ -- $(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)" \ -+ nice -n 19 $(NO_TRACE_MAKE) -C target/linux/$(BOARD)/image install TARGET_BUILD=1 IB=1 EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)" \ - $(if $(USER_PROFILE),PROFILE="$(USER_PROFILE)") - - $(BIN_DIR)/profiles.json: FORCE - ---- a/scripts/json_overview_image_info.py -+++ b/scripts/json_overview_image_info.py -@@ -47,7 +47,7 @@ def get_initial_output(image_info): - - - if output: -- default_packages, output["arch_packages"] = run( -+ default_packages, output["arch_packages"], output["kernel_version"], output["initramfs"] = run( - [ - "make", - "--no-print-directory", -@@ -55,6 +55,8 @@ def get_initial_output(image_info): - "target/linux/", - "val.DEFAULT_PACKAGES", - "val.ARCH_PACKAGES", -+ "val.LINUX_VERSION", -+ "val.KERNEL_INITRAMFS", - ], - stdout=PIPE, - stderr=PIPE, - ---- a/rules.mk -+++ b/rules.mk -@@ -59,6 +59,7 @@ _SINGLE=export MAKEFLAGS=$(space); - CFLAGS:= - ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH))))) - ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) -+KERNEL_INITRAMFS:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_INITRAMFS)) - BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) - SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) - TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) diff --git a/devices/mediatek_mt7986/patches/iptables-mod-socket.patch b/devices/mediatek_mt7986/patches/iptables-mod-socket.patch new file mode 100644 index 000000000000..0398c93b6a6c --- /dev/null +++ b/devices/mediatek_mt7986/patches/iptables-mod-socket.patch @@ -0,0 +1,40 @@ +--- a/package/network/utils/iptables/Makefile ++++ b/package/network/utils/iptables/Makefile +@@ -388,6 +388,19 @@ iptables extension for triggering a LED. + + endef + ++define Package/iptables-mod-socket ++$(call Package/iptables/Module, +kmod-ipt-socket) ++ TITLE:=Socket match iptables extensions ++endef ++ ++define Package/iptables-mod-socket/description ++Socket match iptables extensions. ++ ++ Matches: ++ - socket ++ ++endef ++ + define Package/iptables-mod-tproxy + $(call Package/iptables/Module, +kmod-ipt-tproxy) + TITLE:=Transparent proxy iptables extensions +@@ -396,9 +409,6 @@ endef + define Package/iptables-mod-tproxy/description + Transparent proxy iptables extensions. + +- Matches: +- - socket +- + Targets: + - TPROXY + +@@ -721,6 +731,7 @@ $(eval $(call BuildPlugin,iptables-mod-ulog,$(IPT_ULOG-m))) + $(eval $(call BuildPlugin,iptables-mod-hashlimit,$(IPT_HASHLIMIT-m))) + $(eval $(call BuildPlugin,iptables-mod-rpfilter,$(IPT_RPFILTER-m))) + $(eval $(call BuildPlugin,iptables-mod-led,$(IPT_LED-m))) ++$(eval $(call BuildPlugin,iptables-mod-socket,$(IPT_SOCKET-m))) + $(eval $(call BuildPlugin,iptables-mod-tproxy,$(IPT_TPROXY-m))) + $(eval $(call BuildPlugin,iptables-mod-tee,$(IPT_TEE-m))) + $(eval $(call BuildPlugin,iptables-mod-u32,$(IPT_U32-m))) \ No newline at end of file diff --git a/devices/mediatek_mt7986/patches/targets.patch b/devices/mediatek_mt7986/patches/targets.patch index 4025b23f3719..170f75f95f9d 100644 --- a/devices/mediatek_mt7986/patches/targets.patch +++ b/devices/mediatek_mt7986/patches/targets.patch @@ -1,14 +1,5 @@ --- a/include/target.mk +++ b/include/target.mk -@@ -10,7 +10,7 @@ __target_inc=1 - DEVICE_TYPE?=router - - # Default packages - the really basic set --DEFAULT_PACKAGES:=\ -+DEFAULT_PACKAGES:=luci-app-advanced luci-app-firewall luci-app-gpsysupgrade luci-app-opkg luci-app-upnp luci-app-autoreboot luci-app-wizard luci-base luci-compat luci-lib-ipkg luci-lib-fs coremark wget-ssl curl htop nano zram-swap kmod-lib-zstd kmod-tcp-bbr bash openssh-sftp-server block-mount resolveip ds-lite swconfig \ - base-files \ - ca-bundle \ - dropbear \ @@ -46,28 +46,31 @@ DEFAULT_PACKAGES.router:=\ dnsmasq-full \ firewall \ @@ -55,13 +46,4 @@ + target_conf=$(subst .,_,$(subst -,_,$(subst /,_,$(1)))) ifeq ($(DUMP),) - PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD) -@@ -205,7 +208,7 @@ LINUX_RECONF_DIFF = $(SCRIPT_DIR)/kconfig.pl - '>' $(call __linux_confcmd,$(filt - ifeq ($(DUMP),1) - BuildTarget=$(BuildTargets/DumpCurrent) - -- CPU_CFLAGS = -Os -pipe -+ CPU_CFLAGS = -O2 -pipe - ifneq ($(findstring mips,$(ARCH)),) - ifneq ($(findstring mips64,$(ARCH)),) - CPU_TYPE ?= mips64 \ No newline at end of file + PLATFORM_DIR:=$(TOPDIR)/target/linux/$(BOARD) \ No newline at end of file diff --git a/devices/ramips_mt7620/.config b/devices/ramips_mt7620/.config index 0d738a4eb85b..f905becd9fe4 100644 --- a/devices/ramips_mt7620/.config +++ b/devices/ramips_mt7620/.config @@ -7,6 +7,7 @@ CONFIG_TARGET_DEVICE_ramips_mt7620_DEVICE_glinet_gl-mt750=y CONFIG_TARGET_DEVICE_ramips_mt7620_DEVICE_hiwifi_hc5661=y CONFIG_TARGET_DEVICE_ramips_mt7620_DEVICE_hiwifi_hc5761=y CONFIG_TARGET_DEVICE_ramips_mt7620_DEVICE_hiwifi_hc5861=y +CONFIG_TARGET_DEVICE_ramips_mt7620_DEVICE_hiwifi_r33=y CONFIG_TARGET_DEVICE_ramips_mt7620_DEVICE_lenovo_newifi-y1=y CONFIG_TARGET_DEVICE_ramips_mt7620_DEVICE_lenovo_newifi-y1s=y CONFIG_TARGET_DEVICE_ramips_mt7620_DEVICE_xiaomi_miwifi-mini=y diff --git a/devices/ramips_mt7620/diy.sh b/devices/ramips_mt7620/diy.sh index 291caaf55d57..3a2179853b1b 100644 --- a/devices/ramips_mt7620/diy.sh +++ b/devices/ramips_mt7620/diy.sh @@ -4,3 +4,6 @@ shopt -s extglob sh -c "curl -sfL https://github.com/openwrt/openwrt/commit/2e6d19ee32399e37c7545aefc57d41541a406d55.patch | patch -d './' -p1 --forward" || true + + + diff --git a/devices/ramips_mt7620/patches/hiwifi_r33.patch b/devices/ramips_mt7620/patches/hiwifi_r33.patch new file mode 100644 index 000000000000..0ea34bc1f0cb --- /dev/null +++ b/devices/ramips_mt7620/patches/hiwifi_r33.patch @@ -0,0 +1,2874 @@ +From 1077f225d9906c04dd56b93e63900701beb92483 Mon Sep 17 00:00:00 2001 +From: zfdx123 <2915441170@qq.com> +Date: Thu, 26 Jan 2023 09:42:50 +0800 +Subject: [PATCH] ramips: MT7620 add Support HiWiFi R33(C312B B52) + +--- + .../generic/files/drivers/net/phy/rtl8367b.c | 11 + + .../linux/ramips/dts/mt7620a_hiwifi_r33.dts | 235 ++ + target/linux/ramips/image/mt7620.mk | 21 + + .../mt7620/base-files/etc/board.d/01_leds | 3 + + .../mt7620/base-files/etc/board.d/02_network | 13 + + .../etc/hotplug.d/ieee80211/10_fix_wifi_mac | 7 + + .../mt7620/base-files/lib/upgrade/platform.sh | 3 + + target/linux/ramips/mt7620/config-5.10 | 21 + + target/linux/ramips/mt7620/target.mk | 2 +- + ...38-mtd-ralink-add-mt7620-nand-driver.patch | 2373 +++++++++++++++++ + 10 files changed, 2688 insertions(+), 1 deletion(-) + create mode 100644 target/linux/ramips/dts/mt7620a_hiwifi_r33.dts + create mode 100644 target/linux/ramips/patches-5.10/0038-mtd-ralink-add-mt7620-nand-driver.patch + +diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367b.c b/target/linux/generic/files/drivers/net/phy/rtl8367b.c +index 3599791a517bb..942cbd73b7205 100644 +--- a/target/linux/generic/files/drivers/net/phy/rtl8367b.c ++++ b/target/linux/generic/files/drivers/net/phy/rtl8367b.c +@@ -266,6 +266,8 @@ struct rtl8367b_initval { + #define RTL8367B_MIB_RXB_ID 0 /* IfInOctets */ + #define RTL8367B_MIB_TXB_ID 28 /* IfOutOctets */ + ++u32 rtl_device_id; ++ + static struct rtl8366_mib_counter + rtl8367b_mib_counters[RTL8367B_NUM_MIB_COUNTERS] = { + {0, 0, 4, "ifInOctets" }, +@@ -612,8 +614,14 @@ static int rtl8367b_write_initvals(struct rtl8366_smi *smi, + int err; + int i; + ++ if (rtl_device_id == 0x0020) { ++ return 0; ++ } ++ + for (i = 0; i < count; i++) ++ { + REG_WR(smi, initvals[i].reg, initvals[i].val); ++ } + + return 0; + } +@@ -1540,7 +1548,10 @@ static int rtl8367b_detect(struct rtl8366_smi *smi) + return ret; + } + ++ rtl_device_id = chip_ver; ++ + switch (chip_ver) { ++ case 0x0020: + case 0x1000: + chip_name = "8367RB"; + break; +diff --git a/target/linux/ramips/dts/mt7620a_hiwifi_r33.dts b/target/linux/ramips/dts/mt7620a_hiwifi_r33.dts +new file mode 100644 +index 0000000000000..09f5a84b773c5 +--- /dev/null ++++ b/target/linux/ramips/dts/mt7620a_hiwifi_r33.dts +@@ -0,0 +1,235 @@ ++#include "mt7620a.dtsi" ++ ++#include ++#include ++ ++/ { ++ compatible = "hiwifi,r33", "ralink,mt7620a-soc"; ++ model = "HiWiFi R33"; ++ ++ chosen { ++ bootargs = "console=ttyS0,115200"; ++ }; ++ ++ aliases { ++ led-boot = &led_system; ++ led-failsafe = &led_system; ++ led-running = &led_system; ++ led-upgrade = &led_system; ++ }; ++ ++ nand { ++ status = "okay"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ compatible = "mtk,mt7620-nand"; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "u-boot"; ++ reg = <0x0 0x80000>; ++ read-only; ++ }; ++ ++ partition@80000 { ++ label = "debug"; ++ reg = <0x80000 0x80000>; ++ read-only; ++ }; ++ ++ factory: partition@100000 { ++ label = "factory"; ++ reg = <0x100000 0x40000>; ++ read-only; ++ }; ++ ++ partition@140000 { ++ label = "kernel"; ++ reg = <0x140000 0x400000>; ++ }; ++ ++ ubiconcat0: partition@540000 { ++ label = "ubiconcat0"; ++ reg = <0x540000 0x1c80000>; ++ }; ++ ++ partition@21c0000 { ++ label = "bdinfo"; ++ reg = <0x21c0000 0x80000>; ++ read-only; ++ }; ++ ++ ubiconcat1: partition@2240000 { ++ label = "ubiconcat1"; ++ reg = <0x2240000 0x5d40000>; ++ }; ++ }; ++ }; ++ ++ ubi-concat { ++ compatible = "mtd-concat"; ++ devices = <&ubiconcat0 &ubiconcat1>; ++ ++ partitions { ++ compatible = "fixed-partitions"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ partition@0 { ++ label = "ubi"; ++ reg = <0x0 0x79c0000>; ++ }; ++ }; ++ }; ++ ++ leds { ++ compatible = "gpio-leds"; ++ ++ wlan5g { ++ label = "blue:wlan5g"; ++ gpios = <&gpio0 7 GPIO_ACTIVE_LOW>; ++ linux,default-trigger = "phy0tpt"; ++ }; ++ ++ led_system: system { ++ label = "blue:system"; ++ gpios = <&gpio0 9 GPIO_ACTIVE_HIGH>; ++ }; ++ ++ turbo { ++ label = "blue:turbo"; ++ gpios = <&gpio0 10 GPIO_ACTIVE_HIGH>; ++ }; ++ ++ wlan2g { ++ label = "blue:wlan2g"; ++ gpios = <&gpio0 11 GPIO_ACTIVE_LOW>; ++ linux,default-trigger = "phy1tpt"; ++ }; ++ ++ internet { ++ label = "blue:internet"; ++ gpios = <&gpio3 0 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ ++ keys { ++ compatible = "gpio-keys"; ++ ++ reset { ++ label = "reset"; ++ gpios = <&gpio0 12 GPIO_ACTIVE_HIGH>; ++ linux,code = ; ++ }; ++ }; ++ ++ gpio_export { ++ compatible = "gpio-export"; ++ #size-cells = <0>; ++ ++ usbpower { ++ gpio-export,name = "usbpower"; ++ gpio-export,output = <0>; ++ gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; ++ }; ++ }; ++ ++ rtl8367rb { ++ compatible = "realtek,rtl8367b", "rtl8367b"; ++ cpu_port = <6>; ++ realtek,extif1 = <1 0 1 1 1 1 1 1 2>; ++ mii-bus = <&mdio0>; ++ }; ++}; ++ ++//在最新的openwrt master分支中sysc已经被剔除,此处进行备份标记 ++// &sysc { ++// ralink,gpiomux = "i2c", "jtag"; ++// ralink,uartmux = "gpio"; ++// ralink,wdtmux = <1>; ++// }; ++ ++&gpio3 { ++ status = "okay"; ++}; ++ ++&ehci { ++ status = "okay"; ++}; ++ ++&ohci { ++ status = "okay"; ++}; ++ ++&pcie { ++ status = "okay"; ++}; ++ ++ðernet { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&rgmii1_pins &rgmii2_pins &mdio_pins>; ++ ++ //mtd-mac-address = <&factory 0x4>; ++ ++ nvmem-cells = <&macaddr_factory_4>; ++ nvmem-cell-names = "mac-address"; ++ ++ port@5 { ++ status = "okay"; ++ mediatek,fixed-link = <1000 1 1 1>; ++ phy-handle = <&phy5>; ++ phy-mode = "rgmii"; ++ }; ++ ++ mdio0: mdio-bus { ++ status = "okay"; ++ ++ phy5: ethernet-phy@5 { ++ reg = <5>; ++ phy-mode = "rgmii"; ++ }; ++ }; ++}; ++ ++//5G WIFI ++&pcie0 { ++ wifi@0,0 { ++ compatible = "pci14c3,7662"; ++ reg = <0x0000 0 0 0 0>; ++ mediatek,mtd-eeprom = <&factory 0x8000>; ++ ieee80211-freq-limit = <5000000 6000000>; ++ // nvmem-cells = <&macaddr_factory_4>; ++ // nvmem-cell-names = "mac-address"; ++ // mac-address-increment = <2>; ++ }; ++}; ++ ++//2.4G WIFI ++&wmac { ++ pinctrl-names = "default"; ++ pinctrl-0 = <&pa_pins>; ++ ralink,mtd-eeprom = <&factory 0x0>; ++ // nvmem-cells = <&macaddr_factory_4>; ++ // nvmem-cell-names = "mac-address"; ++}; ++ ++&state_default { ++ gpio { ++ groups = "uartf", "wled"; ++ function = "gpio"; ++ }; ++}; ++ ++&factory { ++ compatible = "nvmem-cells"; ++ #address-cells = <1>; ++ #size-cells = <1>; ++ ++ macaddr_factory_4: macaddr@4 { ++ reg = <0x4 0x6>; ++ }; ++}; +diff --git a/target/linux/ramips/image/mt7620.mk b/target/linux/ramips/image/mt7620.mk +index 445d3dec34238..c90b8d1f93d02 100644 +--- a/target/linux/ramips/image/mt7620.mk ++++ b/target/linux/ramips/image/mt7620.mk +@@ -1495,3 +1495,24 @@ define Device/zyxel_keenetic-viva + SUPPORTED_DEVICES += kng_rc + endef + TARGET_DEVICES += zyxel_keenetic-viva ++ ++define Device/hiwifi_r33 ++ SOC := mt7620a ++ DEVICE_VENDOR := HiWiFi ++ DEVICE_MODEL := R33 / 3Pro ++ DEVICE_PACKAGES := kmod-usb2 kmod-usb-ohci kmod-usb-ledtrig-usbport \ ++ kmod-switch-rtl8366-smi kmod-switch-rtl8367b kmod-mt76x2 ++ BLOCKSIZE := 128k ++ PAGESIZE := 2048 ++ KERNEL_SIZE := 4096k ++ UBINIZE_OPTS := -E 5 ++ IMAGE_SIZE := 32768k ++ IMAGES += kernel.bin rootfs.bin factory.bin ++ IMAGE/kernel.bin := append-kernel | check-size $$$$(KERNEL_SIZE) ++ IMAGE/rootfs.bin := append-ubi | check-size $$$$(IMAGE_SIZE) ++ IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata ++ IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | \ ++ check-size ++ SUPPORTED_DEVICES += r33 ++endef ++TARGET_DEVICES += hiwifi_r33 +diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds +index 36e3045a38a82..5e221159eb80a 100644 +--- a/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds ++++ b/target/linux/ramips/mt7620/base-files/etc/board.d/01_leds +@@ -126,6 +126,9 @@ hiwifi,hc5761) + hiwifi,hc5861) + ucidef_set_led_switch "internet" "internet" "blue:internet" "switch0" "0x20" + ;; ++hiwifi,r33) ++ ucidef_set_led_netdev "internet" "internet" "blue:internet" "eth0.2" "link tx rx" ++ ;; + hnet,c108) + ucidef_set_led_netdev "lan" "lan" "green:lan" "eth0" + ucidef_set_led_netdev "modem" "modem" "green:modem" "wwan0" +diff --git a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +index 424e3709969a1..cbba6c2029366 100644 +--- a/target/linux/ramips/mt7620/base-files/etc/board.d/02_network ++++ b/target/linux/ramips/mt7620/base-files/etc/board.d/02_network +@@ -175,6 +175,13 @@ ramips_setup_interfaces() + ucidef_add_switch "switch0" \ + "0:lan" "1:lan" "5:wan" "6@eth0" + ;; ++ hiwifi,r33) ++ ucidef_add_switch "switch0" \ ++ "1:lan" "2:lan" "3:lan" "4:lan" "0:wan" "6@eth0" ++ ucidef_add_switch_attr "switch0" "enable" "false" ++ ucidef_add_switch "switch1" \ ++ "1:lan" "2:lan" "0:wan" "6@eth0" ++ ;; + iodata,wn-ac1167gr|\ + iodata,wn-ac733gr3|\ + iptime,a1004ns) +@@ -350,6 +357,12 @@ ramips_setup_macs() + [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address) + wan_mac=$(macaddr_add "$lan_mac" 1) + ;; ++ hiwifi,r33) ++ lan_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ") ++ label_mac=$lan_mac ++ [ -n "$lan_mac" ] || lan_mac=$(cat /sys/class/net/eth0/address) ++ wan_mac=$(macaddr_add "$lan_mac" 1) ++ ;; + iodata,wn-ac1167gr|\ + iodata,wn-ac733gr3) + wan_mac=$(mtd_get_mac_ascii u-boot-env wanaddr) +diff --git a/target/linux/ramips/mt7620/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac b/target/linux/ramips/mt7620/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +index aa0ad99158271..c7b818a0af7c0 100644 +--- a/target/linux/ramips/mt7620/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac ++++ b/target/linux/ramips/mt7620/base-files/etc/hotplug.d/ieee80211/10_fix_wifi_mac +@@ -23,4 +23,11 @@ case "$board" in + [ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \ + macaddr_unsetbit "$label_mac" 6 > /sys${DEVPATH}/macaddress + ;; ++ hiwifi,r33) ++ label_mac=$(mtd_get_mac_ascii bdinfo "Vfac_mac ") ++ [ "$PHYNBR" = "1" ] && [ -n "$label_mac" ] && \ ++ echo -n "$label_mac" > /sys${DEVPATH}/macaddress ++ [ "$PHYNBR" = "0" ] && [ -n "$label_mac" ] && \ ++ macaddr_unsetbit "$label_mac" 6 > /sys${DEVPATH}/macaddress ++ ;; + esac +diff --git a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh +index 9f71dc918e50a..9c1aa42326e82 100755 +--- a/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh ++++ b/target/linux/ramips/mt7620/base-files/lib/upgrade/platform.sh +@@ -30,6 +30,9 @@ platform_do_upgrade() { + } + default_do_upgrade "$1" + ;; ++ hiwifi,r33) ++ nand_do_upgrade "$1" ++ ;; + *) + default_do_upgrade "$1" + ;; +diff --git a/target/linux/ramips/mt7620/config-5.10 b/target/linux/ramips/mt7620/config-5.10 +index 135c1689e164d..c2c06b9996b45 100644 +--- a/target/linux/ramips/mt7620/config-5.10 ++++ b/target/linux/ramips/mt7620/config-5.10 +@@ -32,7 +32,13 @@ CONFIG_CPU_SUPPORTS_HIGHMEM=y + CONFIG_CPU_SUPPORTS_MSA=y + CONFIG_CRYPTO_BLAKE2S=y + CONFIG_CRYPTO_LIB_BLAKE2S_GENERIC=y ++CONFIG_CRC16=y ++CONFIG_CRYPTO_DEFLATE=y ++CONFIG_CRYPTO_GF128MUL=y ++CONFIG_CRYPTO_HASH_INFO=y + CONFIG_CRYPTO_LIB_POLY1305_RSIZE=2 ++CONFIG_CRYPTO_LZO=y ++CONFIG_CRYPTO_NULL2=y + CONFIG_CRYPTO_RNG2=y + CONFIG_CSRC_R4K=y + CONFIG_DEBUG_PINCTRL=y +@@ -88,9 +94,12 @@ CONFIG_IRQ_WORK=y + # CONFIG_KERNEL_ZSTD is not set + CONFIG_LIBFDT=y + CONFIG_LOCK_DEBUGGING_SUPPORT=y ++CONFIG_LZO_COMPRESS=y ++CONFIG_LZO_DECOMPRESS=y + CONFIG_MARVELL_PHY=y + CONFIG_MDIO_BUS=y + CONFIG_MDIO_DEVICE=y ++CONFIG_MDIO_DEVRES=y + CONFIG_MEMFD_CREATE=y + CONFIG_MFD_SYSCON=y + CONFIG_MIGRATION=y +@@ -103,6 +112,7 @@ CONFIG_MIPS_CLOCK_VSYSCALL=y + # CONFIG_MIPS_CMDLINE_DTB_EXTEND is not set + # CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER is not set + CONFIG_MIPS_CMDLINE_FROM_DTB=y ++CONFIG_MIPS_EBPF_JIT=y + # CONFIG_MIPS_ELF_APPENDED_DTB is not set + CONFIG_MIPS_L1_CACHE_SHIFT=5 + CONFIG_MIPS_LD_CAN_LINK_VDSO=y +@@ -113,6 +123,7 @@ CONFIG_MODULES_USE_ELF_REL=y + # CONFIG_MT7621_WDT is not set + # CONFIG_MTD_CFI_INTELEXT is not set + CONFIG_MTD_CMDLINE_PARTS=y ++CONFIG_MTD_NAND_MT7620=y + # CONFIG_MTD_PARSER_TPLINK_SAFELOADER is not set + CONFIG_MTD_PHYSMAP=y + CONFIG_MTD_SPI_NOR=y +@@ -122,6 +133,10 @@ CONFIG_MTD_SPLIT_JIMAGE_FW=y + CONFIG_MTD_SPLIT_SEAMA_FW=y + CONFIG_MTD_SPLIT_TPLINK_FW=y + CONFIG_MTD_SPLIT_UIMAGE_FW=y ++CONFIG_MTD_UBI=y ++CONFIG_MTD_UBI_BEB_LIMIT=20 ++CONFIG_MTD_UBI_BLOCK=y ++CONFIG_MTD_UBI_WL_THRESHOLD=4096 + CONFIG_MTD_VIRT_CONCAT=y + CONFIG_NEED_DMA_MAP_STATE=y + CONFIG_NEED_PER_CPU_KM=y +@@ -165,6 +180,7 @@ CONFIG_RESET_CONTROLLER=y + CONFIG_SERIAL_8250_RT288X=y + CONFIG_SERIAL_MCTRL_GPIO=y + CONFIG_SERIAL_OF_PLATFORM=y ++CONFIG_SGL_ALLOC=y + CONFIG_SOC_MT7620=y + # CONFIG_SOC_MT7621 is not set + # CONFIG_SOC_RT288X is not set +@@ -193,6 +209,11 @@ CONFIG_TICK_CPU_ACCOUNTING=y + CONFIG_TIMER_OF=y + CONFIG_TIMER_PROBE=y + CONFIG_TINY_SRCU=y ++CONFIG_UBIFS_FS=y ++CONFIG_UBIFS_FS_ADVANCED_COMPR=y ++# CONFIG_UBIFS_FS_ZSTD is not set + CONFIG_USB_SUPPORT=y + CONFIG_USE_OF=y + CONFIG_WATCHDOG_CORE=y ++CONFIG_ZLIB_DEFLATE=y ++CONFIG_ZLIB_INFLATE=y +diff --git a/target/linux/ramips/mt7620/target.mk b/target/linux/ramips/mt7620/target.mk +index 5fc61e49cf8f3..ce992fc208b68 100644 +--- a/target/linux/ramips/mt7620/target.mk ++++ b/target/linux/ramips/mt7620/target.mk +@@ -4,7 +4,7 @@ + + SUBTARGET:=mt7620 + BOARDNAME:=MT7620 based boards +-FEATURES+=usb ramdisk ++FEATURES+=usb nand ramdisk + CPU_TYPE:=24kc + + DEFAULT_PACKAGES += kmod-rt2800-soc wpad-basic-wolfssl swconfig +diff --git a/target/linux/ramips/patches-5.10/0038-mtd-ralink-add-mt7620-nand-driver.patch b/target/linux/ramips/patches-5.10/0038-mtd-ralink-add-mt7620-nand-driver.patch +new file mode 100644 +index 0000000000000..b2d098b048319 +--- /dev/null ++++ b/target/linux/ramips/patches-5.10/0038-mtd-ralink-add-mt7620-nand-driver.patch +@@ -0,0 +1,2373 @@ ++From afb07a5b467217af1df4162c707cbe554a79130d Mon Sep 17 00:00:00 2001 ++From: Chen Minqiang ++Date: Thu, 3 Sep 2020 03:27:48 +0800 ++Subject: [PATCH] mtd ralink add mt7620-nand driver ++ ++--- ++ drivers/mtd/maps/Kconfig | 4 + ++ drivers/mtd/maps/Makefile | 1 + ++ drivers/mtd/maps/ralink_nand.c | 2095 ++++++++++++++++++++++++++++++++ ++ drivers/mtd/maps/ralink_nand.h | 240 ++++ ++ 4 files changed, 2340 insertions(+) ++ create mode 100644 drivers/mtd/maps/ralink_nand.c ++ create mode 100644 drivers/mtd/maps/ralink_nand.h ++ ++--- a/drivers/mtd/maps/Kconfig +++++ b/drivers/mtd/maps/Kconfig ++@@ -423,4 +423,8 @@ config MTD_PISMO ++ ++ When built as a module, it will be called pismo.ko ++ +++config MTD_NAND_MT7620 +++ tristate "Support for NAND on Mediatek MT7620" +++ depends on RALINK && SOC_MT7620 +++ ++ endmenu ++--- a/drivers/mtd/maps/Makefile +++++ b/drivers/mtd/maps/Makefile ++@@ -46,3 +46,4 @@ obj-$(CONFIG_MTD_INTEL_VR_NOR) += intel_ ++ obj-$(CONFIG_MTD_RBTX4939) += rbtx4939-flash.o ++ obj-$(CONFIG_MTD_VMU) += vmu-flash.o ++ obj-$(CONFIG_MTD_LANTIQ) += lantiq-flash.o +++obj-$(CONFIG_MTD_NAND_MT7620) += ralink_nand.o ++--- /dev/null +++++ b/drivers/mtd/maps/ralink_nand.c ++@@ -0,0 +1,2095 @@ +++#define DEBUG +++#include +++#undef DEBUG +++#include +++#include +++#include +++#include +++#include +++#include +++#include +++#include +++#include +++#include +++#include +++#include +++ +++#include "ralink_nand.h" +++#ifdef RANDOM_GEN_BAD_BLOCK +++#include +++#endif +++ +++#define LARGE_MTD_BOOT_PART_SIZE (CFG_BLOCKSIZE<<2) +++#define LARGE_MTD_CONFIG_PART_SIZE (CFG_BLOCKSIZE<<2) +++#define LARGE_MTD_FACTORY_PART_SIZE (CFG_BLOCKSIZE<<1) +++ +++#define BLOCK_ALIGNED(a) ((a) & (CFG_BLOCKSIZE - 1)) +++ +++#define READ_STATUS_RETRY 1000 +++ +++struct nand_ecclayout { +++ __u32 eccbytes; +++ __u32 eccpos[MTD_MAX_ECCPOS_ENTRIES_LARGE]; +++ __u32 oobavail; +++ struct nand_oobfree oobfree[MTD_MAX_OOBFREE_ENTRIES_LARGE]; +++}; +++ +++struct mtd_info *ranfc_mtd = NULL; +++ +++int skipbbt = 0; +++int ranfc_debug = 1; +++static int ranfc_bbt = 1; +++#if defined (WORKAROUND_RX_BUF_OV) +++static int ranfc_verify = 1; +++#endif +++static u32 nand_addrlen; +++ +++#if 0 +++module_param(ranfc_debug, int, 0644); +++module_param(ranfc_bbt, int, 0644); +++module_param(ranfc_verify, int, 0644); +++#endif +++ +++#if 0 +++#define ra_dbg(args...) do { if (ranfc_debug) printk(args); } while(0) +++#else +++#define ra_dbg(args...) +++#endif +++ +++#define CLEAR_INT_STATUS() ra_outl(NFC_INT_ST, ra_inl(NFC_INT_ST)) +++#define NFC_TRANS_DONE() (ra_inl(NFC_INT_ST) & INT_ST_ND_DONE) +++ +++int is_nand_page_2048 = 0; +++const unsigned int nand_size_map[2][3] = {{25, 30, 30}, {20, 27, 30}}; +++ +++static int nfc_wait_ready(int snooze_ms); +++ +++static const char * const mtk_probe_types[] = { "cmdlinepart", "ofpart", NULL }; +++ +++/** +++ * reset nand chip +++ */ +++static int nfc_chip_reset(void) +++{ +++ int status; +++ +++ //ra_dbg("%s:\n", __func__); +++ +++ // reset nand flash +++ ra_outl(NFC_CMD1, 0x0); +++ ra_outl(NFC_CMD2, 0xff); +++ ra_outl(NFC_ADDR, 0x0); +++ ra_outl(NFC_CONF, 0x0411); +++ +++ status = nfc_wait_ready(5); //erase wait 5us +++ if (status & NAND_STATUS_FAIL) { +++ printk("%s: fail \n", __func__); +++ } +++ +++ return (int)(status & NAND_STATUS_FAIL); +++} +++ +++/** +++ * clear NFC and flash chip. +++ */ +++static int nfc_all_reset(void) +++{ +++ int retry; +++ +++ ra_dbg("%s: \n", __func__); +++ +++ // reset controller +++ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x02); //clear data buffer +++ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) & ~0x02); //clear data buffer +++ +++ CLEAR_INT_STATUS(); +++ +++ retry = READ_STATUS_RETRY; +++ while ((ra_inl(NFC_INT_ST) & 0x02) != 0x02 && retry--); +++ if (retry <= 0) { +++ printk("nfc_all_reset: clean buffer fail \n"); +++ return -1; +++ } +++ +++ retry = READ_STATUS_RETRY; +++ while ((ra_inl(NFC_STATUS) & 0x1) != 0x0 && retry--) { //fixme, controller is busy ? +++ udelay(1); +++ } +++ +++ nfc_chip_reset(); +++ +++ return 0; +++} +++ +++/** NOTICE: only called by nfc_wait_ready(). +++ * @return -1, nfc can not get transction done +++ * @return 0, ok. +++ */ +++static int _nfc_read_status(char *status) +++{ +++ unsigned long cmd1, conf; +++ int int_st, nfc_st; +++ int retry; +++ +++ cmd1 = 0x70; +++ conf = 0x000101 | (1 << 20); +++ +++ //fixme, should we check nfc status? +++ CLEAR_INT_STATUS(); +++ +++ ra_outl(NFC_CMD1, cmd1); +++ ra_outl(NFC_CONF, conf); +++ +++ /* FIXME, +++ * 1. since we have no wired ready signal, directly +++ * calling this function is not gurantee to read right status under ready state. +++ * 2. the other side, we can not determine how long to become ready, this timeout retry is nonsense. +++ * 3. SUGGESTION: call nfc_read_status() from nfc_wait_ready(), +++ * that is aware about caller (in sementics) and has snooze plused nfc ND_DONE. +++ */ +++ retry = READ_STATUS_RETRY; +++ do { +++ nfc_st = ra_inl(NFC_STATUS); +++ int_st = ra_inl(NFC_INT_ST); +++ +++ ndelay(10); +++ } while (!(int_st & INT_ST_RX_BUF_RDY) && retry--); +++ +++ if (!(int_st & INT_ST_RX_BUF_RDY)) { +++ printk("nfc_read_status: NFC fail, int_st(%x), retry:%x. nfc:%x, reset nfc and flash. \n", +++ int_st, retry, nfc_st); +++ nfc_all_reset(); +++ *status = NAND_STATUS_FAIL; +++ return -1; +++ } +++ +++ *status = (char)(le32_to_cpu(ra_inl(NFC_DATA)) & 0x0ff); +++ return 0; +++} +++ +++/** +++ * @return !0, chip protect. +++ * @return 0, chip not protected. +++ */ +++static int nfc_check_wp(void) +++{ +++ /* Check the WP bit */ +++#if !defined CONFIG_NOT_SUPPORT_WP +++ return !!(ra_inl(NFC_CTRL) & 0x01); +++#else +++ char result = 0; +++ int ret; +++ +++ ret = _nfc_read_status(&result); +++ //FIXME, if ret < 0 +++ +++ return !(result & NAND_STATUS_WP); +++#endif +++} +++ +++#if !defined CONFIG_NOT_SUPPORT_RB +++/* +++ * @return !0, chip ready. +++ * @return 0, chip busy. +++ */ +++static int nfc_device_ready(void) +++{ +++ /* Check the ready */ +++ return !!(ra_inl(NFC_STATUS) & 0x04); +++} +++#endif +++ +++/** +++ * generic function to get data from flash. +++ * @return data length reading from flash. +++ */ +++static int _ra_nand_pull_data(char *buf, int len, int use_gdma) +++{ +++#ifdef RW_DATA_BY_BYTE +++ char *p = buf; +++#else +++ __u32 *p = (__u32 *)buf; +++#endif +++ int retry, int_st; +++ unsigned int ret_data; +++ int ret_size; +++ +++ // receive data by use_gdma +++ if (use_gdma) { +++ //if (_ra_nand_dma_pull((unsigned long)p, len)) { +++ if (1) { +++ printk("%s: fail \n", __func__); +++ len = -1; //return error +++ } +++ +++ return len; +++ } +++ +++ //fixme: retry count size? +++ retry = READ_STATUS_RETRY; +++ // no gdma +++ while (len > 0) { +++ int_st = ra_inl(NFC_INT_ST); +++ if (int_st & INT_ST_RX_BUF_RDY) { +++ +++ ret_data = ra_inl(NFC_DATA); +++ ra_outl(NFC_INT_ST, INT_ST_RX_BUF_RDY); +++#ifdef RW_DATA_BY_BYTE +++ ret_size = sizeof(unsigned int); +++ ret_size = min(ret_size, len); +++ len -= ret_size; +++ while (ret_size-- > 0) { +++ //nfc is little endian +++ *p++ = ret_data & 0x0ff; +++ ret_data >>= 8; +++ } +++#else +++ ret_size = min(len, 4); +++ len -= ret_size; +++ if (ret_size == 4) +++ *p++ = ret_data; +++ else { +++ __u8 *q = (__u8 *)p; +++ while (ret_size-- > 0) { +++ *q++ = ret_data & 0x0ff; +++ ret_data >>= 8; +++ } +++ p = (__u32 *)q; +++ } +++#endif +++ retry = READ_STATUS_RETRY; +++ } +++ else if (int_st & INT_ST_ND_DONE) { +++ break; +++ } +++ else { +++ udelay(1); +++ if (retry-- < 0) +++ break; +++ } +++ } +++ +++#ifdef RW_DATA_BY_BYTE +++ return (int)(p - buf); +++#else +++ return ((int)p - (int)buf); +++#endif +++} +++ +++/** +++ * generic function to put data into flash. +++ * @return data length writing into flash. +++ */ +++static int _ra_nand_push_data(char *buf, int len, int use_gdma) +++{ +++#ifdef RW_DATA_BY_BYTE +++ char *p = buf; +++#else +++ __u32 *p = (__u32 *)buf; +++#endif +++ int retry, int_st; +++ unsigned int tx_data = 0; +++ int tx_size, iter = 0; +++ +++ // receive data by use_gdma +++ if (use_gdma) { +++ //if (_ra_nand_dma_push((unsigned long)p, len)) +++ if (1) +++ len = 0; +++ printk("%s: fail \n", __func__); +++ return len; +++ } +++ +++ // no gdma +++ retry = READ_STATUS_RETRY; +++ while (len > 0) { +++ int_st = ra_inl(NFC_INT_ST); +++ if (int_st & INT_ST_TX_BUF_RDY) { +++#ifdef RW_DATA_BY_BYTE +++ tx_size = min(len, (int)sizeof(unsigned long)); +++ for (iter = 0; iter < tx_size; iter++) { +++ tx_data |= (*p++ << (8*iter)); +++ } +++#else +++ tx_size = min(len, 4); +++ if (tx_size == 4) +++ tx_data = (*p++); +++ else { +++ __u8 *q = (__u8 *)p; +++ for (iter = 0; iter < tx_size; iter++) +++ tx_data |= (*q++ << (8*iter)); +++ p = (__u32 *)q; +++ } +++#endif +++ ra_outl(NFC_INT_ST, INT_ST_TX_BUF_RDY); +++ ra_outl(NFC_DATA, tx_data); +++ len -= tx_size; +++ retry = READ_STATUS_RETRY; +++ } +++ else if (int_st & INT_ST_ND_DONE) { +++ break; +++ } +++ else { +++ udelay(1); +++ if (retry-- < 0) { +++ ra_dbg("%s p:%p buf:%p \n", __func__, p, buf); +++ break; +++ } +++ } +++ } +++ +++#ifdef RW_DATA_BY_BYTE +++ return (int)(p - buf); +++#else +++ return ((int)p - (int)buf); +++#endif +++} +++ +++static int nfc_select_chip(struct ra_nand_chip *ra, int chipnr) +++{ +++#if (CONFIG_NUMCHIPS == 1) +++ if (!(chipnr < CONFIG_NUMCHIPS)) +++ return -1; +++ return 0; +++#else +++ BUG(); +++#endif +++} +++ +++/** @return -1: chip_select fail +++ * 0 : both CE and WP==0 are OK +++ * 1 : CE OK and WP==1 +++ */ +++static int nfc_enable_chip(struct ra_nand_chip *ra, unsigned int offs, int read_only) +++{ +++ int chipnr = offs >> ra->chip_shift; +++ +++ ra_dbg("%s: offs:%x read_only:%x \n", __func__, offs, read_only); +++ +++ chipnr = nfc_select_chip(ra, chipnr); +++ if (chipnr < 0) { +++ printk("%s: chip select error, offs(%x)\n", __func__, offs); +++ return -1; +++ } +++ +++ if (!read_only) +++ return nfc_check_wp(); +++ +++ return 0; +++} +++ +++/** wait nand chip becomeing ready and return queried status. +++ * @param snooze: sleep time in ms unit before polling device ready. +++ * @return status of nand chip +++ * @return NAN_STATUS_FAIL if something unexpected. +++ */ +++static int nfc_wait_ready(int snooze_ms) +++{ +++ int retry; +++ char status; +++ +++ // wait nfc idle, +++ if (snooze_ms == 0) +++ snooze_ms = 1; +++ else +++ schedule_timeout(snooze_ms * HZ / 1000); +++ +++ snooze_ms = retry = snooze_ms *1000000 / 100 ; // ndelay(100) +++ +++ while (!NFC_TRANS_DONE() && retry--) { +++ if (!cond_resched()) +++ ndelay(100); +++ } +++ +++ if (!NFC_TRANS_DONE()) { +++ printk("nfc_wait_ready: no transaction done \n"); +++ return NAND_STATUS_FAIL; +++ } +++ +++#if !defined (CONFIG_NOT_SUPPORT_RB) +++ //fixme +++ while(!(status = nfc_device_ready()) && retry--) { +++ ndelay(100); +++ } +++ +++ if (status == 0) { +++ printk("nfc_wait_ready: no device ready. \n"); +++ return NAND_STATUS_FAIL; +++ } +++ +++ _nfc_read_status(&status); +++ return status; +++#else +++ +++ while(retry--) { +++ _nfc_read_status(&status); +++ if (status & NAND_STATUS_READY) +++ break; +++ ndelay(100); +++ } +++ if (retry<0) +++ printk("nfc_wait_ready 2: no device ready, status(%x). \n", status); +++ +++ return status; +++#endif +++} +++ +++/** +++ * return 0: erase OK +++ * return -EIO: fail +++ */ +++int nfc_erase_block(struct ra_nand_chip *ra, int row_addr) +++{ +++ unsigned long cmd1, cmd2, bus_addr, conf; +++ char status; +++ +++ cmd1 = 0x60; +++ cmd2 = 0xd0; +++ bus_addr = row_addr; +++ conf = 0x00511 | ((CFG_ROW_ADDR_CYCLE)<<16); +++ +++ // set NFC +++ ra_dbg("%s: cmd1: %lx, cmd2:%lx bus_addr: %lx, conf: %lx \n", +++ __func__, cmd1, cmd2, bus_addr, conf); +++ +++ //fixme, should we check nfc status? +++ CLEAR_INT_STATUS(); +++ +++ ra_outl(NFC_CMD1, cmd1); +++ ra_outl(NFC_CMD2, cmd2); +++ ra_outl(NFC_ADDR, bus_addr); +++ ra_outl(NFC_CONF, conf); +++ +++ status = nfc_wait_ready(3); //erase wait 3ms +++ if (status & NAND_STATUS_FAIL) { +++ printk("%s: fail \n", __func__); +++ return -EIO; +++ } +++ +++ return 0; +++} +++ +++static inline int _nfc_read_raw_data(int cmd1, int cmd2, int bus_addr, int bus_addr2, int conf, char *buf, int len, int flags) +++{ +++ int ret; +++ +++ CLEAR_INT_STATUS(); +++ ra_outl(NFC_CMD1, cmd1); +++ ra_outl(NFC_CMD2, cmd2); +++ ra_outl(NFC_ADDR, bus_addr); +++#if defined (CONFIG_SOC_MT7620) +++ ra_outl(NFC_ADDR2, bus_addr2); +++#endif +++ ra_outl(NFC_CONF, conf); +++ +++ ret = _ra_nand_pull_data(buf, len, 0); +++ if (ret != len) { +++ ra_dbg("%s: ret:%x (%x) \n", __func__, ret, len); +++ return NAND_STATUS_FAIL; +++ } +++ +++ //FIXME, this section is not necessary +++ ret = nfc_wait_ready(0); //wait ready +++ /* to prevent the DATA FIFO 's old data from next operation */ +++ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x02); //clear data buffer +++ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) & ~0x02); //clear data buffer +++ +++ if (ret & NAND_STATUS_FAIL) { +++ printk("%s: fail \n", __func__); +++ return NAND_STATUS_FAIL; +++ } +++ +++ return 0; +++} +++ +++static inline int _nfc_write_raw_data(int cmd1, int cmd3, int bus_addr, int bus_addr2, int conf, char *buf, int len, int flags) +++{ +++ int ret; +++ +++ CLEAR_INT_STATUS(); +++ ra_outl(NFC_CMD1, cmd1); +++ ra_outl(NFC_CMD3, cmd3); +++ ra_outl(NFC_ADDR, bus_addr); +++#if defined (CONFIG_SOC_MT7620) +++ ra_outl(NFC_ADDR2, bus_addr2); +++#endif +++ ra_outl(NFC_CONF, conf); +++ +++ ret = _ra_nand_push_data(buf, len, 0); +++ if (ret != len) { +++ ra_dbg("%s: ret:%x (%x) \n", __func__, ret, len); +++ return NAND_STATUS_FAIL; +++ } +++ +++ ret = nfc_wait_ready(1); //write wait 1ms +++ /* to prevent the DATA FIFO 's old data from next operation */ +++ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x02); //clear data buffer +++ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) & ~0x02); //clear data buffer +++ +++ if (ret & NAND_STATUS_FAIL) { +++ printk("%s: fail \n", __func__); +++ return NAND_STATUS_FAIL; +++ } +++ +++ return 0; +++} +++ +++/** +++ * @return !0: fail +++ * @return 0: OK +++ */ +++int nfc_read_oob(struct ra_nand_chip *ra, int page, unsigned int offs, char *buf, int len, int flags) +++{ +++ unsigned int cmd1 = 0, cmd2 = 0, conf = 0; +++ unsigned int bus_addr = 0, bus_addr2 = 0; +++ unsigned int ecc_en; +++ int use_gdma; +++ int status; +++ +++ int pages_perblock = 1<<(ra->erase_shift - ra->page_shift); +++ // constrain of nfc read function +++ +++#if defined (WORKAROUND_RX_BUF_OV) +++ BUG_ON (len > 60); //problem of rx-buffer overrun +++#endif +++ BUG_ON (offs >> ra->oob_shift); //page boundry +++ BUG_ON ((unsigned int)(((offs + len) >> ra->oob_shift) + page) > +++ ((page + pages_perblock) & ~(pages_perblock-1))); //block boundry +++ +++ use_gdma = flags & FLAG_USE_GDMA; +++ ecc_en = flags & FLAG_ECC_EN; +++ bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)) | (offs & ((1<> (CFG_COLUMN_ADDR_CYCLE*8); +++ cmd1 = 0x0; +++ cmd2 = 0x30; +++ conf = 0x000511| ((CFG_ADDR_CYCLE)<<16) | (len << 20); +++ } +++ else { +++ cmd1 = 0x50; +++ conf = 0x000141| ((CFG_ADDR_CYCLE)<<16) | (len << 20); +++ } +++ if (ecc_en) +++ conf |= (1<<3); +++ if (use_gdma) +++ conf |= (1<<2); +++ +++ ra_dbg("%s: cmd1:%x, bus_addr:%x, conf:%x, len:%x, flag:%x\n", +++ __func__, cmd1, bus_addr, conf, len, flags); +++ +++ status = _nfc_read_raw_data(cmd1, cmd2, bus_addr, bus_addr2, conf, buf, len, flags); +++ if (status & NAND_STATUS_FAIL) { +++ printk("%s: fail\n", __func__); +++ return -EIO; +++ } +++ +++ return 0; +++} +++ +++/** +++ * @return !0: fail +++ * @return 0: OK +++ */ +++int nfc_write_oob(struct ra_nand_chip *ra, int page, unsigned int offs, char *buf, int len, int flags) +++{ +++ unsigned int cmd1 = 0, cmd3=0, conf = 0; +++ unsigned int bus_addr = 0, bus_addr2 = 0; +++ int use_gdma; +++ int status; +++ +++ int pages_perblock = 1<<(ra->erase_shift - ra->page_shift); +++ // constrain of nfc read function +++ +++ BUG_ON (offs >> ra->oob_shift); //page boundry +++ BUG_ON ((unsigned int)(((offs + len) >> ra->oob_shift) + page) > +++ ((page + pages_perblock) & ~(pages_perblock-1))); //block boundry +++ +++ use_gdma = flags & FLAG_USE_GDMA; +++ bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)) | (offs & ((1<> (CFG_COLUMN_ADDR_CYCLE*8); +++ conf = 0x001123 | ((CFG_ADDR_CYCLE)<<16) | ((len) << 20); +++ } +++ else { +++ cmd1 = 0x08050; +++ cmd3 = 0x10; +++ conf = 0x001223 | ((CFG_ADDR_CYCLE)<<16) | ((len) << 20); +++ } +++ if (use_gdma) +++ conf |= (1<<2); +++ +++ // set NFC +++ ra_dbg("%s: cmd1: %x, cmd3: %x bus_addr: %x, conf: %x, len:%x\n", +++ __func__, cmd1, cmd3, bus_addr, conf, len); +++ +++ status = _nfc_write_raw_data(cmd1, cmd3, bus_addr, bus_addr2, conf, buf, len, flags); +++ if (status & NAND_STATUS_FAIL) { +++ printk("%s: fail \n", __func__); +++ return -EIO; +++ } +++ +++ return 0; +++} +++ +++ +++int nfc_read_page(struct ra_nand_chip *ra, char *buf, int page, int flags); +++int nfc_write_page(struct ra_nand_chip *ra, char *buf, int page, int flags); +++ +++ +++#if !defined (WORKAROUND_RX_BUF_OV) +++static int one_bit_correction(char *ecc, char *expected, int *bytes, int *bits); +++int nfc_ecc_verify(struct ra_nand_chip *ra, char *buf, int page, int mode) +++{ +++ int ret, i; +++ char *p, *e; +++ int ecc; +++ +++ //ra_dbg("%s, page:%x mode:%d\n", __func__, page, mode); +++ +++ if (mode == FL_WRITING) { +++ int len = CFG_PAGESIZE + CFG_PAGE_OOBSIZE; +++ int conf = 0x000141| ((CFG_ADDR_CYCLE)<<16) | (len << 20); +++ conf |= (1<<3); //(ecc_en) +++ //conf |= (1<<2); // (use_gdma) +++ +++ p = ra->readback_buffers; +++ ret = nfc_read_page(ra, ra->readback_buffers, page, FLAG_ECC_EN); +++ if (ret == 0) +++ goto ecc_check; +++ +++ //FIXME, double comfirm +++ printk("%s: read back fail, try again \n",__func__); +++ ret = nfc_read_page(ra, ra->readback_buffers, page, FLAG_ECC_EN); +++ if (ret != 0) { +++ printk("\t%s: read back fail agian \n",__func__); +++ goto bad_block; +++ } +++ } +++ else if (mode == FL_READING) { +++ p = buf; +++ } +++ else +++ return -2; +++ +++ecc_check: +++ p += CFG_PAGESIZE; +++ if (!is_nand_page_2048) { +++ ecc = ra_inl(NFC_ECC); +++ if (ecc == 0) //clean page. +++ return 0; +++ e = (char*)&ecc; +++ for (i=0; ireadback_buffers, page, FLAG_NONE); +++ if (ret != 0) //double comfirm +++ ret = nfc_read_page(ra, ra->readback_buffers, page, FLAG_NONE); +++ +++ if (ret != 0) { +++ printk("%s: mode:%x read back fail \n", __func__, mode); +++ return -1; +++ } +++ return memcmp(buf, ra->readback_buffers, 1<page_shift); +++ } +++ +++ if (mode == FL_READING) { +++#if 0 +++ if (ra->sandbox_page == 0) +++ return 0; +++ +++ ret = nfc_write_page(ra, buf, ra->sandbox_page, FLAG_USE_GDMA | FLAG_ECC_EN); +++ if (ret != 0) { +++ printk("%s, fail write sandbox_page \n", __func__); +++ return -1; +++ } +++#else +++ /** @note: +++ * The following command is actually not 'write' command to drive NFC to write flash. +++ * However, it can make NFC to calculate ECC, that will be used to compare with original ones. +++ * --YT +++ */ +++ unsigned int conf = 0x001223| (CFG_ADDR_CYCLE<<16) | (0x200 << 20) | (1<<3) | (1<<2); +++ _nfc_write_raw_data(0xff, 0xff, ra->sandbox_page<page_shift, conf, buf, 0x200, FLAG_USE_GDMA); +++#endif +++ +++ ecc = ra_inl(NFC_ECC); +++ if (ecc == 0) //clean page. +++ return 0; +++ e = (char*)&ecc; +++ p = buf + (1<page_shift); +++ for (i=0; i 0) { +++ int len; +++#if defined (WORKAROUND_RX_BUF_OV) +++ len = min(60, size); +++#else +++ len = size; +++#endif +++ bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)) | (offs & ((1<> (CFG_COLUMN_ADDR_CYCLE*8); +++ cmd1 = 0x0; +++ cmd2 = 0x30; +++ conf = 0x000511| ((CFG_ADDR_CYCLE)<<16) | (len << 20); +++ } +++ else { +++ if (offs & ~(CFG_PAGESIZE-1)) +++ cmd1 = 0x50; +++ else if (offs & ~((1<buffers_page = -1; //cached +++ } +++ +++ return 0; +++} +++ +++ +++/** +++ * @return -EIO, fail to write +++ * @return 0, OK +++ */ +++int nfc_write_page(struct ra_nand_chip *ra, char *buf, int page, int flags) +++{ +++ unsigned int cmd1 = 0, cmd3, conf = 0; +++ unsigned int bus_addr = 0, bus_addr2 = 0; +++ unsigned int ecc_en; +++ int use_gdma; +++ int size; +++ char status; +++ uint8_t *oob = buf + (1<page_shift); +++ +++ use_gdma = flags & FLAG_USE_GDMA; +++ ecc_en = flags & FLAG_ECC_EN; +++ +++ oob[ra->badblockpos] = 0xff; //tag as good block. +++ ra->buffers_page = -1; //cached +++ +++ page = page & (CFG_CHIPSIZE-1); //chip boundary +++ size = CFG_PAGESIZE + CFG_PAGE_OOBSIZE; //add oobsize +++ bus_addr = (page << (CFG_COLUMN_ADDR_CYCLE*8)); //write_page always write from offset 0. +++ +++ if (is_nand_page_2048) { +++ bus_addr2 = page >> (CFG_COLUMN_ADDR_CYCLE*8); +++ cmd1 = 0x80; +++ cmd3 = 0x10; +++ conf = 0x001123| ((CFG_ADDR_CYCLE)<<16) | (size << 20); +++ } +++ else { +++ cmd1 = 0x8000; +++ cmd3 = 0x10; +++ conf = 0x001223| ((CFG_ADDR_CYCLE)<<16) | (size << 20); +++ } +++ if (ecc_en) +++ conf |= (1<<3); //enable ecc +++ if (use_gdma) +++ conf |= (1<<2); +++ +++ // set NFC +++ ra_dbg("nfc_write_page: cmd1: %x, cmd3: %x bus_addr: %x, conf: %x, len:%x\n", +++ cmd1, cmd3, bus_addr, conf, size); +++ +++ status = _nfc_write_raw_data(cmd1, cmd3, bus_addr, bus_addr2, conf, buf, size, flags); +++ if (status & NAND_STATUS_FAIL) { +++ printk("%s: fail \n", __func__); +++ return -EIO; +++ } +++ +++ +++ if (flags & FLAG_VERIFY) { // verify and correct ecc +++ status = nfc_ecc_verify(ra, buf, page, FL_WRITING); +++ +++#ifdef RANDOM_GEN_BAD_BLOCK +++ if (((random32() & 0x1ff) == 0x0) && (page >= 0x100)) // randomly create bad block +++ { +++ printk("hmm... create a bad block at page %x\n", (bus_addr >> 16)); +++ status = -1; +++ } +++#endif +++ +++ if (status != 0) { +++ printk("%s: ecc_verify fail: ret:%x \n", __func__, status); +++ oob[ra->badblockpos] = 0x33; +++ page -= page % (CFG_BLOCKSIZE/CFG_PAGESIZE); +++ printk("create a bad block at page %x\n", page); +++ if (!is_nand_page_2048) +++ status = nfc_write_oob(ra, page, ra->badblockpos, oob+ra->badblockpos, 1, flags); +++ else +++ { +++ status = _nfc_write_raw_data(cmd1, cmd3, bus_addr, bus_addr2, conf, buf, size, flags); +++ nfc_write_oob(ra, page, 0, oob, 16, FLAG_NONE); +++ } +++ return -EBADMSG; +++ } +++ } +++ +++ ra->buffers_page = page; //cached +++ return 0; +++} +++ +++ +++ +++/************************************************************* +++ * nand internal process +++ *************************************************************/ +++ +++/** +++ * nand_release_device - [GENERIC] release chip +++ * @mtd: MTD device structure +++ * +++ * Deselect, release chip lock and wake up anyone waiting on the device +++ */ +++static void nand_release_device(struct ra_nand_chip *ra) +++{ +++ /* De-select the NAND device */ +++ nfc_select_chip(ra, -1); +++ +++ /* Release the controller and the chip */ +++ ra->state = FL_READY; +++ +++ mutex_unlock(ra->controller); +++} +++ +++/** +++ * nand_get_device - [GENERIC] Get chip for selected access +++ * @chip: the nand chip descriptor +++ * @mtd: MTD device structure +++ * @new_state: the state which is requested +++ * +++ * Get the device and lock it for exclusive access +++ */ +++static int +++nand_get_device(struct ra_nand_chip *ra, int new_state) +++{ +++ int ret = 0; +++ +++ ret = mutex_lock_interruptible(ra->controller); +++ if (!ret) +++ ra->state = new_state; +++ +++ return ret; +++} +++ +++/************************************************************* +++ * nand internal process +++ *************************************************************/ +++ +++int ra_nand_bbt_get(struct ra_nand_chip *ra, int block) +++{ +++ int byte, bits; +++ bits = block * BBTTAG_BITS; +++ +++ byte = bits / 8; +++ bits = bits % 8; +++ +++ return (ra->bbt[byte] >> bits) & BBTTAG_BITS_MASK; +++} +++ +++int ra_nand_bbt_set(struct ra_nand_chip *ra, int block, int tag) +++{ +++ int byte, bits; +++ bits = block * BBTTAG_BITS; +++ +++ byte = bits / 8; +++ bits = bits % 8; +++ +++ // If previous tag is bad, dont overwrite it +++ if (((ra->bbt[byte] >> bits) & BBTTAG_BITS_MASK) == BBT_TAG_BAD) +++ { +++ return BBT_TAG_BAD; +++ } +++ +++ ra->bbt[byte] = (ra->bbt[byte] & ~(BBTTAG_BITS_MASK << bits)) | ((tag & BBTTAG_BITS_MASK) << bits); +++ +++ return tag; +++} +++ +++/** +++ * nand_block_checkbad - [GENERIC] Check if a block is marked bad +++ * @mtd: MTD device structure +++ * @ofs: offset from device start +++ * +++ * Check, if the block is bad. Either by reading the bad block table or +++ * calling of the scan function. +++ */ +++int nand_block_checkbad(struct ra_nand_chip *ra, loff_t offs) +++{ +++ int page, block; +++ int ret = 4; +++ unsigned int tag; +++ char *str[]= {"UNK", "RES", "BAD", "GOOD"}; +++ +++ if (ranfc_bbt == 0) +++ return 0; +++ +++ { +++ // align with chip +++ +++ offs = offs & ((1<chip_shift) -1); +++ +++ page = offs >> ra->page_shift; +++ block = offs >> ra->erase_shift; +++ } +++ +++ tag = ra_nand_bbt_get(ra, block); +++ +++ if (tag == BBT_TAG_UNKNOWN) { +++ ret = nfc_read_oob(ra, page, ra->badblockpos, (char*)&tag, 1, FLAG_NONE); +++ if (ret == 0) +++ tag = ((le32_to_cpu(tag) & 0x0ff) == 0x0ff) ? BBT_TAG_GOOD : BBT_TAG_BAD; +++ else +++ tag = BBT_TAG_BAD; +++ +++ ra_nand_bbt_set(ra, block, tag); +++ } +++ +++ if (tag != BBT_TAG_GOOD) { +++ printk("%s: offs:%x tag: %s \n", __func__, (unsigned int)offs, str[tag]); +++ return 1; +++ } +++ else +++ return 0; +++} +++ +++/** +++ * nand_block_markbad - +++ */ +++int nand_block_markbad(struct ra_nand_chip *ra, loff_t offs) +++{ +++ int page, block; +++ int ret = 4; +++ unsigned int tag; +++ char *ecc; +++ +++ // align with chip +++ ra_dbg("%s offs: %x \n", __func__, (int)offs); +++ +++ offs = offs & ((1<chip_shift) -1); +++ +++ page = offs >> ra->page_shift; +++ block = offs >> ra->erase_shift; +++ +++ tag = ra_nand_bbt_get(ra, block); +++ +++ if (tag == BBT_TAG_BAD) { +++ printk("%s: mark repeatedly \n", __func__); +++ return 0; +++ } +++ +++ // new tag as bad +++ tag =BBT_TAG_BAD; +++ ret = nfc_read_page(ra, ra->buffers, page, FLAG_NONE); +++ if (ret != 0) { +++ printk("%s: fail to read bad block tag \n", __func__); +++ goto tag_bbt; +++ } +++ +++ ecc = &ra->buffers[(1<page_shift)+ra->badblockpos]; +++ if (*ecc == (char)0x0ff) { +++ //tag into flash +++ *ecc = (char)tag; +++ ret = nfc_write_page(ra, ra->buffers, page, FLAG_USE_GDMA); +++ if (ret) +++ printk("%s: fail to write bad block tag \n", __func__); +++ } +++ +++tag_bbt: +++ //update bbt +++ ra_nand_bbt_set(ra, block, tag); +++ +++ return 0; +++} +++ +++#if defined (WORKAROUND_RX_BUF_OV) +++/** +++ * to find a bad block for ecc verify of read_page +++ */ +++unsigned int nand_bbt_find_sandbox(struct ra_nand_chip *ra) +++{ +++ loff_t offs = 0; +++ int chipsize = 1 << ra->chip_shift; +++ int blocksize = 1 << ra->erase_shift; +++ +++ +++ while (offs < chipsize) { +++ if (nand_block_checkbad(ra, offs)) //scan and verify the unknown tag +++ break; +++ offs += blocksize; +++ } +++ +++ if (offs >= chipsize) { +++ offs = chipsize - blocksize; +++ } +++ +++ ra_nand_bbt_set(ra, (unsigned int)offs>>ra->erase_shift, BBT_TAG_RES); // tag bbt only, instead of update badblockpos of flash. +++ return (offs >> ra->page_shift); +++} +++#endif +++ +++/** +++ * nand_erase_nand - [Internal] erase block(s) +++ * @mtd: MTD device structure +++ * @instr: erase instruction +++ * @allowbbt: allow erasing the bbt area +++ * +++ * Erase one ore more blocks +++ */ +++static int _nand_erase_nand(struct ra_nand_chip *ra, struct erase_info *instr) +++{ +++ int page, len, status, ret, state; +++ unsigned int addr, blocksize = 1<erase_shift; +++ +++ ra_dbg("%s: start:%x, len:%x \n", __func__, +++ (unsigned int)instr->addr, (unsigned int)instr->len); +++ +++//#define BLOCK_ALIGNED(a) ((a) & (blocksize - 1)) // already defined +++ +++ if (BLOCK_ALIGNED(instr->addr) || BLOCK_ALIGNED(instr->len)) { +++ ra_dbg("%s: erase block not aligned, addr:%x len:%x\n", __func__, instr->addr, instr->len); +++ return -EINVAL; +++ } +++ +++ instr->fail_addr = 0xffffffff; +++ +++ len = instr->len; +++ addr = instr->addr; +++ state = MTD_ERASING; +++ +++ while (len) { +++ +++ page = (int)(addr >> ra->page_shift); +++ +++ /* select device and check wp */ +++ if (nfc_enable_chip(ra, addr, 0)) { +++ printk("%s: nand is write protected \n", __func__); +++ state = MTD_ERASE_FAILED; +++ goto erase_exit; +++ } +++ +++ /* if we have a bad block, we do not erase bad blocks */ +++ if (nand_block_checkbad(ra, addr)) { +++ printk(KERN_WARNING "nand_erase: attempt to erase a " +++ "bad block at 0x%08x\n", addr); +++ state = MTD_ERASE_FAILED; +++ goto erase_exit; +++ } +++ +++ /* +++ * Invalidate the page cache, if we erase the block which +++ * contains the current cached page +++ */ +++ if (BLOCK_ALIGNED(addr) == BLOCK_ALIGNED(ra->buffers_page << ra->page_shift)) +++ ra->buffers_page = -1; +++ +++ status = nfc_erase_block(ra, page); +++ /* See if block erase succeeded */ +++ if (status) { +++ printk("%s: failed erase, page 0x%08x\n", __func__, page); +++ state = MTD_ERASE_FAILED; +++ instr->fail_addr = (page << ra->page_shift); +++ goto erase_exit; +++ } +++ +++ /* Increment page address and decrement length */ +++ len -= blocksize; +++ addr += blocksize; +++ +++ } +++ state = MTD_ERASE_DONE; +++ +++erase_exit: +++ +++ ret = ((state == MTD_ERASE_DONE) ? 0 : -EIO); +++ +++ if (ret) { +++ ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_BAD); +++ } +++ +++ /* Return more or less happy */ +++ return ret; +++} +++ +++static int +++nand_write_oob_buf(struct ra_nand_chip *ra, uint8_t *buf, uint8_t *oob, size_t size, +++ int mode, int ooboffs) +++{ +++ size_t oobsize = 1<oob_shift; +++ struct nand_oobfree *free; +++ uint32_t woffs = ooboffs; +++ int retsize = 0; +++ +++ ra_dbg("%s: size:%x, mode:%x, offs:%x \n", __func__, size, mode, ooboffs); +++ +++ switch(mode) { +++ case MTD_OPS_PLACE_OOB: +++ case MTD_OPS_RAW: +++ if (ooboffs > oobsize) +++ return -1; +++ +++ size = min(size, oobsize - ooboffs); +++ memcpy(buf + ooboffs, oob, size); +++ retsize = size; +++ break; +++ +++ case MTD_OPS_AUTO_OOB: +++ if (ooboffs > ra->oob->oobavail) +++ return -1; +++ +++ while (size) { +++ for(free = ra->oob->oobfree; free->length && size; free++) { +++ int wlen = free->length - woffs; +++ int bytes = 0; +++ +++ /* Write request not from offset 0 ? */ +++ if (wlen <= 0) { +++ woffs = -wlen; +++ continue; +++ } +++ +++ bytes = min_t(size_t, size, wlen); +++ memcpy (buf + free->offset + woffs, oob, bytes); +++ woffs = 0; +++ oob += bytes; +++ size -= bytes; +++ retsize += bytes; +++ } +++ buf += oobsize; +++ } +++ break; +++ +++ default: +++ BUG(); +++ } +++ +++ return retsize; +++} +++ +++static int nand_read_oob_buf(struct ra_nand_chip *ra, uint8_t *oob, size_t size, +++ int mode, int ooboffs) +++{ +++ size_t oobsize = 1<oob_shift; +++ uint8_t *buf = ra->buffers + (1<page_shift); +++ int retsize=0; +++ +++ ra_dbg("%s: size:%x, mode:%x, offs:%x \n", __func__, size, mode, ooboffs); +++ +++ switch(mode) { +++ case MTD_OPS_PLACE_OOB: +++ case MTD_OPS_RAW: +++ if (ooboffs > oobsize) +++ return -1; +++ +++ size = min(size, oobsize - ooboffs); +++ memcpy(oob, buf + ooboffs, size); +++ return size; +++ +++ case MTD_OPS_AUTO_OOB: { +++ struct nand_oobfree *free; +++ uint32_t woffs = ooboffs; +++ +++ if (ooboffs > ra->oob->oobavail) +++ return -1; +++ +++ size = min(size, ra->oob->oobavail - ooboffs); +++ for(free = ra->oob->oobfree; free->length && size; free++) { +++ int wlen = free->length - woffs; +++ int bytes = 0; +++ +++ /* Write request not from offset 0 ? */ +++ if (wlen <= 0) { +++ woffs = -wlen; +++ continue; +++ } +++ +++ bytes = min_t(size_t, size, wlen); +++ memcpy (oob, buf + free->offset + woffs, bytes); +++ woffs = 0; +++ oob += bytes; +++ size -= bytes; +++ retsize += bytes; +++ } +++ return retsize; +++ } +++ default: +++ BUG(); +++ } +++ +++ return -1; +++} +++ +++/** +++ * nand_do_write_ops - [Internal] NAND write with ECC +++ * @mtd: MTD device structure +++ * @to: offset to write to +++ * @ops: oob operations description structure +++ * +++ * NAND write with ECC +++ */ +++static int nand_do_write_ops(struct ra_nand_chip *ra, loff_t to, +++ struct mtd_oob_ops *ops) +++{ +++ int page; +++ uint32_t datalen = ops->len; +++ uint32_t ooblen = ops->ooblen; +++ uint8_t *oob = ops->oobbuf; +++ uint8_t *data = ops->datbuf; +++ int pagesize = (1<page_shift); +++ int pagemask = (pagesize -1); +++ int oobsize = 1<oob_shift; +++ loff_t addr = to; +++ //int i = 0; //for ra_dbg only +++ +++ ra_dbg("%s: to:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x oobmode:%x \n", +++ __func__, (unsigned int)to, data, oob, datalen, ooblen, ops->ooboffs, ops->mode); +++ +++ ops->retlen = 0; +++ ops->oobretlen = 0; +++ +++ +++ /* Invalidate the page cache, when we write to the cached page */ +++ ra->buffers_page = -1; +++ +++ +++ if (data ==0) +++ datalen = 0; +++ +++ // oob sequential (burst) write +++ if (datalen == 0 && ooblen) { +++ int len = ((ooblen + ops->ooboffs) + (ra->oob->oobavail - 1)) / ra->oob->oobavail * oobsize; +++ +++ /* select chip, and check if it is write protected */ +++ if (nfc_enable_chip(ra, addr, 0)) +++ return -EIO; +++ +++ //FIXME, need sanity check of block boundary +++ page = (int)((to & ((1<chip_shift)-1)) >> ra->page_shift); //chip boundary +++ memset(ra->buffers, 0x0ff, pagesize); +++ //fixme, should we reserve the original content? +++ if (ops->mode == MTD_OPS_AUTO_OOB) { +++ nfc_read_oob(ra, page, 0, ra->buffers, len, FLAG_NONE); +++ } +++ //prepare buffers +++ if (ooblen != 8) +++ { +++ nand_write_oob_buf(ra, ra->buffers, oob, ooblen, ops->mode, ops->ooboffs); +++ // write out buffer to chip +++ nfc_write_oob(ra, page, 0, ra->buffers, len, FLAG_USE_GDMA); +++ } +++ +++ ops->oobretlen = ooblen; +++ ooblen = 0; +++ } +++ +++ // data sequential (burst) write +++ if (datalen && ooblen == 0) { +++ // ranfc can not support write_data_burst, since hw-ecc and fifo constraints.. +++ } +++ +++ // page write +++ while(datalen || ooblen) { +++ int len; +++ int ret; +++ int offs; +++ int ecc_en = 0; +++ +++ ra_dbg("%s (%d): addr:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x \n", +++ __func__, i++, (unsigned int)addr, data, oob, datalen, ooblen, ops->ooboffs); +++ +++ page = (int)((addr & ((1<chip_shift)-1)) >> ra->page_shift); //chip boundary +++ +++ /* select chip, and check if it is write protected */ +++ if (nfc_enable_chip(ra, addr, 0)) +++ return -EIO; +++ +++ // oob write +++ if (ops->mode == MTD_OPS_AUTO_OOB) { +++ //fixme, this path is not yet varified +++ nfc_read_oob(ra, page, 0, ra->buffers + pagesize, oobsize, FLAG_NONE); +++ } +++ if (oob && ooblen > 0) { +++ len = nand_write_oob_buf(ra, ra->buffers + pagesize, oob, ooblen, ops->mode, ops->ooboffs); +++ if (len < 0) +++ return -EINVAL; +++ +++ oob += len; +++ ops->oobretlen += len; +++ ooblen -= len; +++ } +++ +++ // data write +++ offs = addr & pagemask; +++ len = min_t(size_t, datalen, pagesize - offs); +++ if (data && len > 0) { +++ memcpy(ra->buffers + offs, data, len); // we can not sure ops->buf wether is DMA-able. +++ +++ data += len; +++ datalen -= len; +++ ops->retlen += len; +++ +++ ecc_en = FLAG_ECC_EN; +++ } +++ ret = nfc_write_page(ra, ra->buffers, page, FLAG_USE_GDMA | FLAG_VERIFY | +++ ((ops->mode == MTD_OPS_RAW || ops->mode == MTD_OPS_PLACE_OOB) ? 0 : ecc_en )); +++ if (ret) { +++ ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_BAD); +++ return ret; +++ } +++ +++ ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_GOOD); +++ +++ addr = (page+1) << ra->page_shift; +++ +++ } +++ return 0; +++} +++ +++/** +++ * nand_do_read_ops - [Internal] Read data with ECC +++ * +++ * @mtd: MTD device structure +++ * @from: offset to read from +++ * @ops: oob ops structure +++ * +++ * Internal function. Called with chip held. +++ */ +++static int nand_do_read_ops(struct ra_nand_chip *ra, loff_t from, +++ struct mtd_oob_ops *ops) +++{ +++ int page; +++ uint32_t datalen = ops->len; +++ uint32_t ooblen = ops->ooblen; +++ uint8_t *oob = ops->oobbuf; +++ uint8_t *data = ops->datbuf; +++ int pagesize = (1<page_shift); +++ int pagemask = (pagesize -1); +++ loff_t addr = from; +++ //int i = 0; //for ra_dbg only +++ +++ ra_dbg("%s: addr:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x \n", +++ __func__, (unsigned int)addr, data, oob, datalen, ooblen, ops->ooboffs); +++ +++ ops->retlen = 0; +++ ops->oobretlen = 0; +++ if (data == 0) +++ datalen = 0; +++ +++ +++ while(datalen || ooblen) { +++ int len; +++ int ret; +++ int offs; +++ +++ ra_dbg("%s (%d): addr:%x, ops data:%p, oob:%p datalen:%x ooblen:%x, ooboffs:%x \n", +++ __func__, i++, (unsigned int)addr, data, oob, datalen, ooblen, ops->ooboffs); +++ /* select chip */ +++ if (nfc_enable_chip(ra, addr, 1) < 0) +++ return -EIO; +++ +++ page = (int)((addr & ((1<chip_shift)-1)) >> ra->page_shift); +++ +++ ret = nfc_read_page(ra, ra->buffers, page, FLAG_VERIFY | +++ ((ops->mode == MTD_OPS_RAW || ops->mode == MTD_OPS_PLACE_OOB) ? 0: FLAG_ECC_EN )); +++ //FIXME, something strange here, some page needs 2 more tries to guarantee read success. +++ if (ret) { +++ printk("read again:\n"); +++ ret = nfc_read_page(ra, ra->buffers, page, FLAG_VERIFY | +++ ((ops->mode == MTD_OPS_RAW || ops->mode == MTD_OPS_PLACE_OOB) ? 0: FLAG_ECC_EN )); +++ +++ if (ret) { +++ printk("read again fail \n"); +++ ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_BAD); +++ if ((ret != -EUCLEAN) && (ret != -EBADMSG)) { +++ return ret; +++ } +++ else { +++ /* ecc verification fail, but data need to be returned. */ +++ } +++ } +++ else { +++ printk(" read agian susccess \n"); +++ } +++ } +++ +++ // oob read +++ if (oob && ooblen > 0) { +++ len = nand_read_oob_buf(ra, oob, ooblen, ops->mode, ops->ooboffs); +++ if (len < 0) { +++ printk("nand_read_oob_buf: fail return %x \n", len); +++ return -EINVAL; +++ } +++ +++ oob += len; +++ ops->oobretlen += len; +++ ooblen -= len; +++ } +++ +++ // data read +++ offs = addr & pagemask; +++ len = min_t(size_t, datalen, pagesize - offs); +++ if (data && len > 0) { +++ memcpy(data, ra->buffers + offs, len); // we can not sure ops->buf wether is DMA-able. +++ +++ data += len; +++ datalen -= len; +++ ops->retlen += len; +++ if (ret) +++ return ret; +++ } +++ +++ +++ ra_nand_bbt_set(ra, addr >> ra->erase_shift, BBT_TAG_GOOD); +++ // address go further to next page, instead of increasing of length of write. This avoids some special cases wrong. +++ addr = (page+1) << ra->page_shift; +++ } +++ return 0; +++} +++ +++static int +++ramtd_nand_erase(struct mtd_info *mtd, struct erase_info *instr) +++{ +++ struct ra_nand_chip *ra = (struct ra_nand_chip *)mtd->priv; +++ int ret; +++ +++ ra_dbg("%s: start:%x, len:%x \n", __func__, +++ (unsigned int)instr->addr, (unsigned int)instr->len); +++ +++ nand_get_device(ra, FL_ERASING); +++ ret = _nand_erase_nand((struct ra_nand_chip *)mtd->priv, instr); +++ nand_release_device(ra); +++ +++ return ret; +++} +++ +++static int +++ramtd_nand_write(struct mtd_info *mtd, loff_t to, size_t len, +++ size_t *retlen, const uint8_t *buf) +++{ +++ struct ra_nand_chip *ra = mtd->priv; +++ struct mtd_oob_ops ops; +++ int ret; +++ +++ ra_dbg("%s: to 0x%x len=0x%x\n", __func__, to, len); +++ +++ if ((to + len) > mtd->size) +++ return -EINVAL; +++ +++ if (!len) +++ return 0; +++ +++ nand_get_device(ra, FL_WRITING); +++ +++ memset(&ops, 0, sizeof(ops)); +++ ops.len = len; +++ ops.datbuf = (uint8_t *)buf; +++ ops.oobbuf = NULL; +++ ops.mode = MTD_OPS_AUTO_OOB; +++ +++ ret = nand_do_write_ops(ra, to, &ops); +++ +++ *retlen = ops.retlen; +++ +++ nand_release_device(ra); +++ +++ return ret; +++} +++ +++static int +++ramtd_nand_read(struct mtd_info *mtd, loff_t from, size_t len, +++ size_t *retlen, uint8_t *buf) +++{ +++ struct ra_nand_chip *ra = mtd->priv; +++ int ret; +++ struct mtd_oob_ops ops; +++ +++ ra_dbg("%s: mtd:%p from:%x, len:%x, buf:%p \n", __func__, mtd, (unsigned int)from, len, buf); +++ +++ /* Do not allow reads past end of device */ +++ if ((from + len) > mtd->size) +++ return -EINVAL; +++ if (!len) +++ return 0; +++ +++ nand_get_device(ra, FL_READING); +++ +++ memset(&ops, 0, sizeof(ops)); +++ ops.len = len; +++ ops.datbuf = buf; +++ ops.oobbuf = NULL; +++ ops.mode = MTD_OPS_AUTO_OOB; +++ +++ ret = nand_do_read_ops(ra, from, &ops); +++ +++ *retlen = ops.retlen; +++ +++ nand_release_device(ra); +++ +++ return ret; +++} +++ +++static int +++ramtd_nand_readoob(struct mtd_info *mtd, loff_t from, +++ struct mtd_oob_ops *ops) +++{ +++ struct ra_nand_chip *ra = mtd->priv; +++ int ret; +++ +++ ra_dbg("%s: \n", __func__); +++ +++ nand_get_device(ra, FL_READING); +++ +++ ret = nand_do_read_ops(ra, from, ops); +++ +++ nand_release_device(ra); +++ +++ return ret; +++} +++ +++static int +++ramtd_nand_writeoob(struct mtd_info *mtd, loff_t to, +++ struct mtd_oob_ops *ops) +++{ +++ struct ra_nand_chip *ra = mtd->priv; +++ int ret; +++ +++ nand_get_device(ra, FL_READING); +++ ret = nand_do_write_ops(ra, to, ops); +++ nand_release_device(ra); +++ +++ return ret; +++} +++ +++static int +++ramtd_nand_block_isbad(struct mtd_info *mtd, loff_t offs) +++{ +++ if (offs > mtd->size) +++ return -EINVAL; +++ +++ return nand_block_checkbad((struct ra_nand_chip *)mtd->priv, offs); +++} +++ +++static int +++ramtd_nand_block_markbad(struct mtd_info *mtd, loff_t ofs) +++{ +++ struct ra_nand_chip *ra = mtd->priv; +++ int ret; +++ +++ ra_dbg("%s: \n", __func__); +++ nand_get_device(ra, FL_WRITING); +++ ret = nand_block_markbad(ra, ofs); +++ nand_release_device(ra); +++ +++ return ret; +++} +++ +++// 1-bit error detection +++static int one_bit_correction(char *ecc1, char *ecc2, int *bytes, int *bits) +++{ +++ // check if ecc and expected are all valid +++ char *p, nibble, crumb; +++ int i, xor, iecc1 = 0, iecc2 = 0; +++ +++ printk("correction : %x %x %x\n", ecc1[0], ecc1[1], ecc1[2]); +++ printk("correction : %x %x %x\n", ecc2[0], ecc2[1], ecc2[2]); +++ +++ p = (char *)ecc1; +++ for (i = 0; i < CONFIG_ECC_BYTES; i++) +++ { +++ nibble = *(p+i) & 0xf; +++ if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) && +++ (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9)) +++ return -1; +++ nibble = ((*(p+i)) >> 4) & 0xf; +++ if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) && +++ (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9)) +++ return -1; +++ } +++ +++ p = (char *)ecc2; +++ for (i = 0; i < CONFIG_ECC_BYTES; i++) +++ { +++ nibble = *(p+i) & 0xf; +++ if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) && +++ (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9)) +++ return -1; +++ nibble = ((*(p+i)) >> 4) & 0xf; +++ if ((nibble != 0x0) && (nibble != 0xf) && (nibble != 0x3) && (nibble != 0xc) && +++ (nibble != 0x5) && (nibble != 0xa) && (nibble != 0x6) && (nibble != 0x9)) +++ return -1; +++ } +++ +++ memcpy(&iecc1, ecc1, 3); +++ memcpy(&iecc2, ecc2, 3); +++ +++ xor = iecc1 ^ iecc2; +++ printk("xor = %x (%x %x)\n", xor, iecc1, iecc2); +++ +++ *bytes = 0; +++ for (i = 0; i < 9; i++) +++ { +++ crumb = (xor >> (2*i)) & 0x3; +++ if ((crumb == 0x0) || (crumb == 0x3)) +++ return -1; +++ if (crumb == 0x2) +++ *bytes += (1 << i); +++ } +++ +++ *bits = 0; +++ for (i = 0; i < 3; i++) +++ { +++ crumb = (xor >> (18 + 2*i)) & 0x3; +++ if ((crumb == 0x0) || (crumb == 0x3)) +++ return -1; +++ if (crumb == 0x2) +++ *bits += (1 << i); +++ } +++ +++ return 0; +++} +++ +++/************************************************************ +++ * the init/exit section. +++ */ +++ +++static struct nand_ecclayout ra_oob_layout = { +++ .eccbytes = CONFIG_ECC_BYTES, +++ .eccpos = {5, 6, 7}, +++ .oobfree = { +++ {.offset = 0, .length = 4}, +++ {.offset = 8, .length = 8}, +++ {.offset = 0, .length = 0} +++ }, +++#define RA_CHIP_OOB_AVAIL (4+8) +++ .oobavail = RA_CHIP_OOB_AVAIL, +++ // 5th byte is bad-block flag. +++}; +++ +++static int +++mtk_nand_probe(struct platform_device *pdev) +++{ +++ struct mtd_part_parser_data ppdata; +++ struct ra_nand_chip *ra; +++ int alloc_size, bbt_size, buffers_size, reg, err; +++ unsigned char chip_mode = 12; +++ +++ /* if(ra_check_flash_type()!=BOOT_FROM_NAND) { +++ return 0; +++ }*/ +++ +++ //FIXME: config 512 or 2048-byte page according to HWCONF +++#if defined (CONFIG_SOC_MT7620) +++ ra_outl(RALINK_SYSCTL_BASE+0x60, ra_inl(RALINK_SYSCTL_BASE+0x60) & ~(0x3<<18)); +++ reg = ra_inl(RALINK_SYSCTL_BASE+0x10); +++ chip_mode = (reg & 0x0F); +++ if((chip_mode==1)||(chip_mode==11)) { +++ ra_or(NFC_CONF1, 1); +++ is_nand_page_2048 = 1; +++ nand_addrlen = ((chip_mode!=11) ? 4 : 5); +++ printk("!!! nand page size = 2048, addr len=%d\n", nand_addrlen); +++ } +++ else { +++ ra_and(NFC_CONF1, ~1); +++ is_nand_page_2048 = 0; +++ nand_addrlen = ((chip_mode!=10) ? 3 : 4); +++ printk("!!! nand page size = 512, addr len=%d\n", nand_addrlen); +++ } +++#else +++ is_nand_page_2048 = 0; +++ nand_addrlen = 3; +++ printk("!!! nand page size = 512, addr len=%d\n", nand_addrlen); +++#endif +++ +++#if defined (CONFIG_SOC_MT7620) +++ //config ECC location +++ ra_and(NFC_CONF1, 0xfff000ff); +++ ra_or(NFC_CONF1, ((CONFIG_ECC_OFFSET + 2) << 16) + +++ ((CONFIG_ECC_OFFSET + 1) << 12) + +++ (CONFIG_ECC_OFFSET << 8)); +++#endif +++ +++#define ALIGNE_16(a) (((unsigned long)(a)+15) & ~15) +++ buffers_size = ALIGNE_16((1<buffers +++ bbt_size = BBTTAG_BITS * (1<<(CONFIG_CHIP_SIZE_BIT - (CONFIG_PAGE_SIZE_BIT + CONFIG_NUMPAGE_PER_BLOCK_BIT))) / 8; //ra->bbt +++ bbt_size = ALIGNE_16(bbt_size); +++ +++ alloc_size = buffers_size + bbt_size; +++ alloc_size += buffers_size; //for ra->readback_buffers +++ alloc_size += sizeof(*ra); +++ alloc_size += sizeof(*ranfc_mtd); +++ +++ //make sure gpio-0 is input +++ ra_outl(RALINK_PIO_BASE+0x24, ra_inl(RALINK_PIO_BASE+0x24) & ~0x01); +++ +++ ra = (struct ra_nand_chip *)kzalloc(alloc_size, GFP_KERNEL | GFP_DMA); +++ if (!ra) { +++ printk("%s: mem alloc fail \n", __func__); +++ return -ENOMEM; +++ } +++ memset(ra, 0, alloc_size); +++ +++ //dynamic +++ ra->buffers = (char *)((char *)ra + sizeof(*ra)); +++ ra->readback_buffers = ra->buffers + buffers_size; +++ ra->bbt = ra->readback_buffers + buffers_size; +++ ranfc_mtd = (struct mtd_info *)(ra->bbt + bbt_size); +++ +++ //static +++ ra->numchips = CONFIG_NUMCHIPS; +++ ra->chip_shift = CONFIG_CHIP_SIZE_BIT; +++ ra->page_shift = CONFIG_PAGE_SIZE_BIT; +++ ra->oob_shift = CONFIG_OOBSIZE_PER_PAGE_BIT; +++ ra->erase_shift = (CONFIG_PAGE_SIZE_BIT + CONFIG_NUMPAGE_PER_BLOCK_BIT); +++ ra->badblockpos = CONFIG_BAD_BLOCK_POS; +++ ra_oob_layout.eccpos[0] = CONFIG_ECC_OFFSET; +++ ra_oob_layout.eccpos[1] = CONFIG_ECC_OFFSET + 1; +++ ra_oob_layout.eccpos[2] = CONFIG_ECC_OFFSET + 2; +++ ra->oob = &ra_oob_layout; +++ ra->buffers_page = -1; +++ +++#if defined (WORKAROUND_RX_BUF_OV) +++ if (ranfc_verify) { +++ ra->sandbox_page = nand_bbt_find_sandbox(ra); +++ } +++#endif +++ ra_outl(NFC_CTRL, ra_inl(NFC_CTRL) | 0x01); //set wp to high +++ nfc_all_reset(); +++ +++ ranfc_mtd->type = MTD_NANDFLASH; +++ ranfc_mtd->flags = MTD_CAP_NANDFLASH; +++ ranfc_mtd->size = CONFIG_NUMCHIPS * CFG_CHIPSIZE; +++ ranfc_mtd->erasesize = CFG_BLOCKSIZE; +++ ranfc_mtd->writesize = CFG_PAGESIZE; +++ ranfc_mtd->writebufsize = ranfc_mtd->writesize; +++ ranfc_mtd->oobsize = CFG_PAGE_OOBSIZE; +++ ranfc_mtd->oobavail = RA_CHIP_OOB_AVAIL; +++ ranfc_mtd->name = "ra_nfc"; +++ //ranfc_mtd->index +++ //ranfc_mtd->ecclayout = &ra_oob_layout; +++ //ranfc_mtd->numberaseregions +++ //ranfc_mtd->eraseregions +++ //ranfc_mtd->bansize +++ ranfc_mtd->_erase = ramtd_nand_erase; +++ //ranfc_mtd->point +++ //ranfc_mtd->unpoint +++ ranfc_mtd->_read = ramtd_nand_read; +++ ranfc_mtd->_write = ramtd_nand_write; +++ //ranfc_mtd->_read_oob = ramtd_nand_readoob; +++ //ranfc_mtd->_write_oob = ramtd_nand_writeoob; +++ //ranfc_mtd->get_fact_prot_info; ranfc_mtd->read_fact_prot_reg; +++ //ranfc_mtd->get_user_prot_info; ranfc_mtd->read_user_prot_reg; +++ //ranfc_mtd->write_user_prot_reg; ranfc_mtd->lock_user_prot_reg; +++ //ranfc_mtd->writev; ranfc_mtd->sync; ranfc_mtd->lock; ranfc_mtd->unlock; ranfc_mtd->suspend; ranfc_mtd->resume; +++ ranfc_mtd->_block_isbad = ramtd_nand_block_isbad; +++ ranfc_mtd->_block_markbad = ramtd_nand_block_markbad; +++ //ranfc_mtd->reboot_notifier +++ //ranfc_mtd->ecc_stats; +++ // subpage_sht; +++ +++ //ranfc_mtd->get_device; ranfc_mtd->put_device +++ ranfc_mtd->priv = ra; +++ +++ ranfc_mtd->owner = THIS_MODULE; +++ ra->controller = &ra->hwcontrol; +++ mutex_init(ra->controller); +++ +++ printk("%s: alloc %x, at %p , btt(%p, %x), ranfc_mtd:%p\n", +++ __func__, alloc_size, ra, ra->bbt, bbt_size, ranfc_mtd); +++ +++ mtd_set_of_node(ranfc_mtd, pdev->dev.of_node); +++ err = mtd_device_parse_register(ranfc_mtd, mtk_probe_types, +++ &ppdata, NULL, 0); +++ +++ return err; +++} +++ +++static int +++mtk_nand_remove(struct platform_device *pdev) +++{ +++ struct ra_nand_chip *ra; +++ +++ if (ranfc_mtd) { +++ ra = (struct ra_nand_chip *)ranfc_mtd->priv; +++ +++ /* Deregister partitions */ +++ //del_mtd_partitions(ranfc_mtd); +++ kfree(ra); +++ } +++ return 0; +++} +++ +++static const struct of_device_id mtk_nand_match[] = { +++ { .compatible = "mtk,mt7620-nand" }, +++ {}, +++}; +++MODULE_DEVICE_TABLE(of, mtk_nand_match); +++ +++static struct platform_driver mtk_nand_driver = { +++ .probe = mtk_nand_probe, +++ .remove = mtk_nand_remove, +++ .driver = { +++ .name = "mt7620_nand", +++ .owner = THIS_MODULE, +++ .of_match_table = mtk_nand_match, +++ }, +++}; +++ +++module_platform_driver(mtk_nand_driver); +++ +++MODULE_LICENSE("GPL"); ++--- /dev/null +++++ b/drivers/mtd/maps/ralink_nand.h ++@@ -0,0 +1,240 @@ +++#ifndef RT2880_NAND_H +++#define RT2880_NAND_H +++ +++#include +++ +++#define MTD_ERASE_PENDING 0x01 +++#define MTD_ERASING 0x02 +++#define MTD_ERASE_SUSPEND 0x04 +++#define MTD_ERASE_DONE 0x08 +++#define MTD_ERASE_FAILED 0x10 +++ +++#define MTD_FAIL_ADDR_UNKNOWN -1LL +++ +++//#include "gdma.h" +++ +++#define RALINK_SYSCTL_BASE 0xB0000000 +++#define RALINK_PIO_BASE 0xB0000600 +++#define RALINK_NAND_CTRL_BASE 0xB0000810 +++#define CONFIG_RALINK_MT7620 +++ +++#define SKIP_BAD_BLOCK +++//#define RANDOM_GEN_BAD_BLOCK +++ +++#define ra_inl(addr) (*(volatile unsigned int *)(addr)) +++#define ra_outl(addr, value) (*(volatile unsigned int *)(addr) = (value)) +++#define ra_aor(addr, a_mask, o_value) ra_outl(addr, (ra_inl(addr) & (a_mask)) | (o_value)) +++#define ra_and(addr, a_mask) ra_aor(addr, a_mask, 0) +++#define ra_or(addr, o_value) ra_aor(addr, -1, o_value) +++ +++ +++#define CONFIG_NUMCHIPS 1 +++#define CONFIG_NOT_SUPPORT_WP //rt3052 has no WP signal for chip. +++//#define CONFIG_NOT_SUPPORT_RB +++ +++extern int is_nand_page_2048; +++extern const unsigned int nand_size_map[2][3]; +++ +++//chip +++// chip geometry: SAMSUNG small size 32MB. +++#define CONFIG_CHIP_SIZE_BIT (nand_size_map[is_nand_page_2048][nand_addrlen-3]) //! (1<=32)? 31 : CONFIG_CHIP_SIZE_BIT)) +++//#define CFG_CHIPSIZE (1 << CONFIG_CHIP_SIZE_BIT) +++#define CFG_PAGESIZE (1 << CONFIG_PAGE_SIZE_BIT) +++#define CFG_BLOCKSIZE (CFG_PAGESIZE << CONFIG_NUMPAGE_PER_BLOCK_BIT) +++#define CFG_NUMPAGE (1 << (CONFIG_CHIP_SIZE_BIT - CONFIG_PAGE_SIZE_BIT)) +++#define CFG_NUMBLOCK (CFG_NUMPAGE >> CONFIG_NUMPAGE_PER_BLOCK_BIT) +++#define CFG_BLOCK_OOBSIZE (1 << (CONFIG_OOBSIZE_PER_PAGE_BIT + CONFIG_NUMPAGE_PER_BLOCK_BIT)) +++#define CFG_PAGE_OOBSIZE (1 << CONFIG_OOBSIZE_PER_PAGE_BIT) +++ +++#define NAND_BLOCK_ALIGN(addr) ((addr) & (CFG_BLOCKSIZE-1)) +++#define NAND_PAGE_ALIGN(addr) ((addr) & (CFG_PAGESIZE-1)) +++ +++ +++#define NFC_BASE RALINK_NAND_CTRL_BASE +++#define NFC_CTRL (NFC_BASE + 0x0) +++#define NFC_CONF (NFC_BASE + 0x4) +++#define NFC_CMD1 (NFC_BASE + 0x8) +++#define NFC_CMD2 (NFC_BASE + 0xc) +++#define NFC_CMD3 (NFC_BASE + 0x10) +++#define NFC_ADDR (NFC_BASE + 0x14) +++#define NFC_DATA (NFC_BASE + 0x18) +++#if defined (CONFIG_RALINK_RT6855) || defined (CONFIG_RALINK_RT6855A) || \ +++ defined (CONFIG_RALINK_MT7620) || defined (CONFIG_RALINK_MT7621) +++#define NFC_ECC (NFC_BASE + 0x30) +++#else +++#define NFC_ECC (NFC_BASE + 0x1c) +++#endif +++#define NFC_STATUS (NFC_BASE + 0x20) +++#define NFC_INT_EN (NFC_BASE + 0x24) +++#define NFC_INT_ST (NFC_BASE + 0x28) +++#if defined (CONFIG_RALINK_RT6855) || defined (CONFIG_RALINK_RT6855A) || \ +++ defined (CONFIG_RALINK_MT7620) || defined (CONFIG_RALINK_MT7621) +++#define NFC_CONF1 (NFC_BASE + 0x2c) +++#define NFC_ECC_P1 (NFC_BASE + 0x30) +++#define NFC_ECC_P2 (NFC_BASE + 0x34) +++#define NFC_ECC_P3 (NFC_BASE + 0x38) +++#define NFC_ECC_P4 (NFC_BASE + 0x3c) +++#define NFC_ECC_ERR1 (NFC_BASE + 0x40) +++#define NFC_ECC_ERR2 (NFC_BASE + 0x44) +++#define NFC_ECC_ERR3 (NFC_BASE + 0x48) +++#define NFC_ECC_ERR4 (NFC_BASE + 0x4c) +++#define NFC_ADDR2 (NFC_BASE + 0x50) +++#endif +++ +++enum _int_stat { +++ INT_ST_ND_DONE = 1<<0, +++ INT_ST_TX_BUF_RDY = 1<<1, +++ INT_ST_RX_BUF_RDY = 1<<2, +++ INT_ST_ECC_ERR = 1<<3, +++ INT_ST_TX_TRAS_ERR = 1<<4, +++ INT_ST_RX_TRAS_ERR = 1<<5, +++ INT_ST_TX_KICK_ERR = 1<<6, +++ INT_ST_RX_KICK_ERR = 1<<7 +++}; +++ +++ +++//#define WORKAROUND_RX_BUF_OV 1 +++ +++ +++/************************************************************* +++ * stolen from nand.h +++ *************************************************************/ +++ +++/* +++ * Standard NAND flash commands +++ */ +++#define NAND_CMD_READ0 0 +++#define NAND_CMD_READ1 1 +++#define NAND_CMD_RNDOUT 5 +++#define NAND_CMD_PAGEPROG 0x10 +++#define NAND_CMD_READOOB 0x50 +++#define NAND_CMD_ERASE1 0x60 +++#define NAND_CMD_STATUS 0x70 +++#define NAND_CMD_STATUS_MULTI 0x71 +++#define NAND_CMD_SEQIN 0x80 +++#define NAND_CMD_RNDIN 0x85 +++#define NAND_CMD_READID 0x90 +++#define NAND_CMD_ERASE2 0xd0 +++#define NAND_CMD_RESET 0xff +++ +++/* Extended commands for large page devices */ +++#define NAND_CMD_READSTART 0x30 +++#define NAND_CMD_RNDOUTSTART 0xE0 +++#define NAND_CMD_CACHEDPROG 0x15 +++ +++/* Extended commands for AG-AND device */ +++/* +++ * Note: the command for NAND_CMD_DEPLETE1 is really 0x00 but +++ * there is no way to distinguish that from NAND_CMD_READ0 +++ * until the remaining sequence of commands has been completed +++ * so add a high order bit and mask it off in the command. +++ */ +++#define NAND_CMD_DEPLETE1 0x100 +++#define NAND_CMD_DEPLETE2 0x38 +++#define NAND_CMD_STATUS_MULTI 0x71 +++#define NAND_CMD_STATUS_ERROR 0x72 +++/* multi-bank error status (banks 0-3) */ +++#define NAND_CMD_STATUS_ERROR0 0x73 +++#define NAND_CMD_STATUS_ERROR1 0x74 +++#define NAND_CMD_STATUS_ERROR2 0x75 +++#define NAND_CMD_STATUS_ERROR3 0x76 +++#define NAND_CMD_STATUS_RESET 0x7f +++#define NAND_CMD_STATUS_CLEAR 0xff +++ +++#define NAND_CMD_NONE -1 +++ +++/* Status bits */ +++#define NAND_STATUS_FAIL 0x01 +++#define NAND_STATUS_FAIL_N1 0x02 +++#define NAND_STATUS_TRUE_READY 0x20 +++#define NAND_STATUS_READY 0x40 +++#define NAND_STATUS_WP 0x80 +++ +++typedef enum { +++ FL_READY, +++ FL_READING, +++ FL_WRITING, +++ FL_ERASING, +++ FL_SYNCING, +++ FL_CACHEDPRG, +++ FL_PM_SUSPENDED, +++} nand_state_t; +++ +++/*************************************************************/ +++ +++ +++ +++typedef enum _ra_flags { +++ FLAG_NONE = 0, +++ FLAG_ECC_EN = (1<<0), +++ FLAG_USE_GDMA = (1<<1), +++ FLAG_VERIFY = (1<<2), +++} RA_FLAGS; +++ +++ +++#define BBTTAG_BITS 2 +++#define BBTTAG_BITS_MASK ((1<> ./target/linux/rockchip/armv8/config-5.15 diff --git a/onekey/build.sh b/onekey/build.sh deleted file mode 100755 index a045664c4887..000000000000 --- a/onekey/build.sh +++ /dev/null @@ -1,159 +0,0 @@ -#/bin/bash -echo -echo -echo "本脚本仅适用于在Ubuntu环境下编译 https://github.com/kiddin9/OpenWrt_x86-r2s-r4s" -echo -echo -sleep 2s -sudo apt-get update -sudo apt-get upgrade - -sudo apt-get -y install build-essential asciidoc binutils bzip2 gawk gettext git libncurses5-dev patch python3 python2.7 unzip zlib1g-dev lib32gcc-s1 libc6-dev-i386 subversion flex uglifyjs gcc-multilib g++-multilib p7zip p7zip-full msmtp libssl-dev texinfo libglib2.0-dev xmlto qemu-utils libelf-dev autoconf automake libtool autopoint device-tree-compiler ccache xsltproc rename antlr3 gperf curl screen upx-ucl jq - - - -clear -echo -echo -echo -echo "|*******************************************|" -echo "| |" -echo "| |" -echo "| 基本环境部署完成...... |" -echo "| |" -echo "| |" -echo "|*******************************************|" -echo -echo - - -if [ "$USER" == "root" ]; then - echo - echo - echo "请勿使用root用户编译,换一个普通用户吧~~" - sleep 3s - exit 0 -fi - - - - - -rm -Rf openwrt - -echo " - -1. X86_64 - -2. r2s - -3. r4s - -4. Rpi-4B - -5. Exit - -" - -while :; do - -read -p "你想要编译哪个固件? " CHOOSE - -case $CHOOSE in - 1) - firmware="x86_64" - break - ;; - 2) - firmware="nanopi-r2s" - break - ;; - 3) - firmware="nanopi-r4s" - break - ;; - 4) - firmware="Rpi-4B" - break - ;; - 5) exit 0 - ;; - -esac -done - -REPO_BRANCH="$(curl -s https://api.github.com/repos/openwrt/openwrt/tags | jq -r '.[].name' | grep v21 | head -n 1 | sed -e 's/v//')" -git clone -b v$REPO_BRANCH https://github.com/openwrt/openwrt -svn export https://github.com/kiddin9/OpenWrt_x86-r2s-r4s/trunk/devices openwrt/devices - -cd openwrt -if [[ $firmware == "x86_64" ]]; then - curl -fL -o sdk.tar.xz https://mirrors.cloud.tencent.com/openwrt/releases/$REPO_BRANCH/targets/x86/64/openwrt-sdk-$REPO_BRANCH-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz || curl -fL -o sdk.tar.xz https://downloads.openwrt.org/releases/21.02-SNAPSHOT/targets/x86/64/openwrt-sdk-21.02-SNAPSHOT-x86-64_gcc-8.4.0_musl.Linux-x86_64.tar.xz -elif [[ $firmware == nanopi-* ]]; then - curl -fL -o sdk.tar.xz https://mirrors.cloud.tencent.com/openwrt/releases/$REPO_BRANCH/targets/rockchip/armv8/openwrt-sdk-$REPO_BRANCH-rockchip-armv8_gcc-8.4.0_musl.Linux-x86_64.tar.xz || curl -fL -o sdk.tar.xz https://downloads.openwrt.org/releases/21.02-SNAPSHOT/targets/rockchip/armv8/openwrt-sdk-21.02-SNAPSHOT-rockchip-armv8_gcc-8.4.0_musl.Linux-x86_64.tar.xz -elif [[ $firmware == "Rpi-4B" ]]; then - curl -fL -o sdk.tar.xz https://mirrors.cloud.tencent.com/openwrt/releases/$REPO_BRANCH/targets/bcm27xx/bcm2711/openwrt-sdk-$REPO_BRANCH-bcm27xx-bcm2711_gcc-8.4.0_musl.Linux-x86_64.tar.xz || curl -fL -o sdk.tar.xz https://downloads.openwrt.org/releases/21.02-SNAPSHOT/targets/bcm27xx/bcm2711/openwrt-sdk-21.02-SNAPSHOT-bcm27xx-bcm2711_gcc-8.4.0_musl.Linux-x86_64.tar.xz -fi - - -read -p "请输入后台地址 [回车默认10.0.0.1]: " ip -ip=${ip:-"10.0.0.1"} -echo "您的后台地址为: $ip" -cp -rf devices/common/* ./ -cp -rf devices/$firmware/* ./ -if [ -f "devices/common/diy.sh" ]; then - chmod +x devices/common/diy.sh - /bin/bash "devices/common/diy.sh" -fi -if [ -f "devices/$firmware/diy.sh" ]; then - chmod +x devices/$firmware/diy.sh - /bin/bash "devices/$firmware/diy.sh" -fi -cp -Rf ./diy/* ./ -if [ -f "devices/common/default-settings" ]; then - sed -i 's/10.0.0.1/$ip/' package/*/*/my-default-settings/files/etc/uci-defaults/99-default-settings -fi -if [ -f "devices/$firmware/default-settings" ]; then - sed -i "s/10.0.0.1/$ip/" devices/$firmware/default-settings - cat devices/$firmware/default-settings >> package/*/*/my-default-settings/files/etc/uci-defaults/99-default-settings -fi -if [ -n "$(ls -A "devices/common/patches" 2>/dev/null)" ]; then - find "devices/common/patches" -type f -name '*.patch' ! -name '*.revert.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -p1 --forward" -fi -if [ -n "$(ls -A "devices/$firmware/patches" 2>/dev/null)" ]; then - find "devices/$firmware/patches" -type f -name '*.patch' ! -name '*.revert.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -p1 --forward" -fi -cp devices/common/.config .config -echo >> .config -cat devices/$firmware/.config >> .config -make defconfig -for i in $(make --file=preset_pkg.mk presetpkg); do - sed -i "\$a CONFIG_PACKAGE_$i=y" .config -done -make menuconfig -echo -echo -echo -echo " *****5秒后开始编译***** - -1.你可以随时按Ctrl+C停止编译 - -3.大陆用户编译前请准备好梯子,使用大陆白名单或全局模式" -echo -echo -echo -sleep 3s - -make -j$(($(nproc)+1)) download -j$(($(nproc)+1)) & -make -j$(($(nproc)+1)) || make -j1 V=s - -if [ "$?" == "0" ]; then -echo " - -编译完成~~~ - -初始后台地址: $ip -初始用户名密码: root root - -" -fi diff --git a/onekey/rebuild.sh b/onekey/rebuild.sh deleted file mode 100755 index d9753505027e..000000000000 --- a/onekey/rebuild.sh +++ /dev/null @@ -1,126 +0,0 @@ -#/bin/bash -echo -echo -echo "本脚本仅适用于在Ubuntu环境下编译 https://github.com/kiddin9/OpenWrt_x86-r2s-r4s" -echo -echo - -if [ "$USER" == "root" ]; then - echo - echo - echo "请勿使用root用户编译,换一个普通用户吧~~" - sleep 3s - exit 0 -fi - -echo -echo - -clear - -rm -Rf openwrt/common openwrt/files openwrt/devices -svn export https://github.com/kiddin9/OpenWrt_x86-r2s-r4s/trunk/devices openwrt/devices -cd openwrt - -git checkout . -git pull - -[ $(grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/') == generic ] && { - firmware=$(grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/CONFIG_TARGET_(.*)_DEVICE_.*=y/\1/') - } || { firmware=$(grep '^CONFIG_TARGET.*DEVICE.*=y' .config | sed -r 's/.*DEVICE_(.*)=y/\1/') - } - -if [ $firmware == "x86_64" ]; then - firmware="x86_64" -elif [ $firmware == "friendlyarm_nanopi-r2s" ]; then - firmware="nanopi-r2s" -elif [ $firmware == "friendlyarm_nanopi-r4s" ]; then - firmware="nanopi-r4s" -elif [ $firmware == "rpi-4" ]; then - firmware="Rpi-4B" -elif [ $firmware == "d-team_newifi-d2" ]; then - firmware="newifi-d2" -else - echo "无法识别固件类型,请退出" -fi - -echo - -read -p "请输入后台地址 [回车默认10.0.0.1]: " ip -ip=${ip:-"10.0.0.1"} -echo "您的后台地址为: $ip" - -rm -Rf feeds package/feeds common files diy tmp -make clean -[ -f ".config" ] && mv .config .config.bak -cp -rf devices/common/* ./ -cp -rf devices/$firmware/* ./ -if [ -f "devices/common/diy.sh" ]; then - chmod +x devices/common/diy.sh - /bin/bash "devices/common/diy.sh" -fi -if [ -f "devices/$firmware/diy.sh" ]; then - chmod +x devices/$firmware/diy.sh - /bin/bash "devices/$firmware/diy.sh" -fi -cp -Rf ./diy/* ./ -if [ -f "devices/common/default-settings" ]; then - sed -i 's/10.0.0.1/$ip/' package/*/*/my-default-settings/files/uci.defaults -fi -if [ -f "devices/$firmware/default-settings" ]; then - sed -i 's/10.0.0.1/$ip/' devices/$firmware/default-settings - cat devices/$firmware/default-settings >> package/*/*/my-default-settings/files/uci.defaults -fi -if [ -n "$(ls -A "devices/common/patches" 2>/dev/null)" ]; then - find "devices/common/patches" -type f -name '*.patch' ! -name '*.revert.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -p1 --forward" -fi -if [ -n "$(ls -A "devices/$firmware/patches" 2>/dev/null)" ]; then - find "devices/$firmware/patches" -type f -name '*.patch' ! -name '*.revert.patch' -print0 | sort -z | xargs -I % -t -0 -n 1 sh -c "cat '%' | patch -d './' -p1 --forward" -fi -[ -f ".config.bak" ] && cp -f .config.bak .config || { -cp -f devices/common/.config .config -echo >> .config -cat devices/$firmware/.config >> .config -} - -[ firmware == "other" ] || { -while true; do -read -p "是否增删插件? [y/N]: " YN -case ${YN:-N} in - [Yy]) - make menuconfig - echo "" - ;; - [Nn]) - make defconfig - break - ;; -esac -done -} -echo -echo -echo " *****5秒后开始编译***** - -1.你可以随时按Ctrl+C停止编译 - -3.大陆用户编译前请准备好梯子,使用大陆白名单或全局模式" -echo -echo -sleep 3s - -sed -i 's,$(STAGING_DIR_HOST)/bin/upx,upx,' package/feeds/kiddin9/*/Makefile - -make -j$(($(nproc)+1)) download v=s ; make -j$(($(nproc)+1)) || make -j1 V=s - -if [ "$?" == "0" ]; then -echo " - -编译完成~~~ - -初始后台地址: $ip -初始用户名密码: root root - -" -fi -