デフォルトが 3.3V/8Mhz になるようですので要注意です。 この指定でもすんなり書き込めてしまうようですが、どんなプログラムを実行しても不明な USB デバイスになってしまう悲しい機械になってしまいます。(ちょっとはまりました…
また、Pro Micro に USB HID になるプログラムを書き込み、実行が始まると USB HID と COM ポートが OS に認識されますが、この際に COM ポートが書き込み時のものと異なるポートに配置され、次回のプログラム書き込みができなくなるケースがあるようです。 Windows であればデバイスマネージャから、どのように認識されたかを確認して、書き込みできない場合は COM ポートの設定を合わせてみてください。
特殊な操作として、起動中の Pro Micro の RST 端子を GND にちょいちょいと 2回落とすとリセットがかかり初期状態の COM ポートが 8秒間だけ現れる機能があります。
8MHz で設定してしまったなど、どうしても書き込みができなくなった場合は、コンパイルから書き込みに入ったあたりでリセットをかけ、出現した COM ポートめがけて Lチカなどを転送すると元に戻ってほっとします。 😀
てなわけで若干癖があるボードですが、無事セガサターンのバーチャスティックを USB 化することができました。
Looking at the Memory Card:
_________________
|_ _|_ _ _|_ _ _|
1 2 3 4 5 6 7 8
1. DATA - Pin 12 on Arduino
2. CMND - Pin 11 on Arduino
3. 7.6V - External 7.6V power (only required for 3rd party cards and knockoffs)
4. GND - GND Pin on Arduino
5. 3.6V - 5V pin with a voltage divider to 3.6V
6. ATT - Pin 10 on Arduino
7. CLK - Pin 13 on Arduino
8. ACK - Pin 2 on Arduino
MemcardRex は Windows 用 C#.NET のデスクトップクライアントですので、他の OS をお使いの方は MemCARDuino に付属の Python2 スクリプトを使うと良いと思います。( Linux で動作することを確認しました。機械の動作がおかしい場合のデバッグにも使えます)
ポケステの CPU は ARM7 だということで、本家 ARM さんのページから GNU Arm Toolchain をダウンロードします。 今回は Windows を使っていたので、 gcc-arm-none-eabi-7-2017-q4-major-win32.zip をダウンロードして展開します。
The GNU Embedded Toolchain for Arm is a ready-to-use, open source suite of tools for C, C++ and Assembly programming targeting Arm Cortex-M and Cortex-R family of processors.
This is my complete devkit for the PocketStation, I used it to make PKBIOSTool and the NyanCat. Full source and tools included ! Please give credits if you use it ! and drop me a mail if you make PocketStation stuff 🙂
psdevkit.zip を展開すると tools と Example がありますので、この手順では Example の中のプログラムをコンパイルして動作させてみたいと思います。
psdevkit Example のコンパイル
Example のコンパイルでは make コマンドを使っていますので、OS に導入されていない場合はインストールします。今回は Windows を使いましたので Windows 10 の bash on Windows(WLS)上の Ubuntu の make を使いました。(Cygwin でも良いと思います)
bash を起動し、試しに make と入力し “コマンドが見つかりません” なら表示された apt の手順で導入します。
次に、Makefile から呼び出される GNU Arm Toolchain の arm-none-eabi-gcc.exe などが入っている bin ディレクトリと、psdevkit 同梱の tools の mcpad.exe への PATH を bash に次のような感じで設定します。(相対パスで指定した例)
Windows 版の dfu-programmer で Arduino UNO の ATmega16U2 に書き込む方法をいつも忘れて調べてしまうので、メモです。
Arduino UNO などについている ATmega16U2 にカスタムファームを書き込んであげることで、Arduino を USB-MIDI や HID デバイスにすることができます。
Windows から書き込むには、dfu-programer の Windows 版ダウンロードしてを使うと簡単です。
dfu-programmer dfu-programmer is a multi-platform command-line programmer for Atmel (8051, AVR, XMEGA & AVR32) chips with a USB bootloader supporting ISP. Most Atmel devices having a USB port come pre-programmed with the bootloader, and this is a lightweight alternative to Atmel’s own FLIP/BatchISP program. This is a mostly Device Firmware Update (DFU) 1.0 compliant user-space application.
You can download the source distribution from the project files page. Windows users can download a pre-compiled executable, a set of USB drivers and the HTML help file in a separate zip file from the same page.
project files にコンパイル済みの dfu-programer.exe と USB デバイスドライバが同梱されたアーカイブファイルがあるので展開しておきます。
次に Arduino の次のジャンパーをショートさせたまま USB で PC に接続し、Arduino の電源ランプが点灯したらショートを解除します。(本来はドライバーなどでなくジャンパピンを使いましょう。。
ショートを解除すると Windows がデバイスドライバを検索しにいきますので、先ほど展開したアーカイブに同梱されている atmel_usb_dfu.inf を指定してあげると次のように ATmega16U2 がデバイスとして認識されます。