Помощь - Поиск - Пользователи - Календарь
Полная версия этой страницы: Трассировка STM32 CoreSight, ITM, ETM
Форум разработчиков электроники ELECTRONIX.ru > Микроконтроллеры (MCs) > ARM
Basilij
Данная тема пока для меня весьма абстрактна, недельные поиски в интернете не дали должного результата, решил обратиться к сообществу к общественности, полагаю есть люди которые обладают какой либо информацией по совокупности моих вопросов и готовы поделиться ей.

На сайте Кейла в разделе CoreSight Cortex-M3 Debug and Trace(http://www.keil.com/coresight/) сказано:

Serial Wire Viewer (SWV)
Cortex-M3 based devices are able to provide high-speed data trace information in a number of ways depending on the type of information or analysis you require.

The Serial Wire Viewer (SWV) provides real-time data trace information from various sources within the Cortex-M3 device. This is output via the single SWO pin while your system processor continues running at full speed.

Information is available from the ITM (Instrumentation Trace Macrocell) and DWT (Data Watchpoint and Trace) units, providing:

PC (Program Counter) sampling
Event counters that show CPU cycle statistics
Exception and Interrupt execution with timing statistics
Trace data - data reads and writes used for timing analysis
ITM trace information used for simple printf-style debugging
SWV Data trace is available via the SWO pin in two output formats:

UART style (1Mb/s) - supported by ULINK2, ULINK-ME, and ULINKPro
Manchester Encoded (100Mb/s) - supported by ULINKPro

т.е. в трассу можно из откуда угодно ложить даже "printf строки", в общем текстовую отладку использовать методом трассировки.

так вот как я понял в состав Кейловской IDE входит µVision который как раз и следит за трассой.

Незнаю насколько я пока это всё верно представляю, ибо не разу на практике не удалось реализовать трассировку.
Собственно Кейлом никогда и не пытался.

Но вот что в Eclipse + GDB отвечает за чтение трассы?

В Eclipse есть окошко "Trace Control", но не ясно оно не оно.

Отмечу что все опыты провожу на плате STM32L-DISKOVERY.

В документации на эту плату перемычка SB101 стоит, значит сигналы с трассы с вывода PB3 (T_SWO) поступает в строенный отладчик ST-LINK/V2 на вывод PA10.

Значит функционал трассировки должен быть.

В CMSIS нашёл всё что связанно с трассировкой так это типы ITM_Type и CoreDebug_Type
но что дальше с ними делать не совсем ясно.. особбенно когда непонятно где искать результат и как он должен вообще выглядеть.
На данном форуме в разделе про FreeRTOS есть ветка про статьи Курница.А. про FreeRTOS, новая статья как раз про отладку, возможно там и будет раскрыт данный вопрос. Но наврятли. Полагаю прежде всего ETM отладка была создана чтобы упростить отладку многопоточных приложений.

scifi
Вот тут что-то написано:
Application Note 197.
Basilij
Это инструкция для Кейсловского μVision в том то и дело что пытаюсь выяснить есть ли подобное в Eclipse .

В инструкции нашёл код для STM32:

Add ITM Stimulus Port register defines to your source code.
CODE
#define ITM_Port8(n) (*((volatile unsigned char *)(0xE0000000+4*n)))
#define ITM_Port16(n) (*((volatile unsigned short*)(0xE0000000+4*n)))
#define ITM_Port32(n) (*((volatile unsigned long *)(0xE0000000+4*n)))

#define DEMCR (*((volatile unsigned long *)(0xE000EDFC)))
#define TRCENA 0x01000000


Add a fputc function which writes to the ITM Stimulus Port 0 register to your source code. If you use fputc than it is possible to use printf for debug output.
CODE
ITM Port 0 is fix linked to the Serial Window ITM Viewer.
struct __FILE { int handle; /* Add whatever you need here */ };
FILE __stdout;
FILE __stdin;

int fputc(int ch, FILE *f) {
if (DEMCR & TRCENA) {
while (ITM_Port32(0) == 0);
ITM_Port8(0) = ch;
}
return(ch);
}


Add your Debug Trace Messages to your source code using printf.
printf("ITM Output Debug Trace message");


Скомпилировал его для своей платы, GCC компилятором, но при линковке ряд ошибок выдаёт.. незнаю насколько эти ошибки имеют прямое отношение к данной теме но тем не менее позволю себе выложить их. Охото запустить этот код на МК, чтобы хотябы "методом тыка" в Eclipse искать чем слушать трассу..

CODE
Linking: target.elf
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-vfprintf.o): In function `_vfprintf_r':
vfprintf.c:(.text+0x3a4): undefined reference to `__aeabi_dcmplt'
vfprintf.c:(.text+0xafe): undefined reference to `__aeabi_dcmpeq'
vfprintf.c:(.text+0xd1a): undefined reference to `__aeabi_dcmpeq'
vfprintf.c:(.text+0x1034): undefined reference to `__aeabi_uldivmod'
vfprintf.c:(.text+0x104c): undefined reference to `__aeabi_uldivmod'
vfprintf.c:(.text+0x119c): undefined reference to `__aeabi_dcmpeq'
vfprintf.c:(.text+0x1904): undefined reference to `__aeabi_dcmpeq'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-dtoa.o): In function `quorem':
dtoa.c:(.text+0x2e): undefined reference to `__aeabi_uidiv'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-dtoa.o): In function `_dtoa_r':
dtoa.c:(.text+0x18c): undefined reference to `__aeabi_dcmpeq'
dtoa.c:(.text+0x208): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x212): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x21c): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0x226): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x230): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x23c): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0x244): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0x252): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0x25a): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x262): undefined reference to `__aeabi_dcmpeq'
dtoa.c:(.text+0x284): undefined reference to `__aeabi_dcmpgt'
dtoa.c:(.text+0x362): undefined reference to `__aeabi_ui2d'
dtoa.c:(.text+0x426): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x440): undefined reference to `__aeabi_ddiv'
dtoa.c:(.text+0x45c): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0x488): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x498): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x4a4): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x4b0): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0x4c2): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x4ca): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x4d6): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0x4f6): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x502): undefined reference to `__aeabi_dcmpgt'
dtoa.c:(.text+0x516): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0x5d4): undefined reference to `__aeabi_ddiv'
dtoa.c:(.text+0x5d8): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0x5e0): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x5e8): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x5f4): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x616): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x622): undefined reference to `__aeabi_dcmpeq'
dtoa.c:(.text+0x64a): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x656): undefined reference to `__aeabi_dcmpeq'
dtoa.c:(.text+0x670): undefined reference to `__aeabi_ddiv'
dtoa.c:(.text+0x674): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0x67a): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x686): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x692): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x6c0): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0x6d0): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0x6de): undefined reference to `__aeabi_dcmpeq'
dtoa.c:(.text+0x8ac): undefined reference to `__aeabi_ddiv'
dtoa.c:(.text+0x918): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0x920): undefined reference to `__aeabi_dcmpge'
dtoa.c:(.text+0x95c): undefined reference to `__aeabi_ddiv'
dtoa.c:(.text+0x964): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x970): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0x976): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0x982): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x99a): undefined reference to `__aeabi_dcmpgt'
dtoa.c:(.text+0x9b0): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x9bc): undefined reference to `__aeabi_dcmpgt'
dtoa.c:(.text+0x9ec): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0x9f4): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0xa10): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xa24): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xa2c): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0xa32): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0xa40): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0xa52): undefined reference to `__aeabi_dcmplt'
dtoa.c:(.text+0xc5a): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xc8a): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xcbe): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xcca): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0xcd0): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0xcdc): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0xd12): undefined reference to `__aeabi_dmul'
dtoa.c:(.text+0xd1a): undefined reference to `__aeabi_d2iz'
dtoa.c:(.text+0xd20): undefined reference to `__aeabi_i2d'
dtoa.c:(.text+0xd2e): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0xd56): undefined reference to `__aeabi_dadd'
dtoa.c:(.text+0xd62): undefined reference to `__aeabi_dcmpgt'
dtoa.c:(.text+0xd78): undefined reference to `__aeabi_dsub'
dtoa.c:(.text+0xd84): undefined reference to `__aeabi_dcmplt'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-mprec.o): In function `__ratio':
mprec.c:(.text+0x83a): undefined reference to `__aeabi_ddiv'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-mprec.o): In function `_mprec_log10':
mprec.c:(.text+0x85c): undefined reference to `__aeabi_dmul'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-sbrkr.o): In function `_sbrk_r':
sbrkr.c:(.text+0x12): undefined reference to `_sbrk'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-vfiprintf.o): In function `_vfiprintf_r':
vfprintf.c:(.text+0xb20): undefined reference to `__aeabi_uldivmod'
vfprintf.c:(.text+0xb38): undefined reference to `__aeabi_uldivmod'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-writer.o): In function `_write_r':
writer.c:(.text+0x16): undefined reference to `_write'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-closer.o): In function `_close_r':
closer.c:(.text+0x12): undefined reference to `_close'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-fstatr.o): In function `_fstat_r':
fstatr.c:(.text+0x14): undefined reference to `_fstat'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-isattyr.o): In function `_isatty_r':
isattyr.c:(.text+0x12): undefined reference to `_isatty'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-lseekr.o): In function `_lseek_r':
lseekr.c:(.text+0x16): undefined reference to `_lseek'
e:/program files/codesourcery/sourcery g++ lite/bin/../lib/gcc/arm-none-eabi/4.5.2/../../../../arm-none-eabi/lib/thumb2\libc.a(lib_a-readr.o): In function `_read_r':
readr.c:(.text+0x16): undefined reference to `_read'
collect2: ld returned 1 exit status
cs-make: *** [target.elf] Error 1



в мейкфайле использую ключи
FLAGS_LD += -nostdlib

LIB_LD += -lgcc
LIB_LD += -lc
Для просмотра полной версии этой страницы, пожалуйста, пройдите по ссылке.
Invision Power Board © 2001-2025 Invision Power Services, Inc.