Advice for new XMOS developer?

Technical questions regarding the XTC tools and programming with XMOS.
iandmacgregor
Junior Member
Posts: 6
Joined: Sun Aug 27, 2023 7:00 pm

Advice for new XMOS developer?

Post by iandmacgregor »

Hi,
I am taking a dive into XMOS development (for USB audio) and having a tough time getting a consistent, clear development/build system up and running. I am starting without any experience of the TimeComposer IDE and would like to set something up using VScode as I currently use it (+ CubeMX makefile) for STM32 development. I come from the hardware world, so I am trying to catch up on some of the C/makefile/build-system basics & best practices.

So far, I have progressed through the XMOS XTC tools user guide: https://www.xmos.com/documentation/XM-0 ... user-guide - I made it through setting up VScode as my IDE and writing/compiling the simple Quick Start programs along with flashing to an XK-AUDIO-316-MC dev board. The advanced tutorial subjects didn't really make much sense as a next step so I started looking into other things.

Someone on the forum linked me to Kevin Patterson's XC-IDE extension for VScode: https://youtu.be/aSy40Ee-UZk?si=Hk3J2Ncj7MZMXLE3 - This made a lot of sense to me as it functions similar to how I develop STM32. Here, I was also able to get the basic IDE extension setup and create the basic tutorial code. For a next step, I tried to get a simple USB HID sample running: https://github.com/xmos/lib_xud/tree/de ... _hid_class

Here I ran into issues with header files/libraries that I have yet to solve. I am not sure if I should keep using this setup as it is unclear to me if the xmake based setup is obsolete (or going to be).

I also encountered this post about the build system being updated: https://www.xcore.com/viewtopic.php?t=8429

Is this new build system already rolled into the XMOS tutorials and examples? I am having a really hard time finding a path to progressively learn and build on after the basic tutorials. What is the XMOS recommended build system and is there a tutorial to set it up with an IDE like VScode? Are there simple app examples that use/demonstrate this build system? What is the process for pulling an example app (like the USB HID linked above) from github, compiling, and flashing to dev board using the recommended build system?

Is there some kind of big-picture development road map that I just missed? My end goal is a simple USB audio interface with some basic user inputs (buttons/encoders) and some LEDs.

Any help would be greatly appreciated! Thank you!


User avatar
fabriceo
XCore Addict
Posts: 186
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hello
what is important is to get something working quickly so you can tune and learn by doing around.

With the new XTC 15.2, you have to go with vscode and the cmake solution. Still there are possibilities to use the older Eclipse based IDE (14.4.1) with the 15.2 tools but this is useful only for the veteran like some of us.

If you want to build your own USB Audio application with some IO, then go with the latest SW USB AUDIO 7.3.1.zip which is a full pack including all you need and it is configured for xmake.
the pdf file is explaining very well this application, and the modules.
in chapter 4 it explains how to start and build with xmake.

the effort to port this application to cmake is ongoing but you don't need that for prototyping your app.

when it comes to HID, this has been fully integrated inside the sw usb audio code, so there is no need for a task managing HID endpoint, as the basic IO mechanisms have been embedded directly in the "buffer" task. Likely you will need your own custom task to manage your IO and to interact with the HID report. More details about how HID is integrated can be found in the lib_xua.pdf file.

good luck, this is challenging but rewarding
iandmacgregor
Junior Member
Posts: 6
Joined: Sun Aug 27, 2023 7:00 pm

Post by iandmacgregor »

Hi Fabriceo,
Thanks for the response this is helpful! Correct me if I am wrong, but it sounds like cmake is the way to go forward if I was going to create an app from scratch but XMOS is still porting over so some applications (like the SW UWB AUDIO) use xmake? I have XTC tools 15.2.1, will that work with either build system?

I will follow your advice and try to move forward with the USB AUDIO app for now. In the meantime, I attempted to download and install the XCORE SDK, but got stuck at the installation stage. Before I try and figure that out, do I need to have the SDK installed? If I were to make a new app from scratch that required various libraries (USB, I2S, I2c, etc) is the SDK where those libraries come from? In other words, the XTC tools is just the compiler, SDK for the libraries?

Appreciate the help!
Ian
User avatar
fabriceo
XCore Addict
Posts: 186
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

iandmacgregor wrote: Tue Jan 02, 2024 10:40 pm Hi Fabriceo,
Thanks for the response this is helpful! Correct me if I am wrong, but it sounds like cmake is the way to go forward if I was going to create an app from scratch but XMOS is still porting over so some applications (like the SW UWB AUDIO) use xmake? I have XTC tools 15.2.1, will that work with either build system?
All correct Ian,

XTC Tools 15.2.1 is basically the compiler, linker assembler and the core C, XC and C++ librairies and special files for XS2A XS3 architecture and flash memory access. Also it includes a so called "xcommon" makefile which gives the possibility to build application projects with modules or libraires described in the module_build_info files.
With that you can do a basic Hello World program and play with GPIOs for example.
also you have xflash,xsim,xrun,debugger...

XCORE SDK correspond to the GitHub folder xcore_iot. Documentation on the web here :
https://www.xmos.com/documentation/XM-014926-PC-1/html/
this is a modernized environement providing most of the libraries, encapsulated in a small "rtos" abstraction layer and organized to use freeRtos and the C API instead of XC specifics. This was introduced maybe 2 years ago to address some use case related to IOT and possibly connecting with Amazon Alexa.

Recent devloppement around the voice products (microphone arrays) or camera with AI are now leveraging very much this relatively new platform and the code is now very much different from what some of us have been used with the former SW USB AUDIO 6.15 or even 7.3.1.

my view is that there is now 2 paths for developing apps.
Also there are pro & cons... the new way, using freeRtos and Rtos layer and even tinyUsb with C and C++ instead of XC is probably the right direction for long term investment and big or non usb-audio projects. but the old way is certainly good enough for a standard USB Audio platform.

You have to assess if your application will be closer to what can offer the SW USB AUDIO 7.3.1, or the Voice/microphones/iot solution.
iandmacgregor
Junior Member
Posts: 6
Joined: Sun Aug 27, 2023 7:00 pm

Post by iandmacgregor »

Aha! Things are starting to get clearer...

Right now, it looks like I should focus on the SW USB AUDIO path. When I first received the dev board, I did get that up and running - I think the block I ran into was trying to figure out how to modify that code. I ran across some documentation recently that detailed this, so I need to dig back in. If I want to say, add a bunch of LEDs using HC595 shift registers, does this development path include a SPI library already or is that something I would need to get elsewhere?

If I were to download the xcore_iot SDK to develop something unrelated to USB audio, what is the best practice for where that gets stored on my PC? Should it go inside the XMOS folder on my system's program files folder (where the tools live)? Does it not matter at all? If I am developing multiple, separate apps, should copies of the the xcore_iot be local to that app, or can it live in one common spot?

Again, massive thanks for the help! I feel like I'm a couple core concepts/discoveries away from getting up and running.

Ian
User avatar
fabriceo
XCore Addict
Posts: 186
Joined: Mon Jan 08, 2018 4:14 pm

Post by fabriceo »

Hi Ian, depending on your platform the XTC might be installed in different folder. I m using Mac osx and it is installed in the Application folder. this doesn't really matter as long as your PATH contains the xmos bin folder which you can force with the given setenv.sh/bat.

the file sw_usb_audio_user_guide_7_3_1.pdf chapter 4/5 explains every thing and I recommend you follow it so that if it is not clear you can provide feedback to Ross for a next revision.

basically for a new project, create a workspace folder in which you put an application folder (containing the top makefile) and the modules you need, each in a folder at same level of application. then open a shell within the application folder and go with xmake. it shall do the job if the PATH is setup.

you can use git and sync your workspace folders with a remote repos.

regarding xmos library updates from their GitHub, I prefer to control that by myself but some would use git with recursive subdirectories.


one of the first thing to do is to define where your IO (leds, button, lcd) will be connected : on which port and on which Tile.

You will create a dedicated task to manage these IO or screen and it is preferable (but not mandatory) to locate this task on the tile where you ll have most interactions with, in term of ports access and shared memory (as there is no possibility to share global variable across tiles unless you implement a specific exchange mechanism with Channels).

this task will be registered with USER_MAIN_CORES

The way to access IO ports is not obvious. One way is to use lib_gpio which requires coding with XC and not C or CPP (see app note) but XC is supposed to be obsolete...
another way is to define a couple of asm volatile macro to access port and to play with that in a C or CPP program.
you can find some in file flashlib_user.c

if you need to access ports on the other tile, you will need a specific trampoline task on the other tile , transferring information via channed.

for serializing to HC595, I think it will be faster to get it working with your own bit banging access to data and clock pins instead of trying to integrate lib_spi :)

hope this helps
fabriceo
iandmacgregor
Junior Member
Posts: 6
Joined: Sun Aug 27, 2023 7:00 pm

Post by iandmacgregor »

Fabriceo - again, very helpful!

I did a deep dive into the USB audio code and the chapters in the doc you recommended and it's starting to make a lot more sense to me.

I feel like I've got my work cut out for me, but at least now I feel like I have a map to follow. Many thanks!