XCore Targets

An XCore target is required to build applications, running on a particular board. Target itself is a collection of files, located at some directory in the CCore/Target directory. The name of the directory is the target name. Plus a cross-toolchain is required to build projects. The toolchain must be built according the XCore requirements to be aligned with the core. CCore uses GNU-compatible make-based build system. To build an application for the particular target you specify the target name as one of the build variable in a makefile. There is a special target Vanilla-X. This target is a template for any standalone target. If you want to create a new XCore target, you may start from this "vanilla" one.

Here is the file layout for required XCore target files. You may add additional features to your target by adding extra source files. In general case you should add a lot of extra code to be able to use the platform hardware.


TARGET_ROOT

  Makefile
  Makefile.tools

  CCore
    inc
      base
        PlatformBase.h
        Quick.h
      sys
        SysAbort.h
        SysAtomic.h
        SysMemSpace.h
        SysTime.h
        SysPlanInit.h
      dev
        DevInt.h
        DevTick.h
        DevWaitForInterrupt.h
        DevIntHandle.h
        DevPlanInit.h
      libc
        CBase.h
    src
      base
        PlatformBase.cpp
        Quick.cpp
      sys
        SysAbort.cpp
        SysAtomic.cpp
        SysMemSpace.cpp
        SysTime.cpp
        SysCon.cpp
        SysPlanInit.cpp
      task
        TaskContext.cpp
      dev
        DevInt.cpp
        DevTick.cpp
        DevWaitForInterrupt.cpp
        DevIntHandle.cpp
        DevPlanInit.cpp
      libc
        CBase.cpp
      PlanInit_CCore.cpp
    test
      test6XXX.NNN.cpp
  obj
    empty
  test
    Makefile
    main.cpp
  test-obj
    empty

Target code from the directory sys enclosed in the namespace Sys (inside the namespace CCore).

Target code from the file Quick.h enclosed in the namespace Quick (inside the namespace CCore).

Makefile

Makefile is used to build the CCore.a library. It's standard and looks like


CCORE_ROOT = ../..

CCORE_TARGET = TARGET_NAME

SRC_PATH_LIST = $(CCORE_ROOT)/Simple/CCore/src \
                $(CCORE_ROOT)/Fundamental/CCore/src \
                $(CCORE_ROOT)/Applied/CCore/src \
                $(CCORE_ROOT)/XCore/CCore/src \
                $(CCORE_ROOT)/Target/$(CCORE_TARGET)/CCore/src \

GEN_PATH_LIST = $(CCORE_ROOT)/XCore/CCore/inc \
                $(CCORE_ROOT)/Target/$(CCORE_TARGET)/CCore/inc

include $(CCORE_ROOT)/Target/Makefile.core

Makefile.tools defines toolset to build CCore target applications. It looks like (BeagleBoneBlack example)


CCOPT_EXTRA ?= 

LDOPT_EXTRA ?=

# tools

ECHO = /usr/bin/echo

FIND = /bin/find

MKDIR = /bin/mkdir

CAT = /usr/bin/cat

TOUCH = /usr/bin/touch

CC_ = /opt/BeagleBoneBlack/bin/arm-g++.exe

CC = @$(ECHO) CC $< ; $(CC_)

LD = @$(ECHO) LD $@ ; $(CC_)

AS_ = /opt/BeagleBoneBlack/bin/arm-as.exe

AS = @$(ECHO) AS $< ; $(AS_)

AR_ = /opt/BeagleBoneBlack/bin/arm-ar.exe

AR = @$(ECHO) AR $@ ; $(AR_)

RM_ = rm -f

RM = @$(ECHO) RM ; $(RM_)

# options

NOWARN = -Wno-non-virtual-dtor \
         -Wno-switch \
         -Wno-type-limits \
         -Wno-enum-compare \
         -Wno-missing-field-initializers \
         -Wno-delete-non-virtual-dtor \


CCINC = -I$(CCORE_ROOT)/Target/$(CCORE_TARGET) \
        -I$(CCORE_ROOT)/XCore \
        -I$(CCORE_ROOT)/Simple \
        -I$(CCORE_ROOT)/Fundamental \
        -I$(CCORE_ROOT)/Applied \


CPUOPT = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard -mno-unaligned-access

CCOPT = -c -std=c++14 $(CPUOPT) -fwrapv -O3 -Wall -Wextra $(NOWARN) $(CCINC) $(CCOPT_EXTRA)

ASOPT = -march=armv7-a -mfpu=vfpv3 -mfloat-abi=hard

CCORELIB = $(CCORE_ROOT)/Target/$(CCORE_TARGET)/CCore.a

LDOPT = $(CPUOPT) -fno-use-linker-plugin -Wl,-s $(LDOPT_EXTRA) $(CCORELIB) 

You define here the following variables:

ECHO — the standard Unix echo.

FIND — the standard Unix find.

MKDIR — the standard Unix mkdir.

CAT — the standard Unix cat.

TOUCH — the standard Unix touch.

CC — C++ cross-compiler.

LD — cross-linker.

AS — cross-assembler.

AR — cross-librarian.

RM — file delete command.

CCOPT — options for the C++ compiler. Among other they must specify directories to search include files. The order of directories is: target include path, XCore include path, CCore include paths.

ASOPT — options for the assembler.

LDOPT — options for the linker. Linker options must specify the CCore.a library to be linked.

To give a path from the CCore file tree, you should use the variable CCORE_ROOT.

To compile a .cpp source file the following command is used:

$(CC) $(CCOPT) source-file -o object-file

To generate a dependency file the following command is used:

$(CC) $(CCOPT) -MM -MT object-file source-file -MF dep-file

To compile an .asm source file the following command is used:

$(AS) $(ASOPT) source-file -o object-file

To generate register helpers from the register description the following command is used:

$(HOME)/bin/CCore-Regen.exe desc-file gen.h-file

To link an application the following command is used:

$(LD) object-file-list $(LDOPT) -o exe-file

To build a library the following commands are used:

$(RM) lib-file
$(AR) r lib-file object-file-list

Test support

CCore/test is the directory for target-specific tests. The file names here must have the following form: test6XXX.NNN.cpp. 6XXX is a decimal test number, starts from 6001. NNN is some name of the test.

Makefile from the test directory is used to build the target test application. It has the following standard form


CCORE_ROOT = ../../..

CCORE_TARGET = TARGET_NAME

SRC_PATH_LIST = . \
                $(CCORE_ROOT)/Simple/CCore/test \
                $(CCORE_ROOT)/Fundamental/CCore/test \
                $(CCORE_ROOT)/Applied/CCore/test \
                $(CCORE_ROOT)/XCore/CCore/test \
                $(CCORE_ROOT)/Target/$(CCORE_TARGET)/CCore/test \

OBJ_PATH = ../test-obj

TARGET = main.exe

include $(CCORE_ROOT)/Target/Makefile.app

You may add the run target to use a boot program to start the application on the board:


run: $(TARGET)
	~/bin/CCore-BeagleBoot.exe r 192.168.99.10 $(TARGET) && cd root && ~/bin/CCore-PTPServer.exe c

main.cpp from the test directory is the main file of the target test application. It looks like


#include <CCore/test/test.h>

#include <CCore/inc/MemBase.h>
#include <CCore/inc/PacketPool.h>

namespace App {

/* Testit<0> */ 

template<>
const char *const Testit<0>::Name="Test0 empty";
   
template<>
bool Testit<0>::Main() { return false; }
 
} // namespace App
 
/* main() */ 

using namespace App;

int main()
 {
  MemScope mem_scope;
  
  Testit<2999>().run();

  Printf(Con,"\nPeak memory usage #;\n\n",MemPeak());
  
  DetachPacketBufs();
  
  return 0;
 }
 

To run a particular test edit the test number.