NervesSystemArduinoUnoQ.QDL (nerves_system_arduino_uno_q v0.1.1)

Copy Markdown View Source

Builds a Qualcomm EDL (QDL) flash directory that provisions an Arduino UNO Q with Nerves.

It starts from Arduino's eMMC bootloader bundle, keeps Qualcomm's partitions 1 to 66 and their boot firmware, replaces the last partitions of the GPT with the Nerves layout and writes the Nerves firmware into them.

The Nerves firmware is written as regions cut from a disk image produced by fwup -t complete, so fwup stays the only thing that knows how to lay out a firmware update.

Summary

Types

The Nerves partitions as {number, name, type GUID, first LBA, size}

Functions

The sector within the partition array and byte offset of a partition's entry.

Replaces Arduino's last partitions in its primary and backup GPT images with the Nerves partitions. Header and partition array CRCs are fixed up by patch0.xml while flashing, once the eMMC size is known.

The regions of the fwup image that get written to the eMMC.

The Nerves partitions at the end of the GPT.

Generates patch0.xml from Arduino's, pointing its "last partition" fix-ups at the Nerves data partition instead of userdata.

Generates rawprogram0.xml from Arduino's: Qualcomm's boot firmware and the GPT as before, then the Nerves image slices instead of Arduino's U-Boot, efi, rootfs and userdata.

Writes a QDL flash directory to out_dir.

Types

partition()

@type partition() ::
  {pos_integer(), String.t(), String.t(), non_neg_integer(),
   pos_integer() | :rest}

The Nerves partitions as {number, name, type GUID, first LBA, size}

Functions

entry_position(partition)

@spec entry_position(pos_integer()) :: {non_neg_integer(), non_neg_integer()}

The sector within the partition array and byte offset of a partition's entry.

gpt(main, backup)

@spec gpt(binary(), binary()) :: {binary(), binary()}

Replaces Arduino's last partitions in its primary and backup GPT images with the Nerves partitions. Header and partition array CRCs are fixed up by patch0.xml while flashing, once the eMMC size is known.

image_slices()

@spec image_slices() :: [{String.t(), non_neg_integer(), pos_integer()}]

The regions of the fwup image that get written to the eMMC.

partitions()

@spec partitions() :: [partition()]

The Nerves partitions at the end of the GPT.

patch(arduino_xml)

@spec patch(String.t()) :: String.t()

Generates patch0.xml from Arduino's, pointing its "last partition" fix-ups at the Nerves data partition instead of userdata.

rawprogram(arduino_xml)

@spec rawprogram(String.t()) :: String.t()

Generates rawprogram0.xml from Arduino's: Qualcomm's boot firmware and the GPT as before, then the Nerves image slices instead of Arduino's U-Boot, efi, rootfs and userdata.

write_flash_dir(bootloader_dir, image, out_dir)

@spec write_flash_dir(Path.t(), Path.t(), Path.t()) :: :ok

Writes a QDL flash directory to out_dir.

bootloader_dir is the extracted Arduino bootloader bundle and image is the disk image from fwup -t complete.