From c54cc88c0375b7846b4216033171f0ff88272644 Mon Sep 17 00:00:00 2001 From: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> Date: Thu, 19 Aug 2021 18:04:16 +0200 Subject: [PATCH] ota: add Raspberry Pi override fields The override fields can be placed in the [Raspberry Pi] section inside the systoad.conf file. They are designed to enable testing of the piboot package with spread-like integration tests on hardware other than the Raspberry Pi. The documentation is updated but there is no code using the new fields yet. Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@huawei.com> --- man/sysotad.conf.5.in | 26 ++++++++++++++++++++++++-- ota/ota.go | 13 +++++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/man/sysotad.conf.5.in b/man/sysotad.conf.5.in index 2de4cd8..aeab650 100644 --- a/man/sysotad.conf.5.in +++ b/man/sysotad.conf.5.in @@ -1,6 +1,6 @@ .\" SPDX-License-Identifier: Apache-2.0 .\" SPDX-FileCopyrightText: Huawei Inc. -.Dd Jun 18, 2021 +.Dd Aug 20, 2021 .Os @PROJECT_NAME@ @PROJECT_VERSION@ .Dt sysotad.conf 5 PRM .Sh NAME @@ -40,7 +40,7 @@ As files are loaded, settings are stored into the configuration object are overwritten by newer definitions. Care must be taken to define a consistent set. .Sh OPTIONS -All options are configured in the [OTA] section: +The following options are configured in the [OTA] section: .Ss BootLoaderType= .Rs Identifies the type of the boot loader the OTA service will configure and @@ -56,3 +56,25 @@ the .Em config.txt file. .Re +.Pp +The following options are configured in the [Raspberry Pi] section: +.Ss OverrideRevisionCode= +.Rs +Overrides the Raspberry Pi revision code that is otherwise probed from +.Em /proc/cpuinfo . +This property is only designed for tests and may be limited to debug builds in +the future. The value is only used when +.Em OverrideSerialNumber= +is not zero. When the override mechanism is enabled then /proc/cpuinfo is not +scanned at all. +.Re +.Ss OverrideSerialNumber= +.Rs +Overrides the Raspberry Pi serial number that is otherwise probed from +.Em /proc/cpuinfo . +This property is only designed for tests and may be limited to debug builds in +the future. The value is only used when +.Em OverrideRevisionCode= +is not zero. When the override mechanism is enabled then /proc/cpuinfo is not +scanned at all. +.Re diff --git a/ota/ota.go b/ota/ota.go index bc327e2..54ce3b1 100644 --- a/ota/ota.go +++ b/ota/ota.go @@ -10,6 +10,7 @@ import ( "os" "git.ostc-eu.org/OSTC/OHOS/components/sysota/encoding/ini" + "git.ostc-eu.org/OSTC/OHOS/components/sysota/picfg/pimodel" ) // TODO: add marshalable server response types here. @@ -84,6 +85,18 @@ type Config struct { // "/boot" or a sub-directory, such as "/boot/firmware", depending on the // platform. BootPartitionMountDir string `ini:"BootPartitionMountDir,omitempty"` + + // Specific to the Raspberry Pi boot loader. + + // OverrideRevisionCode overrides automatically probed Raspberry Pi revision + // code. This feature is meant for testing. It is only effective when + // coupled with OverrideSerialNumber. + OverrideRevisionCode pimodel.RevisionCode `ini:"OverrideRevisionCode,[Raspberry Pi],omitempty"` + + // OverrideSerialNumber overrides automatically probed Raspberry Pi serial + // number. This feature is meant for testing. It is only effective when + // coupled with OverrideRevisionCode. + OverrideSerialNumber pimodel.SerialNumber `ini:"OverrideSerialNumber,omitempty"` } // DefaultConfigFiles returns sysotad configuration files loaded on startup. -- GitLab