u-boot版本: v2009.08
前一片文章在分析env开机流程时默认为开机后env搬移到RAM中的情况,
此种情况会浪费一部分内存空间,在RAM吃紧时我们可以把env放到u-boot.bin
的text段中,至少flash要比RAM空间多一些。
首先需要使能如下宏:
#define CONFIG_ENV_IS_EMBEDDED 1
uboot-imx/include/environment.h
# ifdef CONFIG_ENV_IS_EMBEDDED
# define ENV_IS_EMBEDDED 1
# endif
这样开机流程和上一篇文章不一样了
void env_relocate (void)
{
......
#ifdef ENV_IS_EMBEDDED
/*
* The environment buffer is embedded with the text segment,
* just relocate the environment pointer
*/
/*定义了之后跑到了这里,取env_ptr后的reloc_off偏移*/
env_ptr = (env_t *)((ulong)env_ptr + gd->reloc_off);
DEBUGF ("%s[%d] embedded ENV at %p\n", __FUNCTION__,__LINE__,env_ptr);
#else
/*
* We must allocate a buffer for the environment
*/
env_ptr = (env_t *)malloc