How to read/write flash in endpoint0( ) Topic is solved

If you have a simple question and just want an answer.
Post Reply
johnsonyin
Member++
Posts: 16
Joined: Thu Nov 10, 2016 2:33 am

How to read/write flash in endpoint0( )

Post by johnsonyin »

For xu216, Add fl_connectToDevice( ) in endpoint0 (),which is on tile[XUD_TILE=1], it always return None Zero value, can't read/write flash. can I do it like this? if I can, what shall I do ? thanks


View Solution
DemoniacMilk
XCore Addict
Posts: 191
Joined: Tue Jul 05, 2016 2:19 pm

Post by DemoniacMilk »

What ports/pins is your flash connected to?

If your USB endpoint is running on a core on tile 1, then calling fl_connect(ports) will try to connect to the flash device using ports on tile 1.

Be aware that (for example) XS1_PORT_1E names a port within a tile, but on tile[0]: XS1_PORT_1E and on tile[1]: XS1_PORT_1E are in fact different ports/pins.

If your flash is connected to pins on a tile other than the USB tile, then you need to get the data you want to write/read from one tile to another tile. For this you may use a channel or an interface.

USB Tile: endpoint <-> chanend/interface
Flash tile: chanend/interface <-> flash_task (access flash here)
johnsonyin
Member++
Posts: 16
Joined: Thu Nov 10, 2016 2:33 am

Post by johnsonyin »

DemoniacMilk wrote:What ports/pins is your flash connected to?

If your USB endpoint is running on a core on tile 1, then calling fl_connect(ports) will try to connect to the flash device using ports on tile 1.

Be aware that (for example) XS1_PORT_1E names a port within a tile, but on tile[0]: XS1_PORT_1E and on tile[1]: XS1_PORT_1E are in fact different ports/pins.

If your flash is connected to pins on a tile other than the USB tile, then you need to get the data you want to write/read from one tile to another tile. For this you may use a channel or an interface.

USB Tile: endpoint <-> chanend/interface
Flash tile: chanend/interface <-> flash_task (access flash here)
thanks for your message, DemoniacMilk!
User avatar
larry
Respected Member
Posts: 275
Joined: Fri Mar 12, 2010 6:03 pm

Post by larry »

You'll also need to make sure endpoint zero doesn't get stalled for too long (e.g. scanning the flash or erasing). I believe the USB spec requires it to respond to requests within 500ms.
johnsonyin
Member++
Posts: 16
Joined: Thu Nov 10, 2016 2:33 am

Post by johnsonyin »

DemoniacMilk wrote:What ports/pins is your flash connected to?

If your USB endpoint is running on a core on tile 1, then calling fl_connect(ports) will try to connect to the flash device using ports on tile 1.

Be aware that (for example) XS1_PORT_1E names a port within a tile, but on tile[0]: XS1_PORT_1E and on tile[1]: XS1_PORT_1E are in fact different ports/pins.

If your flash is connected to pins on a tile other than the USB tile, then you need to get the data you want to write/read from one tile to another tile. For this you may use a channel or an interface.

USB Tile: endpoint <-> chanend/interface
Flash tile: chanend/interface <-> flash_task (access flash here)

i meet other problem with interface communication, add interface parameter to endpoint0 ( ), it always compile error.
D:/sw_usb_audio-[sw]_6.15.2rc1/sc_usb_audio/module_usb_audio/endpoint0\endpoint0.h:25:127: error: interface declared inside parameter list
chanend ?c_mix_ctl,chanend ?c_clk_ctl, chanend ?c_EANativeTransport_ctr, client interface i_dfu dfuInterfaces, server interface flashread i );
can i use interface communication in C file?
User avatar
larry
Respected Member
Posts: 275
Joined: Fri Mar 12, 2010 6:03 pm

Post by larry »

can i use interface communication in C file?
You can't call interface functions in C. You can pass interfaces along in C. That's using CLIENT_INTERFACE and SERVER_INTERFACE macros from xccompat.h.
johnsonyin
Member++
Posts: 16
Joined: Thu Nov 10, 2016 2:33 am

Post by johnsonyin »

Thanks for larry, i got it
Post Reply