Commit graph

51 commits

Author SHA1 Message Date
Gregory Montoir
4a4ada9e9c Revert "Fix doing silent update,power cut/restoration,screen is turned on"
This reverts commit d43ec47f3b.

Bug: 245680635
Reason for revert: SoC specific solution, not standardized and documented for use by other OEMs.

Change-Id: Ide437e0db9d072c1199a715bac8014bc3f041ceb
2023-02-15 01:36:06 +00:00
Hannah.Hsu
d43ec47f3b Fix doing silent update,power cut/restoration,screen is turned on
[Description]
1. In the current code, when tv enter recovery mode, it will
write "boot-recovery" into the BCB command field by default.
This is a protection mechanism to ensure that tv can re-enter
recovery mode continues OTA upgrade after power cut/power restoration.
So, when re-enter recovery mode, since there is no "quiescent"
in the boot parameters, the screen will turn on.

2. And we hope the screen will be turned off when tv re-enter
recovery mode to continue OTA upgrade.

3. We made the following modify:
In reocvery mode,According to GetBoolProperty
"ro.boot.quiescent"to determine whether it is a quiescent
boot this time,and then write "boot-recovery, quiescent"
or"boot-recovery" accordingly.

[Test Report]
1.boot up ok.
2.silent update ok.
(the screen is turned off when interrupting/
resume or complete the upgrade)
3.OTA update ok.
(the screen is turned on when interrupting/
resume or complete the upgrade)

Change-Id: Ic68898f1a8e9ab176556ee2b61efec4d8d5d36e2
2022-09-27 09:32:20 +08:00
Kelvin Zhang
6f68964a57 Make libbootloader_message available in recovery
Test: th
Bug: 227536004
Change-Id: Ie40045963c5493d8fbc1eb15e6a54ecaf1c4728f
2022-08-31 16:28:43 +00:00
Florian Mayer
29ace0ba4c Add MISC_MEMTAG_MODE_MEMTAG_OFF.
This can be used as a killswitch to disable MTE from userspace.

Change-Id: I28ab4357c9ac3e088776f92a0e1f7d390b4b0bdc
2022-06-15 00:02:16 +00:00
Florian Mayer
0b6adb583c Fix typo in static_assert message.
Change-Id: I54ed5c26df8bc0ab4d4f6ab706ec2be0e07122a7
2022-02-09 19:52:09 +00:00
Florian Mayer
cf3234a093 [MTE] Add interface to communicate MTE status to bootloader.
We can use this interface to instruct the bootloader to either
permanently or only for the next reboot enable MTE for userspace
or kernel.

Bug: 206895651
Change-Id: I7330e43b7c4f94fc5913a7bc0f667b6eab06e111
2021-12-08 18:08:41 -08:00
Bob Badour
29be3f6ef1 [LSC] Add LOCAL_LICENSE_KINDS to bootable/recovery
Added SPDX-license-identifier-Apache-2.0 to:
  applypatch/Android.bp
  bootloader_message/Android.bp
  edify/Android.bp
  fuse_sideload/Android.bp
  install/Android.bp
  minadbd/Android.bp
  minui/Android.bp
  otautil/Android.bp
  recovery_ui/Android.bp
  recovery_utils/Android.bp
  tests/Android.bp
  tools/image_generator/Android.bp
  tools/recovery_l10n/Android.bp
  uncrypt/Android.bp
  update_verifier/Android.bp
  updater/Android.bp
  updater/Android.mk
  updater_sample/Android.bp
  updater_sample/tests/Android.bp

Added SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-MIT
    SPDX-license-identifier-OFL
to:
  Android.bp
  Android.mk

Bug: 68860345
Bug: 151177513
Bug: 151953481

Test: m all

Exempt-From-Owner-Approval: janitorial work
Change-Id: I3da761b525452838977297f773974000d4de7bd6
2021-02-14 10:37:20 -08:00
Tianjie Xu
dc4d2a70db Move libboot_control to boot_control 1.1
It should belong to the default /misc implementation of boot control
1.1. Right now, it's only used by cuttlefish. So move it over to reduce
confusion in bootloader_message.

Bug: 131775112
Test: build
Change-Id: If09bc6f4cc8adf74c8798048c8e54ec94566abaa
2019-12-16 16:07:27 -08:00
David Anderson
682d2a5db2 bootloader_message: Add a magic header to the Virtual A/B message block.
This adds a sanity check in addition to the version number in case misc
contains random bits.

Bug: 139156011
Test: manual test
Change-Id: Ie4f3731d2b1795340881c88e0c4eec9cd4432653
2019-11-20 16:23:52 -08:00
Tianjie Xu
3d57c84476 Consolidate the vendor space misc usage for Pixels
The layout of the vendor space /misc partition was pretty confusing and
lead to some usage conflicts. To formalize the layout, we create a pixel
specific library with the definition & offset of various flags. The new
library also handles the R/W. As a result, we will leave system domain
/misc definitions in the libbootloader_message.

We also switch the misc_writer binary to use more specific options
instead of writing an arbitrary hex string. So we can avoid redefining
the string & offset in both init script and recovery ui.

Bug: 131775112
Test: unit tests pass, run misc_writer and check contents of /misc
Change-Id: I00f8842a81d1929e31a1de4d5eb09575ffad47c0
2019-11-12 10:53:04 -08:00
David Anderson
cf8427af89 bootloader_message: Add helpers for handling IBootControl MergeStatus.
Move merge_status from bootloader_control_ab, which is in vendor space,
to a new generic AOSP struct in system space. This will allow more
devices to share the same HAL implementation.

This patch also changes libboot_control to compensate for merge_status
moving out of vendor space. The reference HAL library now also provides
separate helper functions for managing the merge status, so devices
using a custom boot control HAL can still take advantage of the new misc
implementation.

Bug: 139156011
Test: manual test
Change-Id: I5cd824e25f9d07aad1476301def5cdc3f506b029
2019-11-08 15:22:21 -08:00
David Anderson
4ff4cbdd6c bootloader_message: Carve out space reserved for system.
This reduces the wipe space from 32K to 16K. The wipe space is now
at the 16K-32K region. The 32K-64K region is now "system space", to
complement the vendor space, for generic AOSP usage.

Bug: 139156011
Test: manual test
Change-Id: I1474bfa65a5f21049ab64ec0aee2f4585b55f60f
2019-11-04 15:57:04 -08:00
David Anderson
46f38e4610 Add IBootControl 1.1 support to libboot_control.
Bug: 138861550
Test: vts
Change-Id: Id4a2963d6ab657d8ab076b7013492a691462b287
2019-09-04 18:12:36 -07:00
David Anderson
f771484f4e Make libboot_control vendor available.
Bug: 138861550
Test: builds
Change-Id: Ib745b59931c6258073e47b00def84c9157df90a7
2019-08-30 10:21:00 -07:00
Vic Yang
e94b64ae86 bootloader_message: Remove global std::string
A global std::string, even if not used, pollutes the bss section
unnecessarily.  Since this object is only there for testing, make it
std::optional<std::string>, which is constexpr constructible.

Bug: 138856262
Test: Along with a fix in fs_mgr, see that the bss section for
      libbootloader_message.so is now clean on cuttlefish for several
      processes.

Change-Id: I6df837dded88d979ffe14d5b2770b120bcf87341
2019-08-07 14:12:36 -07:00
Tao Bao
7ae0169842 Add misc_writer.
bootloader_message.h currently divides /misc into four segments. The
space between 2K and 16K is reserved for vendor use (e.g. bootloader
persists flags). This CL adds a vendor tool "misc_writer", to allow
writing data to the vendor space in /misc, before getting a dedicated
HAL for accessing /misc partition (b/131775112).

Targets need to explicitly include the module, then invoke the
executable to write data. For example, the following command will write
3-byte data ("0xABCDEF") to offset 4 in vendor space (i.e. 2048 + 4 in
/misc).
$ /vendor/bin/misc_writer --vendor-space-offset 4 --hex-string 0xABCDEF

Bug: 132906936
Test: Run recovery_unit_test on crosshatch.
Test: Call the command via init.hardware.rc on crosshatch. Check that
      the call finishes successfully. Then check the contents written to
      /misc (`dd bs=1 skip=2048 if=/dev/block/sda2 count=32 | xxd`).
Change-Id: I79548fc63fc79b705a0320868690569c3106949f
2019-05-20 15:51:26 -07:00
Colin Cross
fb68d38fba Disable libbootloader_message for darwin
libfstab is not built for darwin, don't build libbootloader_message
either.

Bug: 131709594
Test: m PRODUCT-sdk-sdk sdk_repo
Change-Id: I6e3b04f1c3e97d5aa6ac0452bf13e714f8dae437
2019-05-06 09:49:00 -07:00
Yifan Hong
d83070ddb9 libbootloader_message: host_supported.
Also, strlcat is not available on host, so use
std::string::operator+= instead.

Test: cuttlefish
Bug: 79094284

Change-Id: I1e69daeb522ca73f43e0c4855cf099a021ed4d47
2019-05-02 15:51:56 -07:00
Yifan Hong
c784ce50e8 libbootloader_message: write recovery to any device
Test: cuttlefish
Bug: 79094284

Change-Id: If1a6460a8cbed2e2d22fa9e16e6d7ca84f4592d0
2019-05-02 15:50:15 -07:00
Tom Cherry
72a114a3e1 Add android::fs_mgr namespace for new Fstab code
Also add libfstab dependencies where needed.  Previously the
`typedef struct FstabEntry Volume;` line served to both define a
`struct FstabEntry` as well as alias Volume to it.  With the new
namespace for android::fs_mgr::FstabEntry, `struct FstabEntry` isn't
compatible anymore, so we need to alias Volume to the real
android::fs_mgr::FstabEntry.

In doing so, we need to include <fstab/fstab.h> and this requires
libfstab as a library, which a few modules did not have before.

Test: treehugger
Change-Id: I655209a0efb304b3e0568db0748bd5cf7cecbdb7
2019-01-31 09:00:40 -08:00
Tom Cherry
772c93ca5c Move some small users of fstab to new C++ Fstab
Bug: 62292478
Test: tree-hugger
Change-Id: Ie2cc10e5168ef3b9dcc42f88e67a1ccd1175fcc5
2018-12-04 11:11:14 -08:00
Tao Bao
8ca3220bfe bootloader_message: Build libbootloader_message as shared lib.
And uses the shared lib version of libbase and libfs_mgr.

Bug: 78793464
Test: `m dist`
Test: Run recovery_{unit,component}_test on marlin.
Change-Id: I750c02d0bfccd6e58fb01f641de02532ace52e00
2018-07-25 13:42:33 -07:00
Jiyong Park
fafcfccc3c Mark as recovery_available:true
Libraries that are direct or indirect dependencies of modules installed
to recovery partition (e.g. adbd) are marked as recovery_available:
true. This allows a recovery variant of the lib is created when it is
depended by other recovery or recovery_available modules.

Bug: 79146551
Test: m -j
Change-Id: I9ca07ef53fbd89e7c86c0ba269fa52bb48d6deb4
2018-05-24 14:04:32 +09:00
Sen Jiang
7191bf0492 Add update_channel field to bootloader_message_ab.
The update_channel field is used to store the Omaha update channel
if update_engine is compiled with Omaha support.

We need it to be in misc to persist through factory reset.

Bug: 72332119
Test: mma
Change-Id: Ied4fecc6e78cc69d33a36ba4d101d675100f9d82
2018-01-22 15:03:53 -08:00
Tianjie Xu
a88cc5440e Switch to bionic gtest in bootable/recovery
We encountered segfaults in Imgdiff host tests due to the failure to
reset states of getopt. The problem can be solved by switching to use
bionic's gtest where a new process is forked for each test.

Also modify the recovery_component_test to make sure it runs in parallel.
Changes include:
  1. Merge the writes to misc partition into one single test.
  2. Change the hard coded location "/cache/saved.file" into a configurable
  variable.

Bug: 67849209
Test: recovery tests pass

Change-Id: I165d313f32b83393fb7922c5078636ac40b50bc2
2017-11-03 14:09:11 -07:00
Chih-Hung Hsieh
5aa77ca73d Use -Werror in bootable/recovery
* Move -Werror from cppflags to cflags.

Bug: 66996870
Test: build with WITH_TIDY=1
Change-Id: I59147fe24d8b48a0403c67ba07d4d384b8e9c5a3
2017-10-02 11:45:48 -07:00
Tianjie Xu
c89d1e7e2a Turn on -Wall for recovery modules
Turn on -Wall for all modules. Also remove the obsolete file_cmp() in
apply_patch test and now() in wear_ui.

The only exception is lib_edify due to the unused functions in the
intermediate cpp files generated from the lex files. It will be handled
in a seperate CL.

Bug: 64939312
Test: mma, unit tests pass
Change-Id: Ic53f76b60b6401ab20db3d98130d674c08e3702f
2017-08-28 21:56:33 -07:00
Tom Cherry
600e806384 libbootloader_message: convert to Android.bp
Test: build
Change-Id: Ia0c2e141673e37eea29306817d2f4b2c944213b0
2017-05-17 11:43:29 -07:00
Alex Deymo
fb00d82f32 Boot control HAL based on the A/B headers.
The added bootctrl.bcb module implement the legacy interface for the
bootctrl HAL based on the Boot Control Block (BCB) and the headers
already specified in the booloader_message library.

This serves as a reference implementation of the boot_control HAL.

Bug: 32707546
Test: Tested internally that a device can use this HAL to flip slots and
recovery from a /misc wipe.

Change-Id: Ic02e5aaf4de7d0a1780eac4e8705dae20d0b3e10
2017-04-03 11:25:33 -07:00
Bowgo Tsai
4508f23884 Revert "libbootloader_message: use different fstab paths for normal/recovery boot"
This reverts commit 37bd44174b.

The logic here is better to be moved into fs_mgr, not fs_mgr clients.

Bug: 35811655
Bug: 36502022

Change-Id: Iae79bd8f7131516ad223f3323f1bc1d805206d51
Test: normal boot sailfish, go to Settings > System & tap 
      on "Factory Data reset"
Test: recovery boot sailfish
2017-03-27 17:47:21 +00:00
Bowgo Tsai
37bd44174b libbootloader_message: use different fstab paths for normal/recovery boot
libbootloader_message is used by both normal boot and recovery boot.
It needs to use different fstab paths, respectively. Otherwise, factory
reset will fail when we move /fstab.{ro.hardware} to /vendor/etc/.

  Recovery boot: fs_mgr_read_fstab_with_dt("/etc/recovery.fstab")
  Normal boot: fs_mgr_read_fstab_default()

Bug: 35811655
Bug: 36502022

Test: normal boot sailfish, go to Settings > System & tap on
      "Factory Data reset"
Test: recovery boot sailfish

Change-Id: I253f5bdfb9be8a01f80856eb1194f85cdf992bbd
2017-03-25 19:25:43 +08:00
Bowgo Tsai
d13b6cf29c recovery: replacing fs_mgr_read_fstab() with new fs_mgr APIs
The fstab settings of early-mounted partitions (e.g., /vendor) will be in
kernel device tree. Switch to the new API to get the whole settings with
those in device tree:

    fs_mgr_read_fstab_with_dt("/etc/recovery.fstab")

The original default /fstab.{ro.hardware} might be moved to
/vendor/etc/. or /odm/etc/. Use another new API to get the default fstab
instead of using the hard-coded /fstab.{ro.hardware}. This API also
includes the settings from device tree:

    fs_mgr_read_fstab_default()

Bug: 35811655
Test: boot sailfish recovery
Change-Id: Iaa56ac7f7b4c4dfc7180c65f03e9a37b94f1de09
2017-03-10 17:27:31 +08:00
Tao Bao
2292db819b Add update_bootloader_message() to fix two-step OTAs.
This is a retry of commit 7e31f421a5.

Commit bd56f1590c switches to calling
write_bootloader_message(<options>) in get_args(), which
unintentionally resets the stage field thus breaks two-step OTAs.

This CL adds update_bootloader_message(<options>), which only sets
the command field (to "boot-recovery") and the recovery field (with
the specified options).

Bug: 33534933
Test: Apply a two-step package.
Test: recovery_component_test passes.
Change-Id: Ie0b1ed4053d2d3c97d9cb84310d616b28fcfc72e
2016-12-15 12:36:26 -08:00
Tao Bao
c0336399ae Remove the obsolete comments for firmware update.
The corresponding code was removed in commit
e08991e02a in 2010 (Froyo).

Test: N/A
Change-Id: I2b296e1b07d54232bade79fda7501387d65a4c37
2016-12-13 22:36:02 -08:00
Tao Bao
c908f4f0e3 Merge "Revert "write_bootloader_message(<options>) should not reset stage field."" 2016-12-13 01:24:04 +00:00
Tao Bao
26d5ae741e Revert "write_bootloader_message(<options>) should not reset stage field."
This reverts commit 7e31f421a5.

Bug: 33534933
Change-Id: Ib173f6b1e36a79deafc3592785195693a6779471
2016-12-13 01:06:24 +00:00
Tao Bao
f28afc191d Merge "write_bootloader_message(<options>) should not reset stage field." 2016-12-09 22:33:49 +00:00
Tao Bao
7e31f421a5 write_bootloader_message(<options>) should not reset stage field.
Commit bd56f1590c switches to calling
write_bootloader_message(<options>) in get_args(), which
unintentionally resets the stage field thus breaks two-step OTAs.

This CL changes write_bootloader_message(<options>) to only set the
command field (to "boot-recovery") and the recovery field (with the
specified options).

Test: Apply a two-step package.
Change-Id: I6905918812c7d3402cc1524688079066a4d22d29
2016-12-05 15:31:52 -08:00
Tao Bao
146f92ab3e Merge "updater: Refactor set_stage() and get_stage() functions."
am: c627cd6486

Change-Id: Ie4ff6fa512c875c6be65b02908eadb498d3f9644
2016-11-20 05:09:49 +00:00
Tao Bao
fbde508ace bootloader_message: Remove the no-op blank line.
This single blank line was introduced by some cherry-pick, which is
causing merge conflicts.

Test: N/A
Change-Id: Ida527b76fca7cc916499c5f888476c8e51ba3eaa
2016-11-18 16:00:23 -08:00
Tao Bao
bedf5fc11c updater: Refactor set_stage() and get_stage() functions.
Add read_bootloader_message_from() and write_bootloader_message_to() to
allow specifying the BCB device (/misc).

Also add testcases for set_stage() and get_stage().

Test: recovery_component_test passes.
Test: Build a recovery image and apply a two-step OTA package.
Change-Id: If5ab06a1aaaea168d2a9e5dd63c07c0a3190e4ae
2016-11-18 12:04:48 -08:00
Vineela Tummalapalli
118e814bfe Merge "Add 'reboot bootloader' to bootloader_message."
am: a5538b87e8

Change-Id: I432f48453d2627e165fda7cda1945157ff0e83ae
2016-11-10 02:52:18 +00:00
Vineela Tummalapalli
cba7fa88d8 Add 'reboot bootloader' to bootloader_message.
Add 'reboot bootloader' capability to the bootloader_message.

BUG: https://issuetracker.google.com/issues/32474515

Change-Id: I01e8b2fad978bf7c8fc96ff6b08ad3e52533f504
Author: Vineela Tummalapalli <vineela.tummalapalli@intel.com>
Signed-off-by: Vineela Tummalapalli <vineela.tummalapalli@intel.com>
Signed-off-by: Bruce Beare <bruce.j.beare@intel.com>
Reviewed-on: https://android.intel.com/548519
2016-11-09 17:24:57 -08:00
Yabin Cui
0d5b85944c Fix bootloader_message.
Bug: 29945717
Change-Id: I934fd6c52b0111937fa75455de2fa4157fb30f6f
(cherry picked from commit 9da04d595f)
2016-10-18 15:10:59 -07:00
Yabin Cui
8b309f6970 Create bootloader_message static library.
bootloader_messages merges bootloader_message_writer
and bootloader.cpp, so we can use the same library to
manage bootloader_message in normal boot and recovery mode.

Bug: 29582118

Change-Id: I9efdf776ef8f02b53911ff43a518e035e0c29618
(cherry picked from commit 2f272c0551)
2016-10-18 11:37:05 -07:00
Tianjie Xu
17e316cce0 Turn on -Werror for recovery
Also remove the 0xff comparison when validating the bootloader
message fields. As the fields won't be erased to 0xff after we
remove the MTD support.

Bug: 28202046
Test: The recovery folder compiles for aosp_x86-eng
Change-Id: Ibb30ea1b2b28676fb08c7e92a1e5f7b6ef3247ab
(cherry picked from commit 7aa88748f6)
2016-09-30 11:18:01 -07:00
Elliott Hughes
130f6c86f5 resolve merge conflicts of d5c7d6b to nyc-mr1-dev-plus-aosp
Change-Id: Ia041044547351a3e65b647bb9913aa18c7d2c97c
2016-09-26 12:53:52 -07:00
Yabin Cui
159ca9b0ac Fix bootloader_message.
am: 9da04d595f

Change-Id: I684c6afa25ce1dccad06920eee8a3bd6b7da96b1
2016-07-06 21:17:53 +00:00
Yabin Cui
9da04d595f Fix bootloader_message.
Bug: 29945717
Change-Id: I934fd6c52b0111937fa75455de2fa4157fb30f6f
2016-07-06 11:47:23 -07:00
Yabin Cui
9b15ba8269 resolve merge conflicts of 2f272c0 to nyc-mr1-dev-plus-aosp
Change-Id: I889d94a723415ad2e660b8c99e66935142918bc4
2016-06-30 15:13:12 -07:00