Veck Hsiao
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    1
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 成功大學資訊工程學系進階嵌入式系統課程 Week#3 Lab39 (macOS 環境版) ###### tags: `embedded` ## Developing Environment Note: 因為是一段時間以前就安裝好 STM32 porting environment 的,因此[Ubuntu 版本](http://embedded2015.hackpad.com/Week3-Lab39-ni3tzoIax7Y)前幾個步驟忘了有沒有),參考:http://wiki.csie.ncku.edu.tw/embedded/freertos#測試環境架設 之 `OS X 上安裝 gcc-arm-none-eabi、stlink、openocd` * 作業系統:macOS (OS X) 10.12.2 * 取得 GNU Toolchain: **gcc-arm-none-eabi** ```shell= $ brew tap PX4/homebrew-px4 $ brew update $ brew install gcc-arm-none-eabi # 使用:$ arm-none-eabi-gcc ``` **libenewlib-arm-none-eabi** `brew install libnewlib-arm-none-eabi` <hr> (2018-10-04) 如果發生:`No available formula with the name "libnewlib-arm-none-eabi"`,上網找不太到資料,試著直接 ./configure 這次重建環境沒辦法成功安裝 libnewlib-arm-none-eabi 後: ```shell= ↪ ./configure --disable-werror --enable-debug \ --target-list="arm-softmmu" \ --extra-cflags=-DSTM32_UART_NO_BAUD_DELAY \ --extra-cflags=-DSTM32_UART_ENABLE_OVERRUN \ --disable-gtk ERROR: glib-2.12 gthread-2.0 is required to compile QEMU > brew install glib ↪ ./configure --disable-werror --enable-debug \ --target-list="arm-softmmu" \ --extra-cflags=-DSTM32_UART_NO_BAUD_DELAY \ --extra-cflags=-DSTM32_UART_ENABLE_OVERRUN \ --disable-gtk ERROR: pixman not present. Your options: (1) Preferred: Install the pixman devel package (any recent distro should have packages as Xorg needs pixman too). (2) Fetch the pixman submodule, using: git submodule update --init pixman > git submodule update --init pixman ↪ ./configure --disable-werror --enable-debug \ --target-list="arm-softmmu" \ --extra-cflags=-DSTM32_UART_NO_BAUD_DELAY \ --extra-cflags=-DSTM32_UART_ENABLE_OVERRUN \ --disable-gtk ld: unknown option: --verbose Install prefix /usr/local BIOS directory /usr/local/share/qemu binary directory /usr/local/bin library directory /usr/local/lib module directory /usr/local/lib/qemu libexec directory /usr/local/libexec include directory /usr/local/include config directory /usr/local/etc local state directory /usr/local/var Manual directory /usr/local/share/man ELF interp prefix /usr/gnemul/qemu-%M Source path /Users/veckh/Desktop/workspace/qemu_stm32 C compiler cc Host C compiler cc C++ compiler c++ Objective-C compiler clang ARFLAGS rv CFLAGS -D_REENTRANT -I/usr/local/Cellar/glib/2.58.1/include/glib-2.0 -I/usr/local/Cellar/glib/2.58.1/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.42/include -g QEMU_CFLAGS -m64 -DOS_OBJECT_USE_OBJC=0 -arch x86_64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -Wstrict-prototypes -Wredundant-decls -Wall -Wundef -Wwrite-strings -Wmissing-prototypes -fno-strict-aliasing -fno-common -DSTM32_UART_ENABLE_OVERRUN -DSTM32_UART_NO_BAUD_DELAY -Wno-string-plus-int -Wno-initializer-overrides -Wendif-labels -Wmissing-include-dirs -Wempty-body -Wnested-externs -Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers -Wold-style-definition -Wtype-limits -fstack-protector-strong -I$(SRC_PATH)/pixman/pixman -I$(BUILD_DIR)/pixman/pixman -I$(SRC_PATH)/dtc/libfdt LDFLAGS -m64 -framework CoreFoundation -framework IOKit -arch x86_64 -g make make install install python python -B smbd /usr/sbin/smbd module support no host CPU x86_64 host big endian no target list arm-softmmu tcg debug enabled yes gprof enabled no sparse enabled no strip binaries no profiler no static build no Cocoa support yes pixman internal SDL support no GTK support no VTE support no curses support yes curl support yes mingw32 support no Audio drivers coreaudio Block whitelist (rw) Block whitelist (ro) VirtFS support no VNC support yes VNC TLS support no VNC SASL support yes VNC JPEG support no VNC PNG support no VNC WS support no xen support no brlapi support no bluez support no Documentation yes GUEST_BASE yes PIE no vde support no netmap support no Linux AIO support no ATTR/XATTR support no Install blobs yes KVM support no RDMA support no TCG interpreter no fdt support yes preadv support no fdatasync no madvise yes posix_madvise yes sigev_thread_id no uuid support yes libcap-ng support no vhost-net support no vhost-scsi support no Trace backends nop spice support no rbd support no xfsctl support no nss used no libusb no usb net redir no GLX support no libiscsi support no libnfs support no build guest agent yes QGA VSS support no seccomp support no coroutine backend sigaltstack coroutine pool yes GlusterFS support no virtio-blk-data-plane no gcov gcov gcov enabled no TPM support yes libssh2 support no TPM passthrough no QOM debugging yes vhdx yes Quorum no lzo support no snappy support no NUMA host support no ``` 之後繼續跑教學指令沒問題,但 warning 好像變多... <hr> ## STM32 in QEMU ``` >>> 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 >>> git submodule update --init dtc >>> ./configure --disable-werror --enable-debug \ --target-list="arm-softmmu" \ --extra-cflags=-DSTM32_UART_NO_BAUD_DELAY \ --extra-cflags=-DSTM32_UART_ENABLE_OVERRUN \ --disable-gtk >>> make >>> cd ../stm32_p103_demos >>> make all >>> make blink_flash_QEMURUN ``` 上述步驟成功畫面 ![](https://i.imgur.com/0abb3Eq.png) `make button_QEMURUN` ![](https://i.imgur.com/cyNANvY.png) 如果滑鼠點到 QEMU emulator 視窗,會進入視窗畫面而鎖定滑鼠,按 `command + alt` 可以 release ## FreeRTOS on STM32 ``` git clone https://github.com/fbukevin/freertos-basic.git cd freertos-basic make make qemu ``` ![](https://i.imgur.com/Wlz5B3O.png) * Discover: `前面階段中的 qemu emulator 敘述跑到 terminal 了` * Problem: `在 qemu emulator 中 keyboard 無法輸入` 原因是在 fio.c 中 fio_read function 的這一段: ```c if (fio_fds[fd].fdread) { r = fio_fds[fd].fdread(fio_fds[fd].opaque, buf, count); } else { r = -3; } ``` 其中的 fio_fds[fd].fdread() 沒有作用 in fio.h, we defined: ```c typedef ssize_t (*fdread_t)(void * opaque, void * buf, size_t count); ``` and we assign this poiter in fio.c in fio_init(): ```c fio_fds[0].fdread = stdin_read; ``` so that we know whenever we called like this: ```c r = fio_fds[fd].fdread(fio_fds[fd].opaque, buf, count); ``` it's equivalent to call: ```c r = fio_fds[fd].stdin_read(fio_fds[fd].opaque, buf, count); ``` and we can find the implementation of stdin_read() in fio.c: ```c static ssize_t stdin_read(void * opaque, void * buf, size_t count) { ... } ``` in stdin_read, we found inputs are completed by function recv_byte() which is defined in main.c: ```c char recv_byte() { USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); char msg; while(!xQueueReceive(serial_rx_queue, &msg, portMAX_DELAY)); return msg; } ``` after tracing to here, we found that function `xQueueReceive()` which is not in freertos-basic/src is the problem cause input disabled. * 另外一個可能是,當使用 make qemu,會出現: ``` (process:68826): GLib-WARNING **: gmem.c:482: custom memory allocation vtable not supported ``` 很有可能是這個造成的 * 還有一個可能,用 make qemudbg 發現在 main.c 的 init_rs232() 就有 error,可能是因為 rs232 的初始化失敗,而 rs232 是負責 I/O 的 ``` Error while running hook_stop: No symbol "disassembly" in current context. Reset_Handler () at freertos/libraries/CMSIS/CM3/DeviceSupport/ST/STM32F10x/startup/gcc_ride7/startup_stm32f10x_md.s:67 67 movs r1, #0 Breakpoint 1 at 0x1686: file src/main.c, line 162. Error while running hook_stop: No symbol "disassembly" in current context. Breakpoint 1, main () at src/main.c:162 162 init_rs232(); gdb$ ``` 目前實驗至此終止了!#

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully