1.在LK里读分区 bootable/bootloader/lk/app/aboot/aboot.c
// @20180508 for slb741 reconfig mac address 168行
static const char *mac_cmdline = "meig";
// @20180508 for slb741 reconfig mac address 231行
static char meig_ver_buf[128];
static char meig_mac_buf[128];
//
typedef struct
{uint8_t project_name[512];
uint8_t snu_name[512];
uint8_t lcd_sec_name[512];
uint8_t mac_dress[512];//@20180508 for slb741 reconfig mac address 304行 定义每个成员在分区的地址的位置
} project_feature_entry;
// @20180508 for slb741 reconfig mac address 读分区函数 360行
#if 1
#define ROUND_TO_PAGE(x,y) (((x) + (y)) & (~(y))) //
int target_load_mac_config(project_feature_entry* out)
{
char *ptn_name = "ssign";
unsigned long long ptn = 0;
project_feature_entry *out_entry = out;
unsigned int size = ROUND_TO_PAGE(sizeof(*out_entry), 511); //512的整数倍
unsigned char data[size];
int index = INVALID_PTN;
index = partition_get_index("ssign");
ptn = partition_get_offset(index);
mmc_set_lun(partition_get_lun(index));
if (ptn == 0) {
dprintf(CRITICAL,"partition %s doesn't exist\n", ptn_name);
return -1;
}
mmc_read(ptn, (unsigned int*)data, size);
memcpy((void *)out_entry, (void const *)data, sizeof(*out_entry));
memset(meig_mac_buf, 0, 512);
sprintf(meig_mac_buf, "%s%s", mac_cmdline, out_entry->mac_dress);
dprintf(CRITICAL, "meiggggg string: %s\n", meig_mac_buf);
dprintf(CRITICAL, "meig size: %d\n", size);
return 0;
}
#endif
//读出的东西加到cmdline里 470行
if (target_load_mac_config(&entry) >= 0)
{
dprintf(CRITICAL,"zly mmm 10000\n");
cmdline_len += strlen(meig_mac_buf);
}
// @20180508 for slb741 reconfig mac address 658行
src = meig_mac_buf;
if (have_cmdline) --dst;
have_cmdline = 1;
while ((*dst++ = *src++));
if (warm_boot) {
if (have_cmdline) --dst;
src = warmboot_cmdline;
while ((*dst++ = *src++));
}