版本 20cbfed5c01f777de424d588b0b3568c963d8171
Changes from 20cbfed5c01f777de424d588b0b3568c963d8171 to 514d45f3de3c51fddb9d77ef04045a4a1aadb8a0
---
title: Lab19: QEMU Modeling
toc: no
...
預期目標
-------
- 體驗一個具體而微的 MCU 程式開發過程
- 藉由 QEMU 模擬環境,嘗試控制週邊 (STM32 USART) 並觀察其行為
- 以實驗點出日後課程的提綱
預先準備
-------
- 安裝 Ubuntu Linux,建議版本為 13.04
- 安裝必要的套件
.. code-block:: prettyprint
sudo apt-get install zlib1g-dev libsdl1.2-dev automake* autoconf* libtool libpixman-1-dev
- 若 Ubuntu 使用 **64bit 版本** ,請額外安裝 lib32gcc1 之套件
.. code-block:: prettyprint
sudo apt-get install lib32gcc1 lib32ncurses5
- 取得 GNU Toolchain: `toolchain-2012_03.tar.bz2</embedded/Lab1/toolchain-2012_03.tar.bz2>`_ 並解開到 /usr/local/csl/arm-2012.03 目錄,操作如下
.. code-block:: prettyprint
cd /
sudo tar jxvf toolchain-2012_03.tar.bz2
STM32 Overview
--------------
- Powerful but Cheap
- Wireless Connectivity
- Computing/Prototyping
- One for most use cases
- open source: http://code.google.com/hosting/search?q=label:STM32
.. image:: /STM32-P103-01.jpg
STM32 on QEMU 環境建立與測試
--------------------------
.. code-block:: prettyprint
mkdir -p workspace
cd workspace
git clone git://github.com/beckus/stm32_p103_demos.git
git clone git://github.com/beckus/qemu_stm32.git
cd qemu_stm32
./configure --disable-werror --enable-debug \
--target-list="arm-softmmu" \
--extra-cflags=-DDEBUG_CLKTREE \
--extra-cflags=-DDEBUG_STM32_RCC \
--extra-cflags=-DDEBUG_STM32_UART \
--extra-cflags=-DSTM32_UART_NO_BAUD_DELAY \
--extra-cflags=-DSTM32_UART_ENABLE_OVERRUN
make
cd ../stm32_p103_demos
export PATH=/usr/local/csl/arm-2012.03/bin:$PATH
make all
make blink_flash_QEMURUN
make button_QEMURUN
make uart_echo_QEMURUN
--------------------------------
小提醒
-----
- QEMU monitor 中按下 Ctrl-Alt-2 可切換到 serial0,即可作 UART 輸出/輸入測試,而按下 Ctrl-Alt-1 可切回 QEMU monitor
- 詳情可參閱 stm32_p103_demos 目錄的 README 檔案
- Ubuntu Linux 的「下載」目錄名稱就叫做「下載」,建議可建立 symbolic link 到 "Downloads" 目錄,如下:
- ln -s ~/下載 ~/Downloads
- 可在 ``~/.bashrc`` 加入 ``export PATH=/usr/local/csl/arm-2012.03/bin:$PATH``,即可設定 toolchain 路徑
參考資料
------------
- `STM32 Programming (中文)<stm32-prog.pdf>`_