更新时间:2023-11-19 22:51:40
TL-DR; Linux具有庞大的基础架构,并且可以使用各种rootfs或引导文件系统.选择是由于适应了不同的系统限制和最终用户功能. Busybox是目标系统的不错选择,但是如果系统工程师不花时间去理解它,那么任何软件都可能被滥用.
TL-DR; Linux has a huge infrastructure and variety of rootfs or boot file systems available. The choice is due to accommodation of different system constraints and end user functions. Busybox is a good choice for the target system, but any software can be misused if a system engineer doesn't spend time to understand it.
我的平台是Busybox的用例吗?
Is my platform an use case for Busybox?
如果您需要花一些时间来最小化内核大小和busybox
本身.您不太可能需要当前busybox
中的所有功能.
It is if you take time to minimize the kernel size and busybox
itself. It is unlikely you need all features in your current busybox
.
如果没有,是否有任何方法可以方便地在各自的可执行文件上构建linux系统实用程序?
if not, is there anything to conveniently build linux system utilities each on their own executable?
请参阅下面的klibc信息.您还可以使用musl构建破折号,许多目标,例如软件包管理和实时更新.
See klibc information below. You can also build dash with musl, with buildroot and busybox. Many filesystem builders support shared libraries or static binaries. However, there are many goals such as package management, and live updates, that a filesystem builder may target.
您可以在busybox外配置功能.想法是需要所有已配置的功能.因此,您需要将它们全部存储在内存中.对于busybox,ls
,mkdir
,printf
等都是相同的二进制文件.因此,如果您运行Shell脚本,则一个代码加载就是所有代码加载.另一种方法是,您有许多单独的二进制文件,每个二进制文件都将占用额外的内存.您需要最小化Linux以获取更多的RAM,并且可以从busybox
中删除某些功能以使其更小. Busybox就像一个巨大的共享库.或更准确地说是shared process
.所有代码页都相同.
You can configure features out of busybox. The idea is that all of the configured features are needed. Therefore you need them all in memory. With busybox, ls
, mkdir
, printf
, etc are all the same binary. So if you run a shell script the one code load is all code loads. The other way, you have many separate binaries and each will take extra memory. You need to minimize Linux to get more RAM and you can take features out of busybox
to make it smaller. Busybox is like a giant shared library; or more accurately a shared process
. All code pages are the same.
定制的Cortex-M7板,具有16 Mb的SDRAM和64 Mb的闪存
a custom Cortex-M7 board with 16 Mb of SDRAM and 64 Mb of Flash
...
一个且只有busybox可执行文件(我的系统上为650 Kb)
one and only busybox executable (650 Kb on my system)
显然650KB远远小于16MB.您无需说明其他RAM的用途.有关另一种好的替代方法,请参见 klibc工具套件.目前尚不清楚FLASH是否为NAND/NOR,以及是否启用了XIP.通常,仅使用XIP闪存时,busybox
会更好,而对于某些文件系统在闪存中,klibc
仅对于SDRAM会更好(并且受到更多限制).
Obviously 650KB is far less than 16MB. You don't say what the other RAM is used for. For another good alternative look at the klibc toolsuite. What is not clear is whether the FLASH is NAND/NOR and if you have XIP enabled. Generally, busybox
would be better with XIP flash and klibc
would be better (and more limited) for SDRAM only, with some filesystem in flash.
请参阅:Busybox常见问题解答中的可重定位代码,PIC和静态链接使用的内存.它被设计为从只读存储器运行,这可能是很大的收益,具体取决于系统结构.它可能提供比klibc更丰富的功能集,因为该项目的目标只是引导其他安装设备(硬盘,SSD等).
See: Memory used by relocatable code, PIC, and static linking in the Busybox FAQ. It is designed to run from Read-only memory which can be a big gain depending on system structure. It probably provides a more rich feature set than klibc as the goal with that project is just to boot some other mount device (a hard drive, SSD etc).
Klibc没有比busybox更多的文档.它可以是共享库,也可以是静态链接的.每个二进制文件将仅使用静态链接执行该任务所需的RAM,但这将占用更多的闪存空间.带有klibc的二进制文件是
Klibc does not have as much documentation as busybox. It can be either a shared library or statically linked. Each binary will only use the RAM needed for that task with static linking, but this will take more flash space. The binary with klibc are,
1. dash 2. chroot 3. dd 4. dmesg 5. mkdir 6. mkfifo
7. mknode 8. pivot_root 9. unmount 10. true 11. false 12. sleep
13. ln 14. ls 15. mv 16. nuke 17. minips 18. cat
19. uname 20. halt 21. kill 22. cpio 23. sync 24. readlink
25. gzip 26. losetup
那就是IT!!无需网络连接,无需媒体播放器等.您可以编写代码来使用klibc,但这是一个非常受限制的库,可能没有所需的功能.通常,它将仅限于磁盘任务.例如,***探测USB以使外部设备从中启动.
and that is IT! No networking, no media players, etc. You can write code to use klibc, but it is a very constrained library and may not have features that you require. Generally it would be limit to disk only tasks. It is great to probe USB for external device to boot from for example.
Busybox可以做更多的事情.大多数klibc静态二进制文件的大小都将低于100kB;典型值为10-30kB.破折号和gzip较大.但是,我认为您需要从内核中删除配置项,因为650KB<<<即使没有XIP,16MB和busybox也是该系统的不错选择.
Busybox can do a lot more. Most klibc static binaries will be under 100kB; with 10-30kB typical. Dash and gzip are larger. However, I think you need to remove configuration items from your kernel as 650KB << 16MB and busybox would be a fine choice for this system even without XIP.
我还应该指出,Linux使用MMU系统对代码进行需求页面加载".即使您没有交换,代码也可以从RAM中踢出,并在以后出现页面错误时重新加载.您的系统是非MMU,因此在这种情况下busybox不能正常运行.使用mmu和按需加载页面",它将做得更好.
I should also be noted that Linux does 'demand page loading' for code with an MMU system. Even if you don't have swap, code can be kicked out of RAM and reloaded later with a page fault. Your system is no-MMU, so busybox will not perform as well in this case. With an mmu and 'demand page loading' it will do much better.
对于严格的约束,您始终可以编写完整的免费的库二进制文件 .这样可以避免可能不需要的libgcc启动和支持基础结构.通常,这仅对于测试内核与initrd问题以及必须在许多不同的库环境中运行的脚本/二进制文件才有用.
For severe constraints, you can always code a completely library free binary. This avoids libgcc startup and support infrastructure which you might not need. Generally, this is only good to test a kernel vs. initrd issue and for script/binary that must run in many different library environments.
另请参阅:
XIP只能与ROM,NOR闪存配合使用,并且可能与 SPI-NOR MTD.
XIP can only work with ROM, NOR flash and possibly SPI-NOR MTDs.