cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC™ 6

WaLo_3890256
New Contributor II

Hello,

We need to pre-program Sflash before programming the application to PSoC6.

If we need to write 64 bytes of hex value such as "cdaa5e5bbc31ed47b9e1f5b07b919815c2e1dde780d9b4701c01f812cad407ef"

Is there any command can write hex value into entire Sflash row?

I have studied "Cypress Programmer 2.1 OpenOCD" but there's only write 4 bytes at one time

./openocd.exe -s ../scripts -f ../scripts/interface/kitprog3.cfg -f ../scripts/target/psoc6.cfg -c "init; reset init; flash fillw 0x16000800 0xcdaa5e5b 4; shutdown"

If I write next 4 bytes into next offset 0x16000900:

./openocd.exe -s ../scripts -f ../scripts/interface/kitprog3.cfg -f ../scripts/target/psoc6.cfg -c "init; reset init; flash fillw 0x16000800 0xcdaa5e5b 4; shutdown"

The previous value would be earsed.

Below is the way I used to read value form Sflash in my application:

uint8_t otp_key1[4] = {0};

uint8_t otp_key2[4] = {0};

emcpy(otp_key1, (const void *)0x16000800, 4);

memcpy(otp_key2, (const void *)0x16000900, 4);

Please correct me and help if my way is suitable.

Thanks.

BR,

Wayne

0 Likes
1 Solution
Vison_Zhang
Moderator
Moderator

flash rmw <address> <data> ocd command can be used to program multi-bytes data into dedicate address of FALSH/SFALSH region.

View solution in original post

0 Likes
4 Replies
Vison_Zhang
Moderator
Moderator

flash rmw <address> <data> ocd command can be used to program multi-bytes data into dedicate address of FALSH/SFALSH region.

View solution in original post

0 Likes
WaLo_3890256
New Contributor II

Thanks for your greap help!

It works for using flash rmw

0 Likes
Vison_Zhang
Moderator
Moderator

Why you need pre-program SFLASH content before program FLASH? You know you can define the content of SFLASH in firmware also, then user SFALSH can be programmed together with FLASH during silicon programming.

For example: Add below code in main.c, then you can find user sflash region is include in generated HEX file.

CY_SECTION(".cy_sflash_user_data") CY_ALIGN(CY_FLASH_SIZEOF_ROW)

const uint8_t sFLASH_UserData[10] = {0x50, 0x6F, 0x77, 0x65, 0x72, 0x43, 0x79, 0x63, 0x6C, 0x65};

Capture.PNG

WaLo_3890256
New Contributor II

Hi XiaoweiZ_71

We need to pre-program a set of hash key that calculated with MAC address to SFLASH before programming the application, then our application code will read from SFLASH and check if key is correct. This is designed to sign our fw.

Thanks.

BR,

Wayne

0 Likes
Top labels