Bogi
Bogi

Reputation: 2598

Programatically get information about ROM memory type and size on Linux

I need information form my C program about total size of flash memory and flash memory type on my embedded Linux. I can see these information when the kernel boots, but cannot find any other way to get them. Is this possible at all?

Upvotes: 2

Views: 2345

Answers (4)

l2y3n2
l2y3n2

Reputation: 76

I assume your linux kernel is 2.6 newer and you could check /proc/mtd*** for general information.

If that's not enough, check the source code of mtd-tools: mtdinfo.c

http://gitorious.org/0xdroid/external_mtd_utils/blobs/e783e75e09b4a0a519665afd7bdeaf2985e7a09c/ubi-utils/src/mtdinfo.c

check those print_XXXX_info functions. You also need some external library to make that work.

kernel api for mtd interface changes once in a while, so make sure you have the correct version for your kernel.

Upvotes: 1

Clifford
Clifford

Reputation: 93476

Take a look at the kernel and/or bootloader source to see how it does it when it boots. The method is likely to be specific to your hardware.

Upvotes: 0

theglauber
theglauber

Reputation: 29615

Do you have /proc/meminfo? Would that give you the information you need?

Upvotes: 1

raj_gt1
raj_gt1

Reputation: 4691

yes .it is possible using dmidecode utility of linux. here is the sample code

#include <stdio.h>  
#include <stdlib.h> 
int main()  
{  
    char str[100]  = "dmidecode | grep -i 'ROM Size'";  
    system(str);  
    return 0;  
}

it will give you ROM size and if you do not grep for ROM Size then it also provide other BIOS information. if your embedded Linux doesn't have Dmidecode utility then you can get the source code from here. you can also analyse the part of dmidecode source code which is providing ROM info in case you not want to use system command and not want to dig other BIOS information.

Upvotes: 0

Related Questions