Hi, I am trying to write a command line utility for our dev board (440GX,2.6.9 kernel) in order to provide support for our hardware engineers. As a test I am trying to dump the first few bytes of the U-boot header.
I though that this would work but using /dev/mem gives me a bad address error on the pread64, using /dev/kmem only reads back 0 bytes. Is there something blindingly obvious that I am missing for using 36bit addresses ? I believe the address is correct as I can see the boot code from within the kernel. Thanks. #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <unistd.h> #include <errno.h> unsigned char buf[10240]; int main(int argc,char **argv) { unsigned long long memAddr=0x00000001fff80000ULL; int x; int fd; int readSize; int pageSize; pageSize=sysconf(_SC_PAGESIZE); fd=open64("/dev/mem", O_RDWR); if(fd==-1) { perror("open64"); return 0; } readSize=pread64(fd,(void*)buf,pageSize,memAddr); if(readSize != pageSize) { perror("pread64 "); printf("only read %d of %d requested bytes\n", readSize, pageSize); } close(fd); // show some of it if(readSize>0) { for(x=0;x<25;x++) { printf("%02x(%c) ",buf[x],isprint(buf[x])?buf[x]:'.'); } printf("\n"); } } Neil -- Neil Wilson Airspan Communications Ltd. Cambridge House, Oxford Road, Uxbridge, Middx, UB8 1UN, UK. Tel: +44(0)1895-467265 neilwilson at airspan.com www.airspan.com