[U-Boot] [Almost solved] M5282EVB undefined reference to `environment'

James Steward
2011-11-25T03:52:48Z

On 24/11/11 17:36, Igor Grinberg wrote:
> On 11/24/11 01:58, James Steward wrote:
>> A search with grep CONFIG_ENV_IS_EMBEDDED `find . -name "*.h"`
>> indicates the answer is no. Should it be set?
>
> AFAIK, environment variable is used only when you have
> ENV_IS_EMBEDDED set. Also, there is some logic in the
> include/environment.h files (in current master line 64), that decides
> whether to set this automatically or not.
>
>>
>> With grep CONFIG_ENV_IS_ `find . -name "*.h"` in
>> include/configs/M5282EVB.h, I see #define CONFIG_ENV_IS_IN_FLASH
>> 1
>>
>> So looking in that file I see:
>>
>> /* Configuration for environment * Environment is embedded in
>> u-boot in the second sector of the flash */ #define CONFIG_ENV_ADDR
>> 0xffe04000 #define CONFIG_ENV_SIZE 0x2000 #define
>> CONFIG_ENV_IS_IN_FLASH 1
>
> Look at the logic in environment.h to check if ENV_IS_EMBEDDED gets
> set in your case.

objdump -t common/env_embedded.o | grep environment
00000004 g O .text 00002000 environment

objdump -t common/libcommon.o | grep environment
00000000 l d .rodata.default_environment 00000000
.rodata.default_environment

00000000 *UND* 00000000 environment

00000000 g O .rodata.default_environment 00000163 default_environment

So environment is undefined in libcommon.o, but is in env_embedded.o.

From make all I see;

m68k-elf-ld -n -r -o libcommon.o cmd_bdinfo.o cmd_boot.o cmd_bootm.o
cmd_cache.o cmd_console.o cmd_echo.o cmd_flash.o cmd_help.o cmd_itest.o
cmd_load.o cmd_mem.o cmd_mii.o cmd_misc.o cmd_net.o cmd_nvedit.o
cmd_pcmcia.o cmd_source.o cmd_version.o cmd_ximg.o command.o console.o
dlmalloc.o env_common.o env_flash.o exports.o flash.o image.o main.o
memsize.o miiphyutil.o s_record.o stdio.o xyzModem.o

So it compiles env_embedded.c, but doesn't include it in libcommon.o?

<hack>
vim common/Makefile

XCOBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_embedded.o

becomes

COBJS-$(CONFIG_ENV_IS_IN_FLASH) += env_embedded.o

:q
</hack>

make all

Hey, presto, build now completes!

So how should this be corrected properly?

Regards,
James.