This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

HEX to Bin Conversion Size Issue

Other Parts Discussed in Thread: CC2541

Hi,

I am using CC2541 and I have generated the Super HEX image of my firmware, which consists of BIM + Image A + Image B.

Now to program the firmware using Serial Boot Loader I am converting it to BIN file using Hex2Bin converter. The resultant .bin file is of size 256KB. But I would like to generate .bin file of less than 240KB.

How can I do that? Please help me to achieve that.

By look at the Super HEX file using the HexEdit, I found a very small size code at very higher address. If we can move that part to lower address, then it will help us to reduce the firmware size.

Thanks,

Dhaval

  • Hi Dhaval,

    It might be that you have compiled too large images, what information do you get from the bottom of the generated .map files in the IAR workspace.

    Example SimpleBLEPeripheral;

    112 738 bytes of CODE memory
               35 bytes of DATA memory (+ 73 absolute )
         6 272 bytes of XDATA memory
            194 bytes of IDATA memory
                 8 bits of BIT memory
            487 bytes of CONST memory

    Adding the CODE memory (+CONST) from your different projects will give you the final size of your solution.

  • Hi Joakim,

    Thanks for your quick response.

    1. Yes, I found that. But how can I reduce the overall size based on that information?

    2. There is something at very end of the super hex which is of around 44 bytes. You can see that in the file attached. And it is also in the middle of the empty area. I don't understand what is that and how can I shift it at some lower address?

    Thanks,

    Dhaval

  • Hi Dhaval,

    First of all, you need to check that that code doesn't exceed 256 kB. Don't do that check when you have created the superhex, as functions have linked to memory address so modifying the hex/bin will not get you anywhere.

    What you need to do is looking at the map files. There is a table summary in there that shows you how much every single module takes in flash space. For example, maybe some of your profiles takes up to much flash space, then remove the descriptors for the characteristics if you have such, as they are optional. So you need to do the optimizations in the individual projects, not superhex/bin. You can also make sure that the compiler is set to compile with size optimization (Project Options -> C/C++ Compiler -> Optimizations)

    Best Regards

    Joakim

  • Hi Joakim,

    1. Which .map file I should refer? .map file of the 'Release' or of 'OAD-ImgB'? Also I have tried to search for the table summary, but I didn't find anything. Can you please let me know what exactly I need to search for in the .map file?

    2. After looking at the final .bin file, I found that there are some data at location 0x3e800. And it is data of NV RAM. Where this location defined, as I am not able to find it in .xcl file? And is it possible to change this location to somewhere at lower address?

    Thanks,

    Dhaval

  • Dhaval V said:
    Which .map file I should refer? .map file of the 'Release' or of 'OAD-ImgB'? Also I have tried to search for the table summary, but I didn't find anything. Can you please let me know what exactly I need to search for in the .map file?

    In the IAR Workspace, you have a folder called Output. If you compile the project, it should include a file with .map extension. This map file includes a section called "Module Summary" which will show you what different parts of the code consumes in flash/RAM. At the end of this file, you will see the summary.

    Best Regards

    Joakim

  • Hi Joakim,

    I didn't find any 'Output' named directory in my IAR workspace for my project. I can see 'OAD-ImgB', 'Release' and 'settings' directories, that generates run time after compilation. And there are two .map files, one at <project workspace>\Release\List\*.map and other at <project workspace>\OAD-ImgB\List\*.map. And there is nothing called 'Module Summary' in any of the file.

    Also, can you please tell me how can I change the starting location of the NV RAM?

    Thanks,

    Dhaval

  • Can anyone please help me on this?

  • Hi Dhaval,

    I was referring to the workspace within IAR;

    That should be the same file you found in Release folder though. What does it say in the bottom? Could you share the file here?

    Best Regards

    Joakim

  • Hi Joakim,

    Thanks for your reply. I misunderstood regarding the .map file location. Now I got it!

    I found following on the bottom of that file:

    ****************************************
    * *
    * END OF CROSS REFERENCE *
    * *
    ****************************************

    126 940 bytes of CODE memory
    35 bytes of DATA memory (+ 87 absolute )
    7 025 bytes of XDATA memory
    194 bytes of IDATA memory
    8 bits of BIT memory
    592 bytes of CONST memory

    I can't share the .map file here on the forum. Do you need any other thing?

    Also, please let me know how can I change the start location of the NV RAM? I need to lower the address.

    Looking forward to your quick reply on this.

    Thanks,

    Dhaval

  • Hi Dhaval,

    126 940 bytes of CODE memory + 592 bytes of CONST memory is more than can fit in half the Flash size. You will need to revise your code and optimize the usage before you can generate an OAD file.

    Or, follow example in this guide; http://processors.wiki.ti.com/index.php/BLE_Large_Image_OAD

    There is no such thing as NV RAM. Either you mean RAM, which is already at lowest address, or you mean NV Flash. What are you trying to achieve?

    Best Regards

    Joakim

  • Hi Joakim,

    Yes, I am talking about the NV Flash. We are using that for storing some information that we required after power cycle. And I think it is stored at the higher address. I want to relocate it at some lower address.

    Please help me on this.

    Thanks,

    Dhaval

  • Hi Joakim,

    Did you get a chance to look at this? Is there anyway to change the NV Flash start location to lower address?

    Please reply soon.

    Thanks,

    Dhaval

  • Hi Joakim,

    Also, I would like to share the Summary for SimpleBLEPeripheral image:

    ****************************************
    * *
    * END OF CROSS REFERENCE *
    * *
    ****************************************

    110 698 bytes of CODE memory (+ 16 278 range fill )
    35 bytes of DATA memory (+ 82 absolute )
    6 277 bytes of XDATA memory
    194 bytes of IDATA memory
    8 bits of BIT memory
    746 bytes of CONST memory

    I have few questions/queries based on this:

    1. The CODE memory of this tiny project is also same as our project. And the CONST memory is even higher then our project.

    2. The final .bin file of SimpleBLEPeripheral contain something at address 0x3E800, same as our .bin file. What is this? And can we move this data to lower address?

    Please reply soon.

    Thanks,

    Dhaval

  • Hi Dhaval,

    Dhaval V said:
    1. The CODE memory of this tiny project is also same as our project. And the CONST memory is even higher then our project.

    What is the question? Is the presented values the tiny SimpleBLEPeripheral or your own project? Either way, you can flash it after you've flashed the bootloader. After that you may download an image over the air if that's your end purpose.

    Dhaval V said:
    2. The final .bin file of SimpleBLEPeripheral contain something at address 0x3E800, same as our .bin file. What is this? And can we move this data to lower address?

    I don't know what's on that location.

  • Hi Joakim,

    I am asking this question again and again that I have something which is located at 0x3e800 location of the final BIN file, converted from Super HEX. The Super HEX contains BIM + Image A + Image B. I think it is NV Flash start address and I want to know how to shift this start location to some lower address.

    Please help me to get the solution for this.

    Thanks,

    Dhaval

  • Hi Dhaval,

    Dhaval V said:
    I think it is NV Flash start address

    Based on the OAD users guide (attached) you seem to be correct. I do not know how to re-purpose the OSAL SNV pages to another safe location where both image A & B can access it. I suppose the change has to be made in osal_snv.c, with define OSAL_NV_PAGE_BEG although be careful when changing this (wherever it leads) and note to do so for both projects.

    Best Regards

    Joakim

    1234.OAD_for_CC254x.pdf

  • Hi Joakim,

    Thanks for your reply!

    I would appreciate if you can help me to get required changes to re-purpose the NV Flash pages, as I don't have clear understanding where it is going to affect.

    Thanks,

    Dhaval