Skip to content

Commit

Permalink
Add support for GainStrong Oolite-MT7981B V1
Browse files Browse the repository at this point in the history
  • Loading branch information
guoxiaoqiao committed May 20, 2023
1 parent 566058d commit 84b5503
Show file tree
Hide file tree
Showing 28 changed files with 898 additions and 10 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
/logs
/feeds
/feeds.conf
/files
/overlay
/package/feeds
/package/openwrt-packages
Expand Down
96 changes: 96 additions & 0 deletions MT7981.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
CONFIG_TARGET_mediatek=y
CONFIG_TARGET_mediatek_filogic=y
CONFIG_TARGET_MULTI_PROFILE=y

CONFIG_IMAGEOPT=y
CONFIG_VERSIONOPT=y
CONFIG_VERSION_FILENAMES=y
CONFIG_VERSION_CODE_FILENAMES=y

CONFIG_PACKAGE_kmod-mmc=y
CONFIG_PACKAGE_kmod-usb3=y
CONFIG_PACKAGE_kmod-usb-storage=y

CONFIG_PACKAGE_kmod-oolite-v7=y
CONFIG_PACKAGE_oolite-v7-tools=y

CONFIG_PACKAGE_luci=y
CONFIG_LUCI_LANG_en=y
CONFIG_LUCI_LANG_zh_Hans=y
CONFIG_PACKAGE_luci-app-ttyd=y
CONFIG_PACKAGE_luci-app-ser2net=y

CONFIG_PACKAGE_uboot-envtools=y

CONFIG_PACKAGE_mdio-tools=y
CONFIG_PACKAGE_ethtool=y
CONFIG_PACKAGE_pciutils=y
CONFIG_PACKAGE_usbutils=y

CONFIG_PACKAGE_nand-utils=y
CONFIG_PACKAGE_ubi-utils=y
CONFIG_PACKAGE_mmc-utils=y

CONFIG_PACKAGE_parted=y
CONFIG_PACKAGE_cgdisk=y
CONFIG_PACKAGE_gdisk=y
CONFIG_PACKAGE_sgdisk=y
CONFIG_PACKAGE_cfdisk=y
CONFIG_PACKAGE_fdisk=y
CONFIG_PACKAGE_sfdisk=y

CONFIG_PACKAGE_lsblk=y
CONFIG_PACKAGE_losetup=y
CONFIG_PACKAGE_blkid=y
CONFIG_PACKAGE_blockdev=y

CONFIG_PACKAGE_kmod-fs-ext4=y
CONFIG_PACKAGE_kmod-fs-exfat=y
CONFIG_PACKAGE_kmod-fs-ntfs3=y
CONFIG_PACKAGE_kmod-fs-vfat=y
CONFIG_PACKAGE_e2fsprogs=y

CONFIG_PACKAGE_iperf3=y
CONFIG_PACKAGE_memtester=y

CONFIG_PACKAGE_coreutils=y
CONFIG_PACKAGE_coreutils-dd=y
CONFIG_PACKAGE_coreutils-stty=y
CONFIG_PACKAGE_diffutils=y

CONFIG_PACKAGE_lsof=y
CONFIG_PACKAGE_dmesg=y

############### 4G LTE/5G support start ###############
CONFIG_PACKAGE_luci-proto-qmi=y
CONFIG_PACKAGE_luci-proto-3g=y
CONFIG_PACKAGE_luci-proto-ncm=y
CONFIG_PACKAGE_qmi-utils=y
CONFIG_PACKAGE_mbim-utils=y
CONFIG_PACKAGE_umbim=y

CONFIG_PACKAGE_luci-app-3ginfo-lite=y
CONFIG_PACKAGE_luci-app-sms-tool=y
CONFIG_PACKAGE_luci-compat=y
############### 4G LTE/5G support end ###############

############### I2C support start ###############
CONFIG_PACKAGE_i2c-tools=y
CONFIG_PACKAGE_kmod-i2c-gpio=y
CONFIG_PACKAGE_kmod-gpio-pca953x=y
############### I2C support end ###############

CONFIG_KERNEL_FTRACE=y
CONFIG_KERNEL_FTRACE_SYSCALLS=y
CONFIG_KERNEL_ENABLE_DEFAULT_TRACERS=y
CONFIG_KERNEL_FUNCTION_TRACER=y
CONFIG_KERNEL_FUNCTION_GRAPH_TRACER=y
CONFIG_KERNEL_DYNAMIC_FTRACE=y
CONFIG_KERNEL_FUNCTION_PROFILER=y
CONFIG_KERNEL_IRQSOFF_TRACER=y
CONFIG_KERNEL_PREEMPT_TRACER=y
CONFIG_KERNEL_HIST_TRIGGERS=y
CONFIG_KERNEL_DEBUG_KERNEL=y
CONFIG_KERNEL_DEBUG_INFO=y
CONFIG_KERNEL_DEBUG_INFO_REDUCED=y

80 changes: 80 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash

# Constants
PRODUCT_NAME="Oolite-MT7981B"

if [ -z "$(grep 21.02 include/version.mk)" ]; then
TARGET_NAME="filogic"
else
TARGET_NAME="mt7981"
fi

DEVICE_PREFIX="CONFIG_TARGET_DEVICE_mediatek_${TARGET_NAME}_DEVICE_gainstrong_oolite-mt7981b"
FLASH_TYPES=("nand" "emmc" "sdcard" "nor" "all")

# Function to validate the user input
validate_input() {
local input=$1
for flash_type in "${FLASH_TYPES[@]}"; do
if [ "$input" == "$flash_type" ]; then
return 0
fi
done
return 1
}

# Check if the argument is valid
if [[ $# -eq 1 ]]; then
if validate_input "$1"; then
user_input=$1
else
echo "Error: The input must be a valid flash type (nand, emmc, sdcard, nor, all)"
exit 1
fi
else
# Prompt user to choose flash_type
echo "Please choose a flash type:"
PS3="Enter the corresponding number (1-5) and press Enter: "
select choice in "${FLASH_TYPES[@]}"; do
if [ -n "$choice" ]; then
user_input=$choice
break
else
echo "Invalid selection, please try again."
fi
done
fi

# Function to build for each flash type
build_for_flash_type() {
local flash_type=$1

cp MT7981.config .config

VERSION=$(./scripts/getver.sh)

cat << EOF >> .config
# Add an empty line
CONFIG_KERNEL_BUILD_DOMAIN="$VERSION"
CONFIG_KERNEL_BUILD_USER="$PRODUCT_NAME"
CONFIG_VERSION_DIST="$PRODUCT_NAME"
EOF

if [ "$flash_type" == "all" ]; then
for flash_type_option in nand emmc sdcard nor; do
echo "$DEVICE_PREFIX-dev-board-${flash_type_option}-boot=y" >> .config
# echo "$DEVICE_PREFIX-module-${flash_type_option}-boot=y" >> .config
done
else
echo "$DEVICE_PREFIX-dev-board-${flash_type}-boot=y" >> .config
# echo "$DEVICE_PREFIX-module-${flash_type}-boot=y" >> .config
fi

# Execute the build commands
make package/symlinks
make defconfig
make -j8 V=sc
}

build_for_flash_type "$user_input"
2 changes: 2 additions & 0 deletions feeds.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ src-git-full telephony https://git.openwrt.org/feed/telephony.git^afad179aaec9c1
#src-git-full targets https://github.com/openwrt/targets.git
#src-git-full oldpackages http://git.openwrt.org/packages.git
#src-link custom /usr/src/openwrt/custom-feed
src-git 3ginfo https://github.com/4IceG/luci-app-3ginfo-lite.git^9f090caa04d7e4453201d27ed213ca0b96b9570c
src-git smstool https://github.com/4IceG/luci-app-sms-tool.git^100707821a1a080a1348ea22f0605c3dc4dc7026
2 changes: 1 addition & 1 deletion include/version.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ PKG_CONFIG_DEPENDS += \
sanitize = $(call tolower,$(subst _,-,$(subst $(space),-,$(1))))

VERSION_NUMBER:=$(call qstrip,$(CONFIG_VERSION_NUMBER))
VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),SNAPSHOT)
VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),23.05)

VERSION_CODE:=$(call qstrip,$(CONFIG_VERSION_CODE))
VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),$(REVISION))
Expand Down
85 changes: 85 additions & 0 deletions package/base-files/files/bin/config_generate
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,91 @@ generate_static_network() {
set network.loopback.proto='static'
set network.loopback.ipaddr='127.0.0.1'
set network.loopback.netmask='255.0.0.0'
delete network.4G_QMI_1
set network.4G_QMI_1=interface
set network.4G_QMI_1.proto='qmi'
set network.4G_QMI_1.device='/dev/cdc-wdm0'
set network.4G_QMI_1.metric=11
add_list firewall.cfg03dc81.network='4G_QMI_1'
delete network.4G_PPP_1
set network.4G_PPP_1=interface
set network.4G_PPP_1.proto='3g'
set network.4G_PPP_1.device='/dev/ttyUSB2'
set network.4G_PPP_1.metric=12
add_list firewall.cfg03dc81.network='4G_PPP_1'
delete network.4G_ETH_1
set network.4G_ETH_1=interface
set network.4G_ETH_1.proto='dhcp'
set network.4G_ETH_1.device='usb0'
set network.4G_ETH_1.metric=13
add_list firewall.cfg03dc81.network='4G_ETH_1'
delete network.4G_QMI_2
set network.4G_QMI_2=interface
set network.4G_QMI_2.proto='qmi'
set network.4G_QMI_2.device='/dev/cdc-wdm1'
set network.4G_QMI_2.metric=21
add_list firewall.cfg03dc81.network='4G_QMI_2'
delete network.4G_PPP_2
set network.4G_PPP_2=interface
set network.4G_PPP_2.proto='3g'
set network.4G_PPP_2.device='/dev/ttyUSB7'
set network.4G_PPP_2.metric=22
add_list firewall.cfg03dc81.network='4G_PPP_2'
delete network.4G_ETH_2
set network.4G_ETH_2=interface
set network.4G_ETH_2.proto='dhcp'
set network.4G_ETH_2.device='usb1'
set network.4G_ETH_2.metric=23
add_list firewall.cfg03dc81.network='4G_ETH_2'
######### Oolite V7 802.11ah config start #########
# /etc/config/dhcp
set dhcp.11AH_AP=dhcp
set dhcp.11AH_AP.interface='11AH_AP'
set dhcp.11AH_AP.start='1'
set dhcp.11AH_AP.limit='9'
set dhcp.11AH_AP.leasetime='2d'
set dhcp.@dnsmasq[-1].sequential_ip=1
# /etc/config/firewall
add_list firewall.cfg02dc81.network='11AH_AP'
# /etc/config/network
set network.11AH_AP=interface
set network.11AH_AP.proto='static'
set network.11AH_AP.device='hg0'
set network.11AH_AP.ipaddr='10.10.10.10'
set network.11AH_AP.netmask='255.255.255.0'
# /etc/config/firewall
add_list firewall.cfg03dc81.network='11AH_STA'
# /etc/config/network
set network.11AH_STA=interface
set network.11AH_STA.proto='dhcp'
set network.11AH_STA.device='hg0'
set network.11AH_STA.auto='0'
set network.11AH_STA.metric='77'
# /etc/config/firewall
add firewall zone # =cfg0edc81
set firewall.@zone[-1].name='bridge'
set firewall.@zone[-1].input='ACCEPT'
set firewall.@zone[-1].output='ACCEPT'
set firewall.@zone[-1].forward='ACCEPT'
add firewall forwarding # =cfg0fad58
set firewall.@forwarding[-1].src='lan'
set firewall.@forwarding[-1].dest='bridge'
######### Oolite V7 802.11ah config end #########
EOF
[ -e /proc/sys/net/ipv6 ] && {
uci -q batch <<-EOF
Expand Down
2 changes: 2 additions & 0 deletions package/base-files/files/etc/rc.local
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

iperf3 -s -D --logfile /tmp/iperf3.log

exit 0
8 changes: 6 additions & 2 deletions package/kernel/mac80211/files/lib/wifi/mac80211.sh
Original file line number Diff line number Diff line change
Expand Up @@ -196,20 +196,24 @@ detect_mac80211() {
;;
esac

last_4_mac=$(echo $macaddr | awk -F ":" '{printf toupper($5$6)}')
board_name=$(grep 'DISTRIB_ID' /etc/openwrt_release | awk -F "'" '{print $2}')
mode_band_upper=$(echo $mode_band | awk '{print toupper($0)}')
ssid="${board_name}_${last_4_mac}_${mode_band_upper}"

uci -q batch <<-EOF
set wireless.${name}=wifi-device
set wireless.${name}.type=mac80211
${dev_id}
set wireless.${name}.channel=${channel}
set wireless.${name}.band=${mode_band}
set wireless.${name}.htmode=$htmode
set wireless.${name}.disabled=1
set wireless.default_${name}=wifi-iface
set wireless.default_${name}.device=${name}
set wireless.default_${name}.network=lan
set wireless.default_${name}.mode=ap
set wireless.default_${name}.ssid=OpenWrt
set wireless.default_${name}.ssid=${ssid}
set wireless.default_${name}.encryption=none
EOF
uci -q commit wireless
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/dts-v1/;

#include "mt7981b-gainstrong-oolite-mt7981b.dtsi"
#include "mt7981b-gainstrong-oolite-mt7981b-dev-board.dtsi"

/ {
model = "GainStrong Oolite-MT7981B V1 Dev Board (emmc boot)";
compatible = "gainstrong,oolite-mt7981b-dev-board-emmc-boot", "mediatek,mt7981";

chosen {
bootargs = "rootwait root=PARTLABEL=rootfs";
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/dts-v1/;

#include "mt7981b-gainstrong-oolite-mt7981b.dtsi"
#include "mt7981b-gainstrong-oolite-mt7981b-nand-boot.dtsi"
#include "mt7981b-gainstrong-oolite-mt7981b-dev-board.dtsi"
#include "mt7981b-gainstrong-oolite-mt7981b-mtd-macaddr.dtsi"

/ {
model = "GainStrong Oolite-MT7981B V1 Dev Board (nand boot)";
compatible = "gainstrong,oolite-mt7981b-dev-board-nand-boot", "mediatek,mt7981";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/dts-v1/;

#include "mt7981b-gainstrong-oolite-mt7981b.dtsi"
#include "mt7981b-gainstrong-oolite-mt7981b-nor-boot.dtsi"
#include "mt7981b-gainstrong-oolite-mt7981b-dev-board.dtsi"
#include "mt7981b-gainstrong-oolite-mt7981b-mtd-macaddr.dtsi"

/ {
model = "GainStrong Oolite-MT7981B V1 Dev Board (nor boot)";
compatible = "gainstrong,oolite-mt7981b-dev-board-nor-boot", "mediatek,mt7981";

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/dts-v1/;

#include "mt7981b-gainstrong-oolite-mt7981b.dtsi"
#include "mt7981b-gainstrong-oolite-mt7981b-dev-board.dtsi"

/ {
model = "GainStrong Oolite-MT7981B V1 Dev Board (sd card boot)";
compatible = "gainstrong,oolite-mt7981b-dev-board-sdcard-boot", "mediatek,mt7981";

chosen {
bootargs = "rootwait root=PARTLABEL=rootfs";
};
};

&mmc0 {
bus-width = <4>;
/delete-property/ non-removable;
};
Loading

2 comments on commit 84b5503

@guoxiaoqiao
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ptpt52 可以参考修改clk-mt7981-infracfg.c解决eMMC问题

@ptpt52
Copy link
Contributor

@ptpt52 ptpt52 commented on 84b5503 May 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@guoxiaoqiao
ok, 怎么发现是这个的?

Please sign in to comment.