kuroの覚え書き

96の個人的覚え書き

MAiX II DOCKをいじってみる

どうもこれに入っているLinuxはTina-LinuxといってOpenWRTに由来する組み込みLinuxらしいとの情報を得た。
Allwinner Tina Linux · GitHub
https://d1.docs.aw-ol.com/en/study/study_1tina/

OpenWRT懐かしい。2008年頃、FONという無線LANをみんなでシェアしようと言う趣旨のプロジェクトがあって、そこで安価で配布された無線LANルータのFoneraという装置があった。このFoneraの基板には意味ありげなピンヘッダが立っていて、それがシリアルコンソールであることに気がついた人たちのあいだで、そのコンソールからファームウェアを流し込んでもとの無線LANルータ機能を上書きしてしまうハックが流行った。そこで使われていたのがOpenWRTであった。基本無線LANルータとしてのファームウェアなんだけど、実態としては組み込みLinuxだということで、無線LANルータとしてではなく、安価なLinuxboxとして使ってしまおうというプロジェクトも派生していった。基板上のパターンを解析してSDカードを乗せるSPI接続を実現したり、シリアル通信でArduinoと接続してIOを制御したり、まさに現在、ラズベリーパイがやっているようなことを先駆けてやっていたのよね。当然GUIが動くほどの能力がルータのSOCにあるはずもなく、すべてCUI。多くのコマンドが入っているBusyBoxを駆使しまくってた。WebサーバとかSDカードを使ったファイル共有サーバとか温湿度計を繋いでエアコンリモート制御とか。

閑話休題

で、MAiX ll DOCKですよ。

BusyBox v1.27.2 () built-in shell (ash)

------run profile file-----
 _   .-')      ('-.            ) (`-.
( '.( OO )_   ( OO ).-.         ( OO ).
 ,--.   ,--.) / . --. /  ,-.-')(_/.  \_)-.
 |   `.'   |  | \-.  \   |  |OO)\  `.'  /
 |         |.-'-'  |  |  |  |  \ \     /\
 |  |'.'|  | \| |_.'  |  |  |(_/  \   \ |
 |  |   |  |  |  .-.  | ,|  |_.' .'    \_)
 |  |   |  |  |  | |  |(_|  |   /  .'.  \
 `--'   `--'  `--' `--'  `--'  '--'   '--'
   __   _
  / /  (_)__  __ ____ __ ------------------------
 / /__/ / _ \/ // /\ \ /  sipeed.com (Neptune)
/____/_/_//_/\_,_//_\_\  ------------------------

ほらBusyBoxじゃん。
ということでかつてのお約束のようにシリアルコンソール接続でログインを試みる。
その前にネットワークにつなぐ設定をしておく。SDカードをカードリーダーで覗くとトップディレクトリにWIFIの設定ファイル wpa_supplicant.conf があるので、SSIDとパスワードを入力しておく。
(追記)技適取れてないので無線接続はしてはいけません。日本語の情報が極端に少ないのはこのせいか。

USBでMacとつなぐと/dev/cu.usbserial-14330が現れるので

cu -l /dev/cu.usbserial-14330 -s 115200

としてやってMAiXをリセットすると

Last login: Fri May 17 13:58:12 on ttys002

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
------run rc.modules file-----
------run rc.final file-----
Load mpp modules
insmod: can't insert '/lib/modules/4.9.118/videobuf2-core.ko': No such file or directory
insmod: can't insert '/lib/modules/4.9.118/videobuf2-memops.ko': No such file or directory
insmod: can't insert '/lib/modules/4.9.118/videobuf2-v4l2.ko': No such file or directory
load /etc/asound.conf ...
alsactl: set_control:1461: Cannot write control '2:0:0:codec trigger playback time value:0' : Operation not permitted
alsactl: set_control:1461: Cannot write control '2:0:0:codec trigger capture time value:0' : Operation not permitted
exist /root/wpa_supplicant.conf
Starting app...
enable android usb
Initializing random number generator... done.
Starting network...
Start dropbear: OK
Starting ntpd: done


BusyBox v1.27.2 () built-in shell (ash)

------run profile file-----
 _   .-')      ('-.            ) (`-.
( '.( OO )_   ( OO ).-.         ( OO ).
 ,--.   ,--.) / . --. /  ,-.-')(_/.  \_)-.
 |   `.'   |  | \-.  \   |  |OO)\  `.'  /
 |         |.-'-'  |  |  |  |  \ \     /\
 |  |'.'|  | \| |_.'  |  |  |(_/  \   \ |
 |  |   |  |  |  .-.  | ,|  |_.' .'    \_)
 |  |   |  |  |  | |  |(_|  |   /  .'.  \
 `--'   `--'  `--' `--'  `--'  '--'   '--'
   __   _
  / /  (_)__  __ ____ __ ------------------------
 / /__/ / _ \/ // /\ \ /  sipeed.com (Neptune)
/____/_/_//_/\_,_//_\_\  ------------------------

root@sipeed:/# WARNING: Logging before InitGoogleLogging() is written to STDERR
I0522 03:02:09.853097   795 dup2SeldomUsedFd.c:20]          <dup2SeldomUsedFdInit> gFdLock init
Successfully initialized wpa_supplicant
udhcpc: started, v1.27.2
udhcpc: sending discover
I0522 03:02:10.799209   795 mpi_sys.c:766]                  <AW_MPI_SYS_SetConf> kfctmpdir is [/tmp]
I0522 03:02:10.800760   795 mpi_sys.c:1195]                 <AW_MPI_SYS_Init> ISP init
I0522 03:02:10.800925   795 mpi_sys.c:1197]                 <AW_MPI_SYS_Init> ISP init done
I0522 03:02:10.807874   795 hwdisplay.c:83]                 <hw_display_init> <(hwd_init 989)d_init:989> 95 hwdisplay.c:989] 
I0522 03:02:10.808255   795 hwdisplay.c:1044]               <hwd_init> <hwd_iniret[0][2,0]ch[2]lyl[0] init: enable[1], screenwin[0,0, 240x240], zorder[16], alpha[mode:0, value:255]
I0522 03:02:10.808458   795 alsa_interface.c:659]           <alsaOpenMixer> open mixer:hw:0
I0522 03:02:10.848054   795 alsa_interface.c:721]           <alsaOpenMixer> set player pa switch level 0
I0522 03:02:10.848312   795 alsa_interface.c:709]           <alsaOpenMixer> set playback vol_val to value: 27
E0522 03:02:10.969903   795 video_buffer_manager.c:211]     <VideoBufMgrCreate> Alloc 20 input frame buffers in list manager.
E0522 03:02:10.970302   795 VideoVirVi_Component.c:481]     <VideoViSetViDevAttr> fps 20 nbufs 3
E0522 03:02:11.001482   795 video_buffer_manager.c:211]     <VideoBufMgrCreate> Alloc 20 input frame buffers in list manager.
E0522 03:02:11.001873   795 VideoVirVi_Component.c:481]     <VideoViSetViDevAttr> fps 20 nbufs 3
I0522 03:02:11.002887   795 hwdisplay.c:1244]               <hwd_get_disp_type>Current the  disp_type:0x1  tv_mode:0x0
I0522 03:02:11.003194   795 hwdisplay.c:1117]               <hwd_layer_request_hlay:0, zorder=0, cnt:2t_hlay:1117> 
I0522 03:02:11.003396   795 mpi_vo.c:1030]                  <AW_MPI_VO_SetVideoLayerAttr> ch[0]lyl[0]:dispRect changed, [0, 0, 320x240]->[0, 0, 240x240]
I0522 03:02:11.003574   795 hwdisplay.c:408]                <hwd_layer_set_rectch[0]lyl[0]: screen_win[0,0, 240x240]
E0522 03:02:11.004062   795 vo.c:683]                       <vo_init> debuf create vo channel[0] success!
I0522 03:02:11.004436   896 Clock_Component.c:1109]         <Clock_ComponentThread> ClockComp state[0x1]->Idle!
E0522 03:02:11.004617   795 vo.c:718]                       <vo_init> debuf create clock channel[0] success!
I0522 03:02:11.004777   896 cedarx_avs_counter.c:148]       <avscounter_start> (f:avscounter_start, l:148) Avscounter status [pause]->[run], pauseDuration[0][0]ms
I0522 03:02:11.004956   795 hwdisplay.c:1117]               <hwd_layer_request_hlay:9, zorder=9, cnt:3t_hlay:1117> 
I0522 03:02:11.005098   795 mpi_vo.c:1030]                  <AW_MPI_VO_SetVideoLayerAttr> ch[2]lyl[1]:dispRect changed, [0, 0, 320x240]->[0, 0, 240x240]
I0522 03:02:11.005194   795 hwdisplay.c:408]                <hwd_layer_set_rectch[2]lyl[1]: screen_win[0,0, 240x240]
I0522 03:02:11.005291   795 mpi_vo.c:1130]                  <AW_MPI_VO_SetVideoLayerAlpha> video layer alpha changed, [0, 128]->[0, 25]
E0522 03:02:11.006791   795 vo.c:454]                       <CreateVoUiLayer> create vo channel[0] success!
udhcpc: sending discover
before paHostApiInitializers[0].
ALSA version (build): 1.1.4.1
ALSA version (runtime): 1.1.4.1
BuildDeviceList: Ignoring ALSA plugin device [cards] of type [unknown]
BuildDeviceList: Found plugin [default] of type [unknown]
BuildDeviceList: Found plugin [sysdefault] of type [unknown]
BuildDeviceList: Found plugin [front] of type [unknown]
BuildDeviceList: Found plugin [rear] of type [unknown]
BuildDeviceList: Found plugin [center_lfe] of type [unknown]
BuildDeviceList: Found plugin [side] of type [unknown]
BuildDeviceList: Found plugin [surround21] of type [unknown]
BuildDeviceList: Found plugin [surround40] of type [unknown]
BuildDeviceList: Found plugin [surround41] of type [unknown]
BuildDeviceList: Found plugin [surround50] of type [unknown]
BuildDeviceList: Found plugin [surround51] of type [unknown]
BuildDeviceList: Found plugin [surround71] of type [unknown]
BuildDeviceList: Found plugin [iec958] of type [unknown]
BuildDeviceList: Found plugin [spdif] of type [unknown]
BuildDeviceList: Found plugin [hdmi] of type [unknown]
BuildDeviceList: Found plugin [dmix] of type [unknown]
BuildDeviceList: Ignoring ALSA plugin device [dsnoop] of type [unknown]
BuildDeviceList: Found plugin [modem] of type [unknown]
BuildDeviceList: Found plugin [phoneline] of type [unknown]
BuildDeviceList: Ignoring ALSA plugin device [hw] of type [hw]
BuildDeviceList: Ignoring ALSA plugin device [plughw] of type [plug]
BuildDeviceList: Ignoring ALSA plugin device [plug] of type [plug]
BuildDeviceList: Ignoring ALSA plugin device [shm] of type [shm]
BuildDeviceList: Ignoring ALSA plugin device [tee] of type [file]
BuildDeviceList: Ignoring ALSA plugin device [file] of type [file]
BuildDeviceList: Ignoring ALSA plugin device [null] of type [null]
BuildDeviceList: Filling device info for 19 devices
FillInDevInfo: Filling device info for: sun8iw19-codec: - (hw:0,0)
GropeDevice: collecting info ..
GropeDevice: collecting info ..
Default input device: sun8iw19-codec: - (hw:0,0)
Default output device: sun8iw19-codec: - (hw:0,0)
FillInDevInfo: Adding device sun8iw19-codec: - (hw:0,0): 0
FillInDevInfo: Filling device info for: sysdefault
GropeDevice: collecting info ..
GropeDevice: Limiting number of plugin channels to 128
GropeDevice: collecting info ..
GropeDevice: Limiting number of plugin channels to 128
FillInDevInfo: Adding device sysdefault: 1
FillInDevInfo: Filling device info for: front
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.front
OpenPcm: Opened device 'front' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: front, all channels == 0
FillInDevInfo: Filling device info for: rear
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.rear
OpenPcm: Opened device 'rear' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: rear, all channels == 0
FillInDevInfo: Filling device info for: center_lfe
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.center_lfe
OpenPcm: Opened device 'center_lfe' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: center_lfe, all channels == 0
FillInDevInfo: Filling device info for: side
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.side
OpenPcm: Opened device 'side' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: side, all channels == 0
FillInDevInfo: Filling device info for: surround21
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
OpenPcm: Opened device 'surround21' ptr[0] - result: [-2:No such file or directory]
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround21
OpenPcm: Opened device 'surround21' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: surround21, all channels == 0
FillInDevInfo: Filling device info for: surround40
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround40
OpenPcm: Opened device 'surround40' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: surround40, all channels == 0
FillInDevInfo: Filling device info for: surround41
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround41
OpenPcm: Opened device 'surround41' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: surround41, all channels == 0
FillInDevInfo: Filling device info for: surround50
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround50
OpenPcm: Opened device 'surround50' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: surround50, all channels == 0
FillInDevInfo: Filling device info for: surround51
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround51
OpenPcm: Opened device 'surround51' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: surround51, all channels == 0
FillInDevInfo: Filling device info for: surround71
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.surround71
OpenPcm: Opened device 'surround71' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: surround71, all channels == 0
FillInDevInfo: Filling device info for: iec958
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
OpenPcm: Opened device 'iec958' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: iec958, all channels == 0
FillInDevInfo: Filling device info for: spdif
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
OpenPcm: Opened device 'spdif' ptr[0] - result: [-2:No such file or directory]
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.iec958
OpenPcm: Opened device 'spdif' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: spdif, all channels == 0
FillInDevInfo: Filling device info for: hdmi
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
OpenPcm: Opened device 'hdmi' ptr[0] - result: [-2:No such file or directory]
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.hdmi
OpenPcm: Opened device 'hdmi' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: hdmi, all channels == 0
FillInDevInfo: Filling device info for: modem
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
OpenPcm: Opened device 'modem' ptr[0] - result: [-2:No such file or directory]
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.modem
OpenPcm: Opened device 'modem' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: modem, all channels == 0
FillInDevInfo: Filling device info for: phoneline
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
OpenPcm: Opened device 'phoneline' ptr[0] - result: [-2:No such file or directory]
ALSA lib pcm.c:2501:(snd_pcm_open_noupdate) Unknown PCM cards.pcm.phoneline
OpenPcm: Opened device 'phoneline' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: phoneline, all channels == 0
FillInDevInfo: Filling device info for: default
GropeDevice: collecting info ..
GropeDevice: Limiting number of plugin channels to 128
GropeDevice: collecting info ..
GropeDevice: Limiting number of plugin channels to 128
Default input device: default
Default output device: default
FillInDevInfo: Adding device default: 2
FillInDevInfo: Filling device info for: dmix
ALSA lib pcm_direct.c:1421:(snd1_pcm_direct_initialize_poll_fd) unable to open timer 'hw:CLASS=3,SCLASS=0,CARD=0,DEV=0,SUBDEV=0'
ALSA lib pcm_dmix.c:1183:(snd_pcm_dmix_open) unable to initialize poll_fd
OpenPcm: Opened device 'dmix' ptr[0] - result: [-2:No such file or directory]
FillInDevInfo: Skipped device: dmix, all channels == 0
BuildDeviceList: Building device list took 0.692696 seconds
after paHostApiInitializers[0].
before paHostApiInitializers[1].
PaOSS BuildDeviceList: Total number of devices found: 0
after paHostApiInitializers[1].
PaAlsaStreamComponent_Initialize: Host Chans P 2
AlsaOpen: Opening device default
PaAlsaStreamComponent_InitialConfigure: device MMAP SND_PCM_ACCESS_MMAP_INTERLEAVED: YES
PaAlsaStreamComponent_InitialConfigure: device MMAP SND_PCM_ACCESS_MMAP_NONINTERLEAVED: YES
PaAlsaStreamComponent_InitialConfigure: device can MMAP: YES
PaAlsaStreamComponent_DetermineFramesPerBuffer: user-buffer (frames)           = 1024
PaAlsaStreamComponent_DetermineFramesPerBuffer: user-buffer (sec)              = 0.046440
PaAlsaStreamComponent_DetermineFramesPerBuffer: suggested latency (sec)        = 0.008707
PaAlsaStreamComponent_DetermineFramesPerBuffer: suggested host buffer (frames) = 2048
PaAlsaStreamComponent_DetermineFramesPerBuffer: suggested host buffer (sec)    = 0.092880
PaAlsaStreamComponent_DetermineFramesPerBuffer: periods min = 2, max = 512, req = 4 
PaAlsaStreamComponent_DetermineFramesPerBuffer: suggested host buffer period   = 1024 
PaAlsaStreamComponent_DetermineFramesPerBuffer: device period minimum          = 64
PaAlsaStreamComponent_DetermineFramesPerBuffer: device period maximum          = 16384
PaAlsaStreamComponent_DetermineFramesPerBuffer: host buffer period             = 1024
PaAlsaStreamComponent_DetermineFramesPerBuffer: host buffer period latency     = 0.046440
PaAlsaStream_Configure: Playback period size: 1024, latency: 0.046440
OpenStream: Stream: framesPerBuffer = 1024, maxFramesPerHostBuffer = 1024, latency i=0.000000, o=0.046440
I0522 03:02:15.532507   891 VideoVirVi_Component.c:360]     <DoVideoViReturnAllValidFrames> release [1]validFrames
I0522 03:02:15.532899   891 VideoVirVi_Component.c:1077]    <Vi_ComponentThread> wait using frame return done
W0522 03:02:15.543506   890 videoInputHw.c:4128]            <VideoInputHw_CapThread> VIPP[0], No Virvi Component, drop this one yuv data.
E0522 03:02:15.548595   795 video_buffer_manager.c:211]     <VideoBufMgrCreate> Alloc 20 input frame buffers in list manager.
E0522 03:02:15.548939   795 VideoVirVi_Component.c:481]     <VideoViSetViDevAttr> fps 20 nbufs 3
I0522 03:02:16.274793   897 video_render_linux.cpp:224]     <vr4l_init> mDisplayFormat[0x200], new CedarXNativeRenderer
I0522 03:02:16.275141   897 CedarXNativeRenderer.cpp:174]   <CedarXNativeRenderer> hwc disp fmt[0x80], color space:260
I0522 03:02:16.275300   897 hwdisplay.c:239]                <hwd_layer_set_src>x: 0, y: 0, width: 0xf0, height: 0xf0
I0522 03:02:16.275398   897 hwdisplay.c:246]                <hwd_layer_set_src>width: 0xf000000000, height: 0xf000000000
I0522 03:02:16.275480   897 hwdisplay.c:366]                <hwd_layer_set_src>set fb.format 128 0, color_space 260 end, size0[240x240], size1[0x0]
E0522 03:02:16.275611   897 vo.c:281]                       <VoUiCallbackWrapper> debuf vo report video display size[240x240]
I0522 03:02:16.275724   897 VideoRender_Component.c:2316]   <VideoRender_ComponentThread> init video_render, param: displayRect[0,0][240x240], bufSize[240x240], vdecColorFormat[0xb]
I0522 03:02:16.275821   897 mpi_vo.c:508]                   <VideoRenderEventHandler> KeyFrameDecoded, pts[0]us
E0522 03:02:16.276000   897 vo.c:286]                       <VoUiCallbackWrapper> debuf vo report rendering start
udhcpc: sending discover
udhcpc: sending select for 10.0.1.201
udhcpc: sending select for 10.0.1.201
udhcpc: lease of 10.0.1.201 obtained, lease time 172800
udhcpc: ifconfig wlan0 10.0.1.201 netmask 255.255.255.0 broadcast +
udhcpc: setting default routers: 10.0.1.1

root@sipeed:/#  ls
bin          home         overlay      rom          squashfs     usr
data         lib          proc         root         swapfile     var
dev          lost+found   pseudo_init  run          sys
etc          mnt          rdinit       sbin         tmp

これは普通にLinux boxとして使えそうだ。エッジAIとして使うかどうかはさておき。

追記
とりあえずできること
viでテキスト編集

できないこと
すでに入っている以外のアプリケーションのopkgでのインストール

とりあえずファイルの転送手段としてネットワーク越しは一旦おいておくことにしてまずUSBでの転送を考える。
このデバイスにはUSB-Cが2つついていて、1つを電源&シリアルコンソールとして使っている。もう1つのUSBはOTGということだが、そのままではPCからUSBデバイスとして認識されるモードとなっているため、これをUSBホストに変えてやる。

echo "usb_host" > /sys/devices/platform/soc/usbc0/otg_role

これでOK。
ひとまずSDカードをリーダに入れて接続してみる。
exFATはだめっぽい
FAT32なら

mount -t vfat /dev/sda1 ./media

であらかじめ作っておいたマウントポイント./mediaにマウントすることができた。
これで、とりあえずMacpythonコードを書いてMAiX IIに移して実行。ということは可能になった。アプリのインストールもできるかな。

しかし本格的に活用するなら、やはり無線LANに繋がないとどうにもならないだろうな。
一応無線LANチップ自体は技適が取れているようなので、
総務省 電波利用ホームページ|その他|技適未取得機器を用いた実験等の特例制度
こちらで申請すれば短期間なら試験できるようだけど、180日経ったら廃止申請を出すとか面倒すぎるので、やっぱり使い物にはならない。せめてUSB無線子機を繋いで使えるようにできればいいのだが、それもなかなかハードルが高い。