On Fri, May 4, 2012 at 2:38 PM, Adam Ford <adam.f...@braemarinc.com> wrote:
> We have an older project at my work where we use the TI BSL loaded to
> load code over RS-232.  Our code is broken up into two categories a
> configuration file and a firmware file and they are both loaded together.
>
> The configuration file is a list of constants stored in flash and
> specific addresses and they are unique for each of our customers, but
> the firmware file is the same.
>
> The code we have now was written with IAR, and I'm trying to port it
> over to mspgcc.
>
> What I'd like to be able to do is compile the firmware with the linker
> script specifying certain addresses of data, but I don't want the
> compiler to actually put any data at those locations.
>
> For the configuration, I'd like to just compile the constant variables
> without firmware.
>
> The problem I see is that GCC initializes the constant variables in the
> FW which I have to go and manually delete because those constants are
> loaded from a separate txt file.  I'd like to have that more streamlined
> technique to build both.  Any ideas on the best way to do that?

If the variables have no initializer in the source, the firmware image
shouldn't include data that gets written to their location.  However, in
that case they will normally be assigned to the .bss section, and will be
zeroed in the startup code.

If you want to specify the actual address in a linker script, place the
variable declarations in the .noinit section using a section attribute.
That should be safe: I'd have to play around to see if it's necessary; it
may be that with a specific address the linker won't accrue the object sizes
to the data size or bss size.

An alternative that avoids the linker script is to use an asm statement so
there's no symbol used at all: everything is relative to the fixed address.

Play with the example below.

#include <stdio.h>

__attribute__((section(".noinit")))
const char client_id[20]
//__asm__("0x8000")
  ;
__attribute__((section(".noinit")))
char mutable_client_data[32]
//__asm__("0x3000")
  ;
struct client_data_t {
  int n1;
  int n2;
} client_data __asm__("0x3100");

int putchar (int c) { return c;}
int main ()
{
  printf("Client %d.%d %s, mutable %s\n", client_data.n1,
client_data.n2, client_id, mutable_client_data);
}

> thanks
>
> adam
>
> This email, including any attachments and files transmitted with it, are for 
> the sole use of the intended recipient(s) to whom this email is addressed, 
> and may contain confidential and/or privileged information. Any unauthorized 
> review, use, disclosure or distribution is prohibited. If you are not the 
> intended recipient, please be advised that you have received this email in 
> error, and please contact the sender by reply email and destroy all copies 
> (including all electronic and hard copies) of the original message. Thank you.

Please note: http://www.spinics.net/lists/gcchelp/msg16825.html and
http://gcc.gnu.org/lists.html#policies

mspgcc-users doesn't currently follow this, though it would apply if
msp430 support is integrated into GCC upstream.

Peter

>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Mspgcc-users mailing list
> Mspgcc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/mspgcc-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to