Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
# Copyright (c) Siemens AG, 2020-2024
# Copyright (c) Siemens AG, 2020-2026
#
# Authors:
# Chao Zeng <chao.zeng@siemens.com>
Expand Down Expand Up @@ -514,17 +514,9 @@ class FirmwareUpdate():
file.seek(0)
file_content = file.read()
elif self.tarball.FIRMWARE_TYPES[2] == firmware_type:
with open("/sys/firmware/devicetree/base/model", "r") as model_f, \
open("/etc/os-release", "r") as release_f:
for line in release_f.readlines():
key, value = line.rstrip("\n").split("=")
if "BUILD_ID" in key:
break
with open("/sys/firmware/devicetree/base/model", "r") as model_f:
target_board = model_f.read().replace("\u0000", "")
tmpl_json['firmware'][0]['target_boards'] = target_board
tmpl_json['target_os'][0]['min_version'] = \
value.replace('"', '')[:1] + \
tmpl_json['target_os'][0]['min_version'][1:]
file_content = bytes(json.dumps(tmpl_json, indent=4), "utf8")
else:
raise UpgradeError("Wrong Firmware Type!")
Expand Down Expand Up @@ -611,7 +603,11 @@ class FirmwareTarball(object):
file_tarfileinfo = f.getmember(name=member.name)
file_tarfileinfo.uid = os.getuid()
file_tarfileinfo.gid = os.getgid()
f.extract(file_tarfileinfo, path=self.extract_path)
try:
f.extract(file_tarfileinfo, path=self.extract_path,
filter='fully_trusted')
except TypeError:
f.extract(file_tarfileinfo, path=self.extract_path)
self.extracted_files.append(self.extract_path + "/" + member.name)

self._board_info = BoardInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
"target_boards": ""
}
],
"target_os": [
{
"type": "Example Image",
"key": "BUILD_ID",
"min_version": "V01.01.01"
}
],
"suggest_preserved_uboot_env": [
"boot_targets"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#
# Copyright (c) Siemens AG, 2020-2025
#
# Authors:
# Chao Zeng <chao.zeng@siemens.com>
# Li Hua Qian <huaqian.li@siemens.com>
#
# This file is subject to the terms and conditions of the MIT License. See
# COPYING.MIT file in the top-level directory.
#

PR = "2"

DESCRIPTION = "OSPI Firmware Update Scripts"
MAINTAINER = "chao.zeng@siemens.com"

SRC_URI = " \
file://update.conf.json.tmpl \
file://iot2050-firmware-update.tmpl"

TEMPLATE_FILES = "update.conf.json.tmpl iot2050-firmware-update.tmpl"

DPKG_ARCH = "any"

inherit dpkg-raw

DEBIAN_DEPENDS = "python3-progress, python3-packaging, u-boot-tools"

do_install() {
install -v -d ${D}/usr/sbin/
install -v -m 755 ${WORKDIR}/iot2050-firmware-update ${D}/usr/sbin/

install -v -d ${D}/usr/share/iot2050/fwu
install -v -m 644 ${WORKDIR}/update.conf.json ${D}/usr/share/iot2050/fwu/
}

do_deploy_deb:append() {
cp -f "${WORKDIR}/${PN}_${PV}_arm64.deb" "${DEPLOY_DIR_IMAGE}/"
}

do_deploy_deb[dirs] = "${DEPLOY_DIR_IMAGE}"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
#
# Copyright (c) Siemens AG, 2023
# Copyright (c) Siemens AG, 2023-2026
#
# Authors:
# Li Hua Qian <huaqian.li@siemens.com>
Expand All @@ -11,37 +11,35 @@

update_json()
{
version_letter="$(echo $2 | head -c 1)"
sed -i '/"version": ".*"/s/"V.*"/"'$2'"/g' $1
sed -i '/"description": ".*"/s/V.*["$]/'$2\"'/g' $1
sed -i '/"min_version": ".*"/s/"V/"'$version_letter'/g' $1
sed -i '/"version": ".*"/s/"V.*"/"'"$2"'"/g' "$1"
sed -i '/"description": ".*"/s/V.*["$]/'"$2"'"/g' "$1"
}

generate_fwu_tarball()
{
echo "Generating the firmware tarball..."

if [ ! -e $2/iot2050-pg1-image-boot.bin ] || \
[ ! -e $2/iot2050-pg2-image-boot.bin ]; then
if [ ! -e "$2/iot2050-pg1-image-boot.bin" ] || \
[ ! -e "$2/iot2050-pg2-image-boot.bin" ]; then
echo "Error: iot2050-pg1/2-image-boot.bin doesn't exist!"
exit 2
fi

if [ ! -e $2/u-boot-initial-env ]; then
if [ ! -e "$2/u-boot-initial-env" ]; then
echo "Error: u-boot-initial-env doesn't exist!"
exit 2
fi

mkdir -p $2/.tarball
mkdir -p "$2/.tarball"

cp $1/update.conf.json.tmpl $2/.tarball/update.conf.json
update_json $2/.tarball/update.conf.json $3
cp $2/iot2050-pg*-image-boot.bin $2/.tarball
cp $2/u-boot-initial-env $2/.tarball
cp "$1/update.conf.json.tmpl" "$2/.tarball/update.conf.json"
update_json "$2/.tarball/update.conf.json" "$3"
cp "$2"/iot2050-pg*-image-boot.bin "$2/.tarball"
cp "$2/u-boot-initial-env" "$2/.tarball"

cd $2/.tarball
tar -cJvf $2/IOT2050-FW-Update-PKG-$3.tar.xz *
cd - && rm -rf $2/.tarball
cd "$2/.tarball" || exit
tar -cJvf "$2/IOT2050-FW-Update-PKG-$3.tar.xz" ./*
cd - && rm -rf "$2/.tarball"
}

generate_fwu_tarball $*
generate_fwu_tarball "$@"
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
DESCRIPTION = "Generate The Firmware Update Package"
MAINTAINER = "huaqian.li@siemens.com"

PR = "1"

SRC_URI = "file://iot2050-generate-fwu-tarball.sh \
file://update.conf.json.tmpl"

Expand Down
Loading