Hi all.  I submitted a ticket several weeks ago about sysupgrade not preserving the /etc/config directory when it upgrades the software on a UAP-Pro access point.  (https://dev.openwrt.org/ticket/12923)  I'm trying to solve this to contribute back to OpenWRT, but I'm stuck and hoping for some input.

I added a "set -x" to the top of /sbin/sysupgrade so I can see what's really going on.  Here's what (I think) is the important bit:

+ do_upgrade
+ v Performing system upgrade...
+ [ 1 -ge 1 ]
+ echo Performing system upgrade...
Performing system upgrade...
+ type platform_do_upgrade
+ platform_do_upgrade 13022811.uap-pro.sysupgrade.bin
+ ar71xx_board_name
+ local name
+ [ -f /tmp/sysinfo/board_name ]
+ cat /tmp/sysinfo/board_name
+ name=uap-pro
+ [ -z uap-pro ]
+ echo uap-pro
+ local board=uap-pro
+ default_do_upgrade 13022811.uap-pro.sysupgrade.bin
+ sync
+ [ 1 -eq 1 -a -z  ]
+ mtd -j /tmp/sysupgrade.tgz write - firmware
Unlocking firmware ...

Writing from <stdin> to firmware ...  [ ]
+ get_image 13022811.uap-pro.sysupgrade.bin
+ local from=13022811.uap-pro.sysupgrade.bin
+ local conc=
+ local cmd
+ cmd=cat
+ [ -z  ]
+ hexdump -n 2 -e 1/1 "%02x"
+ dd bs=2 count=1
+ eval cat 13022811.uap-pro.sysupgrade.bin
+ cat 13022811.uap-pro.sysupgrade.bin
+ local magic=1985
+ eval cat 13022811.uap-pro.sysupgrade.bin
+ cat 13022811.uap-pro.sysupgrade.bin
Appending jffs2 data from /tmp/sysupgrade.tgz to firmware...
Writing from <stdin> to firmware ...  [w]TRX header not found
Error fixing up TRX header
+ [ 1 -eq 1 -a -n  ]
+ v Upgrade completed
+ [ 1 -ge 1 ]
+ echo Upgrade completed
Upgrade completed

What's confusing me is that it appears that mtd is running twice based on the output (since "Writing from..." is there twice), but I only see it running once.  And when I trace through the code, it only looks like it runs once.  I've spent quite a few hours tracing this through and it's driving me bonkers.  Especially considering the same build of OpenWRT works perfectly fine on a Ubiquiti UniFi AP.

Any thoughts anyone?
Thanks,
--Brian