fix iar make build with stm32 l0, f2, f3, u5, wb
This commit is contained in:
@@ -40,17 +40,15 @@ static bool ejected = false;
|
|||||||
If you find any bugs or get any questions, feel free to file an\r\n\
|
If you find any bugs or get any questions, feel free to file an\r\n\
|
||||||
issue at github.com/hathach/tinyusb"
|
issue at github.com/hathach/tinyusb"
|
||||||
|
|
||||||
enum
|
enum {
|
||||||
{
|
DISK_BLOCK_NUM = 16,// 8KB is the smallest size that windows allow to mount
|
||||||
DISK_BLOCK_NUM = 16, // 8KB is the smallest size that windows allow to mount
|
|
||||||
DISK_BLOCK_SIZE = 512
|
DISK_BLOCK_SIZE = 512
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CFG_EXAMPLE_MSC_READONLY
|
#ifdef CFG_EXAMPLE_MSC_READONLY
|
||||||
const
|
const
|
||||||
#endif
|
#endif
|
||||||
uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
|
uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = {
|
||||||
{
|
|
||||||
//------------- Block0: Boot Sector -------------//
|
//------------- Block0: Boot Sector -------------//
|
||||||
// byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM;
|
// byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM;
|
||||||
// sector_per_cluster = 1; reserved_sectors = 1;
|
// sector_per_cluster = 1; reserved_sectors = 1;
|
||||||
@@ -59,11 +57,11 @@ uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
|
|||||||
// drive_number = 0x80; media_type = 0xf8; extended_boot_signature = 0x29;
|
// drive_number = 0x80; media_type = 0xf8; extended_boot_signature = 0x29;
|
||||||
// filesystem_type = "FAT12 "; volume_serial_number = 0x1234; volume_label = "TinyUSB MSC";
|
// filesystem_type = "FAT12 "; volume_serial_number = 0x1234; volume_label = "TinyUSB MSC";
|
||||||
// FAT magic code at offset 510-511
|
// FAT magic code at offset 510-511
|
||||||
{
|
{
|
||||||
0xEB, 0x3C, 0x90, 0x4D, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30, 0x00, 0x02, 0x01, 0x01, 0x00,
|
0xEB, 0x3C, 0x90, 0x4D, 0x53, 0x44, 0x4F, 0x53, 0x35, 0x2E, 0x30, 0x00, 0x02, 0x01, 0x01, 0x00,
|
||||||
0x01, 0x10, 0x00, 0x10, 0x00, 0xF8, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x01, 0x10, 0x00, 0x10, 0x00, 0xF8, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x29, 0x34, 0x12, 0x00, 0x00, 'T' , 'i' , 'n' , 'y' , 'U' ,
|
0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x29, 0x34, 0x12, 0x00, 0x00, 'T', 'i', 'n', 'y', 'U',
|
||||||
'S' , 'B' , ' ' , 'M' , 'S' , 'C' , 0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, 0x00, 0x00,
|
'S', 'B', ' ', 'M', 'S', 'C', 0x46, 0x41, 0x54, 0x31, 0x32, 0x20, 0x20, 0x20, 0x00, 0x00,
|
||||||
|
|
||||||
// Zero up to 2 last bytes of FAT magic code
|
// Zero up to 2 last bytes of FAT magic code
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
@@ -96,23 +94,22 @@ uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
|
|||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xAA
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0xAA},
|
||||||
},
|
|
||||||
|
|
||||||
//------------- Block1: FAT12 Table -------------//
|
//------------- Block1: FAT12 Table -------------//
|
||||||
{
|
{
|
||||||
0xF8, 0xFF, 0xFF, 0xFF, 0x0F // // first 2 entries must be F8FF, third entry is cluster end of readme file
|
0xF8, 0xFF, 0xFF, 0xFF, 0x0F// // first 2 entries must be F8FF, third entry is cluster end of readme file
|
||||||
},
|
},
|
||||||
|
|
||||||
//------------- Block2: Root Directory -------------//
|
//------------- Block2: Root Directory -------------//
|
||||||
{
|
{
|
||||||
// first entry is volume label
|
// first entry is volume label
|
||||||
'T' , 'i' , 'n' , 'y' , 'U' , 'S' , 'B' , ' ' , 'M' , 'S' , 'C' , 0x08, 0x00, 0x00, 0x00, 0x00,
|
'T', 'i', 'n', 'y', 'U', 'S', 'B', ' ', 'M', 'S', 'C', 0x08, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x6D, 0x65, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4F, 0x6D, 0x65, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
// second entry is readme file
|
// second entry is readme file
|
||||||
'R' , 'E' , 'A' , 'D' , 'M' , 'E' , ' ' , ' ' , 'T' , 'X' , 'T' , 0x20, 0x00, 0xC6, 0x52, 0x6D,
|
'R', 'E', 'A', 'D', 'M', 'E', ' ', ' ', 'T', 'X', 'T', 0x20, 0x00, 0xC6, 0x52, 0x6D,
|
||||||
0x65, 0x43, 0x65, 0x43, 0x00, 0x00, 0x88, 0x6D, 0x65, 0x43, 0x02, 0x00,
|
0x65, 0x43, 0x65, 0x43, 0x00, 0x00, 0x88, 0x6D, 0x65, 0x43, 0x02, 0x00,
|
||||||
sizeof(README_CONTENTS)-1, 0x00, 0x00, 0x00 // readme's files size (4 Bytes)
|
sizeof(README_CONTENTS) - 1, 0x00, 0x00, 0x00// readme's files size (4 Bytes)
|
||||||
},
|
},
|
||||||
|
|
||||||
//------------- Block3: Readme Content -------------//
|
//------------- Block3: Readme Content -------------//
|
||||||
@@ -121,23 +118,21 @@ uint8_t msc_disk[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
|
|||||||
|
|
||||||
// Invoked when received SCSI_CMD_INQUIRY
|
// Invoked when received SCSI_CMD_INQUIRY
|
||||||
// Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively
|
// Application fill vendor id, product id and revision with string up to 8, 16, 4 characters respectively
|
||||||
void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4])
|
void tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], uint8_t product_rev[4]) {
|
||||||
{
|
|
||||||
(void) lun;
|
(void) lun;
|
||||||
|
|
||||||
const char vid[] = "TinyUSB";
|
const char vid[] = "TinyUSB";
|
||||||
const char pid[] = "Mass Storage";
|
const char pid[] = "Mass Storage";
|
||||||
const char rev[] = "1.0";
|
const char rev[] = "1.0";
|
||||||
|
|
||||||
memcpy(vendor_id , vid, strlen(vid));
|
memcpy(vendor_id, vid, strlen(vid));
|
||||||
memcpy(product_id , pid, strlen(pid));
|
memcpy(product_id, pid, strlen(pid));
|
||||||
memcpy(product_rev, rev, strlen(rev));
|
memcpy(product_rev, rev, strlen(rev));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Invoked when received Test Unit Ready command.
|
// Invoked when received Test Unit Ready command.
|
||||||
// return true allowing host to read/write this LUN e.g SD card inserted
|
// return true allowing host to read/write this LUN e.g SD card inserted
|
||||||
bool tud_msc_test_unit_ready_cb(uint8_t lun)
|
bool tud_msc_test_unit_ready_cb(uint8_t lun) {
|
||||||
{
|
|
||||||
(void) lun;
|
(void) lun;
|
||||||
|
|
||||||
// RAM disk is ready until ejected
|
// RAM disk is ready until ejected
|
||||||
@@ -152,8 +147,7 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun)
|
|||||||
|
|
||||||
// Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size
|
// Invoked when received SCSI_CMD_READ_CAPACITY_10 and SCSI_CMD_READ_FORMAT_CAPACITY to determine the disk size
|
||||||
// Application update block count and block size
|
// Application update block count and block size
|
||||||
void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_size)
|
void tud_msc_capacity_cb(uint8_t lun, uint32_t *block_count, uint16_t *block_size) {
|
||||||
{
|
|
||||||
(void) lun;
|
(void) lun;
|
||||||
|
|
||||||
*block_count = DISK_BLOCK_NUM;
|
*block_count = DISK_BLOCK_NUM;
|
||||||
@@ -163,18 +157,14 @@ void tud_msc_capacity_cb(uint8_t lun, uint32_t* block_count, uint16_t* block_siz
|
|||||||
// Invoked when received Start Stop Unit command
|
// Invoked when received Start Stop Unit command
|
||||||
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
|
// - Start = 0 : stopped power mode, if load_eject = 1 : unload disk storage
|
||||||
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
|
// - Start = 1 : active mode, if load_eject = 1 : load disk storage
|
||||||
bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject)
|
bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, bool load_eject) {
|
||||||
{
|
|
||||||
(void) lun;
|
(void) lun;
|
||||||
(void) power_condition;
|
(void) power_condition;
|
||||||
|
|
||||||
if ( load_eject )
|
if (load_eject) {
|
||||||
{
|
if (start) {
|
||||||
if (start)
|
|
||||||
{
|
|
||||||
// load disk storage
|
// load disk storage
|
||||||
}else
|
} else {
|
||||||
{
|
|
||||||
// unload disk storage
|
// unload disk storage
|
||||||
ejected = true;
|
ejected = true;
|
||||||
}
|
}
|
||||||
@@ -185,52 +175,51 @@ bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo
|
|||||||
|
|
||||||
// Callback invoked when received READ10 command.
|
// Callback invoked when received READ10 command.
|
||||||
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
|
// Copy disk's data to buffer (up to bufsize) and return number of copied bytes.
|
||||||
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void* buffer, uint32_t bufsize)
|
int32_t tud_msc_read10_cb(uint8_t lun, uint32_t lba, uint32_t offset, void *buffer, uint32_t bufsize) {
|
||||||
{
|
|
||||||
(void) lun;
|
(void) lun;
|
||||||
|
|
||||||
// out of ramdisk
|
// out of ramdisk
|
||||||
if ( lba >= DISK_BLOCK_NUM ) {
|
if (lba >= DISK_BLOCK_NUM) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for overflow of offset + bufsize
|
// Check for overflow of offset + bufsize
|
||||||
if ( offset + bufsize > DISK_BLOCK_SIZE ) {
|
if (offset + bufsize > DISK_BLOCK_SIZE) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t const* addr = msc_disk[lba] + offset;
|
uint8_t const *addr = msc_disk[lba] + offset;
|
||||||
memcpy(buffer, addr, bufsize);
|
memcpy(buffer, addr, bufsize);
|
||||||
|
|
||||||
return (int32_t) bufsize;
|
return (int32_t) bufsize;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool tud_msc_is_writable_cb (uint8_t lun)
|
bool tud_msc_is_writable_cb(uint8_t lun) {
|
||||||
{
|
|
||||||
(void) lun;
|
(void) lun;
|
||||||
|
|
||||||
#ifdef CFG_EXAMPLE_MSC_READONLY
|
#ifdef CFG_EXAMPLE_MSC_READONLY
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Callback invoked when received WRITE10 command.
|
// Callback invoked when received WRITE10 command.
|
||||||
// Process data in buffer to disk's storage and return number of written bytes
|
// Process data in buffer to disk's storage and return number of written bytes
|
||||||
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize)
|
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t *buffer, uint32_t bufsize) {
|
||||||
{
|
|
||||||
(void) lun;
|
(void) lun;
|
||||||
|
|
||||||
// out of ramdisk
|
// out of ramdisk
|
||||||
if ( lba >= DISK_BLOCK_NUM ) return -1;
|
if (lba >= DISK_BLOCK_NUM) return -1;
|
||||||
|
|
||||||
#ifndef CFG_EXAMPLE_MSC_READONLY
|
#ifndef CFG_EXAMPLE_MSC_READONLY
|
||||||
uint8_t* addr = msc_disk[lba] + offset;
|
uint8_t *addr = msc_disk[lba] + offset;
|
||||||
memcpy(addr, buffer, bufsize);
|
memcpy(addr, buffer, bufsize);
|
||||||
#else
|
#else
|
||||||
(void) lba; (void) offset; (void) buffer;
|
(void) lba;
|
||||||
#endif
|
(void) offset;
|
||||||
|
(void) buffer;
|
||||||
|
#endif
|
||||||
|
|
||||||
return (int32_t) bufsize;
|
return (int32_t) bufsize;
|
||||||
}
|
}
|
||||||
@@ -238,42 +227,18 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
|
|||||||
// Callback invoked when received an SCSI command not in built-in list below
|
// Callback invoked when received an SCSI command not in built-in list below
|
||||||
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
|
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
|
||||||
// - READ10 and WRITE10 has their own callbacks
|
// - READ10 and WRITE10 has their own callbacks
|
||||||
int32_t tud_msc_scsi_cb (uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize)
|
int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void *buffer, uint16_t bufsize) {
|
||||||
{
|
(void) buffer;
|
||||||
// read10 & write10 has their own callback and MUST not be handled here
|
(void) bufsize;
|
||||||
|
|
||||||
void const* response = NULL;
|
switch (scsi_cmd[0]) {
|
||||||
int32_t resplen = 0;
|
|
||||||
|
|
||||||
// most scsi handled is input
|
|
||||||
bool in_xfer = true;
|
|
||||||
|
|
||||||
switch (scsi_cmd[0])
|
|
||||||
{
|
|
||||||
default:
|
default:
|
||||||
// Set Sense = Invalid Command Operation
|
// Set Sense = Invalid Command Operation
|
||||||
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
|
||||||
|
|
||||||
// negative means error -> tinyusb could stall and/or response with failed status
|
// negative means error -> tinyusb could stall and/or response with failed status
|
||||||
resplen = -1;
|
return -1;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// return resplen must not larger than bufsize
|
|
||||||
if ( resplen > bufsize ) resplen = bufsize;
|
|
||||||
|
|
||||||
if ( response && (resplen > 0) )
|
|
||||||
{
|
|
||||||
if(in_xfer)
|
|
||||||
{
|
|
||||||
memcpy(buffer, response, (size_t) resplen);
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
// SCSI output
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return (int32_t) resplen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -55,8 +55,7 @@ If you find any bugs or get any questions, feel free to file an\r\n\
|
|||||||
issue at github.com/hathach/tinyusb"
|
issue at github.com/hathach/tinyusb"
|
||||||
|
|
||||||
|
|
||||||
MSC_CONST uint8_t msc_disk0[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] =
|
MSC_CONST uint8_t msc_disk0[DISK_BLOCK_NUM][DISK_BLOCK_SIZE] = {
|
||||||
{
|
|
||||||
//------------- Block0: Boot Sector -------------//
|
//------------- Block0: Boot Sector -------------//
|
||||||
// byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM;
|
// byte_per_sector = DISK_BLOCK_SIZE; fat12_sector_num_16 = DISK_BLOCK_NUM;
|
||||||
// sector_per_cluster = 1; reserved_sectors = 1;
|
// sector_per_cluster = 1; reserved_sectors = 1;
|
||||||
@@ -283,9 +282,11 @@ bool tud_msc_is_writable_cb(uint8_t lun) {
|
|||||||
// Process data in buffer to disk's storage and return number of written bytes
|
// Process data in buffer to disk's storage and return number of written bytes
|
||||||
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) {
|
int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t* buffer, uint32_t bufsize) {
|
||||||
// out of ramdisk
|
// out of ramdisk
|
||||||
if (lba >= DISK_BLOCK_NUM) return -1;
|
if (lba >= DISK_BLOCK_NUM) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
#if defined(CFG_EXAMPLE_MSC_READONLY) || defined(CFG_EXAMPLE_MSC_DUAL_READONLY)
|
#if defined(CFG_EXAMPLE_MSC_READONLY) || defined(CFG_EXAMPLE_MSC_DUAL_READONLY)
|
||||||
(void) lun;
|
(void) lun;
|
||||||
(void) lba;
|
(void) lba;
|
||||||
(void) offset;
|
(void) offset;
|
||||||
@@ -302,11 +303,8 @@ int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint32_t offset, uint8_t*
|
|||||||
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
|
// - READ_CAPACITY10, READ_FORMAT_CAPACITY, INQUIRY, MODE_SENSE6, REQUEST_SENSE
|
||||||
// - READ10 and WRITE10 has their own callbacks (MUST not be handled here)
|
// - READ10 and WRITE10 has their own callbacks (MUST not be handled here)
|
||||||
int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) {
|
int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, uint16_t bufsize) {
|
||||||
void const* response = NULL;
|
(void) buffer;
|
||||||
int32_t resplen = 0;
|
(void) bufsize;
|
||||||
|
|
||||||
// most scsi handled is input
|
|
||||||
bool in_xfer = true;
|
|
||||||
|
|
||||||
switch (scsi_cmd[0]) {
|
switch (scsi_cmd[0]) {
|
||||||
default:
|
default:
|
||||||
@@ -316,19 +314,6 @@ int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void* buffer, u
|
|||||||
// negative means error -> tinyusb could stall and/or response with failed status
|
// negative means error -> tinyusb could stall and/or response with failed status
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return resplen must not larger than bufsize
|
|
||||||
if (resplen > bufsize) resplen = bufsize;
|
|
||||||
|
|
||||||
if (response && (resplen > 0)) {
|
|
||||||
if (in_xfer) {
|
|
||||||
memcpy(buffer, response, (size_t) resplen);
|
|
||||||
} else {
|
|
||||||
// SCSI output
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return resplen;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,12 +1,9 @@
|
|||||||
CFLAGS += \
|
MCU_VARIANT = stm32f207xx
|
||||||
-DSTM32F207xx \
|
CFLAGS += -DSTM32F207xx
|
||||||
|
|
||||||
# All source paths should be relative to the top level.
|
# All source paths should be relative to the top level.
|
||||||
LD_FILE = $(BOARD_PATH)/STM32F207ZGTx_FLASH.ld
|
LD_FILE = $(BOARD_PATH)/STM32F207ZGTx_FLASH.ld
|
||||||
|
|
||||||
SRC_S += \
|
|
||||||
$(ST_CMSIS)/Source/Templates/gcc/startup_stm32f207xx.s
|
|
||||||
|
|
||||||
# For flash-jlink target
|
# For flash-jlink target
|
||||||
JLINK_DEVICE = stm32f207zg
|
JLINK_DEVICE = stm32f207zg
|
||||||
|
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
ST_FAMILY = f2
|
ST_FAMILY = f2
|
||||||
|
|
||||||
ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
|
ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
|
||||||
ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
|
ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
|
||||||
|
|
||||||
@@ -14,11 +13,10 @@ CPU_CORE ?= cortex-m3
|
|||||||
CFLAGS += \
|
CFLAGS += \
|
||||||
-DCFG_TUSB_MCU=OPT_MCU_STM32F2
|
-DCFG_TUSB_MCU=OPT_MCU_STM32F2
|
||||||
|
|
||||||
|
# mcu driver cause following warnings
|
||||||
CFLAGS_GCC += \
|
CFLAGS_GCC += \
|
||||||
-flto \
|
-flto \
|
||||||
|
-Wno-error=sign-compare
|
||||||
# mcu driver cause following warnings
|
|
||||||
CFLAGS_GCC += -Wno-error=sign-compare
|
|
||||||
|
|
||||||
LDFLAGS_GCC += \
|
LDFLAGS_GCC += \
|
||||||
-nostdlib -nostartfiles \
|
-nostdlib -nostartfiles \
|
||||||
@@ -40,3 +38,10 @@ INC += \
|
|||||||
$(TOP)/$(ST_CMSIS)/Include \
|
$(TOP)/$(ST_CMSIS)/Include \
|
||||||
$(TOP)/$(ST_HAL_DRIVER)/Inc \
|
$(TOP)/$(ST_HAL_DRIVER)/Inc \
|
||||||
$(TOP)/$(BOARD_PATH)
|
$(TOP)/$(BOARD_PATH)
|
||||||
|
|
||||||
|
# Startup
|
||||||
|
SRC_S_GCC += $(ST_CMSIS)/Source/Templates/gcc/startup_${MCU_VARIANT}.s
|
||||||
|
SRC_S_IAR += $(ST_CMSIS)/Source/Templates/iar/startup_${MCU_VARIANT}.s
|
||||||
|
|
||||||
|
# Linker
|
||||||
|
LD_FILE_IAR ?= $(ST_CMSIS)/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
|
MCU_VARIANT = stm32f303xc
|
||||||
CFLAGS += \
|
CFLAGS += \
|
||||||
-DSTM32F303xC \
|
-DSTM32F303xC \
|
||||||
|
|
||||||
# All source paths should be relative to the top level.
|
# All source paths should be relative to the top level.
|
||||||
LD_FILE = $(BOARD_PATH)/STM32F303VCTx_FLASH.ld
|
LD_FILE = $(BOARD_PATH)/STM32F303VCTx_FLASH.ld
|
||||||
|
|
||||||
SRC_S += \
|
|
||||||
$(ST_CMSIS)/Source/Templates/gcc/startup_stm32f303xc.s
|
|
||||||
|
|
||||||
# For flash-jlink target
|
# For flash-jlink target
|
||||||
JLINK_DEVICE = stm32f303vc
|
JLINK_DEVICE = stm32f303vc
|
||||||
|
|
||||||
|
@@ -1,22 +1,17 @@
|
|||||||
ST_FAMILY = f3
|
ST_FAMILY = f3
|
||||||
|
|
||||||
ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
|
ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
|
||||||
ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
|
ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
|
||||||
|
|
||||||
DEPS_SUBMODULES += \
|
|
||||||
lib/CMSIS_5 \
|
|
||||||
$(ST_CMSIS) \
|
|
||||||
$(ST_HAL_DRIVER)
|
|
||||||
|
|
||||||
include $(TOP)/$(BOARD_PATH)/board.mk
|
include $(TOP)/$(BOARD_PATH)/board.mk
|
||||||
CPU_CORE ?= cortex-m4
|
CPU_CORE ?= cortex-m4
|
||||||
|
|
||||||
CFLAGS += \
|
CFLAGS += \
|
||||||
-flto \
|
|
||||||
-DCFG_TUSB_MCU=OPT_MCU_STM32F3
|
-DCFG_TUSB_MCU=OPT_MCU_STM32F3
|
||||||
|
|
||||||
# mcu driver cause following warnings
|
# mcu driver cause following warnings
|
||||||
CFLAGS += -Wno-error=unused-parameter
|
CFLAGS_GCC += \
|
||||||
|
-flto \
|
||||||
|
-Wno-error=unused-parameter
|
||||||
|
|
||||||
LDFLAGS_GCC += \
|
LDFLAGS_GCC += \
|
||||||
-nostdlib -nostartfiles \
|
-nostdlib -nostartfiles \
|
||||||
@@ -36,3 +31,10 @@ INC += \
|
|||||||
$(TOP)/$(ST_CMSIS)/Include \
|
$(TOP)/$(ST_CMSIS)/Include \
|
||||||
$(TOP)/$(ST_HAL_DRIVER)/Inc \
|
$(TOP)/$(ST_HAL_DRIVER)/Inc \
|
||||||
$(TOP)/$(BOARD_PATH)
|
$(TOP)/$(BOARD_PATH)
|
||||||
|
|
||||||
|
# Startup
|
||||||
|
SRC_S_GCC += $(ST_CMSIS)/Source/Templates/gcc/startup_${MCU_VARIANT}.s
|
||||||
|
SRC_S_IAR += $(ST_CMSIS)/Source/Templates/iar/startup_${MCU_VARIANT}.s
|
||||||
|
|
||||||
|
# Linker
|
||||||
|
LD_FILE_IAR ?= $(ST_CMSIS)/Source/Templates/iar/linker/${MCU_VARIANT}_flash.icf
|
||||||
|
@@ -1,10 +1,9 @@
|
|||||||
|
MCU_VARIANT = stm32l052xx
|
||||||
CFLAGS += \
|
CFLAGS += \
|
||||||
-DSTM32L052xx
|
-DSTM32L052xx
|
||||||
|
|
||||||
LD_FILE = $(BOARD_PATH)/STM32L052K8Ux_FLASH.ld
|
LD_FILE = $(BOARD_PATH)/STM32L052K8Ux_FLASH.ld
|
||||||
|
|
||||||
SRC_S += $(ST_CMSIS)/Source/Templates/gcc/startup_stm32l052xx.s
|
|
||||||
|
|
||||||
# For flash-jlink target
|
# For flash-jlink target
|
||||||
JLINK_DEVICE = stm32l052k8
|
JLINK_DEVICE = stm32l052k8
|
||||||
|
|
||||||
|
@@ -1,12 +1,10 @@
|
|||||||
|
MCU_VARIANT = stm32l053xx
|
||||||
CFLAGS += \
|
CFLAGS += \
|
||||||
-DSTM32L053xx
|
-DSTM32L053xx
|
||||||
|
|
||||||
# All source paths should be relative to the top level.
|
# All source paths should be relative to the top level.
|
||||||
LD_FILE = $(BOARD_PATH)/STM32L053C8Tx_FLASH.ld
|
LD_FILE = $(BOARD_PATH)/STM32L053C8Tx_FLASH.ld
|
||||||
|
|
||||||
SRC_S += \
|
|
||||||
$(ST_CMSIS)/Source/Templates/gcc/startup_stm32l053xx.s
|
|
||||||
|
|
||||||
# For flash-jlink target
|
# For flash-jlink target
|
||||||
JLINK_DEVICE = STM32L053R8
|
JLINK_DEVICE = STM32L053R8
|
||||||
|
|
||||||
|
@@ -1,9 +1,4 @@
|
|||||||
ST_FAMILY = l0
|
ST_FAMILY = l0
|
||||||
DEPS_SUBMODULES += \
|
|
||||||
lib/CMSIS_5 \
|
|
||||||
hw/mcu/st/cmsis_device_$(ST_FAMILY) \
|
|
||||||
hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
|
|
||||||
|
|
||||||
ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
|
ST_CMSIS = hw/mcu/st/cmsis_device_$(ST_FAMILY)
|
||||||
ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
|
ST_HAL_DRIVER = hw/mcu/st/stm32$(ST_FAMILY)xx_hal_driver
|
||||||
|
|
||||||
@@ -11,20 +6,17 @@ include $(TOP)/$(BOARD_PATH)/board.mk
|
|||||||
CPU_CORE ?= cortex-m0plus
|
CPU_CORE ?= cortex-m0plus
|
||||||
|
|
||||||
CFLAGS += \
|
CFLAGS += \
|
||||||
-flto \
|
|
||||||
-DCFG_EXAMPLE_MSC_READONLY \
|
-DCFG_EXAMPLE_MSC_READONLY \
|
||||||
-DCFG_EXAMPLE_VIDEO_READONLY \
|
-DCFG_EXAMPLE_VIDEO_READONLY \
|
||||||
-DCFG_TUSB_MCU=OPT_MCU_STM32L0
|
-DCFG_TUSB_MCU=OPT_MCU_STM32L0
|
||||||
|
|
||||||
# mcu driver cause following warnings
|
# mcu driver cause following warnings
|
||||||
CFLAGS_GCC += \
|
CFLAGS_GCC += \
|
||||||
|
-flto \
|
||||||
-Wno-error=unused-parameter \
|
-Wno-error=unused-parameter \
|
||||||
-Wno-error=redundant-decls \
|
-Wno-error=redundant-decls \
|
||||||
-Wno-error=cast-align \
|
-Wno-error=cast-align \
|
||||||
|
-Wno-error=maybe-uninitialized \
|
||||||
ifeq ($(TOOLCHAIN),gcc)
|
|
||||||
CFLAGS_GCC += -Wno-error=maybe-uninitialized
|
|
||||||
endif
|
|
||||||
|
|
||||||
CFLAGS_CLANG += \
|
CFLAGS_CLANG += \
|
||||||
-Wno-error=parentheses-equality
|
-Wno-error=parentheses-equality
|
||||||
@@ -48,3 +40,10 @@ INC += \
|
|||||||
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
|
$(TOP)/lib/CMSIS_5/CMSIS/Core/Include \
|
||||||
$(TOP)/$(ST_CMSIS)/Include \
|
$(TOP)/$(ST_CMSIS)/Include \
|
||||||
$(TOP)/$(ST_HAL_DRIVER)/Inc
|
$(TOP)/$(ST_HAL_DRIVER)/Inc
|
||||||
|
|
||||||
|
# Startup
|
||||||
|
SRC_S_GCC += $(ST_CMSIS)/Source/Templates/gcc/startup_${MCU_VARIANT}.s
|
||||||
|
SRC_S_IAR += $(ST_CMSIS)/Source/Templates/iar/startup_${MCU_VARIANT}.s
|
||||||
|
|
||||||
|
# Linker
|
||||||
|
LD_FILE_IAR ?= $(ST_CMSIS)/Source/Templates/iar/linker/$(MCU_VARIANT)_flash.icf
|
||||||
|
Reference in New Issue
Block a user