How to do multiple text segments?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to do multiple text segments?

773 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by chrisz on Thu Nov 18 23:59:10 MST 2010
Just started using LPCXpresso and the Eclipse environment, so forgive me if this is somewhere in the documentation and I can't find it.

I am trying to do things:

First, whenever developing embedded systems, I always arrange Makefiles so they compile in 2 parts:

.c -> .s
.s -> .o

That way, the assembly code is always left around so I can look at it and gain an understanding of what was actually done and how to interface to it. I have found a place where I can modify the command line to gss to specify -S to get the assembly files (Tool Settings, MCU C Compiler), but I have not been successful in then making it go on to compile these generated .s files into .o files. It simply stops after the .c -> .s step and fails.

Can someone tell me how I should accomplish this? Can I use an external Makefile with the eclipse environment, and if so, can someone offer an example? The makefile in the source directory appears to be regenerated.

Second, I want to set up 2 text code segments. The first segment will go into flash. The second segment will contain init code that can be thrown away once it has run. I want to compress this segment and then load it into SRAM at startup. (I may eventually add more temporary segments using this same concept if the space saving proves substantial.)

Obviously I will need to create a custom .ld file to pass to the linker, but it is unclear how I should do this. The ones used in the example (e.g. lpcxpresso1114_blinky_Debug.ld) say that they are auto generated from nxp_lpc11_c.ld and not to modify them, but I can not find the parent file on my system.

I also need to add a step in the Makefile that strips the binary code and compresses it to a data block.

Does anyone have an example application that shows how to do this?

I'm sure I can figure all this out myself in time, but if anyone from the group can offer some assistance and an example or 2 it will save me alot of time, and having spent 2 weeks just trying to get the development system to work I'm already way behind on this project.

Thanks for any assistance.
0 Kudos
Reply
2 Replies

749 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Dig Kleppe on Tue Dec 20 14:00:39 MST 2011
For using segments do I need a makefileproject? I placed a var in one of standard RAM segments ( RamAHB8_B0B LPC1788), using attribute.. , but this does not work. Is was placed as a usual var. Making it a global intitialized var did not help.
I want to add a segment for external SDram. I expected I could add this in the MCU settings!
Dig Kleppe

a few minutes later:
Found the solution using cr_section_macros.h , works with a adapted linkerscript.

Dig Kleppe
0 Kudos
Reply

749 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Fri Nov 19 02:27:04 MST 2010
The generated makefiles convert .c to .o without any intermediate step. If you want to see what the compiler has output, use the "-save-temps" option, which will leave the intermediate files in the build directory (Debug or Release). An alternative would be to output an assembler listing file, by adding "-Xassembler -aln=${InputFileBaseName}.s" to the compiler options.

If you really want to do it all yourself, using makefiles, writing your own makefile and linker scripts etc, you need to create a Makefile project by doing the following:
File->New->Project...
Expand C/C++ and select "C Project", Next
Expand Makefile project and select "Empty Project"
Ensure "Code Red MCU Toolchain" is selected under toolchain
Choose a project name, and Next, or Finish

By default, the code is placed in the .text section. You can put the code for any function into your own section by prefixing the function definition with
__attribute__((section(".my-text-section")))

You then need to change the linker script to place this wherever you want. See the FAQ for more information:
http://support.code-red-tech.com/CodeRedWiki/CodeRedFAQ
and specifically
http://support.code-red-tech.com/CodeRedWiki/OwnLinkScripts

You can use arm-none-eabi-strip to strip your binaries.

I'd be surprised if you really can save much space by compressing your code and expanding it at run time (given the size of the expansion routine).
0 Kudos
Reply