Custom Flash Loader for XCORE-200 Topic is solved

If you have a simple question and just want an answer.
ffomich
Experienced Member
Posts: 119
Joined: Mon Sep 15, 2014 1:32 pm

Custom Flash Loader for XCORE-200

Post by ffomich »

Hi,

I try to migrate custom flash loader from my XS1-U8A-128 based board to new XE216-512 based board.

Flash loader analyze button state and load Factory or Upgrade firmware image from flash.

Code: Select all

#include <c:\Program Files (x86)\XMOS\xTIMEcomposer\Community_14.1.2\target\include\xs1.h>


int dpVersion;
unsigned int imgAdr;

unsigned buttonPort = XS1_PORT_4E; //TODO: set correct port

int portMask = 0x01; //TODO: Set correct port mask for button pin

void init ( void ) {

    unsigned buttonVal;
 
    // Read state of button
    asm volatile("setc res[%0], %1" : : "r"(buttonPort), "r"(XS1_SETC_INUSE_ON));
    asm volatile("in %0, res[%1]" : "=r"(buttonVal) : "r"(buttonPort));
 
   // Now 'buttonVal' will have the button value

   // If button is pressed - load factory image. dpVersion: 0 - factory image, 1 - upgrade image
   dpVersion = (buttonVal & portMask) ? 0 : 1;

}

int checkCandidateImageVersion ( int v) {
	return v == dpVersion ;
}

void recordCandidateImage ( int v, unsigned adr ) {
	imgAdr = adr ;
}

unsigned reportSelectedImage ( void ) {
	return imgAdr ;
}

Make with command:

Code: Select all

xcc -c loader.xc -o loader.o
Create file for flash:

Code: Select all

xflash --factory image.xe 0x10000 --loader loader.o --boot-partition-size 0x40000 --target-file target.xn -o flash_image.bin --noinq --verbose
And get error:

Code: Select all

Warning: F03130 --target/--target-file options ignored when an XE file is given
XFlash_Application found _start :40000 on Node 0
XFlash_Application found _DoSyscall :46610 on Node 0
XFlash_Application found _DoException :45594 on Node 0
XFlash_Application found _start :40000 on Node 0
XFlash_Application found _DoSyscall :45064 on Node 0
XFlash_Application found _DoException :44254 on Node 0
XFlash_Application : Attempting to Compress Binary Data
libcompressor marker 1=246
libcompressor marker 2=223
libcompressor marker 3=229
libcompressor best marker length 3 2 2
libcompressor best marker length 3 2 3
libcompressor best marker length 3 2 4
libcompressor best marker length 4 2 5
libcompressor DoCompression_Compress took : 690ms
libcompressor compile command=xcc -nostartfiles -Xmapper --bootstyle=forsim -x a
ssembler-with-cpp "decompressor-8023e746" -x xn "target-xn-v0-7fb3f388" -o decom
pressor-0fd3fef1
libcompressor validating decompressor decompressor-0fd3fef1
libcompressor launching simulator decompressor-0fd3fef1 --disable-syscalls --max
-cycles 100000000
libcompressor simulator starting @0x40000
libcompressor simulator terminate @0x7ff76
libcompressor decompressor validated
XFlash_Application on Node : 0 compressed from : 35960 bytes to : 25540 bytes (2
8.98%)
libcompressor marker 1=223
libcompressor marker 2=107
libcompressor marker 3=229
libcompressor best marker length 3 2 2
libcompressor best marker length 3 2 3
libcompressor best marker length 3 2 4
libcompressor best marker length 4 2 4
libcompressor DoCompression_Compress took : 830ms
libcompressor compile command=xcc -nostartfiles -Xmapper --bootstyle=forsim -x a
ssembler-with-cpp "decompressor-a0a45fa4" -x xn "target-xn-v0-7fb3f388" -o decom
pressor-2c3df26a
libcompressor validating decompressor decompressor-2c3df26a
libcompressor launching simulator decompressor-2c3df26a --disable-syscalls --max
-cycles 100000000
libcompressor simulator starting @0x40000
libcompressor simulator terminate @0x7ff74
libcompressor decompressor validated
XFlash_Application on Node : 0 compressed from : 29184 bytes to : 20284 bytes (3
0.5%)
XFlash::DoXFlash
XFlash::DoImageProgramming
XFlash::GetDeviceInfo
XFlash_DeviceInfo::GetDeviceInfo_User
Warning: F03097
Cannot check factory image protection because --noinq was specified.
Warning: F03102
Node id: 0 - Cannot check boot partition size for sector alignment. The
boot partition should contain a whole number of sectors but
this cannot be checked when the inquirer is disabled

XFlash::BuildFlashBinaryFile
XFlash_Builder_S2L::BuildStage2Loaders Factory
Stage2_Loader::Compile : xcc -Wno-bidirectional-buffered-port -Xmapper --dontena
blesodlinks -Xmapper --nochaninit -Xmapper --noinitialtidy -Xmapper --image-base
 -Xmapper 0x40080 -Xmapper --image-size -Xmapper 0x3ff80 -Xmapper --wno110 -Xmap
per --wno226 -Xmapper --wnoXN -std=c99 -O2 -x xn "target-xn-v0-7fb3f388" -x xc s
2l-n0-86b9f079 -lstage2loader -lswitchsetup -lsqiaccess -x none loader.o -lxcc -
o s2l-n0-0a0f42f0
xmap: Error: Target core mismatch between "XS2" (from "s2l-n0-86b9f079") and "XS
1" (from "loader.xc").
Error: F03010 Failed to compile

Please help.


View Solution
henk
Respected Member
Posts: 347
Joined: Wed Jan 27, 2016 5:21 pm

Post by henk »

Hi ffomich,

Is it possible that the compiler has compiled it for XS1 rather than XS2?

I normally pass loader.xc directly to xflash - rather than compile it first; that way xflash sorts it all out.

Cheers,
Henk