Reduce/Optimize boot code memory C++

Sometimes C++ gives smaller code (please no religious wars; I have examples here). It is unlikely the original bootloader author used any C++ features that used much memory.

First, understand what is consuming the memory (from the MAP / LOC). If, and only if, C++ RTL is chewing up much space consider recoding.

Changing toolchains could easily be a major undertaking; certainly all assembler and/or hardware-access code would need a revisit.

First, understand what is currently consuming memory...

Hope that helps! Best Regards, Dave

Reply to
Dave Nadler
Loading thread data ...

That is a 4MB part. The 80186 can only address 1MB, of which some is RAM.

1a) Are you SURE that's the right flash part number? 1b) What is the CPU chip part number? 1c) Does the application use overlays and switch FLASH banks? 1d) Or, does the application only use part of the flash memory chip?

OK. Now that you've clarified you're trying to add stuff to the bootloader...

2a) How much flash is allocated to the bootloader? 2b) from your LOC file, how much space is remaining? 2c) What is the "new protocol" you are trying to add? 2d) Have you compiled the "new protocol" code, examined the map file, and totaled how much memory that will take? 2e) What is the memory deficit (2d - 2c)? 2f) Have you analyzed your MAP/LOC file to understand WHAT is consuming the code space and potantial improvements

To do so, it uses a utility to process the DOS EXE output by the linker to a loadable HEX file. Do you have a CFG and LOC file for the bootloader? If so, please post them...

Hope this helps! Best Regards, Dave

Reply to
Dave Nadler

...Excepting some late non-Intel 186 clones that redefine the segment register to get 24-bit total address space. That is not directly supported by Borland 4.50 but it can be kludged...

Thankfully, next project I'm back to ARM critters with adequate memory!

See ya, Dave

Reply to
Dave Nadler

The OP asked for UART help for 80C188EB, which has definitively a plain Intel 80186 addressing scheme.

--

-TV
Reply to
Tauno Voipio

application.

file?

Yes, I am sure about the flash chip part.The application uses only a part of flash memory chip - 1MB. No flash bank switch /overlays right now.

a)Total space - 3FFF b)From Loc file spcae remaining - 118 bytes c)Initial step is a feasibility test to ensure space reduction is possible, and memory can be shrinked. So, not i have not tried to build/add the new code.

Thanks a lot for your comments, I think i will able able to head in the right direction with your help.

--------------------------------------- Posted through

formatting link

Reply to
srao

16kb is pretty tight...

If you do not know how much space you need for the new code, you have no clue how much you have to prune, or if it is even feasible. START by building the new protocol code and finding out how much space you will need...

Hope that helps! Best Regards, Dave

Reply to
Dave Nadler

Sure will try that, but before that i have one more question related to this topic. As this i am dealing with legacy code, the boot code was built with multiple targets in mind. And this enhancement is only for one of the targets. So there might be many unused functions. Is there a tool to identify the unused functions so that i can exclude them from the build? So far I have been using source tree to find the link between various files/functions.

--------------------------------------- Posted through

formatting link

Reply to
srao

built

the

Sorry not source tree, 'source insight' tool.

--------------------------------------- Posted through

formatting link

Reply to
srao

Gimpel's PC-Lint.

R.W.

Reply to
Roberto Waltman

You can try Borland objxref. WARNING: Don't take OBJXREF output too seriously. A label listed as 'unreferenced' means it is not referenced outside the module that defines it. It is not NECESSARILY unused, but probably it should not be global. objxref has lots of other 'features' with C++ code as well.

Hope that helps, Best Regards, Dave

Reply to
Dave Nadler

GCC and Gnu binutils will do that automatically for you at link time if you use the right options (-ffunction-sections for gcc and

--gc-sections for ld).

I assume any decent toolchain will have equivalent options.

--
Grant Edwards               grant.b.edwards        Yow! Is it NOUVELLE 
                                  at               CUISINE when 3 olives are 
                              gmail.com            struggling with a scallop 
                                                   in a plate of SAUCE MORNAY?
Reply to
Grant Edwards

The Borland things are so old that the link-time optimization was only a twinkle in the father's eye.

--

-TV
Reply to
Tauno Voipio

build?

Thanks Roberto and Dave.

Dave, Is Objxref a tool or just an exe download? I am asking because, I looked it up, and did not find a trustworthy source to download it.

--------------------------------------- Posted through

formatting link

Reply to
srao

Actually, Borland tools have had "smart linking" (if I remember their term for it correctly) from way back in the DOS days. It is not link-time optimisation, but it simply omits functions that are not used in the final link image.

Despite being suggested many times, the OP still has given no indication that he has looked at the map file, or considered compile-time and link-time options, or looked at any documentation for the toolchain. Until he has control of these basics, any effort in helping him is wasted.

(To the OP - if you /have/ studied the map file and compiler and linker options, let us know the results of your research. The more information you give, the better the help you can get.)

Reply to
David Brown

Well, it was a decent toolchain two decades ago, but the objxref utility is the closest thing... Also, it can't strip unused functions; modules get pulled in whole.

See ya, Dave

Reply to
Dave Nadler

It should be in the same directory as the compiler...

Reply to
Dave Nadler

wasted.

As said by Tauno Voipio above, this version does not provide complete link time optimisation. I have already identified a few parts of code, which were unused and excluded from build, but i believe there are more such possibilities which I might not be able to quickly identify and that's how the question popped up in the first place.

--------------------------------------- Posted through

formatting link

Reply to
srao

Have you finished this project successfully?

Reply to
Dave Nadler

Have you finished this project successfully?

Reply to
Dave Nadler

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.