> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Add partitions to SPINOR flash memory 

SPINOR flash memory is a high-speed and non-volatile storage widely used in embedded systems. On Qualcomm platforms, this memory is divided into multiple logical partitions defined in `nor_partition_frtos.xml`, each identified by a unique GUID.

The following table lists the RTSS SPINOR partition details in `nor_partition_frtos.xml`:

|           **Partition**           |                                                                                                                       **Description**                                                                                                                       |
| :-------------------------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|             `SAIL_DLP`            | <ul><li>Small (4 KB) partition at the beginning of NOR.</li><li>Acts as a download/loader pointer or critical boot marker.</li><li>This partition must be first; its backup (`SAIL_DLP_BKUP`) must be last to ensure tool and update reliability.</li></ul> |
|             `SAIL_HYP`            |                                                  <ul><li>Stores the RTSS hypervisor image (`sailhyp.elf`).</li><li>Runs early in the boot process to provide virtualization and safety isolation.</li></ul>                                                 |
|      `SAIL_SW1` - `SAIL_SW4`      |                           <ul><li>Contains the RTSS software images (`sailsw1.elf`, `sailsw2.elf`, `sailsw3.elf`, and `sailsw4.elf`).</li><li>Represents different software stages or domains loaded by the hypervisor.</li></ul>                           |
|           `SAIL_SEC_ELF`          |                                                                              Stores a secure ELF image or configuration blob required for RTSS security-related code and data.                                                                              |
|         `SAIL_DBG_POLICY`         |                                                                       Contains debug policy configuration that controls permitted debug features, particularly on production devices.                                                                       |
|          `SAIL_HYP_BKUP`          |                                                                                                       Backup of the RTSS hypervisor image (SAIL\_HYP).                                                                                                      |
| `SAIL_SW1_BKUP` - `SAIL_SW4_BKUP` |                                                                                                           Backup of the RTSS software partitions.                                                                                                           |
|        `SAIL_SEC_ELF_BKUP`        |                                                                                                     Backup of the secure ELF or configuration partition.                                                                                                    |
|       `SAIL_DBG_POLICY_BKUP`      |                                                                                                          Backup of the debug policy configuration.                                                                                                          |
|         `SAIL_OTA_REBOOT`         |                                             A small partition is used to store flags or status information related to the reboot sequence during an OTA update (for example, a pending update or reboot state).                                             |
|        `SAIL_OTA_METADATA`        |                   <ul><li>Stores metadata related to the OTA update process such as, version information, image details, and update status.</li><li>This ensures the bootloader to determine which images are valid and current.</li></ul>                  |
|          `SAIL_DLP_BKUP`          |                                                                 <ul><li>Backup of the SAIL\_DLP partition.</li><li>This partition must always be the last entry in the NOR layout.</li></ul>                                                                |
|      `MD_BIST_PATTERN2/BKUP`      |                                                    <ul><li>Stores the modem Built-In Self-Test (BIST) patterns for diagnostics and manufacturing.</li><li>Backup partition improves robustness.</li></ul>                                                   |
|       `SAIL_TGB_MARKER/BKUP`      |                                                                                               Small partition used for RTSS TGB test or tool markers and logs.                                                                                              |
|      `SAIL_NOR_TEST_EL1/EL2`      |                                                                                  Used for NOR flash testing at EL1 and EL2 levels without affecting production partitions.                                                                                  |
|             `SAIL_SLT`            |                                                                               System-level test (SLT) partition is used for validation or manufacturing scripts and binaries.                                                                               |
|        `SAIL_CODE_COVERAGE`       |                                                                                              Stores code coverage data used during development and validation.                                                                                              |
|          `SAIL_PMIC_LOG`          |                                                                                   Very small partition that stores PMIC logs such as power-on reasons and error snapshots.                                                                                  |
|          `SAIL_RAM_DUMP`          |                                                                                  Stores RAM dumps captured after crashes to support debugging of safety-critical failures.                                                                                  |
|      `MD_CRASH_DUMP_IN_SAIL`      |                                                                                       Reserved space for modem crash dumps when other storage options are unavailable.                                                                                      |
|         `SAIL_NOC_ERR_LOG`        |                                                                                      Stores Network-on-Chip (NoC) error logs used to debug interconnect or bus faults.                                                                                      |
|             `SAIL_EFS`            |                                                                                  Embedded File System for RTSS runtime data and configuration that persists across reboots.                                                                                 |
|       `SAIL_OEM_PARTITION_1`      |                                                                                             Reserved for OEM-specific configuration or safety application data.                                                                                             |

## **Prerequisites**

Before you start, create a unique GUID for each partition. Run the following command:

```python theme={null}
python -c "import uuid; print(uuid.uuid4())"
```

When you run the command, it generates a GUID.

Example:

`$ python3 -c "import uuid; print(uuid.uuid4())"`

`55b3aa18-3a33-4d3d-bcb5-c3cf9770cbd1`

Add this GUID to the `nor_partition_frtos.xml` file.

## **Add the partition with the GUID to** `nor_partition_frtos.xml`

1. Get the latest `nor_partition_frtos.xml` file from these folders:
   > * For IQ-9075:
   >   `<FIRMWARE_ROOT>/qualcomm-linux-spf-2-0_ap_standard_oem_sail/QCS9100.LE.2.0/common/config/sail_nor_lemans/nor_partition_frtos.xml`
   > * For IQ-8275:
   >   `<FIRMWARE_ROOT>/qualcomm-linux-spf-2-0_ap_standard_oem_sail/QCS8300.LE.2.0/common/config/sail_nor_monaco/nor_partition_monaco.xml`
2. Modify the file to add a new partition entry:
   > ```python theme={null}
   > <partition label="PARTITION_NAME" size_in_kb="size" type="GUID obtained in prerequisites" filename="binary name"/>
   > ```
   >
   > Example:
   >
   > ```python theme={null}
   > <partition label="SAIL_Test" size_in_kb="2048" type="55b3aa18-3a33-4d3d-bcb5-c3cf9770cbd1" filename="sailtest.elf"/>
   > ```
   >
   > <Note>
   >   **Note**
   >
   >   * The partition size should be 4 KB aligned. The minimum size is 4 KB.
   >   * Replace the highlighted fields with details for your new partition.
   > </Note>
3. To flash binary file into this partition, specify the binary file in the **filename** field:
   Example:

   ```python theme={null}
   <partition label="SAIL_Test" size_in_kb="2048" type="55b3aa18-3a33-4d3d-bcb5-c3cf9770cbd1" filename="sailtest.elf"/>
   ```

   <Note>
     **Note**

     * Place the new partition anywhere after `SAIL_SEC_ELF_BKUP` and before `SAIL_DLP_BKUP`.
     * `SAIL_DLP_BKUP` should always be the last partition. Ensure that there’s a binary for the last partition.
   </Note>

## **Generate GPT partition table binaries for flashing the new entry**

1. Create a new directory and navigate to it:
   ```undefined theme={null}
   mkdir ./sail_new_partition_entry
   ```
   ```powershell theme={null}
   cd sail_new_partition_entry
   ```
2. Run the partition tool:
   > * For IQ-9075:
   >   ```xml theme={null}
   >   python <FIRMWARE_ROOT>/qualcomm-linux-spf-2-0_ap_standard_oem_sail/QCS9100.LE.2.0/common/config/storage/ptool.py -x <FIRMWARE_ROOT>/qualcomm-linux-spf-2-0_ap_standard_oem_sail/QCS9100.LE.2.0/common/config/sail_nor_lemans/nor_partition_frtos.xml
   >   ```
   > * For IQ-8275:
   >   ```xml theme={null}
   >   python <FIRMWARE_ROOT>/qualcomm-linux-spf-2-0_ap_standard_oem_ sail/QCS8300.LE.2.0/common/config/storage/ptool.py -x <FIRMWARE_ ROOT>/qualcomm-linux-spf-2-0_ap_standard_oem_sail/QCS8300.LE.1. 0/common/config/sail_nor_monaco/nor_partition_frtos.xml
   >   ```
   >
   > These commands generate output files based on the XML layout.
3. Copy the generated files into the following directory to program the NOR flash:

   > `<workspace_path>/build-<DISTRO>/tmp-glibc/deploy/images/<MACHINE>/<IMAGE>/sail_nor`
   >
   > Example:
   >
   > `<workspace_path>/build-qcom-wayland/tmp-glibc/deploy/images/qcs9075-iq-9075-evk/qcom-multimedia-image/sail_nor`
   >
   > Parameters:
   >
   > > * \<DISTRO>: `qcom-wayland`
   > > * \<MACHINE>: `qcs9075-iq-9075-evk`
   > > * \<IMAGE>: `qcom-multimedia-image`

   <Note>
     **Note**

     * If pre-built binary images are available, copy the generated files into the SDK directory as shown in the following example:

     ```powershell theme={null}
     cp -r ./sail_new_partition_entry/* <sdk>\target\qcs9075-iq-9075-evk\qcom-multimedia-image\sail_nor

     ```
   </Note>
4. For more information about flashing RTSS, see [Flash SAIL](https://dragonwingdocs.qualcomm.com/Key-Documents/Flash-Guide/flash-with-qdl#flash-sail).
