mbed building

mbed

101940_Xnip_1171258.png

arduino的ARM版,API的封装和arduino的很相似,但是要比arduino更有野心。

如果arduino像个玩具,那mbed则像个精美的工业品。对arduino没有贬义,arduino影响了mbed、raspberry。

mbed的API有不少是用C++的封装的,可能吃资源(我没用过C++写过程序不知道)。

mbed也自带rtos,但是否好用留个大神评价吧(我没用过实时系统 — —!)

以下为mbed的美好愿景:

101919_O8N0_1171258.png

对mbed的分析文:

http://www.mbed.org.cn/archives/mbed-os%E4%BC%9A%E6%88%90%E4%B8%BA%E7%89%A9%E8%81%94%E7%BD%91%E7%9A%84-android-%E5%90%97%EF%BC%9F/



以下内容请大神自行绕路! 

mbed building

关于 mbed building 说明官网也有但是不太全,github上的说明文档讲得比较全面。

https://github.com/mbedmicro/mbed/blob/master/docs/BUILDING.md

  • 前提条件

  1. python2.7

    setuptools(https://pypi.python.org/pypi/setuptools

    pyserial(https://pypi.python.org/pypi/pyserial

    prettytable(https://pypi.python.org/pypi/PrettyTable

    intelHex(https://pypi.python.org/pypi/IntelHex

    jinja2(https://pypi.python.org/pypi/Jinja2

    markupsafe(安装jinja2的时候会附带安装)  

    colorama (https://pypi.python.org/pypi/colorama/)

  2. mbed SDK

    https://github.com/mbedmicro/mbed

  3. C/C++编译器(keil4 and IAR)

  


  • ‍‍‍building‍‍

 先使用github for windows(https://windows.github.com/ 只支持win7以上)下载mbed

(这样不用敲git的命令行)

114459_wH7J_1171258.jpg


  • pip

    pip install             安装第三方包

    pip uninstall         卸载第三方包

    pip freeze             按一定格式输出第三方包列表

    pip list                   查看已安装的第三方列表 

    pip show               显示第三方包所在的目录

    pip search             寻找在 PyPI  packages 上第三方包或者包含第三方包名字的文字描述

    pip wheel              不知道何用,没看懂— —!


  • 自动模式

       然后在mbed的根目录下有setup.py文件,它包含了所有依赖的第三方包的信息,

       调用它来自动完成所有依赖的第三方包的安装。

       python的第三方包默认放在  X:\XXX\python2.7.9\Lib\site-packages的目录下

       执行以下操作:

python setup.py install

      安装完成相应的效果:

   160431_5dhh_1171258.jpg

    其实还需要安装jinja2,project.py会用到。

    ---------



  • ‍‍手动模式  (我比较喜欢这种安装方式)

    首先查看一下 pip和setupstools是否需要更新

pip list --outdated

        更新 pip和setuptools      

pip install --upgrade pip
pip install --upgrade setuptools

       安装第三方包

pip install pyserial
pip install prettytable
pip install intelhex
pip install jinja2

      查看第三方包安装情况

175018_UzTa_1171258.png  



  • Configure workspace tools to work with your compilers

    需要在mbed/workspace_tools/下创建一个private_settings.py来配置路径来取代settings.py中默认的路径

from os.path import join
 
# ARMCC
armcc = "keil" # "keil", or "standalone", or "ds-5"
#ARM_PATH = "C:/Work/toolchains/ARMCompiler_5.03_117_Windows"
ARM_PATH = "E:/software/keil4/ARM/ARMCC"
ARM_BIN = join(ARM_PATH, "bin")
ARM_INC = join(ARM_PATH, "include")
ARM_LIB = join(ARM_PATH, "lib")
 
ARM_CPPLIB = join(ARM_LIB, "cpplib")
MY_ARM_CLIB = join(ARM_PATH, "lib", "microlib")
 
# GCC ARM
GCC_ARM_PATH = "C:/Work/toolchains/gcc_arm_4_8/4_8_2013q4/bin"
 
# GCC CodeSourcery
GCC_CS_PATH = "C:/Work/toolchains/Sourcery_CodeBench_Lite_for_ARM_EABI/bin"
 
# GCC CodeRed
GCC_CR_PATH = "C:/Work/toolchains/LPCXpresso_6.1.4_194/lpcxpresso/tools/bin"
 
# IAR
#IAR_PATH = "C:/Program Files (x86)/IAR Systems/Embedded Workbench 7.0/arm"
IAR_PATH = "E:/software/IAR/arm/bin/iccarm.exe"
 
SERVER_ADDRESS = "127.0.0.1"
LOCALHOST = "127.0.0.1"
 
# This is moved to separate JSON configuration file used by singletest.py
MUTs = {
}

  

  • ARM_PATH for armcc compiler.

  • GCC_ARM_PATH for GCC ARM compiler.

  • GCC_CS_PATH for GCC CodeSourcery compiler.

  • GCC_CR_PATH for GCC CodeRed compiler.

  • IAR_PATH for IAR compiler.


  • Build Mbed SDK library from sources

       从mbed源码包建立离线SDK库用于你的IDE

  • build.py script

C:\Users\sTAR>F:

F:\>cd F:\github\mbed\workspace_tools

F:\github\mbed\workspace_tools>python build.py -S -f NUCLEO_F103RB
+---------------+-----------+-----------+---------+--------+-----------+--------+------------+---------------+
| Platform      |    ARM    |  GCC_ARM  |   uARM  | GCC_CR |    IAR    | GCC_CS | GCC_CW_EWL | GCC_CW_NEWLIB |
+---------------+-----------+-----------+---------+--------+-----------+--------+------------+---------------+
| NUCLEO_F103RB | Supported | Supported | Default |   -    | Supported |   -    |     -      |       -       |
+---------------+-----------+-----------+---------+--------+-----------+--------+------------+---------------+
*Default - default on-line compiler
*Supported - supported off-line compiler

Total platforms: 1
Total permutations: 4

F:\github\mbed\workspace_tools>python build.py -m NUCLEO_F103RB -r
...


F:\github\mbed\workspace_tools>cd ..

F:\github\mbed>cd build

F:\github\mbed\build>tree
文件夹 PATH 列表
卷序列号为 00000200 C8D9:AEA6
F:.
├─mbed
│  ├─.temp
│  │  └─TARGET_NUCLEO_F103RB
│  │      ├─TOOLCHAIN_ARM_MICRO
│  │      │  └─TARGET_STM
│  │      │      └─TARGET_NUCLEO_F103RB
│  │      │          └─TOOLCHAIN_ARM_MICRO
│  │      ├─TOOLCHAIN_ARM_STD
│  │      │  └─TARGET_STM
│  │      │      └─TARGET_NUCLEO_F103RB
│  │      │          └─TOOLCHAIN_ARM_STD
│  │      ├─TOOLCHAIN_GCC_ARM
│  │      │  └─TARGET_STM
│  │      │      └─TARGET_NUCLEO_F103RB
│  │      │          └─TOOLCHAIN_GCC_ARM
│  │      └─TOOLCHAIN_IAR
│  │          ├─TARGET_STM
│  │          │  └─TARGET_NUCLEO_F103RB
│  │          │      └─TOOLCHAIN_IAR
│  │          └─TOOLCHAIN_IAR
│  └─TARGET_NUCLEO_F103RB
│      ├─TARGET_STM
│      │  └─TARGET_NUCLEO_F103RB
│      ├─TOOLCHAIN_ARM_MICRO
│      ├─TOOLCHAIN_ARM_STD
│      ├─TOOLCHAIN_GCC_ARM
│      └─TOOLCHAIN_IAR
└─rtos
    ├─.temp
    │  └─TARGET_NUCLEO_F103RB
    │      ├─TOOLCHAIN_ARM_MICRO
    │      │  └─TARGET_CORTEX_M
    │      │      └─TARGET_M3
    │      │          └─TOOLCHAIN_ARM
    │      └─TOOLCHAIN_ARM_STD
    │          └─TARGET_CORTEX_M
    │              └─TARGET_M3
    │                  └─TOOLCHAIN_ARM
    ├─TARGET_CORTEX_M
    └─TARGET_NUCLEO_F103RB
        ├─TOOLCHAIN_ARM_MICRO
        └─TOOLCHAIN_ARM_STD

F:\github\mbed\build>

        building完成后

  203853_6hPg_1171258.png


  • project.py script

        创建测试用例用于离线IDE

F:\github\mbed\workspace_tools>python project.py -L

[  0] MBED_A1: Basic
[  1] MBED_A2: Semihost file system
[  2] MBED_A3: C++ STL
[  3] MBED_A4: I2C TMP102
[  4] MBED_A5: DigitalIn DigitalOut
[  5] MBED_A6: DigitalInOut
[  6] MBED_A7: InterruptIn
[  7] MBED_A8: Analog
[  8] MBED_A9: Serial Echo at 115200
[  9] MBED_A10: PortOut PortIn
[ 10] MBED_A11: PortInOut
[ 11] MBED_A12: SD File System
[ 12] MBED_A13: I2C MMA7660 accelerometer
[ 13] MBED_A14: I2C Master
[ 14] MBED_A15: I2C Slave
[ 15] MBED_A16: SPI Master
[ 16] MBED_A17: SPI Slave
[ 17] MBED_A18: Interrupt vector relocation
[ 18] MBED_A19: I2C EEPROM read/write test
[ 19] MBED_A20: I2C master/slave test
[ 20] MBED_A21: Call function before main (mbed_main)
[ 21] MBED_A22: SPIFI for LPC4088 (test 1)
[ 22] MBED_A23: SPIFI for LPC4088 (test 2)
[ 23] MBED_A24: Serial echo with RTS/CTS flow control
[ 24] MBED_A25: I2C EEPROM line read/write test
[ 25] MBED_A26: AnalogIn potentiometer test
[ 26] MBED_A27: CAN loopback test
[ 27] MBED_BLINKY: Blinky
[ 28] MBED_BUS: Blinky BUS
[ 29] MBED_BUSOUT: BusOut
[ 30] BENCHMARK_1: Size (c environment)
[ 31] BENCHMARK_2: Size (float math)
[ 32] BENCHMARK_3: Size (printf)
[ 33] BENCHMARK_4: Size (mbed libs)
[ 34] BENCHMARK_5: Size (all)
[ 35] PERF_1: SD Stdio R/W Speed
[ 36] PERF_2: SD FileHandle R/W Speed
[ 37] PERF_3: SD FatFS R/W Speed
[ 38] MBED_1: I2C SRF08
[ 39] MBED_2: stdio
[ 40] MBED_3: PortOut
[ 41] MBED_4: Sleep
[ 42] MBED_5: PWM
[ 43] MBED_6: SW Reset
[ 44] MBED_7: stdio  benchmark
[ 45] MBED_8: SPI
[ 46] MBED_9: Sleep Timeout
[ 47] MBED_10: Hello World
[ 48] MBED_11: Ticker Int
[ 49] MBED_12: C++
[ 50] MBED_13: Heap & Stack
[ 51] MBED_14: Serial Interrupt
[ 52] MBED_15: RPC
[ 53] MBED_16: RTC
[ 54] MBED_17: Serial Interrupt 2
[ 55] MBED_18: Local FS Directory
[ 56] MBED_19: SD FS Directory
[ 57] MBED_20: InterruptIn 2
[ 58] MBED_21: freopen Stream
[ 59] MBED_22: Semihost
[ 60] MBED_23: Ticker Int us
[ 61] MBED_24: Timeout Int us
[ 62] MBED_25: Time us
[ 63] MBED_26: Integer constant division
[ 64] MBED_27: SPI ADXL345
[ 65] MBED_28: Interrupt chaining (InterruptManager)
[ 66] MBED_29: CAN network test
[ 67] MBED_30: CAN network test using interrupts
[ 68] MBED_31: PWM LED test
[ 69] MBED_32: Pin toggling
[ 70] MBED_33: C string operations
[ 71] MBED_34: Ticker Two callbacks
[ 72] MBED_35: SPI C12832 display
[ 73] MBED_36: WFI correct behavior
[ 74] MBED_37: Serial NC RX
[ 75] MBED_38: Serial NC TX
[ 76] CMSIS_RTOS_1: Basic
[ 77] CMSIS_RTOS_2: Mutex
[ 78] CMSIS_RTOS_3: Semaphore
[ 79] CMSIS_RTOS_4: Signals
[ 80] CMSIS_RTOS_5: Queue
[ 81] CMSIS_RTOS_6: Mail
[ 82] CMSIS_RTOS_7: Timer
[ 83] CMSIS_RTOS_8: ISR
[ 84] RTOS_1: Basic thread
[ 85] RTOS_2: Mutex resource lock
[ 86] RTOS_3: Semaphore resource lock
[ 87] RTOS_4: Signals messaging
[ 88] RTOS_5: Queue messaging
[ 89] RTOS_6: Mail messaging
[ 90] RTOS_7: Timer
[ 91] RTOS_8: ISR (Queue)
[ 92] RTOS_9: SD File write-read
[ 93] NET_1: TCP client hello world
[ 94] NET_2: NIST Internet Time Service
[ 95] NET_3: TCP echo server
[ 96] NET_4: TCP echo client
[ 97] NET_5: UDP echo server
[ 98] NET_6: UDP echo client
[ 99] NET_7: HTTP client hello world
[100] NET_8: NTP client
[101] NET_9: Multicast Send
[102] NET_10: Multicast Receive
[103] NET_11: Broadcast Send
[104] NET_12: Broadcast Receive
[105] NET_13: TCP client echo loop
[106] NET_14: UDP PHY/Data link layer
[107] UB_1: u-blox USB modem: HTTP client
[108] UB_2: u-blox USB modem: SMS test
[109] USB_1: Mouse
[110] USB_2: Keyboard
[111] USB_3: Mouse_Keyboard
[112] USB_4: Serial Port
[113] USB_5: Generic HID
[114] USB_6: MIDI
[115] USB_7: AUDIO
[116] CMSIS_DSP_1: FIR
[117] DSP_1: FIR
[118] KL25Z_1: LPTMR
[119] KL25Z_2: PIT
[120] KL25Z_3: TSI Touch Sensor
[121] KL25Z_4: RTC
[122] KL25Z_5: MMA8451Q accelerometer
[123] EXAMPLE_1: /dev/null
[124] EXAMPLE_2: FS + RTOS
[125] UT_1: Basic
[126] UT_2: Semihost file system
[127] UT_3: General tests
[128] UT_BUSIO: BusIn BusOut
[129] UT_I2C_EEPROM_ASYNCH: I2C Asynch eeprom
[130] UT_SERIAL_ASYNCH: Asynch serial test (req 2 serial peripherals)
[131] UT_SPI_ASYNCH: Asynch spi test
[132] UT_LP_TICKER: Low power ticker test
[133] DTCT_1: Simple detect test

F:\github\mbed\workspace_tools>

F:\github\mbed\workspace_tools>python project.py -m NUCLEO_F103RB -i iar -p 45
...
Copy: Ticker.cpp
Copy: Timeout.cpp
Copy: Timer.cpp
Copy: TimerEvent.cpp
Copy: stm32f10x.icf
Copy: main.cpp

Successful exports:
  * NUCLEO_F103RB::iar  F:\github\mbed\build\export\MBED_10_iar_NUCLEO_F103RB.zi
p


F:\github\mbed\build\export>tree
文件夹 PATH 列表
卷序列号为 00000200 C8D9:AEA6
F:.
└─MBED_A1
    ├─env
    └─mbed
        ├─api
        ├─common
        ├─hal
        └─targets
            ├─cmsis
            │  ├─TARGET_STM
            │  │  └─TARGET_NUCLEO_F103RB
            │  │      └─TOOLCHAIN_IAR
            │  └─TOOLCHAIN_IAR
            └─hal
                └─TARGET_STM
                    └─TARGET_NUCLEO_F103RB


  • PS 

      building过程中所犯的低级错误。。。



转载于:https://my.oschina.net/Jr413/blog/417419

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值