3748: expose TR181-compliant methods of managing firmware banks
For context, see https://project.iopsys.eu/issues/3748
The overarching goal of this is to expose an asynchronous ubus function upgrade()
for the fwbank
object. The purpose of this is to give the ability to manage the firmware banks of the system (fwbank.dump()
), and install a firmware image on them (fwbank.upgrade()
) as needed.
This MR:
- Improves the robustness the
dump
method of thefwbank
object as well as is possible right now:- Make it initially work again (5a772aae), depend on the system layout helpers (974b6c89), avoid meddling with jshn's internal state (76e968db)
- Implement the
status
field for a given firmware bank (694a5ade). - Move the implementations of the
fwver
field into its own functions (19872a67). The big problem is deciding how and where to store thefwver
(firmware version) fields of both firmware banks; right now the pragmatic decision has been made to store them on the toplevel of both overlay partitions (<overlay>/fwbank_${bank_id}/fwver
) (4a571b06). This will be iterated upon, starting by storing the fwver field in the FIT image, to avoid mounting the other bank's root file system.
- implements the upgrading of a firmware bank with a given image, through the ubus method
fwbank.upgrade()
. This function is implemented asynchronously with the help of thenohup
busybox built-in. (9599fe96) - simplifies the
set_bootbank
method of the ubus object (57f0c85b), as the existing implementation seemed a bit convoluted.
Dependencies
This MR depends on
- the
nohup
utility being compiled with busybox: iopsys!86 (merged) - the sysupgrade lock path being fixed in one place, for the asynchronous
fwbank.upgrade()
method to work well (as the sysupgrade lock is tested): !31 (merged)
Testing and example output
root@iopsys:~# ubus call fwbank upgrade '{"uri":"/tmp/last.pkgtb","auto_activate":"true", "bank_id": 1}'
root@iopsys:~# ubus call fwbank set_bootbank '{"bank":"0"}'
root@iopsys:~# ubus call fwbank dump
{
"bank": [
{
"name": "A",
"id": 0,
"active": true,
"boot": true,
"upgrade": false,
"fwver": "DG400PRIME-A-IOPSYS-6.1.0BETA2-210329_1302",
"swver": "6.1.0BETA2",
"status": "Active"
},
{
"name": "B",
"id": 1,
"active": false,
"boot": false,
"upgrade": true,
"fwver": "DG400PRIME-A-IOPSYS-6.1.0BETA2-210326_1753",
"swver": "6.1.0BETA2",
"status": "Available"
}
]
}
Edited by Ghost User