undefined reference to 'memcpy' in UC3B framework??!!

Go To Last Post
11 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

hi,

I'm testing my device driver code now and I got a very strange problem this the error:

Quote:

undefined reference to 'memcpy'

One example is I called one function from my device driver c file into the main() function:

//in device driver

signed char CC2420_set_VREG_EN(volatile CC2420_t CC2420)
{
	gpio_set_gpio_pin(CC2420.VREG_EN_pin);
	
	return CC2420_SUCCESS;
}
// in main()

CC2420_set_VREG_EN(CC2420);

Then this function call give me the above mentioned error.

But if I change it to:

// in main()

gpio_set_gpio_pin(CC2420.VREG_EN_pin);

Then the error is gone.

And if I change it to:

// in main()

CC2420_set_VREG_EN(CC2420);
gpio_set_gpio_pin(CC2420.VREG_EN_pin);

then it will be gpio_set_gpio_pin which get the same error!!!

So why???!!!

Cheng

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It seems like a call to memcpy when you are struct.
Check that you link without the -nostdlib.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, I found this in my config.mk:

# Extra flags to use when linking
LD_EXTRA_FLAGS = -Wl,--gc-sections -nostdlib -Wl,-e,_trampoline

I will check the meaning of this -nostdlib.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

yes, after delte:

  $(UTIL_PATH)/STARTUP_FILES/GCC/crt0.S \

and

-nostdlib

from the config.mk, now it's no error anymore.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

so this linker flag is normally useless, right?

The standard system start up file is ok for me.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

crt0.s is no longer required, too.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I will check the meaning of this -nostdlib.

Quote:
so this linker flag is normally useless, right?

With -nostdlib, you will link with no standard library ie the Newlib in the GNUtoolchain.
The newlib provides you function like memcpy, printf, math lib...

-sma

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ok, then I want to keep this flag.

So how can I get ride of the 'memcpy' error while keeping this flag?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You need a memcpy function, either from a standard C lib like Newlib or write it yourself.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can also get rid of any C structure in RAM in your code, that should avoid a call to memcpy.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

but I don't have any memcpy in my code, all I used is some peripheral drivers from the framework.

and I'm a little bit confused:

I don't really need this -nostdlib in normally situation, right? Because I always want to use standard libs from GCC.