Skip to content

Instantly share code, notes, and snippets.

@derjohn
Last active December 8, 2022 11:40
Show Gist options
  • Save derjohn/6ceeb50a7fc25e5fd35df513c9a2f1b6 to your computer and use it in GitHub Desktop.
Save derjohn/6ceeb50a7fc25e5fd35df513c9a2f1b6 to your computer and use it in GitHub Desktop.
u-boot fw_setenv WZR-HP-G300NH OpenWRT
cat /proc/mtd
# dev: size erasesize name
# mtd0: 00040000 00020000 "u-boot"
# mtd1: 00020000 00020000 "u-boot-env"
# mtd2: 01f60000 00020000 "firmware"
# mtd3: 00200000 00020000 "kernel"
# mtd4: 01d60000 00020000 "rootfs"
# mtd5: 01a40000 00020000 "rootfs_data"
# mtd6: 00020000 00020000 "user_property"
# mtd7: 00020000 00020000 "art"
cat <<EOF > /etc/fw_env.config
#MTD device name Device offset Env. size Flash sector size
/dev/mtd1 0x40000 0x20000 0x20000
EOF
opkg install kmod-mtd-rw
insmod mtd-rw i_want_a_brick=1
dmesg | grep mtd
# [ 2988.051401] mtd-rw: mtd1: setting writeable flag
fw_printenv tftp_wait
## tftp_wait=4
fw_printenv accept_open_rt_fmt
# accept_open_rt_fmt=1
fw_setenv tftp_wait 5
## Can't open /dev/mtd1: Permission denied
## Error: can't write fw_env to flash
## :-/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment