itagagaki’s blog

Itagaki's Software Development Blog

WOL (Wake On LAN) 設定

お出かけ先からWOL (Wake On LAN) で自宅PCを起動できるように設定したときにいろいろ引っ掛かったので、メモ書き。

構成は、

です。

ルーター PR-500KI の設定

失敗した設定

詳細設定 > 静的IPマスカレード設定 で、変換対象プロトコルUDP、変換対象ポートと宛先ポートをWOLで使用するポート番号、宛先IPアドレスを起動したいPCの静的IPアドレスに設定

これで一応はうまくいった。が、PCをシャットダウンしてから少し時間が経つと、もう起動できなくなった。

これは、時間が経つとルーター内のARPテーブルからそのPCが消えてしまうため、マジック・パケットに含まれるMACアドレスから宛先IPアドレスを割り出せなくなってしまう、ということらしい。

成功した設定

詳細設定 > 高度な設定 > [ WAN→LAN中継設定 ] を有効にする。 これで、設定したポート宛のWANからのマジック・パケットがLAN内にブロードキャストされるようになり、該当するMACアドレスNICを通じてPCを起動することができるようになる。

マザーボード ASROCK B560-HDVUEFIの設定

  • アドバンスト > ACPI 設定 > PCIE デバイス電源オン を 有効
  • アドバンスト > ACPI 設定 > I219 LAN 電源オン を 有効
  • アドバンスト > チップセット設定 > デイープスリープ を 無効

なお、

  • ブート > 内蔵 LAN からのブート

という一見それっぽい項目もあるが、これはWOLとは関係ない。

ネットワークアダプター(NIC) の設定

使用したのはオンボードNIC Intel(R) Ethernet Connection (14) I219-V です。

  • プロパティ > 詳細設定 > Wake from SOix on Magic Packet を 有効
  • プロパティ > 詳細設定 > Wake On Magic Packet を 有効
  • プロパティ > 詳細設定 > PME をオンにする を 有効

「PME をオンにする」が無効だと、シャットダウン時にNICの電源も切れてしまうようで、すると当然マジック・パケットに反応できず、WOLできない。

Windowsの設定

コントロールパネル > 電源オプション > システム設定 (電源ボタンの動作を選択する) で「現在利用可能ではない設定を変更します」をクリックし、シャットダウン設定の「高速スタートアップを有効にする」のチェックを外す。

有効にしているとWOLできないケースがあるようです。

[以上]

Discussion on the ability to set the startup folder in Mozilla Thunderbird

I think the main role of the "Manually sort folders" add-on for Mozilla Thunderbird has been moved to the core, but there is one more thing left to do.

It is to select a specific folder on startup.

I suppose there is a way to create a new add-on for this without modifying the core, but there is no guarantee that it will always work with a monkey patch. Maybe the WebExtension API would need to be extended, but it seems silly to do that just for this purpose. Then I came to the conclusion that it would be better to deal with this by changing the core.

I have started a discussion about this in the 'Thunderbird Developers' chat.

Progress in implementing core functionality for manually sorting folders in Thunderbird

Last month I submitted a patch to allow users to drag and drop folders to reorder them in the folder pane of Thunderbird 121.

It worked fine.

However, the Betterbird (a fork of Thunderbird) folks pointed out that there were performance issues with a huge number of folders. And then they added their own code to cache the new folder properties and made it available to us.

I tested it. And found another problem with their countermeasure. Upon investigation, it was due to a bug (technical debt) in Thunderbird's folder caching functionality.

The Betterbird folks have done a (band-aid) workaround for this problem, and have backported my patch to Betterbird 115 and released it (I have not confirmed this, but it appears so).

Meanwhile, the Thunderbird team is planning to fix the problem fundamentally. So my patch will be merged into mainstream Thunderbird after the problem is fixed.

So Thunderbird users will have to wait a few more weeks.

Zephyr ビルドと実行 おぼえがき

Zephyr はIntel発祥のRTOSです。

今回使用する環境は Windows 10 です。

Getting Started Guide — Zephyr Project Documentation を読んで、必要なものを揃えておきます。

Windows Terminalに「ZephyrBuild」というプロファイルを加えました。

{
    "commandline": "%SystemRoot%\\System32\\cmd.exe /k %HOME%\\zephyrproject\\.venv\\Scripts\\activate.bat",
    "name": "ZephyrBuild",
    "startingDirectory": "%HOME%\\zephyrproject",
    "tabTitle": "ZephyrBuild"
}

Zephyr ソースコードの更新

west update

サンプル「Blinky」のビルド

cd zephyr
west build -p always -b nucleo_f446ze samples\basic\blinky

nucleo_f446ze は私が使用しているボードの名前です。 サポートしているボードの名前はここで調べます。 Supported Boards — Zephyr Project Documentation

ビルドが成功したらボードに転送して実行してみます。

west flash

無事、LED 1 (LD1) が点滅しました。

次、点滅速度を変えてみます。 zephyr\samples\basic\blinky\src\main.c

#define SLEEP_TIME_MS   1000

#define SLEEP_TIME_MS   200

に書き換えて、再度ビルドして実行してみます。

無事、点滅の間隔が速くなりました。

次、デバッグしてみます。

west debug

ロード後、dgbのプロンプトが出ます。ソースコードを表示してみます。

list main.c:1

ちゃんと表示されました。そして無事にブレークポイントを設定したりステップ実行してみたりすることができました。

以上👍

(追記)

シェルはやっぱりcmdではやりにくいのでCygwin bashを使うことにします。

    "commandline": "C:\\cygwin64\\bin\\bash.exe --init-file .venv/Scripts/activate",

これでイケました。ただしシェルスクリプトファイル activate は改行コードがDosになっているためCygwin bashではそのままでは使えず、改行コードをUnixに直す必要がありました。

deactivate

も可能になっています。

STM32F446 Nucleo-144 でZephyrを動かしてみる

ZephyrというRTOSリポジトリのIssuesへのコントリビューションを始めることにしました。

Issues解決のためには、問題を実際に確認・把握し、コードを調査して原因、改善点、影響範囲などを分析し、修正を行い、テストを行って問題が解消したことを確認する必要があります。

そこでまずは、Zephyrを実際に動かすためのSoCボードを調達した。ZephyrはQEMU等でも動せるそうなんですが、現実のハードウェアで動かしてみるに越したことはありません。

様々なボードがある中で、お勧めを頂戴して STM32F446 Nucleo-144 を選びました。

STM32F446ZET6 144 PINS とあります。

さて、これからの作業に必要なことは、

  • PCでコードを書いたり修正したりする
  • PCでプログラムをビルドする
  • ボードに転送して動かす
  • リモートデバッガーでデバッグする

で、いろいろと検索して調べてみたところ、このボードに対してのビルドと実行には以下の方法があることがわかりました。

おそらくSTM32CubeIDEを使うのが、デバッグ等も含めた効率は良さそうな気がします。 しかし、残念ながら「STM32CubeIDEはZephyrを動かすようには作られていない」そうです。(How to use stm32cubeIDE to build and debug? · Issue #27559 · zephyrproject-rtos/zephyr) したがって、この選択肢は、残念ながら、はい消えた。

次に PlatformIO。これはとにかく試してみたら、あっけなくサンプルコードをビルド・転送して動かすことができました。そこにたどり着くまで、たぶん小一時間だったと思います。 しかも、一番時間がかかったのは、ボードへの転送がエラーになる原因を、あーでもないこーでもないと調べたこと。結局それはUSBケーブルが給電専用のものだったというオチでした。給電専用のUSBケーブルなんて滅んでほしい。そしてST-LINK USBドライバーを使うためにSTSW-LINK009をインストールしておく必要があります。

その後の手順は:

  1. PlatformIOのHomeで[Project Examples]をクリック
  2. [Zephyr-blink]を選んでインポート
  3. ワークスペースのplatformio.iniには4つの環境が記述されています。ぜんぶ要りません。代わりに自分の環境を書きます。私の場合は
[env:nucleo_f446ze]
platform = ststm32
framework = zephyr
board = nucleo_f446ze

です。

そしてBuildしてUploadします。これでボードのLD1が点滅します。 src/main.c の

#define SLEEP_TIME_MS 300

をいじって点滅速度を変えてみることができます。

さて、しかし、ビルドと転送と実行ができたのはいいけれど、問題はデバッギングです。 どうやらST-LINKという道具をボードに接続すればデバッグが可能になるっぽいですが、これ無しでなんとかならんのか?

もう一つ問題がありました。 そういえば、目的はZephyrのリポジトリのIssues解決だったわけですが、いまここで動いているZephyrは一体どこから来たのでしょう?? 探してみたら、%HOMEPATH%\.platformio\packages\framework-zephyrに一式がありました。 (環境はWindows 10です)。 しかしリポジトリのmainブランチの内容と比較してみると、リビジョンが違っているようでした。 ということは、つまり、この仕組みのままではZephyr自身の開発はできないということになります。 何か別のやり方もあるのかもしれませんが、このPlatformIOも残念ながら今回はちょっと使えないかなぁ。

そして最後に、Zephyrのwestというツールで開発する方法。 もうこれしか無さそうです。 Developing with Zephyr — Zephyr Project Documentationを読み込んで説明のとおりにやってみたら、これも小一時間でできました。 具体的には samples/basic/blinky をビルドして動かしてみることができました。 そして試しに west debug を実行してみたらgdbが起動したのでデバッグもできそうな雰囲気です。

続く、かな?

Plan to modify the Thunderbird Supernova's folder pane

How can we freely sort the order of folders in Mozilla Thunderbird? For a while, this was possible with the popular "Manually sort folders" add-on. However, in Thunderbird 115 the add-on no longer works because of the redesigned folder UI. And even in the new "Supernova" UI, the ability to sort folders is still not implemented.

I was involved in the development of "Manually sort folders" for Thunderbird 78 and later as a collaborator. So, as an option, I have considered developing "Manually sort folders" for Thunderbird 115. This may not be impossible. But here I would consider implementing the ability to sort folders properly in Thunderbird.

I started by examining the source code for the new Thunderbird. Apparently the folder pane is var folderPane. The code is in about3Pane.js. And folderPane.handleEvent() looks like this:

  handleEvent(event) {
    switch (event.type) {
      case "select":
        this._onSelect(event);
        break;
      case "contextmenu":
        this._onContextMenu(event);
        break;
      case "collapsed":
        this._onCollapsed(event);
        break;
      case "expanded":
        this._onExpanded(event);
        break;
      case "dragstart":
        this._onDragStart(event);
        break;
      case "dragover":
        this._onDragOver(event);
        break;
      case "dragleave":
        this._clearDropTarget(event);
        break;
      case "drop":
        this._onDrop(event);
        break;
    }
  }

It would be good to modify handling dragstart, dragover, dragleave, and drop a bit. Currently, it is possible to move a folder as a child into the target where we drag and drop. This would be done by these handlers. Probably the only status is in drag or not. The first step is to add the following additional states to the state in drag.

  • Move into the target as a child
  • Move to the point before the target as a sibling
  • Move to the point after the target as a sibling

The above three states may be determined by the relative position of the Y-coordinate of the mouse pointer on the target when dragging. (Not sure if there is a way to get that yet.)

And we need display materials that make the above three states visible.

Once the above is done, the next step is to actually insert the folder into the dropped location.

And the order of the folders sorted in this UI must be stored somewhere.

And it must be replicated next time. The current process of alphabetical sorting needs to be stopped.

Help from someone familiar with the current architecture may be required to ensure that the folder order can be stored and reproduced without contradiction.