Files
oxmc 9344e608f6 Initial commit: PawletOS vendor tree
Adds the full vendor/pawlet tree for PawletOS on Raspberry Pi 4/5:

- build/: envsetup.sh helpers (breakfast/brunch/mka), bacon OTA target,
  Soong namespace, build core hook
- config/: common.mk, version.mk, BoardConfigPawlet.mk, BoardConfigSoong.mk,
  privapp-permissions, me.pawlet.android feature XML
- hal/boot_control/rpi/: AIDL boot_control HAL for RPi A/B slot switching
- apps/Updater/: A/B OTA updater (download, verify, install, reboot)
- apps/PawletPlatform/: platform resource APK (device icons, strings)
- overlay/frameworks/base/core/res/: framework config overrides
- prebuilt/, vars/: init rc, aosp_target_release
2026-03-21 19:08:46 -07:00

65 lines
2.3 KiB
C++

/*
* Copyright (C) The Android Open Source Project
* Copyright (C) 2025 oxmc / PawletOS
*
* SPDX-License-Identifier: Apache-2.0
*
* Implements the AOSP android.hardware.boot AIDL interface
* (hardware/interfaces/boot/) for Raspberry Pi 4/5.
*/
#pragma once
#include <aidl/android/hardware/boot/BnBootControl.h>
#include <aidl/android/hardware/boot/MergeStatus.h>
#include "misc_rpi.h"
namespace aidl::android::hardware::boot {
/**
* PawletOS boot_control AIDL HAL for Raspberry Pi 4 / 5.
*
* Slot metadata is persisted in the "misc" GPT partition at
* PAWLET_MISC_OFFSET (see misc_rpi.h).
*
* The RPi firmware's tryboot mechanism is used for slot switching:
* setActiveBootSlot(1) — writes pending-B to misc
* (caller triggers `reboot tryboot`)
* markBootSuccessful() — confirms boot; if current slot is B, copies
* boot_b → boot_a to make the change permanent
*/
class BootControl : public BnBootControl {
public:
BootControl(const char* misc_device,
const char* boot_a_device,
const char* boot_b_device);
// IBootControl
ndk::ScopedAStatus getNumberSlots(int32_t* out) override;
ndk::ScopedAStatus getCurrentSlot(int32_t* out) override;
ndk::ScopedAStatus getActiveBootSlot(int32_t* out) override;
ndk::ScopedAStatus getSuffix(int32_t slot, std::string* out) override;
ndk::ScopedAStatus markBootSuccessful() override;
ndk::ScopedAStatus setActiveBootSlot(int32_t slot) override;
ndk::ScopedAStatus setSlotAsUnbootable(int32_t slot) override;
ndk::ScopedAStatus isSlotBootable(int32_t slot, bool* out) override;
ndk::ScopedAStatus isSlotMarkedSuccessful(int32_t slot, bool* out) override;
ndk::ScopedAStatus getSnapshotMergeStatus(MergeStatus* out) override;
ndk::ScopedAStatus setSnapshotMergeStatus(MergeStatus status) override;
private:
const std::string misc_device_;
const std::string boot_a_device_;
const std::string boot_b_device_;
bool readMisc(PawletBootControl* ctrl);
bool writeMisc(const PawletBootControl& ctrl);
void initDefaultMisc(PawletBootControl* ctrl);
bool copyBootPartition(const std::string& src, const std::string& dst);
static uint32_t computeCrc32(const void* data, size_t len);
static bool isValidSlot(int32_t slot);
};
} // namespace aidl::android::hardware::boot