分享到plurk 分享到twitter 分享到facebook

版本 7bffbd5754ffea8d9ba4937cb5e516bc6036c7f5

embedded/Lab19

Changes from 7bffbd5754ffea8d9ba4937cb5e516bc6036c7f5 to b2e8231021b35d541f9e769638653e23aa1a66bd

---
title: Lab1: QEMU Modeling
toc: no
...

預期目標
-------
- 體驗一個具體而微的 MCU 程式開發過程
- 藉由 QEMU 模擬環境,嘗試控制週邊 (STM32 USART) 並觀察其行為
- 以實驗點出日後課程的提綱

預先準備
-------
- 安裝 Ubuntu Linux,建議版本為 12.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