Specify XS2 Architecture with CMake Topic is solved

Technical questions regarding the XTC tools and programming with XMOS.
maxmatteo
Member++
Posts: 20
Joined: Wed Dec 30, 2020 8:11 pm
Location: Hamburg

Specify XS2 Architecture with CMake

Post by maxmatteo »

Hey there,

i have an old XS2 board here, but i cant run my compiled code for xs2:

Code: Select all


➜  helloworld cat src/main.xc
#include <platform.h>
#include <stdio.h>

int main( void ) {
    printf (" Hello world \n");
}%

Code: Select all

➜  helloworld cmake -G "Unix Makefiles" -B build
CMake Warning (dev) at /Applications/XMOS_XTC_15.3.0/build/xcommon_cmake/xcommon.cmake:34 (enable_language):
  project() should be called prior to this enable_language() call.
Call Stack (most recent call first):
  CMakeLists.txt:2 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- The CXX compiler identification is Clang 3.6.0
-- The C compiler identification is Clang 3.6.0
-- The ASM compiler identification is XCC
-- Found assembler: /Applications/XMOS_XTC_15.3.0/bin/xcc
-- Configuring application: example
-- Configuring done (0.2s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/max/Development/private/diyinhk-xu208-board/helloworld/build

Code: Select all

➜  helloworld cd build
➜  build xmake
[ 50%] Building C object CMakeFiles/example.dir/src/main.xc.obj
/Users/max/Development/private/diyinhk-xu208-board/helloworld/src/main.xc:6:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
[100%] Linking C executable /Users/max/Development/private/diyinhk-xu208-board/helloworld/bin/example.xe
[100%] Built target example

Code: Select all

➜  build xrun --io ../bin/example.xe
xrun: warning: Selected architecture xs3_reva is not compatible with reported target architecture xs2_reva
xrun: warning: Selected architecture does not match target architecture on tile[0]: xs3_reva != xs2_reva
xrun: Cannot load: architecture mismatch.
how to specify xs2_reva architecture?


board file:

Code: Select all

➜  helloworld cat board.xn
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
    <Type>Device</Type>
    <Name>xmosboard</Name>

    <Declarations>
        <Declaration>tileref tile[2]</Declaration>
        <Declaration>tileref usb_tile</Declaration>
    </Declarations>

    <Packages>
        <Package id="0" Type="XS2-UFnA-512-TQ128">
            <Nodes>
                <Node Id="0" InPackageId="0" Type="XS2-L16A-512"
                    SystemFrequency="500MHz" OscillatorSrc="1">
                    <Boot>
                        <Source Location="bootFlash" />
                    </Boot>
                    <Tile Number="0" Reference="tile[0]">
View Solution
maxmatteo
Member++
Posts: 20
Joined: Wed Dec 30, 2020 8:11 pm
Location: Hamburg

Post by maxmatteo »

seems i need to edit the hw config in the cmakelists file:

Code: Select all

➜  helloworld cat CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(example)

set(APP_HW_TARGET board)

XMOS_REGISTER_APP()
board.xn file exists... but it fails with:

Code: Select all

➜  helloworld cmake -G "Unix Makefiles" -B build
CMake Warning (dev) at /Applications/XMOS_XTC_15.3.0/build/xcommon_cmake/xcommon.cmake:34 (enable_language):
  project() should be called prior to this enable_language() call.
Call Stack (most recent call first):
  CMakeLists.txt:2 (include)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Configuring application: example
xcc: error: unknown target `board'
Supported targets:
XCORE-200-EXPLORER;xCORE-200 Explorer Kit
XCORE-AI-EXPLORER;xcore.ai Explorer Kit
XK-EVK-XU316;xcore.ai Explorer Kit (XK-EVK-XU316)

Additional targets can be provided in the the directory %HOMEPATH%\.xmos\targets on Windows hosts and in the directory $HOME/.xmos/targets on Mac and Linux hosts.

Alternatively a target XN file may be supplied on the command line.
-- Configuring done (0.1s)
-- Generating done (0.0s)
-- Build files have been written to: /Users/max/Development/private/diyinhk-xu208-board/helloworld/build
maxmatteo
Member++
Posts: 20
Joined: Wed Dec 30, 2020 8:11 pm
Location: Hamburg

Post by maxmatteo »

okay solved it by writing board.xn in my CMakeLists.txt:

Code: Select all

➜  helloworld cat CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
include($ENV{XMOS_CMAKE_PATH}/xcommon.cmake)
project(example)

set(APP_HW_TARGET board.xn)

XMOS_REGISTER_APP()
➜  helloworld ls
CMakeLists.txt README         bin            board.xn       build          src
➜  helloworld xrun --io bin/example.xe
 Hello world
danielp
Active Member
Posts: 33
Joined: Tue Jul 16, 2024 9:52 am
Location: Bristol, UK

Post by danielp »

There are two ways to specify the APP_HW_TARGET: either a filename ending in .xn which it will search for in the application source directory, or a target name from the targets supported internally by xcc. So as you've found, you needed board.xn to pick up your local XN file.

However, I have been trying to reproduce your original architecture mismatch and I can't reproduce it.

Do you know what your APP_HW_TARGET setting was in your first post to this thread? If it was board rather than board.xn at that point, I would expect the xmake build to fail.
XMOS, Senior Software Engineer
danielp
Active Member
Posts: 33
Joined: Tue Jul 16, 2024 9:52 am
Location: Bristol, UK

Post by danielp »

I think I can see what probably happened here now. I think the first post must have had a CMakeLists.txt that was understandably based on one of the examples, so had something like

Code: Select all

set(APP_HW_TARGET XK-EVK-XU316)
This would explain the initial architecture mismatch.

The second post with board rather than board.xn actually didn't fail the cmake command - it printed an error from xcc, but will have completed - this is a bug that will be fixed. Despite that completing, the subsequent xmake would have failed because board isn't a known target name.

Thank you for sharing your experience with this, as you have uncovered a bug that needs to be fixed.
XMOS, Senior Software Engineer