Guido Günther d30d9dfc03 gpt-utils: Open block device read only when obtaining info
Otherwise reading information like `qbootctl -a` triggers removal and
readdition of all partitions like:

```
KERNEL[73264.679695] remove   /devices/platform/soc@0/1d84000.ufshc/host0/target0:0:0/0:0:0:4/block/sde/sde11 (block)
KERNEL[73264.748249] add      /devices/platform/soc@0/1d84000.ufshc/host0/target0:0:0/0:0:0:4/block/sde/sde11 (block)
KERNEL[73264.863286] remove   /devices/platform/soc@0/1d84000.ufshc/host0/target0:0:0/0:0:0:4/block/sde/sde11 (block)
KERNEL[73264.917664] add      /devices/platform/soc@0/1d84000.ufshc/host0/target0:0:0/0:0:0:4/block/sde/sde11 (block)
UDEV  [73264.980859] remove   /devices/platform/soc@0/1d84000.ufshc/host0/target0:0:0/0:0:0:4/block/sde/sde11 (block)
UDEV  [73265.150742] add      /devices/platform/soc@0/1d84000.ufshc/host0/target0:0:0/0:0:0:4/block/sde/sde11 (block)
UDEV  [73265.276134] remove   /devices/platform/soc@0/1d84000.ufshc/host0/target0:0:0/0:0:0:4/block/sde/sde11 (block)
UDEV  [73265.492442] add      /devices/platform/soc@0/1d84000.ufshc/host0/target0:0:0/0:0:0:4/block/sde/sde11 (block)
…[the same for all other partitions on sde]…
```

leading to wasted CPU cycles (and battery) but also making programms
that run right after that command and accessing one of the partitions
fail sporadically. This can be bad if those commands are e.g. doing a

```
cat /dev/disk/by-partlabel/boot_a
```

to backup the current boot partition.
2025-02-11 23:41:55 +00:00
2023-06-23 21:53:30 +01:00
2023-05-15 20:25:59 +01:00
2023-06-24 01:38:14 +01:00
2023-06-24 01:38:14 +01:00
2023-06-24 01:38:14 +01:00
2023-06-23 21:53:30 +01:00

Qualcomm bootctl HAL for Linux

This HAL was pulled from AOSP source code and bastardised to build and run on a musl/glibc system. This may or may not render any hardware you run it on unusable, you have been warned.

Dependencies

  • zlib-dev
  • meson
  • cmake
  • linux-headers

Building

qbootctl uses the meson build system

meson build
meson compile -C build

Usage

qbootctl: qcom bootctrl HAL port for Linux
-------------------------------------------
qbootctl [-c|-m|-s|-u|-b|-n|-x] [SLOT]

    <no args>        dump slot info (default)
    -h               this help text
    -c               get the current slot
    -b SLOT          check if SLOT is marked as bootable
    -n SLOT          check if SLOT is marked as successful
    -x [SLOT]        get the slot suffix for SLOT (default: current)
    -s SLOT          set to active slot to SLOT
    -m [SLOT]        mark a boot as successful (default: current)
    -u [SLOT]        mark SLOT as unbootable (default: current)
    -i               still write the GPT headers even if the UFS bLun can't be changed (default: false)

Debugging

Set DEBUG to 1 in utils.h to enable debug logging.

Documentation

A more details explanation and a list of devices where qbootctl has been validated can be found on the postmarketOS wiki:

Description
No description provided
Readme Multiple Licenses 227 KiB
Languages
C 99.4%
Meson 0.6%