halmartin / meraki-builder

Scripts and tools to assemble firmware images for various Meraki MS switches and MX routers
GNU General Public License v3.0
77 stars 17 forks source link

add script to update firmware #28

Closed hall closed 1 year ago

hall commented 1 year ago

Had success with manually executing the steps listed in #21 and figured I'd give a shot at creating a script for it. I've only thus far run this with the last command removed and the previous 3 prefixed with echo (so as to not actually do anything). But the output seems reasonable and if there aren't are large changes you'd recommend, I'll run it as-is and validate that it does the right thing.

With no file:

/tmp # ./fw_upgrade 
error: must pass path to firmware bin or squashfs
usage: ./fw_upgrade ./path/to/firmware.bin

With a bin file:

/tmp # ./fw_upgrade postmerkOS-20221115.bin 
8+0 records in
8+0 records out
killall chrony syslogd klogd uhttpd
./flash_erase /dev/mtd3 0 0
./busybox dd if=/tmp/squashfs.EmUs3g of=/dev/mtdblock3 bs=65535 conv=fsync

With a squashfs file:

/tmp # ./fw_upgrade rootfs.squashfs 
killall chrony syslogd klogd uhttpd
./flash_erase /dev/mtd3 0 0
./busybox dd if=rootfs.squashfs of=/dev/mtdblock3 bs=65535 conv=fsync

With an unknown file:

/tmp # ./fw_upgrade squashfs.khtwCf 
error: cannot determine input filetype; must have .bin or .squashfs suffix
halmartin commented 1 year ago

Thanks for taking the initiative to open this PR :smile:

The fw_upgrade script you wrote was good, but lacked a lot of safety checks that I feel are necessary if users are going to blindly run a script to upgrade the firmware. Therefore I'm going to close this and open a new PR with a heavily revised upgrade script.

I also don't really want to update the README to include flashing instructions which are only applicable to one device family (MS220) when the repo contains buildroot overlays for multiple devices.

In light of this, I'm going to start a wiki on the project with pages for each supported device.

halmartin commented 1 year ago

New PR is #32