背景:

u-boot-2009.08版本不支持ext4文件系统,现在需要对ext4支持

目的:

在u-boot-2009.08版本上添加ext4文件系统支持

方法:

将高版本中的ext4相关代码移植到u-boot-2009.08

代码

低版本uboot代码:u-boot-2009.08

高版本uboot代码:u-boot-2013.10(下载地址:ftp://ftp.denx.de/pub/u-boot/)

步骤:

1:在头文件中定义宏开关

在include/configs/xxxxxxx.h中添加下面红色部分

#ifdef CONFIG_CMD_MMC

#define CONFIG_MMC

#define CONFIG_GENERIC_MMC

#define CONFIG_IMX_MMC

#define CONFIG_SYS_FSL_USDHC_NUM 4

#define CONFIG_SYS_FSL_ESDHC_ADDR 0

#define CONFIG_SYS_MMC_ENV_DEV 2

#define CONFIG_DOS_PARTITION 1

#define CONFIG_CMD_FAT 1

#define CONFIG_CMD_EXT2 1

#define CONFIG_CMD_EXT4 1 //对ext4文件格式支持的配置

#define CONFIG_CMD_EXT4_WRITE 1 //对ext4write命令的支持

/* detect whether SD1, 2, 3, or 4 is boot device */

#define CONFIG_DYNAMIC_MMC_DEVNO

/* SD3 and SD4 are 8 bit */

#define CONFIG_MMC_8BIT_PORTS 0xC

/* Setup target delay in DDR mode for each SD port */

#define CONFIG_GET_DDR_TARGET_DELAY

#endif

#if (defined(CONFIG_CMD_EXT4) ||defined(CONFIG_CMD_EXT2))&& \

!defined(CONFIG_FS_EXT4)

#define CONFIG_FS_EXT4 //新版本中uboot/fs/ext4/Makefile中编译选项的配置

#endif

#if defined(CONFIG_CMD_EXT4_WRITE)&&!defined(CONFIG_EXT4_WRITE)

#define CONFIG_EXT4_WRITE //新版本中uboot/fs/ext4/Makefile中编译选项的配置

#endif

2:添加ext4文件系统代码

A:将u-boot-2013.10/fs/ext4文件夹拷贝到u-boot-2009.08/fs/下

B:将u-boot-2013.10/include/下的fs.h,ext4fs.h, ext_common.h, sandboxfs.h文件

拷贝到u-boot-2009.08/include/下

C:将u-boot-2013.10/fs/fs.c文件拷贝到u-boot-2009.08/fs/ext4/下

D:在u-boot-2009.08/fs/ext4/ext4_journal.c中添加下面红色部分

#include "ext4_common.h"

#define false 0

#define true 1

E:修改u-boot-2009.08/fs/ext4/Makefile

LIB =$(obj)libext4fs.o

修改成

LIB =$(obj)libext4fs.a

$(LIB): $(obj).depend $(OBJS)

$(call cmd_link_o_target, $(OBJS))

修改成

$(LIB): $(obj).depend $(OBJS)

$(AR) $(ARFLAGS) $@ $(OBJS)

COBJS-$(CONFIG_FS_EXT4) := ext4fs.oext4_common.o dev.o

修改成

COBJS-$(CONFIG_FS_EXT4) :=fs.oext4fs.o ext4_common.odev.o

F:修改u-boot-2009.08/fs/Makefile,添加下面红色部分

subdirs-$(CONFIG_CMD_EXT2) += ext2

subdirs-$(CONFIG_CMD_EXT4) += ext4

3:添加ext4相关命令

A:将u-boot-2013.10/common/cmd_ext4.c文件夹拷贝到u-boot-2009.08/common/下

B:修改u-boot-2009.08/common/Makefile,添加下面红色部分

COBJS-$(CONFIG_CMD_EXT2) += cmd_ext2.o

COBJS-$(CONFIG_CMD_EXT4) += cmd_ext4.o

4:修改u-boot-2009.08/Makefile,添加下面红色部分

LIBS+= fs/cramfs/libcramfs.a fs/fat/libfat.afs/fdos/libfdos.afs/jffs2/libjffs2.a \

fs/reiserfs/libreiserfs.afs/ext2/libext2fs.afs/yaffs2/libyaffs2.a \

fs/ubifs/libubifs.a fs/ext4/libext4fs.a

主要步骤完成,下面是编译时需要的一些东西,旧版本没有,需要从新版本中拷贝,

可以在编译时报错时临时修改拷贝,这里给出参考

6:修改u-boot-2009.08/common/cmd_nvedit.c

拷贝u-boot-2013.10/common/cmd_nvedit.c中的函数setenv_hex

到u-boot-2009.08/common/cmd_nvedit.c

7:修改u-boot-2009.08/disk/part.c

在u-boot-2009.08/disk/part.c中添加头文件#include<malloc.h>

在u-boot-2009.08/disk/part.c末尾添加get_device和get_device_and_partition这两个函数

8:修改u-boot-2009.08/include/asm-arm/cache.h,添加下面红色部分

void l2_cache_enable(void);

void l2_cache_disable(void);

#ifdef CONFIG_SYS_CACHELINE_SIZE

#defineARCH_DMA_MINALIGN CONFIG_SYS_CACHELINE_SIZE

#else

#define ARCH_DMA_MINALIGN 64

#endif

#endif

9:修改u-boot-2009.08/include/command.h,添加下面红色部分

#endif /* CONFIG_SYS_LONGHELP */

enum command_ret_t {

CMD_RET_SUCCESS, /* 0 = Success */

CMD_RET_FAILURE, /* 1 = Failure */

CMD_RET_USAGE = -1, /* Failure, please report'usage' error */

};

#endif /* __COMMAND_H */

10:修改u-boot-2009.08/include/common.h,添加下面红色部分到文件末尾

int setenv_hex(const char *varname, ulongvalue);

static inline int setenv_addr(const char*varname, const void*addr)

{

return setenv_hex(varname, (ulong)addr);

}

# ifndef CONFIG_ARCH_MAP_SYSMEM

static inline void *map_sysmem(phys_addr_tpaddr, unsigned longlen)

{

return (void *)(uintptr_t)paddr;

}

static inline void unmap_sysmem(const void*vaddr)

{

}

static inline phys_addr_t map_to_sysmem(void*ptr)

{

return (phys_addr_t)(uintptr_t)ptr;

}

#endif

#ifndef __ASSEMBLY__

#include <asm/cache.h>

#endif

#define PAD_COUNT(s, pad) (((s) - 1) / (pad) +1)

#define PAD_SIZE(s, pad) (PAD_COUNT(s, pad) *pad)

#define ALLOC_ALIGN_BUFFER_PAD(type, name,size, align, pad) \

char __##name[ROUND(PAD_SIZE((size) *sizeof(type), pad),align) \

+ (align - 1)]; \

\

type *name = (type *)ALIGN((uintptr_t)__##name, align)

#define ALLOC_ALIGN_BUFFER(type, name, size,align) \

ALLOC_ALIGN_BUFFER_PAD(type, name, size,align, 1)

#define ALLOC_CACHE_ALIGN_BUFFER_PAD(type,name, size, pad) \

ALLOC_ALIGN_BUFFER_PAD(type, name, size,ARCH_DMA_MINALIGN,pad)

#define ALLOC_CACHE_ALIGN_BUFFER(type, name,size) \

ALLOC_ALIGN_BUFFER(type, name, size,ARCH_DMA_MINALIGN)

#define DEFINE_ALIGN_BUFFER(type, name, size,align) \

static char __##name[roundup(size *sizeof(type), align)] \

__aligned(align); \

\

static type *name = (type *)__##name

#define DEFINE_CACHE_ALIGN_BUFFER(type, name,size) \

DEFINE_ALIGN_BUFFER(type, name, size,ARCH_DMA_MINALIGN)

/* Pull in stuff for the build system */

#ifdef DO_DEPS_ONLY

# include <environment.h>

#endif

11:修改u-boot-2009.08/include/ide.h,添加下面红色部分

#ifdef CONFIG_SYS_64BIT_LBA

typedef uint64_t lbaint_t;

#define LBAF "%llx"

#define LBAFU "%llu"

#else

typedef ulong lbaint_t;

#define LBAF "%lx"

#define LBAFU "%lu"

#endif

12:修改u-boot-2009.08/include/part.h,添加下面红色部分

typedefstruct block_dev_desc {

.......

unsignedlong blksz; /* block size */

int log2blksz; /*for convenience: log2(blksz) */

char vendor[40+1]; /* IDE model, SCSI Vendor */

.......

}block_dev_desc_t;

#defineBLOCK_CNT(size, block_dev_desc)(PAD_COUNT(size,block_dev_desc->blksz))

#definePAD_TO_BLOCKSIZE(size, block_dev_desc) \

(PAD_SIZE(size,block_dev_desc->blksz))

#defineLOG2(x) (((x & 0xaaaaaaaa) ? 1 : 0) + ((x &0xcccccccc) ? 2 :0) + \

((x & 0xf0f0f0f0) ? 4 : 0) + ((x & 0xff00ff00) ? 8 :0) + \

((x & 0xffff0000) ? 16 : 0))

#defineLOG2_INVALID(type) ((type)((sizeof(type)<<3)-1))

/*Interface types: */

#defineIF_TYPE_UNKNOWN 0

#defineIF_TYPE_IDE 1

.......

typedefstruct disk_partition {

ulong start; /*# of first block in partition */

ulong size; /*number of blocks in partition */

ulong blksz; /*block size in bytes */

uchar name[32]; /*partition name */

uchar type[32]; /*string type description */

int bootable; /*Active/Bootable flag is set */

}disk_partition_t;

/*disk/part.c */

......

voiddev_print(block_dev_desc_t *dev_desc);

intget_device(const char *ifname, const char *dev_str,

block_dev_desc_t **dev_desc);

intget_device_and_partition(const char *ifname, constchar*dev_part_str,

block_dev_desc_t **dev_desc,

disk_partition_t *info, int allow_whole_dev);

#else

.......

staticinline void dev_print(block_dev_desc_t *dev_desc) {}

staticinline int get_device(const char *ifname, const char*dev_str,

block_dev_desc_t **dev_desc)

{return -1; }

staticinline int get_device_and_partition(const char *ifname,

const char *dev_part_str,

block_dev_desc_t **dev_desc,

disk_partition_t *info,

int allow_whole_dev)

{*dev_desc = NULL; return -1; }

#endif

测试:

现在应该可以编译通过,测试ext4文件系统是否支持

将编译后生成的u-boot.bin烧写到sd卡中

启动后help下,会看到ext4ls,ext4load,ext4write命令

验证:

mmc

我的SD卡是emmc中管理,用的是SD3,所以是第二个设备(01 2 3)

mmc   dev 2

切换挂载设备到sd卡

mmcinfo

查看下sd卡的信息

然后验证,意思为查看SD卡的第6个分区的文件

ext4ls   mmc 2:6

旧版本uboot对ext4文件系统格式的支持相关推荐

  1. 安装旧版本插件_iOS 应用降级插件,支持任意版本升降

    软件版本越来越高,功能越来越来越多,升级过后发现还是简简单单的老版本好用怎么办? 对于iOS用户来说,这还真不好办.在App Store下载的应用都是当前的最新版,安装方式也不像安卓系统需要先下载安装 ...

  2. 解决:旧版本的 Boostnote 笔记无法导入到新版本 Boostnote 中

    文章目录 1. 问题 2. 原因:笔记格式从 .cson 变为 .json 2.1 目前 Boostnote 的 3 种版本 2.2 三种版本的比较 3. 解决方法(推荐[解法3]) 3.1 解法1: ...

  3. oracle+磁盘挂载格式化,oracle asm disk格式化恢复—格式化为ext4文件系统

    昨天中午接到一位朋友紧急求救电话,大概场景如下,asm data磁盘组一共把个asm disk,但是使用4个lun实现的(也就是说每个lun使用fdisk进行分区),该主机上还有一个lun是用来存放备 ...

  4. linux重新识别逻辑卷,linux – 从已删除的LVM逻辑卷恢复ext4文件系统的任何方法?...

    前几天,当我在Vmware下的 Linux客户端上扩展磁盘时,我有一个适当的大脑放屁时刻.我将Vmware磁盘文件扩展到所需的大小然后我做了我通常在没有LVM的Linux客户端上做的事情:我删除了LV ...

  5. linux磁盘文件格式转换,使用Fstransform在Linux下无损转换文件系统格式

    在 Linux 下也可以无损地转换文件系统格式,那就是使用 Fstransform 工具,它可以将 ext2.ext3.ext4.jfs.reiserfs 及 xfs 分区转换成另一种类型,而且无须备 ...

  6. ext4 文件系统的特点、优缺点以及使用场景

    ext4(Fourth Extended File System)是 Linux 中最新的一种文件系统,它是 ext3 文件系统的后续版本,具有更高的性能.可靠性和扩展性.下面是 ext4 文件系统的 ...

  7. [ Linux驱动炼成记 ] 15 - 存储器EMMC中Ext4文件系统 中 磁盘空间占用率100%

    产品现象 : 设备(Linux 系统) 运行一段时间后,其中某一个分区 /et/config 突然占用率为100%,而实际空间可能1%都不到. 这种问题百思不得其解.谷歌/百度 所遇到的解决方案都是嵌 ...

  8. linux的常用文件系统格式

    文件系统指文件存在的物理空间.在Linux系统中,每个分区都是一个文件系统,都有自己的目录层次结构.Linux的最重要特征之一就是支持多种文件系统,这样它更加灵活,并可以和许多其它种操作系统共存.Vi ...

  9. 如何制作Ext4文件系统镜像

    如何制作Ext4文件系统镜像 Android中system.img的两种格式及其相互转换方法 搞Android的同学经常会接触到system.img.但是该文件经常以两种格式出现:raw和sparse ...

最新文章

  1. gitlab合并分支后需要提交吗_阿里前端,如何基于 GitLab 进行「自动化」构建及发布...
  2. php 登录注册api接口代码
  3. An Algorithm Summary of Programming Collective Intelligence
  4. 【REST】基于RESTful服务端的客户端实现(HttpClient、RestTemplate、HttpURLConnection)
  5. c mysql 工具类_Jave工具——servlet+jsp编程中mysql数据库连接及操作通用工具类
  6. 决策树编程python_Python如何制定决策:编程中的控制流简介
  7. apimac版 java_jdk1.8 mac官方下载-Java SE Development Kit 8 mac下载8u181 官方最新版__西西软件下载...
  8. 如果知道它们的热量,还想点吗?
  9. 会说话的代码——书写自表达代码之道
  10. python微信公众号生成专属二维码--你再也不用去求人了
  11. SpringSecurity多种认证方式记录之自定义
  12. 书架html特效代码,原生JS写的一个书架式的图片缩放滚动展示特效代码
  13. 富景中国在港交所招股书失效,富景农业冲刺香港上市又一次折翼
  14. 第十四周学习周报20181210-20181216
  15. Python实现PPT转化为Word和OCR识别
  16. 字节面试题-小于N的最大数字
  17. Tomcat中如何配置使用APR
  18. python从入门到撩妹 2 —— 30行代码实现520小彩蛋
  19. 洛谷算法题单:模拟与高精度例题(下)
  20. 后台管理有什么作用?

热门文章

  1. win10远程桌面怎么保存密码?win10让远程桌面记住密码的方法
  2. Socket原理和Socket函数
  3. Maven构建 —— groupId、artifactId、version概念
  4. linux中Gy模式什么意思,Linux必学的60个命令 -其他
  5. 计算机学院艺术节主题标语,艺术节标语(精选50句)
  6. windows 忘记密码 强制修改重置密码
  7. 用 Java 爬美女图片,这个厉害了!
  8. span标签中实现换行
  9. 3.0.2-Reaper(track)多通道乐器输出设置
  10. CentOS 7.5 的详细安装教程及初始配置