默认环境变量的设置
T113上有两处默认环境变量设置,一处为:
device/config/chips/t113/configs/evb1_auto/buildroot/env.cfg
编译后生成,out/t113/evb1_auto/pack_out/boot-resource.fex,以供原厂工具和fastboot进行烧录。
另一处则是:
include/configs/sunxi-common.h
这个.h文件是会编译进uboot的,方便SD卡/U盘烧录。
但新SDK上发现sunxi-common.h中设置的SUNXI_SPRITE_ENV_SETTINGS宏,并没有在env default -fa时生效,反倒是include/env_default.h中的环境变量生效了,然后在include/env_default.h中发现:

这个宏在编译完成后发现是空白的,再回到include/configs/sunxi-common.h中发现,SUNXI_SPRITE_ENV_SETTINGS宏被定义成了空白:

而且不知道为什么全志的SUNXI_SPRITE_ENV_SETTINGS宏也没有生效,应该是被uboot原生的代码给提前抢夺设置了,没仔细看。
然后想env default -fa后生效的环境变量为sunxi-common.h中设置的也很简单,只需要在sunxi-common.h中将SUNXI_SPRITE_ENV_SETTINGS宏定义为CONFIG_EXTRA_ENV_SETTINGS就得了:

最后,为了保证SD卡烧录和原厂工具都能正常使用,请在开发时保证device/config/chips/t113/configs/evb1_auto/buildroot/env.cfg和include/configs/sunxi-common.h的设置一致。
烧录env.cfg时partitions环境变量被覆写
我们需要使用partitions环境变量去指定gpt分区,在env.cfg设置后发现不生效,烧录env.cfg后在uboot中变成了如下:
partitions=boot-resource@mmcblk0p1:env@mmcblk0p2:env-redund@mmcblk0p3:boot@mmcblk0p4:rootfs@mmcblk0p5:dsp0@mmcblk0p6:private@mmcblk0p7:recovery@mmcblk0p8:UDISK@mmcblk0p9
顺藤摸瓜在uboot中找到如下源码,brandy/brandy-2.0/u-boot-2018/board/sunxi/board_helper.c:
int sunxi_update_partinfo(void)
{
...
memset(part_name, 0, PARTITION_NAME_MAX_SIZE);
if (storage_type == STORAGE_NAND) {
sprintf(part_name, "nand0p%d", index);
} else if (storage_type == STORAGE_NOR) {
sprintf(part_name, "mtdblock%d", index);
} else {
sprintf(part_name, "mmcblk0p%d", index);
}
temp_offset = strlen((char*)info.name) + strlen(part_name) + 2;
if (temp_offset >= PARTITION_SETS_MAX_SIZE) {
printf("partition_sets is too long, please reduces "
"partition name\n");
break;
}
sprintf(partition_index, "%s@%s:", info.name, part_name);
if (root_partition && strncmp(root_partition, (char *)info.name, sizeof(info.name)) == 0)
sprintf(root_part_name, "/dev/%s", part_name);
if (blkoops_partition && strncmp(blkoops_partition, (char *)info.name, sizeof(info.name)) == 0)
sprintf(blkoops_part_name, "/dev/%s", part_name);
offset += temp_offset;
partition_index = partition_sets + offset;
}
partition_sets[offset - 1] = '\0';
partition_sets[PARTITION_SETS_MAX_SIZE - 1] = '\0';
env_set("partitions", partition_sets);
...
看上去就是这段代码导致的,尝试修改这个函数中partitions为partition,对他解除占用,然后发现生效了:

那原先引用这个变量的地方也要进行修改,在device/config/chips/t113/configs/evb1_auto/buildroot/env.cfg的setargs_nand、setargs_nand_ubi、setargs_mmc变量上有引用,要把:
partitions=${partitions}
改成:
partitions=${partition}
1199

被折叠的 条评论
为什么被折叠?



