你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

RTOS超低功耗平台应用---使用TraceAlyzer

[复制链接]
BinWin 发布时间:2018-4-21 00:31
本帖最后由 wangdbff 于 2018-4-21 00:34 编辑
& P4 [' C# ^. x* `
* n; Z* D7 }" m+ G     了解了一下TraceAlyzer,其实是一个OS时序分析软件.不过强大的功能却要收费,这里看到有FreeRTOS使用的免费版本,下载来看看。2 [+ }/ L+ |6 V1 u9 a
     需要填写几个表单
8 }! L" r* s4 T6 ?' |  _, I0 D9 v      E[M0`JYXC44EY2__T`(DPD2.png . n5 M; I; Z; p9 J: C. w5 P
       实验的工程中要添加trace的支持代码,是按照中间件提供的,如下
. D* d6 s' x' P: }& Z+ N         HANPHYP@PP%2W4JKZLZXCN0.png
$ I0 k# ]$ y' D7 s) g! B, c9 f        这个目录是这个样子的' N6 z8 [3 F4 f: J5 `: }2 T

7 ~; `: \1 m. H5 @2 Z; m: J
  1. readme.txt
    3 R, y. W8 c% {( [
  2. │  trcKernelPort.c2 H+ P: u2 M% q
  3. │  trcSnapshotRecorder.c& G. }* K. F( K0 B- L- e
  4. │  trcStreamingRecorder.c
    7 v2 P3 p9 D$ ~) H1 ?
  5. ├─config6 G& h1 |% J% H2 \. K! Y( Y/ i7 v
  6. │      trcConfig.h                  // 整个Trace源码的配置文件.
    + [7 s/ j5 Y, U5 |6 o% M4 }2 W+ X  V
  7. │      trcSnapshotConfig.h          // 快照模式配置文件,和流模式对应文件选其一
    " p  h6 u6 ~( ]" }- z
  8. │      trcStreamingConfig.h         // 流模式配置文件,和快照模式对应文件选其一: I3 e9 ^8 p$ v6 [
  9. ├─include9 g: U& D% E( q. f8 T
  10. │      trcHardwarePort.h            // 所有硬件依赖关系。包含几个预定义的硬件端口,包括ARM Cortex-M,PIC32,Renesas RX等。
    & g3 b& I" n4 @6 X  P- _, Y
  11. │      trcKernelPort.h              // FreeRTOS特定的定义,最值得注意的是跟踪钩子定义。0 R$ s+ S3 C: P; r. |
  12. │      trcPortDefines.h             // 配置文件的各种常量定义
    % |) o$ M; Q: B
  13. │      trcRecorder.h                // 公共API,开发者将以上两种模式进行了统一,用户使用时,只需要包含该文件即可!6 B3 y. h6 y5 W# ?) }7 v
  14. └─streamports                       // 该文件夹下就是流模式对应的不同接口方式的实现,以下任选其一即可2 M6 D) k" }$ I7 U( c# n
  15.     ├─Jlink_RTT
    5 V! o4 O" p% P* D2 q9 F
  16.     │  │  Readme.txt
    $ b  h; x1 C5 k1 R7 S% \1 X
  17.     │  │  SEGGER_RTT.c
    * m# m1 Y( K+ S% Z
  18.     │  │  SEGGER_RTT_Printf.c+ g! D* o" R3 v( i8 a7 ]
  19.     │  └─include7 D! o# Q9 {6 U  x+ j
  20.     │          SEGGER_RTT.h
    2 S! m1 q: e" I- G
  21.     │          SEGGER_RTT_Conf.h
    / w1 C, I: U. f! G' u
  22.     │          trcStreamingPort.h
    $ |) m( `' U. N3 U
  23.     ├─TCPIP) c  e. n4 [6 w$ l( ?- e
  24.     │  │  Readme.txt1 G* V) t! R8 h, k7 ~: [8 V
  25.     │  │  trcStreamingPort.c
    3 V+ D! M' h, |* @
  26.     │  └─include; S) `$ ?( d% d% \" ?
  27.     │          trcStreamingPort.h
    $ \1 X, {- w3 c$ @
  28.     └─USB_CDC2 T1 |9 N7 f& d
  29.         │  Readme.txt
    + z0 F7 g8 I/ Y. V4 F. M" H/ {
  30.         │  trcStreamingPort.c8 @- }/ Y- b- h
  31.         └─include
    ; _1 E& [9 ^0 N8 A& ^- ~
  32.                 trcStreamingPort.h
复制代码
      另外要在trcConfig文件中修改一些内容,重点看有注释的地方。
  1. #ifndef TRC_CONFIG_H
    $ h2 K+ P6 a  K6 X" o/ ?% {
  2. #define TRC_CONFIG_H6 I4 y  c1 V% n$ g) m7 Y6 C: R

  3. 5 b! ^- q3 j" z8 |' C
  4. #ifdef __cplusplus
    ) h3 B& L# Z8 T# u2 U' i: R
  5. extern "C" {% ^& X- g, _) `, V0 y' ?
  6. #endif* I  I2 T8 c0 ]$ d  y, M
  7. 2 d8 i- ^& Q: l$ D6 Q5 n! E
  8. #include "trcPortDefines.h"
    8 }# c  I7 t5 L1 D2 \4 Q

  9. # Z% S. N' g& O; y3 A: H6 G
  10. /******************************************************************************/ P9 e7 ~2 I$ n' R
  11. * Include of processor header file
    % P9 m; |) U6 x% k, R' d0 ^
  12. *
    # D. |5 A. M4 }, c# A
  13. * Here you may need to include the header file for your processor. This is % k& B+ L9 q8 T' M
  14. * required at least for the ARM Cortex-M port, that uses the ARM CMSIS API.
    1 k# C8 {" q1 |# z
  15. * Try that in case of build problems. Otherwise, remove the #error line below.& L4 L; W7 y# Y& l$ a. l
  16. *****************************************************************************/
    0 m7 l! b8 I6 N  ?7 F- y) @
  17. #include "stm32F2xx.h"      // 这里根据需要添加自己的芯片的头文件
    $ S  m" k% q( O; Y2 Z9 j
  18. //#error "Trace Recorder: Please include your processor´s header file here and remove this line."
    ; E: W- j; A7 J" J

  19. 0 W( Z6 F+ l! T! \
  20. /*******************************************************************************
    $ y% ]6 {. f9 t) S7 A, e& K
  21. * Configuration Macro: TRC_CFG_HARDWARE_PORT. C' L* `- b4 b; F' a
  22. *6 e" c1 {) `/ D
  23. * Specify what hardware port to use (i.e., the "timestamping driver").
    0 v! G4 C. k- v
  24. * All ARM Cortex-M MCUs are supported by "TRC_HARDWARE_PORT_ARM_Cortex_M".
    7 T% e: g. J% z! @7 e0 e" M
  25. ** j' C1 z- p) _. q7 d
  26. * See trcSnapshotHardwarePort.h or trcStreamingHardwarePort.h for available
    : V$ _; c( q) i" M/ j4 u, H( o( v
  27. * ports and information on how to define your own port, if not already present.& Q0 [6 h) S0 W3 X; a& N
  28. ******************************************************************************/
    3 R. E, g" B, }
  29. #define TRC_CFG_HARDWARE_PORT TRC_HARDWARE_PORT_ARM_Cortex_M        // 选择芯片对应的类型
    0 X( E. f5 e& B. M( N

  30. . i2 M% W2 I0 Z
  31. /*******************************************************************************3 l! L+ X0 Q* l$ C3 N/ _7 o
  32. * Configuration Macro: TRC_CFG_RECORDER_MODE
    0 o  N9 i0 u" ~% w4 K
  33. *! r$ l: ^  R' O* j# q9 j! t
  34. * Specify what recording mode to use. Snapshot means that the data is saved in0 v3 w4 k3 J$ A* E7 w2 M+ t
  35. * an internal RAM buffer, for later upload. Streaming means that the data is
    . G3 x: W/ O: k" A4 c: U
  36. * transferred continuously to the host PC. % J; ]5 E( f' P1 K- y& w
  37. *
    ' D/ _' e  n0 ^4 _7 u  P9 U
  38. * For more information, see http://percepio.com/2016/10/05/rtos-tracing/6 |6 h$ h8 S$ f+ W, [* v
  39. * and the Tracealyzer User Manual.
    ( s& X& ?, _0 O; j3 ?
  40. *9 w; Q* I! Q$ Y. O4 J# V% `
  41. * Values:. o1 D7 e# L( L6 C- J
  42. * TRC_RECORDER_MODE_SNAPSHOT
    ( C9 e- p0 j, X. h6 F- H
  43. * TRC_RECORDER_MODE_STREAMING1 ~) N- C5 N- x" h3 X! X9 H' ^
  44. ******************************************************************************/+ m  a5 J# ^' q2 B* @" V: d$ e
  45. #define TRC_CFG_RECORDER_MODE TRC_RECORDER_MODE_STREAMING       // 选择追踪模式(默认快照模式,这里我改成了流模式)
    4 S! }+ M1 t% ~! I2 d

  46. # n& [: \( V/ a" M/ G: n
  47. /*******************************************************************************
    . y4 d( t1 C2 i0 s! `) p: n
  48. * Configuration Macro: TRC_CFG_RECORDER_BUFFER_ALLOCATION) A2 Y' x! u3 _5 s! @' z  l& P
  49. *
    ) m- d+ }9 u5 x# I1 |: a
  50. * Specifies how the recorder's internal buffer is allocated (snapshot or! r1 x% M/ s0 ]5 R9 d" \3 g
  51. * streaming). Note that CUSTOM is only supported in snapshot mode.
    & V8 o# ], X7 H; ?; [: E
  52. *
    ( e6 f4 h, N5 |) k) a3 {
  53. * TRC_RECORDER_BUFFER_ALLOCATION_STATIC  - Static allocation - `, \. T( Q# N7 H
  54. * TRC_RECORDER_BUFFER_ALLOCATION_DYNAMIC - Allocated in vTraceEnable
    ( i  A& W  f/ c& P1 j
  55. * TRC_RECORDER_BUFFER_ALLOCATION_CUSTOM  - Use vTraceSetRecorderDataBuffer' p8 [4 u6 |, I
  56. ******************************************************************************/# \( c6 r4 t$ W0 p
  57. #define TRC_CFG_RECORDER_BUFFER_ALLOCATION TRC_RECORDER_BUFFER_ALLOCATION_STATIC' |8 c$ x/ u3 R7 |3 n$ F/ f

  58. 0 P/ o% k$ b6 i# k
  59. /******************************************************************************
    ( f  A; N0 w/ S9 n7 g: `# V/ S: p
  60. * TRC_CFG_FREERTOS_VERSION/ x9 H5 Y7 ^. F3 O
  61. *
    " U  U0 Z$ }5 ?& K
  62. * Specify what version of FreeRTOS that is used (don't change unless using the' H3 R5 {% _+ E" ^9 J
  63. * trace recorder library with an older version of FreeRTOS).
    % J8 \: S6 o) u9 r( g& x. ?  |
  64. *
    , b! E" X& h% E: [7 ]: H. w
  65. * TRC_FREERTOS_VERSION_7_3_OR_7_4              If using FreeRTOS v7.3.0 - v7.4.2
    / _7 I) Q& D1 q( J
  66. * TRC_FREERTOS_VERSION_7_5_OR_7_6              If using FreeRTOS v7.5.0 - v7.6.0' z5 ?4 V- }0 d8 W' l/ y/ m6 p
  67. * TRC_FREERTOS_VERSION_8_X                     If using FreeRTOS v8.X.X' f9 ?1 y' Q8 P
  68. * TRC_FREERTOS_VERSION_9_X                     If using FreeRTOS v9.X.X& K+ o, O7 {1 @" c1 @$ i2 k
  69. *****************************************************************************/5 e0 A1 Y  v2 J* x+ \" q; a
  70. #define TRC_CFG_FREERTOS_VERSION    TRC_FREERTOS_VERSION_9_X                // 这里根据自己的FreeRTOS版本修改% `! d# ^2 c8 y1 I) J& b
  71. " Q  x" V4 p9 m; ?
  72. /******************************************************************************
    + F& `. m+ b0 d# h' n
  73. * TRC_CFG_MAX_ISR_NESTING
    & {* N  B$ F' V( q
  74. *
    ( [! s+ |2 H2 V1 C$ R
  75. * Defines how many levels of interrupt nesting the recorder can handle, in
    ' R% }" G* e8 V) O* C; B" W# N
  76. * case multiple ISRs are traced and ISR nesting is possible. If this: d8 P, y) x" L  ]5 D' w
  77. * is exceeded, the particular ISR will not be traced and the recorder then
    $ K* g$ b# ]. m- `
  78. * logs an error message. This setting is used to allocate an internal stack1 y. a! M4 O$ j
  79. * for keeping track of the previous execution context (4 byte per entry).
    # [6 F" e) p8 d$ V8 \' I2 B
  80. *
    7 a0 U1 M4 d2 b5 o
  81. * This value must be a non-zero positive constant, at least 1.1 @$ s! Q& ?* l
  82. *
    ; X9 U8 l: n- J  ^  {
  83. * Default value: 8
    & G3 i* a' J7 E6 z# l( N. q1 N* B
  84. *****************************************************************************/
    ( X9 U3 ~" ~: x' e3 |
  85. #define TRC_CFG_MAX_ISR_NESTING 8
    0 H: |- d; ]& ?
  86. % Z7 k4 F- @) Y$ q
  87. /* Specific configuration, depending on Streaming/Snapshot mode */8 h  O1 [" [* l8 D
  88. #if (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_SNAPSHOT), u# k7 ]* h& ^/ t/ ^
  89. #include "trcSnapshotConfig.h"
    ) g* Y3 h4 P# ]& m+ l# b
  90. #elif (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
    4 j, T7 n( U6 H/ ?0 }
  91. #include "trcStreamingConfig.h"
    # g/ L9 r" f2 D& I! ~; l
  92. #endif9 n- H# B# J4 V: h, A6 b) Z
  93. 4 Q) b' F" m- F) A* ]' j% x
  94. #ifdef __cplusplus. O" J# t- ~$ a9 e1 ]
  95. }4 k. h1 w! x* U4 k1 M" a# _: a  h
  96. #endif
    % |9 p! o" K# e) x- b) s3 f: S

  97. + D" M# i, [) Q* X6 D
  98. #endif /* _TRC_CONFIG_H */
复制代码
        主函数中使能trcRecorder,后续就可以使用API了。          3QT~EL7)@NO]H}KYET4}1OI.png          
, _& h& ~/ Q- u! P* ^         安装好下载的软件并输入lisense以后就可以配置上位机。
, H$ c1 H/ F3 I0 f         具体配置方法可以看其他朋友写好的,详细步骤要多图配套,往IAR中添加Tracealyzer 工具的时候直接默认的名字3 s% S( H* D* t& _: Q3 j
          5B0LT$_S[@NQZ(ILJGIATKD.png
+ L0 ?! F7 w5 e' {, p8 V        选择后打开分析软件,从file中打来工程目录的money.hex文件就可以查看到该项目的运行情况。4 i8 s" Q! k8 q& |+ w/ ]1 v' c
        我这里来只看下打开后的效果
/ O4 B9 v. o) b% @% X+ ?* T          2F1~OXQ9GLVWBV(I2[~30E3.png + l' H) q- T; B5 l/ n
          的确很强大,可以图形化的跟踪系统和记录,。' b. s4 J; H0 Y8 t: |6 [6 Q6 l

6 O+ y  E. p# }7 l& D1 q! t2 O: p& @: T9 {8 t

5 s5 N* S# Q$ Z' G, I8 i$ p! {3 U1 l' T: o/ [) r

- d9 }2 u' c" k( O2 g
收藏 评论3 发布时间:2018-4-21 00:31

举报

3个回答
AI++ 回答时间:2018-9-5 11:50:14
根本不行, 运行后直接进入了硬件错误中断9 g4 y9 G2 S$ w/ X
0000000000000000001.jpg % w; H% U) {( ]0 U7 S4 X  s8 ~- P3 \  G
忆古思贤 回答时间:2018-9-30 09:07:06
多谢分享,辛苦了
米兰的无线电 回答时间:2019-7-4 11:30:08
本帖最后由 role_2099 于 2019-7-4 11:51 编辑 ' T9 T1 ]7 c7 [* b

# U# A4 w  B/ }' Y4 `0 ~7 u) x1 ?楼主帮忙看一下,我的是IAR8.32.4,怎么没有你那项new tool啊
' D+ p5 P* n! G! e; _- L! _# U* k: V1 x/ o# _
2019-07-04_11-28-11.png
: h) D* _  s( N( {2 e
2 q! a  q5 W. g/ }3 u. |% y知道了,是我还没有在IAR添加这个工具,我再找一下方法吧,但我从Tracealyzer 4里面直接打开IAR编译生成的.bin问题,提示下面的错误,我是评估版本,已输入license
8 s( J" _% M% b' x 2019-07-04_11-48-53.png 0 }& M# j. e; R+ Q# I: [$ M$ V
关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新和工艺
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版