mx6ulevk BSP was: Re: [PATCH] arm: mx6ulevk: Initial BSP support for i.MX 6UltraLite EVK board.

Thomas Doerfler thomas.doerfler at embedded-brains.de
Mon Aug 1 12:15:03 UTC 2016


Hi,

just out of curiosity (and because I might need a i.MX6 BSP for an
upcoming project):

What is the current state of the BSP? What are the plans for the near
future?

wkr,

Thomas.


Am 14.04.2016 um 11:49 schrieb Peng Fan:
> Initial BSP support for i.MX 6UltraLite EVK board.
> Add uart driver
> Add gpt driver to service tick function
> 
> The i.MX 6UltraLite is a high performance, ultra-efficient processor
> family featuring an advanced implementation of a single ARM® Cortex®-A7
> core, which operates at speeds up to 528 MHz. The i.MX 6UltraLite
> applications processor includes an integrated power management module
> that reduces the complexity of external power supply and simplifies
> power sequencing.
> 
> Now, clock management module and pinmux module not added,
> so relies the setting in U-Boot.
> ---
>  c/src/lib/libbsp/arm/acinclude.m4                  |   2 +
>  c/src/lib/libbsp/arm/mx6ulevk/Makefile.am          | 139 +++++++++++++++++
>  c/src/lib/libbsp/arm/mx6ulevk/README               |  28 ++++
>  c/src/lib/libbsp/arm/mx6ulevk/bsp_specs            |  13 ++
>  c/src/lib/libbsp/arm/mx6ulevk/configure.ac         |  34 +++++
>  .../libbsp/arm/mx6ulevk/console/console-config.c   |  82 +++++++++++
>  c/src/lib/libbsp/arm/mx6ulevk/console/imx-uart.c   | 131 ++++++++++++++++
>  c/src/lib/libbsp/arm/mx6ulevk/gpt.c                | 164 +++++++++++++++++++++
>  c/src/lib/libbsp/arm/mx6ulevk/include/bsp.h        | 121 +++++++++++++++
>  c/src/lib/libbsp/arm/mx6ulevk/include/imx6-gpt.h   |  48 ++++++
>  c/src/lib/libbsp/arm/mx6ulevk/include/imx6-uart.h  |  60 ++++++++
>  c/src/lib/libbsp/arm/mx6ulevk/include/irq.h        |  38 +++++
>  c/src/lib/libbsp/arm/mx6ulevk/include/tm27.h       |  24 +++
>  .../libbsp/arm/mx6ulevk/make/custom/mx6ulevk.cfg   |   9 ++
>  c/src/lib/libbsp/arm/mx6ulevk/preinstall.am        | 151 +++++++++++++++++++
>  c/src/lib/libbsp/arm/mx6ulevk/startup/bspreset.c   |  24 +++
>  c/src/lib/libbsp/arm/mx6ulevk/startup/bspstart.c   |  25 ++++
>  .../libbsp/arm/mx6ulevk/startup/bspstarthooks.c    |  70 +++++++++
>  .../libbsp/arm/mx6ulevk/startup/linkcmds.mx6ulevk  |  48 ++++++
>  19 files changed, 1211 insertions(+)
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/Makefile.am
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/README
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/bsp_specs
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/configure.ac
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/console/console-config.c
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/console/imx-uart.c
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/gpt.c
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/include/bsp.h
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/include/imx6-gpt.h
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/include/imx6-uart.h
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/include/irq.h
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/include/tm27.h
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/make/custom/mx6ulevk.cfg
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/preinstall.am
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/startup/bspreset.c
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/startup/bspstart.c
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/startup/bspstarthooks.c
>  create mode 100644 c/src/lib/libbsp/arm/mx6ulevk/startup/linkcmds.mx6ulevk
> 
> diff --git a/c/src/lib/libbsp/arm/acinclude.m4 b/c/src/lib/libbsp/arm/acinclude.m4
> index f5ca105..c15dc82 100644
> --- a/c/src/lib/libbsp/arm/acinclude.m4
> +++ b/c/src/lib/libbsp/arm/acinclude.m4
> @@ -26,6 +26,8 @@ AC_DEFUN([RTEMS_CHECK_BSPDIR],
>      AC_CONFIG_SUBDIRS([lpc24xx]);;
>    lpc32xx )
>      AC_CONFIG_SUBDIRS([lpc32xx]);;
> +  mx6ulevk )
> +    AC_CONFIG_SUBDIRS([mx6ulevk]);;
>    raspberrypi )
>      AC_CONFIG_SUBDIRS([raspberrypi]);;
>    realview-pbx-a9 )
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/Makefile.am b/c/src/lib/libbsp/arm/mx6ulevk/Makefile.am
> new file mode 100644
> index 0000000..517b524
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/Makefile.am
> @@ -0,0 +1,139 @@
> +##
> +#
> +# @file
> +#
> +# @brief Makefile of libBSP for the i.MX 6UltraLite EVK platform (Cortex-A7).
> +#
> +
> +ACLOCAL_AMFLAGS = -I ../../../../aclocal
> +
> +include $(top_srcdir)/../../../../automake/compile.am
> +
> +include_bspdir = $(includedir)/bsp
> +include_libcpudir = $(includedir)/libcpu
> +
> +dist_project_lib_DATA = bsp_specs
> +
> +###############################################################################
> +#                  Header                                                     #
> +###############################################################################
> +
> +include_HEADERS = include/bsp.h
> +include_HEADERS += ../../shared/include/tm27.h
> +
> +nodist_include_HEADERS = ../../shared/include/coverhd.h \
> +	include/bspopts.h
> +
> +nodist_include_bsp_HEADERS = ../../shared/include/bootcard.h
> +
> +include_bsp_HEADERS =
> +include_bsp_HEADERS += ../../shared/include/utility.h
> +include_bsp_HEADERS += ../../shared/include/irq-generic.h
> +include_bsp_HEADERS += ../../shared/include/irq-info.h
> +include_bsp_HEADERS += ../../shared/include/stackalloc.h
> +include_bsp_HEADERS += ../../shared/include/uart-output-char.h
> +include_bsp_HEADERS += ../shared/include/arm-a8core-start.h
> +include_bsp_HEADERS += ../shared/include/arm-cp15-start.h
> +include_bsp_HEADERS += ../shared/include/arm-errata.h
> +include_bsp_HEADERS += ../shared/include/arm-gic.h
> +include_bsp_HEADERS += ../shared/include/arm-gic-irq.h
> +include_bsp_HEADERS += ../shared/include/arm-gic-regs.h
> +include_bsp_HEADERS += ../shared/include/arm-gic-tm27.h
> +include_bsp_HEADERS += ../shared/include/arm-release-id.h
> +include_bsp_HEADERS += ../shared/include/start.h
> +include_bsp_HEADERS += include/irq.h
> +include_bsp_HEADERS += include/imx6-uart.h
> +include_bsp_HEADERS += include/imx6-gpt.h
> +
> +include_libcpu_HEADERS =
> +include_libcpu_HEADERS += ../../../libcpu/arm/shared/include/arm-cp15.h
> +
> +###############################################################################
> +#                  Data                                                       #
> +###############################################################################
> +
> +noinst_LIBRARIES = libbspstart.a
> +
> +libbspstart_a_SOURCES = ../shared/start/start.S
> +
> +project_lib_DATA = start.$(OBJEXT)
> +
> +project_lib_DATA += startup/linkcmds
> +project_lib_DATA += startup/linkcmds.mx6ulevk
> +
> +EXTRA_DIST = startup/linkcmds.mx6ulevk
> +
> +###############################################################################
> +#                  LibBSP                                                     #
> +###############################################################################
> +
> +noinst_LIBRARIES += libbsp.a
> +
> +libbsp_a_SOURCES =
> +libbsp_a_CPPFLAGS =
> +libbsp_a_LIBADD =
> +
> +# Shared
> +libbsp_a_SOURCES += ../../shared/bootcard.c
> +libbsp_a_SOURCES += ../../shared/bspclean.c
> +libbsp_a_SOURCES += ../../shared/bspgetworkarea.c
> +libbsp_a_SOURCES += ../../shared/bsppredriverhook.c
> +libbsp_a_SOURCES += ../../shared/cpucounterdiff.c
> +libbsp_a_SOURCES += ../../shared/gnatinstallhandler.c
> +libbsp_a_SOURCES += ../../shared/sbrk.c
> +libbsp_a_SOURCES += ../../shared/timerstub.c
> +libbsp_a_SOURCES += ../../shared/src/stackalloc.c
> +libbsp_a_SOURCES += ../shared/abort/simple_abort.c
> +libbsp_a_SOURCES += ../shared/startup/bsp-start-memcpy.S
> +libbsp_a_SOURCES += ../shared/arm-cp15-set-exception-handler.c
> +libbsp_a_SOURCES += ../shared/arm-cp15-set-ttb-entries.c
> +
> +# Startup
> +libbsp_a_SOURCES += startup/bspreset.c
> +libbsp_a_SOURCES += startup/bspstart.c
> +
> +# IRQ
> +libbsp_a_SOURCES += ../../shared/src/irq-default-handler.c
> +libbsp_a_SOURCES += ../../shared/src/irq-generic.c
> +libbsp_a_SOURCES += ../../shared/src/irq-info.c
> +libbsp_a_SOURCES += ../../shared/src/irq-legacy.c
> +libbsp_a_SOURCES += ../../shared/src/irq-server.c
> +libbsp_a_SOURCES += ../../shared/src/irq-shell.c
> +libbsp_a_SOURCES += ../shared/arm-gic-irq.c
> +
> +# Console
> +libbsp_a_SOURCES += ../../shared/console.c
> +libbsp_a_SOURCES += ../../shared/console_control.c
> +libbsp_a_SOURCES += ../../shared/console_read.c
> +libbsp_a_SOURCES += ../../shared/console_select_simple.c
> +libbsp_a_SOURCES += ../../shared/console_write.c
> +libbsp_a_SOURCES += ../../shared/console-output-char.c
> +libbsp_a_SOURCES += console/console-config.c
> +libbsp_a_SOURCES += console/imx-uart.c
> +
> +#I2C
> +
> +#GPIO
> +
> +#RTC
> +
> +# Clock
> +libbsp_a_SOURCES += ../../shared/clockdrv_shell.h
> +libbsp_a_SOURCES += gpt.c
> +
> +# 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
> +
> +###############################################################################
> +#                  Special Rules                                              #
> +###############################################################################
> +
> +DISTCLEANFILES = include/bspopts.h
> +
> +include $(srcdir)/preinstall.am
> +include $(top_srcdir)/../../../../automake/local.am
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/README b/c/src/lib/libbsp/arm/mx6ulevk/README
> new file mode 100644
> index 0000000..bca7661
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/README
> @@ -0,0 +1,28 @@
> +How to compile:
> +$mkdir b-rtems
> +$cd b-rtems
> +$../rtems-source/configure --target=arm-rtems4.12 --enable-tests --disable-networking
> +$gmake RTEMS_BSP="mx6ulevk"
> +
> +After compile:
> +$arm-rtems4.12-objcopy -O binary hello.exe hello.bin
> +$arm-rtems4.12-objcopy -O binary ticker.exe ticker.bin
> +
> +U-Boot source:
> +http://git.freescale.com/git/cgit.cgi/imx/uboot-imx.git/log/?h=imx_v2015.04_3.14.38_6ul_ga
> +Build U-Boot:
> +$export CROSS_COMPILE=arm-poky-linux-gnueabi-
> +$make ARCH=arm mx6ul_14x14_evk_config
> +$make
> +Burn u-boot.imx to offset 0x400 of sd card.
> +
> +How to run using U-Boot:
> +Run hello example
> +=>fatload mmc 1:1 0x80000000 hello.bin
> +=>dcache off; icache off; dcache flush; icache flush
> +=>go 0x80000000
> +
> +Or using tftp to load test bin
> +=>tftp 0x80000000 ticker.bin
> +=>dcache off; icache off; dcache flush; icache flush
> +=>go 0x80000000
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/bsp_specs b/c/src/lib/libbsp/arm/mx6ulevk/bsp_specs
> new file mode 100644
> index 0000000..32c105f
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/bsp_specs
> @@ -0,0 +1,13 @@
> +%rename endfile old_endfile
> +%rename startfile old_startfile
> +%rename link old_link
> +
> +*startfile:
> +%{!qrtems: %(old_startfile)} \
> +%{!nostdlib: %{qrtems: start.o%s crti.o%s crtbegin.o%s -e _start}}
> +
> +*link:
> +%{!qrtems: %(old_link)} %{qrtems: -dc -dp -N}
> +
> +*endfile:
> +%{!qrtems: %(old_endfiles)} %{qrtems: crtend.o%s crtn.o%s }
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/configure.ac b/c/src/lib/libbsp/arm/mx6ulevk/configure.ac
> new file mode 100644
> index 0000000..6f2d1e4
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/configure.ac
> @@ -0,0 +1,34 @@
> +##
> +#
> +# @file
> +#
> +# @brief Configure script of LibBSP for the i.MX 6UltraLite Processor.
> +#
> +
> +AC_PREREQ([2.69])
> +AC_INIT([rtems-c-src-lib-libbsp-arm-mx6ulevk],[_RTEMS_VERSION],[http://www.rtems.org/bugzilla])
> +AC_CONFIG_SRCDIR([bsp_specs])
> +RTEMS_TOP(../../../../../..)
> +
> +RTEMS_CANONICAL_TARGET_CPU
> +AM_INIT_AUTOMAKE([no-define nostdinc foreign 1.12.2])
> +RTEMS_BSP_CONFIGURE
> +
> +RTEMS_PROG_CC_FOR_TARGET
> +RTEMS_CANONICALIZE_TOOLS
> +RTEMS_PROG_CCAS
> +
> +RTEMS_CHECK_NETWORKING
> +AM_CONDITIONAL(HAS_NETWORKING,test "$HAS_NETWORKING" = "yes")
> +
> +RTEMS_BSPOPTS_SET([BSP_START_RESET_VECTOR],[*],[])
> +RTEMS_BSPOPTS_HELP([BSP_START_RESET_VECTOR],[reset vector address for BSP start])
> +
> +RTEMS_BSPOPTS_SET([BSP_CONSOLE_MINOR],[*],[0])
> +RTEMS_BSPOPTS_HELP([BSP_CONSOLE_MINOR],[minor number of console device])
> +
> +RTEMS_BSP_CLEANUP_OPTIONS(0, 1)
> +RTEMS_BSP_LINKCMDS
> +
> +AC_CONFIG_FILES([Makefile])
> +AC_OUTPUT
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/console/console-config.c b/c/src/lib/libbsp/arm/mx6ulevk/console/console-config.c
> new file mode 100644
> index 0000000..cc6b074
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/console/console-config.c
> @@ -0,0 +1,82 @@
> +/*
> + * Copyright (c) 2016 Peng Fan <van.freenix at gmail.com>
> + *
> + * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
> + *
> + *  embedded brains GmbH
> + *  Dornierstr. 4
> + *  82178 Puchheim
> + *  Germany
> + *  <info at embedded-brains.de>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.com/license/LICENSE.
> + */
> +
> +#include <libchip/serial.h>
> +
> +#include <bsp.h>
> +#include <bsp/irq.h>
> +
> +extern const console_fns imx_uart_fns;
> +console_tbl Console_Configuration_Ports[] = {
> +   {
> +    .sDeviceName = "/dev/ttyS0",
> +    .deviceType = SERIAL_CUSTOM,
> +    .pDeviceFns = &imx_uart_fns,
> +    .deviceProbe = NULL,
> +    .pDeviceFlow = NULL,
> +    .ulMargin = 0,
> +    .ulHysteresis = 0,
> +    .pDeviceParams = (void *) 115200,
> +    .ulCtrlPort1 = UART_BASE,
> +    .ulCtrlPort2 = 0,
> +    .ulDataPort = 0,
> +    .getRegister = NULL,
> +    .setRegister = NULL,
> +    .getData = NULL,
> +    .setData = NULL,
> +    .ulClock = 0,
> +    .ulIntVector = UART_IRQ
> +  }
> +};
> +
> +unsigned long Console_Configuration_Count =
> +  RTEMS_ARRAY_SIZE(Console_Configuration_Ports);
> +
> +static void output_char(char c)
> +{
> +  int minor = (int) Console_Port_Minor;
> +  const console_tbl *ct = Console_Port_Tbl != NULL ?
> +    Console_Port_Tbl[minor] : &Console_Configuration_Ports[minor];
> +  const console_fns *cf = ct->pDeviceFns;
> +
> +  if (c == '\n') {
> +    (*cf->deviceWritePolled)(minor, '\r');
> +  }
> +
> +  (*cf->deviceWritePolled)(minor, c);
> +}
> +
> +static void output_char_init(char c)
> +{
> +  if (Console_Port_Tbl == NULL) {
> +    int minor;
> +    const console_fns *cf;
> +
> +    bsp_console_select();
> +
> +    minor = (int) Console_Port_Minor;
> +    cf = Console_Configuration_Ports[minor].pDeviceFns;
> +
> +    (*cf->deviceInitialize)(minor);
> +  }
> +
> +  BSP_output_char = output_char;
> +  output_char(c);
> +}
> +
> +BSP_output_char_function_type BSP_output_char = output_char_init;
> +
> +BSP_polling_getchar_function_type BSP_poll_char = NULL;
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/console/imx-uart.c b/c/src/lib/libbsp/arm/mx6ulevk/console/imx-uart.c
> new file mode 100644
> index 0000000..dd7f8ae
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/console/imx-uart.c
> @@ -0,0 +1,131 @@
> +/*
> + * Copyright (c) 2016 Peng Fan <van.freenix at gmail.com>.
> + *
> + * 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 <bspopts.h>
> +
> +#include <libchip/serial.h>
> +#include <libchip/sersupp.h>
> +
> +#include <bsp.h>
> +#include <bsp/irq.h>
> +#include <bsp/utility.h>
> +#include <bsp/uart-output-char.h>
> +
> +#include <bsp/imx6-uart.h>
> +
> +static uint32_t imx_uart_get_regs(int minor)
> +{
> +  const console_tbl *ct = Console_Port_Tbl != NULL ?
> +    Console_Port_Tbl[minor] : &Console_Configuration_Ports[minor];
> +
> +  return ct->ulCtrlPort1;
> +}
> +
> +/* Make weak and let the user override. */
> +uint32_t imx_uart_input_clock(void) __attribute__ ((weak));
> +
> +uint32_t imx_uart_input_clock(void)
> +{
> +  /*
> +   * Now we use clock set from U-Boot, 80M.
> +   * TODO:
> +   *   Handling clock
> +   */
> +  return 80000000;
> +}
> +
> +static int imx_calculate_baudrate(uint32_t  baudrate,
> +                                  uint32_t* brgr,
> +                                  uint32_t* bauddiv,
> +                                  uint32_t  modereg)
> +{
> +  /*
> +   * Use the initialized baudrate from U-Boot.
> +   * TODO:
> +   *   Add baudrate handling
> +   */
> +  return 0;
> +}
> +
> +static void imx_uart_initialize(int minor)
> +{
> +  /* TODO */
> +}
> +
> +static int imx_uart_first_open(int major, int minor, void *arg)
> +{
> +  rtems_libio_open_close_args_t *oc = (rtems_libio_open_close_args_t *) arg;
> +  struct rtems_termios_tty *tty = (struct rtems_termios_tty *) oc->iop->data1;
> +  console_data *cd = &Console_Port_Data[minor];
> +  const console_tbl *ct = Console_Port_Tbl[minor];
> +
> +  cd->termios_data = tty;
> +  rtems_termios_set_initial_baud(tty, (rtems_termios_baud_t) ct->pDeviceParams);
> +
> +  return 0;
> +}
> +
> +static int imx_uart_last_close(int major, int minor, void *arg)
> +{
> +  return 0;
> +}
> +
> +static int imx_uart_read_polled(int minor)
> +{
> +  uint32_t reg_base = imx_uart_get_regs(minor);
> +
> +  while (readl(reg_base + UTS_OFF) & UTS_RXEMPTY)
> +    ;
> +
> +  return (readl(reg_base + URXD_OFF) & URXD_RX_DATA);
> +}
> +
> +static void imx_uart_write_polled(int minor, char c)
> +{
> +  uint32_t reg_base = imx_uart_get_regs(minor);
> +
> +  writel(c, reg_base + UTXD_OFF);
> +
> +  while (!(readl(reg_base + UTS_OFF) & UTS_TXEMPTY))
> +    ;
> +
> +  if (c == '\n')
> +    imx_uart_write_polled(minor, '\r');
> +}
> +
> +static ssize_t imx_uart_write_support_polled(
> +  int minor,
> +  const char *s,
> +  size_t n
> +)
> +{
> +  ssize_t i = 0;
> +
> +  for (i = 0; i < n; ++i) {
> +    imx_uart_write_polled(minor, s[i]);
> +  }
> +
> +  return n;
> +}
> +
> +static int imx_uart_set_attribues(int minor, const struct termios *term)
> +{
> +  return -1;
> +}
> +
> +const console_fns imx_uart_fns = {
> +  .deviceProbe = libchip_serial_default_probe,
> +  .deviceFirstOpen = imx_uart_first_open,
> +  .deviceLastClose = imx_uart_last_close,
> +  .deviceRead = imx_uart_read_polled,
> +  .deviceWrite = imx_uart_write_support_polled,
> +  .deviceInitialize = imx_uart_initialize,
> +  .deviceWritePolled = imx_uart_write_polled,
> +  .deviceSetAttributes = imx_uart_set_attribues,
> +  .deviceOutputUsesInterrupts = false
> +};
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/gpt.c b/c/src/lib/libbsp/arm/mx6ulevk/gpt.c
> new file mode 100644
> index 0000000..47b1659
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/gpt.c
> @@ -0,0 +1,164 @@
> +/*
> + * Copyright (c) 2016 Peng Fan <van.freenix at gmail.com>.
> + *
> + * 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 <rtems.h>
> +#include <rtems/timecounter.h>
> +#include <bsp.h>
> +
> +#include <bsp/irq.h>
> +
> +#include <bsp/imx6-gpt.h>
> +
> +static imx6_gpt_timer_t gpt_timer = {
> +  .base = GPT_TIMER_BASE,
> +  .irq_nr = GPT_IRQ,
> +};
> +
> +static struct timecounter gpt_clock_tc;
> +static struct imx6_gpt_timer *timer = &gpt_timer;
> +
> +static uint32_t gpt_clock_get_timecount(struct timecounter *tc)
> +{
> +  return readl(timer->base + GPT_CNT);
> +}
> +
> +static inline void gpt_irq_enable(void)
> +{
> +  writel(1 << 0, timer->base + GPT_IR);
> +}
> +
> +static inline void gpt_irq_disable(void)
> +{
> +  writel(0, timer->base + GPT_IR);
> +}
> +
> +static inline void gpt_irq_ack(void)
> +{
> +  writel(TSTAT_OF1, timer->base + GPT_SR);
> +}
> +
> +static void gpt_clock_initialize(void)
> +{
> +  uint32_t gpt_cr;
> +  uint32_t tprer_val, cur_cnt;
> +  uint32_t interval = 3 * rtems_configuration_get_microseconds_per_tick();
> +
> +  /* Software reset */
> +  writel(1 << 15, timer->base + GPT_CR);
> +  /* Dead loop until reset finished */
> +  while (readl(timer->base + GPT_CR) & (1 << 15));
> +
> +  writel(0, timer->base + GPT_CR);
> +  writel(0, timer->base + GPT_PR);
> +
> +  gpt_cr = TCTL_CLK_OSC_DIV8 | TCTL_FRR | TCTL_WAITEN | TCTL_TEN;
> +  gpt_cr |= TCTL_24MEN;
> +
> +  /* 3M = 24M / 8*/
> +  tprer_val = 7 << TPRER_PRE24M;
> +  writel(tprer_val, timer->base + GPT_PR);
> +
> +  writel(gpt_cr, timer->base + GPT_CR);
> +
> +  /* Install timecounter */ \
> +  gpt_clock_tc.tc_get_timecount = gpt_clock_get_timecount;
> +  gpt_clock_tc.tc_counter_mask = 0xffffffff;
> +  /* Runs at 3M */
> +  gpt_clock_tc.tc_frequency = 3000000;
> +  gpt_clock_tc.tc_quality = RTEMS_TIMECOUNTER_QUALITY_CLOCK_DRIVER;
> +  rtems_timecounter_install(&gpt_clock_tc);
> +
> +  /* Clear pending interrupt */
> +  gpt_irq_ack();
> +
> +  /* Fill the value to trigger the tick compare event */
> +  cur_cnt = readl(timer->base + GPT_CNT);
> +  writel(cur_cnt + interval, timer->base + GPT_OCR1);
> +
> +  /* Enable interrupt */
> +  gpt_irq_enable();
> +}
> +
> +static void gpt_clock_at_tick(void)
> +{
> +  uint32_t gpt_cnt;
> +  /*
> +   * The GPT runs at 3M.
> +   *
> +   *             rtems_configuration_get_microseconds_per_tick
> +   * interval =         ----------------------
> +   *                      1000000 / 3000000
> +   */
> +  uint32_t interval = 3 * rtems_configuration_get_microseconds_per_tick();
> +
> +  gpt_irq_disable();
> +  gpt_irq_ack();
> +
> +  gpt_cnt = readl(timer->base + GPT_CNT);
> +  writel(gpt_cnt + interval, timer->base + GPT_OCR1);
> +
> +  gpt_irq_enable();
> +}
> +
> +CPU_Counter_ticks _CPU_Counter_read(void)
> +{
> +  return gpt_clock_get_timecount(NULL);
> +}
> +
> +static rtems_interrupt_handler clock_isr = NULL;
> +
> +static void gpt_clock_handler_install(rtems_interrupt_handler isr)
> +{
> +  rtems_status_code sc = RTEMS_SUCCESSFUL;
> +
> +  sc = rtems_interrupt_handler_install(
> +    timer->irq_nr,
> +    "Clock",
> +    RTEMS_INTERRUPT_UNIQUE,
> +    isr,
> +    NULL
> +  );
> +
> +  if (sc != RTEMS_SUCCESSFUL) {
> +    rtems_fatal_error_occurred(0xdeadbeef);
> +  }
> +  clock_isr = isr;
> +}
> +
> +static void gpt_clock_cleanup(void)
> +{
> +  rtems_status_code sc = RTEMS_SUCCESSFUL;
> +
> +  gpt_irq_ack();
> +
> +  gpt_irq_disable();
> +
> +  /* Remove interrupt handler */
> +  sc = rtems_interrupt_handler_remove(
> +    timer->irq_nr,
> +    clock_isr,
> +    NULL
> +  );
> +  if (sc != RTEMS_SUCCESSFUL) {
> +    rtems_fatal_error_occurred(0xdeadbeef);
> +  }
> +  clock_isr = NULL;
> +}
> +
> +#define Clock_driver_support_at_tick() gpt_clock_at_tick()
> +#define Clock_driver_support_initialize_hardware() gpt_clock_initialize()
> +#define Clock_driver_support_install_isr(isr, old_isr) \
> +  do {                   \
> +    gpt_clock_handler_install(isr);          \
> +    old_isr = NULL;              \
> +  } while (0)
> +
> +#define Clock_driver_support_shutdown_hardware() gpt_clock_cleanup()
> +
> +/* Include shared source clock driver code */
> +#include "../../shared/clockdrv_shell.h"
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/include/bsp.h b/c/src/lib/libbsp/arm/mx6ulevk/include/bsp.h
> new file mode 100644
> index 0000000..516294a
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/include/bsp.h
> @@ -0,0 +1,121 @@
> +/*
> + * Copyright (c) 2016 Peng Fan <van.freenix at gmail.com>.
> + *
> + * 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_MX6ULEVK_BSP_H
> +#define LIBBSP_ARM_MX6ULEVK_BSP_H
> +
> +#include <bspopts.h>
> +#include <stdint.h>
> +#include <bsp/start.h>
> +#include <bsp/default-initial-extension.h>
> +
> +#include <rtems.h>
> +#include <rtems/irq-extension.h>
> +
> +#define BSP_FEATURE_IRQ_EXTENSION
> +
> +/* Access memory-mapped I/O devices */
> +#define mmio_read(a)    (*(volatile uint32_t *)(a))
> +#define mmio_write(a,v) (*(volatile uint32_t *)(a) = (v))
> +#define mmio_set(a,v)   mmio_write((a), mmio_read((a)) | (v))
> +#define mmio_clear(a,v) mmio_write((a), mmio_read((a)) & ~(v))
> +
> +#define REG16(x)(*((volatile uint16_t *)(x)))
> +#define REG(x)(*((volatile uint32_t *)(x)))
> +#define BIT(x)(0x1 << x)
> +
> +#define udelay(u) rtems_task_wake_after(1 + ((u)/rtems_configuration_get_microseconds_per_tick()))
> +
> +/* Write a uint32_t value to a memory address. */
> +static inline void
> +write32(uint32_t address, uint32_t value)
> +{
> +    REG(address) = value;
> +}
> +
> +/* Read an uint32_t from a memory address */
> +static inline uint32_t
> +read32(uint32_t address)
> +{
> +    return REG(address);
> +}
> +
> +/* Set a 32 bits value depending on a mask */
> +static inline void
> +set32(uint32_t address, uint32_t mask, uint32_t value)
> +{
> +    uint32_t val;
> +    val = read32(address);
> +    /* clear the bits */
> +    val &= ~(mask);
> +    /* apply the value using the mask */
> +    val |= (value & mask);
> +    write32(address, val);
> +}
> +
> +/* Write a uint16_t value to a memory address. */
> +static inline void
> +write16(uint32_t address, uint16_t value)
> +{
> +    REG16(address) = value;
> +}
> +
> +/* Read an uint16_t from a memory address */
> +static inline uint16_t
> +read16(uint32_t address)
> +{
> +    return REG16(address);
> +}
> +
> +/* Data synchronization barrier */
> +static inline void dsb(void)
> +{
> +    asm volatile("dsb" : : : "memory");
> +}
> +
> +/* Instruction synchronization barrier */
> +static inline void isb(void)
> +{
> +    asm volatile("isb" : : : "memory");
> +}
> +
> +/* flush data cache */
> +static inline void flush_data_cache(void)
> +{
> +    asm volatile(
> +        "mov r0, #0\n"
> +        "mcr p15, #0, r0, c7, c10, #4\n"
> +        : /* No outputs */
> +        : /* No inputs */
> +        : "r0","memory"
> +    );
> +}
> +
> +#define __arch_getb(a)      (*(volatile unsigned char *)(a))
> +#define __arch_getw(a)      (*(volatile unsigned short *)(a))
> +#define __arch_getl(a)      (*(volatile unsigned int *)(a))
> +
> +#define __arch_putb(v,a)    (*(volatile unsigned char *)(a) = (v))
> +#define __arch_putw(v,a)    (*(volatile unsigned short *)(a) = (v))
> +#define __arch_putl(v,a)    (*(volatile unsigned int *)(a) = (v))
> +
> +#define writeb(v,c) ({ unsigned char  __v = v; __arch_putb(__v,c); __v; })
> +#define writew(v,c) ({ unsigned short __v = v; __arch_putw(__v,c); __v; })
> +#define writel(v,c) ({ unsigned int __v = v; __arch_putl(__v,c); __v; })
> +
> +#define readb(c)  ({ unsigned char  __v = __arch_getb(c); __v; })
> +#define readw(c)  ({ unsigned short __v = __arch_getw(c); __v; })
> +#define readl(c)  ({ unsigned int __v = __arch_getl(c); __v; })
> +
> +#define BSP_ARM_GIC_DIST_BASE 0x00a01000
> +#define BSP_ARM_GIC_CPUIF_BASE 0x00a02000
> +
> +#define GPT_TIMER_BASE 0x02098000                                        
> +#define UART_BASE 0x02020000
> +
> +#endif /* LIBBSP_ARM_BEAGLE_BSP_H */
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/include/imx6-gpt.h b/c/src/lib/libbsp/arm/mx6ulevk/include/imx6-gpt.h
> new file mode 100644
> index 0000000..6ce9c15
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/include/imx6-gpt.h
> @@ -0,0 +1,48 @@
> +/*
> + * Copyright (c) 2016 Peng Fan <van.freenix at gmail.com>.
> + *
> + * 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_MX6ULEVK_GPT_H
> +#define LIBBSP_ARM_MX6ULEVK_GPT_H
> +
> +#include <stdint.h>
> +
> +/* i.MX6 GPT register bit definition */
> +#define TCTL_WAITEN          (1 << 3)
> +#define TCTL_CLK_IPG         (1 << 6)
> +#define TCTL_CLK_PER         (2 << 6)
> +#define TCTL_CLK_OSC_DIV8    (5 << 6)
> +#define TCTL_CLK_OSC         (7 << 6)
> +#define TCTL_24MEN           (1 << 10)
> +#define TCTL_FRR             (1 << 9)
> +#define TPRER_PRE24M         12
> +#define IR                   0x0c
> +#define TSTAT                0x08
> +#define TSTAT_OF1            (1 << 0)
> +#define TCN                  0x24
> +#define TCMP                 0x10
> +#define TCTL_TEN            (1 << 0) /* Enable module */
> +
> +/* Register offset */
> +#define GPT_CR   0x0
> +#define GPT_PR   0x4
> +#define GPT_SR   0x8
> +#define GPT_IR   0xC
> +#define GPT_OCR1 0x10
> +#define GPT_OCR2 0x14
> +#define GPT_OCR3 0x18
> +#define GPT_ICR1 0x1C
> +#define GPT_ICR2 0x20
> +#define GPT_CNT  0x24
> +
> +typedef struct imx6_gpt_timer
> +{
> +  uint32_t base;
> +  int irq_nr;
> +} imx6_gpt_timer_t;
> +
> +#endif
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/include/imx6-uart.h b/c/src/lib/libbsp/arm/mx6ulevk/include/imx6-uart.h
> new file mode 100644
> index 0000000..cbce66a
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/include/imx6-uart.h
> @@ -0,0 +1,60 @@
> +/*
> + * Copyright (c) 2016 Peng Fan <van.freenix at gmail.com>.
> + *
> + * 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_MX6ULEVK_UART_REGS_H
> +#define LIBBSP_ARM_MX6ULEVK_UART_REGS_H
> +
> +/* Register offset */
> +#define URXD_OFF  0x0
> +#define UTXD_OFF  0x40
> +#define UCR1_OFF  0x80
> +#define UCR2_OFF  0x84
> +#define UCR3_OFF  0x88
> +#define UCR4_OFF  0x8c
> +#define UFCR_OFF  0x90
> +#define USR1_OFF  0x94
> +#define USR2_OFF  0x98
> +#define UESC_OFF  0x9c
> +#define UTIM_OFF  0xa0
> +#define UBIR_OFF  0xa4
> +#define UBMR_OFF  0xa8
> +#define UBRC_OFF  0xac
> +#define ONEMS_OFF 0xb0
> +#define UTS_OFF   0xb4
> +
> +/* Register Bit Fields.*/
> +#define  URXD_CHARRDY    (1<<15)
> +#define  URXD_ERR        (1<<14)
> +#define  URXD_OVRRUN     (1<<13)
> +#define  URXD_FRMERR     (1<<12)
> +#define  URXD_BRK        (1<<11)
> +#define  URXD_PRERR      (1<<10)
> +#define  URXD_RX_DATA    (0xFF)
> +#define  UCR1_ADEN       (1<<15)
> +#define  UCR1_ADBR       (1<<14)
> +#define  UCR1_TRDYEN     (1<<13)
> +#define  UCR1_IDEN       (1<<12)
> +#define  UCR1_RRDYEN     (1<<9)
> +#define  UCR1_RDMAEN     (1<<8)
> +#define  UCR1_IREN       (1<<7)
> +#define  UCR1_TXMPTYEN   (1<<6)
> +#define  UCR1_RTSDEN     (1<<5)
> +#define  UCR1_SNDBRK     (1<<4)
> +#define  UCR1_TDMAEN     (1<<3)
> +#define  UCR1_UARTCLKEN  (1<<2)
> +#define  UCR1_DOZE       (1<<1)
> +#define  UCR1_UARTEN     (1<<0)
> +#define  UTS_FRCPERR	 (1<<13)
> +#define  UTS_LOOP        (1<<12)
> +#define  UTS_TXEMPTY	 (1<<6)
> +#define  UTS_RXEMPTY	 (1<<5)
> +#define  UTS_TXFULL	 (1<<4)
> +#define  UTS_RXFULL	 (1<<3)
> +#define  UTS_SOFTRST	 (1<<0)
> +
> +#endif
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/include/irq.h b/c/src/lib/libbsp/arm/mx6ulevk/include/irq.h
> new file mode 100644
> index 0000000..ff75953
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/include/irq.h
> @@ -0,0 +1,38 @@
> +/*
> + * Copyright (c) 2016 Peng Fan <van.freenix at gmail.com>.
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.com/license/LICENSE.
> + */
> +
> +#ifndef LIBBSP_ARM_MX6ULEVK_IRQ_H
> +#define LIBBSP_ARM_MX6ULEVK_IRQ_H
> +
> +#ifndef ASM
> +
> +#include <rtems/irq.h>
> +#include <rtems/irq-extension.h>
> +
> +#include <bsp/arm-gic-irq.h>
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif /* __cplusplus */
> +
> +/*
> + * Interrupt Vector numbers
> + */
> +#define UART_IRQ 58
> +#define GPT_IRQ 87
> +
> +#define BSP_INTERRUPT_VECTOR_MIN 0                                              
> +#define BSP_INTERRUPT_VECTOR_MAX 158
> +
> +#ifdef __cplusplus
> +}
> +#endif /* __cplusplus */
> +
> +#endif /* ASM */
> +
> +#endif /* LIBBSP_ARM_MX6ULEVK_IRQ_H */
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/include/tm27.h b/c/src/lib/libbsp/arm/mx6ulevk/include/tm27.h
> new file mode 100644
> index 0000000..96ab469
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/include/tm27.h
> @@ -0,0 +1,24 @@
> +/*
> + * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
> + *
> + *  embedded brains GmbH
> + *  Dornierstr. 4
> + *  82178 Puchheim
> + *  Germany
> + *  <info at embedded-brains.de>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.com/license/LICENSE.
> + */
> +
> +#ifndef _RTEMS_TMTEST27
> +#error "This is an RTEMS internal file you must not include directly."
> +#endif
> +
> +#ifndef __tm27_h
> +#define __tm27_h
> +
> +#include <bsp/arm-gic-tm27.h>
> +
> +#endif /* __tm27_h */
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/make/custom/mx6ulevk.cfg b/c/src/lib/libbsp/arm/mx6ulevk/make/custom/mx6ulevk.cfg
> new file mode 100644
> index 0000000..162e1ad
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/make/custom/mx6ulevk.cfg
> @@ -0,0 +1,9 @@
> +include $(RTEMS_ROOT)/make/custom/default.cfg
> +
> +RTEMS_CPU_MODEL=mx6
> +
> +RTEMS_CPU = arm
> +
> +CPU_CFLAGS = -march=armv7-a -mfpu=neon -mfloat-abi=soft -mtune=cortex-a7
> +
> +CFLAGS_OPTIMIZE_V ?= -O0 -g
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/preinstall.am b/c/src/lib/libbsp/arm/mx6ulevk/preinstall.am
> new file mode 100644
> index 0000000..7a0dee4
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/preinstall.am
> @@ -0,0 +1,151 @@
> +## Automatically generated by ampolish3 - Do not edit
> +
> +if AMPOLISH3
> +$(srcdir)/preinstall.am: Makefile.am
> +	$(AMPOLISH3) $(srcdir)/Makefile.am > $(srcdir)/preinstall.am
> +endif
> +
> +PREINSTALL_DIRS =
> +DISTCLEANFILES += $(PREINSTALL_DIRS)
> +
> +all-local: $(TMPINSTALL_FILES)
> +
> +TMPINSTALL_FILES =
> +CLEANFILES = $(TMPINSTALL_FILES)
> +
> +all-am: $(PREINSTALL_FILES)
> +
> +PREINSTALL_FILES =
> +CLEANFILES += $(PREINSTALL_FILES)
> +
> +$(PROJECT_LIB)/$(dirstamp):
> +	@$(MKDIR_P) $(PROJECT_LIB)
> +	@: > $(PROJECT_LIB)/$(dirstamp)
> +PREINSTALL_DIRS += $(PROJECT_LIB)/$(dirstamp)
> +
> +$(PROJECT_INCLUDE)/$(dirstamp):
> +	@$(MKDIR_P) $(PROJECT_INCLUDE)
> +	@: > $(PROJECT_INCLUDE)/$(dirstamp)
> +PREINSTALL_DIRS += $(PROJECT_INCLUDE)/$(dirstamp)
> +
> +$(PROJECT_INCLUDE)/bsp/$(dirstamp):
> +	@$(MKDIR_P) $(PROJECT_INCLUDE)/bsp
> +	@: > $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +PREINSTALL_DIRS += $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +
> +$(PROJECT_INCLUDE)/libcpu/$(dirstamp):
> +	@$(MKDIR_P) $(PROJECT_INCLUDE)/libcpu
> +	@: > $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
> +PREINSTALL_DIRS += $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
> +
> +$(PROJECT_LIB)/bsp_specs: bsp_specs $(PROJECT_LIB)/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_LIB)/bsp_specs
> +PREINSTALL_FILES += $(PROJECT_LIB)/bsp_specs
> +
> +$(PROJECT_INCLUDE)/bsp.h: include/bsp.h $(PROJECT_INCLUDE)/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp.h
> +
> +$(PROJECT_INCLUDE)/bsp/imx6-gpt.h: include/imx6-gpt.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/imx6-gpt.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/imx6-gpt.h
> +
> +$(PROJECT_INCLUDE)/bsp/imx6-uart.h: include/imx6-uart.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/imx6-uart.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/imx6-uart.h
> +
> +$(PROJECT_INCLUDE)/tm27.h: include/tm27.h $(PROJECT_INCLUDE)/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/tm27.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/tm27.h
> +
> +$(PROJECT_INCLUDE)/coverhd.h: ../../shared/include/coverhd.h $(PROJECT_INCLUDE)/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/coverhd.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/coverhd.h
> +
> +$(PROJECT_INCLUDE)/bspopts.h: include/bspopts.h $(PROJECT_INCLUDE)/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bspopts.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bspopts.h
> +
> +$(PROJECT_INCLUDE)/bsp/bootcard.h: ../../shared/include/bootcard.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/bootcard.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/bootcard.h
> +
> +$(PROJECT_INCLUDE)/bsp/utility.h: ../../shared/include/utility.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/utility.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/utility.h
> +
> +$(PROJECT_INCLUDE)/bsp/irq-generic.h: ../../shared/include/irq-generic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-generic.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-generic.h
> +
> +$(PROJECT_INCLUDE)/bsp/irq-info.h: ../../shared/include/irq-info.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq-info.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq-info.h
> +
> +$(PROJECT_INCLUDE)/bsp/stackalloc.h: ../../shared/include/stackalloc.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/stackalloc.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/stackalloc.h
> +
> +$(PROJECT_INCLUDE)/bsp/uart-output-char.h: ../../shared/include/uart-output-char.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/uart-output-char.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/uart-output-char.h
> +
> +$(PROJECT_INCLUDE)/bsp/arm-a8core-start.h: ../shared/include/arm-a8core-start.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-a8core-start.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-a8core-start.h
> +
> +$(PROJECT_INCLUDE)/bsp/arm-cp15-start.h: ../shared/include/arm-cp15-start.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-cp15-start.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-cp15-start.h
> +
> +$(PROJECT_INCLUDE)/bsp/arm-errata.h: ../shared/include/arm-errata.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-errata.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-errata.h
> +
> +$(PROJECT_INCLUDE)/bsp/arm-release-id.h: ../shared/include/arm-release-id.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-release-id.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-release-id.h
> +
> +$(PROJECT_INCLUDE)/bsp/start.h: ../shared/include/start.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/start.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/start.h
> +
> +$(PROJECT_INCLUDE)/bsp/arm-gic.h: ../shared/include/arm-gic.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-gic.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-gic.h
> +
> +$(PROJECT_INCLUDE)/bsp/arm-gic-irq.h: ../shared/include/arm-gic-irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-gic-irq.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-gic-irq.h
> +
> +$(PROJECT_INCLUDE)/bsp/arm-gic-regs.h: ../shared/include/arm-gic-regs.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-gic-regs.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-gic-regs.h
> +
> +$(PROJECT_INCLUDE)/bsp/arm-gic-tm27.h: ../shared/include/arm-gic-tm27.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-gic-tm27.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-gic-tm27.h
> +
> +$(PROJECT_INCLUDE)/bsp/arm-release-id.h: ../shared/include/arm-release-id.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/arm-release-id.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/arm-release-id.h
> +
> +$(PROJECT_INCLUDE)/bsp/irq.h: include/irq.h $(PROJECT_INCLUDE)/bsp/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/bsp/irq.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/bsp/irq.h
> +
> +$(PROJECT_INCLUDE)/libcpu/arm-cp15.h: ../../../libcpu/arm/shared/include/arm-cp15.h $(PROJECT_INCLUDE)/libcpu/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
> +PREINSTALL_FILES += $(PROJECT_INCLUDE)/libcpu/arm-cp15.h
> +
> +$(PROJECT_LIB)/start.$(OBJEXT): start.$(OBJEXT) $(PROJECT_LIB)/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_LIB)/start.$(OBJEXT)
> +TMPINSTALL_FILES += $(PROJECT_LIB)/start.$(OBJEXT)
> +
> +$(PROJECT_LIB)/linkcmds: startup/linkcmds $(PROJECT_LIB)/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds
> +TMPINSTALL_FILES += $(PROJECT_LIB)/linkcmds
> +
> +$(PROJECT_LIB)/linkcmds.mx6ulevk: startup/linkcmds.mx6ulevk $(PROJECT_LIB)/$(dirstamp)
> +	$(INSTALL_DATA) $< $(PROJECT_LIB)/linkcmds.mx6ulevk
> +TMPINSTALL_FILES += $(PROJECT_LIB)/linkcmds.mx6ulevk
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/startup/bspreset.c b/c/src/lib/libbsp/arm/mx6ulevk/startup/bspreset.c
> new file mode 100644
> index 0000000..52d07cd
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/startup/bspreset.c
> @@ -0,0 +1,24 @@
> +/*
> + * Copyright (c) 2016 Peng Fan <van.freenix at gmail.com>
> + *
> + * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
> + *
> + *  embedded brains GmbH
> + *  Dornierstr. 4
> + *  82178 Puchheim
> + *  Germany
> + *  <info at embedded-brains.de>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.com/license/LICENSE.
> + */
> +
> +#include <bsp/bootcard.h>
> +
> +void bsp_reset(void)
> +{
> +  while (true) {
> +    /* TODO */;
> +  }
> +}
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/startup/bspstart.c b/c/src/lib/libbsp/arm/mx6ulevk/startup/bspstart.c
> new file mode 100644
> index 0000000..8ebd187
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/startup/bspstart.c
> @@ -0,0 +1,25 @@
> +/*
> + * Copyright (c) 2016 Peng Fan <van.freenix at gmail.com>
> + *
> + * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
> + *
> + *  embedded brains GmbH
> + *  Dornierstr. 4
> + *  82178 Puchheim
> + *  Germany
> + *  <info at embedded-brains.de>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.com/license/LICENSE.
> + */
> +
> +#include <bsp.h>
> +#include <bsp/bootcard.h>
> +#include <bsp/irq-generic.h>
> +
> +void bsp_start(void)
> +{
> +  bsp_interrupt_initialize();
> +  printk("\n RTEMS MX6ULEVK board \n");
> +}
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/startup/bspstarthooks.c b/c/src/lib/libbsp/arm/mx6ulevk/startup/bspstarthooks.c
> new file mode 100644
> index 0000000..28288f9
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/startup/bspstarthooks.c
> @@ -0,0 +1,70 @@
> +/*
> + * Copyright (c) 2016 Peng Fan <van.freenix at gmail.com>
> + *
> + * Copyright (c) 2013 embedded brains GmbH.  All rights reserved.
> + *
> + *  embedded brains GmbH
> + *  Dornierstr. 4
> + *  82178 Puchheim
> + *  Germany
> + *  <info at embedded-brains.de>
> + *
> + * The license and distribution terms for this file may be
> + * found in the file LICENSE in this distribution or at
> + * http://www.rtems.com/license/LICENSE.
> + */
> +
> +#include <bsp.h>
> +#include <bsp/start.h>
> +#include <bsp/arm-cp15-start.h>
> +#include <bsp/arm-a8core-start.h>
> +
> +BSP_START_DATA_SECTION static const arm_cp15_start_section_config
> +mx6ulevk_mmu_config_table[] = {
> +  ARMV7_CP15_START_DEFAULT_SECTIONS,
> +  {
> +    /* ARM CORE */
> +    .begin = 0x00A00000U,
> +    .end   = 0x00A08000U,
> +    .flags = ARMV7_MMU_DEVICE
> +  }, {
> +    /* AIPS1 */
> +    .begin = 0x02000000U,
> +    .end   = 0x02100000U,
> +    .flags = ARMV7_MMU_DEVICE
> +  }, {
> +    /* AIPS2 */
> +    .begin = 0x02100000U,
> +    .end   = 0x02200000U,
> +    .flags = ARMV7_MMU_DEVICE
> +  }
> +};
> +
> +BSP_START_TEXT_SECTION static void setup_mmu_and_cache(void)
> +{
> +
> +  uint32_t ctrl = arm_cp15_start_setup_mmu_and_cache(
> +    ARM_CP15_CTRL_A | ARM_CP15_CTRL_M,
> +    ARM_CP15_CTRL_AFE | ARM_CP15_CTRL_Z
> +  );
> +
> +  arm_cp15_start_setup_translation_table_and_enable_mmu_and_cache(
> +    ctrl,
> +    (uint32_t *) bsp_translation_table_base,
> +    ARM_MMU_DEFAULT_CLIENT_DOMAIN,
> +    &mx6ulevk_mmu_config_table[0],
> +    RTEMS_ARRAY_SIZE(mx6ulevk_mmu_config_table)
> +  );
> +}
> +
> +BSP_START_TEXT_SECTION void bsp_start_hook_0(void)
> +{
> +}
> +
> +BSP_START_TEXT_SECTION void bsp_start_hook_1(void)
> +{
> +  arm_a8core_start_hook_1();
> +  bsp_start_copy_sections();
> +  setup_mmu_and_cache();
> +  bsp_start_clear_bss();
> +}
> diff --git a/c/src/lib/libbsp/arm/mx6ulevk/startup/linkcmds.mx6ulevk b/c/src/lib/libbsp/arm/mx6ulevk/startup/linkcmds.mx6ulevk
> new file mode 100644
> index 0000000..20ea3eb
> --- /dev/null
> +++ b/c/src/lib/libbsp/arm/mx6ulevk/startup/linkcmds.mx6ulevk
> @@ -0,0 +1,48 @@
> +/**
> + * @file
> + *
> + * @ingroup  arm_beagle
> + *
> + * @brief Linker script for beagles.
> + */
> +
> +MEMORY {
> +  /* Beagleboards and beaglebones all
> +   * have either 256M or 512M memory. We just
> +   * use 256M for all.
> +   */
> +  RAM      : ORIGIN = 0x80000000, LENGTH = 256M - 4M
> +  RAM_MMU  : ORIGIN = 0x80000000 + 256M - 4M, LENGTH = 16k
> +}
> +
> +REGION_ALIAS ("REGION_START",          RAM);
> +REGION_ALIAS ("REGION_VECTOR",         RAM);
> +REGION_ALIAS ("REGION_TEXT",           RAM);
> +REGION_ALIAS ("REGION_TEXT_LOAD",      RAM);
> +REGION_ALIAS ("REGION_RODATA",         RAM);
> +REGION_ALIAS ("REGION_RODATA_LOAD",    RAM);
> +REGION_ALIAS ("REGION_DATA",           RAM);
> +REGION_ALIAS ("REGION_DATA_LOAD",      RAM);
> +REGION_ALIAS ("REGION_FAST_TEXT",      RAM);
> +REGION_ALIAS ("REGION_FAST_TEXT_LOAD", RAM);
> +REGION_ALIAS ("REGION_FAST_DATA",      RAM);
> +REGION_ALIAS ("REGION_FAST_DATA_LOAD", RAM);
> +REGION_ALIAS ("REGION_BSS",            RAM);
> +REGION_ALIAS ("REGION_WORK",           RAM);
> +REGION_ALIAS ("REGION_STACK",          RAM);
> +REGION_ALIAS ("REGION_NOCACHE",        RAM);
> +REGION_ALIAS ("REGION_NOCACHE_LOAD",   RAM);
> +
> +bsp_stack_irq_size = DEFINED (bsp_stack_irq_size) ? bsp_stack_irq_size : 4096;
> +bsp_stack_abt_size = DEFINED (bsp_stack_abt_size) ? bsp_stack_abt_size : 1024;
> +
> +bsp_section_rwbarrier_align = DEFINED (bsp_section_rwbarrier_align) ? bsp_section_rwbarrier_align : 1M;
> +
> +bsp_vector_table_in_start_section = 1;
> +
> +bsp_translation_table_base = ORIGIN (RAM_MMU);
> +bsp_translation_table_end = ORIGIN (RAM_MMU) + LENGTH (RAM_MMU);
> +
> +INCLUDE linkcmds.armv4
> +
> +HeapSize = 1024 * 1024;
> 

-- 
--------------------------------------------
embedded brains GmbH
Thomas Doerfler
Dornierstr. 4
D-82178 Puchheim
Germany
email: Thomas.Doerfler at embedded-brains.de
Phone: +49-89-18 94 741-12
Fax:   +49-89-18 94 741-09
PGP: Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.




More information about the devel mailing list