Update for v1.0

This commit is contained in:
James Deng 2024-05-30 23:19:44 +08:00
parent d0e22fd5b0
commit c3b72c9393
49 changed files with 1914 additions and 453 deletions

View file

@ -17,6 +17,10 @@
#include <linux/delay.h>
#include <linux/string.h>
#ifdef CONFIG_VIDEO_SPACEMIT
extern bool is_video_connected;
#endif
/* maximum bootmenu entries */
#define MAX_COUNT 99
@ -600,7 +604,14 @@ int menu_show(int bootdelay)
return 0;
#endif
env_set("stdout","serial,vidconsole");
#ifdef CONFIG_VIDEO_SPACEMIT
printf("menu_show:is_video_connected: %d\n", is_video_connected);
if (is_video_connected) {
env_set("stdout", "serial,vidconsole");
} else {
env_set("stdout", "serial");
}
#endif
while (1) {
ret = bootmenu_show(bootdelay);
@ -616,7 +627,8 @@ int menu_show(int bootdelay)
run_command("run bootcmd", 0);
}
} else {
}
if (ret == BOOTMENU_RET_QUIT) {
break;
}
}

View file

@ -51,98 +51,6 @@ static void free_flash_dev(struct flash_dev *fdev)
free(fdev);
}
static int _write_gpt_partition(struct flash_dev *fdev)
{
__maybe_unused char write_part_command[300] = {"\0"};
char *gpt_table_str = NULL;
u32 boot_mode = get_boot_pin_select();
if (fdev->gptinfo.gpt_table != NULL && strlen(fdev->gptinfo.gpt_table) > 0){
gpt_table_str = malloc(strlen(fdev->gptinfo.gpt_table) + 32);
if (gpt_table_str == NULL){
return -1;
}
sprintf(gpt_table_str, "env set -f partitions '%s'", fdev->gptinfo.gpt_table);
run_command(gpt_table_str, 0);
free(gpt_table_str);
}
switch(boot_mode){
#if CONFIG_IS_ENABLED(FASTBOOT_FLASH_MMC) || CONFIG_IS_ENABLED(FASTBOOT_MULTI_FLASH_OPTION_MMC)
case BOOT_MODE_EMMC:
case BOOT_MODE_SD:
sprintf(write_part_command, "gpt write mmc %x '%s'",
CONFIG_FASTBOOT_FLASH_MMC_DEV, fdev->gptinfo.gpt_table);
if (run_command(write_part_command, 0)){
printf("write gpt fail\n");
return -1;
}
break;
#endif
#if CONFIG_IS_ENABLED(FASTBOOT_SUPPORT_BLOCK_DEV)
case BOOT_MODE_NOR:
case BOOT_MODE_NAND:
printf("write gpt to dev:%s\n", CONFIG_FASTBOOT_SUPPORT_BLOCK_DEV_NAME);
/*nvme need scan at first*/
if (!strncmp("nvme", CONFIG_FASTBOOT_SUPPORT_BLOCK_DEV_NAME, 4)
&& nvme_scan_namespace()){
printf("can not can nvme devices!\n");
return -1;
}
sprintf(write_part_command, "gpt write %s %x '%s'",
CONFIG_FASTBOOT_SUPPORT_BLOCK_DEV_NAME, CONFIG_FASTBOOT_SUPPORT_BLOCK_DEV_INDEX,
fdev->gptinfo.gpt_table);
if (run_command(write_part_command, 0)){
printf("write gpt fail\n");
return -1;
}
break;
#endif
default:
break;
}
return 0;
}
static int _write_mtd_partition(char mtd_table[128])
{
#ifdef CONFIG_MTD
struct mtd_info *mtd;
char mtd_ids[36] = {"\0"};
char mtd_parts[128] = {"\0"};
mtd_probe_devices();
/*
try to find the first mtd device, it there have mutil mtd device such as nand and nor,
it only use the first one.
*/
mtd_for_each_device(mtd) {
if (!mtd_is_partition(mtd))
break;
}
if (mtd == NULL){
printf("can not get mtd device\n");
return -1;
}
/*to mtd device, it should write mtd table to env.*/
sprintf(mtd_ids, "%s=spi-dev", mtd->name);
sprintf(mtd_parts, "spi-dev:%s", mtd_table);
env_set("mtdids", mtd_ids);
env_set("mtdparts", mtd_parts);
#endif
return 0;
}
/* Initialize the mmc device given its number */
static int init_mmc_device(int dev_num)
{
@ -899,11 +807,13 @@ static int parse_flash_config(struct flash_dev *fdev)
}
if (fdev->gptinfo.gpt_table != NULL && strlen(fdev->gptinfo.gpt_table) > 1 && fdev->gptinfo.fastboot_flash_gpt){
_write_gpt_partition(fdev);
if (_write_gpt_partition(fdev))
return -1;
}
if (fdev->mtd_table != NULL && strlen(fdev->mtd_table) > 1){
_write_mtd_partition(fdev->mtd_table);
if (_write_mtd_partition(fdev))
return -1;
}
/*set partition to env*/