secubox-deb/tools/Tow-Boot/modules/tow-boot/disk-image.nix
CyberMind-FR 0d7a21486b feat(tow-boot): Add Tow-Boot with eMMC boot support for MOCHAbin
- Add Tow-Boot source to tools/ with eMMC boot partition support
- Enable CONFIG_SUPPORT_EMMC_BOOT via mmcBootIndex for MOCHAbin variants
- Document boot mode jumpers J17-J22 (SPI 0x32, eMMC 0x2B)
- Document Tow-Boot build and flashing procedures
- Add known hardware issues (SPI intermittent, eMMC BootROM failure)
- Remove incorrect microSD slot reference from MOCHAbin docs
- Fix systemd service path (/lib → /usr/lib) in mitmproxy package

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-05-03 16:58:25 +02:00

98 lines
3.2 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{ config, lib, ... }:
let
inherit (lib)
mkBefore
mkOption
types
;
in
{
options = {
Tow-Boot = {
outputs = {
diskImage = mkOption {
type = types.package;
description = ''
Output of the disk image configuration.
'';
};
};
diskImage = config.helpers.mkImageBuilderEvalOption {
description = ''
Configuration for the disk image.
'';
};
firmwarePartition = mkOption {
type = types.attrsOf types.anything;
description = ''
Configuration for the firmware partition.
'';
};
writeBinaryToFirmwarePartition = mkOption {
type = types.bool;
default = true;
description = ''
Whether the firmware binary is directly written to the partition.
When disabled, the platform **must** handle configuring the firmwarePartition accordingly.
'';
};
};
};
config = {
Tow-Boot = {
diskImage = {
name = "${config.Tow-Boot.outputName}.${config.device.identifier}.${config.Tow-Boot.variant}.img";
gpt = {
# In theory this shouldn't be static, every partition should have a
# unique identifier, but that's not really possible here.
diskID = "E0CA6E57-39B2-4482-9838-21E2785CD93D";
};
mbr = {
# In theory this shouldn't be static, every partition should have a
# unique identifier, but that's not really possible here.
diskID = "01234567";
};
partitioningScheme = lib.mkDefault "gpt";
partitions = mkBefore [
config.Tow-Boot.firmwarePartition
];
};
firmwarePartition = {
name = "${config.Tow-Boot.outputName}.${config.device.identifier}.bin";
partitionLabel = "Firmware (Tow-Boot)";
# > Protective partitions are entries in the partition table that cover
# > the LBA region occupied by firmware and have the Required Partition
# > attribute set.
# — EBBR chapter 4.1.1
requiredPartition = true;
# In theory this shouldn't be static, every partition should have a
# unique identifier, but that's not really possible here.
partitionUUID = "CE8F2026-17B1-4B5B-88F3-3E239F8BD3D8";
# > A protective partition must use a PartitionTypeGUID that identifies
# > it as a firmware protective partition. (e.g., dont reuse a GUID
# > used by non-protective partitions).
# — EBBR chapter 4.1.1
partitionType = lib.mkDefault (
if config.Tow-Boot.diskImage.partitioningScheme == "gpt"
# https://github.com/ARM-software/ebbr/issues/84
# For now, we're "owning" this GUID.
then "67401509-72E7-4628-B1AF-EDD128E4316A"
# https://arm-software.github.io/ebbr/#mbr-partitioning
# May be overriden by platforms.
else "F8"
);
raw = lib.mkIf config.Tow-Boot.writeBinaryToFirmwarePartition "${config.Tow-Boot.outputs.firmware}/binaries/Tow-Boot.noenv.bin";
};
outputs = {
# Round-about, but this is our stable interface now.
diskImage = config.Tow-Boot.diskImage.output;
};
};
};
}