Re: Getting the code size of a function in C



Grant Edwards wrote:
On 2005-11-01, Tauno Voipio <tauno.voipio@xxxxxxxxxxxxx> wrote:


I need to determine the size of a function or module since I
need to temporary relocate the function or module from flash
into sram for firmware updates.


If you're using GCC, probably you do not need to copy
anything, just locate your function to the initialized data
section:


That works, but it can be a bit of a waste since the function
is sitting in both flash and RAM 100% of the time.  If there
are multiple routines that need to be run from RAM at different
points in time, you can save a bit of RAM by overlaying them.


The amount of code needed in RAM for Flash writing is pretty
small: about 250 bytes on an ARM for garden-variety AMD
Flashes.


But where is the "flash writing" code getting the data?

In cases I've dealt with the "flash writing" code has to
impliment some sort of communications protocol in order to
receive the data to be programmed into flash.  In the product
I'm working with right now, it takes 3KB of code to do a flash
update.  That's a pretty significant chunk out of my 32KB of
RAM.


You do not need to keep the whole chunk in RAM at the same time.
Also, only the inner loop of a Flash writer is necessary to be
kept in RAM, the rest can reside in the Flash. The code responsible
for the handling from the unlock sequence till the chip responds
ready to poll has to be in RAM, but this is for erasing a segment
or writing a single byte. The rest of code can be safely in the
Flash without any problems.

The incoming data is usually transferred in some kind of chunks
(e.g. 128 bytes with Xmodem). It's no too difficult to keep
one chunk in the RAM and read more when that's written.

--

Tauno Voipio
tauno voipio (at) iki fi
.



Relevant Pages

  • Re: Performance and Flash Pipelining on TI 28F12 DSPs
    ... > of "critical code" we could move to RAM. ... > from internal flash? ... Since the external RAM is as big as the internal flash, ... the timers and all other interrupts are shut off, ...
    (comp.dsp)
  • Re: [ANNOUNCE] Ramback: faster than a speeding bullet
    ... The fact is, enterprise scale ramdisks are here now, while ... enterprise scale flash is not. ... does not approach the write performance of RAM, ... My goal is not to replace RAM with flash, but disk with flash. ...
    (Linux-Kernel)
  • Re: Relocate from nor to ddr CE 5.0
    ... programmed into flash. ... but the image info says it belongs to ram. ... Your bootloader needs to have code that recognizes if the image is ... blt CODEINRAM ...
    (microsoft.public.windowsce.platbuilder)
  • XIP vs RAM
    ... Maybe the system can even get away with the next small size RAM ... Does anyone know if/what the premimum of the "K" Strata FLASH is? ... Also what are the steps needed to transition to a XIP OS? ... >>> My bootloader create a BINFS partition and an EXTENDED partition on ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Getting the code size of a function in C
    ... >>>The amount of code needed in RAM for Flash writing is pretty ... >> receive the data to be programmed into flash. ... > You do not need to keep the whole chunk in RAM at the same ...
    (comp.arch.embedded)