Commit ba91fa0b authored by Martin Horauer's avatar Martin Horauer
Browse files

modified MBED Blinky

parent 2bdf9292
# Blinky Example
The following guide describes the steps to run the first Blinky program on the
XMC 4500 Relax Kit board from Infineon.
## Import the project
```
mbed import https://github.com/mbed-Infineon-XMC/Blinky-Example.git
```
## Compile the project
Navigate into the project folder and execute the following command:
```
cd Blinky-Example.git/
mbed compile -m XMC_4500_RELAX_KIT -t GCC_ARM
```
mbed creates a BUID directory where you can find the executables (bin, elf, hex ...).
## Step 5: Flash to board
* [Segger JLink](https://www.segger.com/downloads/jlink) - Install the JLink software for your platform.
* Navigate to the BUILD directory and execute the following JLinkExe commands.
```
$ JLinkExe
J-LINK> device xmc4500-1024
J-LINK> h
J-Link> loadfile Blinky-Example.git.hex
J-Link> r
J-Link> g
```
* Choose SWD, 4000kHz as interface settings!!
## Step 6: If successful..
When everything has gone well, LED1 will blink with 2Hz.
## Step 7: Eclipse IDE & debugging
If you want to compile and debug the project with eclipse follow this guidline:
* First export and create a makefile for the eclipse platform.
```
mbed export -i eclipse_gcc_arm -m XMC_4500_RELAX_KIT
```
* Install Eclipse C/C++ IDE
* [Install Plugins](https://github.com/mhorauer/XMC4500-Barebone-Projects/blob/master/Setup/plugins.asciidoc) - The following tutorial could be helpful.
* [Debugging with eclipse](https://docs.mbed.com/docs/mbed-os-handbook/en/5.3/debugging/debugging_eclipse_pyocd/) - Also take a look to the mbed debuging guidlines.
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>APP_BLINKY</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>
\ No newline at end of file
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<meta http-equiv="refresh"
content="1;url="https://os.mbed.com/docs/latest/tools/exporting.html>
<script type="text/javascript">
window.location.href = "https://os.mbed.com/docs/latest/tools/exporting.html"
</script>
<title>Page Redirection</title>
</head>
<body>
If you are not redirected automatically, please follow the
<a href='https://os.mbed.com/docs/v5.6/tools/exporting.html/'>link to the online exporter documentation</a>
</body>
</html>
This diff is collapsed.
# Blinky Example
A siomple blinky example that flashes the LED1 on the XMC Relax-Kit eval board.
## Makefile Usage
```
make # build the application
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
```
# Manuell
## Building
```
mbed compile -c -m XMC_4500_RELAX_KIT -t GCC_ARM -N main
```
This creates several files in the BUILD directory where you can find the executables (bin, elf, hex ...).
## Flashing
```
$ JLinkExe -Device XMC4500-1024 -if SWD -speed 4000
J-LINK> h
J-Link> loadfile BUILD/XMC_4500_RELAX_KIT/GCC_ARM/main.hex
J-Link> r
J-Link> g
```
## Debugging
(1) Start the `JLinkGDEBServer`, e.g.:
```
JLinkGDBServer -Device XMC4500-1024 -if SWD
```
(2) In order to log messages printed to `stdout` we connect to port 2333 via
telnet.
```
telnet 127.0.0.1 2333
```
(3) We launch the debugger and control the debug session:
```
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
[...]
```
This diff is collapsed.
/*
* mbed SDK
* Copyright (c) 2017 ARM Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Automatically generated configuration file.
// DO NOT EDIT, content will be overwritten.
#ifndef __MBED_CONFIG_DATA__
#define __MBED_CONFIG_DATA__
// Configuration parameters
#define MBED_LFS_READ_SIZE 64 // set by library:littlefs
#define MBED_LFS_ENABLE_INFO 0 // set by library:littlefs
#define MBED_CONF_PLATFORM_DEFAULT_SERIAL_BAUD_RATE 9600 // set by library:platform
#define MBED_CONF_EVENTS_SHARED_DISPATCH_FROM_APPLICATION 0 // set by library:events
#define MBED_CONF_EVENTS_PRESENT 1 // set by library:events
#define MBED_CONF_RTOS_PRESENT 1 // set by library:rtos
#define MBED_CONF_EVENTS_SHARED_EVENTSIZE 256 // set by library:events
#define MBED_LFS_PROG_SIZE 64 // set by library:littlefs
#define MBED_CONF_PPP_CELL_IFACE_AT_PARSER_TIMEOUT 8000 // set by library:ppp-cell-iface
#define MBED_CONF_PLATFORM_STDIO_FLUSH_AT_EXIT 1 // set by library:platform
#define MBED_CONF_EVENTS_SHARED_STACKSIZE 1024 // set by library:events
#define MBED_CONF_DRIVERS_UART_SERIAL_RXBUF_SIZE 256 // set by library:drivers
#define MBED_CONF_DRIVERS_UART_SERIAL_TXBUF_SIZE 256 // set by library:drivers
#define MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP 0 // set by library:ppp-cell-iface
#define MBED_LFS_LOOKAHEAD 512 // set by library:littlefs
#define MBED_CONF_EVENTS_USE_LOWPOWER_TIMER_TICKER 0 // set by library:events
#define MBED_CONF_FILESYSTEM_PRESENT 1 // set by library:filesystem
#define MBED_CONF_PPP_CELL_IFACE_BAUD_RATE 115200 // set by library:ppp-cell-iface
#define MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES 0 // set by library:platform
#define MBED_LFS_BLOCK_SIZE 512 // set by library:littlefs
#define MBED_CONF_PPP_CELL_IFACE_AT_PARSER_BUFFER_SIZE 256 // set by library:ppp-cell-iface
#define MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR 0 // set by library:platform
#define MBED_CONF_NSAPI_PRESENT 1 // set by library:nsapi
#define MBED_CONF_PLATFORM_STDIO_BAUD_RATE 9600 // set by library:platform
#define MBED_CONF_EVENTS_SHARED_HIGHPRIO_STACKSIZE 1024 // set by library:events
#define MBED_CONF_EVENTS_SHARED_HIGHPRIO_EVENTSIZE 256 // set by library:events
// Macros
#define UNITY_INCLUDE_CONFIG_H // defined by library:utest
#endif
# About
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`.
## Import the project
```
$ git clone https://es.technikum-wien.at/bel/bel4_ezb_public.git
$ cd XMC_MBED/
```
# Step-by-Step Building/Flashing/Debugging
## Compile a project
Navigate into the project folder and build it using:
```
cd APP_BB_BLINKY/
mbed compile -m XMC_4500_RELAX_KIT -t GCC_ARM -N main
```
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.
```
$ 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
```
## Debugging
To the debug the application 3 steps in sequence are necessary:
(1) Start the `JLinkGDEBServer`, e.g.:
```
JLinkGDBServer -Device XMC4500-1024 -if SWD
```
(2) In order to log messages printed to `stdout` we connect to port 2333 via
telnet.
```
telnet 127.0.0.1 2333
```
(3) We launch the debugger and control the debug session:
```
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
[...]
```
# Makefile Building/Flashing/Debugging
Using the prepared `Makefile` one can invoke trhe following actions in a more
convenient way:
```
make # build the application
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
```
......@@ -226,7 +226,6 @@ $(TARGET): $(TARGET).elf
################################################################################
# DEBUG RULES
debug: $(TARGET)
# comment the following line in Windows and launch JLinkGDBServer manually
ifdef SystemRoot
@call start JLinkGDBServer -Device XMC4500-1024 -if SWD
else
......
################################################################################
# Makefile for XMC4500 RelaxKit using uCOS-III
# v1, 02/2015
# Martin Horauer, UAS Technikum Wien
#
# Supported: Windows, Linux, OSX
# Requirements:
# * GCC ARM https://launchpad.net/gcc-arm-embedded/+download
# * SEGGER JLINK https://www.segger.com/jlink-software.html
# * DOXYGEN http://www.stack.nl/~dimitri/doxygen/
################################################################################
# USAGE
# -----
# make .... build the program image
# make debug .... build the program image and invoke gdb
# make flash .... build an flash the application
# make erase .... erase the target device
# make doc .... run doxygen - output will be in > doc
# make clean .... remove intermediate and generated files
################################################################################
# define the name of the generated output file
#
TARGET = main
################################################################################
# below only edit with care
#
VENDOR = Infineon
################################################################################
# define the following symbol -D JLINK_RTT to enable JLINK_RTT tracing
# -D SEMI_HOSTING to enable semi hosted tracing
# comment the line to disable tracing
TRACE = -D SEMI_HOSTING
################################################################################
# DIRECTORIES
SRCDIR = ./
BIN = ./bin
DOC = ./doc
SYS = ../CMSIS
XMCLIB = ../XMCLIB
OS = ../UCOS3
BSP = $(SRCDIR)/BSP
CMSIS = $(SYS)/CMSIS
CMSIS_INCDIR = $(CMSIS)/Include
CMSIS_LIBDIR = $(CMSIS)/Lib/GCC
INF_INCDIR = $(CMSIS)/$(VENDOR)/Include
INF_LIBDIR = $(CMSIS)/$(VENDOR)/Lib
XMC_INCDIR = $(CMSIS)/$(VENDOR)/$(UC)_series/Include
XMC_LIBDIR = $(CMSIS)/$(VENDOR)/$(UC)_series/Lib
XMC_SRCDIR = $(CMSIS)/$(VENDOR)/$(UC)_series/Source
XMC_GCCDIR = $(CMSIS)/$(VENDOR)/$(UC)_series/Source/GCC
XMC_LIBINCDIR = $(XMCLIB)/inc
XMC_LIBSRCDIR = $(XMCLIB)/src
################################################################################
# TOOLS & ARGS
#
TERMINAL = gnome-terminal
TOOLCHAIN = arm-none-eabi
AS = $(TOOLCHAIN)-as
CC = $(TOOLCHAIN)-gcc
CP = $(TOOLCHAIN)-objcopy
OD = $(TOOLCHAIN)-objdump
GDB = $(TOOLCHAIN)-gdb
SIZE = $(TOOLCHAIN)-size
# DETERMINE OS
ifdef SystemRoot
RM = del /Q
FixPath = $(subst /,\,$1)
else
RM = rm -rf
FixPath = $1
endif
UC = XMC4500
UC_ID = 4503
CPU = cortex-m4
FPU = fpv4-sp-d16
FABI = softfp #soft, softfp, hard
LIBS = -larm_cortexM4_mathL_2
LIBS += -lxmclibcstubs
LIBS += -lm
GDB_ARGS = -ex "target remote :2331"
GDB_ARGS += -ex "monitor reset"
GDB_ARGS += -ex "load"
GDB_ARGS += -ex "monitor reset"
################################################################################
# SEMI_HOSTED DEBUGGING
GDB_ARGS += -ex "monitor SWO EnableTarget 16000000 0 1 0"
# RTT OPTION
#GDB_ARGS += -ex "monitor exec SetRTTAddr 0x20000000"
#GDB_ARGS += -ex "monitor exec SetRTTSearchRanges 0x20000000 0x1000"
################################################################################
# OS Source
SRC = $(wildcard *.c)
SRC += $(OS)/uC-CPU/cpu_core.c
SRC += $(OS)/uC-CPU/ARM-Cortex-M4/GNU/cpu_c.c
SRC += $(wildcard $(OS)/uC-LIB/*.c)
SRC += $(wildcard $(OS)/uCOS-III/Source/*.c)
SRC += $(OS)/uCOS-III/Ports/ARM-Cortex-M4/Generic/GNU/os_cpu_c.c
SRC += $(wildcard $(BSP)/*.c)
################################################################################
# SYSTEM SOURCES
SRC += $(INF_LIBDIR)/System_LibcStubs.c
SRC += $(XMC_SRCDIR)/System_XMC4500.c
SRC += $(wildcard $(XMC_LIBSRCDIR)/*.c)
################################################################################
# ASSEMBLER SOURCES
SRCASM = $(BSP)/startup.asm
SRCASM += $(OS)/uCOS-III/Ports/ARM-Cortex-M4/Generic/GNU/os_cpu_a.asm
SRCASM += $(OS)/uC-CPU/ARM-Cortex-M4/GNU/cpu_a.asm
SRCASM += $(OS)/uC-LIB/Ports/ARM-Cortex-M4/GNU/lib_mem_a.asm
SRCASM += $(XMC_GCCDIR)/startup_XMC4500.asm
################################################################################
# LINKER_FILE
LINKER_FILE = $(XMC_GCCDIR)/xmc4500_ucos.ld
################################################################################
# INCLUDE DIRECTORIES
OS_INCDIR += -I$(OS)
OS_INCDIR += -I$(OS)/uC-CPU
OS_INCDIR += -I$(OS)/uC-CPU/ARM-Cortex-M4/GNU
OS_INCDIR += -I$(OS)/uC-LIB
OS_INCDIR += -I$(OS)/uCOS-III/Source
OS_INCDIR += -I$(OS)/uCOS-III/Ports/ARM-Cortex-M4/Generic/GNU
OS_INCDIR += -I$(BSP)
INC_DIR = -I$(SRCDIR)
INC_DIR+= -I$(SYS)
INC_DIR+= -I$(CMSIS_INCDIR)
INC_DIR+= -I$(INF_INCDIR)
INC_DIR+= -I$(XMC_INCDIR)
INC_DIR+= -I$(OS_INCDIR)
INC_DIR+= -I$(XMC_LIBINCDIR)
################################################################################
# LIBRARY DIRECTORIES
LIBS_DIR = -L$(SYS)
LIBS_DIR += -L$(CMSIS_LIBDIR)
LIBS_DIR += -L$(INF_LIBDIR)
LIBS_DIR += -L$(XMC_LIBDIR)
################################################################################
# OBJECT FILES
OBJS = $(SRC:.c=.o)
OBJS+= $(SRCASM:.asm=.o)
################################################################################
# DEPENDENCY FILES
DEPS = $(SRC:.c=.d)
DEPS += $(SRCASM:.asm=.d)
################################################################################
# STACK USAGE FILES
SU = $(SRC:.c=.su)
################################################################################
# COMPILER, ASSEMBLER OPTIONS
CFLAGS = -mthumb
CFLAGS+= -mcpu=$(CPU)
#CFLAGS+= -mfpu=$(FPU)
#CFLAGS+= -mfloat-abi=$(FABI)
CFLAGS+= -O0
CFLAGS+= -ffunction-sections -fdata-sections -fsigned-char -fstack-usage
CFLAGS+= -MD -std=c99 -Wall -fms-extensions
CFLAGS+= -DUC_ID=$(UC_ID) -DARM_MATH_CM4 -DXMC4500_F144x1024
CFLAGS+= -g3 -fmessage-length=0
AFLAGS = -x assembler-with-cpp
LFLAGS = -nostartfiles $(LIBS_DIR) -Wl,--gc-sections -Wl,-Map=bin/$(TARGET).map
CPFLAGS = -Obinary
ODFLAGS = -S
################################################################################
# BUILD RULES
all: $(OBJS) $(TARGET).elf $(TARGET)
%.o: %.asm
@echo "----------------------------------------------------------------------"
@echo "Assembly of $<:"
@echo ""
$(CC) -c $(CFLAGS) $(INC_DIR) $(AFLAGS) $< -o $@
@echo ""
%.o: %.c
@echo "----------------------------------------------------------------------"
@echo "Compilation of $<:"
@echo ""
$(CC) -c $(CFLAGS) $(INC_DIR) $< -o $@
@echo ""
$(TARGET).elf: $(OBJS)
@echo "----------------------------------------------------------------------"
@echo "Linking:"
@echo ""
$(CC) -T $(LINKER_FILE) $(LFLAGS) $(CFLAGS) -o $(BIN)/$(TARGET).elf $(OBJS) $(LIBS)
@echo ""
$(TARGET): $(TARGET).elf
@echo "----------------------------------------------------------------------"
@echo "Creation of Binary:"
@echo ""
$(CP) $(CPFLAGS) $(BIN)/$(TARGET).elf $(BIN)/$(TARGET).bin
@echo "----------------------------------------------------------------------"
@echo "Create Listing File:"
@echo ""
$(OD) $(ODFLAGS) $(BIN)/$(TARGET).elf > $(BIN)/$(TARGET).lst
@echo "----------------------------------------------------------------------"
@echo "Create Static Usage Analysis:"
@echo ""
$(SIZE) $(BIN)/$(TARGET).elf
################################################################################
# DEBUG RULES
debug: $(TARGET)
# comment the following line in Windows and launch JLinkGDBServer manually
ifdef SystemRoot
@call start JLinkGDBServer -Device XMC4500-1024 -if SWD
else
$(TERMINAL) -e "JLinkGDBServer -Device XMC4500-1024 -if SWD" &
sleep 1 && $(TERMINAL) -e "telnet localhost 2333" &
endif
$(GDB) -q $(BIN)/$(TARGET).elf $(GDB_ARGS)
################################################################################
# FLASH RULES
flash: $(TARGET)
echo -e 'speed 4000\nconnect\nh\nloadbin bin/$(TARGET).bin,0xC000000\nr\ng\nq' | JLinkExe -Device XMC4500-1024 -if SWD
################################################################################
# ERASE DEVICE
erase:
echo -e 'speed 4000\nconnect\nerase\nr\nq' | JLinkExe -Device XMC4500-1024 -if SWD
################################################################################
# DOCUMENTATION RULES
doc: $(TARGET)
doxygen
################################################################################
# CLEAN RULES
clean:
$(RM) $(call FixPath, ${OBJS} ${DEPS} ${SU})
$(RM) $(call FixPath, ${BIN}/*)
$(RM) $(call FixPath, ${DOC}/html/*)
################################################################################
# EOF
################################################################################
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment