I'm using image builder to build my own images.
I was able to upgrade the default gl.inet to openwrt no problem with my image.
Now I wanted to update that image but nothing works.
I've tried sysupgrade and mtd but nothing works.
I tried 'sysupgrade myimage.bin but it boots me out and comes back with the previous image.
It seems this device is using UBI so I tried but this doesn't work.
sysupgrade -v -n -F -p /tmp/myimage.bin
I also tried mtd -r write myfile.bin firmware
Could not open mtd device: firmware
Can't open device for writing!
# cat /proc/mtd
dev: size erasesize name
mtd0: 00100000 00020000 "BL2"
mtd1: 00080000 00020000 "u-boot-env"
mtd2: 00200000 00020000 "Factory"
mtd3: 00200000 00020000 "FIP"
mtd4: 00040000 00020000 "log"
mtd5: 0f640000 00020000 "ubi"
# ubinfo -a
UBI version: 1
Count of UBI devices: 1
UBI control device major/minor: 10:127
Present UBI devices: ubi0
ubi0
Volumes count: 3
Logical eraseblock size: 126976 bytes, 124.0 KiB
Total amount of logical eraseblocks: 1970 (250142720 bytes, 238.5 MiB)
Amount of available logical eraseblocks: 0 (0 bytes)
Maximum count of volumes 128
Count of bad physical eraseblocks: 0
Count of reserved physical eraseblocks: 40
Current maximum erase counter value: 7
Minimum input/output unit size: 2048 bytes
Character device major/minor: 249:0
Present volumes: 0, 1, 2
Volume ID: 0 (on ubi0)
Type: dynamic
Alignment: 1
Size: 30 LEBs (3809280 bytes, 3.6 MiB)
State: OK
Name: kernel
Character device major/minor: 249:1
-----------------------------------
Volume ID: 1 (on ubi0)
Type: dynamic
Alignment: 1
Size: 129 LEBs (16379904 bytes, 15.6 MiB)
State: OK
Name: rootfs
Character device major/minor: 249:2
-----------------------------------
Volume ID: 2 (on ubi0)
Type: dynamic
Alignment: 1
Size: 1765 LEBs (224112640 bytes, 213.7 MiB)
State: OK
Name: rootfs_data
Character device major/minor: 249:3
I'd like to do it from the command line as usual.
Usually I just upload the image to the router then ssh into it and use sysupgrade.
Am I missing a package or doing this the wrong way?
Try using the standard OpenWrt sysupgrade image (not customized) first... when I upgraded mine, I did it directly from the GL-Inet firmware's GUI upgrade page using the sysupgrade image (and I did not keep settings):
So what image are you using and how are you generating it? It should be a sysupgrade image -- the image builder should always produce a sysupgrade image.
Right, I'm using image builder. I made an image and flashed the device using the gl.inet GUI. My images don't have GUI though as I don't need any GUI stuff.
Today, I updated my image using image builder, used scp to put it on the device then logged into it using ssh. But, I am not able to upgrade it using sysupgrade or mtd.
Sounds ok, sysupgrade does automatic detection of compression, as you can see here:
$ cd /tmp
$ owut download
...
Downloaded https://sysupgrade.openwrt.org/store/.../openwrt-78a4d320d982-x86-64-generic-squashfs-combined-efi.img.gz to /tmp/firmware.bin (26617174B at 50.768 Mbps)
...
$ sysupgrade --test firmware.bin
Mon Sep 16 16:34:47 PDT 2024 upgrade: Image metadata not present
Mon Sep 16 16:34:47 PDT 2024 upgrade: Reading partition table from bootdisk...
Mon Sep 16 16:34:47 PDT 2024 upgrade: Extract boot sector from the image
Mon Sep 16 16:34:47 PDT 2024 upgrade: Reading partition table from image...
$ mv firmware.bin firmware.bin.gz
$ gunzip firmware.bin.gz
$ sysupgrade --test firmware.bin
Mon Sep 16 16:35:09 PDT 2024 upgrade: Image metadata not present
Mon Sep 16 16:35:09 PDT 2024 upgrade: Reading partition table from bootdisk...
Mon Sep 16 16:35:09 PDT 2024 upgrade: Extract boot sector from the image
Mon Sep 16 16:35:09 PDT 2024 upgrade: Reading partition table from image...
sysupgrade does want the image in /tmp and will copy it over, if it's not already there. The --test option should always give output, so that's a preliminary diagnostic that you can apply.
There may be some packages mixed in from other builds. Basically, I ended up with this because I was wanting to remove some things while adding some others but god knows what they were at this point.
I can try but I'm guessing it still won't work. My image is not all that unique, other than also having dhcp client for the interfaces instead of the 192.168.1.1 IP.
So here is what happened. I didn't use -n.
Interestingly, it obviously did get flashed but has no open ports now which means I'll have to use recovery mode.
$ ssh 192.168.192.7
root@192.168.192.7's password:
BusyBox v1.36.1 (2024-09-11 15:47:11 UTC) built-in shell (ash)
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
-----------------------------------------------------
OpenWrt 23.05.3, r23809-234f1a2efa
-----------------------------------------------------
root@mt3000:~# cd /tmp
root@mt3000:/tmp# sysupgrade openwrt-23.05.4-mediatek-filogic-glinet_gl-mt3000-squashfs-sysupgrade.bin
verifying sysupgrade tar file integrity
Tue Sep 17 17:39:37 UTC 2024 upgrade: Saving config files...
Tue Sep 17 17:39:37 UTC 2024 upgrade: Commencing upgrade. Closing all shell sessions.
Command failed: Connection failed
root@mt3000:/tmp# Connection to 192.168.192.7 closed by remote host.
Connection to 192.168.192.7 closed.
[root@dev50 23.05.3-mt3000]# ssh 192.168.192.7
ssh: connect to host 192.168.192.7 port 22: Connection refused
[root@dev50 23.05.3-mt3000]# nmap 192.168.192.7
Starting Nmap 7.95SVN ( https://nmap.org ) at 2024-09-17 10:40 MST
ipToPtr: 192.168.192.7 => 7.192.168.192.in-addr.arpa
Nmap scan report for 192.168.192.7
Host is up (0.00045s latency).
All 1000 scanned ports on 192.168.192.7 are in ignored states.
Not shown: 1000 closed tcp ports (reset)
MAC Address: 90:83:C4:4A:E9:DB (GL Technologies (Hong Kong) Limited)
Nmap done: 1 IP address (1 host up) scanned in 39.31 seconds
[root@dev50 23.05.3-mt3000]# nmap 192.168.192.7
Starting Nmap 7.95SVN ( https://nmap.org ) at 2024-09-17 10:44 MST
ipToPtr: 192.168.192.7 => 7.192.168.192.in-addr.arpa
Nmap scan report for 192.168.192.7
Host is up (0.00045s latency).
All 1000 scanned ports on 192.168.192.7 are in ignored states.
Not shown: 1000 closed tcp ports (reset)
MAC Address: 94:83:C4:4A:E9:DB (GL Technologies (Hong Kong) Limited)
Nmap done: 1 IP address (1 host up) scanned in 39.05 seconds
If your currently installed image drops the ubut-envtools package, and if it is required to run sysupgrade, then you've basically backed yourself into a corner with no upgrade option within the context of the OpenWrt system. You'd have to resort to a lower level method like tftp or whatever the device has available for recovery (I haven't looked to see what the method is, though).
So does this mean that the image flashed?
If you didn't use -n, that means that your previous configuration is still there. So, from failsafe mode, just run firstboot -y && reboot.
I think it did flash because while my IP settings were saved, ssh is no longer open. There are no open ports so I can't ssh into it to run any commands.
My only option at this point would be to try recovery mode.