ts-7000
[Top] [All Lists]

[ts-7000] Re: 7260 mmap of /dev/mem fails strerror No Such Device - Help

To:
Subject: [ts-7000] Re: 7260 mmap of /dev/mem fails strerror No Such Device - Help
From: "Phil" <>
Date: Sun, 16 Apr 2006 13:57:36 -0000
Hi,

>From looking at your program, I would say that your problem is just
a small parentheses position issue. The line ...

>  if((fd = open("/dev/mem", O_RDWR | O_SYNC) == -1)) {

should look more like

>  if((fd = open("/dev/mem", O_RDWR | O_SYNC)) == -1) {


Your 'fd' was getting assigned the result of the comparison not the
actual file descriptor.

Hope this is all it is. Let us know.

Cheers
Phil


--- In  "xioaya12" <> wrote:
>
> Just received my 7260 with Dev USB Drive w/ Debian
> Booted TS-Linux OK
> /usr/bin/loadUSBModules.sh
> /usr/bin/loadUSB.sh
> Booted Debian on USB drive OK
> vim'd testlight.c as root (see below)
> failed on the return to mmap after success on open /dev/mem
> strerror set to No Such Device, and file descriptor was 0 ???
> expected > 2
> 
> I'm new to Linux and probably missed something simple.
>  
> (mknod ???, gcc -???, someother ???.sh, chmod ???)
> mmap is byte aligned to the correct 7260 address. 
> 
> Details are below, code, ps, perms on /dev:(Thanks in advance)
> 
> ts7200:~# whoami
> root
> ts7200:~# cd /usr/rich
> ts7200:/usr/rich# cat testlight.c
> #include<stdio.h>
> #include<unistd.h>
> #include<errno.h>
> #include<sys/types.h>
> #include<sys/mman.h>
> #include<sys/time.h>
> #include<fcntl.h>
> #include<string.h>
> #define BASE_ADDRESS  0x80840000
> #define DIAG_LED_OFFSET  0x020
> extern int errno;
> 
> int main(int argc, char **argv) {
>       int fd;
>       unsigned char *start;
>       volatile  unsigned int *dat;
>       int i, psize;
> 
>       if((fd = open("/dev/mem", O_RDWR | O_SYNC) == -1)) {
>         printf("Cannot open /dev/mem\n"); 
>         exit(-1);
>       }
>       psize = getpagesize();
>       if((start = (unsigned char*) mmap(0, psize, 
>                               PROT_READ | PROT_WRITE, 
>                               MAP_SHARED, fd, 
>                               BASE_ADDRESS)) == MAP_FAILED) {
>         printf("Cannot map /dev/mem ret=%d ps=%d fd=%d\n", 
>                   start, psize, fd);
>         printf("Why: %s\n",strerror(errno));
>         close(fd); 
>           exit(-1);
>       }
>       close(fd);
>       exit(0);
> }
>       
> ts7200:/usr/rich# gcc -o testlight testlight.c
> ts7200:/usr/rich# ls -l
> total 7
> -rwxr-xr-x    1 root     root         5692 Apr 15 21:04 testlight
> -rw-r--r--    1 root     root          975 Apr 15 19:27 testlight.c
> ts7200:/usr/rich# ./testlight
> Cannot map /dev/mem ret=-1 ps=4096 fd=0
> Why: No such device
> 
> ts7200:/usr/rich#ls -l /dev/mem /dev/kmem
> crw-r-----    1 root     kmem       1,   2 Dec 31  1969 /dev/kmem
> crw-r-----    1 root     kmem       1,   1 Dec 31  1969 /dev/mem
> 
> some other devices, updated today but not /dev/mem ???
> 
> lr-xr-xr-x    1 root     root            4 Apr 15 21:00 ram0 -> 
rd/0
> lr-xr-xr-x    1 root     root            4 Apr 15 21:00 ram1 -> 
rd/1
> 
> lr-xr-xr-x    1 root     root           33 Apr 15 21:00 sda -> 
> scsi/host0/bus0/target0/lun0/disc
> lr-xr-xr-x    1 root     root           34 Apr 15 21:00 sda1 -> 
> scsi/host0/bus0/target0/lun0/part1
> lr-xr-xr-x    1 root     root            4 Dec 31  1969 stderr -> 
> fd/2
> lr-xr-xr-x    1 root     root            4 Dec 31  1969 stdin -> 
fd/0
> lr-xr-xr-x    1 root     root            4 Dec 31  1969 stdout -> 
> fd/1
> crw-rw-rw-    1 root     tty        5,   0 Dec 31  1969 tty
> lr-xr-xr-x    1 root     root            4 Apr 15 21:00 tty0 -> 
vc/0
> 
> crw-------    1 root     root     204,  16 Apr 15 21:05 ttyAM0
> crw--w--w-    1 root     root     204,  17 Apr 15 20:58 ttyAM1
> 
> ps aux
> USER       PID %CPU %MEM   VSZ  RSS TTY      STAT START   TIME 
> COMMAND
> root         1  0.6  0.7  1432  468 ?        S    20:58   0:01 
init 
> [3]  
> root         2  0.0  0.0     0    0 ?        SW   20:58   0:00 
> [keventd]
> root         3  0.2  0.0     0    0 ?        RWN  20:58   0:00 
> [ksoftirqd_CPU0]
> root         4  0.0  0.0     0    0 ?        SW   20:58   0:00 
> [kswapd]
> root         5  0.0  0.0     0    0 ?        SW   20:58   0:00 
> [bdflush]
> root         6  0.0  0.0     0    0 ?        SW   20:58   0:00 
> [kupdated]
> root         7  0.0  0.0     0    0 ?        SW   20:58   0:00 
> [mtdblockd]
> daemon      54  0.0  0.7  1628  456 ?        S    20:58   
> 0:00 /sbin/portmap
> root        59  0.0  1.1  3768  676 ?        S    20:58   
> 0:00 /usr/sbin/inetd
> root        64  0.0  0.6  3432  412 ?        S    20:58   
> 0:00 /usr/sbin/telnetd
> root        73  0.0  1.7  3088 1080 ?        S    20:58   
> 0:00 /www/apache/bin/h
> #200        78  0.0  1.7  3088 1068 ?        S    20:58   
> 0:00 /www/apache/bin/h
> #200        79  0.0  1.7  3088 1068 ?        S    20:58   
> 0:00 /www/apache/bin/h
> #200        80  0.0  1.7  3088 1068 ?        S    20:58   
> 0:00 /www/apache/bin/h
> #200        81  0.0  1.7  3088 1068 ?        S    20:58   
> 0:00 /www/apache/bin/h
> #200        82  0.0  1.7  3088 1068 ?        S    20:58   
> 0:00 /www/apache/bin/h
> root        89  0.0  1.0  3568  648 ?        S    20:58   0:00 -sh
> root        90  0.0  0.8  3564  536 ?        S    20:58   
> 0:00 /sbin/getty -L 11
> root        93  0.0  0.0     0    0 ?        SW   20:59   0:00 
> [khubd]
> root       101  0.5  0.0     0    0 ?        SW   20:59   0:01 
[usb-
> storage-0]
> root       102  0.0  0.0     0    0 ?        SW   20:59   0:00 
> [scsi_eh_0]
> root       104  0.0  0.8  3560  536 ?        S    21:00   
> 0:00 /bin/sh /usr/bin/
> root       107  0.0  1.5  2240  968 ttyAM0   S    21:00   
> 0:00 /bin/sh /etc/init
> root       122  0.0  1.2  1672  780 ?        S    21:00   
> 0:00 /sbin/devfsd /dev
> root       272  0.0  1.3  2380  832 ?        S    21:01   
> 0:00 /sbin/syslogd
> root       334  0.0  0.9  1432  588 ?        S    21:01   
> 0:00 /sbin/klogd
> root       338  0.0  1.2  1608  744 ?        S    21:01   
> 0:00 /sbin/rpc.statd
> root       343  0.0  1.3  2380  808 ?        S    21:01   
> 0:00 /usr/sbin/inetd
> root       363  0.0  1.2  1872  740 ?        S    21:01   
> 0:00 /usr/sbin/cron
> root       370  0.0  2.1  2484 1288 ttyAM0   S    21:01   0:00 bash
> root       371  0.0  1.4  2832  900 ttyAM0   R    21:03   0:00 ps -
> aux
>






 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/ts-7000/

<*> To unsubscribe from this group, send an email to:
    

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU