============= QEMU Modeling ============= Prerquisites ------------ - 安裝 Ubuntu Linux,建議版本為 12.04 - sudo apt-get install zlib1g-dev libsdl1.2-dev - 若 Ubuntu 使用 **64bit 版本** ,請額外安裝 lib32gcc1 之套件 - sudo apt-get install lib32gcc1 - 取得 GNU Toolchain: `toolchain-2012_03.tar.bz2 `_ / `toolchain-2012_03.tar.bz2 `_ - 解開到 /usr/local/csl/arm-2012.03 目錄,操作如下 - cd / - sudo tar jxvf toolchain-2012_03.tar.bz2 - 取得檔案 `0001-Fix-build-due-to-old-APIs.patch `_ (右鍵另存新檔) 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 - http://0xlab.org/~jserv/tmp/CM-STM32.pdf .. image:: /STM32-P103-01.jpg STM32 on QEMU 環境建立與測試 -------------------------- .. code-block:: prettyprint git clone git://github.com/beckus/stm32_p103_demos.git git clone git://github.com/beckus/SandboxQemu2.git qemu_stm32 cd qemu_stm32 git am 0001-Fix-build-due-to-old-APIs.patch ./configure --disable-werror --enable-debug \ --enable-debug-tcg \ --target-list="arm-softmmu" \ --extra-cflags=-DDEBUG_CLKTREE \ --extra-cflags=-DDEBUG_STM32_UART \ --extra-cflags=-DSTM32_UART_NO_BAUD_DELAY \ --extra-cflags=-DSTM32_UART_ENABLE_OVERRUN make cd ../stm32_p103_demos git checkout -b final origin/final export PATH=/usr/local/csl/arm-2012.03/bin:$PATH make all make blink_flash_QEMURUN make button_QEMURUN make uart_echo_QEMURUN -------------------------------- 作業要求 ------- - 設計 STM32 的程式,使得在按下 Button 時,於 UART 輸出 "Hello!" - STM32 的程式須能與使用者互動,允許透過 UART 下指令控制週邊的狀態,至少要控制 LED 與查詢 Button 的狀態 (如按下的次數) - (加分) 使用 Software interrupt 作業提示 ------- - 可直接修改在現有目錄下 (如 button/ 或 blink_flash/ 等等) 的 main.c 檔案,然後打包壓縮後寄送即可 - 若 makefile 內容有修改,請一併附上 - 避開使用 putc(), printf() 一類的函式,畢竟標準 I/O 函式在嵌入式環境不見得完整支援 - 避開使用 sprintf() 一類需要作特別格式處理的函式,因為很可能在給定的環境中,沒有充分的支援 - 同名的 header file,如 "stm32f10x_conf.h",很可能在不同目錄有不的內容,從而會定義不同的 function - 不同程式的 makefile 的編譯方式不同,請留意。以下是 uart_echo 的編譯條件: .. code-block:: prettyprint demos/uart_echo/main.elf: demos/uart_echo/main.c demos/uart_echo/main.elf: $(STD_PERIPH_SRC)/stm32f10x_rcc.c demos/uart_echo/main.elf: $(STD_PERIPH_SRC)/stm32f10x_gpio.c demos/uart_echo/main.elf: $(STD_PERIPH_SRC)/stm32f10x_usart.c demos/uart_echo/main.elf: $(SYS_FILES) $(CC) $(CFLAGS_LINK) -Idemos/uart_echo/ -o $@ $^ -------------------------------- 繳交作業 ------- - 寄件到 - 標題: "[HW1]" 開頭,後面加學號與姓名 - 內文是測試方法,包含自訂指令,如 "info led" 與 "info button" 的預期結果 - 可以的話,附上一份自介 小提醒 ----- - QEMU monitor 中按下 Ctrl-Alt-2 可切換到 serial0,即可作 UART 輸出/輸入測試,而按下 Ctrl-Alt-1 可切回 QEMU monitor - 詳情可參閱 stm32_p103_demos 目錄的 README 檔案 - Ubuntu Linux 的「下載」目錄名稱就叫做「下載」,建議可建立 symbolic link 到 "Downloads" 目錄,如下: - ln -s ~/下載 ~/Downloads