2015/11/24

Intel Edison; Clone/Copy by 'reboot ota' command

In previous post, I used flashall.sh/bat command to clone a reference image (or restore a backup image) to other Edison board.  If you want to use 'reboot ota' command, it requires some more tweaks.

# reboot ota

If reboot command is given a parameter ("ota"), the parameter is saved in U-Boot environment variable bootargs_mode. And U-Boot runs ota-update.scr at boot up. If you just replace edison-image-edison.ext4 file with a backup image, ota_update.scr fails because it has a hash value of the original ext4 file.

mkimage

If you modify ext4 file's hash value in ota_update.scr (you can edit it with a text editor), then U-Boot fails to load the scr because scr file's CRC check fails. Therefore ota_update.scr file needs to be regenerated with a backup ext4's hash value.

To generate ota_update.scr, it needs mkimage command that is included in U-Boot.
# git clone git://git.denx.de/u-boot.git
It needs not build everything, just needs tools.
make efi-x86_defconfig tools
mkimage tools will be in tools directory.

ota_update.scr

ota_update.scr is basically a script file. It just contains some binary codes at beginning. Strip that binary part off and save a script part into a file, say ota_update.cmd.
Then replace hash value with a reference image's one.
# Start update of edison-image-edison.ext4 on rootfs
setenv ota_image_name edison-image-edison.ext4
setenv u_part_lbl rootfs
setenv sha1_sum_ref cd19f77a22801b21129950a3d5506b55ceeb1888

The following commands generates ota_update.scr from ota_update.cmd.
# mkimage -a 0x10000 -T script -C none -n 'your description' -d ota_update.cmd ota_update.scr

Keep a reference ext4 file and ota_update.scr in pairs. In my case, I create a zip file, for example edison-20150101.zip, and it contains edison-image-edison.ext4 and ota_update.scr. Then I just need unzip a zip file into Edison removable drive and run reboot ota command to restore.

2015/11/21

Windows 10 Nov update; stuck at black screen.

In summary;

I have installed Windows 10 Nov update (Buld 10586 / Threshold 2) to Dell Inspiron 11 3147 a few days ago. It was working fine except Cygwin. And then it stuck at black screen after Dell logo before login screen at start up. To make it work again, I had to disable "Windows Driver Foundation - User-mode driver Framework" service.
The service sounds like important/necessary service, and so hopefully Microsoft fix it soon...

[Edit 22/Nov]
I was wondering why it was working fine a few days after update. And I found Windows Update "Cumulative Update for Windows 10 Version 1511 for x64-based Systems (KB3118754)" caused the problem. If KB3118754 is uninstalled, it works fine with the service enabled.
[/Edit]

[Edit 23/Nov]
It happened again. Disable the service seems to be better workaround.
[/Edit]

[Edit 25/Nov]
As in a comment, it needs just touch a screen, then Windows continues booting.
[/Edit]

Long story;

Soon after installed Windows 10 Nov update, I noticed that Cygwin stopped working on my Dell Inspiron 11 3147. But Windows was working fine other than that for a few days. When I got a time to investigate Cygwin problem, I rebooted the pc and it stuck at black screen before login screen. It won't go any further.

Get into safe mode

When it stuck at black screen, there was no mouse cursor. I pressed Windows+p to see external display settings, but nothing happened. I actually connected an external display but it only showed black screen too. And so I had to force shutdown it by pressing power button until LED turned on and then off again.
Because it won't boot into Windows, it needs an install media to boot into Safe mode. But I accidentally found the following way.

  • Press F12 to get into Boot options and launch Diagnostics.
  • Let it run a while just in case, but you can cancel it memory test.
  • Exit Diagnostics. (Then it automatically reboots.)
  • Somehow Windows detects a boot problem and you can get into advanced start-up screen.

Disable service

It seemed to be working okay in safe mode. So I guessed the problem was caused by a software. To find a cause, run msconfig.exe, open Services tab and enable services little by little. And finally I found that "Windows Driver Foundation - User-mode driver Framework" service caused the problem.

Clean install

It could be a problem of software combination/conflict and so I clean installed Windows 10 Nov update to confirm it. It installed without a problem, and worked fine for a while but the same problem happened after a few reboot. I did not install any additional software but applied Windows Updates.

So far so good

With the service disabled, I installed my everyday software (anti-virus, Cygwin, Chrome, VLC, Xkeymacs, etc.) and all work fine so far.

2015/11/15

Dell XPS L502Xのディスプレイ アップグレード

Dell XPS L502Xのスクリーンの調子が悪くなり、輝度にムラが出てきて、下部2cmくらいが常に白く表示されるようになってしまった。調べてみると、交換用のスクリーンを販売しているLaptop Screenというショップを見つけた。しかも、L502Xは15インチなのに1366x768という残念な解像度なのだけど、フルHDのスクリーンも売っている。
どうやらフルHDのモデルも販売されていたようで、物理的なサイズは全く同じで換装できるらしい。Dellのサポートページによると実際に換装した人もいて成功している。ただしスクリーンとマザーボードを繋ぐフラットケーブルも取り替える必要があるらしい。
必要なフラットケーブルの型番はV73D3といって、残念ながら上記のショップではこのケーブルを販売してなかった。でも、eBayで検索してみると簡単に見つかった。

ということで、注文して物が届いたので、さっそく換装してみた。手順はDellのサポートページからサービス マニュアルをダウンロードできるので、それを参照しながら進めた。

まずは、バッテリーを外して、モジュールカバーを外す。念の為、メモリも外しておいて、あとは無線LANのアンテナ ケーブルをカードから外しておく。











バッテリーを外すとネジと爪が見えるようになるので、そのネジ1本と二つの爪を外すと、パームレストカバー(トップカバー)が外れるようになる。電源ボタンのあたりからぐるっと全周外してから、手前に倒して、2本のフラットケーブルを外す。
そうすると、完全にパームレストを外すことができるようになる。







次はキーボード。まずは上辺にある2つの爪を外して、奥の方へ水平に少しだけスライドさせる。
すると、手前側が持ち上がるようになるので、ちょっと持ち上げて、小さいフラットケーブルを外す。
次に、大きなフラットケーブルを外す。








キーボードを外すと、ディスプレイケーブルが見える。
黒いタブが付いているので、それを引っぱってディスプレイ ケーブルを外す。
ネジも一本外す。












無線カードから外しておいたアンテナ線を引っぱって取り出して、ガイドからも順番に外していく。













スクリーンを本体に固定しているネジを4本外す。ネジを全部外しても、左の写真のように長い足が付いているので、突然倒れて外れたりはしないようになっている。











ベゼルを外す。上方向に無理矢理引っぱって外すのではなくて、ベゼルを水平方向の外側に引っぱりながら上に持ち上げると外れる。
左の写真は外した後の写真で、黒いベゼル側(下)と、灰色のカバー側(上)。










カメラモジュールのケーブルを外す。水平方向に引っぱると抜ける。













ネジを8本外すと (上部2本、下部6本)、パネルがカバーから外れる。1から8まで写真のように番号が振ってある。
パネルを外すだけなら、グリーンのネジは外す必要はない。(ちなみに、このネジを外すとヒンジが外れる。)









パネルからケーブルを外す。テープを剥して、水平方向に引っぱると抜ける。
他にも両面テープで貼り付けてあるので、ゆっくりと剥す。











 ケーブルの見た目は全く同じだけど、一方はV73D3。












別のラベルには、元の方は"HD"、新しい方は"FHD"と書いてあった。













ネジを4本外して、左右のフレームを外す。














後は、新しいパネルと取り替えて、逆の順序で取り付けていくだけ。

ちなみに元のパネルはSamsungのLTN156AT02。(恐らくDellのパーツナンバーは08MN61?)









今までは外部モニターをメインにして使っていて、ほぼデスクノート状態だったけれども、これで外部モニター無しでも色々と使える状態になった。

2015/11/11

Intel Edisonでタイムラプス撮影 その2

大体の下準備は済んだので、実際に撮影しながら色々と試してみた。

pkTriggerCord

--resolutionで解像度を変更しても、ダウンロードされるjpegファイルには反映されないバグがあると書かれているけれども、実際に試してみると保存されるjpegは指定した解像度になっている。
ただし、不思議なことにカメラからの転送にかかる時間は解像度に関わらず4秒ちょっとかかる。RAWで撮影するとサイズが大きくなるのでもっと時間がかかるけれども、jpegだと解像度/サイズに関わらず4秒ちょっとかかる。
ダウンロードした後にリサイズでもしているんだろうか? 最大解像度でも最低解像度でも同じ時間がかかるなら、最大解像度で残しておくに越したことはない。それに10秒毎に撮影するなら余裕だし、6秒毎に1時間くらい撮影してみたけれども常に4秒以上5秒未満だった。

ImageMagick (GraphicsMagick)

撮影画像を16:9のアスペクト比にクロップして、さらに1920x1080にリサイズすると、1枚処理するのに20秒くらいかかる。これでは撮影間隔に比べて時間がかかり過ぎる。ImageMagickから派生したGraphicsMagickは処理が早いということなので、試してみると少し短かくなって15秒くらいだった。できれば撮影間隔と同じか短かい時間に抑えたいので、15秒でも遅い。試しにリサイズをやめてクロップだけにしてみると、10秒くらいかかることが分った。
単純に先頭と後尾の部分を読み飛ばして16:9にクロップするプログラムを、libjpegを使ってCで書いてみたけど、IM/GMと同様に10秒くらいかかった。(同じライブラリを使用しているのだから、当然の結果か?) 何とかならないかなぁとlibjpegのマニュアルを読んでいたら、デコードの段階でスケール(scale_numとscale_denom)を変更すると非常に早くなると書いてあった。K20Dの最高解像度は4672x3104なので、1/2にしても1920x1080よりは大きい。そこで1/2のスケールでデコードしてみた。すると3秒まで縮んだ。

OpenCV

自作のクロップ プログラムが出力したファイルをImageMagickでリサイズしてもいいけれども、ファイルI/Oが増えることになるし、クロップと同時にリサイズもやってしまうことにした。OpenCVライブラリが既にパッケージになっていたので、opkgでインストールして利用した。リサイズにかかる時間は実行時間にほとんど影響がないくらい速く、リサイズのコードを追加した後でも3秒くらいのままだった。これなら撮影間隔未満なので十分と言える。
余談になるけれど、libjpegとOpenCVではメモリに展開したイメージデータの構造が同じなので、そのまま受け渡しができた。ただしRGBデータの順序が違っている。本来ならば、データを受け渡しする際に順序を揃えなければならないし、順序を変更するためのメソッドも用意されていた。けれども、リサイズだけなら色情報は関係ないんじゃないかと思い、順序の変更なしにリサイズ処理をしてみたら、予想通り問題無くリサイズできた。

inotify-tools

pkTriggerCordが撮影して保存が完了するのに合わせて、クロップ/リサイズ プログラムを走らせる必要がある。inotifywaitというコマンドがちょうどその用途に合っているのだけれども、Intel Edisonにはインストールされておらず、opkgにもなかった。
inotifyの仕組み自体はカーネルの機能らしいので、inotify-toolsをgitからcloneしてインストールしてみた。インストールは、
# ./autogen.sh
を実行するとconfigureが生成されるので、
# ./configure
を実行して、あとはmakemake installするだけ。
テストしてみたところ問題無く動いている。

これで、撮影しながら同時に画像変換もできるようになった。