wiki:TipAndDoc/Linux/OpenWRT

Version 17 (modified by mitty, 12 years ago) (diff)

--

  • 注意: 非純正ファームウェアで無線を使うと(日本では)電波法違反になる可能性がある。
  • see also Hardware/WZR-HP-AG300H

OpenWRT

pppd

  • linkup時に /lib/netifd/ppp-up が実行される
    • /etc/ppp/ip-up と同じような使い方が可能?
    • Debian ppp-2.4.5/pppd/ipcp.c
          /*
           * Execute the ip-up script, like this:
           *  /etc/ppp/ip-up interface tty speed local-IP remote-IP
           */
      
    • 引数の具体例
      pppoe-wan eth1 0 114.159.68.126 118.23.8.36 wan
      
  • ONUの再起動(下記)などでpppdが終了してしまった場合、「/etc/init.d/network start」により全てのインタフェースがリセットされ再接続される
    Jun 12 15:57:35 starseed kern.info kernel: [   93.040000] eth1: link down
    Jun 12 15:57:39 starseed daemon.info pppd[1232]: No response to 5 echo-requests
    Jun 12 15:57:39 starseed daemon.notice pppd[1232]: Serial link appears to be disconnected.
    Jun 12 15:57:39 starseed daemon.info pppd[1232]: Connect time 1.1 minutes.
    Jun 12 15:57:39 starseed daemon.info pppd[1232]: Sent 27281 bytes, received 19359 bytes.
    Jun 12 15:57:40 starseed daemon.notice netifd: Interface 'wan' has lost the connection
    Jun 12 15:57:40 starseed daemon.notice pppd[1232]: Modem hangup
    Jun 12 15:57:40 starseed daemon.notice pppd[1232]: Connection terminated.
    
    (snip)
    
    Jun 12 15:58:30 starseed daemon.info pppd[4014]: CHAP authentication failed: permission denied
    Jun 12 15:58:30 starseed daemon.err pppd[4014]: CHAP authentication failed
    Jun 12 15:58:30 starseed daemon.notice pppd[4014]: Connection terminated.
    Jun 12 15:58:30 starseed daemon.info pppd[4014]: Exit.
    Jun 12 15:58:30 starseed daemon.notice netifd: Interface 'wan' is now down
    Jun 12 15:58:30 starseed kern.info kernel: [  148.030000] eth1: link down
    
    • 停電などに備えるには、cronなどでpppoeインタフェースの存在を監視するのが良いかも知れない

multiple PPPoE

cross complie

  • Ubuntu 12.04 LTS x86_64
  • mitty@precise:~$ sudo aptitude install subversion build-essential libncurses5-dev zlib1g-dev gawk gcc-multilib flex git-core gettext libssl-dev xsltproc bison
  • mitty@precise:~$ mkdir openwrt
  • mitty@precise:~/openwrt/trunk$ make prereq
    Collecting package info: done
    Collecting target info: done
    Checking 'working-make'... ok.
    Checking 'case-sensitive-fs'... ok.
    Checking 'getopt'... ok.
    Checking 'fileutils'... ok.
    Checking 'working-gcc'... ok.
    Checking 'working-g++'... ok.
    Checking 'ncurses'... ok.
    Checking 'zlib'... ok.
    Checking 'gawk'... ok.
    Checking 'flex'... ok.
    Checking 'unzip'... ok.
    Checking 'bzip2'... ok.
    Checking 'patch'... ok.
    Checking 'perl'... ok.
    Checking 'python'... ok.
    Checking 'wget'... ok.
    Checking 'git'... ok.
    Checking 'gnutar'... ok.
    Checking 'svn'... ok.
    Checking 'gnu-find'... ok.
    Checking 'getopt-extended'... ok.
    Checking 'non-root'... ok.
    
  • mitty@precise:~/openwrt/trunk$ make -j 5 V=99 2>&1 | tee build.log | grep -i error
    (snip)
    
    make[2]: [package/rootfs-prepare] Error 2 (ignored)
    Compression errors: 0
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wpe72.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    Compression errors: 0
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wp543.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    [mkmylofw] Error: file /home/mitty/openwrt/trunk/build_dir/linux-ar71xx_generic/tmp/vmlinux-wpe72.bin.lzma is too big
    make[5]: [install] Error 1 (ignored)
    make[3]: [/home/mitty/openwrt/trunk/bin/ar71xx/OpenWrt-ImageBuilder-ar71xx_generic-for-Linux-x86_64.tar.bz2] Error 1 (ignored)
    make[3]: [/home/mitty/openwrt/trunk/bin/ar71xx/OpenWrt-ImageBuilder-ar71xx_generic-for-Linux-x86_64.tar.bz2] Error 1 (ignored)
    
  • mitty@precise:~/openwrt$ cat > test.c
    #include <stdio.h>
    
    int main(void) {
            printf("char        -> %ld\n", sizeof(char));
            printf("short       -> %ld\n", sizeof(short));
            printf("int         -> %ld\n", sizeof(int));
            printf("long        -> %ld\n", sizeof(long));
            printf("long long   -> %ld\n", sizeof(long long));
            printf("float       -> %ld\n", sizeof(float));
            printf("double      -> %ld\n", sizeof(double));
            printf("long double -> %ld\n", sizeof(long double));
    
            return 0;
    }
    
  • mitty@precise:~/openwrt$ gcc test.c -o test.x86
  • mitty@precise:~/openwrt$ ./trunk/staging_dir/toolchain-mips_r2_gcc-4.6-linaro_uClibc-0.9.33.2/bin/mips-openwrt-linux-gcc test.c -o test
    mips-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
    mips-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
    mips-openwrt-linux-gcc: warning: environment variable 'STAGING_DIR' not defined
    
  • mitty@precise:~/openwrt$ file test test.x86
    test:     ELF 32-bit MSB executable, MIPS, MIPS32 rel2 version 1, dynamically linked (uses shared libs), with unknown capability 0x41000000 = 0xf676e75, with unknown capability 0x10000 = 0x70403, not stripped
    test.x86: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.24, BuildID[sha1]=0x53177842cbc614b1f4c71bae24df294892906443, not stripped
    
  • mitty@precise:~/openwrt$ ./test.x86
    char        -> 1
    short       -> 2
    int         -> 4
    long        -> 8
    long long   -> 8
    float       -> 4
    double      -> 8
    long double -> 16
    
  • mitty@precise:~/openwrt$ ./test
    bash: ./test: cannot execute binary file
    
  • mitty@starseed:~$ uname -a
    Linux starseed 3.3.6 #1 Thu May 17 02:19:20 PDT 2012 mips GNU/Linux
    
  • mitty@starseed:~$ ./test
    char        -> 1
    short       -> 2
    int         -> 4
    long        -> 4
    long long   -> 8
    float       -> 4
    double      -> 8
    long double -> 8
    

subversion

  • 2012/05/20現在、リポジトリからsubversionが消えている
  • backfire 10.03.1からパッケージを持ってこようとしたが、結局SEGVで動かなかった
  • root@OpenWrt:~# opkg update
  • root@OpenWrt:~# opkg install zlib libneon libaprutil
     * opkg_install_cmd: Cannot install package libaprutil.
    
  • root@OpenWrt:~# opkg install diffutils
    Installing diffutils (3.0-1) to root...
    Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/diffutils_3.0-1_ar71xx.ipk.
    Collected errors:
     * check_data_file_clashes: Package diffutils wants to install file /usr/bin/cmp
            But that file is already provided by package  * busybox
     * opkg_install_cmd: Cannot install package diffutils.
    
  • root@OpenWrt:~# opkg install diffutils --force-overwrite
    Installing diffutils (3.0-1) to root...
    Downloading http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages/diffutils_3.0-1_ar71xx.ipk.
    Configuring diffutils.
    
  • root@OpenWrt:~# cp -a /etc/opkg.conf /etc/opkg.conf.orig-20120520
  • root@OpenWrt:~# vim /etc/opkg.conf
    • /etc/opkg.conf

      old new  
      1 src/gz attitude_adjustment http://downloads.openwrt.org/snapshots/trunk/ar71xx/packages 
       1src/gz attitude_adjustment http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages/ 
      22dest root / 
      33dest ram /tmp 
      44lists_dir ext /var/opkg-lists 
  • root@OpenWrt:~# opkg update
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//Packages.gz.
    Inflating http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//Packages.gz.
    Updated list of available packages in /var/opkg-lists/attitude_adjustment.
    
  • root@OpenWrt:~# opkg install subversion-client
    Installing subversion-client (1.6.17-2) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//subversion-client_1.6.17-2_ar71xx.ipk.
    Installing libaprutil (1.3.12-2) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//libaprutil_1.3.12-2_ar71xx.ipk.
    Installing libapr (1.4.5-2) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//libapr_1.4.5-2_ar71xx.ipk.
    Installing libpthread (0.9.30.1-43.32) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//libpthread_0.9.30.1-43.32_ar71xx.ipk.
    Installing librt (0.9.30.1-43.32) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//librt_0.9.30.1-43.32_ar71xx.ipk.
    Installing libsqlite3 (3070701-1) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//libsqlite3_3070701-1_ar71xx.ipk.
    Installing libuuid (1.41.11-1) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//libuuid_1.41.11-1_ar71xx.ipk.
    Installing subversion-libs (1.6.17-2) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//subversion-libs_1.6.17-2_ar71xx.ipk.
    Configuring librt.
    Configuring libpthread.
    Configuring libapr.
    Configuring libsqlite3.
    Configuring libuuid.
    Configuring libaprutil.
    Configuring subversion-libs.
    Configuring subversion-client.
    
  • root@OpenWrt:~# svn
    svn: can't load library 'libssl.so.0.9.8'
    
  • root@OpenWrt:~# opkg remove libopenssl
    No packages removed.
    Collected errors:
     * print_dependents_warning: Package libopenssl is depended upon by packages:
     * print_dependents_warning:    libneon
     * print_dependents_warning: These might cease to work if package libopenssl is removed.
    
     * print_dependents_warning: Force removal of this package with --force-depends.
     * print_dependents_warning: Force removal of this package and its dependents
     * print_dependents_warning: with --force-removal-of-dependent-packages.
    
  • root@OpenWrt:~# opkg remove libopenssl --force-removal-of-dependent-packages
    Removing package subversion-client from root...
    Removing package subversion-libs from root...
    Removing package subversion-client from root...
    You can force removal of packages with failed prerm scripts with the option:
            --force-remove
    No packages removed.
    Collected errors:
     * pkg_run_script: Internal error: subversion-client has a NULL tmp_unpack_dir.
     * opkg_remove_pkg: not removing package "subversion-client", prerm script failed
    
  • root@OpenWrt:~# opkg remove libopenssl --force-removal-of-dependent-packages --f
    orce-remove
    Removing package libneon from root...
    Removing package libopenssl from root...
    
  • root@OpenWrt:~# opkg install libneon
    Installing libneon (0.29.6-2) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//libneon_0.29.6-2_ar71xx.ipk.
    Installing libopenssl (0.9.8r-1) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//libopenssl_0.9.8r-1_ar71xx.ipk.
    Configuring libopenssl.
    Configuring libneon.
    
  • root@OpenWrt:~# opkg install subversion-client
    Installing subversion-client (1.6.17-2) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//subversion-client_1.6.17-2_ar71xx.ipk.
    Installing subversion-libs (1.6.17-2) to root...
    Downloading http://downloads.openwrt.org/backfire/10.03.1/ar71xx/packages//subversion-libs_1.6.17-2_ar71xx.ipk.
    Configuring subversion-libs.
    Configuring subversion-client.
    
  • root@OpenWrt:~# svn
    Segmentation fault
    

DD-WRT