惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Know Your Adversary
Know Your Adversary
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
F
Fortinet All Blogs
B
Blog
罗磊的独立博客
宝玉的分享
宝玉的分享
Vercel News
Vercel News
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium
P
Proofpoint News Feed
T
Threatpost
Security Latest
Security Latest
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Stack Overflow Blog
Stack Overflow Blog
I
Intezer
P
Privacy International News Feed
D
Docker
月光博客
月光博客
博客园 - 三生石上(FineUI控件)
M
MIT News - Artificial intelligence
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
Lohrmann on Cybersecurity
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
A
Arctic Wolf
IT之家
IT之家
S
SegmentFault 最新的问题
S
Securelist
博客园 - 叶小钗
N
News and Events Feed by Topic
F
Full Disclosure
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
Hacker News: Ask HN
Hacker News: Ask HN
博客园 - Franky
GbyAI
GbyAI
AI
AI
Y
Y Combinator Blog
WordPress大学
WordPress大学
Latest news
Latest news
Microsoft Security Blog
Microsoft Security Blog
人人都是产品经理
人人都是产品经理
N
News | PayPal Newsroom
The Cloudflare Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
I
InfoQ

博客园 - midhillzhou

windows 11关闭防火墙 以使得 外部的开发板可以主动发起ping通电脑 uboot中调试景略以太网phy JL3111A2-NA windows上excel运行macro之后出现错误 在linux上移植sgdisk 在linux上移植phytool + 调试tja1103 以太网phy 使用gdb调试user程序 之 某个线程的调用栈 在uboot中修改tja 1103以太网phy from slave to master porting perf性能观测工具 porting 开源memtester uboot 2020版本下gpio命令的使用 + linux下的libgpiod lib库的移植使用 i2c指令使用 + 仿照开源i2ctransfer实现的自己的i2ctransfer windows下outlook 撤回邮件 安装repo 使用lauterbach debug uboot之重定位 uboot中各种memory读写命令 uboot nand flash dump 环境变量 + 制作环境变量分区 + 代码结构详解 uboot bootm代码详解图 Beyond Compare 进行二进制文档的比对时,怎么去对齐(转载) notepad++分析log小技巧 使用继电器控制开发板上下电 uboot debug小技巧
ubi文件系统的 制作 + 挂载 + 若干问题
midhillzhou · 2025-09-28 · via 博客园 - midhillzhou

1 ubi文件系统的制作

1.1 测试项目的文件目录结构如下

image

其中diag.img和diag.ubifs是生成的产物。

ubinize.cfg是自己手写的配置文件,下文将会讲解。

ubi_source_dir是待制作的ubi 镜像的原始文件。

1.2 使用如下命令制作出diag.ubifs

mkfs.ubifs –F -q -r ubi_source_dir -m 2048 -e 126976 -c 71 -o diag.ubifs

我们使用的nand flash是 page size: 2k     block size: 64 page

block_size: 2k * 1024 * 64 = 131072‬

-F: 使能“white-space-fixup”,如果是通过u-boot烧写需要使能此功能

-r: 待制作的文件系统目录

-m: 最小输入输出大小,一般为page_size, 当前spinand的page_size为2048byte

-e: LEB size 逻辑可擦除块大小,block_size - (2*page_size) = 128k - 4k = 126976       2 * 1024 * 62 = 126976‬   62个page size

-c: 文件系统所占用的最大block数,一般小于等于(block_count - 1)。

目前有如下两种方式,我已经验证的是方式一,所以这里写-c 71

方式一:131072 * (71 + 1) = 9,437,184

方式二:LEB = 9216 * 1024 / 126976 - 4 = 70.322

1.3 使用如下命令制作出最终可以烧录的diag.img

ubinize -o diag.img -m 2048 -p 128KiB ubinize.cfg

-p: block size

-m: spi nand flash的最小读写单元,一般为page_size

-o:输出的diag.img文件

ubinize.cfg: 为ubinize所需的配置文件,内容如下

[ubifs]
mode=ubi
image=diag.ubifs
vol_id=0
vol_size=9216KiB
vol_type=dynamic
vol_name=diag
vol_alignment=1
vol_flags=autoresize

 2.linux启动的时候,在/etc/init.d/S打头文件里面加入如下行进行attach

ubiattach /dev/ubi_ctrl -m ${diag_mtdidx} -d ${ubidev_idx}
mount -t ubifs -o noatime,rw /dev/ubi${ubidev_idx}_0 /mnt/diag

我这里使用的是: ubiattach /dev/ubi_ctrl -m 23 -d 2

-m: diag分区的mtd index

-d: 0被ubi rootfs用掉了, 1被另外一个ubi分区用掉了,所以这里写2.

问题1:一直显示attach不上,错误如下

[    8.907131] ubi2 error: ubi_eba_init: no enough physical eraseblocks (0, need 1)
[    8.907199] ubi2 error: ubi_attach_mtd_dev: failed to attach mtd23, error -28

目前我的diag分区是mtd23,其大小是10M,我在ubinize.cfg里面配置的是9M,然后将其改成如下的7M,就ok了

image

问题2:怎么判断自己烧录到flash当中的内容和生成的diag.img是一样,确认下是否烧错了

dd if=/dev/mtd23 of=mtd23_dump_16_54.bin bs=2048

 不过如上命令,可能不能handle 坏块

问题3:怎么知道某个mtd分区的偏移地址,大小

cat /sys/class/mtd/mtd23/name
cat /sys/class/mtd/mtd23/offset
cat /sys/class/mtd/mtd23/size