how to reduce the size of cyacd file generated using PSoC creator ?

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

cross mob
DhDa_2432241
Level 5
Level 5
5 likes given First like received First like given

Hello, 

   

I want to store the generated .cyacd file from a bootloadable project into an embedded host. The embedded host a RAM size of 128KB.  My project's .cyacd file is 195KB. I am looking for ways to shrink this image so that I can store it in the embedded host. This is needed so that I can bootload the firmware image onto CYBLE-012011 from the embedded host flash instead of downloading it from a server. 

Also, what is the difference between .cyacd file and .hex file? Why are we using .cyacd file for bootloading using an embedded host?

Out of curiosity, I have created an empty project and placed a few components in it. Without application code the generated hex file is about 282 KB and .cyacd file is about 7 KB. With my application code, the .hex file is still 282 KB but the .cyacd file grew to 195 KB. I don't get this. The .hex file size is always the same? Any ideas?

Thanks
Dheeraj

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

Hi Dheeraj, 

   

CYBLE-012011 has a flash size of 128 kB. You can expect the new image to go up to 100 kB (excluding bootloader). So, cyacd will be around this size depending on complexity of your application code. I suggest you to store this image in an external memory chip (SPI based EEPROM) or store it in embedded host's flash. 

   

 

   

Hex files are heavy as they have lot of other info and are in intel hex file format. That's why you use cyacd files. Cyacd files are simple in which they just have one flash row stored in each line of the file. Last row contains metadata. You can actually read the file and store the data in external memory or host's flash. 

   

 

   

Thank you,

   

Pavan

0 Likes

This is surprising. CYBLE-012011 has a flash size of 128 KB but the projects .cyacd file is 192 KB. I was able to flash this file using MiniProg3. How is this possible?
 

0 Likes
Anonymous
Not applicable

Hi Dheeraj,

   

The .cyacd format still represents binary data using ASCII hexadecimal, which results in a minimum 200% inflation since two characters are required for every byte. Adding in offset and length metadata, the inflation is even higher than this. If you convert a 192 KB .cyacd file to pure binary and remove the metadata, you are probably looking at something closer to about 80-90 KB. Even if you keep the metadata (at least the starting address would be required), you can still cut it in half, so a 192 KB .cyacd file has about 96 KB of binary data.

   

See Appendix B starting on Page 24 of AN68272 for details on the .cyacd format:

   

http://www.cypress.com/documentation/application-notes/an68272-psoc-3-psoc-4-psoc-5lp-and-psoc-analo...

   

Jeff

0 Likes

Hi Jeff,
Thanks for this. I get it now.

   

From the references in AN68272, there is cybtldr_parse.c which parses .cyacd file during the bootload process. If I use the bootloader and bootloadable components, I have to use the .cyacd file. I can't cut it down to binary and use it. Correct?

 

0 Likes
Anonymous
Not applicable

Hi Dheeraj,

   

I am virtually certain that the actual bootloader expects raw binary data as input, not ASCII-formatted hex. This would result in a great deal of unnecessary computation within the bootloader, which would needlessly increase the flash size required for bootloading functionality. I would review other source files in the same set and the app note itself to see how the packets are assembled.

   

You should be able to store the bootloadable image data as binary rather than hex, as long as your host-side bootloader API implementation can send the correct data to the module during the update process.

   

Jeff

0 Likes

Hello Jeff, 
You were right. I looked at the host side code. The read hex data is converted to a byte. The UART sends these bytes as a binary stream to the bootloader.

   

The packets are assembled as follows:
| CMD_START | CMD_SEND_DATA | SIZE(byte 0) | SIZE(byte 1) | DATA ...... | CS(byte 0) | CS(byte 1) |

I still need the array ID, row number, data length and checksum. So I can convert the ASCII formatted hex to char which would convert a 195 KB .cyacd file to about 90 KB. As of now, the max possible array size I can declare in my embedded host is 13 KB. I wouldn't be able to store this image. How do I convert it to a binary file?

0 Likes
Anonymous
Not applicable

Hi Dheeraj,

   

Converting to binary would have to be done by a tool that you write, I think. Or, you could make use of the existing source used for the actual host-side bootloading process and modify it to output the firmware data to a file instead. Strictly speaking, you could keep only the raw binary data and starting offset, then calculate checksums for each line's worth of data on the fly from the host side as it is transmitted later.

   

As for storage, if you can't declare constant byte arrays for directly flash storage (or this type is limited to 13 KB as well), you will probably need to add an external flash chip for arbitrary binary data storage. SPI flash or I2C flash should work as long as you are able to perform basic read/write operations from your host MCU.

   

Jeff

0 Likes

Hello Jeff,
Yes, I can use the host-side bootloading tool to generate the binary. I have to see the checksum part. For storing the firmware image, I have an SPI flash already. I wanted to have it in the application like a constant byte array, as it would avoid the process of maintaining a firmware image on the server, saving it to external flash and then reading from it to start the bootload process. 

Thanks
Dheeraj

0 Likes
Anonymous
Not applicable

Hi Dheeraj,

   

Out of curiosity, what is the host MCU platform you are using? Is the 13 KB limitation something inherent in the chipset itself, or because of the compiler/toolchain, or simply because there is no additional flash space available?

   

Jeff

0 Likes

Hello Jeff,
I am using Particle P1 as my host MCU. The 13 KB limitation comes from no additional flash space available. It is subject to change based on the application code size. 

Thanks 
Dheeraj

0 Likes