Reputation: 2598
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
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
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
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
Reputation: 29615
Do you have /proc/meminfo? Would that give you the information you need?
Upvotes: 1
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