Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for DEBUG_PRINT using SEGGER RTT #30

Merged
merged 1 commit into from
May 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ CLOAD_SCRIPT ?= ../crazyflie-clients-python/bin/cfloader

S110 ?= 1 # SoftDevice flashed or not
BLE ?= 1 # BLE mode activated or not. If disabled, CRTP mode is active
DEBUG_PRINT_ON_SEGGER_RTT ?= 0 # debug prints

PLATFORM ?= cf2

Expand Down Expand Up @@ -85,7 +86,14 @@ OBJS += src/main.o gcc_startup_nrf51.o system_nrf51.o src/uart.o \
src/syslink.o src/pm.o src/systick.o src/button.o src/swd.o src/ow.o \
src/ow/owlnk.o src/ow/ownet.o src/ow/owtran.o \
src/ow/crcutil.o src/ds2431.o src/ds28e05.o src/esb.o src/memory.o \
src/platform.o src/platform_$(PLATFORM).o
src/platform.o src/platform_$(PLATFORM).o src/debug.o

ifeq ($(strip $(DEBUG_PRINT_ON_SEGGER_RTT)), 1)
INCLUDES += -I src/lib/Segger_RTT/RTT
OBJS += src/lib/Segger_RTT/RTT/SEGGER_RTT.o src/lib/Segger_RTT/RTT/SEGGER_RTT_printf.o
CFLAGS += -DDEBUG_PRINT_ON_SEGGER_RTT
endif


all: $(PROGRAM).elf $(PROGRAM).bin $(PROGRAM).hex
$(SIZE) $(PROGRAM).elf
Expand Down
42 changes: 42 additions & 0 deletions interface/debug.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* || ____ _ __
* +------+ / __ )(_) /_______________ _____ ___
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
*
* Crazyflie 2.0 NRF Firmware
* Copyright (c) 2014, Bitcraze AB, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/

#ifndef __DEBUG_H__
#define __DEBUG_H__

#ifdef DEBUG_PRINT_ON_SEGGER_RTT
#include "SEGGER_RTT.h"
#endif

void debugInit(void);

#if defined(DEBUG_PRINT_ON_SEGGER_RTT)
#define DEBUG_PRINT(fmt, ...) SEGGER_RTT_printf(0, fmt, ## __VA_ARGS__)
#define DEBUG_PRINT_OS(fmt, ...) SEGGER_RTT_printf(0, fmt, ## __VA_ARGS__)
#else // No debug
#define DEBUG_PRINT(fmt, ...)
#define DEBUG_PRINT_OS(fmt, ...)
#endif

#endif //__DEBUG_H__
33 changes: 33 additions & 0 deletions src/debug.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* || ____ _ __
* +------+ / __ )(_) /_______________ _____ ___
* | 0xBC | / __ / / __/ ___/ ___/ __ `/_ / / _ \
* +------+ / /_/ / / /_/ /__/ / / /_/ / / /_/ __/
* || || /_____/_/\__/\___/_/ \__,_/ /___/\___/
*
* Crazyflie 2.0 NRF Firmware
* Copyright (c) 2014, Bitcraze AB, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/

#include "debug.h"

void debugInit(void)
{
#ifdef DEBUG_PRINT_ON_SEGGER_RTT
SEGGER_RTT_Init();
SEGGER_RTT_ConfigUpBuffer(0, NULL, NULL, 0, SEGGER_RTT_MODE_NO_BLOCK_TRIM);
#endif
}
44 changes: 44 additions & 0 deletions src/lib/Segger_RTT/License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
Important - Read carefully:

SEGGER RTT - Real Time Transfer for embedded targets

All rights reserved.

SEGGER strongly recommends to not make any changes
to or modify the source code of this software in order to stay
compatible with the RTT protocol and J-Link.

Redistribution and use in source and binary forms, with or
without modification, are permitted provided that the following
conditions are met:

o Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.

o Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.

o Neither the name of SEGGER Microcontroller GmbH
nor the names of its contributors may be used to endorse or
promote products derived from this software without specific
prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL SEGGER Microcontroller BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
DAMAGE.


(c) 2014 - 2016 SEGGER Microcontroller GmbH
www.segger.com
20 changes: 20 additions & 0 deletions src/lib/Segger_RTT/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
README.txt for the SEGGER RTT Implementation Pack.

Included files:
===============
Root Directory
- Examples
- Main_RTT_InputEchoApp.c - Sample application which echoes input on Channel 0.
- Main_RTT_MenuApp.c - Sample application to demonstrate RTT bi-directional functionality.
- Main_RTT_PrintfTest.c - Sample application to test RTT small printf implementation.
- Main_RTT_SpeedTestApp.c - Sample application for measuring RTT performance. embOS needed.
- RTT
- SEGGER_RTT.c - The RTT implementation.
- SEGGER_RTT.h - Header for RTT implementation.
- SEGGER_RTT_Conf.h - Pre-processor configuration for the RTT implementation.
- SEGGER_RTT_Printf.c - Simple implementation of printf to write formatted strings via RTT.
- Syscalls
- RTT_Syscalls_GCC.c - Low-level syscalls to retarget printf() to RTT with GCC / Newlib.
- RTT_Syscalls_IAR.c - Low-level syscalls to retarget printf() to RTT with IAR compiler.
- RTT_Syscalls_KEIL.c - Low-level syscalls to retarget printf() to RTT with KEIL/uVision compiler.
- RTT_Syscalls_SES.c - Low-level syscalls to retarget printf() to RTT with SEGGER Embedded Studio.
Loading