Starting with Assembler

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
DrFingersSchaefer
Experienced Member
Posts: 65
Joined: Fri Dec 18, 2009 1:27 pm
Location: The Interzone

Post by DrFingersSchaefer »

Ummm

Still no joy with getting the snippet to link. (or map even), no reply from XMOS yet too. I did send them a request for help via the XMOS web site a few days ago. :roll:

The mapper seems to be lacking a directive of some sort to tell it which device to map/link for. The error suggests that the path is incorrect or not present, which is clearly not the case from the output below. I modified the makefile to printout everything that was needed including the variable that the mapper claims wasn't set, and listed the files that were in the path from the variable that clearly was set.

I can only guess that I need to include some directive or other in the asm file/s as the trace also shows that there is no mapper option to set the required platform. Unless the -h option to the mapper doesn't show it. Nothing in any of the docs you guys have so helpfully suggested either.

Code: Select all


fingers@quicksilver:~/Data/Common/development/G4th$ make binary
XCC_DEVICE_PATH is set to :~/applications/XMOS/DesktopTools/XDE/configs

ls -al ~/applications/XMOS/DesktopTools/XDE/configs
total 236
drwxr-xr-x  2 fingers fingers   4096 2009-12-12 22:21 .
drwxr-xr-x 15 fingers fingers   4096 2010-01-05 16:36 ..
-rwxr-xr-x  1 fingers fingers    872 2009-12-12 22:21 config_default_XS1-B.xml
-rwxr-xr-x  1 fingers fingers    224 2009-12-12 22:21 config_index
-rwxr-xr-x  1 fingers fingers   1240 2009-12-12 22:21 config_XS1-G2B-FB144.xml
-rwxr-xr-x  1 fingers fingers   2552 2009-12-12 22:21 config_XS1-G4A-FB144.xml
-rwxr-xr-x  1 fingers fingers   2552 2009-12-12 22:21 config_XS1-G4A-FB512.xml
-rwxr-xr-x  1 fingers fingers   2552 2009-12-12 22:21 config_XS1-G4B-FB144.xml
-rwxr-xr-x  1 fingers fingers   2559 2009-12-12 22:21 config_XS1-G4B-FB512.xml
-rwxr-xr-x  1 fingers fingers    869 2009-12-12 22:21 config_XS1-L1A-LQ64.xml
-rwxr-xr-x  1 fingers fingers    869 2009-12-12 22:21 config_XS1-L1A-TQ128.xml
-rwxr-xr-x  1 fingers fingers    873 2009-12-12 22:21 config_XS1-L2A-QF124.xml
-rwxr-xr-x  1 fingers fingers   2019 2009-12-12 22:21 XC-1A.xn
-rwxr-xr-x  1 fingers fingers   1276 2009-12-12 22:21 XC-1.xn
-rwxr-xr-x  1 fingers fingers   2739 2009-12-12 22:21 XC-2.xn
-rwxr-xr-x  1 fingers fingers   3493 2009-12-12 22:21 XC-3.xn
-rwxr-xr-x  1 fingers fingers   1850 2009-12-12 22:21 XC-5.xn
-rwxr-xr-x  1 fingers fingers   4932 2009-12-12 22:21 XDK.xn
-rwxr-xr-x  1 fingers fingers   1551 2009-12-12 22:21 XK-1.xn
-rwxr-xr-x  1 fingers fingers  23946 2009-12-12 22:21 XS1-G2B-FB144.pkg
-rwxr-xr-x  1 fingers fingers    668 2009-12-12 22:21 XS1-G2B-FB144.xn
-rwxr-xr-x  1 fingers fingers  23946 2009-12-12 22:21 XS1-G4A-FB144.pkg
-rwxr-xr-x  1 fingers fingers    764 2009-12-12 22:21 XS1-G4A-FB144.xn
-rwxr-xr-x  1 fingers fingers    635 2009-12-12 22:21 XS1-G4A-FB512.xn
-rwxr-xr-x  1 fingers fingers  23946 2009-12-12 22:21 XS1-G4B-FB144.pkg
-rwxr-xr-x  1 fingers fingers    764 2009-12-12 22:21 XS1-G4B-FB144.xn
-rwxr-xr-x  1 fingers fingers    635 2009-12-12 22:21 XS1-G4B-FB512.xn
-rwxr-xr-x  1 fingers fingers  10142 2009-12-12 22:21 XS1-L1A-LQ64.pkg
-rwxr-xr-x  1 fingers fingers    618 2009-12-12 22:21 XS1-L1A-LQ64.xn
-rwxr-xr-x  1 fingers fingers  15584 2009-12-12 22:21 XS1-L1A-TQ128.pkg
-rwxr-xr-x  1 fingers fingers    620 2009-12-12 22:21 XS1-L1A-TQ128.xn
-rwxr-xr-x  1 fingers fingers  23134 2009-12-12 22:21 XS1-L2A-QF124.pkg
-rwxr-xr-x  1 fingers fingers   1364 2009-12-12 22:21 XS1-L2A-QF124.xn
xmap -h
XMOS mapper
Usage: xmap [options] file...
Options:
  -h, --help                 Display this message
  -o FILE                    Set output file name
  --first FILE               Place the specified file at the start of the input file list
  --last FILE                Place the specified file at the end of the input file list
  --defsymbol SYM=VAL        Define a symbol SYM with value VAL
  -r, -i, --relocatable      Generate a relocatable object file
  -g                         Generate debugging information
  -Werror                    Treat warnings as errors
  -Wcodes                    Report error code numbers
  -s --strip-all             Discard all symbols
  -x --discard-all           Discard all local symbols
  -X --discard-locals        Discard temporary local symbols
  -l LIB, -lLIB              Link with the specified library
  -L LIBPATH, -LLIBPATH      Adds the specified path to the library search path
  -save-temps                Do not delete intermediate files
  --discard-none             Do not discard any local symbols
  --image-base VALUE         Use VALUE as the base address
  --image-size VALUE         Use VALUE as the address range size
  --ass-image-base VALUE     Use VALUE as the base address for simulator assertion code
  --noconstmerge             No not merge mergeable const sections
  --show-report              Show constraints report even when it passes
  --version                  Print version information
  --report                   Reports information about resource usage
  --report-name NAME         Restricts reporting to functions with the given name
  --report-callees           Expands reporting to callees of specified functions
  --retain                   Retain unreferenced objects
  --bootable                 Produce a bootable XB file (default is XE)
  --fulltypes                Report full type information in error messages
  -march=[xs1a|xs1b]         Specify the target architecture
  --bootstyle=<style>        Build multi-node XE with the special boot style: forsim or codegoblin(default)
  --map FILE                 Output a mapfile (even if final constraint checking fails).
  --wnoX                     Suppress warning outout for warning number X.


   For bug reporting instructions, please see:
http://www.xmos.com/support
xmap G4th.o -save-temps --report --bootable -march=xs1b -o G4th.xb
xmap: Warning: No platform specified; using default (XS1-G4B-FB512). This behavior is deprecated.
xmap: Error: Cannot location default platform xn because XCC_DEVICE_PATH is not set.
make: *** [G4th.xb] Error 1
fingers@quicksilver:~/Data/Common/development/G4th$



"Dr Fingers Schaefer, The Lobotomy Kid"
Caesar ad sum iam forti
Brutus ad erat
Caesar sic in omnibus
Brutus sic in at
:ugeek:
User avatar
trousers
Active Member
Posts: 44
Joined: Fri Dec 11, 2009 10:20 am

Post by trousers »

Assuming you want nothing but your own code in the binary, you need to do something like:

Code: Select all

xmap g4th.o --nochaninit --bootable -target=XK-1 -o g4th.xb
Note than an XB is not a binary image - it's the same as an XE but with binary data inside instead of elves - i.e. it's much like a stripped executable. AFAIK there's no advantage to XB and XE.
Best friends with the code fairy.
User avatar
DrFingersSchaefer
Experienced Member
Posts: 65
Joined: Fri Dec 18, 2009 1:27 pm
Location: The Interzone

Post by DrFingersSchaefer »

Thanks

I will give that a go, my objective is to initialise nothing or as little as possible in advance and have the Forth OS do it all (or at least canned segments of assembled code that the Forth OS can run). Almost on the fly as it were.

That may seem a little strange but there is purpose to it. I want a minimalist forth booted into one core of a multi core & multi chip system to be able to boot copies of itself into every other available node it can find. Ideally I would like to be able to do this without boot loaders, just using the default boot modes of the G4's. Sort of a viral OS.

I am sure I will stumble across some reason why this is'nt possible at some point but will continue as if it is until then.

If it is not possible any other way it will have to be boot loaders from OTP, ug. :cry:

First off is to get something working though.
"Dr Fingers Schaefer, The Lobotomy Kid"
Caesar ad sum iam forti
Brutus ad erat
Caesar sic in omnibus
Brutus sic in at
:ugeek:
User avatar
DrFingersSchaefer
Experienced Member
Posts: 65
Joined: Fri Dec 18, 2009 1:27 pm
Location: The Interzone

Post by DrFingersSchaefer »

OK

That got rid of one error but leaves us with one to go.

Code: Select all


fingers@quicksilver:~/Data/Common/development/G4th$ make binary
xmap G4th.o --nochaninit -save-temps --report --bootable -march=xs1b -o G4th.xb
xmap: Warning: No platform specified; using default (XS1-G4B-FB512). This behavior is deprecated.
xmap: Error: Cannot location default platform xn because XCC_DEVICE_PATH is not set.
make: *** [G4th.xb] Error 1

fingers@quicksilver:~/Data/Common/development/G4th$ make binary
xmap G4th.o --nochaninit --bootable -target=XS1-G4B-FB512 -o G4th.xb
xmap: Error: Cannot location default platform xn because XCC_DEVICE_PATH is not set.
make: *** [G4th.xb] Error 1

We can see from the first block before modification the errors we had last time. From the second we can see that replacing march with target fixed one error. But not the second. I tried various combinations of the options but still no better. As we could see from the previous posting the env variable is definitely set and listing the path shows us the files that xmap should be able to see.

Hmm progress but still not quite there, excellent work though that man, where did you get the revised parameters from ??
"Dr Fingers Schaefer, The Lobotomy Kid"
Caesar ad sum iam forti
Brutus ad erat
Caesar sic in omnibus
Brutus sic in at
:ugeek:
User avatar
paul
XCore Addict
Posts: 169
Joined: Fri Jan 08, 2010 12:13 am

Post by paul »

If you are using a linux command line then make sure you have done

Code: Select all

cd <install location of xmos tools>/XMOS/DesktopTools/<version>
source SetEnv
This sets up the appropriate environment variables.

You can also add the appropriate bits from SetEnv into you bashrc so its always available...
Paul

On two occasions I have been asked, 'Pray, Mr. Babbage, if you put into the machine wrong figures, will the right answers come out?' I am not able rightly to apprehend the kind of confusion of ideas that could provoke such a question.
User avatar
DrFingersSchaefer
Experienced Member
Posts: 65
Joined: Fri Dec 18, 2009 1:27 pm
Location: The Interzone

Post by DrFingersSchaefer »

Yup I had picked up on that and put the relevant statements into my makefile. I like to avoid cluttering up my usual shell paths.

Here's my current makefile, There is a rule vars that can be run to printout what they are all set to at the time the make file is running, so I am fairly sure it variable is set and defined. In the posting above I modified the makefile to printout a bit more info including the value of XCC_DEVICE_PATH and to ls the contents of that dorectory, All the config files etc are there.

Code: Select all


# Dr. Fingers Schaefer (The Lobotomy Kid), Complexity Tends to a Maximum.
# If you are uptight about licensing all of this project is GPL, get over it.
# Simple Makefile IDE
# Uses m4 to preprocess .masm files into an asm file
# Uses the XDE to process the asm file into binary

# shell directive
SHELL = /bin/bash

# suffixes list
.SUFFIXES:
.SUFFIXES: .masm .asm .bin

# some useful lists and variables
PREFED = gedit
XMOSTOOLS = ~/applications/XMOS/DesktopTools/XDE
XMOSASM = xas
XMOSLNK = xmap
# Leon's assm flags
# ASMFLAGS = -g -nostdlib -nostartfiles -Xmapper --nochaninit -target=XC-5 -o
# test assm flags
# ASMTEST = -v --help
ASMFLAGS = -l -v -march=xs1b -o
#LINKFLAGS = --nochaninit -save-temps --report --bootable -march=xs1b -o
LINKFLAGS = --nochaninit --bootable -target=XS1-G4B-FB512 -o
TARFLAGS = -cvz --exclude *.tgz --no-recursion -f
NOWSTR = $(shell date +%M%H%d%m%y)

# compiler/assembler environment variables
PATH := $(XMOSTOOLS)/bin:$(XMOSTOOLS)/xde_bin:$(XMOSTOOLS)/xvcd_bin:$(XMOSTOOLS)/xta_bin:$(PATH)
LD_LIBRARY_PATH := $(XMOSTOOLS)/lib:$(LD_LIBRARY_PATH)
XCC_XC_INCLUDE_PATH := $(XMOSTOOLS)/target/include:$(XMOSTOOLS)/target/include/gcc
XCC_C_INCLUDE_PATH := $(XCC_XC_INCLUDE_PATH)
XCC_CPLUS_INCLUDE_PATH := $(XCC_XC_INCLUDE_PATH):$(XMOSTOOLS)/target/include/c++/4.2.1
XCC_CPLUS_INCLUDE_PATH := $(XCC_CPLUS_INCLUDE_PATH):$(XMOSTOOLS)/target/include/c++/4.2.1/xcore-xmos-elf
XCC_ASSEMBLER_INCLUDE_PATH := $(XCC_XC_INCLUDE_PATH)
XCC_LIBRARY_PATH := $(XMOSTOOLS)/target/lib
XCC_DEVICE_PATH := $(XMOSTOOLS)/configs
XCC_EXEC_PREFIX := $(XMOSTOOLS)/libexec/
XMOS_DOC_PATH := $(XMOSTOOLS)/doc

# The usage for the Makefile IDE
usage:		
	@echo -e "\nMakefile Useage:-\n"
	@echo -e "make usage\tThis helpful list of commands"
	@echo -e "make source\tEdit your source file list with your prefered editor"
	@echo -e "make binary\tRefresh binaries where needed."
	@echo -e "make clean\tRemove all the target files"
	@echo -e "make tarball\tTar and Compress all files in the project directory, no subs"
	@echo -e "make install\tLoad the binaries into the target"
	@echo -e "make all\tMakes clean, binary, install"
	@echo -e "make package\tMakes clean, tarball\n\n"

# edit the source file list with prefered editor
source:			
	$(PREFED) *.masm &

# preprocess the masm file with m4
G4th.asm: *.masm
	m4 forth.masm >G4th.asm

# assemble the asm file into an object file
G4th.o: G4th.asm
	$(XMOSASM) G4th.asm $(ASMFLAGS) G4th.o

# link/map the object file into a bootable file
G4th.xb: G4th.o
	$(XMOSLNK) G4th.o $(LINKFLAGS) G4th.xb

# make the bootable/binary file
binary: G4th.xb

# remove all unnecesary files for archiving or to force a clean build
clean:
	clear		
	rm -f G4th.o G4th.o.txt G4th.xb G4th.asm *.tar.gz *~ 

# tar and compresses all the files in this directory, ignores subdirectories
tarball:
	tar $(TARFLAGS) G4th$(NOWSTR).tar.gz ./*
	mv ./G4th$(NOWSTR).tar.gz ./archive/

# install the binarys to your target
install:
	@echo Not done yet - Write me............	

# Makes clean, binary, install
all: clean binary install

# Makes clean, tarball
package: clean tarball

# list devices
listdevices:
	xrun --listdevices

# Show what key environment variables are set to
vars:
	clear
	@echo " "
	@echo "Path => $(PATH)"
	@echo " "
	@echo "LD_LIBRARY_PATH => $(LD_LIBRARY_PATH)"
	@echo " "
	@echo "XCC_XC_INCLUDE_PATH => $(XCC_XC_INCLUDE_PATH)"
	@echo " "
	@echo "XCC_C_INCLUDE_PATH => $(XCC_C_INCLUDE_PATH)"
	@echo " "
	@echo "XCC_CPLUS_INCLUDE_PATH => $(XCC_CPLUS_INCLUDE_PATH)"
	@echo " "
	@echo "XCC_CPLUS_INCLUDE_PATH => $(XCC_CPLUS_INCLUDE_PATH)"
	@echo " "
	@echo "XCC_ASSEMBLER_INCLUDE_PATH => $(XCC_ASSEMBLER_INCLUDE_PATH)"
	@echo " "
	@echo "XCC_LIBRARY_PATH => $(XCC_LIBRARY_PATH)"
	@echo " "
	@echo "XCC_DEVICE_PATH => $(XCC_DEVICE_PATH)"
	@echo " "
	@echo "XCC_EXEC_PREFIX => $(XCC_EXEC_PREFIX)"
	@echo " "
	@echo "XMOS_DOC_PATH => $(XMOS_DOC_PATH)"
	@echo " "
		
Given this I am left with the conclusion that the issue is a something or lack of that I need to be telling xmap either in the intermediate file or a CLI parameter.

Without documentation though for xmap I am struggling.

Any and all advice welcome.
"Dr Fingers Schaefer, The Lobotomy Kid"
Caesar ad sum iam forti
Brutus ad erat
Caesar sic in omnibus
Brutus sic in at
:ugeek:
User avatar
DrFingersSchaefer
Experienced Member
Posts: 65
Joined: Fri Dec 18, 2009 1:27 pm
Location: The Interzone

Post by DrFingersSchaefer »

Sir Awesome of Pants.

I had understood a bootable (XB) to be the lump of code that you could squirt down a link and the processor would boot from it.

IE it is prefixed with the size of the lump and suffixed with a CRC that validates the lump.

XE on the other hand I took to be a lump of code that would run if you had some way to load it (already running process maybe) but was incapable of booting a core due to lack of prefix and suffix.

Otherwise the lumps of code would be identical.

But with all else I have read and conclusions I have formed from the docs, there is a very strong likely hood, I haven't got a scooby doo.

If someone in the know could confirm/deny this that would be incredibly useful ??

:?:
"Dr Fingers Schaefer, The Lobotomy Kid"
Caesar ad sum iam forti
Brutus ad erat
Caesar sic in omnibus
Brutus sic in at
:ugeek:
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

.xe files are containers for multiple ELF files. It contains ELF images plus metadata describing which cores each image should be loaded onto. The ELF files contain symbolic information (and debugging information if you compiled your program with debug turned on).

.xb files use the same container format as .xe but contain raw binary images instead if ELF files. The primary difference between a .xb and a .xe is the lack of symbolic information.

An .xb file is not in a suitable format for loading it directly using the SPI or channel boot modes. You can get the raw binary images out of a .xb using xobjdump -s (the image for core x, node y will be dumped to image_nxcy.bin). You would need to add the size and CRC yourself.
User avatar
DrFingersSchaefer
Experienced Member
Posts: 65
Joined: Fri Dec 18, 2009 1:27 pm
Location: The Interzone

Post by DrFingersSchaefer »

Richard

Thanks for that you are also a star. I will need to alter my make file for the G4th project then to take account of this as I only want binary for Core0.

Questions:-

1. what CLI tool if any would process the dumped binary into a binary plus size and crc ready to squirt down a link or write into a SPI/flash/wonder-boot device.

2. You could'nt work the same magic and tell me how to get my stuff to link/map from the CLI could you ??

Cheers

Fingers
"Dr Fingers Schaefer, The Lobotomy Kid"
Caesar ad sum iam forti
Brutus ad erat
Caesar sic in omnibus
Brutus sic in at
:ugeek:
richard
Respected Member
Posts: 318
Joined: Tue Dec 15, 2009 12:46 am

Post by richard »

DrFingersSchaefer wrote:1. what CLI tool if any would process the dumped binary into a binary plus size and crc ready to squirt down a link or write into a SPI/flash/wonder-boot device.
xflash can take a multicore .xe file and turn it into a single SPI image that will be loaded onto all cores in a multi-stage boot process, see the Tools User Guide. This does quite a bit more than just adding the header.

If you just want add the header to a binary then there is no tool to do this, but the code to create the header would be pretty simple (the format of the header is defined in the XS1-G / XS1-L System Specification). I could probably post some code if this is what you want to do.
DrFingersSchaefer wrote:2. You could'nt work the same magic and tell me how to get my stuff to link/map from the CLI could you ??
I'm not sure why it isn't working. Did it work for you if you source SetEnv and run the same command outside of the Makefile?