jartim 0 Report post Posted November 17, 2017 (edited) Hi guys, Is there any easy way of identifying the last used address in rom using BoostC or BoostC++ compilers? I cannot find a linker control file to add a label, is there any way to guarantee that a label defined in the source code ends up as the last addressed object? Thanks Tim Edited November 17, 2017 by jartim Added compiler names. Quote Share this post Link to post Share on other sites
JorgeF 0 Report post Posted November 17, 2017 Hi I usually find that kind of information on the HEX file used to program the PIC. If you tell us what is your goal, maybe there are other ways, besides finding the last used flash address, to achieve it. Best regards Jorge Quote Share this post Link to post Share on other sites
jartim 0 Report post Posted November 17, 2017 Hi Jorge All I'm trying to do is calculate a CRC checksum for the ROM, starting at 0x0000 and ending at the last used address of my program, hence I need to know the last address used. I can't CRC the entire ROM because I will be using the top end for non-volatile storage, and for that I also need to know the last used address. Normally I would edit the linker control file and add a label after the used code section, but this compiler doesn't appear to use a control file, I guess it has the parameters hard-coded in. All I can do at the moment is build the code with a 0x0000 address coded in as a rom char* pair, look at the code statistics after the build process, copy the size of the code in to the rom char* and then re-build. It would be safer and easier to have the compiler and linker do it automatically. Regards Tim Quote Share this post Link to post Share on other sites
JorgeF 0 Report post Posted November 19, 2017 Hi There is one thing in your logic that you might want to re-evaluate. I wouldn't trust a compiler to organize the code space in a continuos block, most of the ones I know do spread chuncks of code all over the place just to optimize for the addressing scheme of the PIC (mnimize pagging). The same spreading, for the same reasons, might be found with RAM usage. If you intend to use some part of your flash memory for data you would better reserve it. Use the "-rt" command line switch to limit the maximum address available for the program and use the flash above that address for runtime data (NVM). A work around for your initial question can be to adjust the top of rom (-rt) close the the actual size of your release code and calculate the CRC from "0x0000" up to your "-rt" value. You can calculate the CRC verification from the data on the HEX file as it is a byte image of what will be recorded in the program flash. BTW: Make sure you do program your release code on blank chips so you can use the erased value of the flash in your CRC calculation. Just my 2 cents of it.... Best regards Jorge Quote Share this post Link to post Share on other sites
jartim 0 Report post Posted November 19, 2017 Thanks Jorge, pretty much what I had decided to do as well. It just would be easier to have the compiler and linker do all the work for me, rather than have to build the code twice. Regards Tim Quote Share this post Link to post Share on other sites