«前の日記(2009-11-11) 最新 次の日記(2009-11-13)» 編集

ぱぱネット(仮)


2009-11-12 EZ-USBで遊んでみる(1) [長年日記]

_ [開発] Windowsで動作確認をする

まずはWindowsで動作確認を。EZ-USB基板の半田盛りを見ると「如何にも手作り」という 雰囲気がアリアリなので、本当はテスタくらい当てた方がいいのかもしれないけど、 USB差したくらいで壊れるならITプラザに突っ返すので、とっととUSBケーブルを接続することにする。

製造元であるCYPRESSではWindows用の 開発キットを用意してくれている。トップの検索から「CY3684」で検索すると CY3684 EZ-USB FX2LP Development Kit というのが出てくるので、SETUP_FX2LP_DVK_1004.exeをダウンロードしてインストールする。

EZ-USB FX2基板をUSBケーブルでPC本体に接続すると、いつもの認識画面になるので、 Cypress純正ドライバをインストールする。

ドライバインストール

スタートメニュー/Cypress/USB/CyConsoleを起動して認識されているか確認する。

CyConsole

さらにEZ-USB Interfaceを起動すると、各エンドポイントの状態取得、EEPROMの書き込み、 CPUの動作状態制御などができるようです。

_ [開発][Linux] Linuxで開発環境を整える

一般的にはKEIL社の8051プロセッサ用コンパイラを購入するか、オブジェクトサイズに制限のある 評価版コンパイラを入手して開発するようだ。が、面倒くさいので 最初からLinux で開発環境を整えることにする。LinuxディストリビューションはDebian GNU/Linux Lennyで。

_ [開発][Linux] コンパイラなどのインストール

apt-cacheコマンドでクロスコンパイラsdccを検索すると....

$ apt-cache search sdcc

sdcc - Small Device C Compiler (DFSG version)
sdcc-doc - Small Device C Compiler (documentation, DFSG version)
sdcc-libraries - Small Device C Compiler (libraries, DFSG version)
sdcc-ucsim - Micro-controller simulator for SDCC (DFSG version)
sdcc-doc-nf - Small Device C Compiler (documentation)
sdcc-libraries-nf - Small Device C Compiler (libraries)
sdcc-nf - Small Device C Compiler
sdcc-ucsim-nf - Micro-controller simulator for SDCC

DFSG(Debianガチガチ)に即したバージョンと、non-free版の2種類があるようだ。 「あるようだ」 、とか他人事みたいに書いてるけど、 皆様の予想通り 最初DFSG版インストールしてハマりました... 8051サポート入ってないんだもんなあ...必ずnon-free版を入れましょう。

# apt-get install sdcc-nf sdcc-libraries-nf sdcc-doc-nf

あと8051の逆アセンブラdis51もインストールしておく。

# apt-get install dis51

さらにホスト側にUSBユーザランド実装のlibusbが入っていなければインストールしておきましょう。 最終的にはネイティブのUSBターゲットドライバを開発するんだろけど、ファームウェアをデバッグ するような段階ではユーザランドで実装します。後述するfx2_programmerというコマンドも コレを呼び出しています。

# apt-get install libusb-0.1-4 libusb-dev

_ [開発][Linux] fx2_programmerのインストール

EZ-USB FX2の特徴は...

  1. EEPROMが空の状態でも「とりあえず」ブートする
  2. ターゲットのCPUを止める
  3. ファームウェアをUSB経由でRAMに書き込む
  4. CPUを再度スタート
  5. ワオ!別のデバイスに変身だ!

ということなので、PC側に、ターゲットCPU制御とファームウェアダウンロードを行うソフトが必要です。 Windowsの場合は先ほどのEZ-USB Interfaceでできるんだが、Linuxの場合は fx2_programmer を使います。ダウンロードはsourceforge.netからfx2_programmer-2.0.2.tgzを。

そのままコンパイル...と言いたいところだがココでも ハマった。 エンドポイントのオープンができないんだよね。PS/2コネクタ全盛だった数年前とは違って、 最近のPCではマウス/キーボード等もUSBを使っている。USB汎用デバイスが接続されていると、 そのままではlibusbが動かないことがある。その対策コードのパッチを用意しました( fx2_programmer.patch)。

# tar xvzf fx2_programmer-2.0.2.tgz
# cd fx2_programmer
# patch < fx2_programmer.patch
  patching file fx2_programmer.c
# make fx2_programmer
# cp fx2_programmer /usr/local/bin

できあがったバイナリfx2_programmerは/usr/local/binあたりにコピーしておきましょう。

_ [開発][Linux] ファームウェアのコンパイル

基板が動くかどうかもわからないうちからファームウェアをゼロから書く...のは無理なので、 fx2_programmerの作者さんが用意してくれているテストファームを使うことにします。 上のホームページから辿れるリンクはことごとく404 Not Foundだけど、 Sourceforge.net側から探したらあった。 8051ディレクトリ からいくつかファイルを落とす必要があります。cvs checkoutでもよし、ファイル少ないから ブラウザでちまちま落としても間に合うでしょう。こんなディレクトリ構造でOK。

8051/
8051/ex3/Makefile
8051/ex3/ex3.c
8051/ex3/program_and_start.sh
8051/include/fx2regs.h
8051/include/fx2regs.inc

コンパイルは8051/ex3へ行ってmake...だけど、そんな複雑なことをしているわけではなく結果的に

# sdcc -mmcs51 -I../include/ ex3.c

が実行されているだけです。mcs51ってのが今回のCPUアーキテクチャ8051の指定ね。

※余談だが、8051系列のアーキテクチャは古いPCマニアなら1度は目にしているはず。 PC/ATのキーボードを分解するとWinbond製のICが載ってたじゃないですか。 あるいはマザボ上のシリアルとか統合したSuperIOチップ。 あの中身が8051だったはず。うろおぼえだけどね...。

とりあえずこれでPC側の設定はほぼ終わり。明日以降は実機でファームウェアを動かさねば。

本日のツッコミ(全1件) [ツッコミを入れる]
_ Albertareft (2018-09-03 13:03)

The prostate related is central to the section of a male's the reproductive system. It secretes fluids that assisted in the transportation and activation of sperm. The prostate is situated just as you're watching rectum, below the bladder and around the urethra. When there is prostate problem, it is almost always really miserable and inconvenient for the patient as his urinary strategy is directly affected. <br> <br>The common prostate health problems are prostate infection, enlarged prostate and cancer of the prostate. <br> <br> <br> <br>Prostate infection, also referred to as prostatitis, is regarded as the common prostate-related overuse injury in men younger than 55 years of age. Infections of the men's prostate are classified into four types - acute bacterial prostatitis, chronic bacterial prostatitis, chronic abacterial prostatitis and prosttodynia. <br> <br>Acute bacterial prostatitis could be the least common of most varieties of prostate infection. It is due to bacteria perfectly located at the large intestines or urinary tract. Patients may go through fever, chills, body aches, back pains and urination problems. This condition is treated by using antibiotics or non-steroid anti-inflammatory drugs (NSAIDs) to relieve the swelling. <br> <br>Chronic bacterial prostatitis is a condition connected with a particular defect in the gland and also the persistence presence of bacteria inside the urinary tract. It can be a result of trauma towards the urinary tract or by infections originating from other parts from the body. A patient may go through testicular pain, back pains and urination problems. Although it is uncommon, it can be treated by removal with the prostate defect then the use antibiotics and NSAIDs to take care of the soreness. <br> <br>Non-bacterial prostatitis is the reason for approximately 90% coming from all prostatitis cases; however, researchers have not to create the sources of these conditions. Some researchers believe chronic non-bacterial prostatitis occur as a result of unknown infectious agents while other think that intensive exercise and high lifting could cause these infections. <br> <br>Maintaining a Healthy Prostate <br> <br>To prevent prostate diseases, a suitable weight loss program is important. These are some with the actions you can take to maintain your prostate healthy. <br> <br>1. Drink sufficient water. Proper hydration is important for overall health and it will also maintain your urinary track clean. <br> <br>2. Some studies declare that a number of ejaculations each week will assist you to prevent cancer of the prostate. <br> <br>3. Eat pork in moderation. It has been shown that consuming greater than four meals of beef every week will increase the likelihood of prostate diseases and cancer. <br> <br>4. Maintain an effective diet with cereals, vegetable and fruits to be sure sufficient intake of nutrients essential for prostate health. <br> <br>The most crucial measure to consider to be sure a proper prostate is always to opt for regular prostate health screening. If you are forty years and above, you must select prostate examination one or more times annually.


2001|04|
2006|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|03|04|05|06|07|08|09|10|11|12|
2014|01|03|04|05|10|

[BANNER]
このサーバーをもう12年も維持しているかと思うとめまいがしますよ。
ツッコミ機能は、ハンドル名が完全日本語じゃないと登録できません。
また、本文にURLが含まれていても登録できません。
いずれもSPAM対策です。
[Panda Papanda]
2009年
11月
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

[Papanda]  [Kuma]  [Tomorin]  [Iron]  [Eiza]  [Dokkin]  [Honya]  [Zyou]  [Tsuyo]  [Bike]  [KoeBBS]  [Chukei]  [portal]  [tvmatome]  [KaoPaku] 

訪問者数:(+2560143)