Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Telink] Flash various sizes support #29726

Merged
merged 13 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ jobs:
- name: clean out build output (keep tools)
run: rm -rf ./out/telink*

- name: Build example Telink (B91) Lighting App with RPC, Shell and Factory Data
- name: Build example Telink (B91) Lighting App with OTA, RPC, Factory Data and 4Mb flash
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-light-rpc-shell-factory-data' build"
"./scripts/build/build_examples.py --target 'telink-tlsr9518adk80d-light-ota-rpc-factory-data-4mb' build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
telink tlsr9518adk80d lighting-app-rpc-shell-factory-data \
out/telink-tlsr9518adk80d-light-rpc-shell-factory-data/zephyr/zephyr.elf \
Expand All @@ -136,10 +136,10 @@ jobs:
- name: clean out build output (keep tools)
run: rm -rf ./out/telink*

- name: Build example Telink (B92) Light Switch App with RPC, Shell and Factory Data
- name: Build example Telink (B92) Light Switch App with OTA, Shell, Factory Data
run: |
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py --target 'telink-tlsr9528a-light-switch-rpc-shell-factory-data' build"
"./scripts/build/build_examples.py --target 'telink-tlsr9528a-light-switch-ota-shell-factory-data' build"
.environment/pigweed-venv/bin/python3 scripts/tools/memory/gh_sizes.py \
telink tlsr9528a light-switch-app-rpc-shell-factory-data \
out/telink-tlsr9528a-light-switch-rpc-shell-factory-data/zephyr/zephyr.elf \
Expand Down
28 changes: 20 additions & 8 deletions config/telink/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ else()
unset(GLOBAL_BOOTLOADER_CONF_OVERLAY_FILE)
endif()

set(BLOCK_SIZE "1024")

# get code-partition mcuboot_partition size
dt_nodelabel(dts_partition_path NODELABEL "boot_partition")
dt_reg_size(mcuboot_size PATH ${dts_partition_path})
math(EXPR boot_blocks "${mcuboot_size} / ${BLOCK_SIZE}" OUTPUT_FORMAT DECIMAL)

if (CONFIG_CHIP_OTA_IMAGE_BUILD)
add_custom_target(build_mcuboot ALL
COMMAND
Expand All @@ -176,7 +183,7 @@ if (CONFIG_CHIP_OTA_IMAGE_BUILD)
COMMAND
dd if=${PROJECT_BINARY_DIR}/../modules/chip-module/build_mcuboot/zephyr/zephyr.bin of=${PROJECT_BINARY_DIR}/zephyr.bin
COMMAND
dd if=${PROJECT_BINARY_DIR}/zephyr.signed.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=100
dd if=${PROJECT_BINARY_DIR}/zephyr.signed.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=${BLOCK_SIZE} seek=${boot_blocks}
)

chip_ota_image(chip-ota-image
Expand All @@ -188,16 +195,21 @@ if (CONFIG_CHIP_OTA_IMAGE_BUILD)
add_dependencies(chip-ota-image ${ZEPHYR_FINAL_EXECUTABLE})
endif()

# get code-partition factory_partition address
dt_nodelabel(dts_partition_path NODELABEL "factory_partition")
dt_reg_addr(factory_size PATH ${dts_partition_path})
math(EXPR factory_blocks "${factory_size} / ${BLOCK_SIZE}" OUTPUT_FORMAT DECIMAL)

if (CONFIG_CHIP_FACTORY_DATA_MERGE_WITH_FIRMWARE)
add_custom_target(merge_factory_data ALL
COMMAND
dd if=${PROJECT_BINARY_DIR}/factory/factory_data.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=1024 seek=1052
)
if (CONFIG_CHIP_OTA_IMAGE_BUILD)
add_custom_target(merge_factory_data ALL
COMMAND
dd if=${PROJECT_BINARY_DIR}/factory/factory_data.bin of=${PROJECT_BINARY_DIR}/zephyr.bin bs=${BLOCK_SIZE} seek=${factory_blocks}
)
if (CONFIG_CHIP_OTA_IMAGE_BUILD)
add_dependencies(merge_factory_data merge_mcuboot)
else()
else()
add_dependencies(merge_factory_data ${ZEPHYR_FINAL_EXECUTABLE})
endif()
endif()
endif()

# ==============================================================================
Expand Down
11 changes: 11 additions & 0 deletions config/telink/chip-module/generate_factory_data.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,17 @@ if(CONFIG_CHIP_DEVICE_ENABLE_KEY)
string(APPEND script_args "--enable-key \"${CONFIG_CHIP_DEVICE_ENABLE_KEY}\"\n")
endif()

# get code-partition factory_partition address
dt_nodelabel(dts_partition_path NODELABEL "factory_partition")
dt_reg_addr(factory_off PATH ${dts_partition_path})

# get code-partition factory_partition size
dt_nodelabel(dts_partition_path NODELABEL "factory_partition")
dt_reg_size(factory_size PATH ${dts_partition_path})

string(APPEND script_args "--offset ${factory_off}\n")
string(APPEND script_args "--size ${factory_size}\n")

string(APPEND script_args "--output \"${output_path}\"/factory\n")

set(factory_data_bin ${output_path}/factory/factory_data.bin)
Expand Down
12 changes: 10 additions & 2 deletions examples/air-quality-sensor-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@ else()
unset(GLOBAL_DTC_OVERLAY_FILE)
endif()

if(EXISTS "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
message(STATUS "Flash memory size is set to: " ${FLASH_SIZE} "b")
else()
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/2m_flash.overlay")
message(STATUS "Flash memory size is set to: 2mb")
endif()

if(DTC_OVERLAY_FILE)
set(DTC_OVERLAY_FILE
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
CACHE STRING "" FORCE
)
else()
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
endif()

set(CONF_FILE prj.conf)
Expand Down
9 changes: 8 additions & 1 deletion examples/air-quality-sensor-app/telink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ You can use this example as a reference for creating your own application.
$ west build -b <build_target>
```

Also use key `-DFLASH_SIZE`, if your board has memory size different from 2
MB, for example, `-DFLASH_SIZE=1m` or `-DFLASH_SIZE=1m`:

```bash
$ west build -b tlsr9518adk80d -- -DFLASH_SIZE=4m
```

4. Flash binary:

```
Expand Down Expand Up @@ -115,7 +122,7 @@ feature for another Telink example:

After build application with enabled OTA feature, use next binary files:

- zephyr.bin - main binary to flash PCB (Use 2MB PCB).
- zephyr.bin - main binary to flash PCB (Use at least 2MB PCB).
- zephyr-ota.bin - binary for OTA Provider

All binaries has the same SW version. To test OTA “zephyr-ota.bin” should have
Expand Down
12 changes: 10 additions & 2 deletions examples/all-clusters-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ else()
unset(GLOBAL_DTC_OVERLAY_FILE)
endif()

if(EXISTS "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
message(STATUS "Flash memory size is set to: " ${FLASH_SIZE} "b")
else()
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/2m_flash.overlay")
message(STATUS "Flash memory size is set to: 2mb")
endif()

if(DTC_OVERLAY_FILE)
set(DTC_OVERLAY_FILE
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
CACHE STRING "" FORCE
)
else()
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
endif()

set(CONF_FILE prj.conf)
Expand Down
9 changes: 8 additions & 1 deletion examples/all-clusters-app/telink/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ creating your own application.
$ west build -b <build_target>
```

Also use key `-DFLASH_SIZE`, if your board has memory size different from 2
MB, for example, `-DFLASH_SIZE=1m` or `-DFLASH_SIZE=1m`:

```bash
$ west build -b tlsr9518adk80d -- -DFLASH_SIZE=4m
```

4. Flash binary:

```
Expand Down Expand Up @@ -117,7 +124,7 @@ feature for another Telink example:

After build application with enabled OTA feature, use next binary files:

- zephyr.bin - main binary to flash PCB (Use 2MB PCB).
- zephyr.bin - main binary to flash PCB (Use at least 2MB PCB).
- zephyr-ota.bin - binary for OTA Provider

All binaries has the same SW version. To test OTA “zephyr-ota.bin” should have
Expand Down
12 changes: 10 additions & 2 deletions examples/all-clusters-minimal-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,21 @@ else()
unset(GLOBAL_DTC_OVERLAY_FILE)
endif()

if(EXISTS "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
message(STATUS "Flash memory size is set to: " ${FLASH_SIZE} "b")
else()
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/2m_flash.overlay")
message(STATUS "Flash memory size is set to: 2mb")
endif()

if(DTC_OVERLAY_FILE)
set(DTC_OVERLAY_FILE
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
CACHE STRING "" FORCE
)
else()
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
endif()

set(CONF_FILE prj.conf)
Expand Down
9 changes: 8 additions & 1 deletion examples/all-clusters-minimal-app/telink/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ for creating your own application.
$ west build -b <build_target>
```

Also use key `-DFLASH_SIZE`, if your board has memory size different from 2
MB, for example, `-DFLASH_SIZE=1m` or `-DFLASH_SIZE=1m`:

```bash
$ west build -b tlsr9518adk80d -- -DFLASH_SIZE=4m
```

4. Flash binary:

```
Expand Down Expand Up @@ -100,7 +107,7 @@ feature for another Telink example:

After build application with enabled OTA feature, use next binary files:

- zephyr.bin - main binary to flash PCB (Use 2MB PCB).
- zephyr.bin - main binary to flash PCB (Use at least 2MB PCB).
- zephyr-ota.bin - binary for OTA Provider

All binaries has the same SW version. To test OTA “zephyr-ota.bin” should have
Expand Down
12 changes: 10 additions & 2 deletions examples/bridge-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@ else()
unset(GLOBAL_DTC_OVERLAY_FILE)
endif()

if(EXISTS "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
message(STATUS "Flash memory size is set to: " ${FLASH_SIZE} "b")
else()
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/2m_flash.overlay")
message(STATUS "Flash memory size is set to: 2mb")
endif()

if(DTC_OVERLAY_FILE)
set(DTC_OVERLAY_FILE
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
CACHE STRING "" FORCE
)
else()
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
endif()

set(CONF_FILE prj.conf)
Expand Down
9 changes: 8 additions & 1 deletion examples/bridge-app/telink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,13 @@ defined:
$ west build -b <build_target>
```

Also use key `-DFLASH_SIZE`, if your board has memory size different from 2
MB, for example, `-DFLASH_SIZE=1m` or `-DFLASH_SIZE=1m`:

```bash
$ west build -b tlsr9518adk80d -- -DFLASH_SIZE=4m
```

4. Flash binary:

```
Expand Down Expand Up @@ -262,7 +269,7 @@ feature for another Telink example:

After build application with enabled OTA feature, use next binary files:

- zephyr.bin - main binary to flash PCB (Use 2MB PCB).
- zephyr.bin - main binary to flash PCB (Use at least 2MB PCB).
- zephyr-ota.bin - binary for OTA Provider

All binaries has the same SW version. To test OTA “zephyr-ota.bin” should have
Expand Down
12 changes: 10 additions & 2 deletions examples/chef/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,21 @@ else()
unset(GLOBAL_DTC_OVERLAY_FILE)
endif()

if(EXISTS "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
message(STATUS "Flash memory size is set to: " ${FLASH_SIZE} "b")
else()
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/2m_flash.overlay")
message(STATUS "Flash memory size is set to: 2mb")
endif()

if(DTC_OVERLAY_FILE)
set(DTC_OVERLAY_FILE
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
CACHE STRING "" FORCE
)
else()
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
endif()

set(CONF_FILE prj.conf)
Expand Down
12 changes: 10 additions & 2 deletions examples/contact-sensor-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@ else()
unset(GLOBAL_DTC_OVERLAY_FILE)
endif()

if(EXISTS "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
message(STATUS "Flash memory size is set to: " ${FLASH_SIZE} "b")
else()
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/2m_flash.overlay")
message(STATUS "Flash memory size is set to: 2mb")
endif()

if(DTC_OVERLAY_FILE)
set(DTC_OVERLAY_FILE
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
CACHE STRING "" FORCE
)
else()
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
endif()

set(CONF_FILE prj.conf)
Expand Down
9 changes: 8 additions & 1 deletion examples/contact-sensor-app/telink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ You can use this example as a reference for creating your own application.
$ west build -b <build_target>
```

Also use key `-DFLASH_SIZE`, if your board has memory size different from 2
MB, for example, `-DFLASH_SIZE=1m` or `-DFLASH_SIZE=1m`:

```bash
$ west build -b tlsr9518adk80d -- -DFLASH_SIZE=4m
```

4. Flash binary:

```
Expand Down Expand Up @@ -119,7 +126,7 @@ feature for another Telink example:

After build application with enabled OTA feature, use next binary files:

- zephyr.bin - main binary to flash PCB (Use 2MB PCB).
- zephyr.bin - main binary to flash PCB (Use at least 2MB PCB).
- zephyr-ota.bin - binary for OTA Provider

All binaries has the same SW version. To test OTA “zephyr-ota.bin” should have
Expand Down
12 changes: 10 additions & 2 deletions examples/light-switch-app/telink/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,21 @@ else()
unset(GLOBAL_DTC_OVERLAY_FILE)
endif()

if(EXISTS "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/${FLASH_SIZE}_flash.overlay")
message(STATUS "Flash memory size is set to: " ${FLASH_SIZE} "b")
else()
set(FLASH_DTC_OVERLAY_FILE "${CHIP_ROOT}/src/platform/telink/2m_flash.overlay")
message(STATUS "Flash memory size is set to: 2mb")
endif()

if(DTC_OVERLAY_FILE)
set(DTC_OVERLAY_FILE
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
"${DTC_OVERLAY_FILE} ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE}"
CACHE STRING "" FORCE
)
else()
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
set(DTC_OVERLAY_FILE ${GLOBAL_DTC_OVERLAY_FILE} ${FLASH_DTC_OVERLAY_FILE} ${LOCAL_DTC_OVERLAY_FILE})
endif()

set(CONF_FILE prj.conf)
Expand Down
Loading
Loading