-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iot2050-module-firmware-update: Add module firmware update
The IOT2050 features a customized external signal module, such as the SM SENS DI. Unlike the standard PLC1200, this module is specifically tailored to the IOT2050's requirements. As a result, it cannot be upgraded within the conventional PLC ecosystem. However, we ensure to provide a method to support firmware upgrades for these custom modules. And the firmware update for the module should not be included with the image. This is because the image becomes too large and cumbersome to release when only the update tool needs to be released. Instead, the module firmware update should be packaged separately in its own Debian package for a more efficient and manageable release process. Signed-off-by: Li Hua Qian <[email protected]>
- Loading branch information
Showing
4 changed files
with
123 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# Copyright (c) Siemens AG, 2024 | ||
# | ||
# Authors: | ||
# Li Hua Qian <[email protected]> | ||
# | ||
# This file is subject to the terms and conditions of the MIT License. See | ||
# COPYING.MIT file in the top-level directory. | ||
# | ||
|
||
header: | ||
version: 14 | ||
|
||
local_conf_header: | ||
no-eio: | | ||
IOT2050_MODULE_FWU = "1" |
76 changes: 76 additions & 0 deletions
76
recipes-app/iot2050-module-firmware-update/files/iot2050-module-firmware-update.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Copyright (c) Siemens AG, 2024 | ||
# | ||
# Authors: | ||
# Li Hua Qian <[email protected]> | ||
# | ||
# SPDX-License-Identifier: MIT | ||
|
||
import os | ||
import sys | ||
import argparse | ||
import textwrap | ||
|
||
def main(args): | ||
description=textwrap.dedent('''\ | ||
Script for updating module firmware on IoT2050 | ||
Examples usage: | ||
1. iot2050-module-firmware-update -s 1 -fwa firmwareA.bin | ||
2. iot2050-module-firmware-update -s 1 -fwa firmwareA.bin -fwb firmwareB.bin | ||
''') | ||
parser = argparse.ArgumentParser( | ||
description=description, | ||
formatter_class=argparse.RawDescriptionHelpFormatter | ||
) | ||
parser.add_argument( | ||
"-s", "--slot", | ||
type=int, | ||
required=True, | ||
help="Slot number" | ||
) | ||
parser.add_argument( | ||
"-fwa", "--firmware-a", | ||
help="Path to firmware A file", | ||
type=argparse.FileType('rb') | ||
) | ||
parser.add_argument( | ||
"-fwb", "--firmware-b", | ||
help="Path to firmware B file", | ||
type=argparse.FileType('rb') | ||
) | ||
args = parser.parse_args(args) | ||
|
||
if not args.firmware_a and not args.firmware_b: | ||
print("Error: No firmware file specified") | ||
parser.print_help() | ||
return 1 | ||
|
||
slot = args.slot | ||
slot_path = f"/eiofs/controller/slot{slot}" | ||
if args.firmware_a: | ||
print("Updating firmware A ...") | ||
try: | ||
with open(slot_path + "/fwa", "wb") as f: | ||
f.write(args.firmware_a.read()) | ||
except Exception as e: | ||
print(f"Error: Failed to write firmware A, {e}") | ||
return 1 | ||
|
||
if args.firmware_b: | ||
print("Updating firmware B ...") | ||
try: | ||
with open(slot_path + "/fwb", "wb") as f: | ||
f.write(args.firmware_b.read()) | ||
except Exception as e: | ||
print(f"Error: Failed to write firmware B, {e}") | ||
return 1 | ||
|
||
print("Firmware updated successfully") | ||
|
||
return 0 | ||
|
||
if __name__ == '__main__': | ||
CODE = main(sys.argv[1:]) | ||
sys.exit(CODE) | ||
|
26 changes: 26 additions & 0 deletions
26
recipes-app/iot2050-module-firmware-update/iot2050-module-firmware-update_01.bb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Copyright (c) Siemens AG, 2024 | ||
# | ||
# Authors: | ||
# Li Hua Qian <[email protected]> | ||
# | ||
# This file is subject to the terms and conditions of the MIT License. See | ||
# COPYING.MIT file in the top-level directory. | ||
# | ||
|
||
DESCRIPTION = "IOT2050 Customized External Signal Module Firmware Update" | ||
MAINTAINER = "[email protected]" | ||
|
||
SRC_URI = " \ | ||
file://iot2050-module-firmware-update.tmpl" | ||
|
||
TEMPLATE_FILES = "iot2050-module-firmware-update.tmpl" | ||
|
||
inherit dpkg-raw | ||
|
||
do_install() { | ||
install -v -d ${D}/usr/sbin/ | ||
install -v -m 755 ${WORKDIR}/iot2050-module-firmware-update ${D}/usr/sbin/ | ||
} | ||
|
||
do_deploy_deb[dirs] = "${DEPLOY_DIR_IMAGE}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters