Revisit: Xflash failed to compile with custom loader Topic is solved

Technical questions regarding the xTIMEcomposer, xSOFTip Explorer and Programming with XMOS.
woodsb
Experienced Member
Posts: 75
Joined: Thu Nov 17, 2016 11:24 pm

Revisit: Xflash failed to compile with custom loader

Postby woodsb » Mon Oct 29, 2018 11:12 pm

I have almost exactly the same custom loader problem as reported in this older thread (http://www.xcore.com/viewtopic.php?t=3110), but the solution there (building and flashing with two different, and now unavailable, older versions of the tools) is not possible, and I wonder if anyone has any advice.

I wrote and compiled a custom loader to run either the factory image or the first upgrade, based on the value of a location read from the flash data partition. I then wrote 2 simple routines to flash an LED at a rate that depends on which image is run. All's good to this point.

I next tried to xflash this as instructed in examples and manuals from xmos:

Code: Select all

xflash ../../FlashLEDFastV10/bin/FlashLEDFast.xe --loader myloader.o --upgrade 1 ../../FlashLEDSlowV10/bin/FlashLEDSlow.xe

but get the following warnings and errors:
Warning: F03098 Factory image and boot loader cannot be write-protected on flash device on node 0
xflash: Warning: F03148 --quad-spi-clock not given, using default 15.62MHz
xflash: Warning: F03149 QE_REGISTER and/or QE_BIT locations not found in XN file for this flash device. Using default quad_spi_qe_location_status_reg_0 and quad_spi_qe_bit_6.
myloader.xc: Error: Undefined reference to 'fl_connectToDevice'
myloader.xc: Error: Undefined reference to 'fl_readDataPage'
Error: F03010 Failed to compile second stage bootloader

It is the errors that concern me, as it appears that xflash does not know how to link in the flash calls used in the loader (i.e., fl_connectToDevice and fl_readDataPage), similar to what the previous poster noted.

I imagine I am missing an xcc or xflash option, but cannot determine any that seem to help.

I am on Ubuntu 16.04 with tools 14.3.3. I compiled the custom loader using:

Code: Select all

xcc -c myloader.xc -o myloader.o -target=XUF216-512-TQ128-C20 -lquadflash

FWIW - The problem is the same whether or not I append the "-lquadflash" bit to the xcc command. The flash commands are referenced in myloader.xc using:

Code: Select all

extern int fl_connect(fl_QSPIPorts& QSPI);
extern int fl_readDataPage(unsigned n, unsigned char dst[]);

Any assistance would be greatly appreciated.
View Solution
User avatar
mon2
XCore Legend
Posts: 1282
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Postby mon2 » Tue Oct 30, 2018 12:24 am

Older versions of the tools are available here:

https://www.xmos.com/developer/software/tools/archive
woodsb
Experienced Member
Posts: 75
Joined: Thu Nov 17, 2016 11:24 pm

Postby woodsb » Tue Oct 30, 2018 12:32 am

Thanks, mon2, for the link to the older versions of the tools. I'm really looking for a true fix to this issue, though. I have other kluges I can use to get around this problem currently that I find more appealing than using old tools.

I'd really like to know, is this an xflash bug, or am I missing something?
User avatar
mon2
XCore Legend
Posts: 1282
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Postby mon2 » Tue Oct 30, 2018 12:49 am

Could you try again but replace:

Code: Select all

-lquadflash


with

Code: Select all

-lquadflashlib


and post your results?

Ignore the above comments. I don't think the above advice sounds correct. According to the XMOS docs, -lquadflash is the proper way to access this library.

Ref:
viewtopic.php?t=5067

but check for the existence of the library with a filename of libquadflash.a on your box.

Code: Select all

Linker And Mapper Options

The following options control the linker/mapper.

    -llibrary

    Searches the library library when linking. The linker searches and processes libraries and object files in the order specified. The actual library name searched for is liblibrary.a.

    The directories searched include any specified with -L.

    Libraries are archive files whose members are object files. The linker scans the archive for its members which define symbols that have so far been referenced but not defined.
woodsb
Experienced Member
Posts: 75
Joined: Thu Nov 17, 2016 11:24 pm

Postby woodsb » Tue Oct 30, 2018 1:38 am

Thanks for the continued help. I did find the file, in the 14.3.3 tools, target/lib/xs1b/libquadflash.a and target/lib/xs2a/libquadflash.a. I've also used the flash library in other routines, with the -lquadflash in the makefile, so know that the resources are there.

But looking at your hints prompts me to note that I tried xcc with quadflash, and not libquadflash. When I am again near the setup I'll try the whole procedure with that change (the xcc command worked with the change, but can't do xflash as I don't have the xmos hardware hooked up).
User avatar
mon2
XCore Legend
Posts: 1282
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Postby mon2 » Tue Oct 30, 2018 6:53 am

From my understanding, when you pass:

Code: Select all

-lname


the tool will search for:

Code: Select all

libname.a


that is, the "lib" prefix is applied by the tool and concatenated with your passed value. Please confirm this detail. Do experiment to see if the tool complains about missing library files with your passed parameters.

Also, does --verbose help for any of these command line tools?

Do you have to use command line tools or is there a GUI version for Linux that could be applied? GUI tool may ease the use of the referenced library.
woodsb
Experienced Member
Posts: 75
Joined: Thu Nov 17, 2016 11:24 pm

Postby woodsb » Tue Oct 30, 2018 3:50 pm

Please confirm this detail.

Yes, the -llibrary option causes xcc to look for liblibrary.a. Confirmed in XCC command line manual.

Do experiment to see if the tool complains about missing library files with your passed parameters.
Also, does --verbose help for any of these command line tools?

My loader compile does not generate any complaints. It seems to run, as the output file myloader.o is generated, with or without an appended -lquadflash. The latter makes sense, as I understand the xcc with -o does not link, so will not bother to look for a library to link with. In response to

Code: Select all

xcc -c myloader.xc -o myloader.o -target=XUF216-512-TQ128-C20 -v
I received the following output:
~/XMOS/xTIMEcomposer/Community_14.3.3/targets/XUF216-512-TQ128-C20/XUF216-512-TQ128-C20.xn:27 Warning: XN11206 Oscillator is not specified for USB node.
"~/XMOS/xTIMEcomposer/Community_14.3.3/libexec/xcc1llvm" -isystem "~/XMOS/xTIMEcomposer/Community_14.3.3/target/include/xc" -isystem "~/XMOS/xTIMEcomposer/Community_14.3.3/target/include" -isystem "~/XMOS/xTIMEcomposer/Community_14.3.3/target/include/clang" -D__xcore__ -D__XS2A__ -DXCC_VERSION_YEAR=14 -DXCC_VERSION_MONTH=3 -DXCC_VERSION_MAJOR=1403 -DXCC_VERSION_MINOR=3 -D__XCC_HAVE_FLOAT__ "-D_PLATFORM_INCLUDE_FILE=\"/tmp/ccO9ag0B.h\"" "-D_XSCOPE_PROBES_INCLUDE_FILE=\"/tmp/ccaa9TP3.h\"" -Wuseful -march=xs2a -o "/tmp/ccwwojEv.s" "myloader.xc"
xas -march=xs2a -o "myloader.o" "/tmp/ccwwojEv.s"
Same with or without the appended -lquadflash.

I added --verbose to the xflash command:

Code: Select all

 xflash ../../FlashLEDFastV10/bin/FlashLEDFast.xe --loader myloader.o --upgrade 1 ../../FlashLEDSlowV10/bin/FlashLEDSlow.xe  --verbose
It generated a couple screens worth of output which I put below. One thing that stands out for me is the Stage2_loader part at the very end:
Stage2_Loader::Compile : xcc -Wno-bidirectional-buffered-port -Xmapper --dontenablesodlinks -Xmapper --nochaninit -Xmapper --noinitialtidy -Xmapper --image-base -Xmapper 0x40080 -Xmapper --image-size -Xmapper 0x3ff80 -Xmapper --wno110 -Xmapper --wno226 -Xmapper --wnoXN -std=c99 -O2 -x xn "target-xn-v0-e9da95d8" -x xc s2l-n0-b156549e -lstage2loader -lswitchsetup -lsqiaccess -lquadspi -x none myloader.o -lxcc -o s2l-n0-6fb0b4c6.
It is directly after this that the error messages are thrown and the process aborts:
myloader.xc: Error: Undefined reference to 'fl_connectToDevice'
myloader.xc: Error: Undefined reference to 'fl_readDataPage'
Error: F03010 Failed to compile second stage bootloader

Seems to me the issue is the Stage2_Loader bit is missing a "-lquadflash", but I do not see any way to force that to happen. I do not know how to parse the xflash output to run the process manually, either.

Do you have to use command line tools or is there a GUI version for Linux that could be applied? GUI tool may ease the use of the referenced library.

I am using command line for this as that is what is used in all the examples provided by xmos. When I use the GUI to do the flash, and use the XFlash Options tab to add options to the command to execute the custom loader inclusion, the output in the console is the same as the command line method, including no success and same final error messages.

In the "Design and manufacture systems with flash memory" note from xmos they show a custom loader using an extern reference to readFlashDataPage(). The only statement in the text regarding this is "The loader provides the function readFlashDataPage".

My basic issue is, it is unclear to me how this provision is accomplished.

Complete output from verbose xflash command:

Code: Select all

XFlash_Options::ListDevices : xgdb --batch -q --ex listdevices devl-289cc23b
XFlash_Application found _start :40000 on Node 0
XFlash_Application found _DoSyscall :40ad4 on Node 0
XFlash_Application found _DoException :400a4 on Node 0
XFlash_Application found _start :40000 on Node 0
XFlash_Application found _DoSyscall :404b4 on Node 0
XFlash_Application found _DoException :400a4 on Node 0
XFlash_Application : Attempting to Compress Binary Data
libcompressor marker 1=181
libcompressor marker 2=187
libcompressor marker 3=158
libcompressor best marker length 3 2 2
libcompressor best marker length 3 2 3
libcompressor best marker length 3 2 4
libcompressor DoCompression_Compress took : 58ms
libcompressor compile command=xcc -nostartfiles -Xmapper --bootstyle=forsim -x assembler-with-cpp "decompressor-76341a34" -x xn "target-xn-v0-e9da95d8" -o decompressor-37c6ebdf
libcompressor validating decompressor decompressor-37c6ebdf
libcompressor launching simulator decompressor-37c6ebdf --disable-syscalls --max-cycles 100000000
libcompressor simulator starting @0x40000
libcompressor simulator terminate @0x7ff58
libcompressor decompressor validated
XFlash_Application on Node : 0 compressed from : 10736 bytes to : 7948 bytes (25.97%)
libcompressor marker 1=59
libcompressor marker 2=62
libcompressor marker 3=91
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 3 2 5
libcompressor best marker length 4 2 4
libcompressor best marker length 4 2 5
libcompressor DoCompression_Compress took : 17ms
libcompressor compile command=xcc -nostartfiles -Xmapper --bootstyle=forsim -x assembler-with-cpp "decompressor-c9a5b71f" -x xn "target-xn-v0-e9da95d8" -o decompressor-771deab7
libcompressor validating decompressor decompressor-771deab7
libcompressor launching simulator decompressor-771deab7 --disable-syscalls --max-cycles 100000000
libcompressor simulator starting @0x40000
libcompressor simulator terminate @0x7ff58
libcompressor decompressor validated
XFlash_Application on Node : 0 compressed from : 3424 bytes to : 2820 bytes (17.64%)
XFlash_Application found _start :40000 on Node 0
XFlash_Application found _DoSyscall :40228 on Node 0
XFlash_Application found _DoException :400a4 on Node 0
XFlash_Application found _start :40000 on Node 0
XFlash_Application found _DoSyscall :402a0 on Node 0
XFlash_Application found _DoException :400a4 on Node 0
XFlash_Application : Attempting to Compress Binary Data
libcompressor marker 1=11
libcompressor marker 2=12
libcompressor marker 3=15
libcompressor best marker length 3 2 2
libcompressor best marker length 3 2 3
libcompressor best marker length 5 2 5
libcompressor DoCompression_Compress took : 5ms
libcompressor compile command=xcc -nostartfiles -Xmapper --bootstyle=forsim -x assembler-with-cpp "decompressor-c50986d9" -x xn "target-xn-v1-b16f9645" -o decompressor-75cae450
libcompressor validating decompressor decompressor-75cae450
libcompressor launching simulator decompressor-75cae450 --disable-syscalls --max-cycles 100000000
libcompressor simulator starting @0x40000
libcompressor simulator terminate @0x7ff58
libcompressor decompressor validated
libcompressor marker 1=17
libcompressor marker 2=18
libcompressor marker 3=19
libcompressor best marker length 3 2 2
libcompressor best marker length 3 2 3
libcompressor best marker length 4 2 4
libcompressor best marker length 5 3 5
libcompressor DoCompression_Compress took : 5ms
libcompressor compile command=xcc -nostartfiles -Xmapper --bootstyle=forsim -x assembler-with-cpp "decompressor-61dc7018" -x xn "target-xn-v1-b16f9645" -o decompressor-f996050b
libcompressor validating decompressor decompressor-f996050b
libcompressor launching simulator decompressor-f996050b --disable-syscalls --max-cycles 100000000
libcompressor simulator starting @0x40000
libcompressor simulator terminate @0x7ff58
libcompressor decompressor validated
XFlash_Application on Node : 0 compressed from : 896 bytes to : 888 bytes (0.8929%)
XFlash::DoXFlash
XFlash::DoImageProgramming
XFlash::GetDeviceInfo
XFlash_DeviceInfo::GetDeviceInfo_Hardware
XFlash_DeviceInfo::GetDeviceInfo_Hardware_IssueCompileCommand : xcc -Xmapper --dontenablesodlinks -Xmapper --wnoXN -x xc "spiinfo-269ded58" -x xn "target-xn-v0-e9da95d8" -o "spiinfo-16aef464" -lquadflash -D xnPORT_SQI_CS0=PORT_SQI_CS -D xnPORT_SQI_SCLK0=PORT_SQI_SCLK -D xnPORT_SQI_SIO0=PORT_SQI_SIO
XFlash_Utils::BuildRunCommand : xrun --io spiinfo-16aef464
Warning: F03098 Factory image and boot loader cannot be write-protected on flash device on node 0
XFlash::BuildFlashBinaryFile
XFlash_Builder_S2L::BuildStage2Loaders Factory
xflash: Warning: F03148 --quad-spi-clock not given, using default 15.62MHz
xflash: Warning: F03149 QE_REGISTER and/or QE_BIT locations not found in XN file for this flash device. Using default quad_spi_qe_location_status_reg_0 and quad_spi_qe_bit_6.
Stage2_Loader::Compile : xcc -Wno-bidirectional-buffered-port -Xmapper --dontenablesodlinks -Xmapper --nochaninit -Xmapper --noinitialtidy -Xmapper --image-base -Xmapper 0x40080 -Xmapper --image-size -Xmapper 0x3ff80 -Xmapper --wno110 -Xmapper --wno226 -Xmapper --wnoXN -std=c99 -O2 -x xn "target-xn-v0-e9da95d8" -x xc s2l-n0-b156549e -lstage2loader -lswitchsetup -lsqiaccess -lquadspi -x none myloader.o -lxcc -o s2l-n0-6fb0b4c6
myloader.xc: Error: Undefined reference to 'fl_connectToDevice'
myloader.xc: Error: Undefined reference to 'fl_readDataPage'
Error: F03010 Failed to compile second stage bootloader
User avatar
mon2
XCore Legend
Posts: 1282
Joined: Thu Jun 10, 2010 11:43 am
Contact:

Postby mon2 » Wed Oct 31, 2018 2:25 am

The same error message is raised here:

viewtopic.php?t=1280

Code: Select all

http://www.xcore.com/viewtopic.php?t=1280


based on the above thread, try changing:

Code: Select all

extern int fl_connect(fl_QSPIPorts& QSPI);
extern int fl_readDataPage(unsigned n, unsigned char dst[]);


to:

Code: Select all

extern int fl_connect(fl_QSPIPorts& QSPI);
extern unsigned fl_readDataPage(unsigned n, unsigned char dst[]);


Curious on the results.
woodsb
Experienced Member
Posts: 75
Joined: Thu Nov 17, 2016 11:24 pm

Postby woodsb » Wed Oct 31, 2018 3:12 pm

Thanks for the link and suggestion. I haven't checked this currently, but do note that my declarations match those in the quadflash.h API.

What I'll check next is changing the flash call based on some info in some other threads I just discovered (e.g., http://www.xcore.com/viewtopic.php?t=5053, http://www.xcore.com/viewtopic.php?t=5711, http://www.xcore.com/viewtopic.php?t=3438). The XMOS examples use a "readFlashDataPage" command I was not familiar with, so I, perhaps erroneously, thought I should change that to the "fl..." flash commands I am currently using. When I search our forums for the command originally used I find several discussions similar to ours and indicating there may be a solution. I will look into those and follow up here with the results.

Thanks, again, for your continued help. I hope I'll find something to make it worthwhile.
woodsb
Experienced Member
Posts: 75
Joined: Thu Nov 17, 2016 11:24 pm

Postby woodsb » Fri Nov 02, 2018 5:43 pm

I now have the custom loader working with the "readFlashDataPage" command. It does indeed appear my using the quadflash library was my basic error. I am still not quite sure of the format of the output from the readFlashDataPage, but feel I am over the primary hurdle of getting the custom loader compiled and running.

Thanks again for your help.

-Bill

Who is online

Users browsing this forum: No registered users and 29 guests