아무튼 jtag-hs2를 연결해서 리눅스에서 보면 그냥 시리얼 포트다 (연결되었다 끊어지지만)
$ lsusb -t -v |__ Port 2: Dev 3, If 0, Class=Vendor Specific Class, Driver=ftdi_sio, 480M ID 0403:6014 Future Technology Devices International, Ltd FT232H Single HS USB-UART/FIFO IC
$ sudo dmesg [ 924.904844] usb 1-2: new high-speed USB device number 14 using xhci_hcd [ 925.059009] usb 1-2: New USB device found, idVendor=0403, idProduct=6014, bcdDevice= 9.00 [ 925.059027] usb 1-2: New USB device strings: Mfr=1, Product=2, SerialNumber=3 [ 925.059034] usb 1-2: Product: Digilent USB Device [ 925.059040] usb 1-2: Manufacturer: Digilent [ 925.059045] usb 1-2: SerialNumber: 0000000000 [ 925.066084] ftdi_sio 1-2:1.0: FTDI USB Serial Device converter detected [ 925.066178] usb 1-2: Detected FT232H [ 925.067712] usb 1-2: FTDI USB Serial Device converter now attached to ttyUSB0 [ 925.104014] ftdi_sio ttyUSB0: FTDI USB Serial Device converter now disconnected from ttyUSB0 [ 925.104066] ftdi_sio 1-2:1.0: device disconnected
PTM interface The Cortex-A9 processor optionally implements a Program Trace Macrocell (PTM) interface, that is compliant with the Program Flow Trace (PFT) instruction-only architecture protocol. Waypoints, changes in the program flow or events such as changes in context ID, are output to enable the trace to be correlated with the code image.
이는 기존 프로그램이 종료되었지만, 비정상종료된 상태로 아직 커널이 bind정보를 유지하고 있음으로 발생하는 문제다. 보통 1-2분 정도 지나만 커널이 알아서 정리를 하긴 하지만, 그 시간동안 기달려야 한다는 것은 상당히 번거로운 일이다. 이 경우 다음과 같은 코드를 삽입함으로써 문제를 해결할 수 있다.
int sock = socket(...); setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&bf, (int)sizeof(bf));
이렇게 하면 커널은 기존에 bind로 할당된 소켓자원을 프로세스가 재 사용할 수 있도록 허락한다.
프로토 타입은 아래와 같은데 SO_REUSEADDR 은 optname으로 level이 SOL_SOCKET 이라..
optval에는 또 어떻게 넣어줘야 하려나
#include <sys/types.h> /* See NOTES */ #include <sys/socket.h>
int getsockopt(int sockfd, int level, int optname, void *optval, socklen_t *optlen); int setsockopt(int sockfd, int level, int optname, const void *optval, socklen_t optlen);
빌드시에 생성되는 *.gnco 파일을 바이너리와 동일 경로에 두고 프로그램을 실행하면 *.gcda 파일이 생성된다.
그리고 gcovr을 아래 옵션을 주고 실행하면 html로 결과가 나온다.
소스 디렉토리 내에 bin/ 이 하위 디렉토리로 있어서
bin 에서 covr을 실행하였기에 상위 디렉토리(소스 디렉토리)를 지정해야 해서 "-r .." 을 사용해야 한다.
$ gcovr -r.. --html-details -o gcov.html
다만 크로스컴파일 환경에서 실행경로가 다르면 이래저래 번거로우니
profile-dir 플래그로 실행환경에 맞추어서 넣어주어야 편리할 듯 하다.
gcov uses two files for profiling. The names of these files are derived from the original object file by substituting the file suffix with either .gcno, or .gcda. The files contain coverage and profile data stored in a platform-independent format. The .gcno files are placed in the same directory as the object file. By default, the .gcda files are also stored in the same directory as the object file, but the GCC -fprofile-dir option may be used to store the .gcda files in a separate directory.
(gdb) help target Connect to a target machine or process. The first argument is the type or protocol of the target machine. Remaining arguments are interpreted by the target protocol. For more information on the arguments for a particular protocol, type `help target ' followed by the protocol name.
List of target subcommands:
target core -- Use a core file as a target. target ctf -- (Use a CTF directory as a target. target exec -- Use an executable file as a target. target extended-remote -- Use a remote computer via a serial line, using a gdb-specific protocol. target native -- Native process (started by the "run" command). target record-btrace -- Collect control-flow trace and provide the execution history. target record-core -- Log program while executing and replay execution from log. target record-full -- Log program while executing and replay execution from log. target remote -- Use a remote computer via a serial line, using a gdb-specific protocol. target tfile -- Use a trace file as a target.
Type "help target" followed by target subcommand name for full documentation. Type "apropos word" to search for commands related to "word". Type "apropos -v word" for full documentation of commands related to "word". Command name abbreviations are allowed if unambiguous.
(gdb) help target remote Use a remote computer via a serial line, using a gdb-specific protocol. Specify the serial device it is connected to (e.g. /dev/ttyS0, /dev/ttya, COM1, etc.).
(gdb) help monitor Send a command to the remote monitor (remote targets only).
monitor는 remote로 붙었을때만 보내는 명령인데 reset은 검색되진 않는다.
(gdb) file C:/temp/Blinky.elf
Reading symbols from C:/temp/Blinky.elf...done.
(gdb) target remote localhost:2331
Remote debugging using localhost:2331
0x00000000 in ?? ()
(gdb) monitor reset
Resetting target
(gdb) load