Xflash failed to compile with custom loader

Technical questions regarding the XTC tools and programming with XMOS.
pgbross
Member
Posts: 8
Joined: Fri Apr 16, 2010 1:08 pm

Xflash failed to compile with custom loader

Post by pgbross »

I have a custom loader for use with Xflash that I have been using to allow a choice between a factory and a main image at boot depending on the state of an input port. It follows the principles in the example in the tools documentation, but fails when passed as a --loader argument to Xflash.

Using the command:
xflash --loader ..\flashLoader\loader.o --factory bin\release\nbFactory.xe 0x10000 --boot-partition-size 458752 --noinq -o factory.bin

gives an error:
loader.xc: Error: Undefined reference to 'xpsig'
Error: F03010 Failed to compile

where the port 'xpsig' is referred to in the code below that is reading the input port.

Am I missing some parameters somewhere with tools version 13.2, as this used to work with the development tools version 11?

Any hints appreciated about how to get a xflash custom loader that samples an input port to "compile",

--philip

Code: Select all

# include "xs1.h"
# include "platform.h"

int keptVersion;
unsigned int keptAddress;

in port xpsig = on tile[0]: XS1_PORT_4A;

int bootFactory;

void init(void) {
  int signal;

  keptAddress = 0;
  bootFactory = 0;

  clearbuf(xpsig);

  // read the state of the gpio cp3 line
  xpsig: > signal;

  // if the signal is asserted, then note a boot from factory is requested.
  if ((signal & 1) == 1) bootFactory = 1;
}

int checkCandidateImageVersion(int v) {
  // this is a good version if we don't yet have an address
  // or if we are not booting from factory and the version is
  // greater than or equal to the kept version.
  return (keptAddress == 0) || (!bootFactory && v >= keptVersion);
}

void recordCandidateImage(int v, unsigned int address) {
  // we don't record the version if the kept address is still 0
  // as this is assumed to be the factory image version
  // and is therefore independent of the "upgrade" versions.
  if (keptAddress != 0) {
    keptVersion = v;
  }
  // record the candidate address.
  keptAddress = address;
}

unsigned int reportSelectedImage(void) {
  // return what we found, should be at least one as the factory image
  // will be recorded.
  return keptAddress;
}


User avatar
infiniteimprobability
XCore Legend
Posts: 1126
Joined: Thu May 27, 2010 10:08 am

Post by infiniteimprobability »

Hi - overall idea looks OK, so is this problem as simple as the typo below?

Code: Select all

  xpsig: > signal;
should be:

Code: Select all

xpsig :> signal;
note spaces.

Also - no need for clearbuf() as it's not a buffered port and no previous activity, although it won't do any harm.
pgbross
Member
Posts: 8
Joined: Fri Apr 16, 2010 1:08 pm

Post by pgbross »

Hi infiniteimprobability,

Thanks for the response, but the simple typo seems to have been my in pasting into the "code" window in the forum. My source code really is:

Code: Select all

// read the state of the gpio cp3 line
  xpsig :> signal;
When I compile the loader.xc code (xcc -O2 -c loader.xc -o loader.o -target=irNetBox) there are no errors. The "compile" error is in the Xflash tool itself after I have created the loader.o file, so I guess it is something internal to the Xflash tool's build.

--philip
colin
Experienced Member
Posts: 74
Joined: Mon Dec 16, 2013 12:14 pm

Post by colin »

The loader code looks fine and is similar to one I have here that is compiling and working fine within xflash 13.2. Perhaps you could post your xn file, it is possible that something there could be causing the issue you are seeing.
pgbross
Member
Posts: 8
Joined: Fri Apr 16, 2010 1:08 pm

Post by pgbross »

I have found a workaround to my problem.

If I compile the flashLoader and my "firmware" in the tools version 13.2, but then build the flash binary using the xflash from tools version 13.1, then it all works perfectly.

I have looked at the output of Xflash with --verbose in both v13.1 and v13.2 and cannot spot the difference in the commands, so I assume it is either a bug in the 13.2 tools, or there is some option I have not found that needs setting.

Anyway for now I am happy that I have a solution to my problem - thanks to all who made suggestions.

--philip