trouble with flashlib

Technical questions regarding the XTC tools and programming with XMOS.
pasau
Experienced Member
Posts: 77
Joined: Fri Dec 06, 2013 7:05 pm

trouble with flashlib

Post by pasau »

Hi, i recently tried integrating the flash_module into my applications, so i first got the files from github, but when i tried importing the module and the app found at https://github.com/xcore/sc_flash to xTIMEcomposer, i get No projects are found to import, and i never had that problem with any other module. I tried copying the source files into a new module, but i get an error saying i am missing the file SpecDefinitions.h, which would normally be generated according the what the module_build_info file seems to be doing.

I also tried building sw_flashlib_examples, but it doesn't seem to work so far, i can't get past the point where it says Click and expand C/XC Build and click on "Settings", since i don't have this tab in version 13

I really need the flash library for my apps, but i am having trouble importing the library correctly. Some advice would be very kind. Thank you!

pasau


GrizzlyAdams
Junior Member
Posts: 4
Joined: Thu Jan 09, 2014 2:22 am

Post by GrizzlyAdams »

You need to import the module_flash as a makefile project. Additionally you will need to add -lflash to the end of the XCC_FLAGS line in the makefile for your main project.

Code: Select all

XCC_FLAGS = -g -O2 -lflash
I'm sure there is something I'm missing, but that should get you started. You'll need to build module_flash before your project, so consider adding it as a dependency to your project.
GrizzlyAdams
Junior Member
Posts: 4
Joined: Thu Jan 09, 2014 2:22 am

Post by GrizzlyAdams »

I'm sure there is something else I'm missing, since I'm having trouble with xTIMEcomposer unable to find the sources for libflash when debugging (only offering to let me view disassembly).
pasau
Experienced Member
Posts: 77
Joined: Fri Dec 06, 2013 7:05 pm

Post by pasau »

there seems to be a problem with certain modules like module_flash and module_XUD, i simply cannot compile them in xTimeComposer 12.2.0 or 13.0.1
pasau
Experienced Member
Posts: 77
Joined: Fri Dec 06, 2013 7:05 pm

Post by pasau »

Hi, i got further in my understanding and i figured that i had to run the .pl script first to generate the files from the spec files, so i downloaded perl and got familiar with it. But now my problem is that for me the script prints some c++ code directly in a .cpp file without any function declaration. It basically looks like this:

fprintf(outFile," FL_DEVICE_ATMEL_AT25DF041A,\n");
fprintf(outFile," FL_DEVICE_ST_M25PE10,\n");
...

i get syntax errors and when i compile i get
"expected constructor, destructor, or type conversion before '(' token"
"expected constructor, destructor, or type conversion before '(' token"
...
GrizzlyAdams
Junior Member
Posts: 4
Joined: Thu Jan 09, 2014 2:22 am

Post by GrizzlyAdams »

On my system I was able to run the following command:

Code: Select all

perl src/BuildLists.pl specs SpecDefinitions.h SpecMacros.h SpecEnum.h XflashCode.cpp
And generated the files in question. Though it appears to generate an incomplete SpecDefinitions.h which possibly explains why I'm unable to access the chip on the startkit, its definition never made it into the list :P

In the perl file on line 17 there is a list of which flash chips to enable. Make sure your target chip is in the list (copy the needed entry from enumorder just below it if necessary)

if you have module_build_info in the root of the module, xTIMEcomposer should automatically run the perl script.

Code: Select all

xmake all 
Building flash_dev
Generating headers from spec files
Creating dependencies for DeviceAccess.xc
Creating dependencies for flashlib.c
Compiling flashlib.c
Compiling DeviceAccess.xc
Creating libflash_dev.a
Built all libraries
Also, the cpp file can be safely ignored, it isn't referenced by the target library, its either unused, or related to a build step. on my system it is a bunch of naked fprintf calls as well.
pasau
Experienced Member
Posts: 77
Joined: Fri Dec 06, 2013 7:05 pm

Post by pasau »

I did like you told but about the module_build_info, i think it simply didn't work because i didn't have perl installed.

I also ignored the .cpp file and after a few file linking mistakes i think i managed to compile the library. I haven't tried running a test app for it yet though.

In any case, can anyone please tell me more about the things you normally do with the module_build_info file? To me it seems kind of similar to a Makefile
User avatar
sethu_jangala
XCore Expert
Posts: 589
Joined: Wed Feb 29, 2012 10:03 am

Post by sethu_jangala »

pasau wrote:I did like you told but about the module_build_info, i think it simply didn't work because i didn't have perl installed.

I also ignored the .cpp file and after a few file linking mistakes i think i managed to compile the library. I haven't tried running a test app for it yet though.

In any case, can anyone please tell me more about the things you normally do with the module_build_info file? To me it seems kind of similar to a Makefile
module_build_info for a module is similar to Makefile for an application. If a module needs to include some other module, this information can be added in the module_build_info. If you want to add directives or build configurations, this information can be added in the module_build_info.

Sethu.