linux error note

  1. undefined reference to `wrong_size_cmpxchg'?

    reason:gcc 版本不兼容,更换新版试试  

  2. 在开发板和LINUX间用NFS挂载已成功,但文件却看不到?

    reason:开发板上的NFS 版本与你PC机上的不兼容,挂载时加个OPTION nfsvers=版本号(4,3,2)

    man 5 nfs 查看了下nfsvers=n 的说明如下:

    nfsvers=n The NFS protocol version number used to
    contact the server's NFS service. If the
    server does not support the requested ver‐
    sion, the mount request fails. If this
    option is not specified, the client negoti‐
    ates a suitable version with the server,
    trying version 4 first, version 3 second,
    and version 2 last.
    
  3. 下载自己裁减编译好的内核zImage启动后出现:

     List of all partitions:
        1f00            1024 mtdblock0 (driver?)
        1f01            3840 mtdblock1 (driver?)
        1f02            3072 mtdblock2 (driver?)
        1f03           61440 mtdblock3 (driver?)
        1f04           61440 mtdblock4 (driver?)
        No filesystem could mount root, tried:  ext3 ext2 cramfs vfat msdos iso9660 romfs
        Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(31,3)

    reason:内核没有添加对YAFFS2的支持,添加。。后来看了看自己的配置其实是添加了的,但还是有问题,我就直接保存成.config 再编译。ok

    综上所述得知更改的配置并没有保存在.config中(我是用make s3c2410_defconf 加载的默认配置改的,改好自己保存成一个配置文件 ,后面是用LOAD加载进来的,改后直接 保存了就make zImage,结果怎么都不成功。不知道什么BUG)

  4. 写宏遇到的问题:warning: backslash and newline separated by space

    reason:'\'符号后面多了空格,删除空格就OK

  5. 在编译2440的内核时遇到如下问题:

    drivers/net/cs8900.c: In function `cs8900_probe':
    drivers/net/cs8900.c:461: error: `S3C2410_GPGCON' undeclared (first use in this function)
    drivers/net/cs8900.c:461: error: (Each undeclared identifier is reported only once
    drivers/net/cs8900.c:461: error: for each function it appears in.)
    drivers/net/cs8900.c:462: error: `S3C2410_EXTINT1' undeclared (first use in this function)
    drivers/net/cs8900.c:463: error: `S3C2410_BWSCON' undeclared (first use in this function)
    drivers/net/cs8900.c:464: error: `S3C2410_BANKCON3' undeclared (first use in this function)
    drivers/net/cs8900.c:461: warning: statement with no effect
    drivers/net/cs8900.c:462: warning: statement with no effect
    drivers/net/cs8900.c:463: warning: statement with no effect
    drivers/net/cs8900.c:464: warning: statement with no effect
    make[2]: *** [drivers/net/cs8900.o] Error 1
    make[1]: *** [drivers/net] Error 2

      reason:S3C2410的宏没定义,检查发现编译2440内核时需要选中system type->s3c2410 machines->SMDK2410/A9M2410

  6. 编译出的内核    ls /dev下有一堆的tty,pty端口,如何减少这些端口?

     reason :tty 终端设备的统称,pty是虚拟端口属字符设备,更改相应驱动项即可

    todo:make menuconfig 

    Device Drivers  --->Character devices  --->  (256)Maximum number of legacy PTY in use   将256改小  我此处改为64

    同样到上面处,在选 Serial drivers  ---> (4)   Maximum number of non-legacy 8250/16550 serial ports 可改tty

       无效
  7. u盘无法挂载?

    dmesg如下:
    starting pid 935, tty '': '/bin/sh'
    # Warning: could not register server
    usb 1-1.2: new full speed USB device using s3c2410-ohci and address 3
    usb 1-1.2: configuration #1 chosen from 1 choice
    scsi0 : SCSI emulation for USB Mass Storage devices
    usb 1-1.2: New USB device found, idVendor=0781, idProduct=5567
    usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
    usb 1-1.2: Product: Firebird USB Flash Drive
    usb 1-1.2: Manufacturer: SanDisk
    usb 1-1.2: SerialNumber: 4C532000051130122550
    QDir::readDirEntries: Cannot read the directory: /usr/lib/ipkg/externinfo
    scsi 0:0:0:0: Direct-Access     SanDisk  Cruzer Blade     1.26 PQ: 0 ANSI: 5
    sd 0:0:0:0: [sda] 15633408 512-byte hardware sectors: (8.00 GB/7.45 GiB)
    sd 0:0:0:0: [sda] Write Protect is off
    sd 0:0:0:0: [sda] Assuming drive cache: write through
    sd 0:0:0:0: [sda] 15633408 512-byte hardware sectors: (8.00 GB/7.45 GiB)
    sd 0:0:0:0: [sda] Write Protect is off
    sd 0:0:0:0: [sda] Assuming drive cache: write through
    sda:<7>usb-storage: queuecommand called
       sda1
    sd 0:0:0:0: [sda] Attached SCSI removable disk
    sd 0:0:0:0: Attached scsi generic sg0 type 0
    

    如下命令查询 # cat /proc/partitions major minor #blocks name 31 0 1024 mtdblock0 31 1 3840 mtdblock1 31 2 3072 mtdblock2 31 3 61440 mtdblock3 31 4 61440 mtdblock4 8 0 7816704 sda 8 1 7816688 sda1 # ls /dev/sda ls: /dev/sda: No such file or directory dev/下没有sda设备。。

    直接手动mknod 如下:
    # mknod /dev/sda b 8 0
    # mknod /dev/sda1 b 8 1
    # mount /dev/sda1 /mnt ok

    注:检查发现U盘的支持不仅要usb massive storage, scsi, msdos partition/ filesystem,还要加入对应文件系统的language编码支持(437) Default codepage for FAT --------------------------必须选中 Codepage 437 (United States,Canada)(iso8859-1) Default iocharset for FAT -------------------------必须选中 NLS ISO 8859-1 (Latin 1; Western European Languages
  8. 打开dev/fb0时老是出错,fd_fb = open("/dev/fb0", O_RDWR);返回-1

    /dev/fb0 结点存在,ls /dev/fb0 -l
    crw-rw---- 1 root video 29, 0 Apr 25 15:25 /dev/fb0
    todo:更改权限 chmod 666 /dev/fb0
    crw-rw-rw- 1 root video 29, 0 Apr 25 15:25 /dev/fb0
    打开时不再出错。权限问题,或者把当前账户加入VIDEO组别中,注销重登录也可
  9. VIDIOC_S_FMT failed (-1)

    运行V4L2编写的camera测试程序出现如下错误:
     Capability Informations:
            driver: uvcvideo
            card: USB2.0 PC Camera
            bus_info: usb-0000:02:03.0-1
            version: 3.5.7
            capabilities: 04000001
            VIDIOC_S_FMT failed (-1)
    
    在开发板上运行camera程序时总是出现VIDIOC_S_FMT failed (-1)错误,查看源码发现是在 ret = ioctl(fd, VIDIOC_S_FMT, &fmt);时出错,用源码在PC机上调试运行却没问题,可以通过此条语句,goolgle也没查到什么有用的信息。后来在PC机上调试时发现在有一个调试程序的情况下再对该程序重启一个进程调试也出现这个问题,怀疑出现这个问题的原因是video0设备被别的程序占用了,所以无法再次设置FMT,
    实验:杀断所有占用视频设备的程序或重启,在一个终端上运行正常,再开个终端运行时也出现相同情况,说明确实是因为被占用的原因。
    以这个思路在开发板上排除了USB CAMERA设备节点被占用后,依然无法设置FMT,偿试了下先获取设备支持的视频格式,以此设置OK了,同一个摄像头在PC上的格式是YUV但在开发板上获取却变成MJPG了,所以以PC机上的格式设置无法在开发板上运行,格式不同的根本原因应该是UVC驱动不同造成。
    检查了下源码发现退出时都没有close相应的设备文件,这样也会导致重新插拔USB摄像头时设备结点的次设备号增加变成video1,video2....videoN等。
  10. 在写图片保存文件时遇到错误,总是无法生成正解的BMP格式 ,查看产生的图片文件数据发现总是多了两个字节。

    对比相同大小和位色的图片发现在类型属性后面总是多出两字节,正常的BMP格式头部信息应该是14+40=54个字节,结果此处却是56,追查发现是
    sizeof(BITMAPFILEHEADER)=16 但

         typedef unsigned short int WORD;
         typedef unsigned long int DWORD;
         typedef long int LONG;
         /* Header of the bitmap file */
         typedef struct {
           WORD bfType;			
           DWORD bfSize;		
           WORD bfReserved1;	
           WORD bfReserved2;		
           DWORD bfOffBits;	
         } BITMAPFILEHEADER;

    读出sizeof(WORD)=2,sizeof(DWORD)=4   那此处 sizeof(BITMAPFILEHEADER)=14 才应该是对的,可无论怎样都是16
    MSDN:When applied to a structure type or variable, sizeof returns the actual size, which may include padding bytes inserted for alignment.
    多出来的是padding bytes,为了对齐出现的,如何解决?

    • 使用#pragma pack(n)来设定变量以n字节对齐方式 eg:
      <span style="color:#3333FF;">#pragma pack(push,1)</span>
      typedef struct {
      WORD bfType;
      DWORD bfSize;
      WORD bfReserved1;
      WORD bfReserved2;
      DWORD bfOffBits;
      } BITMAPFILEHEADER;
      <span style="color:#3333FF;">#pragma pack(pop)</span>
    • 使用__attribute__属性
      struct my_align_struct {
        uint32 u0:8;
        uint32 u1:8;
        uint32 u2:8;
        uint32 u3:16;
      }__attribute__((packed, aligned(1)))
  11. nfs挂载错误:wrong fs type, bad option, bad superblock

    anzyelay@ubuntu:~$ sudo mount -t nfs -o nolock,tcp 192.168.1.218:/home/anzyelay/ /mnt
    mount: wrong fs type, bad option, bad superblock on 192.168.1.218:/home/anzyelay/,
    missing codepage or helper program, or other error
    (for several filesystems (e.g. nfs, cifs) you might
    need a /sbin/mount.<type> helper program)

    In some cases useful info is found in syslog - try
    dmesg | tail or so.
    查看/sbin/mount.<type>文件,发现没有/sbin/mount.nfs的文件
    anzyelay@ubuntu:~$ ls /sbin/mount.*
    mount.exfat mount.fuse mount.ntfs
    mount.exfat-fuse mount.lowntfs-3g mount.ntfs-3g
    安装nfs-utils即可,使用命令apt-get install nfs-common  之后多出了几个文件
    anzyelay@ubuntu:~$ ls /sbin/mount*
    mountall mount.exfat-fuse mount.lowntfs-3gmount.nfs4 mount.ntfs-3g
    mount.exfat mount.fuse mount.nfs mount.ntfs 
    再次sudo mount -t nfs -o nolock,tcp 192.168.1.218:/home/anzyelay/ /mnt 就OK了。

  12. 'mount.nfs: Protocol not supported'

    nfs-common已经安装了,但依然出错如标题所示,增加-o项 vers=2,即sudo mount -t nfs -o nolock,tcp,vers=2192.168.1.218:/home/anzyelay/ /mnt    OK!

  13. Makefile:492: recipe for target 'menuconfig' failed ,Unable to find the ncurses libraries or the required header files.

    anzyelay@ubuntu:~/Templates/linux-3.0.1$ make menuconfig
    HOSTCC scripts/basic/fixdep
    HOSTCC scripts/kconfig/conf.o
    *** Unable to find the ncurses libraries or the
    *** required header files.
    *** 'make menuconfig' requires the ncurses libraries.
    ***
    *** Install ncurses (ncurses-devel) and try again.
    ***
    /home/anzyelay/Templates/linux-3.0.1/scripts/kconfig/Makefile:215: recipe for target 'scripts/kconfig/dochecklxdialog' failed
    make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1
    Makefile:492: recipe for target 'menuconfig' failed
    make: *** [menuconfig] Error 2

    缺少 ncurses libraries,安装就行,apt-get install libncurses5-dev
  14. make bzImage 时 fatal error: linux/compiler-gcc5.h: No such file or directory

      CHK     include/linux/version.h
      UPD     include/linux/version.h
      CHK     include/generated/utsrelease.h
      UPD     include/generated/utsrelease.h
      CC      kernel/bounds.s
    In file included from include/linux/compiler.h:48:0,
                     from include/linux/stddef.h:4,
                     from include/linux/posix_types.h:4,
                     from include/linux/types.h:17,
                     from include/linux/page-flags.h:8,
                     from kernel/bounds.c:9:
    include/linux/compiler-gcc.h:94:30: fatal error: linux/compiler-gcc5.h: No such file or directory
    compilation terminated.

    /home/anzyelay/Templates/linux-3.0.1/./Kbuild:35: recipe for target 'kernel/bounds.s' failed
    make[1]: *** [kernel/bounds.s] Error 1
    Makefile:985: recipe for target 'prepare0' failed
    make: *** [prepare0] Error 2

    当前GCC版本太高,查看gcc --version 为gcc-5,
    anzyelay@ubuntu:~$ gcc --version
    gcc (Ubuntu 5.2.1-22ubuntu2) 5.2.1 20151010
    Copyright (C) 2015 Free Software Foundation, Inc.
    This is free software; see the source for copying conditions.  There is NO
    warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


    而当前的linux-3.0.1内核源码中缺少compiler-gcc5.h的库,要么自己找到这些库放到内核库文件夹中,要么下个低版本GCC用(我下了个gcc-4.7的)。
    下载后查看如下:默认的gcc是使用gcc-5的(连接过去的),你可以更改连接以变改变gcc,或者改Makefile 中的 CC变量 (CC=gcc-4.7)
    anzyelay@ubuntu:~$ ls /usr/bin/gcc* -l
    lrwxrwxrwx 1 root root      5 Apr 29 09:46 /usr/bin/gcc -> gcc-5
    -rwxr-xr-x 1 root root 578808 Oct  3  2015 /usr/bin/gcc-4.7
    -rwxr-xr-x 1 root root 886968 Oct 17  2015 /usr/bin/gcc-5
    lrwxrwxrwx 1 root root      8 Apr 29 09:46 /usr/bin/gcc-ar -> gcc-ar-5
    -rwxr-xr-x 1 root root  22848 Oct  3  2015 /usr/bin/gcc-ar-4.7
    -rwxr-xr-x 1 root root  26976 Oct 17  2015 /usr/bin/gcc-ar-5
    lrwxrwxrwx 1 root root      8 Apr 29 09:46 /usr/bin/gcc-nm -> gcc-nm-5
    -rwxr-xr-x 1 root root  22848 Oct  3  2015 /usr/bin/gcc-nm-4.7
    -rwxr-xr-x 1 root root  26976 Oct 17  2015 /usr/bin/gcc-nm-5
    lrwxrwxrwx 1 root root     12 Apr 29 09:46 /usr/bin/gcc-ranlib -> gcc-ranlib-5
    -rwxr-xr-x 1 root root  22848 Oct  3  2015 /usr/bin/gcc-ranlib-4.7
    -rwxr-xr-x 1 root root  26976 Oct 17  2015 /usr/bin/gcc-ranlib-5

    再编译make bzImage  OK!

  15. Makefile:1607 *** mixed implicit and nomal rules:depracated syntax

    Makefile:1607行: *** 混和的隐含和普通规则。 停止,,此行显示:
    1607 / %/: prepare scripts FORCE
    1608 $(cmd_crmodverdir)
    1609 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
    1610 $(build)=$(build-dir)
    1607中的/  %/要分开写成:
    / : prepare scripts FORCE
    $(cmd_crmodverdir)
    $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
    $(build)=$(build-dir)
    %/: prepare scripts FORCE
    $(cmd_crmodverdir)
    $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
    $(build)=$(build-dir)
  16. yaffs2移植出错

    下载最新版源码git clonegit://www.aleph1.co.uk/yaffs2,打补丁,刚开始时打补丁用的命令是:

    ./patch-ker.sh c s  /root/linux-test/linux-2.6.32.2,后来出错建议我s 改用m,内核版本太低只能用m,改正好OK,之后配置编译时却出了一堆问题:

    fs/yaffs2/yaffs_vfs.c:66:26: error: yaffs_mtdif1.h: No such file or directory
    fs/yaffs2/yaffs_vfs.c:67:26: error: yaffs_mtdif2.h: No such file or directory
    fs/yaffs2/yaffs_vfs.c: In function 'yaffs_link':
    fs/yaffs2/yaffs_vfs.c:309: error: implicit declaration of function 'set_nlink'
    fs/yaffs2/yaffs_vfs.c: In function 'yaffs_setattr':

    处理方法,删除原来的yaffs2文件,重新打补丁./patch-ker.sh c m  /root/linux-test/linux-2.6.32.2,
    错误原因:第一次打补丁时用的s参数,后来虽然改了m,但先前的文件却是保留下来了。

  17. uvc驱动是正常的,在PC机上插入拔出USB camera会自动创建与删除设备结点,但到开发板上却只有在启动时插上才会自动创建/dev/video0,拔掉也不会知道删除?

    百度查询得知:要想自动创建设备结点,不仅要驱动中利用udev(mdev)来实现设备文件的自动创建,还要文件系统支持udev(mdev)才行,坑爹的飞凌板子里的文件系统不支持,所以一直不能自动创建 ,还以为是我UVC驱动移植错了。。对busybox配置加入mdev机制,编译自己的文件系统。

    经验证直接用飞凌现有的文件系统更改下 /linuxrc 文件重启后就可以了。
    #!/bin/sh
    #echo "mount /etc as ramfs"
    #/bin/mount -n -t ramfs ramfs /etc
    #/bin/cp -a /mnt/etc/* /etc

    #/bin/mount -n -t ramfs ramfs /var/state/dhcp
    #/bin/mount -n -t ramfs ramfs /var/log/boa
    #/bin/mount -n -t ramfs ramfs /usr/Setting
    #/bin/cp -a /mnt/Setting/* /usr/Setting

    #/bin/mount -n -t ramfs ramfs /tmp
    #/bin/cp -a /mnt/etc/* /etc

    /bin/mount -t proc proc /proc
    /bin/mount -t sysfs sysfs /sys
    /bin/mount -t tmpfs tmpfs /dev
    mkdir /dev/pts
    mkdir /dev/shm

    /bin/echo /sbin/mdev > /proc/sys/kernel/hotplug

    /sbin/mdev -s

    exec /sbin/init
    可参考:http://blog.csdn.net/geekcome/article/details/6570072

  18. need a /sbin/mount.<type> helper program)In some cases useful info is found in syslog - trydmesg | tail or so



你可能感兴趣的:(linux error note)