PSoC6 I2C stops working with DFU added

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

cross mob
BeMb_4626836
Level 1
Level 1
First like given Welcome!

Hi.guys

our project works fine when downloaded with SWD to our PCBA.

We added DFU SDK with UART interface, our application stops at I2C's

There is a posted discussion with similar issue:

Re: PSoC 6 I2C Stops Working When DFU SDK Included

Can you provide a code snipet how this issue was addressed.

I did send the same question to Dheeraj and Ganesh

Thanks
Ben

0 Likes
1 Solution

The issue was caused due to misalignment of memory. In the DFU project, all the ram_appX_core0 regions have to be 0x100 aligned and the ram_appX_core1 regions have to be 0x400 aligned.

Before:

ram_app1_core0    (rwx) : ORIGIN = 0x08000100, LENGTH = 0x14000

ram_app1_core1    (rwx) : ORIGIN = 0x08014100, LENGTH = 0x33700

After:

ram_app1_core0 (rwx) : ORIGIN = 0x08000100, LENGTH = 0x13F00

ram_app1_core1 (rwx) : ORIGIN = 0x08014000, LENGTH = 0x33800

The reason it fails in the I2C is because when I2C tries to trigger the interrupt, the interrupt vectors in the ram regions are incorrectly aligned which causes a hard fault. After making this change, the project works as expected!

Regards,

Dheeraj

View solution in original post

0 Likes
5 Replies
lock attach
Attachments are accessible only for community members.
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi Ben,

Please check the linker scripts (dfu_cm0p.ld and dfu_cm4.ld) present in the attached code example. In that, please check the space allocated for the FLASH memory and RAM the respective core in which I2C code is placed and adjust them accordingly. For example, CM0+ linker file looks like this:

linker_script.PNG

Please use PDL 3.1.3 to build and program the attached code example.

Thanks

Ganesh

0 Likes

Thanks Ganesh,
I checked the code.

Is the recommendation to use CY_SECTION to allocate flash/RAM to functions with I2C calls?
Do you have a concrete examples you can share?
For code you provided, there are no CY_SECTION directives used for functions in "DOWNLOADALE" project (app1);

There are however a couple in the "LOADER" project (bootloader)

Find results for 'CY_SECTION':

------------------------------

C:\Users\benmb\Documents\partners\cypress\Projects\DFU\DFU_UART_SINGLE_APP_I2C.cywrk.Archive01\DFU_UART_SINGLE_APP\LOADER.cydsn\dfu_user.c - (line 36, col 1): CY_SECTION(".cy_boot_metadata") __USED

C:\Users\benmb\Documents\partners\cypress\Projects\DFU\DFU_UART_SINGLE_APP_I2C.cywrk.Archive01\DFU_UART_SINGLE_APP\LOADER.cydsn\Generated_Source\PSoC6\pdl\drivers\peripheral\flash\cy_flash.c - (line 258, col 9):         CY_SECTION(".cy_ramfunc") CY_NOINLINE

C:\Users\benmb\Documents\partners\cypress\Projects\DFU\DFU_UART_SINGLE_APP_I2C.cywrk.Archive01\DFU_UART_SINGLE_APP\LOADER.cydsn\Generated_Source\PSoC6\pdl\drivers\peripheral\flash\cy_flash.c - (line 349, col 5):     CY_SECTION(".cy_ramfunc") CY_NOINLINE

C:\Users\benmb\Documents\partners\cypress\Projects\DFU\DFU_UART_SINGLE_APP_I2C.cywrk.Archive01\DFU_UART_SINGLE_APP\LOADER.cydsn\Generated_Source\PSoC6\pdl\drivers\peripheral\flash\cy_flash.c - (line 509, col 9):         CY_SECTION(".cy_ramfunc") CY_NOINLINE

C:\Users\benmb\Documents\partners\cypress\Projects\DFU\DFU_UART_SINGLE_APP_I2C.cywrk.Archive01\DFU_UART_SINGLE_APP\LOADER.cydsn\Generated_Source\PSoC6\pdl\drivers\peripheral\flash\cy_flash.c - (line 572, col 13):             CY_SECTION(".cy_ramfunc") CY_NOINLINE

C:\Users\benmb\Documents\partners\cypress\Projects\DFU\DFU_UART_SINGLE_APP_I2C.cywrk.Archive01\DFU_UART_SINGLE_APP\LOADER.cydsn\Generated_Source\PSoC6\pdl\drivers\peripheral\syspm\cy_syspm.c - (line 2791, col 5):     CY_SECTION(".cy_ramfunc") CY_NOINLINE

C:\Users\benmb\Documents\partners\cypress\Projects\DFU\DFU_UART_SINGLE_APP_I2C.cywrk.Archive01\DFU_UART_SINGLE_APP\LOADER.cydsn\Generated_Source\PSoC6\pdl\dfu\cy_dfu.c - (line 22, col 1): CY_SECTION(".cy_boot_noinit.appId") __USED static uint8_t cy_dfu_appId;

0 Likes

Hi Ben,

Is the recommendation to use CY_SECTION to allocate flash/RAM to functions with I2C calls?

No actually. You just have to ensure that proper flash area is allocated for the CM0+ and CM4 cores.

The I2C used in the code example is fixed function I2C. So the registers of that particular I2C block is present in peripheral memory address space. There is no need to place the code corresponding to I2C in a separate section. In case you want to store some data in flash you can create a section for that data and use Emulated EEPROM component to store the data in that flash.

Can you please attach your project (which is not working with I2C and UDB)? I will check it here once and get back to you with changes required.

Thanks

Ganesh

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

Hi Ganesh,
thanks for your feedback.

My project is pretty large though.
I have attached a couple of file where we are having the DFU/I2C issues.
We have some screen files as data and use I2C to render the touchscreen data.
We store this data in the internal flash and also have I2C talks in the internal flash.thin

Everything works when downloaded with SWD, but stops at I2C when downloaded with DFU/UART

Thanks

Ben

0 Likes

The issue was caused due to misalignment of memory. In the DFU project, all the ram_appX_core0 regions have to be 0x100 aligned and the ram_appX_core1 regions have to be 0x400 aligned.

Before:

ram_app1_core0    (rwx) : ORIGIN = 0x08000100, LENGTH = 0x14000

ram_app1_core1    (rwx) : ORIGIN = 0x08014100, LENGTH = 0x33700

After:

ram_app1_core0 (rwx) : ORIGIN = 0x08000100, LENGTH = 0x13F00

ram_app1_core1 (rwx) : ORIGIN = 0x08014000, LENGTH = 0x33800

The reason it fails in the I2C is because when I2C tries to trigger the interrupt, the interrupt vectors in the ram regions are incorrectly aligned which causes a hard fault. After making this change, the project works as expected!

Regards,

Dheeraj

0 Likes