PublicNotes on Nostr: #### Open tasks - [ ] investigate [support for other ...
#### Open tasks
- [ ] investigate [support for other devices](https://github.com/OpenTollGate/tollgate-sdk/commit/1a9718556dbe8b6cecc36714d7982986862d27ef) - [testing required](https://nostrudel.ninja/#/n/nevent1qqste4adj6hxshyusg7c98qxx5lnpghpzedr2lpmx4z3z83y4y9wy6qpzpmhxue69uhkummnw3ezumt0d5hsz9thwden5te0dehhxarj9ehhsarj9ejx2a30qyt8wumn8ghj7mmjv9hxwetn09hxxtn5v43kstcrqsqqqqqpqgs04e59dy6q87zzvg868rufut7lc8kqh9w0ej42rxdu3lavkukjapqcjrqnw)
- [x] Builds for both GL-AR300m and GL-MT3000 with [this change](https://github.com/OpenTollGate/custom-nostr-feed/commit/278cf417b3b27298b8b1ea9fc116177dd227eb71#diff-add219057bcf13ad46b272dc8b0b41a32891c92e81acd8f8fcf28837a56eeefa)
- [x] Fixed `GOOS` and `GOARCH`
- [x] ready to add [our other go packages](https://njump.me/nevent1qqsfr7cv90sr7u00k4967yfucce576zc4892dt9qu5j6rpamwjw4xjgppemhxue69uhkummn9ekx7mp0qgswmfau3q22zvunk4etqh97aznddp60rwuq3ghcfnlrn9xnm7vy6xgrqsqqqqqp9vk9a5)
- [x] build all packages from custom feed
- [x] no longer require that the user specifies which package to build as a CLI argument to `build-firmeware`
- [x] Automate [upload to blossom](https://njump.me/nevent1qqsramr2agk02gm7zvefvs4myl9yjlx88mh8f7t69g554xsztad4znspzpmhxue69uhkummnw3ezumt0d5hsyg86u6zkjdqrlppxyrar37y79l0urmqtjh8ue24pnx7gl7ktwtfwsspsgqqqqqqs8vu68v) server
- [x] Facing [issues](https://njump.me/nevent1qqsf8xf4r7td2halxe7kgkppc66jw06tjlmjq8h34uxlxmlp3rlw35spz4mhxue69uhkummnw3ezummcw3ezuer9wchs4f943e) with `sattelite.earth`
- [x] uploads to other public blossom servers fine
- [x] created [events](https://njump.me/nevent1qqs90s57k22ktsf8vcmdks2x030xrxn64h9cctjfh9lpl77n9kqnuqgpzpmhxue69uhkummnw3ezumt0d5hsyg8d577gs99pxwfm2u4stjlw3fkksa83hwqg5tuyel3ejnfalxzdrypsgqqqqqqsn6lf7c) that map commit hashes and binary checksums to blossom servers that store the binaries
- [x] [include all binaries](https://github.com/OpenTollGate/tollgate-image-builder/pull/4) in image
- [x] the binaries are included, but the image seems to be too large sometimes
- [x] figuring out [what the problem is](https://njump.me/nevent1qqsz24ahpxt47c7xv9ehy7kga3qmfed3cjkqljvgslamwnuenmutmmcpzpmhxue69uhkummnw3ezumt0d5hsz9thwden5te0dehhxarj9ehhsarj9ejx2a30qyt8wumn8ghj7mmjv9hxwetn09hxxtn5v43kstcdwre6e) and fixing the user output
- [x] test sysupgrade image on `GL-MT3000`
- [x] Updated `init.d`, waiting for OS upgrade to complete so that I can resolve [this error](https://njump.me/nevent1qqstv0dsr0tvezmuurydelwnzj7n2emjyecg9a0lp8gcuhwft32fnqcpzpmhxue69uhkummnw3ezumt0d5hsz9thwden5te0dehhxarj9ehhsarj9ejx2a30qyt8wumn8ghj7mmjv9hxwetn09hxxtn5v43kstcrae7kt)
- [ ] Test `ipks` on GL-AR300m
- [ ] Perhaps there is an issue with the arch?
`GOOS=linux GOARCH=mips CGO_ENABLED=0 go build -ldflags="-s -w"`
**Confirmed:**
```
root@GL-AR300M:/tmp# opkg install whoami.ipk
Unknown package 'tollgate-module-whoami-go'.
Collected errors:
* pkg_hash_check_unresolved: cannot find dependency golang for tollgate-module-whoami-go
* pkg_hash_fetch_best_installation_candidate: Packages for tollgate-module-whoami-go found, but incompatible with the architectures configured
* opkg_install_cmd: Cannot install package tollgate-module-whoami-go.
```
- [ ] Perhaps [this](
) is progressquoting nevent1q…mgl2## Looks like progress (finally)
Commit `3197f918d2850799887a91a19e1ee9f240717dad`
As you can see below, it no longer says that whoami has the wrong architecture.
```
root@GL-AR300M:/tmp# wget https://github.com/OpenTollGate/tollgate-sdk/releases/download/t
est_arch/tollgate-module-whoami-go_0.1-1_mips_24kc.ipk
Downloading ' https://github.com/OpenTollGate/tollgate-sdk/releases/download/test_arch/tollgate-module-whoami-go_0.1-1_mips_24kc.ipk'
Connecting to 140.82.121.4:443
Redirected to /github-production-release-asset-2e65be/904311377/669e575a-1522-42e2-b016-3320b12b62f8?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=releaseassetproduction%2F20250127%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20250127T180742Z&X-Amz-Expires=300&X-Amz-Signature=2880275209faf79c2b03553e244c090e75b931821dbf1fe31f3ebdfbd4409f91&X-Amz-SignedHeaders=host&response-content-disposition=attachment%3B%20filename%3Dtollgate-module-whoami-go_0.1-1_mips_24kc.ipk&response-content-type=application%2Foctet-stream on objects.githubusercontent.com
Writing to '669e575a-1522-42e2-b016-3320b12b62f8?X-Amz-Algorithm=AWS4-HMAC-SHA256'
669e575a-1522-42e2-b 100% |*******************************| 2048k 0:00:00 ETA
Download completed (2097404 bytes)
root@GL-AR300M:/tmp# mv 669e575a-1522-42e2-b016-3320b12b62f8\?X-Amz-Algorithm=AWS4-HMAC-SH
A256 whoami.ipk
root@GL-AR300M:/tmp# opkg install whoami.ipk
Installing tollgate-module-whoami-go (0.1-1) to root...
Collected errors:
* verify_pkg_installable: Only have 116kb available on filesystem /overlay, pkg tollgate-module-whoami-go needs 2053
* opkg_install_cmd: Cannot install package tollgate-module-whoami-go.
```
I intend to install a fresh OpenWRT image on the router to make space and then see if I can install the `whoami` module..
- [ ] Generate an image successfully without any of the go stuff
- [ ] Maybe I should have been testing on the router with the external antennas. Maybe these routers [are different](
)..quoting nevent1q…dwpk```
Writing to '6051c63e-6c7c-41fa-9ae6-509e216dbcfa?X-Amz-Algorithm=AWS4-HMAC-SHA256'
6051c63e-6c7c-41fa-9 100% |*******************************| 7040k 0:00:00 ETA
Download completed (7209781 bytes)
root@GL-AR300M:/tmp# sysupgrade -n 6051c63e-6c7c-41fa-9ae6-509e216dbcfa\?X-Amz-Algorithm=A
WS4-HMAC-SHA256
Mon Jan 27 19:54:18 UTC 2025 upgrade: Device glinet,gl-ar300m-nor not supported by this image
Mon Jan 27 19:54:18 UTC 2025 upgrade: Supported devices: glinet,gl-ar300m16 gl-ar300m
Image check failed.
```
- [ ] Confirmed the distinction between [nand and nor ](
)seems to be part of the problem.quoting nevent1q…vu8a## Question
```
root@GL-AR300M:/tmp# sysupgrade -n 6051c63e-6c7c-41fa-9ae6-509e216dbcfa\?X-Amz-Algorithm=AWS4-HMAC-SHA256
Mon Jan 27 20:06:50 UTC 2025 upgrade: Device glinet,gl-ar300m-nor not supported by this image
Mon Jan 27 20:06:50 UTC 2025 upgrade: Supported devices: glinet,gl-ar300m16 gl-ar300m
Image check failed.
```
I'm using the following script to build for the `glar300m`, but I seem to have multiple similar devices as you can see in the error message above.
```
-15-Gen6:~/TollGate/tollgate-image-builder$ cat build-firmware
#!/bin/bash
set -e
set -x
# Install packages if needed
# sudo apt install -y gawk
# sudo apt-get install -y coreutils
# Build openwrt image
MODEL=$1
VERSION=23.05.3
BUILDDIR=/tmp/openwrt-build
BASE_PACKAGES=" \
base-files \
busybox \
ca-bundle \
dnsmasq \
dropbear \
firewall4 \
fstools \
kmod-gpio-button-hotplug \
kmod-leds-gpio \
kmod-nft-offload \
libc \
libgcc \
libustream-mbedtls \
logd \
mtd \
netifd \
nftables \
odhcp6c \
opkg \
ppp \
ppp-mod-pppoe \
procd \
procd-seccomp \
procd-ujail \
swconfig \
uci \
uclient-fetch \
urandom-seed \
urngd \
openssh-sftp-server \
opennds \
travelmate \
luci-app-travelmate \
curl \
jshn \
jsonfilter \
rpcd \
rpcd-mod-rpcsys \
"
# opennds: our captive portal dependency (for ndsctl)
# travelmate: lets upstream captive portals through the firewall for user to click ok
# For the gl-ar300m case, modify the EXTRA_PACKAGES:
case $MODEL in
"gl-mt300n-v2")
PLATFORM=ramips
TYPE=mt76x8
TARGET_DEVICE=ramips-mt76x8
PROFILE=glinet_gl-mt300n-v2
EXTRA_PACKAGES="\
uboot-envtools \
watchcat \
luci \
luci-ssl \
" # opennds \
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
"
;;
"gl-ar300m")
PLATFORM=ath79
TYPE=generic
TARGET_DEVICE=ath79-generic
PROFILE=glinet_gl-ar300m16
EXTRA_PACKAGES="\
uboot-envtools \
kmod-usb2 \
kmod-usb-core \
kmod-usb-storage \
luci \
luci-ssl \
iwinfo \
wpad-wolfssl \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
-wpad-basic-wolfssl \
-wpad-basic-mbedtls \
-wpad-mini \
"
;;
"gl-mt3000")
PLATFORM=mediatek
TYPE=filogic
TARGET_DEVICE=mediatek-filogic
PROFILE=glinet_gl-mt3000
EXTRA_PACKAGES="\
kmod-usb2 \
kmod-usb-core \
kmod-usb-storage \
luci \
luci-ssl \
iwinfo \
wpad-wolfssl \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
-wpad-basic-wolfssl \
-wpad-basic-mbedtls \
-wpad-mini \
"
;;
"gl-mt6000")
PLATFORM=mediatek
TYPE=filogic
TARGET_DEVICE=mediatek-filogic
PROFILE=glinet_gl-mt6000
EXTRA_PACKAGES="\
kmod-usb2 \
kmod-usb-core \
kmod-usb-storage \
luci \
luci-ssl \
iwinfo \
wpad-wolfssl \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
-wpad-basic-wolfssl \
-wpad-basic-mbedtls \
-wpad-mini \
"
;;
"gl-e750")
VERSION="snapshot"
PLATFORM=ath79
TYPE=nand
TARGET_DEVICE=ath79-nand
PROFILE=glinet_gl-e750
EXTRA_PACKAGES="\
kmod-usb2 \
kmod-usb-core \
kmod-usb-storage \
uboot-envtools \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
"
;;
"archer_mr200")
PLATFORM=ramips
TYPE=mt7620
TARGET_DEVICE=ramips-mt7620
PROFILE=tplink_archer-mr200 # Update to the correct profile name
EXTRA_PACKAGES="\
kmod-usb2 \
kmod-usb-core \
luci \
luci-ssl \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
"
;;
*)
echo "specify build target (gl-mt300n-v2, gl-ar300m, gl-mt3000, gl-mt6000, gl-e750, or archer_mr200)"
exit 1
;;
esac
if [ ! -d ${BUILDDIR} ] ; then
mkdir ${BUILDDIR}
fi
# the need for $TYPE and $TARGET_DEVICE seems dumb but it helps get aroudn the problem of downloads ↓↓↓↓↓↓↓
# http://downloads.openwrt.org/releases/18.06.1/targets/ath79/generic/openwrt-imagebuilder-18.06.1-ath79-generic.Linux-x86_64.tar.xz
#http://downloads.openwrt.org/releases/18.06.1/targets/ipq40xx/generic/openwrt-imagebuilder-18.06.1-ipq40xx.Linux-x86_64.tar.xz
if [ "$VERSION" = "snapshot" ]; then
IMAGEBUILDER_NAME="openwrt-imagebuilder-${PLATFORM}-${TYPE}.Linux-x86_64"
DOWNLOAD_URL="https://downloads.openwrt.org/snapshots/targets/${PLATFORM}/${TYPE}/${IMAGEBUILDER_NAME}.tar.zst"
ARCHIVE_EXT="tar.zst"
else
IMAGEBUILDER_NAME="openwrt-imagebuilder-${VERSION}-${TARGET_DEVICE}.Linux-x86_64"
DOWNLOAD_URL="https://downloads.openwrt.org/releases/${VERSION}/targets/${PLATFORM}/${TYPE}/${IMAGEBUILDER_NAME}.tar.xz"
ARCHIVE_EXT="tar.xz"
fi
if [ ! -d ${BUILDDIR}/${IMAGEBUILDER_NAME} ] ; then
if [ ! -f ${BUILDDIR}/${IMAGEBUILDER_NAME}.${ARCHIVE_EXT} ]; then
(cd ${BUILDDIR} && curl -C - -O ${DOWNLOAD_URL})
fi
if [ "$VERSION" = "snapshot" ]; then
tar --zstd -xf ${BUILDDIR}/${IMAGEBUILDER_NAME}.${ARCHIVE_EXT} -C ${BUILDDIR}/
else
tar xfJ ${BUILDDIR}/${IMAGEBUILDER_NAME}.${ARCHIVE_EXT} -C ${BUILDDIR}/
fi
fi
COMBINED_PACKAGE_LIST="`echo ${REMOVED_PACKAGES}` `echo ${BASE_PACKAGES}` `echo ${EXTRA_PACKAGES}`"
echo "Combined package list ${COMBINED_PACKAGE_LIST}"
CORES=$(nproc)
# Add these lines just before the final make command
echo "Copying custom files..."
cp -r $(pwd)/files ${BUILDDIR}/${IMAGEBUILDER_NAME}/
# Determine architecture based on platform/type
case "${PLATFORM}-${TYPE}" in
"ath79-generic")
BLOSSOM_ARCH="mips_24kc"
;;
"mediatek-filogic")
BLOSSOM_ARCH="aarch64_cortex-a53"
;;
*)
echo "Unsupported platform-type combination for blossom downloads: ${PLATFORM}-${TYPE}"
exit 1
;;
esac
# Create packages directory in image builder
PACKAGES_DIR="${BUILDDIR}/${IMAGEBUILDER_NAME}/packages/local"
mkdir -p "${PACKAGES_DIR}"
# Download IPK files using blossom_download.py
echo "Downloading IPK files for architecture ${BLOSSOM_ARCH}..."
python3 $(pwd)/blossom_download.py "${PACKAGES_DIR}" "${BLOSSOM_ARCH}"
# Generate package index
echo "Generating package index..."
(cd ${BUILDDIR}/${IMAGEBUILDER_NAME} && \
sudo bash -c 'mkhash() { if [ "$1" = "sha256" ]; then sha256sum "$2" | cut -d" " -f1; else sha256sum "$1" | cut -d" " -f1; fi; }; \
export -f mkhash; \
export MKHASH=mkhash; \
./scripts/ipkg-make-index.sh packages/local > packages/local/Packages && \
gzip -9c packages/local/Packages > packages/local/Packages.gz')
# Add tollgate packages to the package list
TOLLGATE_PACKAGES="\
"
# tollgate-module-whoami-go \
# Update the combined package list to include tollgate packages
COMBINED_PACKAGE_LIST="${COMBINED_PACKAGE_LIST} ${TOLLGATE_PACKAGES}"
# Replace the build command and error checking with:
echo "Building ${VERSION} using ${CORES} cores..."
BUILD_OUTPUT=$(cd ${BUILDDIR}/${IMAGEBUILDER_NAME} && \
sudo make -j${CORES} image PROFILE="$PROFILE" \
PACKAGES="$COMBINED_PACKAGE_LIST" \
FILES="${BUILDDIR}/${IMAGEBUILDER_NAME}/files" 2>&1 | tee >(cat))
echo "${BUILD_OUTPUT}"
# Check for common error patterns
if echo "$BUILD_OUTPUT" | grep -q "Failed to open firmware file"; then
echo "Error: Build failed - firmware file creation error"
exit 1
fi
if echo "$BUILD_OUTPUT" | grep -q "No such file or directory"; then
echo "Error: Build failed - missing files"
exit 1
fi
# Extract the filesystem size from the output
FILESYSTEM_SIZE=$(echo "$BUILD_OUTPUT" | grep "Filesystem size" | grep -o '[0-9.]\+ Kbytes' | awk '{print $1/1024}')
# After the build command, add:
OUTPUT_FILE="${BUILDDIR}/${IMAGEBUILDER_NAME}/bin/targets/${PLATFORM}/${TYPE}/openwrt-${VERSION}-${TARGET_DEVICE}-${PROFILE}-squashfs-sysupgrade.bin"
if [ ! -f "$OUTPUT_FILE" ]; then
echo "Error: Build failed - output file not created"
exit 1
fi
echo "Build successful! Firmware image created at:"
echo "Image size (${FILESYSTEM_SIZE}MB)"
echo "${OUTPUT_FILE}"
echo
echo "To deploy, use:"
echo "scp -O ${BUILDDIR}/${IMAGEBUILDER_NAME}/bin/targets/${PLATFORM}/${TYPE}/openwrt-${VERSION}-${TARGET_DEVICE}-${PROFILE}-squashfs-sysupgrade.bin root@:/tmp"
```
Please add a section for `glinet,gl-ar300m-nor` to the above script without removing whats already there, since that might be useful for one of the other routers that I have..
--------
## Answer
I'll add a new case for the `glinet,gl-ar300m-nor` device. You'll need to add this within the case statement, alongside the other device configurations:
```bash
"gl-ar300m-nor")
PLATFORM=ath79
TYPE=generic
TARGET_DEVICE=ath79-generic
PROFILE=glinet_gl-ar300m-nor
EXTRA_PACKAGES="\
uboot-envtools \
kmod-usb2 \
kmod-usb-core \
kmod-usb-storage \
luci \
luci-ssl \
iwinfo \
wpad-wolfssl \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
-wpad-basic-wolfssl \
-wpad-basic-mbedtls \
-wpad-mini \
"
;;
```
Also, you'll need to update the usage message in the default case (*) to include the new option. Change this line:
```bash
*)
echo "specify build target (gl-mt300n-v2, gl-ar300m, gl-mt3000, gl-mt6000, gl-e750, archer_mr200, gl-ar300m-nor)"
exit 1
;;
```
The configuration for `gl-ar300m-nor` is similar to the regular `gl-ar300m` since they share the same basic hardware, but they differ in their flash memory configuration. The "nor" variant uses NOR flash memory instead of NAND flash memory. You can now build for this specific variant by running:
```bash
./build-firmware gl-ar300m-nor
```
## Followup
```
make: *** [Makefile:260: image] Error 2
make: *** [Makefile:260: image] Error 2'
+ grep -q 'No such file or directory'
++ echo 'Profile "glinet_gl-ar300m-nor" does not exist!
Profile "glinet_gl-ar300m-nor" does not exist!
Use "make info" to get a list of available profile names.
Use "make info" to get a list of available profile names.
```
As you can see above, my build script still seems to be wrong. Here is some related information from the openwrt page about this router:
```
### Info[](https://openwrt.org/toh/gl.inet/gl-ar300m#info)
|Brand|Model|Version|Device Type|Availability|Supported Since Commit|Supported Since Rel|Supported Current Rel|Unsupported Functions|Bootloader|Target|CPU MHz|Flash MB|RAM MB|Switch|Ethernet 100M ports|Ethernet 1Gbit ports|Comments network ports|Modem|VLAN|WLAN 2.4GHz|WLAN 5.0GHz|WLAN Hardware|WLAN Comments|Detachable Antennas|USB ports|SATA ports|Comments USB SATA ports|Serial|JTAG|LED count|Button count|Power Supply||OWrt Forum Topic URL|WikiDevi URL|OEM Device Homepage URL|Firmware OEM Stock URL|Firmware OpenWrt Install URL|Firmware OpenWrt Upgrade URL|Comments|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|GL.iNet|GL-AR300M|v1.4.0|WiFi Router|Available 2020|`[d963ddf0424a](https://git.lede-project.org/?p=source.git;a=commit;h=d963ddf0424a551e5fadd561c934bfdb5d198764)`|[17.01.0](https://openwrt.org/releases/17.01.0 "releases:17.01.0")|[23.05.5](https://openwrt.org/releases/23.05.5 "releases:23.05.5")|NAND flash not supported until after 19.07.x, must be forced into booting from NOR flash|U-Boot|[ar71xx-ath79](https://openwrt.org/docs/techref/targets/ar71xx-ath79 "docs:techref:targets:ar71xx-ath79")|650|16, 128NAND|128|Qualcomm Atheros QCA9531|2|-||-|Yes|b/g/n|-|Qualcomm Atheros QCA9531|"-EXT" suffix has 2 detachable Antennas (RP-SMA)|-|1x 2.0|-||Yes|No|3|2|5 VDC, 2.0 A (µUSB)|[Edit](https://openwrt.org/toh/hwdata/gl.inet/gl.inet_gl-ar300m "toh:hwdata:gl.inet:gl.inet_gl-ar300m")|[Discourse: gl-ar300m-sysupgrade-problem](https://forum.openwrt.org/t/gl-ar300m-sysupgrade-problem/1812), [Discourse: howto-upgrade-the-preinstalled-openwrt-lede-17-01-firmware-in-the-gl-ar300m-router](https://forum.openwrt.org/t/howto-upgrade-the-preinstalled-openwrt-lede-17-01-firmware-in-the-gl-ar300m-router/21129)|[WikiDevi: GL.iNet_GL-AR300M](https://wikidevi.wi-cat.ru/GL.iNet_GL-AR300M)|[gl-inet.com](https://www.gl-inet.com/products/gl-ar300m/)|[OEM Firmware](https://dl.gl-inet.com/?model=ar300m)|[Factory image](https://downloads.openwrt.org/releases/23.05.5/targets/ath79/nand/)|[Sysupgrade image](https://downloads.openwrt.org/releases/23.05.5/targets/ath79/nand/)|Flashing to the 128MB NAND flash is supported in Snapshot ath79 at time of writing, removable external antennas on "ext" variant|
|GL.iNet|GL-AR300M16||WiFi Router|Available 2024|`[b591cabd3989](https://git.openwrt.org/?p=openwrt/openwrt.git;a=commit;h=b591cabd3989b44cfaf15248af9e55a0300a9c0a)`|[21.02.0](https://openwrt.org/releases/21.02.0 "releases:21.02.0")|[23.05.5](https://openwrt.org/releases/23.05.5 "releases:23.05.5")||U-Boot|[ath79](https://openwrt.org/docs/techref/targets/ath79 "docs:techref:targets:ath79")|650|16|128|Qualcomm QCA9531|2|-||-|Yes|b/g/n|-|Qualcomm QCA9531|GL-AR300M16-Ext variant has 2 detachable antennas (RP-SMA)|-|1x 2.0|-||Yes|No|3|2|5V/1A, microUSB|[Edit](https://openwrt.org/toh/hwdata/gl.inet/gl.inet_gl-ar300m16 "toh:hwdata:gl.inet:gl.inet_gl-ar300m16")||[WikiDevi: GL.iNet_GL-AR300M](https://wikidevi.wi-cat.ru/GL.iNet_GL-AR300M)|[gl-inet.com](https://www.gl-inet.com/products/gl-ar300m/)|[OEM Firmware](https://dl.gl-inet.com/router/ar300m16/)|[Factory image](https://downloads.openwrt.org/releases/23.05.5/targets/ath79/generic/openwrt-23.05.5-ath79-generic-glinet_gl-ar300m16-initramfs-kernel.bin)|[Sysupgrade image](https://downloads.openwrt.org/releases/23.05.5/targets/ath79/generic/openwrt-23.05.5-ath79-generic-glinet_gl-ar300m16-squashfs-sysupgrade.bin)||
```
Does this information help to identify what needs to go in the build script?
## Answer
It looks like OpenWrt does not actually define a “glinet_gl-ar300m-nor” profile name. Instead, the NOR version of the GL-AR300M is referred to as “glinet_gl-ar300m16.” So, if you want to build for the device’s NOR flash, you will need a case matching that existing OpenWrt profile.
Below is an example of how you can add a “gl-ar300m-nor” option to your script (so that you can pass “gl-ar300m-nor” on the command line), while internally using the “glinet_gl-ar300m16” profile. Note that you are not removing anything you already have; you’re simply adding a new case for the sake of building the NOR variant:
```bash
"gl-ar300m-nor")
PLATFORM=ath79
TYPE=generic
TARGET_DEVICE=ath79-generic
PROFILE=glinet_gl-ar300m16
EXTRA_PACKAGES="\
uboot-envtools \
kmod-usb2 \
kmod-usb-core \
kmod-usb-storage \
luci \
luci-ssl \
iwinfo \
wpad-wolfssl \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
-wpad-basic-wolfssl \
-wpad-basic-mbedtls \
-wpad-mini \
"
;;
```
Also modify your default usage message to include “gl-ar300m-nor” as an option:
```bash
*)
echo "specify build target (gl-mt300n-v2, gl-ar300m, gl-ar300m-nor, gl-mt3000, gl-mt6000, gl-e750, or archer_mr200)"
exit 1
;;
```
If you invoke your script as:
» ./build-firmware gl-ar300m-nor
it will now use the “glinet_gl-ar300m16” profile (which is the correct NOR-only OpenWrt image for AR300M devices).
## Followup
Ok, now I think I have duplicates. The nor and nand versions both end in `m16`. How can I fix this?
```
"gl-ar300m")
PLATFORM=ath79
TYPE=generic
TARGET_DEVICE=ath79-generic
PROFILE=glinet_gl-ar300m16
EXTRA_PACKAGES="\
uboot-envtools \
kmod-usb2 \
kmod-usb-core \
kmod-usb-storage \
luci \
luci-ssl \
iwinfo \
wpad-wolfssl \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
-wpad-basic-wolfssl \
-wpad-basic-mbedtls \
-wpad-mini \
"
;;
"gl-ar300m-nor")
PLATFORM=ath79
TYPE=generic
TARGET_DEVICE=ath79-generic
PROFILE=glinet_gl-ar300m16
EXTRA_PACKAGES="\
uboot-envtools \
kmod-usb2 \
kmod-usb-core \
kmod-usb-storage \
luci \
luci-ssl \
iwinfo \
wpad-wolfssl \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
-wpad-basic-wolfssl \
-wpad-basic-mbedtls \
-wpad-mini \
"
;;
```
## Answer
Looking at the OpenWrt device info you shared, the NAND version should use the `ath79/nand` target while the NOR version uses `ath79/generic`. Here's how to correctly differentiate between the two versions:
```bash
"gl-ar300m") # NAND version
PLATFORM=ath79
TYPE=nand
TARGET_DEVICE=ath79-nand
PROFILE=glinet_gl-ar300m
EXTRA_PACKAGES="\
uboot-envtools \
kmod-usb2 \
kmod-usb-core \
kmod-usb-storage \
luci \
luci-ssl \
iwinfo \
wpad-wolfssl \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
-wpad-basic-wolfssl \
-wpad-basic-mbedtls \
-wpad-mini \
"
;;
"gl-ar300m-nor") # NOR version (16MB flash)
PLATFORM=ath79
TYPE=generic
TARGET_DEVICE=ath79-generic
PROFILE=glinet_gl-ar300m16
EXTRA_PACKAGES="\
uboot-envtools \
kmod-usb2 \
kmod-usb-core \
kmod-usb-storage \
luci \
luci-ssl \
iwinfo \
wpad-wolfssl \
"
REMOVED_PACKAGES="\
-odhcpd \
-odhcpd-ipv6only \
-wpad-basic-wolfssl \
-wpad-basic-mbedtls \
-wpad-mini \
"
;;
```
The key differences are:
1. NAND version uses `TYPE=nand` and `TARGET_DEVICE=ath79-nand`
2. NAND version uses `PROFILE=glinet_gl-ar300m`
3. NOR version uses `TYPE=generic` and `TARGET_DEVICE=ath79-generic`
4. NOR version uses `PROFILE=glinet_gl-ar300m16`
This should now correctly build for both variants of the router.
- [ ] Ensure that the blossom downloader can distinguish between them correctly based on the hashtags
- [ ] Ensure that sysupgrade binaries can be generated for both nor and nand
- [ ] Try installing the ipk files on the router after flashing it with a binary that doesn't contain any go programs yet
- [ ] Install the `whoami` module manually using the ipk - also test with the `relay` module since the changes to `golang.mk` affect both packages, but the changes to the `relay`'s make file only affect the relay
- [ ] Cry and go back to messing with the Makefile in the SDK if that doesn't work. Note that each package has its own Makefile, and
- [ ] Test `ipks` on GL-MT3000
- [ ] test sysupgrade image on `GL-AR300M`
- [ ] Compare with code that worked on previous commit of main
- [ ] Upload OpenWRT image to blossom as well
- [ ] **make captive portal front-end work again & improve new image -- Working on this one**
- [ ] test the install step of makefiles and use that to configure programs
- [ ] would like to switch to [local golang](https://github.com/OpenTollGate/custom-nostr-feed/blob/9cd211abcfc964f26a900c2bdacefa931be4d051/tollgate-module-relay-go/Makefile#L55-L61) for better reproducibility across build environment, branch: `with_golang_feed`
- [ ] would like to start using actions so that we can use this [runner](nostr:naddr1qqfk67fdwajk26edxvkkjm3dwfjhv6t9wuqsuamnwvaz7tmwdaejumr0dshsyg9mkhw6pc24v7te7p2rgpaacgpn6mcthvc0wfgj4xqulke0p838gupsgqqqw4rsetaqht)
- [ ] Make installer for `ipk` and `sysupgrade` files from blossom