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

Igor Grinberg
2011-11-24T06:36:53Z

On 11/24/11 01:58, James Steward wrote:
> Hi Igor,
>
> On 23/11/11 23:19, Igor Grinberg wrote:
>> Hi James,
>>
>> On 11/22/11 07:22, James Steward wrote:
>>> On 22/11/11 15:51, Marek Vasut wrote:
>>>>> Hi,
>>>>>
>>>>> I'm trying to build U-Boot for the above mentioned board. Basically,
>>>>> I've done the following on a Ubuntu 10.04:
>>>>>
>>>>> wget
>>>>> https://sourcery.mentor.com/public/gnu_toolchain/m68k-elf/freescale-coldfir
>>>>> e-4.4-215-m68k-elf-i686-pc-linux-gnu.tar.bz2
>>>>>
>>>>> sudo tar xvfj
>>>>> freescale-coldfire-4.4-215-m68k-elf-i686-pc-linux-gnu.tar.bz2 -C /opt
>>>>>
>>>>> export
>>>>> PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/free
>>>>> scale-coldfire-4.4/bin
>>>>>
>>>>> |sudo apt-get install git-core
>>>>>
>>>>> mkdir /home/james/u-boot-git&& cd ||/home/james/u-boot-git
>>>>>
>>>>> git clone ||git://git.denx.de/u-boot-coldfire.git
>>>>>
>>>>> ||cd u-boot-coldfire
>>>>> ||
>>>>> ||make clean
>>>>>
>>>>> make M5282EVB_config
>>>>
>>>> try ./MAKEALL M5282EVB ... I suspect you don't have CROSS_COMPILE=your-crosscc-
>>>> prefix variable set, and maybe ARCH=m68k variable too.
>>>
>>> I didn't have those env vars set, however now with them set, and the latest codesourcery compiler I get the same error;
>>>
>>> export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/freescale-coldfire-2011.09/bin
>>>
>>> export CROSS_COMPILE=m68k-elf-
>>>
>>> export ARCH=m68k
>>>
>>> ./MAKEALL M5282EVB
>>> Configuring for M5282EVB board...
>>> cmd_nvedit.c: In function 'do_env_export':
>>> cmd_nvedit.c:748:3: warning: format '%zX' expects argument of type 'size_t', but argument 3 has type 'unsigned int' [-Wformat]
>>> cmd_nvedit.c:774:2: warning: format '%zX' expects argument of type 'size_t', but argument 3 has type 'unsigned int' [-Wformat]
>>> cmd_nvedit.c: In function 'do_env_import':
>>> cmd_nvedit.c:865:3: warning: format '%zd' expects argument of type 'signed size_t', but argument 2 has type 'size_t' [-Wformat]
>>> cmd_nvedit.c:865:3: warning: format '%zX' expects argument of type 'size_t', but argument 3 has type 'unsigned int' [-Wformat]
>>> mcfmii.c: In function 'mcffec_miiphy_write':
>>> mcfmii.c:318:8: warning: variable 'rdreg' set but not used [-Wunused-but-set-variable]
>>> common/libcommon.o:(.data.rel.env_ptr+0x0): undefined reference to `environment'
>>> make: *** [u-boot] Error 1
>>> m68k-elf-size: './u-boot': No such file
>>>
>>> --------------------- SUMMARY ----------------------------
>>> Boards compiled: 1
>>> Boards with warnings or errors: 1 ( M5282EVB )
>>> ----------------------------------------------------------
>>>
>>> Any other thoughts? Do I need to define something to configure the environment to flash or something?
>>
>> Do you have CONFIG_ENV_IS_EMBEDDED set?
>>
>>
>
> 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.

>
> This is pure unadulterated coldfire git source that will not build out of the box. I assumed I was doing something wrong. But it seems there is really a bug in the default configuration for this board?

Could be... It is extremely hard to understand what's going on
when the source code is a kind of divergence from upstream.
Also, there is a possibility that ENV_IS_EMBEDDED is broken
for some time already.

--
Regards,
Igor.