Skip to content

Commit

Permalink
Merge pull request #611 from socallinuxexpo/rh/issue-367
Browse files Browse the repository at this point in the history
[READY] - Belkin RT3200 support for scale openwrt
  • Loading branch information
owendelong authored Aug 24, 2023
2 parents c3138e9 + c208d55 commit 81faac3
Show file tree
Hide file tree
Showing 16 changed files with 297 additions and 75 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/openwrt-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-22.04
strategy:
matrix:
target: ["ar71xx", "ipq806x"]
target: ["ar71xx", "mt7622"]
container:
image: sarcasticadmin/openwrt-build@sha256:8dc545cb1cbb2cb507f4e5c8df2f3632335abf7230f9574eb39080c2fc67cc3f
# Since user is openwrt and gets 1001 from inside container
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/openwrt-golden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,3 @@ jobs:
run: |
cd tests/unit/openwrt
sh -x test.sh -t ar71xx
- name: openwrt_golden_ipq806x
shell: sh
run: |
cd tests/unit/openwrt
sh -x test.sh -t ipq806x
21 changes: 21 additions & 0 deletions facts/secrets/mt7622-openwrt-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# scale
root_hash: "$1$zh0PjBbB$f9aFGDX9vNYNdSRexhib8/"

# Bump for each year for scale
scale: 21

sshd:
password_auth: true

rsyslog:
server: 'loghost.scale.lan'
port: '514'
protocol: 'udp'

zabbix:
server: 'zabbix.scale.lan'

ntp:
server: '0.openwrt.pool.ntp.org'

# Wired/Wireless config can directly be found in files dir
13 changes: 11 additions & 2 deletions openwrt/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ include include/*.mk
# Export all variables by default
.EXPORT_ALL_VARIABLES:

SHELL = /usr/bin/env bash

# WNDR by default
TARGET ?= ar71xx

Expand Down Expand Up @@ -76,10 +78,13 @@ diffconfig:
@cd $(BUILD_DIR)/$(IMAGEBUILDER) && ./scripts/diffconfig.sh > .diffconfig

commonconfig: diffconfig
ifneq ($(TARGET), x86)
$(error "common config can only be generated from x86")
endif
cat ./$(BUILD_DIR)/$(IMAGEBUILDER)/.diffconfig | grep -v CONFIG_TARGET > ./configs/common.config

targetconfig: diffconfig
cat ./$(BUILD_DIR)/$(IMAGEBUILDER)/.diffconfig | grep CONFIG_TARGET > ./configs/$(TARGET)-generic.config
comm -23 <(sort ./$(BUILD_DIR)/$(IMAGEBUILDER)/.diffconfig) <(sort ./configs/common.config) > ./configs/$(TARGET)-generic.config

config: $(BUILD_DIR)/$(IMAGEBUILDER)/.config

Expand All @@ -99,7 +104,7 @@ package:
mkdir -p $(BUILD_DIR)/artifacts
# TODO: Look into striping path to only be from targets/ onward
tar zcvf $(BUILD_DIR)/artifacts/$(TARGET)-$(SHORT_VER)-artifacts.tar.gz \
-C $(BUILD_DIR)/$(IMAGEBUILDER)/bin/targets/*/generic ./
-C $(BUILD_DIR)/$(IMAGEBUILDER)/bin/targets/* ./

$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
Expand All @@ -124,6 +129,10 @@ ifndef GOMPLATE
$(error "gomplate is not available please install it")
endif
$(GOMPLATE) -d openwrt=$(BUILD_SECRETS) -d keys_dir=$(KEYPATH) --input-dir=$(TMPL_SRC_DIR) --output-dir=$(TMPL_OUT_DIR)
# Check that TARGET specific dir exists
ifneq ($(wildcard $(TMPL_SRC_DIR)-$(TARGET)/.),)
$(GOMPLATE) -d openwrt=$(BUILD_SECRETS) -d keys_dir=$(KEYPATH) --input-dir=$(TMPL_SRC_DIR)-$(TARGET) --output-dir=$(TMPL_OUT_DIR)
endif
# TODO: should do this automatically for .sh file types
chmod 750 $(TMPL_OUT_DIR)/root/bin/config-version.sh
chmod 750 $(TMPL_OUT_DIR)/root/bin/wifi-details.sh
Expand Down
56 changes: 10 additions & 46 deletions openwrt/configs/common.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
CONFIG_BUSYBOX_CUSTOM=y
CONFIG_BUSYBOX_CONFIG_FEATURE_DEFAULT_PASSWD_ALGO="sha512"
# CONFIG_BUSYBOX_CONFIG_FEATURE_PASSWD_WEAK_CHECK is not set
CONFIG_BUSYBOX_CONFIG_FEATURE_STAT_FILESYSTEM=y
CONFIG_BUSYBOX_CONFIG_FEATURE_STAT_FORMAT=y
CONFIG_BUSYBOX_CONFIG_SHA512SUM=y
CONFIG_BUSYBOX_CONFIG_STAT=y
CONFIG_LLDPD_WITH_CDP=y
CONFIG_LLDPD_WITH_CUSTOM=y
Expand All @@ -18,89 +18,53 @@ CONFIG_LUA_ECO_OPENSSL=y
# CONFIG_LUA_ECO_WOLFSSL is not set
CONFIG_OPENSSH_LIBFIDO2=y
CONFIG_OPENSSL_ENGINE=y
CONFIG_OPENSSL_OPTIMIZE_SPEED=y
CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM=y
CONFIG_OPENSSL_WITH_ASM=y
CONFIG_OPENSSL_WITH_CHACHA_POLY1305=y
CONFIG_OPENSSL_WITH_CMS=y
CONFIG_OPENSSL_WITH_DEPRECATED=y
CONFIG_OPENSSL_WITH_ERROR_MESSAGES=y
CONFIG_OPENSSL_WITH_NPN=y
CONFIG_OPENSSL_WITH_PSK=y
CONFIG_OPENSSL_WITH_SRP=y
CONFIG_OPENSSL_WITH_SSE2=y
CONFIG_OPENSSL_WITH_TLS13=y
CONFIG_PACKAGE_apinger=y
CONFIG_PACKAGE_bash=y
# CONFIG_PACKAGE_dnsmasq is not set
# CONFIG_PACKAGE_dropbear is not set
# CONFIG_PACKAGE_firewall4 is not set
CONFIG_PACKAGE_iperf3=y
# CONFIG_PACKAGE_jansson is not set
CONFIG_PACKAGE_jq=y
CONFIG_PACKAGE_kmod-ipt-core=y
CONFIG_PACKAGE_kmod-nf-ipt=y
CONFIG_PACKAGE_kmod-usb-serial=y
CONFIG_PACKAGE_kmod-usb-serial-ftdi=y
CONFIG_PACKAGE_kmod-usb-serial-pl2303=y
CONFIG_PACKAGE_libbz2=y
# CONFIG_PACKAGE_kmod-nft-fib is not set
CONFIG_PACKAGE_libcap=y
CONFIG_PACKAGE_libcbor=y
CONFIG_PACKAGE_libestr=y
CONFIG_PACKAGE_libevdev=y
CONFIG_PACKAGE_libevent2=y
CONFIG_PACKAGE_libfastjson=y
CONFIG_PACKAGE_libffi=y
CONFIG_PACKAGE_libfido2=y
CONFIG_PACKAGE_libiperf3=y
CONFIG_PACKAGE_libiwinfo-lua=y
CONFIG_PACKAGE_liblua=y
# CONFIG_PACKAGE_libmnl is not set
CONFIG_PACKAGE_libncurses=y
CONFIG_PACKAGE_libnetsnmp=y
# CONFIG_PACKAGE_libnftnl is not set
CONFIG_PACKAGE_libopenssl=y
CONFIG_PACKAGE_libpcap=y
CONFIG_PACKAGE_libpci=y
CONFIG_PACKAGE_libpcre=y
CONFIG_PACKAGE_libpopt=y
CONFIG_PACKAGE_libpython3=y
CONFIG_PACKAGE_libreadline=y
CONFIG_PACKAGE_librrd1=y
CONFIG_PACKAGE_librt=y
CONFIG_PACKAGE_libubus-lua=y
CONFIG_PACKAGE_libuci-lua=y
# CONFIG_PACKAGE_libucode is not set
CONFIG_PACKAGE_libudev-zero=y
CONFIG_PACKAGE_libuuid=y
CONFIG_PACKAGE_lldpd=y
# CONFIG_PACKAGE_logd is not set
CONFIG_PACKAGE_logrotate=y
CONFIG_PACKAGE_lua=y
# CONFIG_PACKAGE_nftables-json is not set
# CONFIG_PACKAGE_odhcpd-ipv6only is not set
CONFIG_PACKAGE_openssh-client=y
CONFIG_PACKAGE_openssh-client-utils=y
CONFIG_PACKAGE_openssh-keygen=y
CONFIG_PACKAGE_openssh-server=y
CONFIG_PACKAGE_python3-base=y
CONFIG_PACKAGE_python3-light=y
CONFIG_PACKAGE_rrdtool1=y
CONFIG_PACKAGE_rsyslog=y
CONFIG_PACKAGE_tcpdump=y
CONFIG_PACKAGE_terminfo=y
CONFIG_PACKAGE_zabbix-agentd=y
CONFIG_PACKAGE_zabbix-extra-mac80211=y
CONFIG_PACKAGE_zabbix-extra-network=y
CONFIG_PACKAGE_zabbix-extra-wifi=y
# CONFIG_PACKAGE_ucode is not set
CONFIG_PACKAGE_zlib=y
CONFIG_PCRE_JIT_ENABLED=y
CONFIG_PACKAGE_jansson=y
CONFIG_PACKAGE_kmod-nft-fib=y
CONFIG_PACKAGE_libmnl=y
CONFIG_PACKAGE_libnftnl=y
CONFIG_PACKAGE_libucode=y
CONFIG_PACKAGE_ucode=y
CONFIG_PACKAGE_ucode-mod-fs=y
# CONFIG_PACKAGE_ucode-mod-math is not set
# CONFIG_PACKAGE_ucode-mod-nl80211 is not set
# CONFIG_PACKAGE_ucode-mod-resolv is not set
# CONFIG_PACKAGE_ucode-mod-rtnl is not set
# CONFIG_PACKAGE_ucode-mod-struct is not set
CONFIG_PACKAGE_ucode-mod-ubus=y
CONFIG_PACKAGE_ucode-mod-uci=y
# CONFIG_PACKAGE_ucode-mod-uloop is not set
CONFIG_OPENSSL_WITH_SSE2=y
25 changes: 25 additions & 0 deletions openwrt/configs/mt7622-generic.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# CONFIG_PACKAGE_kmod-ata-ahci-mtk is not set
# CONFIG_PACKAGE_kmod-ata-core is not set
# CONFIG_PACKAGE_kmod-bluetooth is not set
# CONFIG_PACKAGE_kmod-btmtkuart is not set
# CONFIG_PACKAGE_kmod-crypto-ecb is not set
# CONFIG_PACKAGE_kmod-crypto-ecdh is not set
# CONFIG_PACKAGE_kmod-crypto-kpp is not set
# CONFIG_PACKAGE_kmod-hid is not set
# CONFIG_PACKAGE_kmod-input-core is not set
# CONFIG_PACKAGE_kmod-input-evdev is not set
# CONFIG_PACKAGE_kmod-lib-crc16 is not set
# CONFIG_PACKAGE_kmod-scsi-core is not set
# CONFIG_PACKAGE_mt7622bt-firmware is not set
# CONFIG_PACKAGE_u-boot-mt7622_rfb1 is not set
CONFIG_DRIVER_11AX_SUPPORT=y
CONFIG_KERNEL_RELAY=y
CONFIG_PACKAGE_kmod-mt7915e=y
CONFIG_PACKAGE_kmod-thermal=y
CONFIG_PACKAGE_librt=y
CONFIG_PACKAGE_libuuid=y
CONFIG_TARGET_DEVICE_mediatek_mt7622_DEVICE_mediatek_mt7622-rfb1-ubi=y
CONFIG_TARGET_MULTI_PROFILE=y
CONFIG_TARGET_mediatek=y
CONFIG_TARGET_mediatek_mt7622=y
CONFIG_WPA_MBO_SUPPORT=y
3 changes: 3 additions & 0 deletions openwrt/configs/x86-generic.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_TARGET_x86=y
CONFIG_TARGET_x86_generic=y
CONFIG_TARGET_x86_generic_DEVICE_generic=y
99 changes: 82 additions & 17 deletions openwrt/docs/BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ Make sure you have the prereq pkgs for the [Openwrt Image Builder](https://openw
To use this part of the git repo you will need the following pkgs:
- git >= 1.8.2
- git-lfs
- gomplate >= 3.2.0
- gomplate >= 3.11.0
- Docker (Optional)
- Nixpkgs (Optional)

### Gomplate

Expand Down Expand Up @@ -90,29 +91,38 @@ into the Openwrt build

### Adding new packages

#### common.config

Leverage the existing `diffconfig` via the `Makefile`:

```
make config
cd build/source-<SHA>/
make menuconfig
TARGET=x86 make config menuconfig
```
> This assumes the additional packages are common to all architectures if not change TARGET
> to specific board arch
At this point you can add any additional pkgs youd like. Afterwhich its time
to save them back to the `diffconfig` using the makefile and then copy them
Save pkgs back to common.config with `diffconfig` using the Makefile and then copy them
to the commonconfig:

```
make diffconfig commonconfig
TARGET=x86 make commonconfig
```

At which point you should have a diff in git which can then be tested against a new
build of the img

### Updating target info
#### mt7622-generic.config

Will use mt7622 as an example but this will work for any other arch we support:

```
TARGET=mt7622 make config menuconfig
```

After adding the specific mt7622 arch packages:

This is similar to `Adding a new package` however after running `menuconfig` go back to the Makefile in `openwrt`
and run:
```
make diffconfig targetconfig
TARGET=mt7622 make targetconfig
```

### Update openwrt/opkg
Expand All @@ -127,24 +137,23 @@ After bumping the version of openwrt/opkg make sure to ensure that the configs a
still generated cleanly (no diff)

```
make config
make menuconfig
TARGET=x86 make config menuconfig
```
> Ensure the selections in menuconfig are what your expecting
If it looks good save them back to `config/` using:

```
make diffconfig commonconfig targetconfig
TARGET=x86 make commonconfig targetconfig
```
> This generates the diff of the base config, then we split it out
> into the common components and last its arch target configs
Repeat this for `TARGET=ipq806x`
Repeat this for `TARGET=ar71xx` and `TARGET=mt7622`

```
TARGET=ipq806x make config
TARGET=ipq806x make diffconfig commonconfig targetconfig
TARGET=mt7622 make config menuconfig
TARGET=mt7622 make commonconfig targetconfig
```

### Build Identity
Expand Down Expand Up @@ -212,3 +221,59 @@ x 2.6.32, with debug_info, not stripped
> Note: `mkhash` will exist but be unable to run and fail with the following `No such file or directory`
`make clean-all` and rerun inside the local environment should fix it

### Config generation process

Assuming we are starting from no existing `.config`. Lets generate the x86 config first since its
the most generic (no specific drivers or modules):

```
cd <build source>
rm -f *.config
```

If you already have a true common config (meaning no specific arch or arch packages inside) you can copy it in:

```
cp $(git root)/openwrt/configs/common.config ./.config
```

Or create a new one:

```
make defconfig
```
> Set target to `x86/generic`
Install only packages which are utilities and non arch specific things. We dont want the hardware packages to pollute the common.config. When youve got all of it selected you can then create
the `common.config`

```
./scripts/diffconfig.sh | tee .diffconfig | grep -v CONFIG_TARGET > $(git root)/openwrt/configs/common.config
```

```
comm -23 <(sort ./.diffconfig) <(sort $(git root)/openwrt/configs/common.config) > $(git root)/openwrt/configs/x86-generic.config
```

Now we have the `common.config` and `x86-generic.config`. To add in a specific board:

```
cd <build source>
cat $(git root)/openwrt/configs/common.config > ./.config
cat $(git root)/openwrt/configs/x86_generic.config >> ./.config
```

Run `make menuconfig` and change the arch from x86 to target arch:

```
./scripts/diffconfig.sh | tee .diffconfig | grep -v CONFIG_TARGET > $(git root)/openwrt/configs/common.config
```

```
comm -23 <(sort ./.diffconfig) <(sort $(git root)/openwrt/configs/common.config) > $(git root)/openwrt/configs/mt7622-generic.config
```
> Assuming mt7622 is our target arch
Thats it now you should have a generic config and a arch specific config going forward. The majority of these steps are taken care of by the Makefile in the `openwrt` dir but in the cases where
we need to start fresh this has been time consuming to recall.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 81faac3

Please sign in to comment.