External Memory Programming through UART Bootloader using PSoC5LP

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

cross mob
Anonymous
Not applicable

I implemented a UART based bootloader on PSoC5LP kit having CY8C5888LTI-LP097 controller which stores the application on internal flash. Now I want the Bootloader to download the application on External Flash or EEPROM and Download the application from external memory upon a key press to the internal memory. IS it possible ? if yes then guide me how to proceed.

0 Likes
1 Solution
Anonymous
Not applicable

Hi Aditya,

   

Your external flash/EEPROM is SPI based ? You need to modify the bootloader project to copy image from external memory to the PSoC flash and launch it. 

   

- Create a project with bootloader-bootloadable architecture. 

   

- While you running bootlodable (application space of flash), you receive new image and you write it into external memory. 

   

- Once writing to external memory is done, you verify it by calculating checksum.

   

- If checksum is okay, you launch bootloader().

   

- Execution jumps to bootloader space of PSoC5 flash.

   

- Bootloader project copies new image from external memory to the application space of flash.

   

- Verify checksum and launch application.

   

 

   

There is one more method to achieve it without requiring an external memory. PSoC itself can divide its memory into two halves. One portion bootloading the other portion. Read dual-bootloader in PSoCLP bootloader component. The drawback is your application can get only half of the total flash size.

   

- PSoC5 flash is divided into launcher, app1 (bootloadable1) and app2 (bootlodable2) portions.

   

- App1 while running if receives new image, it writes to app2 space. Validates the new image and sets a flag.

   

- Similarly, if app2 is running it stores new image into app1 space.

   

- Launcher at power up selects which app to launch and execution goes to app1 or app2.

View solution in original post

13 Replies
Anonymous
Not applicable

Hi Aditya,

   

Your external flash/EEPROM is SPI based ? You need to modify the bootloader project to copy image from external memory to the PSoC flash and launch it. 

   

- Create a project with bootloader-bootloadable architecture. 

   

- While you running bootlodable (application space of flash), you receive new image and you write it into external memory. 

   

- Once writing to external memory is done, you verify it by calculating checksum.

   

- If checksum is okay, you launch bootloader().

   

- Execution jumps to bootloader space of PSoC5 flash.

   

- Bootloader project copies new image from external memory to the application space of flash.

   

- Verify checksum and launch application.

   

 

   

There is one more method to achieve it without requiring an external memory. PSoC itself can divide its memory into two halves. One portion bootloading the other portion. Read dual-bootloader in PSoCLP bootloader component. The drawback is your application can get only half of the total flash size.

   

- PSoC5 flash is divided into launcher, app1 (bootloadable1) and app2 (bootlodable2) portions.

   

- App1 while running if receives new image, it writes to app2 space. Validates the new image and sets a flag.

   

- Similarly, if app2 is running it stores new image into app1 space.

   

- Launcher at power up selects which app to launch and execution goes to app1 or app2.

Anonymous
Not applicable

Thanks Pavan for your solution.

   

I know the second method of dual application Bootloader.However, can you elaborate how to write in external memory because when we call Bootloader_Start() function it automatically copies the application *.cyacd file in the internal memory.

0 Likes
emen_2218296
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Aditya,

   

To write new image to external memory, you must be receiving the new image from some host. From where are you receiving the new image ? Is it over UART, I2C or USB ? 

   

Are you using your own app to send this new image ? If so, you can send new image row by row and store the data into external memory. For every row of data you receive you can cross check checksum and if the checksum sent by host is same as calculated checksum, you write the received row of data to external memory. Writing to external memory depends on what type of memory you are using - SPI, I2C etc.

   

By the way, Bootloader_Start()  function waits for host application to send flash data and writes to PSoC flash. It does not go and fetch data from external memory. You have to write this part. 

Anonymous
Not applicable

I am receiving new application image from Bootloader host tool in PSoC creator over UART. And yes that is what I want to know how to write the code to fetch data from external memory.Can you give me any reference or steps to be followed for writing code to write data on extrnal memory and fetch data from external memory.

0 Likes
emen_2218296
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Aditya, 

   

1) I have some code writing data into external EEPROM over I2C. However, I need a day to search that and provide here. Is your external memory an I2C based EEPROM ? Usually, it is just initializing the EEPROM at the beginning and then just send address and data for writing. If you send me datasheet or part number of your external memory I will be able to help. 

   

2) Can you confirm why you don't want dual bootloader architecture ? It is worthwhile to conisder this approach because in this case, you don't need any external memory and any custom code. 

lock attach
Attachments are accessible only for community members.
emen_2218296
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Here are files. They would not compile straightaway. However, you can see functions and fix syntax to use those. You need to modify these according to your EEPROM. 

0 Likes
Anonymous
Not applicable

Thanks embedded.engg ,

   

However what I want to know is, when we write Bootloader_start function it do all the work on its own. We just have to send application image from host tool given in PSoC creator and it automaticaaly saves the image file in controller's flash.So what I want to know is how to send that image in external flash memory.

   

Because when Bootloader_start() function is called it never returns and we can't add our code inside this function.

0 Likes
emen_2218296
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Aditya, 

   

As you said, Bootloader_Start you can use to copy image from host to flash. However, for your case, you need to

   

1) In your bootloadable project (application), copy the new image from host and write it to EEPROM. For this, I have provided you I2C EEPROM APIs. Use CyEEBtldrCommWrite() for writing to EEPROM.

   

2) Once you write image to EEPROM, you invoke Bootloader_Load() which will never return as you said. Even here, you need to modify bootloader component code to read from EEPROM instead of waiting for command from host. The code should read from EEPROM and write to PSoC flash. 

   

 

   

I hope you are understanding what I am trying to tell you. Why don't you use dual bootloader instead of writing this custom code ?

0 Likes
Anonymous
Not applicable

embedded.engg

   

1)I know In my Bootloadable project I can copy new image from host and write it to EEPROM

   

2)The main problem I am facing is how to modify my bootloader component to read from EEPROM instead of waiting for commands from host.

   

yes I understood what you said.My project requires me to do so that's why I am not using dual app bootloader and I know about dual app bootloader.

   

I hope you are understanding what I am trying to ask

0 Likes
emen_2218296
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

The main problem I am facing is how to modify my bootloader component to read from EEPROM instead of waiting for commands from host.

   

See this link. 

   

http://www.cypress.com/resource-types/video/psoc-creator-tutorial-importing-components

   

​You need to import the component and then modify the host_link API to read EEPROM and write into PSoC flash. 

0 Likes
Anonymous
Not applicable

Can someone please tell me how to switch between applications in dual application bootloader.

0 Likes

I have same question.i want to recieve data packet with gsm and save them on external FRAM(I2C) then load bootloader progrm to reprogramming and write new program from extern FRAM to psoc5 FLASH.but i dont know what is memory map on FRAM to save .cyacd file on it?another question is about bootloader configuration to read automatic and change old application ?

I cant use app0 and app1 bootloadble because i using most of flash memory for my application.

Thank you for attention...

0 Likes