Operation of DFU and Flash Memory

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

cross mob
lock attach
Attachments are accessible only for community members.
MuNa_4652896
Level 4
Level 4
First like received First like given

Hello

Following up with several tutorials, I was able to flash App0 and use it to update the Firmware and add App1 via BLE.

Now I am wondering, Where are the settings that tell App0 DFU process to flash App1 starting from this memory location in the flash memory?

So

1 - I tried flashing App0 then Flashing App1 without erasing the Flash Memory (using Psoc Programmer) but it didn't work. App0 as still active, but switching to App1 just crashes the psoc. Why? (I edited the flash addresses in cy8c6xx7_cm0plus.ld and cy8c6xx7_cm4_dual.ld with those found in dfu_cm0.ld and dfu_cm4.ld respectively)

2 - Checking the attached example, Why flashing App1 directly (Bootloadable) doesn't work as normal firmware?

3 - In all examples, App0(Bootloader) shall be flashed first then App1(Bootloadable) shall be flashed using App0. How can I have both into the same App without having to flash twice (One with programmer and one through DFU)

4- Any references or material to understand more about the operation of DFU.

5 - How to maintain BLE Advertising name across App1 Updates?

Thank you

0 Likes
1 Solution

For some reason the highlighted part in bold is causing a problem, and I usually get a Failed to thne App0.elf file

%CY_MCU_ELF_TOOL% -M %OUTPUT_DIR%\%PRJ_NAME%%ELF_EXT% ../PSoC6DfuBleApp0.cydsn/%OUTPUT_DIR%\PSoC6DfuBleApp0.elf --output %OUTPUT_DIR%\%PRJ_NAME%_merged%ELF_EXT% --hex %OUTPUT_DIR%\%PRJ_NAME%_test.hex

I used this instead with explicitly mentioning the directory name

%CY_MCU_ELF_TOOL% -M %OUTPUT_DIR%\%PRJ_NAME%%ELF_EXT% %OUTPUT_DIR%\PSoC6DfuBleApp0%ELF_EXT% --output %OUTPUT_DIR%\%PRJ_NAME%_merged%ELF_EXT% --hex %OUTPUT_DIR%\%PRJ_NAME%_merged.hex

Now, App1 boots without problems and I can switch between them.

Regarding Point #5. Any insights yet?

View solution in original post

0 Likes
8 Replies
RavikiranH_01
Employee
Employee
10 sign-ins 25 replies posted 10 replies posted

Hi MuNa_4652896​,

Please refer the linker files. dfu_cm<x>.ld file will have the memory map defined for each of the application.

below snippet is taken from dfu_cm0p.ld, just for illustration here.

    flash_app0_core0  (rx)  : ORIGIN = 0x10000000, LENGTH = 0x20000

    flash_app0_core1  (rx)  : ORIGIN = 0x10020000, LENGTH = 0x20000

    flash_app1_core0  (rx)  : ORIGIN = 0x10050000, LENGTH = 0x10000

    flash_app1_core1  (rx)  : ORIGIN = 0x10060000, LENGTH = 0x10000

1. Please take a look at dfu_cm<X>.ld files ,  if you are using DFU code example.
Please refer below link for more details.
https://www.cypress.com/documentation/code-examples/ce213903-psoc-6-mcu-basic-device-firmware-update...

2. I haven't checked the attached code. But, APP1 can't boot directly in  DFU CE because the memory map is designed so. It depends on what you have placed in 0x10000000 in linker files. Please refer dfu_cm<X>.ld file and "Operation"  section of CE213903 – PSoC 6 MCU Basic Device Firmware Update (DFU) document

3 .  You can use cymcuelftool.exe tool to combine the images (-M option)
C:\Program Files (x86)\Cypress\PDL\3.1.0\tools\win\elf\cymcuelftool.exe"

4-  Please refer AN213924 along with

https://www.cypress.com/documentation/code-examples/ce213903-psoc-6-mcu-basic-device-firmware-update...

Cypress Device Firmware Update (DFU) Middleware Library 4.0: API Reference

5 - BLE advertisement name doesn't change, unless you intentionally change the name in BLE component configuration.
BLE component configuration page provides several option to customize the BLE properties including advertisement name, interval etc.
You may want to leave that untouched to retain the properties across updates.

Hope it helps.

Thanks !

0 Likes

Thanks RavikiranH_01​ for your helpful response.

1 - Alright. Let me review this part again.

From dfu_cm<x>.ld (This is in the common region. So it is the same across both Apps and Cores)

flash_app0_core0  (rx)  : ORIGIN = 0x10000000, LENGTH = 0x10000

flash_app0_core1  (rx)  : ORIGIN = 0x10010000, LENGTH = 0x30000

flash_app1_core0  (rx)  : ORIGIN = 0x10040000, LENGTH = 0x30000

flash_app1_core1  (rx)  : ORIGIN = 0x10070000, LENGTH = 0x10000

For App0

cy8c6xx7_cm0plus.ld

flash             (rx)    : ORIGIN = 0x10000000, LENGTH = 0x10000

For App0

cy8c6xx7_cm4_dual.ld

flash             (rx)    : ORIGIN = 0x10010000, LENGTH = 0x30000

For App1

cy8c6xx7_cm0plus.ld

flash             (rx)    : ORIGIN = 0x10040000, LENGTH = 0x30000

For App1

cy8c6xx7_cm4_dual.ld

    flash             (rx)    : ORIGIN = 0x10070000, LENGTH = 0x10000

Rephrasing my process. I flash (*.hex) of App0 to the Kit using. Then I upgrade the firmware using CySmart to upload the *Cyacd2 file. Switch to App1 with no problems.

Now, I decided to have two hex files. One for App0 and one for App1. I use PSoC Programmer to Erase the Flash Memory. Flash App0 and then without Erasing the Flash Memory, I flash App1.

Why I cannot mimic this behavior by directly flashing the hex file at the same address as the same DFU process. What am I missing here?

2 - Thank you. This was informative.

3 - Does this tool merge the *.hex files or the *.elf files? If the *.elf. What are the target *.elf files here?

I found this command

@rem Merges App0 and App1 into a single hex file for easier programming

%CY_MCU_ELF_TOOL% -M %OUTPUT_DIR%\%PRJ_NAME%%ELF_EXT% ..\PSoC6DfuBleApp0%ELF_EXT% --output %OUTPUT_DIR%\%PRJ_NAME%_merged%ELF_EXT% --hex %OUTPUT_DIR%\%PRJ_NAME%.hex

EDIT: I fixed it

%CY_MCU_ELF_TOOL% -M %OUTPUT_DIR%\%PRJ_NAME%%ELF_EXT% %OUTPUT_DIR%\PSoC6DfuBleApp0%ELF_EXT% --output %OUTPUT_DIR%\%PRJ_NAME%_merged%ELF_EXT% --hex %OUTPUT_DIR%\%PRJ_NAME%_merged.hex

I placed PSoC6DfuBleApp0.elf  into the same directory as PSoC6DfuBleApp1.elf.

And I always get ..\PSoC6DfuBleApp0.elf: Failed to open ..\PSoC6DfuBleApp0.elf error, when merging. I dunno why? Address Overlapping? If so, how can I check this?

4 - Thank you for the references. I  will come back with questions regarding this later.

5 - For this part. Lets assume I have 2 kits. I flashed two kits BLE Advertising names BLE1 and BLE2 respectively. Now fixed some bugs or added new features to App1.

I want to flash two kits with the new image, but still retaining the same BLE Advertising names BLE1 and BLE2 for the kits without the need to do it manually for each kit.

My question rephrased in another way, Is it possible to exclude certain component configurations at will from the patch .cyacd2 image? Is this possible?

Thank you very much

0 Likes

Hi,

For the first issue you mentioned, please can you attach the call stack, when it crashes?

Also, looks like you are attempting to run BLE on different cores in App0(CM4) and App1(CM0). Is that intentional ? 

0 Likes

How can I get the call stack? Or shall I run in debugging mode?

Not intentional at all. I used the examples as they are provided. How this can cause a problem?

0 Likes

Please program both the hex files to the device as needed and then

  • Set APP1 as active project in PSoC Creator
  • Select Debug-->attach tp running target option.
  • Select CM0 core and attach to it.
  • Now collect the call stack window contents (that would automatically popup)

Not intentional at all. I used the examples as they are provided. How this can cause a problem?

No, I Don't think that problem is caused by that. I haven't closely looked into your project yet. Hopefully, I will get some time tomorrow to take a look.

Thanks

0 Likes

MuNa_4652896​,

Meanwhile,
1. please copy paste below line to your post_build_core1.bat file in APP1 project. %CY_MCU_ELF_TOOL% -M %OUTPUT_DIR%\%PRJ_NAME%%ELF_EXT% ../PSoC6DfuBleApp0.cydsn/%OUTPUT_DIR%\PSoC6DfuBleApp0.elf --output %OUTPUT_DIR%\%PRJ_NAME%_merged%ELF_EXT% --hex %OUTPUT_DIR%\%PRJ_NAME%_test.hex

2.  Program the newly generated hex file (_test.hex under APP2).

Please let me know, if that helps to boot APP2 without any issues.

Thanks

For some reason the highlighted part in bold is causing a problem, and I usually get a Failed to thne App0.elf file

%CY_MCU_ELF_TOOL% -M %OUTPUT_DIR%\%PRJ_NAME%%ELF_EXT% ../PSoC6DfuBleApp0.cydsn/%OUTPUT_DIR%\PSoC6DfuBleApp0.elf --output %OUTPUT_DIR%\%PRJ_NAME%_merged%ELF_EXT% --hex %OUTPUT_DIR%\%PRJ_NAME%_test.hex

I used this instead with explicitly mentioning the directory name

%CY_MCU_ELF_TOOL% -M %OUTPUT_DIR%\%PRJ_NAME%%ELF_EXT% %OUTPUT_DIR%\PSoC6DfuBleApp0%ELF_EXT% --output %OUTPUT_DIR%\%PRJ_NAME%_merged%ELF_EXT% --hex %OUTPUT_DIR%\%PRJ_NAME%_merged.hex

Now, App1 boots without problems and I can switch between them.

Regarding Point #5. Any insights yet?

0 Likes

MuNa_4652896​,

Glad to hear that you could program both the images successfully now.

Apologies for a long pause.  Regarding point#5, if you are using CySmart tool, I don't think there is an option.
However, if you have your custom application implemented, you can choose to ignore the names and make use of MAC, service UUID's & characteristics etc to determine if the device requires an update and download your OTA to specific targets.

Thanks