At bootup the XMOS uses ports 1A/B/C/D. After boot up I can recycle 3 of these lines by raising CS high. However, I want to use flashlib sometimes and can't seem to reuse the ports AND retain flashlib support despite the fact I only want to use flashlib only rarely to perform on the fly firmware updates.
Is there any example for retaining flashlib and using the ABCD ports?
How to use SPI ports AND retain Flashlib support
-
- XCore Addict
- Posts: 162
- Joined: Thu Dec 31, 2009 8:51 am
-
- XCore Legend
- Posts: 1274
- Joined: Thu Dec 10, 2009 10:20 pm
Can you explain a little more what is preventing this from working, do you have little more detail as I am also interested in this approach.
regards
Al
regards
Al
-
- XCore Addict
- Posts: 162
- Joined: Thu Dec 31, 2009 8:51 am
If you use Flashlib then you must define:
//define ports
fl_SPIPorts SPI={ XS1_PORT_1A, XS1_PORT_1B, XS1_PORT_1C, XS1_PORT_1D, XS1_CLKBLK_5};
Then you cannot define the pins as ports that you can use yourself.
//define ports
fl_SPIPorts SPI={ XS1_PORT_1A, XS1_PORT_1B, XS1_PORT_1C, XS1_PORT_1D, XS1_CLKBLK_5};
Then you cannot define the pins as ports that you can use yourself.
-
- XCore Legend
- Posts: 1274
- Joined: Thu Dec 10, 2009 10:20 pm
If you mean you can't use the fl_SPIPorts in another thread, then can't you use the same thread to handle both SPI operations?
Alternatively for a separate thread you can drop down to C and pass the unsigned resource ids of the ports between threads (by passing them over a channel for example) as long as you ensure both threads don't use them at once.
regards
Al
Alternatively for a separate thread you can drop down to C and pass the unsigned resource ids of the ports between threads (by passing them over a channel for example) as long as you ensure both threads don't use them at once.
regards
Al
-
- XCore Addict
- Posts: 162
- Joined: Thu Dec 31, 2009 8:51 am
I only intend to call the SPI parts from one thread.
To use the XMOS SPI libraries you must define:
typedef struct spi_slave_interface {
clock blk;
in port ss;
in buffered port:8 mosi;
out buffered port:8 miso;
in port sclk;
} spi_slave_interface;
Since the same ports are used in the flash structure, the compile won't let you go.
If we had source code for flashlib then this would be easy to modify.
Since we don't then I don't see how to use both.
To use the XMOS SPI libraries you must define:
typedef struct spi_slave_interface {
clock blk;
in port ss;
in buffered port:8 mosi;
out buffered port:8 miso;
in port sclk;
} spi_slave_interface;
Since the same ports are used in the flash structure, the compile won't let you go.
If we had source code for flashlib then this would be easy to modify.
Since we don't then I don't see how to use both.
-
- XCore Legend
- Posts: 1274
- Joined: Thu Dec 10, 2009 10:20 pm
I couldn't agree more and have no idea why the flashlib code has not been opened on github like most everything else. This has been requested before I believe but I cannot find the relevant thread.If we had source code for flashlib then this would be easy to modify.
PS there is an aurora of black magic around flash with Xmos because of the obscurity of the code, openness hear could clear a lot up for many folk.
PPS The side effect of a closed flashlib will likely be folks writing there own flash drivers which is the last thing Xmos or its community need.
Update here are some useful bonus links I found after a search
Opening the tools:
https://www.xcore.com/forum/viewtopic.p ... lash#p8555
Boeserbaer rolls his own:
https://www.xcore.com/forum/viewtopic.p ... lash#p7866
Using an SD card on the SPI ports possible?
https://www.xcore.com/forum/viewtopic.p ... ilit=flash
Re-using the SPI FLASH port:
https://www.xcore.com/forum/viewtopic.p ... lash#p7140
regards
Al
-
- Experienced Member
- Posts: 64
- Joined: Tue Oct 05, 2010 7:33 pm
You should be able to do this using xlinks in the manner I've shown here: https://www.xcore.com/projects/runtime- ... ion-xlinks. You'll need to disable the links before you use the ports for flash access, then reenable them (and re-connect) when you are done. It may take a little cooperative work with whatever is connected on the other end (which must also be running the same routines).
Paul
Paul