如何在C中获得Linux Flash ROM大小?

时间:2011-07-01 01:35:31

标签: c++ linux embedded-linux

是否有可用于获取ROM大小的C / C ++库或Linux系统命令? 在启动时,内核以Mb显示正确的大小。我似乎无法找到我可以从哪里拉出来的

谢谢-Naze

顺便说一下,我在嵌入式系统上使用jff2 ROM文件系统。 ARM7 cpu。

2 个答案:

答案 0 :(得分:2)

如果它显示为mtd设备,您可以执行以下操作

cat /proc/mtd
dev:    size   erasesize  name
mtd0: 00030000 00010000 "BootLoaders"
mtd1: 00200000 00010000 "Kernel"
mtd2: 00280000 00010000 "RootFS"
mtd3: 00350000 00010000 "User"

大小是十六进制

有关单个mtd的更多信息,您可以在/sys/class/mtd<n>目录

中找到它们

答案 1 :(得分:1)

不确定底层系统功能是什么,但是dmidecodehere)是一个可以在shell上运行的程序,它将转储一堆信息,包括bios ROM大小。在我的机器上它执行此操作:

sophiel:/home/owner# dmidecode | more
# dmidecode 2.9
SMBIOS 2.3 present.
59 structures occupying 1891 bytes.
Table at 0x000F0450.

Handle 0xDA00, DMI type 218, 35 bytes
OEM-specific Type
        Header and Data:
                DA 23 00 DA B2 00 17 0B 0E 18 00 58 00 58 00 01
                00 59 00 59 00 01 00 05 80 05 80 01 00 FF FF 00
                00 00 00

Handle 0xDA01, DMI type 218, 17 bytes
OEM-specific Type
        Header and Data:
                DA 11 01 DA B2 00 17 0B 0E 18 00 FF FF 00 00 00
                00

Handle 0x0000, DMI type 0, 20 bytes
BIOS Information
        Vendor: Dell Computer Corporation
        Version: A03
        Release Date: 01/05/2006
        Address: 0xF0000
        Runtime Size: 64 kB
        ROM Size: 512 kB
        Characteristics:
                PCI is supported
                PNP is supported
                APM is supported
                BIOS is upgradeable
                BIOS shadowing is allowed
                ESCD support is available
                Boot from CD is supported
                Selectable boot is supported
                EDD is supported
                Japanese floppy for Toshiba 1.2 MB is supported (int 13h)
                Print screen service is supported (int 5h)
                8042 keyboard services are supported (int 9h)
                Serial services are supported (int 14h)
                Printer services are supported (int 17h)
                ACPI is supported
                USB legacy is supported
                LS-120 boot is supported
                BIOS boot specification is supported
                Function key-initiated network boot is supported

它是开源的,所以我打赌你可以深入研究它并弄清楚它是如何工作的:我希望有一堆二进制数据解码是必要的。