aboutsummaryrefslogtreecommitdiff
path: root/bootloaders/diskloader/src
diff options
context:
space:
mode:
authorZach Eveland <zeveland@blacklabel-development.com>2011-09-08 09:12:30 -0400
committerZach Eveland <zeveland@blacklabel-development.com>2011-09-08 09:12:30 -0400
commit384f8e80fa55b1a704674a4ee19192328ec90abe (patch)
tree1a1d22f7df6f746e9700cee9ef97c66ee10d75b0 /bootloaders/diskloader/src
parentd81084e8e91ec4abc24e4b3f6a9ecb9621a6c736 (diff)
removed all bootloader mass storage and MSC references
Diffstat (limited to 'bootloaders/diskloader/src')
-rw-r--r--bootloaders/diskloader/src/DiskLoader.cpp12
-rw-r--r--bootloaders/diskloader/src/Platform.h10
-rw-r--r--bootloaders/diskloader/src/SCSI.cpp213
-rw-r--r--bootloaders/diskloader/src/ThinFAT.cpp130
-rw-r--r--bootloaders/diskloader/src/USBCore.cpp29
-rw-r--r--bootloaders/diskloader/src/USBCore.h15
-rw-r--r--bootloaders/diskloader/src/USBDesc.cpp21
-rw-r--r--bootloaders/diskloader/src/USBDesc.h30
8 files changed, 8 insertions, 452 deletions
diff --git a/bootloaders/diskloader/src/DiskLoader.cpp b/bootloaders/diskloader/src/DiskLoader.cpp
index 9ecbc4b..34a9c94 100644
--- a/bootloaders/diskloader/src/DiskLoader.cpp
+++ b/bootloaders/diskloader/src/DiskLoader.cpp
@@ -112,8 +112,6 @@ const u8 _consts[] =
void USBInit(void);
-extern u8 _sector3[512];
-
int main(void) __attribute__ ((naked));
// STK500v1 main loop, very similar to optiboot in protocol and implementation
@@ -125,16 +123,12 @@ int main()
BOARD_INIT();
USBInit();
-#ifdef WRITABLE_DIRECTORY
- _sector3[0] = 0;
-#endif
-
_inSync = STK_INSYNC;
_ok = STK_OK;
-#ifndef MSC_ENABLED
+
if (pgm_read_word(0) != -1)
_ejected = 1;
-#endif
+
for(;;)
{
u8* packet = _flashbuf;
@@ -153,9 +147,7 @@ int main()
if (c == cmd || c == 0)
break;
}
-#ifndef MSC_ENABLED
_timeout = 0;
-#endif
// Read params
Recv(CDC_RX,packet,len);
diff --git a/bootloaders/diskloader/src/Platform.h b/bootloaders/diskloader/src/Platform.h
index 004933e..416d9c3 100644
--- a/bootloaders/diskloader/src/Platform.h
+++ b/bootloaders/diskloader/src/Platform.h
@@ -14,14 +14,6 @@ typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned long u32;
-//#define MICROTOUCH
-
-//#define WRITABLE_DIRECTORY // undef saved 56 + 512 RAM
-
-#define FAT_DISK_LABEL 'b','o','o','t','l','o','a','d','e','r',' ' // 11 chars (undef saves 12)
-#define FAT_FILE_NAME 'F','I','R','M','W','A','R','E','B','I','N' // 11 chars
-#define MSC_DISK_SERIAL '0','0','0','0','0','0','0','0','1','7','0','1' // 12 chars
-
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
#define DISABLE_JTAG() MCUCR = (1 << JTD) | (1 << IVCE) | (0 << PUD); MCUCR = (1 << JTD) | (0 << IVSEL) | (0 << IVCE) | (0 << PUD);
@@ -47,8 +39,6 @@ void Recv(u8 ep, u8* dst, u8 len);
void Program(u8 ep, u16 page, u8 count);
#define CDC_ENABLED
-//#define MSC_ENABLED
-//#define MSC_NO_MEDIA // MSC is enabled but not media inserted
#include "USBCore.h"
#include "USBDesc.h"
diff --git a/bootloaders/diskloader/src/SCSI.cpp b/bootloaders/diskloader/src/SCSI.cpp
deleted file mode 100644
index dbbf9cf..0000000
--- a/bootloaders/diskloader/src/SCSI.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-
-
-/* Copyright (c) 2010, Peter Barrett
-**
-** Permission to use, copy, modify, and/or distribute this software for
-** any purpose with or without fee is hereby granted, provided that the
-** above copyright notice and this permission notice appear in all copies.
-**
-** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
-** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
-** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
-** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-** SOFTWARE.
-*/
-
-#include "Platform.h"
-
-#ifdef MSC_ENABLED
-
-// SCSI Commands
-#define TEST_UNIT_READY 0x00
-#define REQUEST_SENSE 0x03
-#define FORMAT_UNIT 0x04
-#define INQUIRY 0x12
-#define MODE_SENSE 0x1A
-#define START_STOP_UNIT 0x1B
-#define MEDIA_REMOVAL 0x1E
-#define READ_FORMAT_CAPACITIES 0x23
-#define READ_CAPACITY 0x25
-#define READ10 0x28
-#define WRITE10 0x2A
-#define VERIFY10 0x2F
-
-
-// In FakeFAT
-void SendSector(u8 b);
-void RecvSector(u8 b);
-
-// In USBCore
-u8 RecvPacket(u8 ep, u8* dst, u8 len);
-u8 SendPacket(u8 ep, const u8* src, u8 len);
-void Reboot();
-
-#define MSC_TX MSC_ENDPOINT_IN
-#define MSC_RX MSC_ENDPOINT_OUT
-
-extern const u8 P_Inquiry[36] PROGMEM;
-extern const u8 P_RequestSense[18] PROGMEM;
-extern const u8 P_ReadCapacity[8-3] PROGMEM;
-extern const u8 P_ModeSense[4] PROGMEM;
-
-typedef struct
-{
- u8 signature[4];
- u8 tag[4];
- u32 transferLength;
- u8 flags;
- u8 lun;
- u8 cblength;
- u8 cb[16];
-} CBW;
-
-const u8 P_Inquiry[36] =
-{
- 0x00, // Direct Access Device
- 0x80, // Removable Medium
- 0x00, // Version
- 0x01,
-
- 36-4, // Additional Length
- 0x80, // Storage Controller Component
- 0x00,
- 0x00,
-
- 'r','o','s','s','u','m','u','r', // Vendor
-
- 'm','i','c','r','o','t','o','u', // Product
- 'c','h',' ',' ',' ',' ',' ',' ',
-
- '2','.','4',' ' // Revision
-};
-
-const u8 P_RequestSense[18] =
-{
- 0x70, // Response Code
- 0x00,
-// 0x02, // Sense Key
- 0x00,
- 0x00,
-
- 0x00,
- 0x00,
- 0x00,
- 0x0A, // Additional Length
-
- 0x00,
- 0x00,
- 0x00,
- 0x00,
-
- 0x30, // ASC
- 0x01, // ASCQ
-
- 0x00,
- 0x00,
- 0x00,
- 0x00
-};
-
-// Save 3 bytes if merging
-const u8 P_ReadCapacity[8-3] =
-{
-// 0x00,
-// 0x00,
-// 0x00, // Steal 3 zero bytes from end of P_RequestSense
- 64+4, // block count 64 + 4
- 0x00,
- 0x00,
- 0x02, // block size = 512
- 0x00
-};
-
-const u8 P_ModeSense[4] =
-{
- 0x03,
- 0x00,
- 0x00,
- 0x00
-};
-
-extern volatile u8 _ejected;
-
-void SCSI(CBW& cbw)
-{
- const u8* pgm = 0;
- u8 status = 0;
- u8 blen = 0;
-
- u8 cmd = cbw.cb[0];
- if (START_STOP_UNIT == cmd)
- {
- _ejected = 1; // Stopped; going away
- }
- else if (TEST_UNIT_READY == cmd || MEDIA_REMOVAL == cmd)
- {
-#ifdef MSC_NO_MEDIA
- status = 1;
-#else
- status = _ejected;
-#endif
- }
- else if (REQUEST_SENSE == cmd)
- {
- pgm = P_RequestSense;
- blen = sizeof(P_RequestSense);
- }
- else if (INQUIRY == cmd)
- {
- pgm = P_Inquiry;
- blen = sizeof(P_Inquiry);
- }
- else if (WRITE10 == cmd || READ10 == cmd)
- {
- // Write 10 byte form
- // Read 10 byte form
- {
- u8 lba = cbw.cb[5];
- u8 count = cbw.cb[8];
- u8 read = READ10 == cbw.cb[0];
- while (count--)
- {
- if (read)
- SendSector(lba);
- else
- RecvSector(lba);
- lba++;
- cbw.transferLength -= 512; // 24 bytes
- }
- }
- }
- else if (MODE_SENSE == cmd)
- {
- pgm = P_ModeSense;
- blen = 4;
- }
- else
- {
- pgm = P_ReadCapacity-3;
- blen = 8;
- if (READ_CAPACITY != cmd)
- status = 1; // Faking a data phase for unknown commands
- }
-
- if (pgm)
- Transfer(MSC_TX | TRANSFER_PGM | TRANSFER_RELEASE,pgm,blen);
-
- cbw.flags = status;
- cbw.transferLength -= blen;
- cbw.signature[3] = 'S';
- Transfer(MSC_TX | TRANSFER_RELEASE,(u8*)&cbw,13);
-}
-
-CBW cbw; // 38 byte savings by making this global
-void SCSITask()
-{
- Recv(MSC_RX,(u8*)&cbw,sizeof(CBW));
- SCSI(cbw);
-}
-
-#endif \ No newline at end of file
diff --git a/bootloaders/diskloader/src/ThinFAT.cpp b/bootloaders/diskloader/src/ThinFAT.cpp
deleted file mode 100644
index c238741..0000000
--- a/bootloaders/diskloader/src/ThinFAT.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-
-
-/* Copyright (c) 2011, Peter Barrett
-**
-** Permission to use, copy, modify, and/or distribute this software for
-** any purpose with or without fee is hereby granted, provided that the
-** above copyright notice and this permission notice appear in all copies.
-**
-** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
-** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
-** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR
-** BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
-** OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-** WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-** ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-** SOFTWARE.
-*/
-
-#include "Platform.h"
-
-#ifdef MSC_ENABLED
-
-extern const u8 Sector_0[] PROGMEM;
-extern const u8 Sector_1[] PROGMEM;
-extern const u8 Sector_2[] PROGMEM;
-extern const u8 Sector_3[] PROGMEM;
-extern const u8 Sector_Size[] PROGMEM;
-
-
-const u8 Sector_0[27] =
-{
- 0xEB,0x3C,0x90,
- FAT_OEM_NAME,
- 0x00,0x02, // Bytes per sector 512
- 0x40, // Sectors per Cluster 32k per cluster
- 0x01,0x00, // Reserved sectors
- 0x02, // FATSs
- 0x10,0x00, // root entries
- 4+64,0x00, // number of sectors: 30k file
- 0xF8, // Media type fixed
- 0x01,0x00, // Sectors per FAT
- 0x01,0x00, // Sectors per head
- 0x01,//0x00, // Heads per cylinder
- //0x00,0x00,0x00,0x00, // Hidden
- //0x00,0x00,0x00,0x00, // long number of sectors
- //0x00,0x00, // Ext flags
- // 38 bytes
-};
-
-// FAT12 clusters for 32k file
-const u8 Sector_1[] =
-{
-#if 0
- 0xF8,0xFF,0xFF,
- 0xFF,0x0F//,0x00
-#endif
-};
-
-const u8 Sector_2[] =
-{
-};
-
-const u8 Sector_3[] =
-{
-#if 0
- FAT_FILE_NAME, 0x00,0x00,0x00,0x00,0x00, // Uppercase name please
- 0x43,0x3E,0x43,0x3E,0x00,0x00,0xAB,0x8C,0x40,0x3E,0x02,0x00,0x00,0x80,//0x00,0x00
- // 0x00,0x00,
-#endif
-
-#ifdef FAT_DISK_LABEL
- FAT_DISK_LABEL,0x28
-#endif
-};
-
-#if 0
-const u8 Sector_Size[] =
-{
- 0,
- sizeof(Sector_0),
- sizeof(Sector_0) + sizeof(Sector_1),
- sizeof(Sector_0) + sizeof(Sector_1) + sizeof(Sector_2),
- sizeof(Sector_0) + sizeof(Sector_1) + sizeof(Sector_2) + sizeof(Sector_3)
-};
-#endif
-
-const u8* LBAToROM(u8 b)
-{
- b -= 4;
- return (const u8*)(b << 9);
-}
-
-void SendSector(u8 b)
-{
- if (b == 0)
- {
- u8 n = sizeof(Sector_0);
- Transfer(MSC_TX | TRANSFER_PGM,Sector_0,n);
- Transfer(MSC_TX | TRANSFER_ZERO,0,512-n);
- return;
- }
-
- if ((b < 4) || (b >= 64))
- {
- Transfer(MSC_TX | TRANSFER_ZERO,0,512);
- return;
- }
-
- // Copy body of file from ROM
- Transfer(MSC_TX | TRANSFER_PGM,LBAToROM(b),512);
-}
-
-#define GENERATE_INVALID_ROM_ADDRESS 60
-
-void RecvSector(u8 lba)
-{
- if ((lba < 4) || (lba >= 64))
- lba = GENERATE_INVALID_ROM_ADDRESS; // Only care about the first 30k
-
- // Write sectors to flash
- u16 addr = (u16)LBAToROM(lba); // may generate out of range addresses, Program will fix
- u8 i = 4; // 4x128 is a sector
- while (i--)
- {
- Program(MSC_RX,addr,128);
- addr += 128;
- }
-}
-
-#endif \ No newline at end of file
diff --git a/bootloaders/diskloader/src/USBCore.cpp b/bootloaders/diskloader/src/USBCore.cpp
index 8b071a1..142fc79 100644
--- a/bootloaders/diskloader/src/USBCore.cpp
+++ b/bootloaders/diskloader/src/USBCore.cpp
@@ -18,8 +18,6 @@
#include "Platform.h"
-#define MSC_TX MSC_ENDPOINT_IN
-#define MSC_RX MSC_ENDPOINT_OUT
#define CDC_TX CDC_ENDPOINT_IN
#define CDC_RX CDC_ENDPOINT_OUT
@@ -255,11 +253,6 @@ const u8 _initEndpoints[] =
#endif
EP_TYPE_INTERRUPT_IN, // HID_ENDPOINT_INT
-
-#ifdef MSC_ENABLED
- EP_TYPE_BULK_OUT, // MSC_ENDPOINT_OUT
- EP_TYPE_BULK_IN // MSC_ENDPOINT_IN
-#endif
};
static void InitEndpoints()
@@ -310,19 +303,6 @@ bool USBHook()
_usbLineInfo.lineState = setup.wValueL;
}
-#ifdef MSC_ENABLED
- // MSC Requests
- else if (MSC_GET_MAX_LUN == r)
- {
- Send8(0);
- }
- else if (MSC_RESET == r)
- {
- // MSC_Reset();
- } else
- return false; // unhandled
-#endif
-
return true;
}
@@ -385,8 +365,6 @@ bool SendDescriptor()
{
if (setup.wValueL == 0)
desc_addr = (const u8*)&STRING_LANGUAGE;
- else if (setup.wValueL == ISERIAL)
- desc_addr = (const u8*)&STRING_SERIAL;
else
return false;
} else
@@ -484,8 +462,6 @@ void USBGeneralInterrupt()
}
}
-void SCSITask();
-
void LEDPulse();
int USBGetChar()
{
@@ -494,11 +470,6 @@ int USBGetChar()
USBSetupInterrupt();
USBGeneralInterrupt();
-#ifdef MSC_ENABLED
- // Service disk
- if (HasData(MSC_RX))
- SCSITask();
-#endif
// Read a char
if (HasData(CDC_RX))
{
diff --git a/bootloaders/diskloader/src/USBCore.h b/bootloaders/diskloader/src/USBCore.h
index a37b9f2..537c0ec 100644
--- a/bootloaders/diskloader/src/USBCore.h
+++ b/bootloaders/diskloader/src/USBCore.h
@@ -43,10 +43,6 @@
#define CDC_GET_LINE_CODING 0x21
#define CDC_SET_CONTROL_LINE_STATE 0x22
-#define MSC_RESET 0xFF
-#define MSC_GET_MAX_LUN 0xFE
-
-
// Descriptors
#define USB_DEVICE_DESC_SIZE 18
@@ -98,10 +94,6 @@
#define CDC_CS_ENDPOINT 0x25
#define CDC_DATA_INTERFACE_CLASS 0x0A
-#define MSC_SUBCLASS_SCSI 0x06
-#define MSC_PROTOCOL_BULK_ONLY 0x50
-
-
// Device
typedef struct {
@@ -210,13 +202,6 @@ typedef struct
EndpointDescriptor out;
} CDCDescriptor;
-typedef struct
-{
- InterfaceDescriptor msc;
- EndpointDescriptor in;
- EndpointDescriptor out;
-} MSCDescriptor;
-
typedef struct
{
u8 len; // 9
diff --git a/bootloaders/diskloader/src/USBDesc.cpp b/bootloaders/diskloader/src/USBDesc.cpp
index dfde01d..ec7cf7d 100644
--- a/bootloaders/diskloader/src/USBDesc.cpp
+++ b/bootloaders/diskloader/src/USBDesc.cpp
@@ -27,18 +27,6 @@ const u16 STRING_LANGUAGE[2] = {
0x0409 // English
};
-#if 0
-const u16 STRING_PRODUCT[] = {
- (3<<8) | (2+2*10),
- 'M','i','c','r','o','t','o','u','c','h'
-};
-#endif
-
-const u16 STRING_SERIAL[13] = {
- (3<<8) | (2+2*12),
- MSC_DISK_SERIAL
-};
-
//#ifdef CDC_ENABLED
DeviceDescriptor USB_DeviceDescriptorA = D_DEVICE(0X02,0X00,0X00,64,USB_VID,USB_PID,0x100,0,IPRODUCT,ISERIAL,1);
@@ -74,15 +62,6 @@ Config USB_ConfigDescriptor =
D_INTERFACE(HID_INTERFACE,1,3,0,0),
D_HIDREPORT(30),
D_ENDPOINT(USB_ENDPOINT_IN (HID_ENDPOINT_INT),USB_ENDPOINT_TYPE_INTERRUPT,0x40,0x40)
- },
-
-#ifdef MSC_ENABLED
- // Mass Storage
- {
- D_INTERFACE(MSC_INTERFACE,2,USB_DEVICE_CLASS_STORAGE,MSC_SUBCLASS_SCSI,MSC_PROTOCOL_BULK_ONLY),
- D_ENDPOINT(USB_ENDPOINT_OUT(MSC_ENDPOINT_OUT),USB_ENDPOINT_TYPE_BULK,0x40,0),
- D_ENDPOINT(USB_ENDPOINT_IN (MSC_ENDPOINT_IN ),USB_ENDPOINT_TYPE_BULK,0x40,0)
}
-#endif
};
diff --git a/bootloaders/diskloader/src/USBDesc.h b/bootloaders/diskloader/src/USBDesc.h
index a551d69..589dfa9 100644
--- a/bootloaders/diskloader/src/USBDesc.h
+++ b/bootloaders/diskloader/src/USBDesc.h
@@ -17,15 +17,7 @@
*/
-#ifndef CDC_ENABLED
-
-#define MSC_INTERFACE 0 // MSC Interface
-#define MSC_ENDPOINT_OUT 1
-#define MSC_ENDPOINT_IN 2
-
-#define INTERFACE_COUNT 1 // 1 for msc
-
-#else
+#ifdef CDC_ENABLED
#define CDC_ACM_INTERFACE 0 // CDC ACM
#define CDC_DATA_INTERFACE 1 // CDC Data
@@ -36,18 +28,14 @@
#define HID_INTERFACE 2 // HID Interface
#define HID_ENDPOINT_INT 4
-#ifdef MSC_ENABLED
-
-#define MSC_INTERFACE 3 // MSC Interface
-#define MSC_ENDPOINT_OUT 5
-#define MSC_ENDPOINT_IN 6
-#define INTERFACE_COUNT 4 // 2 for cdc + 1 for hid + 1 for msc
+#define INTERFACE_COUNT 3 // 2 for cdc + 1 for hid
-#else
+#else
-#define INTERFACE_COUNT 3 // 2 for cdc + 1 for hid
+#define HID_INTERFACE 2 // HID Interface
+#define HID_ENDPOINT_INT 4
-#endif
+#define INTERFACE_COUNT 1 // 1 for hid
#endif
@@ -58,9 +46,6 @@ typedef struct
CDCDescriptor cdc;
#endif
HIDDescriptor hid;
-#ifdef MSC_ENABLED
- MSCDescriptor msc;
-#endif
} Config;
extern Config USB_ConfigDescriptor PROGMEM;
@@ -74,8 +59,5 @@ extern const u16 STRING_SERIAL[13] PROGMEM;
#define IPRODUCT 0
#define ISERIAL 1 // Only need this for MSC
-
-#define MSC_TX MSC_ENDPOINT_IN
-#define MSC_RX MSC_ENDPOINT_OUT
#define CDC_TX CDC_ENDPOINT_IN
#define CDC_RX CDC_ENDPOINT_OUT \ No newline at end of file