Merge branch 'develop' into xross-patch-2

This commit is contained in:
oscarbailey-xmos
2020-12-08 15:55:27 +00:00
committed by GitHub
29 changed files with 2348 additions and 69 deletions

View File

@@ -442,6 +442,16 @@
#define CODEC_MASTER (0)
#endif
/**
* @brief Serial Number String used by the device
*
* Default: ""
*/
#ifndef SERIAL_STR
#define SERIAL_STR ""
#endif
/**
* @brief Vendor String used by the device. This is also pre-pended to various strings used by the design.
*
@@ -516,21 +526,21 @@
* @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number.
*/
#ifndef BCD_DEVICE_J
#define BCD_DEVICE_J (0)
#define BCD_DEVICE_J (1)
#endif
/**
* @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number.
*/
#ifndef BCD_DEVICE_M
#define BCD_DEVICE_M (1)
#define BCD_DEVICE_M (2)
#endif
/**
* @brief Device firmware version number in Binary Coded Decimal format: 0xJJMN where JJ: major, M: minor, N: sub-minor version number.
*/
#ifndef BCD_DEVICE_N
#define BCD_DEVICE_N (1)
#define BCD_DEVICE_N (0)
#endif
/**

View File

@@ -62,6 +62,16 @@ void XUA_Endpoint0_setProductStr(char * unsafe product_str);
void XUA_Endpoint0_setProductStr(char * product_str);
#endif
/** Function to set the Serial string
*
* \param serial_str Serial string to set
*/
#ifdef __XC__
void XUA_Endpoint0_setSerialStr(char * unsafe serial_str);
#else
void XUA_Endpoint0_setSerialStr(char * serial_str);
#endif
/** Function to set the BCD device
*
* \param bcdDevice BCD device to set
@@ -72,34 +82,44 @@ void XUA_Endpoint0_setBcdDevice(unsigned short bcdDevice);
/** Function to get the Vendor string
*
* \param vid vendor string
* \return vendor string
*/
#ifdef __XC__
char * unsafe XUA_Endpoint0_getVendorStr();
#else
char * XUA_Endpoint0_getVendorStr(;
char * XUA_Endpoint0_getVendorStr();
#endif
/** Function to get the Product string
*
* \param pid Product string
*/
#ifdef __XC__
char * unsafe XUA_Endpoint0_getProductStr();
#else
char * XUA_Endpoint0_getProductStr(;
#endif
/** Function to get the Vendor string
*
* \return Vendor string
*/
unsigned short XUA_Endpoint0_getVendorId();
/** Function to get the Product string
*
* \return Product string
*/
#ifdef __XC__
char * unsafe XUA_Endpoint0_getProductStr();
#else
char * XUA_Endpoint0_getProductStr();
#endif
/** Function to get the Serial Number string
*
* \return Serial string
*/
#ifdef __XC__
char * unsafe XUA_Endpoint0_getSerialStr();
#else
char * XUA_Endpoint0_getSerialStr();
#endif
/** Function to get the Vendor ID
*
* \return Vendor ID
*/
unsigned short XUA_Endpoint0_getVendorId();
/** Function to get the Product ID
*
* \return Product ID
*/
unsigned short XUA_Endpoint0_getProductId();
/** Function to get the BCD device

View File

@@ -1,2 +1,3 @@
all:
g++ -m32 -Wall -g -o xmosdfu xmosdfu.cpp -Ilibusb/Linux32 -lusb-1.0
mkdir -p bin
g++ -m32 -Wall -g -o bin/xmosdfu xmosdfu.cpp -Ilibusb/Linux32 -lusb-1.0

View File

@@ -1,2 +1,3 @@
all:
g++ -Wall -g -o xmosdfu xmosdfu.cpp -Ilibusb/Linux32 -lusb-1.0
mkdir -p bin
g++ -Wall -g -o bin/xmosdfu xmosdfu.cpp -Ilibusb/Linux32 -lusb-1.0

View File

@@ -1,2 +1,3 @@
all:
g++ -g -o xmosdfu xmosdfu.cpp -Ilibusb/OSX32 libusb/OSX32/libusb-1.0.0.dylib -m32 -Wall
mkdir -p bin
g++ -g -o bin/xmosdfu xmosdfu.cpp -Ilibusb/OSX32 libusb/OSX32/libusb-1.0.0.dylib -m32 -Wall

View File

@@ -1,2 +1,3 @@
all:
g++ -g -o xmosdfu xmosdfu.cpp -Ilibusb/OSX64 libusb/OSX64/libusb-1.0.0.dylib -Wall
mkdir -p bin
g++ -g -o bin/xmosdfu xmosdfu.cpp -Ilibusb/OSX64 libusb/OSX64/libusb-1.0.0.dylib -Wall

View File

@@ -5,4 +5,5 @@
# vendor and product IDs
xmosdfu: xmosdfu.cpp
g++ -D_GNU_SOURCE -Wall -g -o xmosdfu -Ilibusb/Rasp -lusb-1.0 -x c xmosdfu.cpp -std=c99
mkdir -p bin
g++ -D_GNU_SOURCE -Wall -g -o bin/xmosdfu -Ilibusb/Rasp -lusb-1.0 -x c xmosdfu.cpp -std=c99

View File

@@ -0,0 +1,31 @@
# Build tested with Visual Studio 2017 command prompt
#
# Run: nmake /f Makefile.Win32
#
# NOTE: To run xmosdfu on Windows, libusbK drivers must be installed on the DFU endpoint
# We recommend using the third-party Zadig tool for this.
COMMON_FLAGS = \
/D BECLEAR_HOST=1 \
/I libusb\Win32 \
/nologo \
/W4 \
/WX- \
/O2 \
/EHa \
/D _CRT_SECURE_NO_WARNINGS \
xmosdfu.cpp \
all: xmosdfu
xmosdfu:
if not exist bin mkdir bin
CL.exe \
$(COMMON_FLAGS) \
/Fe"bin\xmosdfu.exe" \
/link "libusb\Win32\libusb-1.0.lib""
copy libusb-1.0.dll bin
del *.obj
clean:
rmdir /s /q bin

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@@ -73,42 +73,42 @@ system_profiler SPUSBDataType|grep -A10 "$device_grep_string" |grep Version
echo ""
echo "*** DFU download new firmware 1 ***"
$PROGDIR/xmosdfu $device_pid --download $update1
$PROGDIR/bin/xmosdfu $device_pid --download $update1
sleep 2
echo "Version Read:"
system_profiler SPUSBDataType|grep -A10 "$device_grep_string" |grep Version
echo ""
echo "*** DFU download new firmware 2 ***"
$PROGDIR/xmosdfu $device_pid --download $update2
$PROGDIR/bin/xmosdfu $device_pid --download $update2
sleep 2
echo "Version Read:"
system_profiler SPUSBDataType|grep -A10 "$device_grep_string" |grep Version
echo ""
echo "*** DFU upload existing firmware ***"
$PROGDIR/xmosdfu $device_pid --upload upload.bin
$PROGDIR/bin/xmosdfu $device_pid --upload upload.bin
sleep 2
echo "Version Read:"
system_profiler SPUSBDataType|grep -A10 "$device_grep_string" |grep Version
echo ""
echo "*** DFU revert to factory ***"
$PROGDIR/xmosdfu $device_pid --revertfactory
$PROGDIR/bin/xmosdfu $device_pid --revertfactory
sleep 2
echo "Version Read:"
system_profiler SPUSBDataType|grep -A10 "$device_grep_string" |grep Version
echo ""
echo "*** DFU download uploaded firmware ***"
$PROGDIR/xmosdfu $device_pid --download upload.bin
$PROGDIR/bin/xmosdfu $device_pid --download upload.bin
sleep 2
echo "Version Read:"
system_profiler SPUSBDataType|grep -A10 "$device_grep_string" |grep Version
echo ""
echo "*** DFU revert to factory ***"
$PROGDIR/xmosdfu $device_pid --revertfactory
$PROGDIR/bin/xmosdfu $device_pid --revertfactory
sleep 2
echo "Version Read:"
system_profiler SPUSBDataType|grep -A10 "$device_grep_string" |grep Version

View File

@@ -1,7 +1,28 @@
// Copyright (c) 2012-2018, XMOS Ltd, All rights reserved
// Copyright (c) 2012-2020, XMOS Ltd, All rights reserved
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#ifdef _WIN32
#include <windows.h>
// Used for checking if a file is a directory
#ifndef S_ISDIR
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif
// Aliases for Windows
#define stat _stat
#define fstat _fstat
#define fileno _fileno
#else
#include <unistd.h>
void Sleep(unsigned milliseconds) {
usleep(milliseconds * 1000);
}
#endif
#include "libusb.h"
/* the device's vendor and product id */
@@ -51,7 +72,7 @@ static int find_xmos_device(unsigned int id, unsigned int pid, unsigned int list
libusb_device *dev;
libusb_device **devs;
int i = 0;
int found = 0;
unsigned int found = 0;
size_t count = libusb_get_device_list(NULL, &devs);
if ((int)count < 0)
@@ -195,7 +216,7 @@ int xmos_dfu_restore_state(unsigned int interface)
return 0;
}
int dfu_download(unsigned int interface, unsigned int block_num, unsigned int size, unsigned char *data)
unsigned int dfu_download(unsigned int interface, unsigned int block_num, unsigned int size, unsigned char *data)
{
//printf("... Downloading block number %d size %d\r", block_num, size);
/* Returns actual data size transferred */
@@ -212,7 +233,7 @@ int dfu_upload(unsigned int interface, unsigned int block_num, unsigned int size
int write_dfu_image(char *file)
{
int i = 0;
unsigned int i = 0;
FILE* inFile = NULL;
int image_size = 0;
unsigned int num_blocks = 0;
@@ -225,6 +246,7 @@ int write_dfu_image(char *file)
unsigned int timeout = 0;
unsigned char strIndex = 0;
unsigned int dfuBlockCount = 0;
struct stat statbuf;
inFile = fopen( file, "rb" );
if( inFile == NULL )
@@ -233,6 +255,19 @@ int write_dfu_image(char *file)
return -1;
}
/* Check if file is a directory */
int status = fstat(fileno(inFile), &statbuf);
if (status != 0)
{
fprintf(stderr,"Error: Failed to get info on file.\n");
return -1;
}
if ( S_ISDIR(statbuf.st_mode) )
{
fprintf(stderr,"Error: Specified path is a directory.\n");
return -1;
}
/* Discover the size of the image. */
if( 0 != fseek( inFile, 0, SEEK_END ) )
{
@@ -259,7 +294,7 @@ int write_dfu_image(char *file)
{
memset(block_data, 0x0, block_size);
fread(block_data, 1, block_size, inFile);
int transferred = dfu_download(0, dfuBlockCount, block_size, block_data);
unsigned int transferred = dfu_download(0, dfuBlockCount, block_size, block_data);
if(transferred != block_size)
{
/* Error */
@@ -334,7 +369,7 @@ int read_dfu_image(char *file)
static void print_device_list(FILE *file, const char *indent)
{
for (int i = 0; i < sizeof(pidList)/sizeof(pidList[0]); i++)
for (long unsigned int i = 0; i < sizeof(pidList)/sizeof(pidList[0]); i++)
{
fprintf(file, "%s%-30s (0x%0x)\n", indent, pidList[i].device_name, pidList[i].pid);
}
@@ -371,7 +406,7 @@ static unsigned int select_pid(char *device_pid)
}
// Otherwise do a lookup of names
for (int i = 0; i < sizeof(pidList)/sizeof(pidList[0]); i++)
for (long unsigned int i = 0; i < sizeof(pidList)/sizeof(pidList[0]); i++)
{
if (strcmp(device_pid, pidList[i].device_name) == 0)
{
@@ -501,7 +536,7 @@ int main(int argc, char **argv)
printf("Waiting for device to restart and enter DFU mode...\n");
// Wait for device to enter dfu mode and restart
system("sleep 20");
Sleep(20 * 1000);
#endif
// NOW IN DFU APPLICATION MODE
@@ -556,7 +591,7 @@ int main(int argc, char **argv)
printf("... Reverting device to factory image\n");
xmos_dfu_revertfactory();
// Give device time to revert firmware
system("sleep 2");
Sleep(2 * 1000);
xmos_dfu_resetfromdfu(XMOS_DFU_IF);
}
else
@@ -572,5 +607,5 @@ int main(int argc, char **argv)
libusb_close(devh);
libusb_exit(NULL);
return 1;
return 0;
}

View File

@@ -1,4 +1,4 @@
VERSION = 1.0.1
VERSION = 1.2.0
DEPENDENT_MODULES = lib_logging(>=3.0.0) \
lib_xassert(>=4.0.0) \
@@ -45,6 +45,7 @@ INCLUDE_DIRS = $(EXPORT_INCLUDE_DIRS) \
src/core/user/audiostream \
src/core/user/hid \
src/core/user/hostactive \
src/hid \
src/midi
SOURCE_DIRS = src/core \

View File

@@ -36,9 +36,10 @@ extern unsigned int g_curSamFreqMultiplier;
#define SET_SHARED_GLOBAL0(x,y) SET_SHARED_GLOBAL(x,y)
#endif
/* Global var for speed. Related to feedback. Used by input stream to determine IN packet size */
unsigned g_speed;
/* Initialise g_speed now so we get a sensible packet size until we start properly calculating feedback in the SoF case */
/* Without this, zero size input packets fill the input FIFO and it takes a long time to clear out when feedback starts */
/* This can cause a delay to the decouple ISR being serviced pushing our I2S timing. Initialising solves this */
unsigned g_speed = (AUDIO_CLASS == 2) ? (DEFAULT_FREQ/8000) << 16 : (DEFAULT_FREQ/1000) << 16;
unsigned g_freqChange = 0;
unsigned feedbackValid = 0;

View File

@@ -118,6 +118,9 @@ char g_product_str[XUA_MAX_STR_LEN] = PRODUCT_STR_A2;
char g_product_str[XUA_MAX_STR_LEN] = PRODUCT_STR_A1;
#endif
/* Global variable for current USB Serial Number strings */
char g_serial_str[XUA_MAX_STR_LEN] = SERIAL_STR;
/* Subslot */
const unsigned g_subSlot_Out_HS[OUTPUT_FORMAT_COUNT] = {HS_STREAM_FORMAT_OUTPUT_1_SUBSLOT_BYTES,
#if(OUTPUT_FORMAT_COUNT > 1)
@@ -289,6 +292,9 @@ void XUA_Endpoint0_setStrTable() {
concatenateAndCopyStrings(g_product_str, "", g_strTable.usbInputTermStr_Audio2);
concatenateAndCopyStrings(g_product_str, "", g_strTable.usbOutputTermStr_Audio2);
#endif
// update Serial strings
concatenateAndCopyStrings(g_serial_str, "", g_strTable.serialStr);
}
void XUA_Endpoint0_setVendorStr(char* vendor_str) {
@@ -301,6 +307,11 @@ void XUA_Endpoint0_setProductStr(char* product_str) {
concatenateAndCopyStrings(product_str, "", g_product_str);
}
void XUA_Endpoint0_setSerialStr(char* serial_str) {
debug_printf("XUA_Endpoint0_setSerialStr() with string %s\n", serial_str);
concatenateAndCopyStrings(serial_str, "", g_serial_str);
}
char* XUA_Endpoint0_getVendorStr() {
return g_strTable.vendorStr;
}
@@ -313,6 +324,10 @@ char* XUA_Endpoint0_getProductStr() {
#endif
}
char* XUA_Endpoint0_getSerialStr() {
return g_strTable.serialStr;
}
void XUA_Endpoint0_setProductId(unsigned short pid) {
#if (AUDIO_CLASS == 1)
devDesc_Audio1.idProduct = pid;

View File

@@ -40,6 +40,7 @@
#define XUA_CTRL_EMPTY_STRING "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\08"
#define XUA_MIDI_OUT_EMPTY_STRING "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\09"
#define XUA_MIDI_IN_EMPTY_STRING "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0a"
#define XUA_SERIAL_EMPTY_STRING "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0b"
// The value below must match the length of XUA_DESCR_EMPTY_STRING.
#define XUA_MAX_STR_LEN (32)
@@ -334,7 +335,7 @@ StringDescTable_t g_strTable =
{
.langID = "\x09\x04", /* US English */
.vendorStr = XUA_VENDOR_EMPTY_STRING,
.serialStr = "",
.serialStr = XUA_SERIAL_EMPTY_STRING,
#if (AUDIO_CLASS == 2)
.productStr_Audio2 = XUA_PRODUCT_EMPTY_STRING,
.outputInterfaceStr_Audio2 = XUA_PRODUCT_EMPTY_STRING,
@@ -434,7 +435,7 @@ USB_Descriptor_Device_t devDesc_Audio1 =
.bcdDevice = BCD_DEVICE,
.iManufacturer = offsetof(StringDescTable_t, vendorStr)/sizeof(char *),
.iProduct = offsetof(StringDescTable_t, productStr_Audio1)/sizeof(char *),
.iSerialNumber = 0,
.iSerialNumber = offsetof(StringDescTable_t, serialStr)/sizeof(char *),
.bNumConfigurations = 1
};
#endif
@@ -470,7 +471,7 @@ USB_Descriptor_Device_t devDesc_Audio2 =
.bcdDevice = BCD_DEVICE,
.iManufacturer = offsetof(StringDescTable_t, vendorStr)/sizeof(char *),
.iProduct = offsetof(StringDescTable_t, productStr_Audio2)/sizeof(char *),
.iSerialNumber = 0,
.iSerialNumber = offsetof(StringDescTable_t, serialStr)/sizeof(char *),
.bNumConfigurations = 0x02 /* Set to 2 such that windows does not load composite driver */
};
@@ -493,7 +494,7 @@ unsigned char devDesc_Null[] =
(BCD_DEVICE >> 8), /* 13 bcdDevice : Device release number */
offsetof(StringDescTable_t, vendorStr)/sizeof(char *),
offsetof(StringDescTable_t, productStr_Audio2)/sizeof(char *),
0, /* 16 iSerialNumber : Index of serial number decriptor */
offsetof(StringDescTable_t, serialStr)/sizeof(char *), /* 16 iSerialNumber : Index of serial number decriptor */
0x01 /* 17 bNumConfigurations : Number of possible configs */
};
#endif

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2015-2019, XMOS Ltd, All rights reserved
// Copyright (c) 2015-2020, XMOS Ltd, All rights reserved
#include "xua.h"
@@ -115,7 +115,7 @@ void XUA_PdmBuffer(streaming chanend c_ds_output[2], chanend c_audio)
dc[1].mic_gain_compensation[2]=0;
dc[1].mic_gain_compensation[3]=0;
dc[1].channel_count = 4;
dc[0].async_interface_enabled = 0;
dc[1].async_interface_enabled = 0;
mic_array_decimator_configure(c_ds_output, decimatorCount, dc);

View File

@@ -1,4 +1,4 @@
// Copyright (c) 2011-2018, XMOS Ltd, All rights reserved
// Copyright (c) 2011-2020, XMOS Ltd, All rights reserved
#include <xs1.h>
#include <platform.h>
#include <print.h>
@@ -61,7 +61,7 @@ unsigned int divide, unsigned curSamFreq)
}
#endif
#if defined(__XS2A__)
#if defined(__XS2A__) || defined(__XS3A__)
unsafe
{
/* Clock bitclock clock block from master clock pin (divided) */

View File

@@ -1,4 +1,5 @@
// Copyright (c) 2019, XMOS Ltd, All rights reserved
// Copyright (c) 2019-2020, XMOS Ltd, All rights reserved
#include <stdint.h>
#include <xs1.h>
#include "descriptor_defs.h"
#include "hid.h"