DFU Postbuild script merging ELF files error in MTB 2.1

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
OkBa_4438736
Level 3
Level 3
10 replies posted 5 replies posted 5 questions asked

Hi,

I am using  two APPs for DFU functionality. App0 is just used as a launcher and App1 provides the main logic.

I would like to program the PSOC6 with an ELF file which includes both APPs.

Therefore, I merge both ELF files after the build.

Postbuild  in Makefile of APP0 :

# Custom post-build commands to run.

POSTBUILD= "$(CY_MCUELFTOOL_DIR)/bin/cymcuelftool.exe" --sign $(CY_CONFIG_DIR)/$(APPNAME).elf --output $(CY_CONFIG_DIR)/$(APPNAME)_signed.elf

Postbuild  in Makefile of APP1 :

# Custom post-build commands to run.

POSTBUILD= "$(CY_MCUELFTOOL_DIR)/bin/cymcuelftool.exe" --sign $(CY_CONFIG_DIR)/$(APPNAME).elf --output $(CY_CONFIG_DIR)/$(APPNAME)_signed.elf  && \

"$(CY_MCUELFTOOL_DIR)/bin/cymcuelftool.exe" --merge $(CY_CONFIG_DIR)/$(APPNAME)_signed.elf \

$(APP0_DIR)/$(APP0NAME)_signed.elf --output $(APP0_DIR)/$(APPNAME)_merged.elf --hex $(CY_CONFIG_DIR)/$(APPNAME).hex

Eventually when I build APP1, I get following build error

"C:/Users/OKBA/ModusToolbox/tools_2.1/cymcuelftool-1.0/bin/cymcuelftool.exe" --sign C:/Users/OKBA/Downloads/BLE_Battery_Level_FreeRTOS_Custom_Print/BLE_Battery_Level_FreeRTOS/build/CY8CPROTO-063-BLE/Debug/DFU_App1.elf --output C:/Users/OKBA/Downloads/BLE_Battery_Level_FreeRTOS_Custom_Print/BLE_Battery_Level_FreeRTOS/build/CY8CPROTO-063-BLE/Debug/DFU_App1_signed.elf  && "C:/Users/OKBA/ModusToolbox/tools_2.1/cymcuelftool-1.0/bin/cymcuelftool.exe" --merge C:/Users/OKBA/Downloads/BLE_Battery_Level_FreeRTOS_Custom_Print/BLE_Battery_Level_FreeRTOS/build/CY8CPROTO-063-BLE/Debug/DFU_App1_signed.elf C:/Users/OKBA/mtw_2_1/DFU_App0/build/CY8CPROTO-063-BLE/Debug/DFU_App0_signed.elf --output C:/Users/OKBA/mtw_2_1/DFU_App0/build/CY8CPROTO-063-BLE/Debug/DFU_App1_merged.elf --hex C:/Users/OKBA/Downloads/BLE_Battery_Level_FreeRTOS_Custom_Print/BLE_Battery_Level_FreeRTOS/build/CY8CPROTO-063-BLE/Debug/DFU_App1.hex

SUCCESS: calculated CRC-32C over ELF section .cy_boot_metadata and stored

ELF section .cy_app_signature found, but no hash specified. Skipping application signature

No ELF section .cychecksum found, creating one

Application checksum calculated and stored in ELF section .cychecksum

No ELF section .cymeta found, creating one

Checksum calculated and stored in ELF section .cymeta

C:/Users/OKBA/mtw_2_1/DFU_App0/build/CY8CPROTO-063-BLE/Debug/DFU_App0_signed.elf: Merge error: Section 0x100FFA00 at C:/Users/OKBA/mtw_2_1/DFU_App0/build/CY8CPROTO-063-BLE/Debug/DFU_App0_signed.elf overlaps section 0x100FFA00 from C:/Users/OKBA/Downloads/BLE_Battery_Level_FreeRTOS_Custom_Print/BLE_Battery_Level_FreeRTOS/build/CY8CPROTO-063-BLE/Debug/DFU_App1_signed.elf,

but it contains different data

The referred error is Section 0x100FFA00

is

flash_boot_meta   (rw)  : ORIGIN = 0x100FFA00, LENGTH = 0x400

in the linker script file. I use the default linker scripts that come with DFU library with some small changes:

defu.jpg

Do you have any idea about why I get this error.

Regards,

0 Likes
1 Solution

Hi OkBa_4438736​,

I just tried your linker and postbuild scripts with the KBA229130 example:

Set Up a Basic DFU Application in ModusToolbox 2.0 for PSoC 6 MCU Device – KBA229130

The postbuild merge command worked fine for me.

In the KBA there's a note:

"NOTE: Do not copy dfu_user.c to avoid duplication of the metadata structures."

If you, for example, would miss that note and copy the file anyway into the loadable project and change the content of the const array cy_dfu_metadata[], in only one of the projects then you would get the error message you're seeing because the two elf files would then contain different data at that address.

You should be able to use the "readelf" utility to examine the elf files and determine what's causing your memory collision.

/Håkan

View solution in original post

3 Replies
DheerajK_81
Moderator
Moderator
Moderator
First comment on KBA First comment on blog 5 questions asked

Whatever changes you do the linker script, make sure you copy the same into the linker script of the other app. What I mean is, if you edited the memory layout in the linker script dfu_cm4_app0.ld file, then make sure you copy the same memory layout in the file dfu_cm4_app1.ld file. Otherwise you will get a merge error when you use the cymcuelftool.

Please attach your linker scripts here if you have the same memory layout in both the files and still see this error, I'll have a look.

Regards,

Dheeraj

0 Likes
lock attach
Attachments are accessible only for community members.

Hi DheerajK_81​,

I have same memory layout in both the files.You can find them enclosed.

Regards

0 Likes

Hi OkBa_4438736​,

I just tried your linker and postbuild scripts with the KBA229130 example:

Set Up a Basic DFU Application in ModusToolbox 2.0 for PSoC 6 MCU Device – KBA229130

The postbuild merge command worked fine for me.

In the KBA there's a note:

"NOTE: Do not copy dfu_user.c to avoid duplication of the metadata structures."

If you, for example, would miss that note and copy the file anyway into the loadable project and change the content of the const array cy_dfu_metadata[], in only one of the projects then you would get the error message you're seeing because the two elf files would then contain different data at that address.

You should be able to use the "readelf" utility to examine the elf files and determine what's causing your memory collision.

/Håkan