diff --git a/fs/vfs/multi_partition/src/mtd_partition.c b/fs/vfs/multi_partition/src/mtd_partition.c index d11adb2e8845b8aa592bdc8b18e554164559d836..804865d36d3f1d9e91827f3be6232ead89829c09 100644 --- a/fs/vfs/multi_partition/src/mtd_partition.c +++ b/fs/vfs/multi_partition/src/mtd_partition.c @@ -71,10 +71,18 @@ static VOID MtdNorParamAssign(partition_param *spinorParam, const struct MtdDev * you can change the SPIBLK_NAME or SPICHR_NAME to NULL. */ spinorParam->flash_mtd = (struct MtdDev *)spinorMtd; +#ifndef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 spinorParam->flash_ops = GetDevSpinorOps(); spinorParam->char_ops = GetMtdCharFops(); spinorParam->blockname = SPIBLK_NAME; spinorParam->charname = SPICHR_NAME; +#else + extern struct block_operations *GetCfiBlkOps(void); + spinorParam->flash_ops = GetCfiBlkOps(); + spinorParam->char_ops = NULL; + spinorParam->blockname = "/dev/cfiflash"; + spinorParam->charname = NULL; +#endif spinorParam->partition_head = g_spinorPartitionHead; spinorParam->block_size = spinorMtd->eraseSize; } @@ -88,7 +96,12 @@ static VOID MtdDeinitSpinorParam(VOID) static partition_param *MtdInitSpinorParam(partition_param *spinorParam) { +#ifndef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 struct MtdDev *spinorMtd = GetMtd("spinor"); +#else + extern struct MtdDev *GetCfiMtdDev(void); + struct MtdDev *spinorMtd = GetCfiMtdDev(); +#endif if (spinorMtd == NULL) { return NULL; } @@ -121,7 +134,7 @@ static partition_param *MtdInitSpinorParam(partition_param *spinorParam) /* According the flash-type to init the param of the partition. */ static INT32 MtdInitFsparParam(const CHAR *type, partition_param **fsparParam) { - if (strcmp(type, "spinor") == 0) { + if (strcmp(type, "spinor") == 0 || strcmp(type, "cfi-flash") == 0) { g_spinorPartParam = MtdInitSpinorParam(g_spinorPartParam); *fsparParam = g_spinorPartParam; } else { @@ -138,7 +151,7 @@ static INT32 MtdInitFsparParam(const CHAR *type, partition_param **fsparParam) /* According the flash-type to deinit the param of the partition. */ static INT32 MtdDeinitFsparParam(const CHAR *type) { - if (strcmp(type, "spinor") == 0) { + if (strcmp(type, "spinor") == 0 || strcmp(type, "cfi-flash") == 0) { MtdDeinitSpinorParam(); g_spinorPartParam = NULL; } else { @@ -356,7 +369,7 @@ static INT32 DeleteParamCheck(UINT32 partitionNum, const CHAR *type, partition_param **param) { - if (strcmp(type, "spinor") == 0) { + if (strcmp(type, "spinor") == 0 || strcmp(type, "cfi-flash") == 0) { *param = g_spinorPartParam; } else { PRINT_ERR("type error \n"); diff --git a/kernel/common/los_rootfs.c b/kernel/common/los_rootfs.c index 8210ad64d4315d8eab36d202c981012ecaa3b312..934a8a8fd0fa6fbb514bd9051c25130e380e16d6 100644 --- a/kernel/common/los_rootfs.c +++ b/kernel/common/los_rootfs.c @@ -31,7 +31,7 @@ #include "los_base.h" #include "los_typedef.h" #include "string.h" -#ifdef LOSCFG_PLATFORM_HI3518EV300 +#if defined(LOSCFG_PLATFORM_HI3518EV300) || defined(LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7) #include "mtd_partition.h" #endif #ifdef LOSCFG_DRIVERS_MMC @@ -181,6 +181,24 @@ STATIC const CHAR *GetDevName(const CHAR *rootType, INT32 rootAddr, INT32 rootSi rootDev = AddEmmcRootfsPart(rootAddr, rootSize); } else #endif + +#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 +#define CFIFLASH_CAPACITY 64 * 1024 * 1024 + INT32 ret; + if (strcmp(rootType, "cfi-flash") == 0) { + ret = add_mtd_partition("cfi-flash", rootAddr, rootSize, 0); + if (ret != LOS_OK) { + PRINT_ERR("Failed to add cfi-flash root partition!\n"); + } else { + rootDev = "/dev/cfiflash0"; + ret = add_mtd_partition("cfi-flash", (rootAddr + rootSize), + CFIFLASH_CAPACITY - rootAddr - rootSize, 1); + if (ret != LOS_OK) { + PRINT_ERR("Failed to add cfi-flash storage partition!\n"); + } + } + } else +#endif { PRINT_ERR("Failed to find root dev type: %s\n", rootType); } @@ -239,8 +257,7 @@ STATIC INT32 GetArgs(CHAR **args) * bootloader it will pass DTB by default. */ (void)ret; - PRINT_ERR("Fetching bootargs unimplemented.\n"); - goto ERROUT; + cmdLine = "bootargs=root=cfi-flash fstype=jffs2 rootaddr=0xA00000 rootsize=27M"; #endif for (i = 0; i < COMMAND_LINE_SIZE; i += len + 1) { @@ -471,6 +488,19 @@ STATIC INT32 OsMountRootfsAndUserfs(const CHAR *rootDev, const CHAR *fsType) PRINT_ERR("Failed to mount /storage, errno %d: %s\n", err, strerror(err)); } } +#endif +#ifdef LOSCFG_PLATFORM_QEMU_ARM_VIRT_CA7 + ret = mkdir("/storage", DEFAULT_STORAGE_MOUNT_DIR_MODE); + if (ret != LOS_OK) { + err = get_errno(); + PRINT_ERR("Failed to reserve inode /storage, errno %d: %s\n", err, strerror(err)); + } else { + ret = mount("/dev/cfiflash1", "/storage", fsType, 0, NULL); + if (ret != LOS_OK) { + err = get_errno(); + PRINT_ERR("Failed to mount /storage, errno %d: %s\n", err, strerror(err)); + } + } #endif } return LOS_OK; diff --git a/tools/build/config/debug/qemu_arm_virt_ca7_clang.config b/tools/build/config/debug/qemu_arm_virt_ca7_clang.config index b56d817ada4d849efd9a1988d3e19b9a7b2797ea..0ea33d91d81744f781cd4eeaac511d4f3532deb3 100644 --- a/tools/build/config/debug/qemu_arm_virt_ca7_clang.config +++ b/tools/build/config/debug/qemu_arm_virt_ca7_clang.config @@ -34,6 +34,7 @@ LOSCFG_ARCH_CPU="cortex-a7" # # LOSCFG_ARCH_FPU_DISABLE is not set LOSCFG_IRQ_USE_STANDALONE_STACK=y +LOSCFG_PLATFORM_ROOTFS=y # # Kernel @@ -43,7 +44,7 @@ LOSCFG_KERNEL_EXTKERNEL=y # LOSCFG_KERNEL_CPPSUPPORT is not set LOSCFG_KERNEL_CPUP=y LOSCFG_CPUP_INCLUDE_IRQ=y -# LOSCFG_KERNEL_DYNLOAD is not set +LOSCFG_KERNEL_DYNLOAD=y # LOSCFG_KERNEL_VDSO is not set # LOSCFG_KERNEL_TICKLESS is not set # LOSCFG_KERNEL_TRACE is not set @@ -72,7 +73,7 @@ LOSCFG_FILE_MODE=y # LOSCFG_FS_FAT is not set LOSCFG_FS_RAMFS=y LOSCFG_FS_PROC=y -# LOSCFG_FS_JFFS is not set +LOSCFG_FS_JFFS=y # # Net @@ -97,7 +98,7 @@ LOSCFG_SHELL=y # LOSCFG_SHELL_LK is not set # LOSCFG_SHELL_EXCINFO is not set # LOSCFG_EXC_INTERACTION is not set -# LOSCFG_USER_INIT_DEBUG is not set +LOSCFG_USER_INIT_DEBUG=y # LOSCFG_SHELL_CMD_DEBUG is not set # LOSCFG_MEM_DEBUG is not set # LOSCFG_NULL_ADDRESS_PROTECT is not set @@ -125,7 +126,7 @@ LOSCFG_DRIVERS_HDF_PLATFORM=y # LOSCFG_DRIVERS_HDF_USB is not set LOSCFG_DRIVERS_MEM=y # LOSCFG_DRIVERS_MMC is not set -# LOSCFG_DRIVERS_MTD is not set +LOSCFG_DRIVERS_MTD=y # LOSCFG_DRIVERS_RANDOM is not set # LOSCFG_DRIVERS_VIDEO is not set # LOSCFG_DRIVERS_HIEVENT is not set