目前分類:Ralink SDK (77)

瀏覽方式: 標題列表 簡短摘要

在更新 uClibc 為新版後,突然發現 syslogd 完全沒作用了。在 trace busybox syslogd 後,完全沒結果。把 uClibc 的 syslog.c 換成舊版的也沒有用。最後就想說寫一個簡單的 syslog.c 試試,果然發現了問題所在。

syslog 是透過 socket(AF_UNIX, SOCK_DGRAM, 0) 來連接,而在 connect 時需要帶一個檔名,這個檔名要跟 busybox syslogd 所設定的檔名相同,否則就算資料傳送過去,syslogd 也不理你。

台南小新 發表在 痞客邦 留言(0) 人氣()

  • LAN MAC: MTD3(Factory) 0xE000
  • WAN MAC: MTD3(Factory) 0xE006
  • dd if=/dev/mtdblock3 of=/mnt/flash.bin
  • dd of=/dev/mtdblock3 if=/mnt/flash.bin
  • WAN_MAC_ADDR=98:2D:BA:50:0:1 <-- 改完 MAC 要清除,nvram_set WAN_MAC_ADDR。

台南小新 發表在 痞客邦 留言(0) 人氣()

Reference


台南小新 發表在 痞客邦 留言(0) 人氣()

  • uClibc: https://www.uclibc.org/
  • uClibc download: https://www.uclibc.org/downloads/
  • uClibc-ng: https://uclibc-ng.org/
  • uClibc-ng download: https://downloads.uclibc-ng.org/releases/

porting

diff -Nur uClibc-ng-1.0.30/Makefile uClibc-ng-1.0.30.new/Makefile
--- uClibc-ng-1.0.30/Makefile   2018-04-29 03:16:31.000000000 +0800
+++ uClibc-ng-1.0.30.new/Makefile       2018-10-12 14:50:13.441349190 +0800
@@ -17,3 +17,5 @@
 include $(top_srcdir)Makefile.in
 include $(top_srcdir)Makerules
 include $(top_srcdir)Makefile.help
+
+romfs:
diff -Nur uClibc-ng-1.0.30/Makefile.in uClibc-ng-1.0.30.new/Makefile.in
--- uClibc-ng-1.0.30/Makefile.in        2018-04-29 03:16:31.000000000 +0800
+++ uClibc-ng-1.0.30.new/Makefile.in    2018-10-12 14:50:13.497348486 +0800
@@ -13,7 +13,7 @@
 
 ifeq ($(HAVE_DOT_CONFIG),y)
 
-all: pregen libs startfiles
+all: pregen libs startfiles install_headers
 libs: pregen
 
 # In this section, we need .config
@@ -213,6 +213,15 @@
        install
 
 install: install_runtime install_dev
+romfs: install_runtime
+       ln -s -f /lib/libuClibc-1.0.30.so $(ROOTDIR)/romfs/lib/libresolv.so.0
+       ln -s -f /lib/libuClibc-1.0.30.so $(ROOTDIR)/romfs/lib/libnsl.so.0
+       ln -s -f /lib/libuClibc-1.0.30.so $(ROOTDIR)/romfs/lib/libpthread.so.0
+       ln -s -f /lib/libuClibc-1.0.30.so $(ROOTDIR)/romfs/lib/libm.so.0
+       ln -s -f /lib/libuClibc-1.0.30.so $(ROOTDIR)/romfs/lib/librt.so.0
+       ln -s -f /lib/libuClibc-1.0.30.so $(ROOTDIR)/romfs/lib/libdl.so.0
+       ln -s -f /lib/libuClibc-1.0.30.so $(ROOTDIR)/romfs/lib/libcrypt.so.0
+       ln -s -f /lib/libuClibc-1.0.30.so $(ROOTDIR)/romfs/lib/libutil.so.0
 
 
 RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=$(shell $(top_srcdir)extra/scripts/relative_path.sh $(DEVEL_PREFIX)$(MULTILIB_DIR) $(RUNTIME_PREFIX)$(MULTILIB_DIR))
@@ -355,6 +364,10 @@
 else
        $(Q)cd $(PREFIX)$(DEVEL_PREFIX)include && $(RM) -f wchar-stub.h
 endif
+# MTK/Ralink++
+$(PREFIX)$(DEVEL_PREFIX)include:
+       mkdir -p $(PREFIX)$(DEVEL_PREFIX)include
+# MTK/Ralink--
 
 EMPTY_LIB_NAMES = dl nsl resolv
 ifeq ($(DO_C99_MATH),y)
@@ -531,6 +544,11 @@
        @$(MAKE) -C utils CLEAN_utils
        $(Q)$(RM) $(top_builddir)extra/scripts/unifdef
        $(Q)$(RM) -r $(LOCAL_INSTALL_PATH)
+# MTK/Ralink++
+ifneq ($(DEVEL_PREFIX:%/=%),$(CURDIR))
+       $(RM) -rf $(PREFIX)$(DEVEL_PREFIX)
+endif
+# MTK/ralink --
 
 distclean: realclean
        -find . \( -name core -o -name \*.orig -o -name \*~ -o -name .\*.dep \) -exec $(RM) {} \;
diff -Nur uClibc-ng-1.0.30/Rules.mak uClibc-ng-1.0.30-new/Rules.mak
--- uClibc-ng-1.0.30/Rules.mak  2018-04-29 03:16:31.000000000 +0800
+++ uClibc-ng-1.0.30-new/Rules.mak      2018-10-13 15:28:33.058437789 +0800
@@ -96,7 +96,7 @@
 Kconfig := $(abspath $(top_srcdir)extra/Configs/Config.in)
 
 # Pull in the user's uClibc-ng configuration
-ifeq ($(filter $(noconfig_targets) clean CLEAN_%,$(MAKECMDGOALS)),)
+ifeq ($(filter $(noconfig_targets) CLEAN_%,$(MAKECMDGOALS)),)
 -include $(KCONFIG_CONFIG)
 endif
  • 加 install_headers 是為了把 include 拷貝給其它套件用。
  • romfs 加上 ln 是因為那些 .so 檔都併到 libuClibc-1.0.30.so 了,但不知道為啥還會呼叫舊的 .so。
  • MTK/Ralink 是拷貝原廠的,是為了建立 include 目錄及移除 include 目錄。
  • 在 Rules.mak 移除 clean,是為了在 make clean 時載入 .config,因為在移除 include 目錄時,需要 .config 變數。

Debug

  • busybox
    /opt/buildroot-gcc483_arm/usr/bin/arm-linux-gcc -Wp,-MD,miscutils/.time.o.d   -std=gnu99 -Iinclude -Ilibbb  -include include/autoconf.h -D_GNU_SOURCE -DNDEBUG  -D"BB_VER=KBUILD_STR(1.12.1)" -DBB_BT=AUTOCONF_TIMESTAMP -O2 -fomit-frame-pointer -pipe  -Dlinux -D__linux__ -Dunix -DEMBED -I/home/enos/workspace/fgn1300/source/uClibc-ng-1.0.30/app_headers/include -I/home/enos/workspace/fgn1300/source/lib/include -DCONFIG_UCLIBC_0_9_33_2 -mcpu=cortex-a7 -I/home/enos/workspace/fgn1300/source  -DLINUX_3_0_0 -DCONFIG_ARM -Wall -Wshadow -Wwrite-strings -Wundef -Wstrict-prototypes -Wunused -Wunused-parameter -Wmissing-prototypes -Wmissing-declarations -Wdeclaration-after-statement -Wold-style-definition -fno-builtin-strlen -finline-limit=0 -fomit-frame-pointer -ffunction-sections -fdata-sections -fno-guess-branch-probability -funsigned-char -static-libgcc -falign-functions=1 -falign-jumps=1 -falign-labels=1 -falign-loops=1 -Os -Dlinux -mcpu=cortex-a7   -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(time)"  -D"KBUILD_MODNAME=KBUILD_STR(time)" -c -o miscutils/time.o miscutils/time.c
    miscutils/time.c:17:16: error: field ‘ru’ has incomplete type
      struct rusage ru;
                    ^
    make[4]: *** [miscutils/time.o] Error 1
    make[3]: *** [miscutils] Error 2
    make[3]: Leaving directory `/home/enos/workspace/fgn1300/source/user/busybox'
    只要加上 sys/resource.h 就好了。
    diff --git a/source/user/busybox/include/libbb.h b/source/user/busybox/include/libbb.h
    old mode 100644
    new mode 100755
    index ba4e1f2..7cf307f
    --- a/source/user/busybox/include/libbb.h
    +++ b/source/user/busybox/include/libbb.h
    @@ -78,6 +78,7 @@
     #  include 
     # endif
     #endif
    +#include 
     
     /* Some libc's forget to declare these, do it ourself */
     extern char **environ;
  • dnsmasq
    /opt/buildroot-gcc483_arm/usr/bin/arm-linux-gcc -mcpu=cortex-a7 -O2 -fomit-frame-pointer -pipe  -Dlinux -D__linux__ -Dunix -DEMBED -I/home/enos/workspace/fgn1300/source/uClibc-ng-1.0.30/app_headers/include -I/home/enos/workspace/fgn1300/source/lib/include -DCONFIG_UCLIBC_0_9_33_2 -mcpu=cortex-a7 -I/home/enos/workspace/fgn1300/source  -O2 -D__uClinux__ -DNO_GETTEXT    -c -o forward.o forward.c
    In file included from /home/enos/workspace/fgn1300/source/uClibc-ng-1.0.30/app_headers/include/sys/socket.h:39:0,
                     from /home/enos/workspace/fgn1300/source/uClibc-ng-1.0.30/app_headers/include/netinet/in.h:24,
                     from dnsmasq.h:17,
                     from forward.c:13:
    forward.c: In function ‘send_from’:
    forward.c:40:37: error: invalid application of ‘sizeof’ to incomplete type ‘struct in6_pktinfo’
         char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
                                         ^
    /home/enos/workspace/fgn1300/source/uClibc-ng-1.0.30/app_headers/include/bits/socket.h:303:28: note: in definition of macro ‘CMSG_ALIGN’
     #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
                                ^
    forward.c:40:19: note: in expansion of macro ‘CMSG_SPACE’
         char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
                       ^
    forward.c:83:7: error: dereferencing pointer to incomplete type
        pkt->ipi6_ifindex = iface; /* Need iface for IPv6 to handle link-local addrs */
           ^
    forward.c:84:7: error: dereferencing pointer to incomplete type
        pkt->ipi6_addr = source->addr.addr6;
           ^
    In file included from /home/enos/workspace/fgn1300/source/uClibc-ng-1.0.30/app_headers/include/sys/socket.h:39:0,
                     from /home/enos/workspace/fgn1300/source/uClibc-ng-1.0.30/app_headers/include/netinet/in.h:24,
                     from dnsmasq.h:17,
                     from forward.c:13:
    forward.c:85:59: error: invalid application of ‘sizeof’ to incomplete type ‘struct in6_pktinfo’
        msg.msg_controllen = cmptr->cmsg_len = CMSG_LEN(sizeof(struct in6_pktinfo));
                                                               ^
    /home/enos/workspace/fgn1300/source/uClibc-ng-1.0.30/app_headers/include/bits/socket.h:307:66: note: in definition of macro ‘CMSG_LEN’
     #define CMSG_LEN(len)   (CMSG_ALIGN (sizeof (struct cmsghdr)) + (len))
                                                                      ^
    forward.c: In function ‘receive_query’:
    forward.c:530:37: error: invalid application of ‘sizeof’ to incomplete type ‘struct in6_pktinfo’
         char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
                                         ^
    /home/enos/workspace/fgn1300/source/uClibc-ng-1.0.30/app_headers/include/bits/socket.h:303:28: note: in definition of macro ‘CMSG_ALIGN’
     #define CMSG_ALIGN(len) (((len) + sizeof (size_t) - 1) \
                                ^
    forward.c:530:19: note: in expansion of macro ‘CMSG_SPACE’
         char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
                       ^
    forward.c:611:65: error: dereferencing pointer to incomplete type
       dst_addr.addr.addr6 = ((struct in6_pktinfo *)CMSG_DATA(cmptr))->ipi6_addr;
                                                                     ^
    forward.c:612:53: error: dereferencing pointer to incomplete type
       if_index =((struct in6_pktinfo *)CMSG_DATA(cmptr))->ipi6_ifindex;
                                                         ^
    make[4]: *** [forward.o] Error 1
    make[4]: Leaving directory `/home/enos/workspace/fgn1300/source/user/dnsmasq-2.40/src'
    只要加上 -D_GNU_SOURCE 就可以了。
    diff --git a/source/user/dnsmasq-2.40/src/Makefile b/source/user/dnsmasq-2.40/src/Makefile
    old mode 100644
    new mode 100755
    index 7b46fbc..222399f
    --- a/source/user/dnsmasq-2.40/src/Makefile
    +++ b/source/user/dnsmasq-2.40/src/Makefile
    @@ -3,7 +3,7 @@ OBJS = cache.o rfc1035.o util.o option.o forward.o isc.o network.o \
            dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
            helper.o tftp.o log.o
     
    -CFLAGS += -O2 -D__uClinux__ -DNO_GETTEXT #-DNO_IPV6
    +CFLAGS += -O2 -D__uClinux__ -DNO_GETTEXT -D_GNU_SOURCE #-DNO_IPV6
     
     all: $(NAME)

台南小新 發表在 痞客邦 留言(0) 人氣()

Bugs

adns.c:182:15: error: initializer element is not constant
 static struct __res_state *statp = &_res;
               ^
make[7]: *** [adns.o] Error 1
解決方式
--- src/pluto/adns.c.bak      2018-10-01 19:02:19.031260300 +0800
+++ src/pluto/adns.c    2018-10-01 19:05:04.656066781 +0800
@@ -179,7 +179,7 @@
        res_query(dname, class, type, answer, anslen)
 # define res_nclose(statp) res_close()
 
-static struct __res_state *statp = &_res;
+#define statp (&(_res))
 
 #else /* !OLD_RESOLVER */

台南小新 發表在 痞客邦 留言(0) 人氣()


台南小新 發表在 痞客邦 留言(0) 人氣()


台南小新 發表在 痞客邦 留言(0) 人氣()

  • vtysh -d bgpd
    只針對 bgpd 溝通
  • write terminal

台南小新 發表在 痞客邦 留言(0) 人氣()


台南小新 發表在 痞客邦 留言(0) 人氣()

  • official site: https://invisible-island.net/ncurses/
  • download: https://invisible-mirror.net/archives/ncurses/
  • AR=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-ar \
    CC=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-gcc \
    CXX=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-g++ \
    RANLIB=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-ranlib \
    STRIP=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-strip \
    ./configure --host=arm-linux --target=arm-linux --prefix=/usr \
            --enable-static=yes --enable-shared=no
  • make 完之後,.a 檔案都放在 lib 目錄。

台南小新 發表在 痞客邦 留言(0) 人氣()

  • Jul 24 Tue 2018 16:32
  • BGP4

路由策略

  • 訪問控制列表 (ACL, access-list, ipv6 access-list)
    访问控制列表详解
  • 前綴列表 (ip prefix-list, ipv6 prefix-list)

台南小新 發表在 痞客邦 留言(0) 人氣()

  • c-ares is a C library for asynchronous DNS requests (including name resolves)
  • official site: https://c-ares.haxx.se/
  • download: https://c-ares.haxx.se/download/
  • git: https://github.com/c-ares/c-ares.git
  • AR=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-ar \
    CC=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-gcc \
    CXX=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-g++ \
    RANLIB=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-ranlib \
    STRIP=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-strip \
    ./configure --host=arm-linux --target=arm-linux --prefix=/usr \
            --enable-static=yes --enable-shared=no --with-random=/dev/urandom

台南小新 發表在 痞客邦 留言(0) 人氣()

Build

  • AR=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-ar \
    CC=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-gcc \
    CXX=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-g++ \
    RANLIB=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-ranlib \
    STRIP=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-strip \
    CFLAGS=-I/home/enos/workspace \
    LDFLAGS="-L/home/enos/workspace/readline -L/home/enos/workspace/ncurses-6.1/lib" \
    CARES_CFLAGS=-I/home/enos/workspace/c-ares-1.14.0 \
    CARES_LIBS="-L/home/enos/workspace/c-ares-1.14.0/.libs -lcares" \
    ./configure --host=arm-linux --target=arm-linux --prefix=/usr \
            --disable-doc --enable-static=yes --enable-shared=no
  • make
  • DESTDIR=/tmp/quagga make install
  • rm -rf /tmp/quagga/usr/include
  • rm -rf /tmp/quagga/usr/lib
  • /tmp/quagga/
    └── usr
        ├── bin
        │   ├── arm-linux-bgp_btoa
        │   ├── arm-linux-test_igmpv3_join
        │   └── arm-linux-vtysh
        ├── etc
        │   ├── bgpd.conf.sample
        │   ├── bgpd.conf.sample2
        │   ├── isisd.conf.sample
        │   ├── ospf6d.conf.sample
        │   ├── ospfd.conf.sample
        │   ├── pimd.conf.sample
        │   ├── ripd.conf.sample
        │   ├── ripngd.conf.sample
        │   └── zebra.conf.sample
        └── sbin
            ├── arm-linux-bgpd
            ├── arm-linux-isisd
            ├── arm-linux-nhrpd
            ├── arm-linux-ospf6d
            ├── arm-linux-ospfclient
            ├── arm-linux-ospfd
            ├── arm-linux-pimd
            ├── arm-linux-ripd
            ├── arm-linux-ripngd
            ├── arm-linux-watchquagga
            └── arm-linux-zebra
  • 把 --target=arm-linux 移除就可以把開頭的 arm-linux- 移除。

Debug

$ ./configure --host=arm-linux --target=arm-linux --prefix=/usr
.....
.....
checking for tputs in -lcurses... no
checking for tputs in -lncurses... no
checking for main in -lreadline... no
configure: error: vtysh needs libreadline but was not found and usable on your system.

增加參數 --disable-vtysh 即可,或是安裝 libreadline。

$ ./configure --host=arm-linux --target=arm-linux --prefix=/usr
.....
.....
checking for netinet6/in6_var.h... no
checking for netinet6/nd6.h... no
checking for inet_ntop in -lc... yes
checking for inet_pton in -lc... yes
checking for crypt in -lcrypt... yes
checking for res_init in -lresolv... no
checking whether system has GNU regex... checking for regexec in -lc... yes
checking for CARES... no
configure: error: Package requirements (libcares) were not met:

No package 'libcares' found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables CARES_CFLAGS
and CARES_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.

安裝 libcares 並加上 CARES_CFLAGS 及 CARES_LIBS 指定位置,要使用絕對路徑,不可以用相對路徑,因為有的 Makefile 是放在子目錄。

台南小新 發表在 痞客邦 留言(0) 人氣()

產生金鑰

使用 ssh-keygen 產生所需的 rsa 4096 金鑰,使用空白密碼,會產生二個檔案 id_rsa 及 id_rsa.pub。

$ ssh-keygen -t rsa -b 4096 -f /tmp/id_rsa -N ""
Generating public/private rsa key pair.
Your identification has been saved in /tmp/id_rsa.
Your public key has been saved in /tmp/id_rsa.pub.
The key fingerprint is:
8f:46:11:eb:e0:84:9e:a9:5f:4f:0b:d7:1c:50:8d:b9 enos@enos-VirtualBox
The key's randomart image is:
+--[ RSA 4096]----+
|        . .+     |
|     .   +o .    |
|    . o +  .     |
|   . = o oE      |
|    + . S .      |
|   .   . = .     |
|  .   o = +      |
|   . . * .       |
|    .   o        |
+-----------------+

id_rsa.pub

接下來要把 id_rsa.pub 放到 ssh server 上。

  • ssh root@192.168.150.1

台南小新 發表在 痞客邦 留言(0) 人氣()

config file

  • nodetach: Don't detach from the controlling terminal. Without this option, if a serial device other than the terminal on the standard input is specified, pppd will fork to become a background process.

台南小新 發表在 痞客邦 留言(0) 人氣()


台南小新 發表在 痞客邦 留言(0) 人氣()

open file "/tmp/log"
fprint "This is a log\n"
close file
  • open file: 開啟一個檔案。
  • fprint: 輸出文字到檔案。
  • close file: 關閉檔案。

台南小新 發表在 痞客邦 留言(0) 人氣()

Makefile

--- usb-modeswitch-2.5.2-org/Makefile 2017-12-31 17:34:02.000000000 +0800
+++ usb-modeswitch-2.5.2/Makefile       2018-07-10 18:42:55.974599912 +0800
@@ -1,8 +1,8 @@
 PROG        = usb_modeswitch
 VERS        = 2.5.2
 CC          ?= gcc
-CFLAGS      += -Wall
-LIBS        = `pkg-config --libs --cflags libusb-1.0`
+CFLAGS      += -Wall -I$(ROOTDIR)/lib/libusb-1.0.0/libusb
+LIBS        = -lusb -lpthread -L$(ROOTDIR)/lib/libusb-1.0.0/
 RM          = /bin/rm -f
 OBJS        = usb_modeswitch.c
 PREFIX      = $(DESTDIR)/usr
@@ -27,7 +27,7 @@
        dispatcher-script dispatcher-shared dispatcher-static \
        install-script install-shared install-static
 
-all: script
+all: $(PROG)
 
 script: $(PROG) dispatcher-script
 
@@ -103,3 +103,6 @@
        $(RM) $(MANDIR)/usb_modeswitch.1
        $(RM) -R $(DESTDIR)/var/lib/usb_modeswitch
        $(RM) $(SYSDIR)/usb_modeswitch@.service
+romfs:
+       $(ROMFSINST) /bin/$(PROG)
  • CC 要指向 cross-compiler。
  • CFLAGS 要指向 libusb.h 的位置,libusb 要 1.0.0 以上。
  • LIBS 要指向 libusb.a 的位置,而且要加上 -lpthread 才不會有問題。
  • all 拿掉 script 只留 $(PROG),也就是不要 tcl 編譯的 usb_modeswitch_dispatcher,用不到。
  • 加上 romfs,只安裝 usb_modeswitch。

usb_modeswitch.c

--- usb-modeswitch-2.5.2-org/usb_modeswitch.c 2017-12-31 18:33:30.000000000 +0800
+++ usb-modeswitch-2.5.2usb_modeswitch.c        2018-07-10 18:09:26.516974857 +0800
@@ -510,8 +510,8 @@
 
        /* libusb initialization */
        if ((libusbError = libusb_init(&ctx)) != LIBUSB_SUCCESS) {
-               fprintf(stderr, "Error: Failed to initialize libusb. %s (%d)\n\n",
-                               libusb_error_name(libusbError), libusbError);
+               fprintf(stderr, "Error: Failed to initialize libusb. (%d)\n\n",
+                               libusbError);
                exit(1);
        }
  • libusb-1.0.0 沒有 libusb_error_name(),只是除錯訊息,移除就好了,沒有影響。

台南小新 發表在 痞客邦 留言(0) 人氣()

  • usbutils 0.87 以下使用 libusb-0.1.12,而且沒有 usbhid-dump,usbhid-dump 使用 libusb-1.0.0。
  • git clone https://github.com/gregkh/usbutils.git
  • cd usbutils
  • sudo apt-get install libtool
  • sudo apt-get install autoconf
  • autoreconf --install --symlink
  • LIBUSB_LIBS="-L../../lib/libusb-0.1.12 -lusb" \
    LIBUSB_CFLAGS=-I../../lib/libusb-0.1.12 \
    AR=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-ar \
    CC=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-gcc \
    CXX=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-g++ \
    RANLIB=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-ranlib \
    STRIP=/opt/buildroot-gcc483_arm/usr/bin/arm-linux-strip \
    ./configure --host=arm-linux --target=arm-linux --prefix=/usr --disable-zlib
  • mount -t devtmpfs none /dev

Reference


台南小新 發表在 痞客邦 留言(0) 人氣()

  • 插上 FS020U,辨識結果為 CD-ROM,而不是 USB Modem。
    [ 5578.340760] (3)[34:khubd]usb 1-1: ep 0x81 - rounding interval to 32768 microframes, ep desc says 0 microframes
    [ 5579.377146] (3)[30:kworker/3:1]scsi 0:0:0:0: CD-ROM            USBModem Disk             2.31 PQ: 0 ANSI: 2
    # lsusb
    1c9e:9bfe (bus 1, device 2)
    1d6b:0002 (bus 1, device 1)
    1d6b:0003 (bus 2, device 1)
    1d6b:0002 (bus 3, device 1)
  • 使用 usb_modeswitch 來轉換 USB type。usb_modeswitch -v 0x1c9e -p 0x9bfe -M 55534243123456780000000080000606f50402527600000000000000000000
    # usb_modeswitch -v 0x1c9e -p 0x9bfe -M 55534243123456780000000080000606f5040252
    7600000000000000000000
    Look for default devices ...
     Found devices in default mode (1)
    Access device 002 on bus 001
    Get the current device configuration ...
    Current configuration number is 1
    Use interface number 0
     with class 8
    Use endpoints 0x01 (out) and 0x81 (in)
    Looking for active drivers ...
     OK, driver detached
    Set up interface 0
    Use endpoint 0x01 for message sending ...
    Trying to send message 1 to endpoint 0x01 ...
     OK, message successfully sent
    Read the response to message 1 (CSW) ...
     Response successfully read (13 bytes), status 0
    Reset response endpoint 0x81
    Reset message endpoint 0x01
     Device is gone, skip any further commands
    -> Run lsusb to note any changes. Bye!
    
    # [ 6085.963225] (3)[34:khubd]usb 1-1: ep 0x81 - rounding interval to 32768 microframes, ep desc says 0 microframes
    [ 6085.973910] (3)[34:khubd]usb 1-1: ep 0x1 - rounding interval to 32768 microframes, ep desc says 0 microframes
    [ 6085.984161] (3)[34:khubd]usb 1-1: ep 0x82 - rounding interval to 32768 microframes, ep desc says 0 microframes
    [ 6085.994436] (3)[34:khubd]usb 1-1: ep 0x2 - rounding interval to 32768 microframes, ep desc says 0 microframes
    [ 6086.004523] (3)[34:khubd]usb 1-1: ep 0x84 - rounding interval to 32768 microframes, ep desc says 0 microframes
    [ 6086.014920] (3)[34:khubd]usb 1-1: ep 0x3 - rounding interval to 32768 microframes, ep desc says 0 microframes
    [ 6086.064168] (3)[34:khubd]
    [ 6086.064168]
    [ 6086.064168]Unsupported Device!
    [ 6086.064168]Vendor=1c9e ProdID=9b11
    [ 6086.064168]Manufacturer=USB Modem Product=USB Modem
    [ 6086.064168]
  • 由於 linux kernel 沒有內建 FS020U 的硬體識別碼,無法順利轉換成 USB Modem,所以需要手動把硬體識別碼寫入 usb-serial。echo 1c9e 9b11 > /sys/bus/usb-serial/drivers/option1/new_id
    echo 1c9e 9b11 > /sys/bus/usb-serial/drivers/option1/new_id
    # dmesg
    [ 6760.271729] (0)[12069:echo]option 1-1:1.0: usb_probe_interface
    [ 6760.271781] (0)[12069:echo]option 1-1:1.0: usb_probe_interface - got id
    [ 6760.271861] (0)[12069:echo]option 1-1:1.0: GSM modem (1-port) converter detected
    [ 6760.274054] (3)[12069:echo]usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
    [ 6760.274184] (3)[12069:echo]option 1-1:1.1: usb_probe_interface
    [ 6760.274237] (3)[12069:echo]option 1-1:1.1: usb_probe_interface - got id
    [ 6760.274319] (3)[12069:echo]option 1-1:1.1: GSM modem (1-port) converter detected
    [ 6760.276525] (3)[12069:echo]usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
    [ 6760.276634] (3)[12069:echo]option 1-1:1.2: usb_probe_interface
    [ 6760.276680] (3)[12069:echo]option 1-1:1.2: usb_probe_interface - got id
    [ 6760.276760] (3)[12069:echo]option 1-1:1.2: GSM modem (1-port) converter detected
    [ 6760.279454] (3)[12069:echo]usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
    [ 6760.279558] (3)[12069:echo]option 1-1:1.3: usb_probe_interface
    [ 6760.279609] (3)[12069:echo]option 1-1:1.3: usb_probe_interface - got id
    [ 6760.279693] (3)[12069:echo]option 1-1:1.3: GSM modem (1-port) converter detected
    [ 6760.283329] (3)[12069:echo]usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
    [ 6760.283455] (3)[12069:echo]option 1-1:1.4: usb_probe_interface
    [ 6760.283507] (3)[12069:echo]option 1-1:1.4: usb_probe_interface - got id
    [ 6760.283593] (3)[12069:echo]option 1-1:1.4: GSM modem (1-port) converter detected
    [ 6760.286507] (3)[12069:echo]usb 1-1: GSM modem (1-port) converter now attached to ttyUSB4
  • 或是把硬體識別碼寫入 linux kernel,修改 linux/drivers/usb/serial/option.c。
    static const struct usb_device_id option_ids[] = {
    { USB_DEVICE(LONGCHEER_VENDOR_ID, 0x9b11) },

台南小新 發表在 痞客邦 留言(0) 人氣()

1 234