Skip to content

Commit

Permalink
docs: fix formatting in documentation (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
pixincreate authored Oct 21, 2024
1 parent 3c83fb7 commit 6309bde
Showing 1 changed file with 86 additions and 69 deletions.
155 changes: 86 additions & 69 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,97 +63,97 @@ Reading the [AVBRoot docs](https://github.com/chenxiaolong/AVBRoot) is essential

1. Ensure Fastboot version is `34` or newer. `35` or above is recommended as older versions are known to have bugs that prevent commands like `fastboot flashall` from running.

```shell
fastboot --version
```
```shell
fastboot --version
```

2. Reboot into `fastboot` mode and unlock the bootloader if not already. **This will trigger a data wipe.** Ensure data is backed up.

```shell
fastboot flashing unlock
```
```shell
fastboot flashing unlock
```

3. When setting PixeneOS up for the first time, the device must already be running the correct OS. Flash the original unpatched OTA or factory image if needed.

```shell
bsdtar xvf DEVICE_NAME-factory-VERSION.zip # tar on Windows and macOS
./flash-all.sh # or .bat on Windows
```
```shell
bsdtar xvf DEVICE_NAME-factory-VERSION.zip # tar on Windows and macOS
./flash-all.sh # or .bat on Windows
```

4. Download the [OTA from the releases](https://github.com/pixincreate/PixeneOS/releases). Ensure the version matches the installed version.

Extract the partition images from the patched OTA that are different from the original.
Extract the partition images from the patched OTA that are different from the original.

```shell
avbroot ota extract \
--input /path/to/ota.zip.patched \
--directory extracted \
--fastboot
```
```shell
avbroot ota extract \
--input /path/to/ota.zip.patched \
--directory extracted \
--fastboot
```

To extract and flash all OS partitions, pass `--all`.
To extract and flash all OS partitions, pass `--all`.

5. Set the `ANDROID_PRODUCT_OUT` environment variable to the directory containing the extracted files.

For sh/bash/zsh (Linux, macOS, WSL):
For `sh`/`bash`/`zsh` (Linux, macOS, WSL):

```shell
export ANDROID_PRODUCT_OUT=extracted
```
```shell
export ANDROID_PRODUCT_OUT=extracted
```

For PowerShell (Windows):
For PowerShell (Windows):

```powershell
$env:ANDROID_PRODUCT_OUT = "extracted"
```
```powershell
$env:ANDROID_PRODUCT_OUT = "extracted"
```

For cmd (Windows):
For cmd (Windows):

```bat
set ANDROID_PRODUCT_OUT=extracted
```
```bat
set ANDROID_PRODUCT_OUT=extracted
```

6. Flash the partition images.

```shell
fastboot flashall --skip-reboot
```
```shell
fastboot flashall --skip-reboot
```

Note: This only flashes the OS partitions. The bootloader and modem/radio partitions are left untouched due to fastboot limitations. If they are not already up to date or if unsure, after fastboot completes, follow the steps in the [updates section](#updates) to sideload the patched OTA once. Sideloading OTAs always ensures that all partitions are up to date.
Note: This only flashes the OS partitions. The bootloader and modem/radio partitions are left untouched due to fastboot limitations. If they are not already up to date or if unsure, after fastboot completes, follow the steps in the [updates section](#updates) to sideload the patched OTA once. Sideloading OTAs always ensures that all partitions are up to date.

Alternatively, for Pixel devices, running `flash-base.sh` from the factory image will also update the bootloader and modem.
Alternatively, for Pixel devices, running `flash-base.sh` from the factory image will also update the bootloader and modem.

7. Set up the custom AVB public key in the bootloader after rebooting from fastbootd to bootloader.

```shell
fastboot reboot-bootloader
fastboot erase avb_custom_key
fastboot flash avb_custom_key /path/to/avb_pkmd.bin
```
```shell
fastboot reboot-bootloader
fastboot erase avb_custom_key
fastboot flash avb_custom_key /path/to/avb_pkmd.bin
```

8. **[Optional]** Before locking the bootloader, reboot into Android to confirm proper signing.

Install the Magisk or KernelSU app and run:
Install the Magisk or KernelSU app and run:

```shell
adb shell su -c 'dmesg | grep libfs_avb'
```
```shell
adb shell su -c 'dmesg | grep libfs_avb'
```

If AVB is working, you should see:
If AVB is working, you should see:

```shell
init: [libfs_avb]Returning avb_handle with status: Success
```
```shell
init: [libfs_avb]Returning avb_handle with status: Success
```

9. Reboot into fastboot and lock the bootloader. This will trigger a data wipe.

```shell
fastboot flashing lock
```
```shell
fastboot flashing lock
```

Confirm by pressing volume down and then power. Then reboot.
Confirm by pressing volume down and then power. Then reboot.

> [!IMPORTANT]
> [!CAUTION]
> **Do not uncheck `OEM unlocking`!**
10. For future updates, see the [updates section](#updates).
Expand Down Expand Up @@ -207,7 +207,7 @@ Magisk versions 25211 and newer require a writable partition for storing custom

Now that the partition name is known, it can be passed to avbroot when patching via `--magisk-preinit-device <name>`. The partition name should be saved somewhere for future reference since it's unlikely to change across Magisk updates.

If the device is unbootable, patch and flash the OTA once using `--ignore-magisk-warnings`, then repatch and reflash the OTA with `--magisk-preinit-device <name>`.
If the device is unbootable, patch and flash the OTA once using `--ignore-magisk-warnings`, then repatch and reflash the OTA with `--magisk-preinit-device <name>`.

### Updates

Expand All @@ -219,30 +219,32 @@ Updates can be done by patching (or re-patching) the OTA using `adb sideload`:
PixeneOS leverages Custota:

1. Disable the [system updater app](https://github.com/chenxiaolong/avbroot#ota-updates).
2. Open Custota and set the OTA server URL to: https://pixincreate/github.io/PixeneOS/<rootless/magisk>
2. Open Custota and set the OTA server URL to: `https://pixincreate.github.io/PixeneOS/<rootless/magisk>`

For more info, refer to the [server](https://github.com/pixincreate/PixeneOS/tree/gh-pages) branch.

## Tool Usage

PixeneOS can be run on your local machine. A Linux based machine is preferred.

1. Clone or fork the repository.
2. Modify `env.toml` to set environment variables (your device model, AVBRoot architecture, GrapheneOS update channel and etc.,).
3. Run the program end-to-end:

```shell
. src/main.sh
```
1. Clone or fork the repository

`INTERACTIVE_MODE`, by default is set to `true` that calls `check_toml_env` function to check the existence of `env.toml`. If the file exist, it will read the `env.toml` file and set the environment variables accordingly. If the `env.toml` is non-existent, ignored. If it exist, and the format is wrong, the script exits with an error.
2. Modify `env.toml` to set environment variables (your device model, AVBRoot architecture, GrapheneOS update channel and etc.,)

> [!IMPORTANT]
> Make sure that `env.toml` file exist in root of the project.
3. Run the program end-to-end:

```shell
. src/main.sh
```

> [!NOTE]
> Running the program end-to-end will only generate the patched OTA package locally and will not push it to the server (server branch that contains the json file which is read by the Custota).
`INTERACTIVE_MODE`, by default is set to `true` that calls `check_toml_env` function to check the existence of `env.toml`. If the file exist, it will read the `env.toml` file and set the environment variables accordingly. If the `env.toml` is non-existent, ignored. If it exist, and the format is wrong, the script exits with an error.

To make the patched OTA available to the device, it needs to be hosted on the server. PixeneOS uses GitHub for pushing updates, handled by [release.yml](.github/workflows/release.yml).

To set up automated release, add the following variables in GitHub secrets:
Expand Down Expand Up @@ -287,7 +289,7 @@ To set up automated release, add the following variables in GitHub secrets:

This command will generate the AVB keys and store them in `.keys` directory.

> [!NOTE]
> [!WARNING]
> For security reasons, `.keys` directory will **not** be pushed to your GitHub repository.> Execute `setup_hooks.sh` to install a pre-commit hook that will prevent `.keys` directory from being pushed.
- To create and make the release:
Expand All @@ -307,18 +309,33 @@ To set up automated release, add the following variables in GitHub secrets:
To revert to stock GrapheneOS or firmware:

1. Reboot into fastboot mode and unlock the bootloader. **This will trigger a data wipe**. Ensure data is backed up.

2. Erase the custom AVB public key:

```shell
fastboot erase avb_custom_key
```
```shell
fastboot erase avb_custom_key
```

3. Flash the stock firmware.

## More information

2. Flash the stock firmware.
To know more about the projects used in this repository, refer to the following links:

- [GrapheneOS](https://grapheneos.org)
- [MSD](https://github.com/chenxiaolong/MSD)
- [BCR](https://github.com/chenxiaolong/BCR)
- [Custota](https://github.com/chenxiaolong/Custota)
- [OEMUnlockOnBoot](https://github.com/chenxiaolong/OEMUnlockOnBoot)
- [AVBRoot](https://github.com/chenxiaolong/AVBRoot)
- [AFSR](https://github.com/chenxiaolong/AFSR)
- [AlterInstaller](https://github.com/chenxiaolong/AlterInstaller)
- [Magisk](https://github.com/pixincreate/Magisk)
- [Rooted Graphene](https://github.com/schnatterer/rooted-graphene)

## License

This project is licensed under the `MIT`. For more information, please refer to the [LICENSE](LICENSE) file.

Dependencies are downloaded from their respective repositories and are licensed under their respective licenses. Refer to the respective repositories for more information.

## Credits
Expand Down

0 comments on commit 6309bde

Please sign in to comment.