> ## 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.

# Provision UFS device

Provisioning refers to the process of creating and defining LUNs on a new UFS device. A UFS device has one or more logical units. A logical unit is an independent processing entity within the device. Each logical unit has an address within the UFS device called a Logical Unit Number (LUN).

The configuration file for provisioning is at `<build root/common/config/ufs/provision`.

The provision XML files for the various UFS device versions are as follows:

* `provision_ufs22.xml` - This is for UFS device 2.2 part
* `provision_ufs31.xml` - This is for UFS device 3.1 part

In the UFS device provision XML file, the UFS Device Descriptor is a section that has essential information about the UFS device being provisioned. The Device Descriptor includes details such as number of LUNs, initial power modes, write boost parameters. Here is a sample device descriptor entry:

```xml theme={null}
<ufs bNumberLU="6" bBootEnable="1" bDescrAccessEn="0" bInitPowerMode="1" bHighPriorityLUN="0x5" bSecureRemovalType="0"
bInitActiveICCLevel="0" wPeriodicRTCUpdate="0" bConfigDescrLock="0" bWriteBoosterBufferPreserveUserSpaceEn="1" bWriteBoosterBufferType="1"
shared_wb_buffer_size_in_kb="4194304" />
```

The provision XML file also describes each LUN with Unit Descriptor parameters such as Logical Unit Enable, Boot LUN ID. The following is a sample LUN descriptor entry:

```xml theme={null}
<ufs LUNum="0" bLUEnable="1" bBootLunID="0" size_in_kb="4096" bDataReliability="0" bLUWriteProtect="0" bMemoryType="0"
bLogicalBlockSize="0x0c" bProvisioningType="2" wContextCapabilities="0" wb_buffer_size_in_kb="0"
desc="LU 0 - User LUN - Rest of the device" />
```

The following table describes some important parameters used in the *provision XML* files.

| Parameter            | Description                                                                                                                                                                                                                                                                                                                                                                 |
| -------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bNumberLU`          | Number of Logical Units. `bNumberLU` does not include well-known logical units.                                                                                                                                                                                                                                                                                             |
| `bBootEnable`        | Indicates whether the device is enabled for boot: `00h` = Boot feature disabled, `01h` = Bootable feature enabled                                                                                                                                                                                                                                                           |
| `bDescrAccessEn`     | Indicates whether the Device Descriptor can be read after the partial initialization phase of the boot sequence: `00h` = Device Descriptor access disabled, `01h` = Device Descriptor access enabled                                                                                                                                                                        |
| `BInitPowerMode`     | Defines the Power Mode after device initialization or hardware reset: `00h` = UFS-Sleep Mode, `01h` = Active Mode                                                                                                                                                                                                                                                           |
| `bHighPriorityLUN`   | Defines the high-priority logical unit                                                                                                                                                                                                                                                                                                                                      |
| `bSecureRemovalType` | `00h` = Information removed by an erase of the physical memory; `01h` = Information removed by overwriting the addressed locations with a single character followed by an erase; `02h` = Information removed by overwriting the addressed locations with a character, its complement, then a random character; `03h` = Information removed using a vendor-defined mechanism |
| `bConfigDescrLock`   | `0h` = Configuration Descriptor not locked; `1h` = Configuration Descriptor locked                                                                                                                                                                                                                                                                                          |

<Note>
  * To reprovision the UFS device, set `bConfigDescrLock="0"`. This parameter is part of the provision XML file.
  * To prevent reprovisioning, set `bConfigDescrLock="1"` after the UFS device configuration and provisioning is finalized.
</Note>

| Parameter           | Description                                                                                                                                                                                                                                                  |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `LUNum`             | Logical Unit Number                                                                                                                                                                                                                                          |
| `bLUEnable`         | Enables/disables the logical unit: `00h` = Disables the logical unit, `01h` = Enables the logical unit                                                                                                                                                       |
| `bBootLunID`        | Boot LUN ID: `00h` = Not bootable, `01h` = Boot LU A, `02h` = Boot LU B                                                                                                                                                                                      |
| `size_in_kb`        | Specifies LUN size in KBs                                                                                                                                                                                                                                    |
| `bLUWriteProtect`   | Logical Unit Write Protect: `00h` = LU is not write protected, `01h` = LU write protected when `fPowerOnWPEn = 1`                                                                                                                                            |
| `bMemoryType`       | Defines logical unit memory type: `00h` = Normal memory, `01h` = System code memory type, `02h` = Non-Persistent memory type, `03h` = Enhanced memory type 1, `04h` = Enhanced memory type 2, `05h` = Enhanced memory type 3, `06h` = Enhanced memory type 4 |
| `bProvisioningType` | Provisioning type: `00h` = Thin Provisioning is disabled, `02h` = Enables thin provisioning with `TPRZ = 0`                                                                                                                                                  |

## UFS device partition layout

The default UFS device provisioning creates eight LUNs (LUN0 to LUN7).

* The Linux data and all Linux file system images are stored in LUN0.
* Boot well-known LUN (WLUN) 0xB0 alternates between LUN1 and LUN2 to provide a fail-safe backup for the XBL.
* The rest of the boot chain is stored in LUN4.
* The LUN6 and LUN7 are unused by default.

<img src="https://mintlify.s3.us-west-1.amazonaws.com/qualcomm-prod/images/default-ufs-provisioning-layout.svg" alt="Default UFS device layout" />
