[PATCH v2] bsp/tms570: implemented support functions to satisfy complete tests build requirements.
Joel Sherrill
joel.sherrill at oarcorp.com
Thu Aug 21 14:09:23 UTC 2014
I pushed this and am building now.
Thanks.
On 8/21/2014 8:38 AM, Pavel Pisa wrote:
> This patch enables to build all RTEMS tests for tms570ls3137_hdk_sdram
> BSP variant in in default build. Debug build with --enable-rtems-debug set
> has succeed for samples subset of tests as well.
> ---
> c/src/lib/libbsp/arm/tms570/Makefile.am | 9 ++++
> .../lib/libbsp/arm/tms570/clock/benchmark_timer.c | 61 +++++++++++++++++++++
> c/src/lib/libbsp/arm/tms570/clock/clock.c | 4 +-
> .../lib/libbsp/arm/tms570/include/system-clocks.h | 62 ++++++++++++++++++++++
> .../arm/tms570/make/custom/tms570ls3137_hdk.cfg | 2 +-
> .../tms570/make/custom/tms570ls3137_hdk_intram.cfg | 2 +-
> .../tms570/make/custom/tms570ls3137_hdk_sdram.cfg | 2 +-
> c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c | 44 +++++++++++++++
> c/src/lib/libbsp/arm/tms570/preinstall.am | 4 ++
> 9 files changed, 186 insertions(+), 4 deletions(-)
> create mode 100644 c/src/lib/libbsp/arm/tms570/clock/benchmark_timer.c
> create mode 100644 c/src/lib/libbsp/arm/tms570/include/system-clocks.h
> create mode 100644 c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c
>
> diff --git a/c/src/lib/libbsp/arm/tms570/Makefile.am b/c/src/lib/libbsp/arm/tms570/Makefile.am
> index 02d7b66..e66cf79 100644
> --- a/c/src/lib/libbsp/arm/tms570/Makefile.am
> +++ b/c/src/lib/libbsp/arm/tms570/Makefile.am
> @@ -39,6 +39,7 @@ include_bsp_HEADERS += include/tms570-rti.h
> include_bsp_HEADERS += include/tms570-vim.h
> include_bsp_HEADERS += include/tms570-pom.h
> include_bsp_HEADERS += include/tms570-sci-driver.h
> +include_bsp_HEADERS += include/system-clocks.h
>
> include_HEADERS += ../../shared/include/tm27.h
>
> @@ -78,6 +79,7 @@ libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
> libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
> libbsp_a_SOURCES += ../../shared/sbrk.c
> libbsp_a_SOURCES += ../../shared/src/stackalloc.c
> +libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
>
> # Startup
> libbsp_a_SOURCES += ../shared/startup/bsp-start-memcpy.S
> @@ -105,6 +107,7 @@ libbsp_a_SOURCES += console/tms570-sci.c
> # Clock
> libbsp_a_SOURCES += ../../shared/clockdrv_shell.h
> libbsp_a_SOURCES += clock/clock.c
> +libbsp_a_SOURCES += clock/benchmark_timer.c
>
> # RTC
>
> @@ -115,9 +118,15 @@ libbsp_a_SOURCES += clock/clock.c
> # Benchmark Timer
>
> # Misc
> +libbsp_a_SOURCES += misc/cpucounterread.c
>
> # Watchdog
>
> +# Cache
> +libbsp_a_SOURCES += ../../../libcpu/shared/src/cache_manager.c
> +libbsp_a_SOURCES += ../../../libcpu/arm/shared/include/cache_.h
> +libbsp_a_CPPFLAGS += -I$(srcdir)/../../../libcpu/arm/shared/include
> +
> # Start hooks
> libbsp_a_SOURCES += startup/bspstarthooks.c
>
> diff --git a/c/src/lib/libbsp/arm/tms570/clock/benchmark_timer.c b/c/src/lib/libbsp/arm/tms570/clock/benchmark_timer.c
> new file mode 100644
> index 0000000..b45f0f4
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/tms570/clock/benchmark_timer.c
> @@ -0,0 +1,61 @@
> +/**
> + * @file benchmark_timer.c
> + *
> + * @ingroup tms570
> + *
> + * @brief clock functions definitions.
> + */
> +
> +/*
> + * Copyright (c) 2014 Pavel Pisa <pisa at cmp.felk.cvut.cz>
> + *
> + * Czech Technical University in Prague
> + * Zikova 1903/4
> + * 166 36 Praha 6
> + * Czech Republic
> + *
> + * Based on LPC24xx and LPC1768 BSP
> + * by embedded brains GmbH and others
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.org/license/LICENSE.
> + */
> +
> +#include <stdlib.h>
> +
> +#include <rtems.h>
> +#include <bsp.h>
> +#include <bsp/system-clocks.h>
> +#include <rtems/btimer.h>
> +#include <rtems/timerdrv.h>
> +
> +bool benchmark_timer_find_average_overhead = false;
> +
> +static uint32_t benchmark_timer_base;
> +
> +void benchmark_timer_initialize(void)
> +{
> + benchmark_timer_base = _CPU_Counter_read();
> +}
> +
> +uint32_t benchmark_timer_read(void)
> +{
> + uint32_t delta = _CPU_Counter_read() - benchmark_timer_base;
> +
> + if (benchmark_timer_find_average_overhead) {
> + return delta;
> + } else {
> + /* TODO check on hardware */
> + if (delta > 74) {
> + return delta - 74;
> + } else {
> + return 0;
> + }
> + }
> +}
> +
> +void benchmark_timer_disable_subtracting_average_overhead(bool find_average_overhead )
> +{
> + benchmark_timer_find_average_overhead = find_average_overhead;
> +}
> diff --git a/c/src/lib/libbsp/arm/tms570/clock/clock.c b/c/src/lib/libbsp/arm/tms570/clock/clock.c
> index 2a8bb5f..4dba949 100644
> --- a/c/src/lib/libbsp/arm/tms570/clock/clock.c
> +++ b/c/src/lib/libbsp/arm/tms570/clock/clock.c
> @@ -29,6 +29,7 @@
> #include <bsp.h>
> #include <bsp/irq.h>
> #include <bsp/tms570-rti.h>
> +#include <rtems/counter.h>
>
> /**
> * holds HW counter value since last interrupt event
> @@ -49,6 +50,8 @@ static void tms570_clock_driver_support_initialize_hardware( void )
>
> uint32_t microsec_per_tick = rtems_configuration_get_microseconds_per_tick();
>
> + rtems_counter_initialize_converter(BSP_PLL_OUT_CLOCK);
> +
> /* Hardware specific initialize */
> TMS570_RTI.RTIGCTRL = 0;
> TMS570_RTI.RTICPUC0 = BSP_PLL_OUT_CLOCK /1000000 / 2; /* prescaler */
> @@ -80,7 +83,6 @@ static void tms570_clock_driver_support_at_tick( void )
> {
> TMS570_RTI.RTIINTFLAG = 0x00000001;
> tms570_rti_last_tick_fcr0 = TMS570_RTI.RTICOMP0 - TMS570_RTI.RTIUDCP0;
> - /* TMS570_RTI.RTICOMP0 += 1000; */
> }
>
> /**
> diff --git a/c/src/lib/libbsp/arm/tms570/include/system-clocks.h b/c/src/lib/libbsp/arm/tms570/include/system-clocks.h
> new file mode 100644
> index 0000000..d441ec4
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/tms570/include/system-clocks.h
> @@ -0,0 +1,62 @@
> +/**
> + * @file benchmark_timer.c
> + *
> + * @ingroup tms570
> + *
> + * @brief System clocks.
> + */
> +
> +/*
> + * Copyright (c) 2014 Pavel Pisa <pisa at cmp.felk.cvut.cz>
> + *
> + * Czech Technical University in Prague
> + * Zikova 1903/4
> + * 166 36 Praha 6
> + * Czech Republic
> + *
> + * Based on LPC24xx and LPC1768 BSP
> + * by embedded brains GmbH and others
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.org/license/LICENSE.
> + */
> +
> +#ifndef LIBBSP_ARM_TMS570_SYSTEM_CLOCKS_H
> +#define LIBBSP_ARM_TMS570_SYSTEM_CLOCKS_H
> +
> +#include <bsp/tms570-rti.h>
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif /* __cplusplus */
> +
> +/**
> + * @defgroup tms570_clock System Clocks
> + *
> + * @ingroup tms570
> + *
> + * @brief System clocks.
> + *
> + * @{
> + */
> +
> +/**
> + * @brief Returns current standard timer value in microseconds.
> + *
> + * This function uses RTI module free running counter 0 used
> + * which is used as system tick timebase as well.
> + */
> +static inline unsigned tms570_timer(void)
> +{
> + uint32_t actual_fcr0 = TMS570_RTI.RTIFRC0;
> + return actual_fcr0;
> +}
> +
> +/** @} */
> +
> +#ifdef __cplusplus
> +}
> +#endif /* __cplusplus */
> +
> +#endif /* LIBBSP_ARM_TMS570_SYSTEM_CLOCKS_H */
> diff --git a/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk.cfg b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk.cfg
> index eb4a65f..e90414a 100644
> --- a/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk.cfg
> +++ b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk.cfg
> @@ -8,7 +8,7 @@ RTEMS_CPU = arm
>
> CPU_CFLAGS = -march=armv7-r -mthumb -mbig-endian
>
> -CFLAGS_OPTIMIZE_V = -O2 -ggdb3 -DNDEBUG
> +CFLAGS_OPTIMIZE_V = -O2 -ggdb
> BINEXT?=.bin
>
> # This defines the operations performed on the linked executable.
> diff --git a/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_intram.cfg b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_intram.cfg
> index eb4a65f..e90414a 100644
> --- a/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_intram.cfg
> +++ b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_intram.cfg
> @@ -8,7 +8,7 @@ RTEMS_CPU = arm
>
> CPU_CFLAGS = -march=armv7-r -mthumb -mbig-endian
>
> -CFLAGS_OPTIMIZE_V = -O2 -ggdb3 -DNDEBUG
> +CFLAGS_OPTIMIZE_V = -O2 -ggdb
> BINEXT?=.bin
>
> # This defines the operations performed on the linked executable.
> diff --git a/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_sdram.cfg b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_sdram.cfg
> index eb4a65f..e90414a 100644
> --- a/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_sdram.cfg
> +++ b/c/src/lib/libbsp/arm/tms570/make/custom/tms570ls3137_hdk_sdram.cfg
> @@ -8,7 +8,7 @@ RTEMS_CPU = arm
>
> CPU_CFLAGS = -march=armv7-r -mthumb -mbig-endian
>
> -CFLAGS_OPTIMIZE_V = -O2 -ggdb3 -DNDEBUG
> +CFLAGS_OPTIMIZE_V = -O2 -ggdb
> BINEXT?=.bin
>
> # This defines the operations performed on the linked executable.
> diff --git a/c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c b/c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c
> new file mode 100644
> index 0000000..f25380c
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/tms570/misc/cpucounterread.c
> @@ -0,0 +1,44 @@
> +/**
> + * @file
> + *
> + * @ingroup tms570_clocks
> + *
> + * @brief System clocks.
> + */
> +
> +/*
> + * Copyright (c) 2014 Pavel Pisa <pisa at cmp.felk.cvut.cz>
> + *
> + * Czech Technical University in Prague
> + * Zikova 1903/4
> + * 166 36 Praha 6
> + * Czech Republic
> + *
> + * Based on LPC24xx and LPC1768 BSP
> + * by embedded brains GmbH and others
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.org/license/LICENSE.
> + */
> +
> +#include <stdlib.h>
> +
> +#include <rtems.h>
> +#include <bsp.h>
> +
> +
> +/**
> + * @brief returns the actual value of Cortex-R cycle counter register
> + *
> + * The register is incremented at each core clock period
> + *
> + * @retval x actual core clock counter value
> + *
> + */
> +CPU_Counter_ticks _CPU_Counter_read(void)
> +{
> + uint32_t ticks;
> + asm volatile ("mrc p15, 0, %0, c9, c13, 0\n": "=r" (ticks));
> + return ticks;
> +}
> diff --git a/c/src/lib/libbsp/arm/tms570/preinstall.am b/c/src/lib/libbsp/arm/tms570/preinstall.am
> index 81dbad1..d7ac628 100644
> --- a/c/src/lib/libbsp/arm/tms570/preinstall.am
> +++ b/c/src/lib/libbsp/arm/tms570/preinstall.am
> @@ -109,6 +109,10 @@ $(PROJECT_INCLUDE)/bsp/tms570-sci-driver.h: include/tms570-sci-driver.h $(PROJEC
> $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/tms570-sci-driver.h
> PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/tms570-sci-driver.h
>
> +$(PROJECT_INCLUDE)/bsp/system-clocks.h: include/system-clocks.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> + $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/system-clocks.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/system-clocks.h
> +
> $(PROJECT_INCLUDE)/tm27.h: ../../shared/include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
> $(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
> PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
--
Joel Sherrill, Ph.D. Director of Research & Development
joel.sherrill at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the devel
mailing list