Partition Table Syntax Version 3.0
This document describes the design, usage, and migration guide for the partition table v3 (in short ptab v3) format in the SiFli SDK.
Overview
ptab v3 is the next-generation partition table format in the SiFli SDK and uses YAML. Compared with the v1/v2 JSON formats, it offers several advantages:
Clearer semantics: uses
type/subtypeinstead of the more complextagsmechanismAbstract storage regions: references logical storage regions via the
regionfield, decoupling layout from chip topologyUnified execution address: specifies execution/copy destination clearly via
exec: {region, offset}Automatic macro generation: generates C macro definitions from
namefieldsImproved validation: built-in validators check partition correctness
Unlike ptab v1/v2, ptab v3 is closely integrated with the build system and directly generates ftab.bin, ptab.h, and jinja2-based link script fragments.
File format
Basic structure
The YAML example below shows the fully expanded form to illustrate the semantics for each partition type. In real projects, ptab.yaml can omit partitions that the build system can deterministically infer; only partitions that differ from defaults need to be explicitly declared.
version: 3
chip: SF32LB525UC6
memory:
- mpi: mpi2
type: nand
size: 16777216 # 16MB
partitions:
# Flash Table (ftab)
- name: flash_table
type: ftab
region: mpi2
offset: 0
size: 32KB
# Calibration data
- name: calibration
type: data
subtype: calibration
region: mpi2
offset: 0x8000
size: 8KB
# Bootloader (stored in Flash, executed in RAM)
- name: bootloader
type: bootloader
region: mpi2
offset: 0x80000
size: 64KB
exec:
region: hpsys_ram
offset: 0x20000
core: HCPU
# Main application
- name: hcpu_flash_code
type: app
subtype: factory
region: mpi2
offset: 0xA0000
size: 4MB
exec:
region: mpi1
offset: 0
core: HCPU
# DFU application
- name: dfu_flash_code
type: app
subtype: dfu
region: mpi2
offset: 0x4A0000
size: 512KB
exec:
region: mpi1
offset: 0
core: HCPU
# DFU info region
- name: dfu_info_region
type: data
subtype: raw
region: mpi2
offset: 0x520000
size: 128KB
# DFU download region
- name: dfu_download_region
type: data
subtype: raw
region: mpi2
offset: 0x780000
size: 1152KB
# Filesystem region
- name: fs_region
type: data
subtype: filesystem
region: mpi2
offset: 0x8A0000
size: 4MB
# KVDB for DFU
- name: dfu
type: data
subtype: flashdb_kv
region: mpi2
offset: 0xCA0000
size: 16KB
# KVDB for BLE
- name: ble
type: data
subtype: flashdb_kv
region: mpi2
offset: 0xCA4000
size: 16KB
# PSRAM data region
- name: psram_data
type: data
subtype: ram
region: mpi1
offset: 0x400000
size: 4MB
# HCPU RAM data (shared with bootloader exec)
- name: hcpu_ram_data
type: data
subtype: ram
region: hpsys_ram
offset: 0
size: 128KB
# Bootloader RAM data
- name: bootloader_ram_data
type: data
subtype: ram
region: hpsys_ram
offset: 0x40000
size: 64KB
# LPSYS RAM
- name: lpsys_ram
type: data
subtype: ram
region: lpsys_ram
offset: 0
size: 24KB
Top-level fields
Field |
Type |
Required |
Description |
|---|---|---|---|
|
int |
yes |
Must be |
|
string |
yes |
Chip model, e.g. |
|
list |
no |
Storage region definitions |
|
list |
yes |
Partition list |
Memory definitions
memory defines external storage devices such as NAND or NOR.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
MPI or SDMMC interface name, e.g. |
|
string |
yes |
Storage type: |
|
string |
yes |
Size; supports |
For SD/MMC (eMMC/SD card) define the storage in memory and reference it in partitions via region.
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
SDMMC storage name, e.g. |
|
string |
yes |
Storage size; supports |
Partition fields
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
Partition name, used for generating C macros |
|
string |
yes |
Partition type |
|
string |
no |
Partition subtype |
|
string |
yes |
Storage region (logical name) |
|
int/string |
yes |
Region offset; supports |
|
int/string |
yes |
Partition size |
|
dict |
no |
Execution address definition |
|
string |
no |
Running core: |
|
dict |
no |
Custom attributes |
exec field
exec specifies where code should be executed from if XIP is not possible (copy-to-execute).
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
yes |
Execution region (logical name) |
|
int/string |
yes |
Execution region offset; supports |
Example: if the main program is stored in NAND and must be copied to PSRAM for execution:
- name: hcpu_flash_code
type: app
subtype: factory
region: mpi2
offset: 0xA0000
size: 4MB
exec:
region: mpi1
offset: 0
core: HCPU
Partition type definitions
type values
Value |
Meaning |
|---|---|
|
Flash Table (the partition table itself) |
|
Bootloader |
|
Application |
|
Data partition |
subtype values
When type=app:
Value |
Meaning |
|---|---|
|
Factory (primary) application |
|
DFU upgrade application (runs independently) |
When type=data:
Value |
Meaning |
|---|---|
|
FlashDB KV database (generates |
|
Filesystem (generates |
|
LittleFS (for future uses) |
|
FAT filesystem (for future uses) |
|
RAM data area (can be omitted for default |
|
Calibration data |
|
Raw data area for application-managed storage |
|
Internal resources: linked into the final ELF and sliced by section names |
Default partition inference
The ptab v3 parser will auto-fill certain system default partitions. This lets board-level ptab.yaml omit defaults and only declare differences.
SF32LB52
When boot storage is NOR/NAND/SDMMC,
flash_tableandbootloaderare inferred from the HCPU factory app storageregion.When boot storage is NAND, a
factory_datapartition (aliasFACTORY_DATA) is reserved by default:offset = 2 * block_size,size = block_size. Ifmemory.block_sizeis not explicitly set, NAND block size defaults to 128KB; if explicitly set to 256KB the defaults follow accordingly.When boot storage is SDMMC,
mbr(aliasMBR,offset=0x0,size=0x1000) andfactory_data(aliasFACTORY_DATA,offset=0x41000,size=0x20000) are reserved.If RAM layout is unchanged,
hcpu_ram_data,bootloader_ram_data, andlpsys_ramcan be omitted.
SF32LB56 / SF32LB58
flash_tableandbootloaderlocated on internalmpi5can be omitted.
psram_data / psram_data2
On-chip SiP PSRAM windows are generated automatically from the SiliconSchema and
execreserved regions and need not be declared in board YAML.
Notes:
Defaults only apply when a partition is missing; explicitly declared partitions always take precedence.
If a project customizes RAM layout (e.g. shrinks
hcpu_ram_datato match a linker script), that partition must be kept.Project-level
ptab.overlay.yamlcan still override defaults; overlay sees the filled-default set before applying overrides.
Regions (region)
Supported region names
Region |
Description |
|---|---|
External storage |
Defined in |
|
HPSYS RAM |
|
LPSYS RAM |
Address resolution
Each region maps to two addresses:
SBUS address (storage address): used for DMA and flashing
CBUS address (XIP address): used for CPU execution
Address mapping comes from tools/SiliconSchema/common/mpi/<chip>/mpi.yaml.
Macro generation rules
Basic macros
Each partition automatically generates the following macros (where <NAME> is the partition name uppercased):
#define <NAME>_START_ADDR (0x...) // SBUS address
#define <NAME>_SIZE (0x...) // partition size
#define <NAME>_OFFSET (0x...) // region offset
If the partition region maps to a known storage type, an additional macro is generated:
#define <NAME>_MEM_TYPE HAL_MEM_TYPE_...
Possible memory type constants:
HAL_MEM_TYPE_NOR_FLASHHAL_MEM_TYPE_NAND_FLASHHAL_MEM_TYPE_SDMMC_STORAGEHAL_MEM_TYPE_PSRAM
For on-chip RAM regions that have no HAL memory type, <NAME>_MEM_TYPE is omitted.
Special macros
CODE_START partitions:
When type=app and subtype=factory, the generator will emit:
#define CODE_START_ADDR (0x...)
#define CODE_SIZE (0x...)
CODE_START_ADDR corresponds to the execution address specified by exec. If exec is absent, the storage CBUS address is used.
If macros such as HCPU_FLASH_CODE or FLASH_BOOT_LOADER are generated from execution-address compatibility rules and also include _MEM_TYPE, the _MEM_TYPE follows the final execution region rather than the storage region. If the execution region is on-chip RAM, the _MEM_TYPE will not be generated.
Filesystem partitions:
When type=data and subtype is one of filesystem/littlefs/fat/fatfs/flashdb, the following macros are emitted:
#define FS_REGION_START_ADDR (0x...)
#define FS_REGION_SIZE (0x...)
#define FS_REGION_OFFSET (0x...)
#define FS_REGION_MEM_TYPE HAL_MEM_TYPE_...
FlashDB KV partitions:
When type=data and subtype=flashdb_kv, KVDB macros are generated (where <NAME> is the uppercase partition name, which also becomes the FlashDB database name and FAL partition name, e.g. dfu, ble):
#define KVDB_<NAME>_REGION_START_ADDR (0x...)
#define KVDB_<NAME>_REGION_OFFSET (0x...)
#define KVDB_<NAME>_REGION_SIZE (0x...)
#define KVDB_<NAME>_REGION_MEM_TYPE HAL_MEM_TYPE_...
FAL_PART_TABLE:
ptab.h will auto-generate FAL_PART_TABLE containing the following partitions:
type=data, subtype=flashdb_kvtype=data, subtype=filesystemtype=appwheresubtype != ex
Excluded from auto-inclusion:
type=ftabtype=bootloadertype=datawheresubtypeisraw/ram/calibration/int_restype=appwheresubtype=ex
FAL partition names use the partition name directly and do not map legacy names like main, dfu_code, or fs_root.
Example generation:
#define FAL_PART_TABLE \\
{ \\
{FAL_PART_MAGIC_WORD, "hcpu_flash_code", NOR_FLASH5_DEV_NAME, 0x00020000, 0x00200000, 0}, \\
{FAL_PART_MAGIC_WORD, "dfu_flash_code", NOR_FLASH5_DEV_NAME, 0x00220000, 0x00080000, 0}, \\
{FAL_PART_MAGIC_WORD, "fs_region", NOR_FLASH5_DEV_NAME, 0x00600000, 0x00100000, 0}, \\
{FAL_PART_MAGIC_WORD, "<name>", NOR_FLASHx_DEV_NAME, <offset>, <size>, 0}, \\
... \\
}
Device names are determined by the storage region, not by exec:
mpi1..mpi5→NOR_FLASH1_DEV_NAME…NOR_FLASH5_DEV_NAMEsdmmc1→SDMMC1_DEV_NAMEsdmmc2→SDMMC2_DEV_NAME
Build system integration
Auto-detection
The build system detects ptab format in this order:
Look for
ptab.yaml(v3)If absent, fall back to
ptab.json(v1/v2)
Search priority:
$BSP_ROOT/<board>/$BSP_ROOT/<chip>/$BSP_ROOT/customer/boards/<board>/
Project-level partition overlays
If a project only needs small adjustments, use ptab.overlay.yaml rather than copying the full board ptab.yaml.
Overlay filenames supported:
<project>/<chip>/ptab.overlay.yaml<project>/<board>/ptab.overlay.yaml
Notes:
<chip>usesCHIP.lower()from boardrtconfig.py, e.g.sf32lb52x<board>uses the full board name including core suffix, e.g.sf32lb52-lcd_n16r8_hcpuBoard overlay has higher priority than chip overlay
Overlay files should only contain a top-level partitions field. Example:
partitions:
- op: override
name: fs_region
size: 5MB
- op: add
name: log_region
type: data
subtype: raw
region: mpi2
offset: 0x00F00000
size: 64KB
op is optional but recommended for clarity. Meaning:
op: overridemodifies an existing partitionop: addadds a new partitionIf
opis omitted: existingname→override, missingname→add
Restrictions:
Overlay supports only partition-level changes; it cannot change
memory,chip, orversionOverlay cannot delete partitions
Overlay applies only to board-level
ptab.yaml(v3); it cannot be layered overptab.jsonIf the board still uses
ptab.json(v1/v2) and no fullptab.yamlis found in the project, the build system will ignoreptab.overlay.yaml, emit a warning, and continue with legacy PTAB behaviorIf a project provides a full
ptab.yaml/ptab.json, it must not also useptab.overlay.yaml
When processing overlays the build system prints a summary via rich and writes ptab.effective.yaml in the build directory for inspection.
Note:
If an overlay is ignored because the board uses ptab.json, ptab.effective.yaml will not be generated. That warning means the build falls back to v1/v2 behavior, not that the overlay has been applied.
Generated artifacts
Artifact |
Description |
|---|---|
|
C header with partition macros |
|
Binary Flash Table used by the bootloader |
|
GCC / Keil link scripts |
|
Final effective PTAB YAML when overlay is applied |
ptab v3 and custom_mem_map.h
Projects using ptab v3 do not need to maintain board-level custom_mem_map.h. Prefer using the generated ptab.h as the source of partition macros.
Migration steps to ptab v3:
Convert board
ptab.jsontoptab.yaml.Remove board-level
custom_mem_map.h(e.g.customer/boards/<board>/{hcpu,lcpu,acpu}/custom_mem_map.h).Clean any existing
build_xxxdirectories and rebuild.
Notes:
Do not manually define
FAL_PART_TABLEin board headers;ptab.hauto-generates it based onflashdb_kv/filesystem/app(subtype != ex)partitions.If the board
custom_mem_map.his not removed, the build may still generatebuild_xxx/custom_mem_map.h, leading toFAL_PART_TABLE redefinedwarnings.Deleting board headers while leaving old
build_xxx/custom_mem_map.hfiles may also trigger legacy warnings; clean build directories to avoid this.
app/ex resource partition artifacts (ptab v3 + GCC/Keil)
ptab v3 uses type: app with subtype: ex to describe resource partitions. The build system generates linker script fragments per resource partition: GCC assigns each resource partition a MEMORY region and emits an output section .<name> (lowercase), Keil produces LR_<NAME> / ER_<NAME> areas. Both toolchains normalize artifact names under output/.
GCC default collection rule:
.<name> : { *(.<NAME>*) } > <NAME>
If a partition declares sections, the build will also collect the specified input sections or object + section selectors in addition to the default rule.
Output files under each build directory’s output/:
Code image (ELF-exported code excluding all
.<resource_name>sections):Single final binary:
build_xxx/output/main.bin,build_xxx/output/main.hexWhen code image + one or more
app/exresource images are present:build_xxx/output/main.app.bin,build_xxx/output/main.app.hexProject-named variants:
build_xxx/<proj>/output/<proj>.binor.../<proj>.app.bin
Resource images (one file per
app/expartition):Filenames use the partition
nameverbatim (not uppercased)Examples:
build_xxx/output/main.hcpu_flash2_img.binbuild_xxx/output/main.hcpu_flash2_font.bin
Corresponding
.hexfiles are also produced
If a resource partition has no corresponding input section or the section is empty, the build skips generating that partition’s main.<partition_name>.bin/.hex without error.
Avoid naming app/ex partitions app to prevent filename collisions on case-insensitive filesystems.
ftab.bin generation
In v3, ftab.bin is generated directly by a Python script rather than building an ftab subproject:
Generating build_xxx/ftab.bin ...
Generated ftab.bin: build_xxx/ftab.bin (11280 bytes)
jinja2 link script templates
In ptab v1/v2, link scripts were produced using the compiler’s C-style preprocessor.
In ptab v3:
GCC link scripts use jinja2 templates located by default at
drivers/cmsis/<chip>/Templates/gcc/<core>/link.jinja2Keil
.sctjinja2 templates are located atdrivers/cmsis/<chip>/Templates/arm/<core>/link.sct.jinja2and need manual maintenance
Notes:
tools/build/migrate_ptab_to_v3.pyonly migratesptab.json -> ptab.yaml; it does not migrate link scripts.If a project or board uses custom link scripts, those must be manually migrated to
link.jinja2orlink.sct.jinja2.ptab v3 requires jinja2 templates; it cannot use the C preprocessor-based link script generation.
ptab v1/v2 do not support jinja2 templates.
validate_ptab_v3.py
Validate a ptab v3 file for correctness:
python tools/build/validate_ptab_v3.py customer/boards/<board>/ptab.yaml
Validation checks include:
Partition name format
Type/subtype validity
Region name validity
Partition overlap detection
bootloaderpartition uniqueness
sdk.py ptab-export
To inspect the final effective PTAB YAML for a project run:
sdk.py ptab-export --board=<board_name>
Common usage:
sdk.py ptab-export --board=sf32lb52-lcd_n16r8_hcpu
sdk.py ptab-export --board=sf32lb52-lcd_n16r8_hcpu --output /tmp/ptab.effective.yaml
sdk.py ptab-export --strict
Notes:
By default, the final YAML is printed to stdout.
--outputwrites the effective YAML to a file--stricttreats warnings as failuresThis command uses the same PTAB parsing and overlay merge logic as the build
FAQ
Q: How do I add custom macros?
Use the attrs field:
- name: my_partition
type: data
subtype: flashdb_kv
region: mpi2
offset: 0x100000
size: 64KB
attrs:
MY_CUSTOM_MACRO: 0x12345678
This generates:
#define MY_CUSTOM_MACRO (0x12345678)
Change history
Version |
Date |
Notes |
|---|---|---|
v3.4 |
2026-04 |
|
v3.3 |
2026-03 |
Added default partition inference rules; allowed omission of default |
v3.2 |
2026-03 |
Added project-level |
v3.1 |
2026-03 |
Clarified relationship between ptab v3 and |
v3.0 |
2024-12 |
Initial release; YAML format; removed ftab subproject |