Skip to content

Commit

Permalink
Merge pull request #43 from xmos/release/v1.1.1
Browse files Browse the repository at this point in the history
Release v1.1.1
  • Loading branch information
mbanth authored Jul 21, 2022
2 parents e166232 + 582234b commit 2ad0497
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 27 deletions.
9 changes: 8 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
xscope fileio change log
========================

1.1.1
-----

* REMOVED: xscope_fread() delay for Windows race condition
* ADDED: checks that xscope_io_init() has completed before allowing a file to be opened
* ADDED: adds helper function, xscope_fileio_is_initialized(), to allow application to check if the host connection has been established

1.1.0
-----

Expand All @@ -13,7 +20,7 @@ xscope fileio change log
* ADDED: support for building and running the host endpoint on Windows
* ADDED: XMOS public V1 license
* ADDED: support for run_on_target() to optionally redirect stdout to file
* REMOVED:run_on_target() method returns stdout/err as list of lines
* REMOVED:run_on_target() method returns stdout/err as list of lines
* REMOVED: optional verbose kwarg in run_on_target()to reduce verbosity

0.4.0
Expand Down
8 changes: 5 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ Source and header files for device code are found in ``src_xcore``

void xscope_io_init(chanend_t xscope_end);

unsigned xscope_fileio_is_initialized(void);

xscope_file_t xscope_open_file(char* filename, char* attributes);

//NOTE MAXIMUM n_bytes_to_read of 64kB on Linux http://bugzilla/show_bug.cgi?id=18528
Expand All @@ -68,15 +70,15 @@ Source and header files for device code are found in ``src_xcore``

void xscope_fseek(xscope_file_t *xscope_io_handle, int offset, int whence);

int xscope_ftell(xscope_file_t *xscope_file);
int xscope_ftell(xscope_file_t *xscope_file);

void xscope_close_all_files(void);

The device side application requires a multi-tile main since it uses the xscope_host_data(xscope_chan); service
to communicate with the host, which requires this. See examples for XC and C applications for how to do this.

You will also need a copy of ``config.xscope`` in your firmware directory. This
enables xscope in the tools and sets up the xscope probes used by fileio for communicating with the host app. You
enables xscope in the tools and sets up the xscope probes used by fileio for communicating with the host app. You
can find a copy in ``xscope_fileio/config.xscope xscope_fileio/config.xscope.txt`` which you should rename to ``config.xscope``.

Note currently missing from fileio api:
Expand All @@ -90,7 +92,7 @@ System Architecture
-------------------

The ``run_on_target`` function calls ``xrun --xscope-port`` with the binary and specified target adapter,
and simultaneously launches a host application to communicate xscope data to/from
and simultaneously launches a host application to communicate xscope data to/from
the xrun process via sockets. The host application responds to ``xscope_fileio`` API calls
in the firmware code, reading/writing to the host file system.

Expand Down
33 changes: 21 additions & 12 deletions xscope_fileio/api/xscope_io_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,19 @@ extern "C"{
*
* @param xscope_end is the app side channel end connected xscope_host_data()
* task in the top level application.
* @return void
* @return void
******************************************************************************/
void xscope_io_init(chanend_t xscope_end);

/******************************************************************************
* xscope_fileio_is_initialized
*
* This returns the status of the host xscope fileio connection
*
* @return 1 if initialized, else 0
******************************************************************************/
unsigned xscope_fileio_is_initialized(void);

/******************************************************************************
* xscope_open_files
*
Expand All @@ -44,7 +53,7 @@ void xscope_io_init(chanend_t xscope_end);
*
* @param read_file_name to open on host
* @param write_file_name to open on host
* @return an initialised xscope_file_handle
* @return an initialised xscope_file_handle
******************************************************************************/
xscope_file_t xscope_open_file(const char* filename, char* attributes);

Expand All @@ -56,9 +65,9 @@ xscope_file_t xscope_open_file(const char* filename, char* attributes);
* requested data from the file. Each read is contiguous from the previous read
*
* @param handle of file to operate on
* @param buffer that will be written the file read
* @param buffer that will be written the file read
* @param n_bytes_to_read
* @return number of bytes actually read. Will be zero if EOF already hit.
* @return number of bytes actually read. Will be zero if EOF already hit.
******************************************************************************/
size_t xscope_fread(xscope_file_t *xscope_io_handle, uint8_t *buffer, size_t n_bytes_to_read);

Expand All @@ -68,9 +77,9 @@ size_t xscope_fread(xscope_file_t *xscope_io_handle, uint8_t *buffer, size_t n_b
* Writes a number of bytes from the buffer provided by the application.
*
* @param handle of file to operate on
* @param buffer that will be read and sent to be written on the host
* @param buffer that will be read and sent to be written on the host
* @param n_bytes_to_write
* @return void
* @return void
******************************************************************************/
void xscope_fwrite(xscope_file_t *xscope_io_handle, uint8_t *buffer, size_t n_bytes_to_write);

Expand All @@ -80,9 +89,9 @@ void xscope_fwrite(xscope_file_t *xscope_io_handle, uint8_t *buffer, size_t n_by
* Sets the file position of the stream to the given offset
*
* @param handle of file to operate on
* @param offset in bytes
* @param offset in bytes
* @param whence - SEEK_SET, SEEK_CUR or SEEK_END
* @return void
* @return void
******************************************************************************/
void xscope_fseek(xscope_file_t *xscope_io_handle, int offset, int whence);

Expand All @@ -92,9 +101,9 @@ void xscope_fseek(xscope_file_t *xscope_io_handle, int offset, int whence);
* Obtain the file position of the stream
*
* @param handle of file to operate on
* @return void
* @return void
******************************************************************************/
int xscope_ftell(xscope_file_t *xscope_file);
int xscope_ftell(xscope_file_t *xscope_file);


/******************************************************************************
Expand All @@ -104,12 +113,12 @@ int xscope_ftell(xscope_file_t *xscope_file);
* This must be called at the end of device application as it also signals
* terminate to the host app.
*
* @return void
* @return void
******************************************************************************/
void xscope_close_all_files(void);

#ifdef __XC__
}
#endif

#endif
#endif
2 changes: 1 addition & 1 deletion xscope_fileio/module_build_info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = 1.1.0
VERSION = 1.1.1

MODULE_XCC_FLAGS = $(XCC_FLAGS)

Expand Down
20 changes: 10 additions & 10 deletions xscope_fileio/src/xscope_io_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
chanend_t c_xscope = 0;
unsigned file_idx = 0;
lock_t file_access_lock;
volatile unsigned xscope_io_init_flag = 0;

__attribute__((weak))
void xscope_fileio_lock_alloc(void) {
Expand All @@ -33,14 +34,23 @@ void xscope_fileio_lock_release(void) {
lock_release(file_access_lock);
}

unsigned xscope_fileio_is_initialized(void) {
return xscope_io_init_flag;
}

void xscope_io_init(chanend_t xscope_end){
xscope_fileio_lock_alloc();
xscope_mode_lossless();
c_xscope = xscope_end;
xscope_connect_data_from_host(c_xscope);
xscope_io_init_flag = 1;
}

xscope_file_t xscope_open_file(const char* filename, char* attributes){
/* Wait until xscope_fileio is initialized */
while(xscope_fileio_is_initialized() == 0) {
delay_ticks(1);
}
xscope_fileio_lock_acquire();
xscope_file_t xscope_file;
strcpy(xscope_file.filename, filename);
Expand Down Expand Up @@ -93,16 +103,6 @@ size_t xscope_fread(xscope_file_t *xscope_file, uint8_t *buffer, size_t n_bytes_

xscope_bytes(XSCOPE_ID_READ_BYTES, sizeof(packet), packet);

// Add a delay to avoid a race condition seen only on Windows
// See issue 30
#define XSCOPE_FREAD_RACE_CONDITION_DELAY ( XS1_TIMER_MHZ * 100 )

// Define the timeafter macro until it becomes available in C source files via xs1.h
#define timeafter(A, B) ((int)((B) - (A)) < 0)

uint32_t time_delay = get_reference_time() + XSCOPE_FREAD_RACE_CONDITION_DELAY;
while(timeafter(time_delay, get_reference_time()));

do
{
int bytes_read = 0;
Expand Down

0 comments on commit 2ad0497

Please sign in to comment.