mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2025-12-10 07:44:53 +01:00
ipq807x: board: Pass UUID of rootfs partion to kernel in bootargs
This change is for mounting the rootfs partition in kernel based on UUID(Universally Unique IDentifier). In embedded system it is common to store rootfs on SD card or eMMC. Typically the kernel command line has like: root=/dev/mmcblk0p20 to tell the kernel where to look for rootfs partition. The problem in this approach is the eMMC device number can vary based on wether the SD card present or not in the SD card slot. Also depending on kernel version the eMMC device number can vary. This means passing the eMMC device for specifying the rootfs location is not robust approach. If SD card first get detected then the base minor 0 is assigned to SD card and kernel will try to mount rootfs from SD card and if there is no rootfs present on SD card then kernel fail to mount the rootfs. Change-Id: Ia9e6dded61292bed8a10a40fd3cb86f4026393eb Signed-off-by: Md Sadre Alam <mdalam@codeaurora.org>
This commit is contained in:
parent
f79446c62a
commit
6878c037e3
5 changed files with 86 additions and 1 deletions
|
|
@ -53,6 +53,7 @@ void set_flash_secondary_type(qca_smem_flash_info_t *);
|
|||
void dump_func(void);
|
||||
int do_dumpqca_flash_data(const char *);
|
||||
int apps_iscrashed(void);
|
||||
int set_uuid_bootargs(char *boot_args, char *part_name, int buflen, bool gpt_flag);
|
||||
|
||||
struct dumpinfo_t{
|
||||
char name[16]; /* use only file name in 8.3 format */
|
||||
|
|
@ -80,4 +81,6 @@ extern int dump_entries_s;
|
|||
|
||||
#define SPI_DEFAULT_ADDR_LEN 3
|
||||
#define SPI_MAX_ADDR_LEN 4
|
||||
|
||||
#define MAX_BOOT_ARGS_SIZE 64
|
||||
#endif /* __QCA_COMMON_H_ */
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@
|
|||
|
||||
static int debug = 0;
|
||||
static char mtdids[256];
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
static qca_smem_flash_info_t *sfi = &qca_smem_flash_info;
|
||||
int ipq_fs_on_nand ;
|
||||
|
|
@ -272,6 +271,8 @@ static int set_fs_bootargs(int *fs_on_nand)
|
|||
{
|
||||
char *bootargs;
|
||||
unsigned int active_part = 0;
|
||||
int ret = 0;
|
||||
char boot_args[MAX_BOOT_ARGS_SIZE] = {'\0'};
|
||||
|
||||
#define nand_rootfs "ubi.mtd=" QCA_ROOT_FS_PART_NAME " root=mtd:ubi_rootfs rootfstype=squashfs"
|
||||
|
||||
|
|
@ -298,15 +299,23 @@ static int set_fs_bootargs(int *fs_on_nand)
|
|||
setenv("fsbootargs", bootargs);
|
||||
} else {
|
||||
if (smem_bootconfig_info() == 0) {
|
||||
bootargs = boot_args;
|
||||
active_part = get_rootfs_active_partition();
|
||||
if (active_part) {
|
||||
bootargs = "rootfsname=rootfs_1";
|
||||
ret = set_uuid_bootargs(bootargs, "rootfs_1", sizeof(boot_args), false);
|
||||
} else {
|
||||
bootargs = "rootfsname=rootfs";
|
||||
ret = set_uuid_bootargs(bootargs, "rootfs", sizeof(boot_args), false);
|
||||
}
|
||||
} else {
|
||||
bootargs = "rootfsname=rootfs";
|
||||
ret = set_uuid_bootargs(bootargs, "rootfs", sizeof(boot_args), false);
|
||||
}
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
*fs_on_nand = 0;
|
||||
|
||||
snprintf(mtdids, sizeof(mtdids), "nand%d="
|
||||
|
|
@ -326,16 +335,23 @@ static int set_fs_bootargs(int *fs_on_nand)
|
|||
#ifdef CONFIG_QCA_MMC
|
||||
} else if (sfi->flash_type == SMEM_BOOT_MMC_FLASH) {
|
||||
if (smem_bootconfig_info() == 0) {
|
||||
bootargs = boot_args;
|
||||
active_part = get_rootfs_active_partition();
|
||||
if (active_part) {
|
||||
bootargs = "rootfsname=rootfs_1 gpt";
|
||||
ret = set_uuid_bootargs(bootargs, "rootfs_1", sizeof(boot_args), true);
|
||||
} else {
|
||||
bootargs = "rootfsname=rootfs gpt";
|
||||
ret = set_uuid_bootargs(bootargs, "rootfs", sizeof(boot_args), true);
|
||||
}
|
||||
} else {
|
||||
bootargs = "rootfsname=rootfs gpt";
|
||||
ret = set_uuid_bootargs(bootargs, "rootfs", sizeof(boot_args), true);
|
||||
}
|
||||
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
*fs_on_nand = 0;
|
||||
if (getenv("fsbootargs") == NULL)
|
||||
setenv("fsbootargs", bootargs);
|
||||
|
|
|
|||
|
|
@ -503,3 +503,11 @@ unsigned int get_dts_machid(unsigned int machid)
|
|||
return machid;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the uuid in bootargs variable for mounting rootfilesystem
|
||||
*/
|
||||
int set_uuid_bootargs(char *boot_args, char *part_name, int buflen, bool gpt_flag)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -971,3 +971,11 @@ void disable_caches(void)
|
|||
icache_disable();
|
||||
dcache_disable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the uuid in bootargs variable for mounting rootfilesystem
|
||||
*/
|
||||
int set_uuid_bootargs(char *boot_args, char *part_name, int buflen, bool gpt_flag)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1033,3 +1033,53 @@ int apps_iscrashed(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the uuid in bootargs variable for mounting rootfilesystem
|
||||
*/
|
||||
int set_uuid_bootargs(char *boot_args, char *part_name, int buflen, bool gpt_flag)
|
||||
{
|
||||
int ret, len;
|
||||
block_dev_desc_t *blk_dev;
|
||||
disk_partition_t disk_info;
|
||||
|
||||
blk_dev = mmc_get_dev(mmc_host.dev_num);
|
||||
if (!blk_dev) {
|
||||
printf("Invalid block device name\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (buflen <= 0 || buflen > MAX_BOOT_ARGS_SIZE)
|
||||
return -EINVAL;
|
||||
|
||||
#ifdef CONFIG_PARTITION_UUIDS
|
||||
ret = get_partition_info_efi_by_name(blk_dev,
|
||||
part_name, &disk_info);
|
||||
if (ret) {
|
||||
printf("bootipq: unsupported partition name %s\n",part_name);
|
||||
return -EINVAL;
|
||||
}
|
||||
if ((len = strlcpy(boot_args, "root=PARTUUID=", buflen)) >= buflen)
|
||||
return -EINVAL;
|
||||
#else
|
||||
if ((len = strlcpy(boot_args, "rootfsname=", buflen)) >= buflen)
|
||||
return -EINVAL;
|
||||
#endif
|
||||
boot_args += len;
|
||||
buflen -= len;
|
||||
|
||||
#ifdef CONFIG_PARTITION_UUIDS
|
||||
if ((len = strlcpy(boot_args, disk_info.uuid, buflen)) >= buflen)
|
||||
return -EINVAL;
|
||||
#else
|
||||
if ((len = strlcpy(boot_args, part_name, buflen)) >= buflen)
|
||||
return -EINVAL;
|
||||
#endif
|
||||
boot_args += len;
|
||||
buflen -= len;
|
||||
|
||||
if (gpt_flag && strlcpy(boot_args, " gpt", buflen) >= buflen)
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue