README.adoc 4.01 KB
Newer Older
Martin Horauer's avatar
Martin Horauer committed
1
= About
Martin Horauer's avatar
lol2  
Martin Horauer committed
2
3
4
5
6
7
8
9
10
11
12

The following guide describes the steps to build and run the mbed applications
targeting the XMC 4500 Relax Kit board from Infineon.

The `mbed-os` folder contains the MBED platform with various drivers for the
XMC platform. At the moment this is kept in a separate repository from the
main mbed project hosted on github at https://github.com/mbed-Infineon-XMC/mbed-os[https://github.com/mbed-Infineon-XMC/mbed-os].

The example applications are obtained from https://github.com/mbed-Infineon-XMC?tab=repositories[https://github.com/mbed-Infineon-XMC?tab=repositories] and are 
structured in folders named like `APP_XXX`.

13
14
15
16
17
[TIP]
Checkout the comments in the main.cpp files of every application - these 
examples are heavily commented and refer to the respective files where the 
classes, methods and definitions are found.

Martin Horauer's avatar
Martin Horauer committed
18
== Import the project
Martin Horauer's avatar
lol2  
Martin Horauer committed
19

Martin Horauer's avatar
Martin Horauer committed
20
21
[source%nowrap, bash]
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
22
23
$ git clone https://es.technikum-wien.at/bel/bel4_ezb_public.git
$ cd XMC_MBED/
Martin Horauer's avatar
Martin Horauer committed
24
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
25

Martin Horauer's avatar
Martin Horauer committed
26
== Import a library
Martin Horauer's avatar
lol2  
Martin Horauer committed
27

Martin Horauer's avatar
Martin Horauer committed
28
29
30
31
32
33
34
35
36
37
38
Libraries can be added to the project using `mbed add LINK` where LINK points
to the respective repository, e.g.:

----
mbed add https://mbed.org/users/CheeseW/code/ADJDs311/#5d0bc4df0701
----

This adds a folder `ADJDs311` containing the respective sources and adds a file
`ADJDs311.lib` that simply contains the above link. This löibrary will than be 
considered when the project is being built.

Martin Horauer's avatar
Martin Horauer committed
39
40
41
42
43
44
45
46
47
48
49
== STDIO_UART

The mbed library outputs `printf()` messages via a standard UART interface that
is per default enabled and configured. For the XMC RelaxKit the default UART is
configured in
`targets/TARGET_Infineon/TARGET_XMC4XXX/TARGET_XMC4500/PeripheralNames.h` and
`targets/TARGET_Infineon/TARGET_XMC4XXX/serial_api.c`, respectively. In
particular, UART2 (pins P0.4 and P0.5) is used. Default setting is 9600-8N1.

TIP: Keep UART2 in all MBED projects connected to a terminal program.

Martin Horauer's avatar
Martin Horauer committed
50
51
52
= Step-by-Step Building/Flashing/Debugging

== Compile a project
Martin Horauer's avatar
lol2  
Martin Horauer committed
53
54
55

Navigate into the project folder and build it using:

Martin Horauer's avatar
Martin Horauer committed
56
57
[source%nowrap, bash]
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
58
59
cd APP_BB_BLINKY/
mbed compile -m XMC_4500_RELAX_KIT -t GCC_ARM -N main
Martin Horauer's avatar
Martin Horauer committed
60
61
----

Martin Horauer's avatar
lol2  
Martin Horauer committed
62
63
64
65
66
67
68
69
70
71
mbed creates a BUILD directory where you can find the executable (`*.bin`, `*.elf`, `*.hex` ...).

[NOTE]
When using MS-Windows delete the existing Unix symbolic-link `mbed-os` and 
replace it with a Windows symbolic link using `mklink /D mbed-os ..\mbed-os`.

## Flash the application to the Relax-Kit

Use the JLink tools to flash the application hexfile to the Relax-Kit.

Martin Horauer's avatar
Martin Horauer committed
72
73
[source%nowrap, bash]
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
74
75
76
77
78
$ JLinkExe -device XMC4500-1024 -if SWD -speed 4000 -autoconnect 1
J-LINK> h
J-Link> loadfile BUILD/XMC_4500_RELAX_KIT/GCC_ARM/main.hex
J-Link> r
J-Link> g
Martin Horauer's avatar
Martin Horauer committed
79
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
80

Martin Horauer's avatar
Martin Horauer committed
81
== Debugging
Martin Horauer's avatar
lol2  
Martin Horauer committed
82
83
84
85
86
87

To the debug the application 4 steps in sequence are necessary.

(1) You will need to create the executable with DEBUg symbols. To that end add 
`--profile mbed-os/tools/profiles/debug.json` to the build command.

Martin Horauer's avatar
Martin Horauer committed
88
89
[source%nowrap, bash]
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
90
mbed compile -m XMC_4500_RELAX_KIT -t GCC_ARM -N main --profile mbed-os/tools/profiles/debug.json
Martin Horauer's avatar
Martin Horauer committed
91
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
92
93
94

(2) Start the `JLinkGDEBServer`, e.g.:

Martin Horauer's avatar
Martin Horauer committed
95
96
[source%nowrap, bash]
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
97
JLinkGDBServer -Device XMC4500-1024 -if SWD
Martin Horauer's avatar
Martin Horauer committed
98
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
99
100
101
102

(3) In order to log messages printed to `stdout` we connect to port 2333 via
telnet.

Martin Horauer's avatar
Martin Horauer committed
103
104
[source%nowrap, bash]
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
105
telnet 127.0.0.1 2333
Martin Horauer's avatar
Martin Horauer committed
106
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
107
108
109

(4) We launch the debugger and control the debug session:

Martin Horauer's avatar
Martin Horauer committed
110
111
[source%nowrap, bash]
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
112
113
114
115
116
117
118
119
arm-none-eabi-gdb -q BUILD/XMC_4500_RELAX_KIT/GCC_ARM/main.elf
(gdb) target remote :2331
(gdb) monitor reset
(gdb) load
(gdb) monitor reset
(gdb) b main
(gdb) c
[...]
Martin Horauer's avatar
Martin Horauer committed
120
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
121

Martin Horauer's avatar
Martin Horauer committed
122
= Makefile Building/Flashing/Debugging
Martin Horauer's avatar
lol2  
Martin Horauer committed
123
124
125
126

Using the prepared `Makefile` one can invoke trhe following actions in a more 
convenient way:

Martin Horauer's avatar
Martin Horauer committed
127
128
[source%nowrap, bash]
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
129
130
131
132
133
134
135
136
make          # build the application with debug symbols
make debug    # -"-
make release  # debug a release version of the project
make flash    # flash the application
make debug    # debug the application
make erase    # erase the program memory
make doc      # invoke doxygen
make clean    # clean the project
Martin Horauer's avatar
Martin Horauer committed
137
----
Martin Horauer's avatar
lol2  
Martin Horauer committed
138

Martin Horauer's avatar
lol3    
Martin Horauer committed
139
140
141


///////////////////////////////////////////////////////////////////////////////