diff --git a/arduino/opencr_arduino/opencr/boards.txt b/arduino/opencr_arduino/opencr/boards.txt index b915a51d0..871796146 100755 --- a/arduino/opencr_arduino/opencr/boards.txt +++ b/arduino/opencr_arduino/opencr/boards.txt @@ -4,6 +4,8 @@ menu.device_variant=Variant menu.bootloader_version=Bootloader version menu.upload_method=Upload method +OpenCR.bootloader.tool = dfu_util +OpenCR.bootloader.file = opencr_boot.bin OpenCR.name=OpenCR Board OpenCR.upload.maximum_size=786432 diff --git a/arduino/opencr_arduino/opencr/bootloaders/opencr_boot.bin b/arduino/opencr_arduino/opencr/bootloaders/opencr_boot.bin new file mode 100755 index 000000000..5aed5709d Binary files /dev/null and b/arduino/opencr_arduino/opencr/bootloaders/opencr_boot.bin differ diff --git a/arduino/opencr_arduino/opencr/cores/mapleMX/WInterrupts.c b/arduino/opencr_arduino/opencr/cores/mapleMX/WInterrupts.c new file mode 100755 index 000000000..4a703676f --- /dev/null +++ b/arduino/opencr_arduino/opencr/cores/mapleMX/WInterrupts.c @@ -0,0 +1,52 @@ +/* + Copyright (c) 2014 Arduino. All right reserved. + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the GNU Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "WInterrupts.h" +#include "variant.h" +#include "wiring_digital.h" + +#include + +#ifdef __cplusplus +extern "C" { +#endif + + + +/* + * \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs. + * Replaces any previous function that was attached to the interrupt. + */ + +void attachInterrupt( uint32_t pin, voidFuncPtr callback, uint32_t ulMode ) +{ + drv_exti_attach( pin, callback, ulMode ); +} + +/* + * \brief Turns off the given interrupt. + */ +void detachInterrupt( uint32_t pin ) +{ + drv_exti_detach( pin ); +} + + +#ifdef __cplusplus +} +#endif diff --git a/arduino/opencr_arduino/opencr/cores/mapleMX/wiring_constants.h b/arduino/opencr_arduino/opencr/cores/mapleMX/wiring_constants.h index 9d4978b89..24196b534 100755 --- a/arduino/opencr_arduino/opencr/cores/mapleMX/wiring_constants.h +++ b/arduino/opencr_arduino/opencr/cores/mapleMX/wiring_constants.h @@ -26,9 +26,11 @@ extern "C"{ #define HIGH 0x1 #define LOW 0x0 -#define INPUT 0x0 -#define OUTPUT 0x1 -#define INPUT_PULLUP 0x2 +#define INPUT 0x0 +#define OUTPUT 0x1 +#define INPUT_PULLUP 0x2 +#define INPUT_ANALOG 0x3 + //#define true 0x1 //#define false 0x0 diff --git a/arduino/opencr_arduino/opencr/cores/mapleMX/wiring_digital.c b/arduino/opencr_arduino/opencr/cores/mapleMX/wiring_digital.c index 9653576b2..d53d9db63 100755 --- a/arduino/opencr_arduino/opencr/cores/mapleMX/wiring_digital.c +++ b/arduino/opencr_arduino/opencr/cores/mapleMX/wiring_digital.c @@ -109,14 +109,19 @@ extern void pinMode( uint32_t ulPin, uint32_t ulMode ) GPIO_InitStruct.Pull = GPIO_NOPULL; break ; + case INPUT_ANALOG: + drv_adc_pin_init(ulPin); + break; + default: break ; } - GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; - - - HAL_GPIO_Init(g_Pin2PortMapArray[ulPin].GPIOx_Port, &GPIO_InitStruct); + if( ulMode != INPUT_ANALOG ) + { + GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; + HAL_GPIO_Init(g_Pin2PortMapArray[ulPin].GPIOx_Port, &GPIO_InitStruct); + } } extern void digitalWrite( uint32_t ulPin, uint32_t ulVal ) diff --git a/arduino/opencr_arduino/opencr/libraries/Dynamixel/Dynamixel.cpp b/arduino/opencr_arduino/opencr/libraries/Dynamixel/Dynamixel.cpp new file mode 100644 index 000000000..79a25ad86 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/Dynamixel/Dynamixel.cpp @@ -0,0 +1,1375 @@ +/* + * Dynamixel.cpp + * + * Created on: 2013. 11. 8. + * Author: in2storm + */ + +#include +#include "Dynamixel.h" + + + +static unsigned short update_crc(unsigned short crc_accum, unsigned char *data_blk_ptr, unsigned short data_blk_size); + + + +Dynamixel::Dynamixel() { + +} + +Dynamixel::Dynamixel(int dev_num) { + +} + +Dynamixel::~Dynamixel() { + // TODO Auto-generated destructor stub +} +void Dynamixel::begin(int baud){ + + uint32_t Baudrate = 0; + mPacketType = DXL_PACKET_TYPE1; //2014-04-02 default packet type is 1.0 -> set as 1 + + + + //Calculate baudrate, refer to ROBOTIS support page. + //Baudrate = dxl_get_baudrate(baud); //Dxl 2.0 + if(baud == 3) + baud = 1; + else if(baud == 2) + baud = 16; + else if(baud == 1) + baud = 34; + else if(baud == 0) + baud = 207; + + Baudrate = 2000000 / (baud + 1); + + DXL_SERIAL.begin(Baudrate); + + delay(100); + mDXLtxrxStatus = 0; + mBusUsed = 0;// only 1 when tx/rx is operated + //gbIsDynmixelUsed = 1; //[ROBOTIS]2012-12-13 to notify end of using dynamixel SDK to uart.c + + this->setLibStatusReturnLevel(2); + this->setLibNumberTxRxAttempts(2); + + this->clearBuffer(); + if(this->checkPacketType()){ // Dxl 2.0 + this->setPacketType(DXL_PACKET_TYPE2); + }else{ // Dxl 1.0 + this->setPacketType(DXL_PACKET_TYPE1); + } + this->setLibNumberTxRxAttempts(1); + this->clearBuffer(); +} +/* + * [ROBOTIS][ADD][START] 2013-04-09 support read and write on dxl bus + * */ + +byte Dynamixel::readRaw(void){ + return DXL_SERIAL.read(); +} +void Dynamixel::writeRaw(uint8_t value){ + + dxlTxEnable(); + + DXL_SERIAL.write(value); + + dxlTxDisable(); +} + +/* + * @brief : if data coming from dxl bus, returns 1, or if not, returns 0. + * + */ +byte Dynamixel::available(void){ + return DXL_SERIAL.available(); +} +void Dynamixel::dxlTxEnable(void){ + drv_dxl_tx_enable(TRUE); +} +void Dynamixel::dxlTxDisable(void){ + drv_dxl_tx_enable(FALSE); +} +void Dynamixel::clearBuffer(void){ + uint32_t tTime; + + tTime = millis(); + while(1) + { + if(DXL_SERIAL.available()) + DXL_SERIAL.read(); + else + break; + + if( millis()-tTime > 1000 ) break; + } +} +void Dynamixel::setPacketType(byte type){ + mPacketType = type; + if(mPacketType == DXL_PACKET_TYPE2){ // Dxl 2.0 + mPktIdIndex = 4; + mPktLengthIndex = 5; + mPktInstIndex = 7; + mPktErrorIndex = 8; + //mRxLengthOffset = 7; + }else{ // Dxl 1.0 + mPktIdIndex = 2; + mPktLengthIndex = 3; + mPktInstIndex = 4; + mPktErrorIndex = 4; + //mRxLengthOffset = 4; + } +} +byte Dynamixel::getPacketType(void){ + return mPacketType; +} +byte Dynamixel::checkPacketType(void){ + this->setPacketType(DXL_PACKET_TYPE2); + //TxDStringC("Check DXL Ver\r\n"); + if(this->txRxPacket(0xFE, INST_PING, 0)){ + if(mRxBuffer[0] == 0xff && mRxBuffer[1] == 0xff && mRxBuffer[2] == 0xfd){ + //TxDStringC("DXL 2.0 Detected!\r\n"); + return 1; //Dxl 2.0 + }else{ + //TxDStringC("DXL 1.0 Detected!\r\n"); + return 0; //Dxl 1.0 + } + } + return 0;//default is 1.0 protocol +} + + +byte Dynamixel::setLibStatusReturnLevel(byte num) +{ + gbDXLStatusReturnLevel = num; + return gbDXLStatusReturnLevel; +} + +byte Dynamixel::setLibNumberTxRxAttempts(byte num) +{ + gbDXLNumberTxRxAttempts = num; + return gbDXLNumberTxRxAttempts; +} +/* + * return value for getTxRxStatus(), getResult(); +#define COMM_TXSUCCESS (0) +#define COMM_RXSUCCESS (1) +#define COMM_TXFAIL (2) +#define COMM_RXFAIL (3) +#define COMM_TXERROR (4) +#define COMM_RXWAITING (5) +#define COMM_RXTIMEOUT (6) +#define COMM_RXCORRUPT (7) +*/ +byte Dynamixel::getTxRxStatus(void) // made by NaN (Robotsource.org) +{ + return mDXLtxrxStatus; +} +/* + * Use getTxRxStatus() instead of getResult() + * */ +byte Dynamixel::getResult(void){ + // return mCommStatus; + return this->getTxRxStatus(); +} +/* + * ERROR Bit table is below. + +//DXL 1.0 protocol +#define ERRBIT_VOLTAGE (1) +#define ERRBIT_ANGLE (2) +#define ERRBIT_OVERHEAT (4) +#define ERRBIT_RANGE (8) +#define ERRBIT_CHECKSUM (16) +#define ERRBIT_OVERLOAD (32) +#define ERRBIT_INSTRUCTION (64) + +//DXL 2.0 protocol +#define ERRBIT_RESULT_FAIL (1) +#define ERRBIT_INST_ERROR (2) +#define ERRBIT_CRC (4) +#define ERRBIT_DATA_RANGE (8) +#define ERRBIT_DATA_LENGTH (16) +#define ERRBIT_DATA_LIMIT (32) +#define ERRBIT_ACCESS (64) + * */ +byte Dynamixel::getError( byte errbit ){ + //return dxl_get_rxpacket_error( errbit ); + if(mPacketType == DXL_PACKET_TYPE1){ + if( mRxBuffer[4] & errbit ) return 1; + else return 0; + + }else{ + if( mRxBuffer[8] & errbit ) return 1; + else return 0; + + + } + +} + +byte Dynamixel::txPacket(byte bID, byte bInstruction, int bParameterLength){ + + word bCount,bCheckSum,bPacketLength; + byte offsetParamIndex; + if(mPacketType == DXL_PACKET_TYPE1){//dxl protocol 1.0 + mTxBuffer[0] = 0xff; + mTxBuffer[1] = 0xff; + mTxBuffer[2] = bID; + mTxBuffer[3] = bParameterLength+2; //2(byte) <- instruction(1byte) + checksum(1byte) + mTxBuffer[4] = bInstruction; + + offsetParamIndex = 5; + bPacketLength = bParameterLength+2+4; + + }else{ //dxl protocol 2.0 + mTxBuffer[0] = 0xff; + mTxBuffer[1] = 0xff; + mTxBuffer[2] = 0xfd; + mTxBuffer[3] = 0x00; + mTxBuffer[4] = bID; + //get parameter length + mTxBuffer[5] = DXL_LOBYTE(bParameterLength+3);// 3(byte) <- instruction(1byte) + checksum(2byte) + mTxBuffer[6] = DXL_HIBYTE(bParameterLength+3); + mTxBuffer[7] = bInstruction; + + offsetParamIndex = 8; + bPacketLength = bParameterLength+3+7; //parameter length 3bytes, 7bytes = packet header 4bytes, ID 1byte, length 2bytes + } + + //copy parameters from mParamBuffer to mTxBuffer + for(bCount = 0; bCount < bParameterLength; bCount++) + { + mTxBuffer[bCount+offsetParamIndex] = mParamBuffer[bCount]; + } + + if(mPacketType == DXL_PACKET_TYPE1){ + bCheckSum = 0; + for(bCount = 2; bCount < bPacketLength-1; bCount++){ //except 0xff,checksum + bCheckSum += mTxBuffer[bCount]; + } + mTxBuffer[bCount] = ~bCheckSum; //Writing Checksum with Bit Inversion + }else{ + bCheckSum = update_crc(0, mTxBuffer, bPacketLength-2); // -2 : except CRC16 + mTxBuffer[bPacketLength-2] = DXL_LOBYTE(bCheckSum); // last - 2 + mTxBuffer[bPacketLength-1] = DXL_HIBYTE(bCheckSum); // last - 1 + } + //TxDStringC("bPacketLength = ");TxDHex8C(bPacketLength);TxDStringC("\r\n"); + this->dxlTxEnable(); // this define is declared in dxl.h + + + for(bCount = 0; bCount < bPacketLength; bCount++) + { + writeRaw(mTxBuffer[bCount]); + } + + this->dxlTxDisable();// this define is declared in dxl.h + + return(bPacketLength); // return packet length +} +byte Dynamixel::rxPacket(int bRxLength){ + unsigned long ulCounter, ulTimeLimit; + word bCount, bLength, bChecksum; + byte bTimeout; + uint32_t tTime; + + ulTimeLimit = 200; + + bTimeout = 0; + tTime = millis(); + for(bCount = 0; bCount < bRxLength; bCount++) + { + while(1) + { + if( DXL_SERIAL.available() ) + { + mRxBuffer[bCount] = DXL_SERIAL.read(); + break; + } + + if( millis()-tTime > ulTimeLimit ) + { + bTimeout = 1; + break; + } + } + if( bTimeout == 1 ) break; + } + + bLength = bCount; + bChecksum = 0; + if( mTxBuffer[mPktIdIndex] != BROADCAST_ID ) + { + if(bTimeout && bRxLength != 255) + { + #ifdef PRINT_OUT_COMMUNICATION_ERROR_TO_USART2 + TxDStringC("Rx Timeout"); + TxDByteC(bLength); + #endif + mDXLtxrxStatus |= (1< 3) //checking available length. + { + /*if(mPacketType == 1){ + if(mRxBuffer[0] != 0xff || mRxBuffer[1] != 0xff ) mDXLtxrxStatus |= (1< 3) + }//end of Rx status packet check + + return bLength; +} +void Dynamixel::printBuffer(byte *bpPrintBuffer, byte bLength) +{ +#ifdef PRINT_OUT_TRACE_ERROR_PRINT_TO_USART2 + byte bCount; + if(bLength == 0) + { + if(mTxBuffer[2] == BROADCAST_ID) + { + TxDStringC("\r\n No Data[at Broadcast ID 0xFE]"); + } + else + { + TxDStringC("\r\n No Data(Check ID, Operating Mode, Baud rate)");//TxDString("\r\n No Data(Check ID, Operating Mode, Baud rate)"); + } + } + for(bCount = 0; bCount < bLength; bCount++) + { + TxDHex8C(bpPrintBuffer[bCount]); + TxDByteC(' '); + } + TxDStringC(" LEN:");//("(LEN:") + TxDHex8C(bLength); + TxDStringC("\r\n"); +#endif +} + +byte Dynamixel::txRxPacket(byte bID, byte bInst, int bTxParaLen){ + + mDXLtxrxStatus = 0; + + word bTxLen, bRxLenEx, bTryCount; + + mBusUsed = 1; + mRxLength = bRxLenEx = bTxLen = 0; + + for(bTryCount = 0; bTryCount < gbDXLNumberTxRxAttempts; bTryCount++)//for(bTryCount = 0; bTryCount < TRY_NUM; bTryCount++) + { + /************************************** Transfer packet ***************************************************/ + bTxLen = this->txPacket(bID, bInst, bTxParaLen); + + if(mPacketType == DXL_PACKET_TYPE1){ //Dxl 1.0 Tx success ? + if (bTxLen == (bTxParaLen+4+2)) mDXLtxrxStatus = (1< 0){ + if(mPacketType == DXL_PACKET_TYPE1) mRxLength = bRxLenEx = 6+mParamBuffer[1]; + else mRxLength = bRxLenEx = 11+DXL_MAKEWORD(mParamBuffer[2], mParamBuffer[3]); + } + else{ + mRxLength = bRxLenEx = 0; + } + + } + else if( bID == BROADCAST_ID ){ + if(bInst == INST_SYNC_READ || bInst == INST_BULK_READ) mRxLength = bRxLenEx = 0xffff; //only 2.0 case + else mRxLength = bRxLenEx = 0; // no response packet + } + else{ + if (gbDXLStatusReturnLevel>1){ + if(mPacketType == DXL_PACKET_TYPE1) mRxLength = bRxLenEx = 6;//+mParamBuffer[1]; + else mRxLength = bRxLenEx = 11; + } + else{ + mRxLength = bRxLenEx = 0; + } + } + + + if(bRxLenEx){ + if(SmartDelayFlag == 1) + delay(150); + /************************************** Receive packet ***************************************************/ + mRxLength = this->rxPacket(bRxLenEx); + + }//bRxLenEx is exist + } //for() gbDXLNumberTxRxAttempts + + //TxDStringC("\r\n TEST POINT 2");//TxDString("\r\n Err ID:0x"); + mBusUsed = 0; + + + if((mRxLength != bRxLenEx) && (mTxBuffer[mPktIdIndex] != BROADCAST_ID)) + { + //TxDByteC('3');// + //TxDStringC("Rx Error\r\n");//TxDString("\r\n Err ID:0x"); +#ifdef PRINT_OUT_COMMUNICATION_ERROR_TO_USART2 + //TxDString("\r\n Err ID:0x"); + //TxDHex8(bID); + TxDStringC("\r\n ->[DXL]Err: "); + printBuffer(mTxBuffer,bTxLen); + TxDStringC("\r\n <-[DXL]Err: "); + printBuffer(mRxBuffer,mRxLength); +#endif + +#ifdef PRINT_OUT_TRACE_ERROR_PRINT_TO_USART2 + //TxDString("\r\n {[ERROR:");TxD16Hex(0x8100);TxDByte(':');TxD16Hex(bID);TxDByte(':');TxD8Hex(bInst);TxDByte(']');TxDByte('}'); + //TxDByte(bID);TxDByte(' '); + //TxDByte(bInst);TxDByte(' '); + //TxDByte(gbpParameter[0]);TxDByte(' '); + //TxDByte(gbpParameter[1]);TxDByte(' '); +#endif + return 0; + }else if((mRxLength == 0) && (mTxBuffer[mPktInstIndex] == INST_PING)){ //[ROBOTIS] 2013-11-22 correct response for ping instruction + //return 0; + } + //TxDString("\r\n TEST POINT 4");//TxDString("\r\n Err ID:0x"); +#ifdef PRINT_OUT_PACKET_TO_USART2 + TxDStringC("\r\n ->[TX Buffer]: "); + printBuffer(mTxBuffer,bTxLen); + TxDStringC("\r\n <-[RX Buffer]: "); + printBuffer(mRxBuffer,mRxLength); +#endif + mDXLtxrxStatus = (1<txRxPacket(bID, INST_PING, 0)){ + if(mPacketType == DXL_PACKET_TYPE1) return (mRxBuffer[2]); //1.0 + else return DXL_MAKEWORD(mRxBuffer[9],mRxBuffer[10]); //return product code when 2.0 + }else{ + return 0xffff; //no dxl in bus. + } + +} +/* + * Broadcast ping for DXL 2.0 protocol + * return : bit set each dynaxmel on bus. but it is limit to 32 DXLs + * */ +uint32_t Dynamixel::ping(void){ + int i=0; + uint32_t result=0; + if(mPacketType == DXL_PACKET_TYPE1) return 0xFFFFFFFF; //cannot be used in 1.0 protocol + if(this->txRxPacket(BROADCAST_ID, INST_PING, 0)){ + for(i=0; i < 32*14; i+=14){ + if(mRxBuffer[i] == 0xFF && mRxBuffer[i+1] == 0xFF && mRxBuffer[i+2] == 0xFD){ + result |= 1UL << mRxBuffer[i+4]; + //TxDStringC("result = ");TxDHex32C(result);TxDStringC("\r\n"); + } + } + return result; + }else{ + return 0xFFFFFFFF; //no dxl in bus. + } +} +byte Dynamixel::writeByte(byte bID, word bAddress, byte bData){ + byte param_length = 0; + if(mPacketType == DXL_PACKET_TYPE1){ + mParamBuffer[0] = bAddress; + mParamBuffer[1] = bData; + param_length = 2; + }else{ + //insert wAddress to parameter bucket + mParamBuffer[0] = (unsigned char)DXL_LOBYTE(bAddress); + mParamBuffer[1] = (unsigned char)DXL_HIBYTE(bAddress); + //insert data to parameter bucket + mParamBuffer[2] = bData; + param_length = 3; + } + return this->txRxPacket(bID, INST_WRITE, param_length); +} + +byte Dynamixel::readByte(byte bID, word bAddress){ + this->clearBuffer(); + if(mPacketType == DXL_PACKET_TYPE1){ + mParamBuffer[0] = bAddress; + mParamBuffer[1] = 1; + if( this->txRxPacket(bID, INST_READ, 2 )){ + //mCommStatus = 1; + return(mRxBuffer[5]); //refer to 1.0 packet structure + } + else{ + //mCommStatus = 0; + return 0xff; + } + }else{ + mParamBuffer[0] = (unsigned char)DXL_LOBYTE(bAddress); + mParamBuffer[1] = (unsigned char)DXL_HIBYTE(bAddress); + mParamBuffer[2] = 1; //1byte + mParamBuffer[3] = 0; + if( this->txRxPacket(bID, INST_READ, 4 )){ + return(mRxBuffer[9]);//refer to 2.0 packet structure + } + else{ + return 0xff; + } + } +} + + + +byte Dynamixel::writeWord(byte bID, word bAddress, word wData){ + byte param_length = 0; + this->clearBuffer(); + if(mPacketType == DXL_PACKET_TYPE1){ + mParamBuffer[0] = bAddress; + mParamBuffer[1] = DXL_LOBYTE(wData);//(byte)(wData&0xff); + mParamBuffer[2] = DXL_HIBYTE(wData);//(byte)((wData>>8)&0xff); + param_length = 3; + }else{ + mParamBuffer[0] = (unsigned char)DXL_LOBYTE(bAddress); + mParamBuffer[1] = (unsigned char)DXL_HIBYTE(bAddress); + //insert data to parameter bucket + mParamBuffer[2] = DXL_LOBYTE(wData); + mParamBuffer[3] = DXL_HIBYTE(wData); + param_length = 4; + + } + return this->txRxPacket(bID, INST_WRITE, param_length); + +} + + + +word Dynamixel::readWord(byte bID, word bAddress){ + this->clearBuffer(); + if(mPacketType == DXL_PACKET_TYPE1){ + mParamBuffer[0] = bAddress; + mParamBuffer[1] = 2; + if(this->txRxPacket(bID, INST_READ, 2)){ + return DXL_MAKEWORD(mRxBuffer[5],mRxBuffer[6]);//( (((word)mRxBuffer[6])<<8)+ mRxBuffer[5] ); + } + else{ + return 0xffff; + } + + }else{ + mParamBuffer[0] = (unsigned char)DXL_LOBYTE(bAddress); + mParamBuffer[1] = (unsigned char)DXL_HIBYTE(bAddress); + mParamBuffer[2] = 2; //2byte + mParamBuffer[3] = 0; + if(this->txRxPacket(bID, INST_READ, 4)){ + return(DXL_MAKEWORD(mRxBuffer[9], mRxBuffer[10])); + }else{ + return 0xffff; + } + } +} + + +byte Dynamixel::writeDword( byte bID, word wAddress, uint32_t value ){ + + this->clearBuffer(); + if(mPacketType == DXL_PACKET_TYPE1) return 0; + //insert wAddress to parameter bucket + mParamBuffer[0] = (unsigned char)DXL_LOBYTE(wAddress); + mParamBuffer[1] = (unsigned char)DXL_HIBYTE(wAddress); + //insert data to parameter bucket + mParamBuffer[2] = DXL_LOBYTE(DXL_LOWORD(value)); + mParamBuffer[3] = DXL_HIBYTE(DXL_LOWORD(value)); + mParamBuffer[4] = DXL_LOBYTE(DXL_HIWORD(value)); + mParamBuffer[5] = DXL_HIBYTE(DXL_HIWORD(value)); + + return this->txRxPacket(bID, INST_WRITE, 6); //// parameter length 4 = 2(address)+2(data) +} +uint32_t Dynamixel::readDword( byte bID, word wAddress ){ + + if(mPacketType == DXL_PACKET_TYPE1) return 0xFFFFFFFF; + + mParamBuffer[0] = (unsigned char)DXL_LOBYTE(wAddress); + mParamBuffer[1] = (unsigned char)DXL_HIBYTE(wAddress); + mParamBuffer[2] = 4; //4byte + mParamBuffer[3] = 0; + if(this->txRxPacket(bID, INST_READ, 4)){ + return DXL_MAKEDWORD( DXL_MAKEWORD( mRxBuffer[9], mRxBuffer[10]), + DXL_MAKEWORD( mRxBuffer[11], mRxBuffer[12])); + }else{ + return 0xFFFFFFFF; + } +} + +/* + * @brief Sets the target position and speed of the specified servo + * @author Made by Martin S. Mason(Professor @Mt. San Antonio College) + * @change 2013-04-17 changed by ROBOTIS,.LTD. + * */ +byte Dynamixel::setPosition(byte ServoID, int Position, int Speed){ + + byte param_length = 0; + if(mPacketType == DXL_PACKET_TYPE1){ + mParamBuffer[0] = (unsigned char)30; + mParamBuffer[1] = (unsigned char)DXL_LOBYTE(Position); + mParamBuffer[2] = (unsigned char)DXL_HIBYTE(Position); + mParamBuffer[3] = (unsigned char)DXL_LOBYTE(Speed); + mParamBuffer[4] = (unsigned char)DXL_HIBYTE(Speed); + param_length = 5; + + }else{ + mParamBuffer[0] = 30; + mParamBuffer[1] = 0; + //insert data to parameter bucket + mParamBuffer[2] = (unsigned char)DXL_LOBYTE(Position); + mParamBuffer[3] = (unsigned char)DXL_HIBYTE(Position); + mParamBuffer[4] = (unsigned char)DXL_LOBYTE(Speed); + mParamBuffer[5] = (unsigned char)DXL_HIBYTE(Speed); + param_length = 6; + } + return (this->txRxPacket(ServoID, INST_WRITE, param_length)); + +} +byte Dynamixel::syncWrite(int start_addr, int data_length, word *param, int param_length){ + + int i=0, j=0, k=0, num=0; + this->clearBuffer(); + num = param_length/(data_length + 1); //ID+DATA1+DATA2.. + if(mPacketType == DXL_PACKET_TYPE2){ + + mParamBuffer[0] = DXL_LOBYTE(start_addr); + mParamBuffer[1] = DXL_HIBYTE(start_addr); + mParamBuffer[2] = DXL_LOBYTE(data_length*2); + mParamBuffer[3] = DXL_HIBYTE(data_length*2); + + for(i=4; i < (4+num*(1+data_length*2)); i+=(1+data_length*2) ){ + mParamBuffer[i] = (byte)param[k++]; //ID + for(j=0; j < (data_length*2); j+=2){ + mParamBuffer[i+j+1] = DXL_LOBYTE(param[k]); //low byte + mParamBuffer[i+j+2] = DXL_HIBYTE(param[k]); //high byte + k++; + } + } + + return this->txRxPacket(BROADCAST_ID, INST_SYNC_WRITE, i); + + }else{ + + mbLengthForPacketMaking = 0; + mbIDForPacketMaking = BROADCAST_ID; + mbInstructionForPacketMaking = INST_SYNC_WRITE; + mCommStatus = 0; + mParamBuffer[mbLengthForPacketMaking++] = start_addr; + mParamBuffer[mbLengthForPacketMaking++] = data_length*2; + for(i=mbLengthForPacketMaking; i < num*(1+data_length*2); i+=(1+data_length*2)){ + mParamBuffer[i] = param[k++]; //ID + for(j=0; j < (data_length*2); j+=2){ + mParamBuffer[i+j+1] = DXL_LOBYTE(param[k]); //low byte + mParamBuffer[i+j+2] = DXL_HIBYTE(param[k]);; //high byte + k++; + } + } + mbLengthForPacketMaking= i; + return this->txRxPacket(mbIDForPacketMaking, mbInstructionForPacketMaking, mbLengthForPacketMaking); + } + +} + +byte Dynamixel::syncWrite(int start_addr, byte data_length, int *param, int param_length){ + int i=0, j=0, k=0, num=0; + if(mPacketType == DXL_PACKET_TYPE1) return 0; + + this->clearBuffer(); + + num = param_length / (data_length + 1); + + mParamBuffer[0] = DXL_LOBYTE(start_addr); + mParamBuffer[1] = DXL_HIBYTE(start_addr); + mParamBuffer[2] = DXL_LOBYTE(data_length*4); + mParamBuffer[3] = DXL_HIBYTE(data_length*4); + + for(i=4; i < (4+num*(1+data_length*4)); i+=(1+data_length*4) ){ + mParamBuffer[i] = (byte)param[k++]; //ID + for(j=0; j < (data_length*4); j+=4){ + mParamBuffer[i+j+1] = DXL_LOBYTE(DXL_LOWORD(param[k])); //data + mParamBuffer[i+j+2] = DXL_HIBYTE(DXL_LOWORD(param[k])); + mParamBuffer[i+j+3] = DXL_LOBYTE(DXL_HIWORD(param[k])); + mParamBuffer[i+j+4] = DXL_HIBYTE(DXL_HIWORD(param[k])); + k++; + } + + } + return this->txRxPacket(BROADCAST_ID, INST_SYNC_WRITE, 4+i); +} + +#if 0 +int Dynamixel::bulkRead(byte *param, int param_length){ + //mResult = 0; + uint32_t bulkReadlength=0; + + int n, i, k=0; + int num = param_length / 5; // each length : 5 (ID ADDR_L ADDR_H LEN_L LEN_H) + // int pkt_length = param_length + 3; // 3 : INST CHKSUM_L CHKSUM_H + // unsigned char txpacket[MAXNUM_TXPACKET] = {0}; + // unsigned char rxpacket[MAXNUM_RXPACKET] = {0}; + + for(n=0; n < param_length; n++){ + mParamBuffer[n] = param[n]; + } + + /************ TxRxPacket *************/ + // Wait for Bus Idle + /* while(comm->iBusUsing == 1) + { + //Sleep(0); + }*/ + + //mResult = txrx_PacketEx(BROADCAST_ID, INST_BULK_READ_EX, param_length);; + this->txRxPacket(BROADCAST_ID, INST_BULK_READ, param_length); + + + for(n = 0; n < num; n++){ + // int id = param[n*5+0]; + + bulkReadlength = this->rxPacket(param_length+11); + /*result = DXL_MAKEDWORD( DXL_MAKEWORD(gbpRxBufferEx[9],gbpRxBufferEx[10]), + DXL_MAKEWORD(gbpRxBufferEx[11],gbpRxBufferEx[12]) + );*/ + if(mRxBuffer[7] == 0x55){ //packet instruction index + mBulkData[n].iID = mRxBuffer[4]; //packet ID index + mBulkData[n].iAddr = DXL_MAKEWORD(mParamBuffer[5*n+1],mParamBuffer[5*n+2]); //get address + mBulkData[n].iLength = DXL_MAKEWORD(mParamBuffer[5*n+3],mParamBuffer[5*n+4]);//DXL_MAKEWORD(gbpRxBufferEx[PKT_LENGTH_L],gbpRxBufferEx[PKT_LENGTH_H]); + //TxDStringC("iLength = ");TxDHex8C(mBulkData[n].iLength);TxDStringC("\r\n"); + mBulkData[n].iError = mRxBuffer[7+1]; //Error code + for(i=0; i < mBulkData[n].iLength ; i++){ + mBulkData[n].iData[i] = mRxBuffer[7+2+i]; //DATA1 + } + } + for(k=0;k < DXL_RX_BUF_SIZE ; k++){ + mRxBuffer[k] = 0; //buffer clear + } + this->clearBuffer(); + } + return bulkReadlength; + +} +#endif + + +void Dynamixel::setTxPacketId(byte id){ + mbIDForPacketMaking = id; + +} +void Dynamixel::setTxPacketInstruction(byte instruction){ + mbInstructionForPacketMaking = instruction; + +} +void Dynamixel::setTxPacketParameter( byte index, byte value ){ + mParamBuffer[index] = value; + +} +void Dynamixel::setTxPacketLength( byte length ){ + mbLengthForPacketMaking = length; + +} +byte Dynamixel::txrxPacket(void){ + mCommStatus = this->txRxPacket(mbIDForPacketMaking, mbInstructionForPacketMaking, mbLengthForPacketMaking); + return mCommStatus; +} + +int Dynamixel::getRxPacketParameter( int index ){ + //return dxl_get_rxpacket_parameter( index ); + return mRxBuffer[5 + index]; +} +int Dynamixel::getRxPacketLength(void){ + //return dxl_get_rxpacket_length(); + return mRxBuffer[3]; //length index is 3 in status packet +} + +word Dynamixel::getModelNumber(byte bID){ + return this->readWord(bID, 0); +} + + +void Dynamixel::setID(byte current_ID, byte new_ID){ + this->writeByte(current_ID, 3, new_ID); +} +void Dynamixel::setBaud(byte bID, byte baud_num){ + this->writeByte(bID, 4, baud_num); +} + +void Dynamixel::returnLevel(byte bID, byte level){ + if(mPacketType == DXL_PACKET_TYPE1){ + this->writeByte(bID, 16, level); + }else{ + this->writeByte(bID, 17, level); + } +} +byte Dynamixel::returnLevel(byte bID){ + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readByte(bID, 16); + }else{ + return this->readByte(bID, 17); + } +} + +void Dynamixel::returnDelayTime(byte bID, byte time){ + this->writeByte(bID, 5, time); + +} +byte Dynamixel::returnDelayTime(byte bID){ + return this->readByte(bID, 5); +} + +void Dynamixel::alarmShutdown(byte bID,byte option){ + this->writeByte(bID, 18, option); +} +byte Dynamixel::alarmShutdown(byte bID){ + return this->readByte(bID, 18); +} + +void Dynamixel::controlMode(byte bID, byte mode){ // change wheel, joint + word model=0; + if(mPacketType == DXL_PACKET_TYPE1){ + if(mode == 1) this->writeWord(bID,8,0); + else{ + model = this->getModelNumber(bID); + if( model == 12 || model == 18 || model == 144) this->writeWord(bID,8,0x3FF); + else this->writeWord(bID,8,0xFFF); + } + }else{ + this->writeByte(bID, 24, 0); + this->writeByte(bID, 11, mode); + this->writeByte(bID, 24, 1); + } +} +byte Dynamixel::controlMode(byte bID){ // return current mode + if(mPacketType == DXL_PACKET_TYPE1){ + //return this->readByte(bID, 16); + if(this->readWord(1, 8) == 0 ) return 1; //wheel mode + else return 2; //joint mode + }else{ + return this->readByte(bID, 11); + } +} + +void Dynamixel::wheelMode(byte bID){ + if(mPacketType == DXL_PACKET_TYPE1){ + this->writeWord(bID,8,0); + }else{ + this->writeByte(bID, 24, 0); + this->writeByte(bID, 11, 1); + this->writeByte(bID, 24, 1); + } +} +void Dynamixel::jointMode(byte bID){ + word model=0; + if(mPacketType == DXL_PACKET_TYPE1){ + model = this->getModelNumber(bID); + if( model == 12 || model == 18 || model == 144 || model == 300) this->writeWord(bID,8,1023); + else this->writeWord(bID,8,4095); + }else{ + this->writeByte(bID, 24, 0); + this->writeByte(bID, 11, 2); + this->writeByte(bID, 24, 1); + } +} + + +void Dynamixel::maxTorque(byte bID, word value){ + if(mPacketType == DXL_PACKET_TYPE1){ + this->writeWord(bID, 14, value); + }else{ + this->writeWord(bID, 15, value); + } + +} +word Dynamixel::maxTorque(byte bID){ + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readWord(bID, 14); + }else{ + return this->readWord(bID, 15); + } + +} + +void Dynamixel::maxVolt(byte bID, byte value){ + if(mPacketType == DXL_PACKET_TYPE1){ + this->writeByte(bID, 13, value); + }else{ + this->writeByte(bID, 14, value); + } +} +byte Dynamixel::maxVolt(byte bID){ + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readByte(bID, 13); + }else{ + return this->readByte(bID, 14); + } +} + +void Dynamixel::minVolt(byte bID, byte value){ + if(mPacketType == DXL_PACKET_TYPE1){ + this->writeByte(bID, 12, value); + }else{ + this->writeByte(bID, 13, value); + } +} +byte Dynamixel::minVolt(byte bID){ + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readByte(bID, 12); + }else{ + return this->readByte(bID, 13); + } +} + +void Dynamixel::maxTemperature(byte bID, byte temp){ + if(mPacketType == DXL_PACKET_TYPE1){ + this->writeByte(bID, 11, temp); + }else{ + this->writeByte(bID, 12, temp); + } +} +byte Dynamixel::maxTemperature(byte bID){ + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readByte(bID, 11); + }else{ + return this->readByte(bID, 12); + } +} + +void Dynamixel::torqueEnable(byte bID){ + this->writeByte(bID, 24, 1); +} +void Dynamixel::torqueDisable(byte bID){ + this->writeByte(bID, 24, 0); +} + +void Dynamixel::cwAngleLimit(byte bID, word angle){ + this->writeWord(bID, 6, angle); +} +word Dynamixel::cwAngleLimit(byte bID){ + return this->readWord(bID, 6); +} + +void Dynamixel::ccwAngleLimit(byte bID, word angle){ + this->writeWord(bID, 8, angle); +} +word Dynamixel::ccwAngleLimit(byte bID){ + return this->readWord(bID, 8); +} + +void Dynamixel::goalPosition(byte bID, int position){ + this->writeWord(bID, 30, position); +} +void Dynamixel::goalSpeed(byte bID, int speed){ + this->writeWord(bID, 32, speed); +} +void Dynamixel::goalTorque(byte bID, int torque){ + if(mPacketType == DXL_PACKET_TYPE2) + this->writeWord(bID, 35, torque); +} + +int Dynamixel::getPosition(byte bID){ + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readWord(bID, 36); + }else{ + return this->readWord(bID, 37); + } +} +int Dynamixel::getSpeed(byte bID){ + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readWord(bID, 38); + }else{ + return this->readWord(bID, 39); + } +} +int Dynamixel::getLoad(byte bID){ + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readWord(bID, 40); + }else{ + return this->readWord(bID, 41); + } +} + +int Dynamixel::getVolt(byte bID){ //Current Voltage + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readByte(bID, 42); + }else{ + return this->readByte(bID, 45); + } +} +byte Dynamixel::getTemperature(byte bID){ //Current Temperature + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readByte(bID, 43); + }else{ + return this->readByte(bID, 46); + } +} +byte Dynamixel::isMoving(byte bID){ // is Moving?? Means if there is any movement + if(mPacketType == DXL_PACKET_TYPE1){ + return this->readByte(bID, 46); + }else{ + return this->readByte(bID, 49); + } +} + +void Dynamixel::ledOn(byte bID){ + this->writeByte(bID, 25, 1); +} +void Dynamixel::ledOn(byte bID, byte option){ //for XL-320 , DXL PRO + this->writeByte(bID, 25, option); +} +void Dynamixel::ledOff(byte bID){ + this->writeByte(bID, 25, 0); +} + +void Dynamixel::setPID(byte bID, byte propotional, byte integral, byte derivative){ + if(mPacketType == DXL_PACKET_TYPE2){ + this->writeByte(bID, 27, derivative); + this->writeByte(bID, 28, integral); + this->writeByte(bID, 29, propotional); + } +} + +void Dynamixel::complianceMargin(byte bID, byte CW, byte CCW){ + if(mPacketType == DXL_PACKET_TYPE1){ + this->writeByte(bID, 26, CW); + this->writeByte(bID, 27, CCW); + } +} +void Dynamixel::complianceSlope(byte bID, byte CW, byte CCW){ + if(mPacketType == DXL_PACKET_TYPE1){ + this->writeByte(bID, 28, CW); + this->writeByte(bID, 29, CCW); + } +} + +void Dynamixel::cwTurn(byte bID, word speed){ + word mode=0; + if(mPacketType == DXL_PACKET_TYPE1){ + //return this->readByte(bID, 16); + if(this->readWord(bID, 8) == 0 ) mode = 1; //wheel mode + else mode = 2; //joint mode + }else{ + mode = this->readByte(bID, 11); + } + + if(mode != 1){ + if(mPacketType == DXL_PACKET_TYPE1){ + this->writeWord(bID,8,0); + + }else{ + this->writeByte(bID, 11, 1); + } + } + this->writeWord(bID, 32, speed+1023); +} + +void Dynamixel::ccwTurn(byte bID, word speed){ + word mode=0; + if(mPacketType == DXL_PACKET_TYPE1){ + //return this->readByte(bID, 16); + if(this->readWord(bID, 8) == 0 ) mode = 1; //wheel mode + else mode = 2; //joint mode + }else{ + mode = this->readByte(bID, 11); + } + + if(mode != 1){ + if(mPacketType == DXL_PACKET_TYPE1){ + this->writeWord(bID,8,0); + + }else{ + this->writeByte(bID, 11, 1); + } + } + this->writeWord(bID, 32, speed); +} + +/* + * @brief initialize parameter and get ID, instruction for making packet + * */ +void Dynamixel::initPacket(byte bID, byte bInst){ + mbLengthForPacketMaking = 0; + mbIDForPacketMaking = bID; + mbInstructionForPacketMaking = bInst; + mCommStatus = 0; +} +/* + * @brief just push parameters, individual ID or moving data, individual data length + * */ +void Dynamixel::pushByte(byte value){ + //packet length is not above the maximum 143 bytes because size of buffer receiver has only 143 bytes capacity. + //please refer to ROBOTIS e-manual (support.robotis.com) + if(mbLengthForPacketMaking > 140)//prevent violation of memory access + return; + mParamBuffer[mbLengthForPacketMaking++] = value; +} +void Dynamixel::pushParam(byte value){ + if(mbLengthForPacketMaking > 140)//prevent violation of memory access + return; + mParamBuffer[mbLengthForPacketMaking++] = value; +} +void Dynamixel::pushParam(int value){ + + if(mbLengthForPacketMaking > 140)//prevent violation of memory access + return; + mParamBuffer[mbLengthForPacketMaking++] = (unsigned char)DXL_LOBYTE(value); + mParamBuffer[mbLengthForPacketMaking++] = (unsigned char)DXL_HIBYTE(value); +} +/* + * @brief transfers packets to dynamixel bus + * */ +byte Dynamixel::flushPacket(void){ + + //TxDString("\r\n"); + //TxD_Dec_U8(gbLengthForPacketMaking); + mCommStatus = this->txRxPacket(mbIDForPacketMaking, mbInstructionForPacketMaking, mbLengthForPacketMaking); + return mCommStatus; +} +/* + * @brief return current the total packet length + * */ + + + +unsigned short update_crc(unsigned short crc_accum, unsigned char *data_blk_ptr, unsigned short data_blk_size) +{ + unsigned short i, j; + unsigned short crc_table[256] = {0x0000, + 0x8005, 0x800F, 0x000A, 0x801B, 0x001E, 0x0014, 0x8011, + 0x8033, 0x0036, 0x003C, 0x8039, 0x0028, 0x802D, 0x8027, + 0x0022, 0x8063, 0x0066, 0x006C, 0x8069, 0x0078, 0x807D, + 0x8077, 0x0072, 0x0050, 0x8055, 0x805F, 0x005A, 0x804B, + 0x004E, 0x0044, 0x8041, 0x80C3, 0x00C6, 0x00CC, 0x80C9, + 0x00D8, 0x80DD, 0x80D7, 0x00D2, 0x00F0, 0x80F5, 0x80FF, + 0x00FA, 0x80EB, 0x00EE, 0x00E4, 0x80E1, 0x00A0, 0x80A5, + 0x80AF, 0x00AA, 0x80BB, 0x00BE, 0x00B4, 0x80B1, 0x8093, + 0x0096, 0x009C, 0x8099, 0x0088, 0x808D, 0x8087, 0x0082, + 0x8183, 0x0186, 0x018C, 0x8189, 0x0198, 0x819D, 0x8197, + 0x0192, 0x01B0, 0x81B5, 0x81BF, 0x01BA, 0x81AB, 0x01AE, + 0x01A4, 0x81A1, 0x01E0, 0x81E5, 0x81EF, 0x01EA, 0x81FB, + 0x01FE, 0x01F4, 0x81F1, 0x81D3, 0x01D6, 0x01DC, 0x81D9, + 0x01C8, 0x81CD, 0x81C7, 0x01C2, 0x0140, 0x8145, 0x814F, + 0x014A, 0x815B, 0x015E, 0x0154, 0x8151, 0x8173, 0x0176, + 0x017C, 0x8179, 0x0168, 0x816D, 0x8167, 0x0162, 0x8123, + 0x0126, 0x012C, 0x8129, 0x0138, 0x813D, 0x8137, 0x0132, + 0x0110, 0x8115, 0x811F, 0x011A, 0x810B, 0x010E, 0x0104, + 0x8101, 0x8303, 0x0306, 0x030C, 0x8309, 0x0318, 0x831D, + 0x8317, 0x0312, 0x0330, 0x8335, 0x833F, 0x033A, 0x832B, + 0x032E, 0x0324, 0x8321, 0x0360, 0x8365, 0x836F, 0x036A, + 0x837B, 0x037E, 0x0374, 0x8371, 0x8353, 0x0356, 0x035C, + 0x8359, 0x0348, 0x834D, 0x8347, 0x0342, 0x03C0, 0x83C5, + 0x83CF, 0x03CA, 0x83DB, 0x03DE, 0x03D4, 0x83D1, 0x83F3, + 0x03F6, 0x03FC, 0x83F9, 0x03E8, 0x83ED, 0x83E7, 0x03E2, + 0x83A3, 0x03A6, 0x03AC, 0x83A9, 0x03B8, 0x83BD, 0x83B7, + 0x03B2, 0x0390, 0x8395, 0x839F, 0x039A, 0x838B, 0x038E, + 0x0384, 0x8381, 0x0280, 0x8285, 0x828F, 0x028A, 0x829B, + 0x029E, 0x0294, 0x8291, 0x82B3, 0x02B6, 0x02BC, 0x82B9, + 0x02A8, 0x82AD, 0x82A7, 0x02A2, 0x82E3, 0x02E6, 0x02EC, + 0x82E9, 0x02F8, 0x82FD, 0x82F7, 0x02F2, 0x02D0, 0x82D5, + 0x82DF, 0x02DA, 0x82CB, 0x02CE, 0x02C4, 0x82C1, 0x8243, + 0x0246, 0x024C, 0x8249, 0x0258, 0x825D, 0x8257, 0x0252, + 0x0270, 0x8275, 0x827F, 0x027A, 0x826B, 0x026E, 0x0264, + 0x8261, 0x0220, 0x8225, 0x822F, 0x022A, 0x823B, 0x023E, + 0x0234, 0x8231, 0x8213, 0x0216, 0x021C, 0x8219, 0x0208, + 0x820D, 0x8207, 0x0202 }; + + for(j = 0; j < data_blk_size; j++) + { + i = ((unsigned short)(crc_accum >> 8) ^ *data_blk_ptr++) & 0xFF; + crc_accum = (crc_accum << 8) ^ crc_table[i]; + } + + return crc_accum; +} diff --git a/arduino/opencr_arduino/opencr/libraries/Dynamixel/Dynamixel.h b/arduino/opencr_arduino/opencr/libraries/Dynamixel/Dynamixel.h new file mode 100644 index 000000000..9fc4c4b66 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/Dynamixel/Dynamixel.h @@ -0,0 +1,224 @@ +/* + * Dynamixel.h + * + * Created on: 2013. 11. 8. + * Author: in2storm + * brief : 2013-11-12 [ROBOTIS] revised for OpenCM board + */ + +#ifndef DYNAMIXEL_H_ +#define DYNAMIXEL_H_ + +#include "./inc/dxl_constants.h" + +/* +typedef struct data { + int iID; + int iAddr; + int iLength; + int iError; + byte iData[8]; +} BulkData, *PBulkData; + +*/ + +class Dynamixel { +public: + Dynamixel(); + Dynamixel(int dev_num); + virtual ~Dynamixel(); + + /////////// Device control methods ///////////// + void begin(int buad); + uint8_t readRaw(void); + uint8_t available(void); + void writeRaw(uint8_t); + + byte getResult(void); // use getTxRxStatus() instead of getResult() method + byte getTxRxStatus(void);// made by NaN (Robotsource.org) + byte getError(byte errbit); + byte setLibStatusReturnLevel(byte); // made by NaN (Robotsource.org) + byte setLibNumberTxRxAttempts(byte);// made by NaN (Robotsource.org) + + byte txRxPacket(byte bID, byte bInst, int bTxParaLen); + byte txPacket(byte bID, byte bInstruction, int bParameterLength); + byte rxPacket(int bRxLength); + + void setPacketType(byte ver); + byte getPacketType(void); + + word ping(byte bID); + uint32_t ping(void); //Broadcast ping in DXL 2.0 protocol + + //// High communication methods //////// + byte readByte(byte bID, word bAddress); + byte writeByte(byte bID, word bAddress, byte bData); + word readWord(byte bID, word bAddress); + byte writeWord(byte bID, word bAddress, word wData); + + byte writeDword( byte bID, word wAddress, uint32_t value ); + uint32_t readDword( byte bID, word wAddress ); + + byte setPosition(byte ServoID, int Position, int Speed); + byte syncWrite(int start_addr, byte data_length, int *param, int param_length);// DWORD(32bit) syncwrite() for DXL PRO + byte syncWrite(int start_addr, int data_length, word *param, int param_length); // WORD(16bit) syncwrite() for DXL + + + /////// Methods for making a packet //////// + void setTxPacketId( byte id ); + void setTxPacketInstruction( byte instruction ); + void setTxPacketParameter( byte index, byte value ); + void setTxPacketLength( byte length ); + byte txrxPacket(void); + int getRxPacketParameter( int index ); + int getRxPacketLength(void); + + /* + * Dynamixel Pro Bulk Read & utility functions + * */ + /*int bulkRead(byte *param, int param_length); + int bulkRead(word *param, int param_length); //new + int bulkWrite(byte *param, int param_length); + + byte getBulkByte(int id, int addr); + uint16 getBulkWord(int id, int addr); + int getBulkDword(int id,int addr); +*/ + + //Easy Functions for DXL + word getModelNumber(byte bID); + + void setID(byte current_ID, byte new_ID); + void setBaud(byte bID, byte baud_num); + + void returnLevel(byte bID, byte level); + byte returnLevel(byte bID); + + void returnDelayTime(byte bID, byte time); + byte returnDelayTime(byte bID); + + void alarmShutdown(byte bID,byte option); + byte alarmShutdown(byte bID); + + void controlMode(byte bID, byte mode); // change wheel, joint + byte controlMode(byte bID); // return current mode + + void jointMode(byte bID); + void wheelMode(byte bID); + + void maxTorque(byte bID, word value); + word maxTorque(byte bID); + + void maxVolt(byte bID, byte value); + byte maxVolt(byte bID); + + void minVolt(byte bID, byte value); + byte minVolt(byte bID); + + void maxTemperature(byte bID, byte temp); + byte maxTemperature(byte bID); + + void torqueEnable(byte bID); + void torqueDisable(byte bID); + + void cwAngleLimit(byte bID, word angle); + word cwAngleLimit(byte bID); + void ccwAngleLimit(byte bID, word angle); + word ccwAngleLimit(byte bID); + + void goalPosition(byte bID, int position); + void goalSpeed(byte bID, int speed); + void goalTorque(byte bID, int torque); + + int getPosition(byte bID); + int getSpeed(byte bID); + int getLoad(byte bID); + int getVolt(byte bID); + byte getTemperature(byte bID); + byte isMoving(byte bID); + + void ledOn(byte bID); + void ledOn(byte bID, byte option); //for XL-320 , DXL PRO + void ledOff(byte bID); + + void setPID(byte bID, byte propotional, byte integral, byte derivative); + + void complianceMargin(byte bID, byte CW, byte CCW); + void complianceSlope(byte bID, byte CW, byte CCW); + + + + void cwTurn(byte bID, word speed); //cwTurn()���� ���� + void ccwTurn(byte bID, word speed);//ccwTurn() + //int getRxPacketError( byte errbit ); + /* + * New Methods for making a packet + * you can make sync write packet and reg/action packet by using these methods + */ + //byte syncWrite(byte start_addr, byte num_of_data, byte *param, int array_length); + // + + /* + * New Methods for making a packet + * + */ + void initPacket(byte bID, byte bInst); + void pushByte(byte value); + void pushParam(int value); + void pushParam(byte value); + byte flushPacket(void); + byte getPacketLength(void); + + /* + * Utility methods for Dynamixel + */ + + /*byte getLowByte( word wData ); //can be replaced by DXL_LOBYTE(w) + byte getHighByte( word wData );//can be replaced by DXL_HIBYTE(w) + word makeWord( byte lowbyte, byte highbyte ); //can be replaced by DXL_MAKEWORD(w)*/ + +private: + void printBuffer(byte *bpPrintBuffer, byte bLength); + uint32_t Dummy(uint32_t tmp); + void uDelay(uint32_t uTime); + void nDelay(uint32_t nTime); + void dxlTxEnable(void); + void dxlTxDisable(void); + void clearBuffer(void); + byte checkPacketType(void); + + uint8_t setDxlLibStatRtnLvl(uint8_t); // inspired by NaN (robotsource.org) + uint8_t setDxlLibNumTries(uint8_t); // inspired by NaN (robotsource.org) + + uint8_t mRxBuffer[DXL_RX_BUF_SIZE]; + uint8_t mTxBuffer[DXL_RX_BUF_SIZE]; + uint8_t mParamBuffer[DXL_PARAMETER_BUF_SIZE]; + uint8_t mBusUsed; + uint8_t mRxLength; // the length of the received data from dynamixel bus + + // additions to return proper COMM_* status + uint8_t mDXLtxrxStatus; // inspired by NaN (robotsource.org) + // additions to permit non-default Status Return Level settings without returning errors + uint8_t gbDXLStatusReturnLevel; + // additions to adjust number of txrx attempts + uint8_t gbDXLNumberTxRxAttempts; + + uint8_t mPacketType; //2014-04-02 + + byte mPktIdIndex; + byte mPktLengthIndex; + byte mPktInstIndex; + byte mPktErrorIndex; + //byte mRxLengthOffset; + + byte mbLengthForPacketMaking; + byte mbIDForPacketMaking; + byte mbInstructionForPacketMaking; + byte mCommStatus; + + byte SmartDelayFlag; + //BulkData mBulkData[32]; //Maximum dxl pro number is 32 +}; + + +#endif /* DYNAMIXEL_H_ */ diff --git a/arduino/opencr_arduino/opencr/libraries/Dynamixel/inc/dxl_constants.h b/arduino/opencr_arduino/opencr/libraries/Dynamixel/inc/dxl_constants.h new file mode 100644 index 000000000..df56ba032 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/Dynamixel/inc/dxl_constants.h @@ -0,0 +1,107 @@ +/* + * dxl_constants.h + * + * Created on: 2012. 12. 17. + * Author: ROBOTIS(jason@robotis.com) + */ + +#ifndef DXL_CONSTANTS_H_ +#define DXL_CONSTANTS_H_ + + +#define BROADCAST_ID (254) /* 0xFE */ + +/* + * Instruction command + * */ + +/* +#define INST_PING 0x01 +#define INST_READ 0x02 +#define INST_WRITE 0x03 +#define INST_REG_WRITE 0x04 +#define INST_ACTION 0x05 +#define INST_RESET 0x06 +#define INST_DIGITAL_RESET 0x07 +#define INST_SYSTEM_READ 0x0C +#define INST_SYSTEM_WRITE 0x0D +#define INST_SYNC_WRITE 0x83 +#define INST_SYNC_REG_WRITE 0x84 +*/ +enum DXL_INSTRUCTION{ //2014-04-02 ROBOTIS DXL Protocol 2.0 + INST_PING = 1, + INST_READ = 2, + INST_WRITE = 3, + INST_REG_WRITE = 4, + INST_ACTION = 5, + INST_FACTORY_RESET = 6, + INST_REBOOT = 8, + INST_SYSTEM_WRITE = 13, // 0x0D + INST_STATUS = 85, // 0x55 + INST_SYNC_READ = 130, // 0x82 + INST_SYNC_WRITE = 131, // 0x83 + INST_BULK_READ = 146, // 0x92 + INST_BULK_WRITE = 147 // 0x93 +}; + + +/* + * defines error message for protocol 1.0 + * */ +#define ERRBIT_VOLTAGE (1) +#define ERRBIT_ANGLE (2) +#define ERRBIT_OVERHEAT (4) +#define ERRBIT_RANGE (8) +#define ERRBIT_CHECKSUM (16) +#define ERRBIT_OVERLOAD (32) +#define ERRBIT_INSTRUCTION (64) + +/* + * defines error message for protocol 2.0 + * */ +#define ERRBIT_RESULT_FAIL (1) +#define ERRBIT_INST_ERROR (2) +#define ERRBIT_CRC (4) +#define ERRBIT_DATA_RANGE (8) +#define ERRBIT_DATA_LENGTH (16) +#define ERRBIT_DATA_LIMIT (32) +#define ERRBIT_ACCESS (64) + +/* + * defines message of communication + * */ +#define COMM_TXSUCCESS (0) +#define COMM_RXSUCCESS (1) +#define COMM_TXFAIL (2) +#define COMM_RXFAIL (3) +#define COMM_TXERROR (4) +#define COMM_RXWAITING (5) +#define COMM_RXTIMEOUT (6) +#define COMM_RXCORRUPT (7) + +/* timing defines */ +#define RX_TIMEOUT_COUNT2 (1600L) //(1000L) //porting +#define NANO_TIME_DELAY (12000) //ydh added 20111228 -> 20120210 edited ydh +//#define RX_TIMEOUT_COUNT1 (RX_TIMEOUT_COUNT2*90L)// -> 110msec before Ver 1.11e +#define RX_TIMEOUT_COUNT1 (RX_TIMEOUT_COUNT2*128L)// -> 156msec for ID 110 safe access after Ver 1.11f //porting ydh + +#define DXL_RX_BUF_SIZE 0x3FF +#define DXL_PARAMETER_BUF_SIZE 128 + + +///////////////// utility for value /////////////////////////// +#define DXL_MAKEWORD(a, b) ((unsigned short)(((unsigned char)(((unsigned long)(a)) & 0xff)) | ((unsigned short)((unsigned char)(((unsigned long)(b)) & 0xff))) << 8)) +#define DXL_MAKEDWORD(a, b) ((unsigned int)(((unsigned short)(((unsigned long)(a)) & 0xffff)) | ((unsigned int)((unsigned short)(((unsigned long)(b)) & 0xffff))) << 16)) +#define DXL_LOWORD(l) ((unsigned short)(((unsigned long)(l)) & 0xffff)) +#define DXL_HIWORD(l) ((unsigned short)((((unsigned long)(l)) >> 16) & 0xffff)) +#define DXL_LOBYTE(w) ((unsigned char)(((unsigned long)(w)) & 0xff)) +#define DXL_HIBYTE(w) ((unsigned char)((((unsigned long)(w)) >> 8) & 0xff)) + +#define DXL_PACKET_TYPE1 1 //2014-04-08 sm6787@robotis.com -> DXL protocol 1.0 packet type +#define DXL_PACKET_TYPE2 2 //2014-04-08 sm6787@robotis.com -> DXL protocol 1.0 packet type + + +#define DXL_SERIAL Serial3 + + +#endif /* DXL_CONSTANTS_H_ */ diff --git a/arduino/opencr_arduino/opencr/libraries/OLLO/OLLO.cpp b/arduino/opencr_arduino/opencr/libraries/OLLO/OLLO.cpp new file mode 100644 index 000000000..ee38a9ca7 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OLLO/OLLO.cpp @@ -0,0 +1,615 @@ +/* + * OLLO.cpp + * + * Created on: 2013. 5. 30. + * Author: ROBOTIS CO,.LTD. + */ + +#include "OLLO.h" + + +uint8_t before_color_num =0; +uint8_t before_color_cnt =0; +uint8_t after_color_value = 0; +uint8_t bColorResult =0; + +OLLO::OLLO() { + // TODO Auto-generated constructor stub + +} + +OLLO::~OLLO() { + // TODO Auto-generated destructor stub +} +int average_cnt = 0; +word long gwTheRmistor[108] = { + 67747,64577,61571,58721, + 56017,53452,51018,48707, + 46513,44430,42450,40569, + 38781,37081,35465,33927, + 32464,31072,29747,28485, + 27283,26138,25048,24008, 23017, + 22072,21171,20311,19491, + 18708,17960,17246,16565, + 15913,15291,14696,14128, + 13584,13064,12567,12091, + 11636,11200,10782,10383, + 10000, 9633, 9282, 8945, + 8622, 8313, 8016, 7731, + 7458, 7195, 6944, 6702, + 6470, 6247, 6033, 5828, + 5630, 5440, 5258, 5082, + 4914, 4751, 4595, 4445, + 4300, 4161, 4027, 3898, + 3774, 3654, 3539, 3427, + 3320, 3217, 3118, 3022, + 2929, 2840, 2754, 2671, + 2590, 2513, 2438, 2366, + 2296, 2229, 2164, 2101, +}; + + +void OLLO::begin(int devNum){ + if( devNum == 0 ){ + return; + } + mMot_plus = 0; + mMot_minus = 0; + switch(devNum){ + case 1: + pinMode(PORT1_SIG1, OUTPUT); //RED (right) + pinMode(PORT1_SIG2, OUTPUT); //BLUE (left) + pinMode(PORT1_ADC, INPUT_ANALOG); //ADC input + break; + case 2: + pinMode(PORT2_SIG1, OUTPUT); //RED (right) + pinMode(PORT2_SIG2, OUTPUT); //BLUE (left) + pinMode(PORT2_ADC, INPUT_ANALOG);//ADC input + break; + case 3: + pinMode(PORT3_SIG1, OUTPUT); //RED (right) + pinMode(PORT3_SIG2, OUTPUT); //BLUE (left) + pinMode(PORT3_ADC, INPUT_ANALOG);//ADC input + break; + case 4: + pinMode(PORT4_SIG1, OUTPUT); //RED (right) + pinMode(PORT4_SIG2, OUTPUT); //BLUE (left) + pinMode(PORT4_ADC, INPUT_ANALOG);//ADC input + break; + default: + break; + } +} +void OLLO::begin(int devNum, OlloDeviceIndex device_index){ //MAGNETIC SENSOR, Button, IR Sensor, and etc... + if( devNum == 0 ){ + return; + } + mMot_plus = 0; + mMot_minus = 0; + switch(devNum){ + case 1: + if(device_index == TOUCH_SENSOR || device_index == PIR_SENSOR || device_index == MAGNETIC_SENSOR){ + pinMode(PORT1_ADC, INPUT_PULLUP); + }else if(device_index == ULTRASONIC_SENSOR || device_index == COLOR_SENSOR || device_index == TEMPERATURE_SENSOR ){ + pinMode(PORT1_ADC, INPUT_ANALOG); + } + else{ + pinMode(PORT1_ADC, INPUT_ANALOG); //ADC input + } + + pinMode(PORT1_SIG1, OUTPUT); //SIG1 + pinMode(PORT1_SIG2, OUTPUT); //SIG2 + if(device_index == IR_SENSOR ){ + digitalWrite(PORT1_SIG1,LOW); //SIG1 set to LOW + digitalWrite(PORT1_SIG2,LOW); //SIG2 set to LOW + } + break; + case 2: + if(device_index == TOUCH_SENSOR || device_index == PIR_SENSOR || device_index == MAGNETIC_SENSOR){ + pinMode(PORT2_ADC, INPUT_PULLUP); + }else if(device_index == ULTRASONIC_SENSOR || device_index == COLOR_SENSOR || device_index == TEMPERATURE_SENSOR ){ + pinMode(PORT2_ADC, INPUT_ANALOG);//ADC input + }else{ + pinMode(PORT2_ADC, INPUT_ANALOG);//ADC input + } + + pinMode(PORT2_SIG1, OUTPUT); //SIG1 + pinMode(PORT2_SIG2, OUTPUT); //SIG2 + if(device_index == IR_SENSOR ){ + digitalWrite(PORT2_SIG1,LOW); //set to LOW + digitalWrite(PORT2_SIG2,LOW); //set to LOW + } + break; + case 3: + if(device_index == TOUCH_SENSOR || device_index == PIR_SENSOR || device_index == MAGNETIC_SENSOR){ + pinMode(PORT3_ADC, INPUT_PULLUP); + }else if(device_index == ULTRASONIC_SENSOR || device_index == COLOR_SENSOR || device_index == TEMPERATURE_SENSOR ){ + pinMode(PORT3_ADC, INPUT_ANALOG);//ADC input + }else{ + pinMode(PORT3_ADC, INPUT_ANALOG);//ADC input + } + + pinMode(PORT3_SIG1, OUTPUT); //SIG1 + pinMode(PORT3_SIG2, OUTPUT); //SIG2 + if(device_index == IR_SENSOR ){ + digitalWrite(PORT3_SIG1,LOW); //set SIG1 to LOW + digitalWrite(PORT3_SIG2,LOW); //set SIG2 to LOW + } + break; + case 4: + if(device_index == TOUCH_SENSOR || device_index == PIR_SENSOR || device_index == MAGNETIC_SENSOR ){ + pinMode(PORT4_ADC, INPUT_PULLUP); + }else if(device_index == ULTRASONIC_SENSOR || device_index == COLOR_SENSOR || device_index == TEMPERATURE_SENSOR ){ + pinMode(PORT4_ADC, INPUT_ANALOG);//ADC input + }else{ + pinMode(PORT4_ADC, INPUT_ANALOG);//ADC input + } + + pinMode(PORT4_SIG1, OUTPUT); //SIG1 + pinMode(PORT4_SIG2, OUTPUT); //SIG2 + if(device_index == IR_SENSOR ){ + digitalWrite(PORT4_SIG1,LOW); //set SIG1 to LOW + digitalWrite(PORT4_SIG2,LOW); //set SIG2 to LOW + } + break; + default: + break; + } +} + +void OLLO::begin(int devNum, OlloDeviceIndex device_index, voidFuncPtr handler){ //Button with handler function. + if( devNum == 0 ){ + return; + } + switch(devNum){ + case 1: + if(device_index == TOUCH_SENSOR){ + pinMode(PORT1_ADC, INPUT_PULLUP); + attachInterrupt(PORT1_ADC,handler, RISING); + } + break; + case 2: + if(device_index == TOUCH_SENSOR){ + pinMode(PORT2_ADC, INPUT_PULLUP); + attachInterrupt(PORT2_ADC,handler, RISING); + } + break; + case 3: + if(device_index == TOUCH_SENSOR){ + pinMode(PORT3_ADC, INPUT_PULLUP); + attachInterrupt(PORT3_ADC,handler, RISING); + } + break; + case 4: + if(device_index == TOUCH_SENSOR){ + pinMode(PORT4_ADC, INPUT_PULLUP); + attachInterrupt(PORT4_ADC,handler, RISING); + } + break; + default: + break; + } +} + + +int OLLO::read(int devNum){ // general sensor reading method + if( devNum == 0 ){ + return 0; + } + switch(devNum){ + case 1: + return (int)analogRead(PORT1_ADC); + case 2: + return (int)analogRead(PORT2_ADC); + case 3: + return (int)analogRead(PORT3_ADC); + case 4: + return (int)analogRead(PORT4_ADC); + default: + return 0; + } + +} +int OLLO::read(int devNum, OlloDeviceIndex device_index){ // IR SENSOR, Button, MAGNETIC SENSOR, and etc... + int adcValue = 0; + + signed int scount; + word vvalue = 0; + word analogValue; + int distance_value = 0; + int dis_value = 0; + + signed int average_value = 0; + if( devNum == 0 ){ + return 0; + } + switch(devNum){ + case 1: + if(device_index == IR_SENSOR){ + digitalWrite(PORT1_SIG2, HIGH); + delayMicroseconds(15); + adcValue = analogRead(PORT1_ADC); + digitalWrite(PORT1_SIG2, LOW); + return adcValue; + }else if(device_index == MAGNETIC_SENSOR || device_index == TOUCH_SENSOR || device_index == PIR_SENSOR){ + return digitalRead(PORT1_ADC); + }else if(device_index == ULTRASONIC_SENSOR){ + distance_value = (int)analogRead(PORT1_ADC); + dis_value = (((distance_value * 0.24)/4) - 3); + average_cnt++; + average_value+=dis_value; + if(average_cnt >= 100){ + average_value/=100; + average_cnt = 0; + } + return average_value; + }else if(device_index == TEMPERATURE_SENSOR){ + analogValue = analogRead(PORT1_ADC); + vvalue = (4095 - analogValue) * 10000 /analogValue; + for(scount = -20; scount < 140; scount++){ + if(vvalue > gwTheRmistor[scount +20]){ + return scount; + } + } + } + else if(device_index == COLOR_SENSOR){ + return this->detectColor(1); + }else{ + return (int)analogRead(PORT1_ADC); + } + break; + case 2: + if(device_index == IR_SENSOR){ + digitalWrite(PORT2_SIG2, HIGH);//digitalWrite(PORT1_SIG2, HIGH); -> digitalWrite(PORT2_SIG2, HIGH); 140324 + delayMicroseconds(15); + adcValue = analogRead(PORT2_ADC);//adcValue = analogRead(PORT1_ADC); -> adcValue = analogRead(PORT2_ADC); 140324 + digitalWrite(PORT2_SIG2, LOW);//digitalWrite(PORT1_SIG2, LOW); -> digitalWrite(PORT2_SIG2, LOW); + return adcValue; + }else if(device_index == MAGNETIC_SENSOR || device_index == TOUCH_SENSOR || device_index == PIR_SENSOR){ + return digitalRead(PORT2_ADC); + }else if(device_index == ULTRASONIC_SENSOR){ + distance_value = (int)analogRead(PORT2_ADC); //analogRead(PORT1_ADC); -> analogRead(PORT2_ADC); 140324 + dis_value = (((distance_value * 0.24)/4) - 3); + average_cnt++; + average_value+=dis_value; + if(average_cnt >= 100){ + average_value/=100; + average_cnt = 0; + } + return average_value; + }else if(device_index == COLOR_SENSOR){ + return this->detectColor(2); + } + else if(device_index == TEMPERATURE_SENSOR){ + analogValue = analogRead(PORT2_ADC); + vvalue = (4095 - analogValue) * 10000 /analogValue; + for(scount = -20; scount < 140; scount++){ + if(vvalue > gwTheRmistor[scount +20]){ + return scount; + } + } + } + else{ + return (int)analogRead(PORT2_ADC); + } + break; + case 3: + if(device_index == IR_SENSOR){ + digitalWrite(PORT3_SIG2, HIGH);////digitalWrite(PORT1_SIG2, HIGH); -> digitalWrite(PORT3_SIG2, HIGH); 140324 + delayMicroseconds(15); + adcValue = analogRead(PORT3_ADC);//adcValue = analogRead(PORT1_ADC); -> adcValue = analogRead(PORT3_ADC); 140324 + digitalWrite(PORT3_SIG2, LOW);//digitalWrite(PORT1_SIG2, LOW); -> digitalWrite(PORT3_SIG2, LOW); + return adcValue; + }else if(device_index == MAGNETIC_SENSOR || device_index == TOUCH_SENSOR || device_index == PIR_SENSOR){ + return digitalRead(PORT3_ADC); + }else if(device_index == ULTRASONIC_SENSOR){ + distance_value = (int)analogRead(PORT3_ADC); //analogRead(PORT1_ADC); -> analogRead(PORT3_ADC); 140324 + dis_value = (((distance_value * 0.24)/4) - 3); + average_cnt++; + average_value+=dis_value; + if(average_cnt >= 100){ + average_value/=100; + average_cnt = 0; + } + return average_value; + }else if(device_index == TEMPERATURE_SENSOR){ + analogValue = analogRead(PORT3_ADC); + vvalue = (4095 - analogValue) * 10000 /analogValue; + for(scount = -20; scount < 140; scount++){ + if(vvalue > gwTheRmistor[scount +20]){ + return scount; + } + } + }else if(device_index == COLOR_SENSOR){ + return OLLO::detectColor(3); + }else{ + return (int)analogRead(PORT3_ADC); + } + break; + case 4: + if(device_index == IR_SENSOR){ + digitalWrite(PORT4_SIG2, HIGH); //digitalWrite(PORT1_SIG2, HIGH); -> digitalWrite(PORT4_SIG2, HIGH); 140324 + delayMicroseconds(15); + adcValue = analogRead(PORT4_ADC); //adcValue = analogRead(PORT1_ADC); -> adcValue = analogRead(PORT4_ADC); 140324 + digitalWrite(PORT4_SIG2, LOW);//digitalWrite(PORT1_SIG2, LOW); -> digitalWrite(PORT4_SIG2, LOW); + return adcValue; + }else if(device_index == MAGNETIC_SENSOR || device_index == TOUCH_SENSOR || device_index == PIR_SENSOR ){ + return digitalRead(PORT4_ADC); + }else if(device_index == ULTRASONIC_SENSOR){ + distance_value = (int)analogRead(PORT4_ADC); //analogRead(PORT1_ADC); -> analogRead(PORT4_ADC); 140324 + dis_value = (((distance_value * 0.24)/4) - 3); + average_cnt++; + average_value+=dis_value; + if(average_cnt >= 100){ + average_value/=100; + average_cnt = 0; + } + return average_value; + }else if(device_index == TEMPERATURE_SENSOR){ + analogValue = analogRead(PORT4_ADC);// 2014-04-17 shin + vvalue = (4095 - analogValue) * 10000 /analogValue; + for(scount = -20; scount < 140; scount++){ + if(vvalue > gwTheRmistor[scount +20]){ + return scount; + } + } + }else if(device_index == COLOR_SENSOR){ + return OLLO::detectColor(4); + }else{ + return (int)analogRead(PORT4_ADC); + } + break; + default: + return 0; + } + return 0; +} + +int OLLO::read(int devNum, OlloDeviceIndex device_index, ColorIndex sub_index){ //COLOR SENSOR + //int adcValue = 0; + if( devNum == 0 ){ + return 0; + } + if(device_index == COLOR_SENSOR){ + setColor(sub_index); + }else{ + return 0; + } + + switch(devNum){ + case 1: + digitalWrite(PORT1_SIG1, mMot_minus); + digitalWrite(PORT1_SIG2, mMot_plus); + delay(5); // after 20ms, read analog + return (((int)analogRead(PORT1_ADC))/4); + + case 2: + digitalWrite(PORT2_SIG1, mMot_minus); + digitalWrite(PORT2_SIG2, mMot_plus); + delay(5); + return ((int)analogRead(PORT2_ADC)); + + case 3: + digitalWrite(PORT3_SIG1, mMot_minus); + digitalWrite(PORT3_SIG2, mMot_plus); + delay(5); + return ((int)analogRead(PORT3_ADC)/4); + + case 4: + digitalWrite(PORT4_SIG1, mMot_minus); + digitalWrite(PORT4_SIG2, mMot_plus); + delay(5); + return ((int)analogRead(PORT4_ADC)/4); + + default: + return 0; + } +} +void OLLO::writeLED(int devNum, uint8_t leftVal, uint8_t rightVal ){ + if( leftVal >1 || rightVal >1 || devNum == 0 ){ + return; + } + + switch(devNum){ + case 1: + digitalWrite(PORT1_SIG1,rightVal); + digitalWrite(PORT1_SIG2,leftVal); + break; + case 2: + digitalWrite(PORT2_SIG1,rightVal); + digitalWrite(PORT2_SIG2,leftVal); + break; + case 3: + digitalWrite(PORT3_SIG1,rightVal); + digitalWrite(PORT3_SIG2,leftVal); + break; + case 4: + digitalWrite(PORT4_SIG1,rightVal); + digitalWrite(PORT4_SIG2,leftVal); + break; + default: + break; + } + +} +void OLLO::write(int devNum, uint8_t leftVal, uint8_t rightVal ){ + if( leftVal >1 || rightVal >1 || devNum == 0 ){ + return; + } + + switch(devNum){ + case 1: + digitalWrite(6,rightVal); + digitalWrite(7,leftVal); + break; + case 2: + digitalWrite(8,rightVal); + digitalWrite(9,leftVal); + break; + case 3: + digitalWrite(10,rightVal); + digitalWrite(11,leftVal); + break; + case 4: + digitalWrite(12,rightVal); + digitalWrite(13,leftVal); + break; + default: + break; + } + +} +void OLLO::write(int devNum, uint8_t leftVal, uint8_t centerVal, uint8_t rightVal){ + + if( leftVal >1 || rightVal >1 || centerVal > 1 || devNum == 0){ + return; + } + + switch(devNum){ + case 1: + digitalWrite(6,rightVal); + digitalWrite(2,centerVal); + digitalWrite(7,leftVal); + break; + case 2: + digitalWrite(8,rightVal); + digitalWrite(3,centerVal); + digitalWrite(9,leftVal); + break; + case 3: + digitalWrite(10,rightVal); + digitalWrite(0,centerVal); + digitalWrite(11,leftVal); + break; + case 4: + digitalWrite(12,rightVal); + digitalWrite(1,centerVal); + digitalWrite(13,leftVal); + break; + default: + break; + } + +} + +void OLLO::setColor(ColorIndex colorIndex){ + switch(colorIndex){ + case RED: //Red + mMot_minus = LOW; + mMot_plus = LOW; + break; + case GREEN://Green + mMot_minus = LOW; + mMot_plus = HIGH; + break; + case BLUE://Blue + mMot_minus = HIGH; + mMot_plus = LOW; + break; + default: + break; + } + +} + + +int OLLO::detectColor(uint8_t port){ + + int temp_red,temp_green,temp_blue; + + temp_red = 0; + temp_green = 0; + temp_blue= 0; + int lColor[3]= {0,0,0}; + int lRed,lGreen,lBlue; + int bMaxColor, bMinColor, bColorResult; + bMaxColor=0; + bMinColor=0; + bColorResult=0; + + lRed = this->read(port, COLOR_SENSOR, RED); +//for(i=0; i < 3; i++) + + lGreen = (this->read(port, COLOR_SENSOR, GREEN)); +//for(i=0; i < 3; i++) + + lBlue = this->read(port, COLOR_SENSOR, BLUE); + + if(lRed >= lGreen && lRed >= lBlue) + { + bMaxColor = 1; + lColor[0] = lRed; + } + else if(lGreen >= lRed && lGreen >= lBlue) + { + bMaxColor = 2; + lColor[0] = lGreen; + } + + else if(lBlue >= lRed && lBlue >= lGreen) + { + bMaxColor = 3; + lColor[0] = lBlue; + } + if(lRed <= lGreen && lRed <= lBlue) + { + bMinColor = 1; + lColor[2] = lRed; + } + else if(lGreen <= lRed && lGreen <= lBlue) + { + bMinColor = 2; + lColor[2] = lGreen; + } + + else if(lBlue <= lRed && lBlue <= lGreen) + { + bMinColor = 3; + lColor[2] = lBlue; + } + + lColor[1] = lRed + lGreen + lBlue - lColor[0] - lColor[2]; + + uint32_t RtoB = lRed * 100 / lBlue; + uint32_t GtoB = lGreen * 100 / lBlue; + uint32_t GtoR = lGreen * 100 / lRed; + +//2014-03-24 sm6787@robotis.com + if(lColor[0] < 90 || ( lColor[0] < 180 && + RtoB > 50 && + (GtoB < 110 || GtoR < 130) && + (GtoB + GtoR < 230) && + ((lColor[2] * 100 / lColor[0]) > 75) + ) + ){//end of if() + bColorResult = 2; // blackz + } + else if((lColor[2] > 550) || ((lColor[2] > 200) && (lColor[0] > 300) && (lColor[2] * 100 / lColor[0] > 75) && (GtoB < 105))) + bColorResult = 1; // white + else if(RtoB > 170 && GtoB > 130) + bColorResult = 6; // yellow + else if(RtoB > 170 && GtoB <= 130) + bColorResult = 3; // red + else if(GtoB > 80 && GtoR >= 100)//90 110 + bColorResult = 4; // green + else if(RtoB < 70 && GtoB <= 85) + bColorResult = 5; // blue + else + bColorResult = 0; // unknown + + if(bColorResult == before_color_num){ + before_color_cnt++; + if(before_color_cnt >= 10){ + //before_color_cnt = 0; + return bColorResult; + } + } + else{ + before_color_cnt = 0; + } + + before_color_num = bColorResult; + return 0; +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OLLO/OLLO.h b/arduino/opencr_arduino/opencr/libraries/OLLO/OLLO.h new file mode 100644 index 000000000..5e7f78b07 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OLLO/OLLO.h @@ -0,0 +1,103 @@ +/* + * OLLO.h For OpenCR + * + * Created on: 2013. 5. 30. + * Author: ROBOTIS CO,.LTD. + */ + +#ifndef OLLO_H_ +#define OLLO_H_ +#include + + + + + +typedef enum OLLO_DEVICE_INDEX { + IR_SENSOR, + TOUCH_SENSOR, + GYRO_SENOSR, + DMS_SENSOR, + PIR_SENSOR, + MAGNETIC_SENSOR, + COLOR_SENSOR, + ULTRASONIC_SENSOR, + LED_DISPLAY, + TEMPERATURE_SENSOR +}OlloDeviceIndex; + +typedef enum COLOR_INDEX { + RED =1 , + GREEN, + BLUE, + YELLOW, + ORANGE, + BLACK, + WHITE +}ColorIndex; + + +#define COLOR_RED 1 +#define COLOR_GREEN 2 +#define COLOR_BLUE 3 + + +#define PORT1_SIG1 30 +#define PORT1_SIG2 31 +#define PORT1_ADC 32 + +#define PORT2_SIG1 33 +#define PORT2_SIG2 34 +#define PORT2_ADC 35 + +#define PORT3_SIG1 30 +#define PORT3_SIG2 31 +#define PORT3_ADC 32 + +#define PORT4_SIG1 33 +#define PORT4_SIG2 34 +#define PORT4_ADC 35 + +class OLLO { +private: + uint8_t mportNumber; + uint8_t mMot_plus; + uint8_t mMot_minus; + int detectColor(uint8_t port); + //int color_chk(); + void setColor(ColorIndex colorIndex); + int read(int devNum, OlloDeviceIndex device_index, ColorIndex sub_index); +public: + OLLO(); + virtual ~OLLO(); + //General 3PIN sensors + void begin(int devNum); + void begin(int devNum, OlloDeviceIndex device_index); + void begin(int devNum, OlloDeviceIndex device_index, voidFuncPtr handler); + + int read(int devNum); + int read(int devNum, OlloDeviceIndex device_index); + +// uint8_t isGreen(uint8_t port); +// uint8_t isWhite(uint8_t port); +// uint8_t isBlue(uint8_t port); +// uint8_t isBlack(uint8_t port); +// uint8_t isRed(uint8_t port); +// uint8_t isYellow(uint8_t port); +// uint8_t detectColor(uint8_t port); + + void write(int devNum, uint8_t leftVal, uint8_t rightVal); + void write(int devNum, uint8_t leftVal, uint8_t centerVal, uint8_t rightVal); + + //IR Sensor Module + //void beginIR(int devNum); + //LED Module + void writeLED(int devNum,uint8_t leftVal, uint8_t rightVal ); + //Button Module + //void beginButton(int devNum,voidFuncPtr handler); + //int readColor(int devNum, int colorIndex); + + +}; + +#endif /* OLLO_H_ */ diff --git a/arduino/opencr_arduino/opencr/libraries/OLLO/keywords.txt b/arduino/opencr_arduino/opencr/libraries/OLLO/keywords.txt new file mode 100644 index 000000000..d3c025a88 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OLLO/keywords.txt @@ -0,0 +1,37 @@ +####################################### +# Datatypes (KEYWORD1) +####################################### + +####################################### +# Methods and Functions (KEYWORD2) +####################################### +read KEYWORD2 +write KEYWORD2 +writeLED KEYWORD2 +beginIR KEYWORD2 +beginButton KEYWORD2 +readColor KEYWORD2 +####################################### +# Class (KEYWORD3) +####################################### +OLLO KEYWORD3 +myOLLO KEYWORD3 +####################################### +# Constants (LITERAL1) +####################################### +TOUCH_SENSOR LITERAL1 +GYRO_SENOSR LITERAL1 +DMS_SENSOR LITERAL1 +IR_SENSOR LITERAL1 +PIR_SENSOR LITERAL1 +MAGNETIC_SENSOR LITERAL1 +COLOR_SENSOR LITERAL1 +ULTRASONIC_SENSOR LITERAL1 +LED_DISPLAY LITERAL1 +RED LITERAL1 +GREEN LITERAL1 +BLUE LITERAL1 +YELLOW LITERAL1 +ORANGE LITERAL1 +BLACK LITERAL1 +WHITE LITERAL1 diff --git a/arduino/opencr_arduino/drivers/boards.txt b/arduino/opencr_arduino/opencr/libraries/OpenCR/OpenCR.cpp similarity index 100% rename from arduino/opencr_arduino/drivers/boards.txt rename to arduino/opencr_arduino/opencr/libraries/OpenCR/OpenCR.cpp diff --git a/arduino/opencr_arduino/tools/boards.txt b/arduino/opencr_arduino/opencr/libraries/OpenCR/OpenCR.h similarity index 100% rename from arduino/opencr_arduino/tools/boards.txt rename to arduino/opencr_arduino/opencr/libraries/OpenCR/OpenCR.h diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/a_Bare_Minimum/a_Bare_Minimum.pde b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/a_Bare_Minimum/a_Bare_Minimum.pde new file mode 100644 index 000000000..1729212bb --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/a_Bare_Minimum/a_Bare_Minimum.pde @@ -0,0 +1,12 @@ +/* Minimum_Source*/ + +void setup() { + // put your setup code here, to run once: + +} + +void loop() { + // put your main code here, to run repeatedly: + +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/b_Blink_LED/b_Blink_LED.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/b_Blink_LED/b_Blink_LED.ino new file mode 100644 index 000000000..366f62f2e --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/b_Blink_LED/b_Blink_LED.ino @@ -0,0 +1,26 @@ +/* Blink(LED) + + Turns on the built-in LED(Status LED) on for 0.1 second, then off for 0.1 second, + repeatedly. BOARD_LED_PIN is defined previously, so just use it without declaration. + BOARD_LED_PIN was connected to pin 16 in CM-900, but connected to pin 14 in OpenCM9.04. + + Compatibility +CM900 O +OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +void setup() { + // Set up the built-in LED pin as an output: + pinMode(BOARD_LED_PIN, OUTPUT); +} + +void loop() { + digitalWrite(BOARD_LED_PIN, HIGH); // set to as HIGH LED is turn-off + delay(100); // Wait for 0.1 second + digitalWrite(BOARD_LED_PIN, LOW); // set to as LOW LED is turn-on + delay(100); // Wait for 0.1 second +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/c_Digital_Read_Serial/c_Digital_Read_Serial.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/c_Digital_Read_Serial/c_Digital_Read_Serial.ino new file mode 100644 index 000000000..c8fc73b5e --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/c_Digital_Read_Serial/c_Digital_Read_Serial.ino @@ -0,0 +1,24 @@ +/* DigitalReadSerial + + Reads a digital input on pin 23, prints the result to the serial monitor + You can use BOARD_BUTTON_PIN instead of using pin 23 in OpenCM9.04 + + Compatibility +CM900 X +OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +void setup(){ + pinMode(BOARD_BUTTON_PIN, INPUT_PULLDOWN); +} +void loop(){ + int buttonState = digitalRead(BOARD_BUTTON_PIN); + SerialUSB.print("buttonState = "); + SerialUSB.println(buttonState); + delay(100); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/d_Analog_Read_Serial/d_Analog_Read_Serial.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/d_Analog_Read_Serial/d_Analog_Read_Serial.ino new file mode 100644 index 000000000..67c29967c --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/d_Analog_Read_Serial/d_Analog_Read_Serial.ino @@ -0,0 +1,28 @@ +/* AnalogReadSerial + + Reads an analog input on pin 0, prints the result to the serial monitor. + This example code is in the public domain. + + Compatibility + CM900 O + OpenCM9.04 O + + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + + + +void setup(){ + pinMode(0, INPUT_ANALOG); // set pin 0 as analog input +} + +void loop(){ + int AdcData = analogRead(0); + SerialUSB.print("AdcData = "); + SerialUSB.println(AdcData); + delay(100); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/e_Read_Analog_Voltage/e_Read_Analog_Voltage.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/e_Read_Analog_Voltage/e_Read_Analog_Voltage.ino new file mode 100644 index 000000000..cbdf9bb5f --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/e_Read_Analog_Voltage/e_Read_Analog_Voltage.ino @@ -0,0 +1,28 @@ +/* Read_Analog_Voltage + + Reads an analog input on pin 1, prints the result to the serial monitor. + voltage = Analog_data * (Max_voltage / Max_Analog_data); + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +volatile float voltage=0; + +void setup(){ + pinMode(1, INPUT_ANALOG); +} + +void loop(){ + int AdcData = analogRead(1); + voltage = AdcData * (3.3 / 4095.0); + SerialUSB.print("voltage = "); + SerialUSB.print(voltage); + SerialUSB.println(" [V]"); + delay(100); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/f_Led_Fadin/f_Led_Fadin.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/f_Led_Fadin/f_Led_Fadin.ino new file mode 100644 index 000000000..189af9896 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/01. Basics/f_Led_Fadin/f_Led_Fadin.ino @@ -0,0 +1,37 @@ +/* LED_Fading + + This example shows how to fade an LED using the analogWrite() function. + It operates only on OpenCM board, not CM-900(ES) because built-in led in CM900 + is not pwm-enabled pin, so you need some external circuit using other + pwm-enabled pin. + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +void setup() { + pinMode(BOARD_LED_PIN, PWM); // setup the pin as PWM +} + +void loop() { + // Fade in from min to max in increments of 1280 points: + for (int fadeValue = 0; fadeValue <= 65535; fadeValue += 1280) { + // Sets the value (range from 0 to 65535): + analogWrite(BOARD_LED_PIN, fadeValue); + // Wait for 30 milliseconds to see the dimming effect: + delay(30); + } + + // Fade out from max to min in increments of 1280 points: + for (int fadeValue = 65535 ; fadeValue >= 0; fadeValue -= 1280) { + // Sets the value (range from 0 to 1280): + analogWrite(BOARD_LED_PIN, fadeValue); + // Wait for 30 milliseconds to see the dimming effect: + delay(30); + } +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/a_Blink2_LED/a_Blink2_LED.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/a_Blink2_LED/a_Blink2_LED.ino new file mode 100644 index 000000000..cd1f7b5e3 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/a_Blink2_LED/a_Blink2_LED.ino @@ -0,0 +1,24 @@ +/*Blink2(LED) + + Turns on the built-in(Status) LED on for 0.1 second, then off for 0.1 second, + repeatedly using toggleLED() which is function only for built-in LED. + + Compatibility + CM900 O + OpenCM9.04 O + + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +void setup() { + // Set up the built-in LED pin as an output: + pinMode(BOARD_LED_PIN, OUTPUT); +} + +void loop() { + toggleLED(); //toggle digital value based on current value. + delay(100); //Wait for 0.1 second +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/b_Blink_Without_Delay/b_Blink_Without_Delay.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/b_Blink_Without_Delay/b_Blink_Without_Delay.ino new file mode 100644 index 000000000..1f984c62a --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/b_Blink_Without_Delay/b_Blink_Without_Delay.ino @@ -0,0 +1,43 @@ +/*Blink without delay + + Turns on and off the built-in light emitting diode (LED), without + using the delay() function. This means that other code can run at + the same time without being interrupted by the LED code. + + Compatibility + CM900 O + OpenCM9.04 O + + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ +/* +millis() + : Returns the number of milliseconds since the Arduino board began running the current program. + This number will overflow (go back to zero), after approximately 50 days. + */ + +// Variables: +long previousMillis = 0; // will store the last time the LED was updated +int interval = 1000; // interval at which to blink (in milliseconds) + +void setup() { + // Set up the built-in LED pin as output: + pinMode(BOARD_LED_PIN, OUTPUT); +} + +void loop() { + // Check to see if it's time to blink the LED; that is, if the + // difference between the current time and last time we blinked + // the LED is bigger than the interval at which we want to blink + + if ((int)millis() - previousMillis > interval) { + // Save the last time you blinked the LED + previousMillis = millis(); + + // If the LED is off, turn it on, and vice-versa: + toggleLED(); + } +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/c_Button/c_Button.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/c_Button/c_Button.ino new file mode 100644 index 000000000..3a371a5fc --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/c_Button/c_Button.ino @@ -0,0 +1,42 @@ +/* Button + + OpenCM9.04 has built-in button which is called as user button + User button is defined previously as BOARD_BUTTON PIN, so just call it. + This example shows how to use user button and status LED(built-in LED) + When button is pressed, status LED turn on, when released LED turn off + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +void setup(){ + /* + BOARD_BUTTON_PIN is needed to pull-down circuit + for operationg as digital switch fully. + */ + pinMode(BOARD_BUTTON_PIN, INPUT_PULLDOWN); + pinMode(BOARD_LED_PIN, OUTPUT); +} + +void loop(){ + // read the state of the pushbutton value: + int buttonState = digitalRead(BOARD_BUTTON_PIN); + + if(buttonState==HIGH){ //if button is pushed, means 3.3V(HIGH) is connected to BOARD_BUTTON_PIN + digitalWrite(BOARD_LED_PIN, LOW); + } + if(buttonState==LOW){// if button is released, means GND(LOW) is connected to BOARD_BUTTON_PIN + digitalWrite(BOARD_LED_PIN, HIGH); + } + +} + + + + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/d_Debounce/d_Debounce.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/d_Debounce/d_Debounce.ino new file mode 100644 index 000000000..cdbd6af93 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/d_Debounce/d_Debounce.ino @@ -0,0 +1,57 @@ +/* Debounce + + Each time the input pin goes from LOW to HIGH (e.g. because of a push-button + press), the output pin is toggled from LOW to HIGH or HIGH to LOW. There's + a minimum delay between toggles to debounce the circuit (i.e. to ignore + noise). + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +// Variables: +int ledState = HIGH; // the current state of the output pin +int buttonState; // the current reading from the input pin +int lastButtonState = LOW; // the previous reading from the input pin +int lastDebounceTime = 0; // the last time the output pin was toggled +int debounceDelay = 50; // the debounce time; increase if the output flickers + +void setup() { + pinMode(BOARD_BUTTON_PIN, INPUT_PULLDOWN); + pinMode(BOARD_LED_PIN, OUTPUT); +} + +void loop() { + // read the state of the switch into a local variable: + int reading = digitalRead(BOARD_BUTTON_PIN); + + // check to see if you just pressed the button + // (i.e. the input went from LOW to HIGH), and you've waited + // long enough since the last press to ignore any noise: + + // If the switch changed, due to noise or pressing: + if (reading != lastButtonState) { + // reset the debouncing timer + lastDebounceTime = millis(); + } + + if (((int)millis() - lastDebounceTime) > debounceDelay) { + // whatever the reading is at, it's been there for longer + // than the debounce delay, so take it as the actual current state: + buttonState = reading; + } + + // set the LED using inverted the state of the button: + // because status LED circuit is based on current sink + // so it is needed to inverted current button value + digitalWrite(BOARD_LED_PIN, !buttonState); + + // save the reading. Next time through the loop, + // it'll be the lastButtonState: + lastButtonState = reading; +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/e_State_Change_Detection/e_State_Change_Detection.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/e_State_Change_Detection/e_State_Change_Detection.ino new file mode 100644 index 000000000..19b4f8d4e --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/e_State_Change_Detection/e_State_Change_Detection.ino @@ -0,0 +1,63 @@ +/*State change detection + + Often, you don't need to know the state of a digital input all the + time, but you just need to know when the input changes from one state + to another. For example, you want to know when a button goes from + OFF to ON. + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +// Variables will change: +int buttonPushCounter = 0; // counter for the number of button presses +int buttonState = 0; // current state of the button +int lastButtonState = 0; // previous state of the button + +void setup() { + // initialize the button as an input: + pinMode(BOARD_BUTTON_PIN, INPUT_PULLDOWN); + pinMode(BOARD_LED_PIN, OUTPUT); +} + +void loop() { + // read the pushbutton input pin: + buttonState = digitalRead(BOARD_BUTTON_PIN); + + // compare the buttonState to its previous state + if (buttonState != lastButtonState) { + // if the state has changed, increment the counter + if (buttonState == HIGH) { + // if the current state is HIGH, then the button went from + // off to on: + buttonPushCounter++; + SerialUSB.println("on"); + SerialUSB.print("number of button pushes: "); + SerialUSB.println(buttonPushCounter, DEC); + } + else { + // if the current state is LOW, then the button went from + // on to off: + SerialUSB.println("off"); + } + + // save the current state as the last state, for next time + // through the loop + lastButtonState = buttonState; + } + + // turns on the LED every four button pushes by checking the + // modulo of the button push counter. Modulo (percent sign, %) + // gives you the remainder of the division of two numbers: + if (buttonPushCounter % 4 == 0) { + digitalWrite(BOARD_LED_PIN, HIGH); + } + else { + digitalWrite(BOARD_LED_PIN, LOW); + } +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/f_button_toggleLED/f_button_toggleLED.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/f_button_toggleLED/f_button_toggleLED.ino new file mode 100644 index 000000000..07696c2a2 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/02. Digital/f_button_toggleLED/f_button_toggleLED.ino @@ -0,0 +1,25 @@ +/*Button Toggle LED + + Toggles the built-in LED using built-in button on OpenCM9.04 + repeatedly. + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +void setup() { + // Set up the built-in LED pin as an output: + pinMode(BOARD_LED_PIN, OUTPUT); + pinMode(BOARD_BUTTON_PIN, INPUT_PULLDOWN); +} + +void loop() { + if(digitalRead(BOARD_BUTTON_PIN)) + toggleLED(); + +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/a_SerialUSB_HelloWorld/a_SerialUSB_HelloWorld.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/a_SerialUSB_HelloWorld/a_SerialUSB_HelloWorld.ino new file mode 100644 index 000000000..de6a5f3d8 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/a_SerialUSB_HelloWorld/a_SerialUSB_HelloWorld.ino @@ -0,0 +1,28 @@ +/* SerialUSB_HelloWorld + + USB Serial print "Hello World!!" to PC + You can see it any terminal program, putty, TeraTerm, Hyper Terminal, etc... + + Compatibility + CM900 O + OpenCM9.04 O + + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. +*/ +volatile int nCount=0; + +void setup() { +} + +void loop() { + //print "Hello World!!" to PC though USB Virtual COM port + SerialUSB.println("Hello World!!"); + SerialUSB.print("nCount : "); // display nCount variable and increase nCount. + SerialUSB.println(nCount++);//SerialUSB.print("\r\n"); + + delay(1000); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/b_SerialUSB_Echo/b_SerialUSB_Echo.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/b_SerialUSB_Echo/b_SerialUSB_Echo.ino new file mode 100644 index 000000000..5293435c3 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/b_SerialUSB_Echo/b_SerialUSB_Echo.ino @@ -0,0 +1,38 @@ +/* SerialUSB_Echo + + Demonstrates sending data from the computer to the CM900, OpenCM9.04 + echoes it to the computer again. + You can just type in terminal program, character you typed will be displayed + + + Compatibility + CM900 O + OpenCM9.04 O + + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +void setup(){ + //You can attach your serialUSB interrupt + //or, also detach the interrupt by detachInterrupt(void) method + SerialUSB.attachInterrupt(usbInterrupt); + pinMode(BOARD_LED_PIN, OUTPUT); //toggleLED_Pin_Out +} + +//USB max packet data is maximum 64byte, so nCount can not exceeds 64 bytes +void usbInterrupt(byte* buffer, byte nCount){ + SerialUSB.print("nCount ="); + SerialUSB.println(nCount); + for(unsigned int i=0; i < nCount;i++) //printf_SerialUSB_Buffer[N]_receive_Data + SerialUSB.print((char)buffer[i]); + SerialUSB.println(""); +} + +void loop(){ + toggleLED(); + delay(100); + +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/c_SerialUSB_Echo_Interrupt/c_SerialUSB_Echo_Interrupt.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/c_SerialUSB_Echo_Interrupt/c_SerialUSB_Echo_Interrupt.ino new file mode 100644 index 000000000..0d25fe829 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/c_SerialUSB_Echo_Interrupt/c_SerialUSB_Echo_Interrupt.ino @@ -0,0 +1,35 @@ +/*SerialUSB_Echo_Interrupt + + Demonstrates sending data from the computer to the CM900,OpenCM9.04 + echoes it to the computer again. + You can just type in terminal program, character you typed will be displayed + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +void setup(){ + //You can attach your serialUSB interrupt + //or, also detach the interrupt by detachInterrupt(void) method + SerialUSB.attachInterrupt(usbInterrupt); + pinMode(BOARD_LED_PIN, OUTPUT); //toggleLED_Pin_Out +} + +void usbInterrupt(byte* buffer, byte nCount){ + SerialUSB.print("nCount ="); + SerialUSB.println(nCount); + for(unsigned int i=0; i < nCount;i++) //printf_SerialUSB_Buffer[N]_receive_Data + SerialUSB.print((char)buffer[i]); + SerialUSB.println(""); +} + +void loop(){ + toggleLED(); + delay(100); + +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/d_Serial2_Echo/d_Serial2_Echo.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/d_Serial2_Echo/d_Serial2_Echo.ino new file mode 100644 index 000000000..0bf4e076f --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/d_Serial2_Echo/d_Serial2_Echo.ino @@ -0,0 +1,44 @@ +/* Serial2_Echo + + Demonstrates sending data from the computer to the CM900, OpenCM9.04 + echoes it to the computer again. + You can just type in terminal program, character you typed will be displayed + + [BT-110A] or [BT-110A Set] + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=875 + [ZIG-110A Set] + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=405 + [LN-101] download tool in CM-100 + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=348 + + You can also find all information about ROBOTIS products + http://support.robotis.com/ + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +/* + Serial1 : Dynamixel_Poart + Serial2 : Serial_Poart + TxD(Cm9) <--(Connect)--> RxD(PC) + RxD(Cm9) <--(Connect)--> TxD(PC) +*/ + + +void setup(){ + //Serial2 Serial initialize + Serial2.begin(57600); +} +void loop(){ + // when you typed any character in terminal + if(Serial2.available()){ + //print it out though USART2(RX2,TX2) + Serial2.print((char)Serial2.read()); + } +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/e_Serial2_Echo_interrupt/e_Serial2_Echo_interrupt.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/e_Serial2_Echo_interrupt/e_Serial2_Echo_interrupt.ino new file mode 100644 index 000000000..21d0af8e8 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/e_Serial2_Echo_interrupt/e_Serial2_Echo_interrupt.ino @@ -0,0 +1,42 @@ +/* Serial2_Echo_interrupt + + Demonstrates sending data from the computer to the CM900, OpenCM9.04 + echoes it to the computer again. + You can just type in terminal program, character you typed will be displayed + + You can connect the below products to J9 Connector in CM-900, OpenCM9.04 + [BT-110A] or [BT-110A Set] + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=875 + [ZIG-110A Set] + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=405 + [LN-101] download tool in CM-100 + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=348 + + You can also find all information about ROBOTIS products + http://support.robotis.com/ + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +void setup(){ + //Serial2 Serial initialize + Serial2.begin(57600); + //You can attach your serial interrupt + //or, also detach the interrupt by detachInterrupt(void) method + Serial2.attachInterrupt(serialInterrupt); + pinMode(BOARD_LED_PIN, OUTPUT); //toggleLED_Pin_Out +} +void serialInterrupt(byte buffer){ + Serial2.print((char)buffer); +} +void loop(){ + toggleLED(); + delay(50); + +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/f_SerialUSB_Serial2_Converter/f_SerialUSB_Serial2_Converter.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/f_SerialUSB_Serial2_Converter/f_SerialUSB_Serial2_Converter.ino new file mode 100644 index 000000000..36abfdb69 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/f_SerialUSB_Serial2_Converter/f_SerialUSB_Serial2_Converter.ino @@ -0,0 +1,43 @@ +/*SerialUSB_Serial2_Converter + + This example is convert from serial2 to USB. + CM-900, OpenCM9.04 has a port(J9) connected directly to Serial2. + If some data is coming from Serial2, it is sent to serialUSB. + On the contrary, all data coming from serialUSB is sent to Serial2. + + + You can connect the below products to J9 Connector in CM-900, OpenCM9.04 + [BT-110A] or [BT-110A Set] + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=875 + [ZIG-110A Set] + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=405 + [LN-101] USART communication and download tool in CM-100 + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=348 + + You can also find all information about ROBOTIS products + http://support.robotis.com/ + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +void setup(){ + Serial2.begin(57600); + pinMode(BOARD_LED_PIN, OUTPUT); +} + +void loop(){ + if(SerialUSB.available()){ + Serial2.print((char)SerialUSB.read());//send data coming from USB to Serial2 + } + + if(Serial2.available()){ + toggleLED(); + SerialUSB.print((char)Serial2.read()); //send data coming from Serial2 to USB(PC) + } +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/g_Serial3_Echo/g_Serial3_Echo.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/g_Serial3_Echo/g_Serial3_Echo.ino new file mode 100644 index 000000000..307ea00c2 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/03. Communication/g_Serial3_Echo/g_Serial3_Echo.ino @@ -0,0 +1,47 @@ +/*Serial3_Echo + + Demonstrates sending data from the computer to the CM900, OpenCM9.04 + echoes it to the computer again. + You can just type in terminal program, character you typed will be displayed + + You can connect the below products to J9 Connector in CM900, OpenCM9.04 + [BT-110A] or [BT-110A Set] + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=875 + [ZIG-110A Set] + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=405 + [LN-101] download tool in CM-100 + http://www.robotis-shop-kr.com/goods_detail.php?goodsIdx=348 + + You can also find all information about ROBOTIS products + http://support.robotis.com/ + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +/* +Serial1 : Dynamixel_Poart + Serial2 : Serial_Poart(4pin_Molex) + Serial3 : Serial_Poart(pin26:Tx3, pin27:Rx3) + + TxD3(Cm9_Pin26) <--(Connect)--> RxD(PC) + RxD3(Cm9_Pin27) <--(Connect)--> TxD(PC) + */ + + +void setup(){ + //Serial3 Serial initialize + Serial3.begin(57600); +} +void loop(){ + // when you typed any character in terminal + if(Serial3.available()){ + //print it out though USART2(RX2,TX2) + Serial3.print((char)Serial3.read()); + } +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/a_Analog_Input/a_Analog_Input.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/a_Analog_Input/a_Analog_Input.ino new file mode 100644 index 000000000..aee0a6852 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/a_Analog_Input/a_Analog_Input.ino @@ -0,0 +1,51 @@ +/* Analog input + + Reads an analog input pin, maps the result to a range from 0 to + 65535 and uses the result to set the pulse width modulation (PWM) of + an output pin. Also prints the results to the serial monitor. + + The circuit: + * Potentiometer connected to analog pin 1. + Center pin of the potentiometer goes to the analog pin. + Side pins of the potentiometer go to +3.3V and ground. + * LED connected from digital pin 14 to 3.3V( defined as BOARD_LED_PIN ) + If you have CM-900, you have to connect LED to any PWM enable pin. + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +const int analogInPin = 2; // Analog input pin that the potentiometer + +// These variables will change: +int sensorValue = 0; // value read from the pot +int outputValue = 0; // value output to the PWM + +void setup() { + // Configure the ADC pin + pinMode(analogInPin, INPUT_ANALOG); + // Configure LED pin + pinMode(BOARD_LED_PIN, PWM); +} + +void loop() { + // read the analog in value: + sensorValue = analogRead(analogInPin); + // map it to the range of the analog out: + outputValue = map(sensorValue, 0, 4095, 0, 65535); + // change the analog out value: + analogWrite(BOARD_LED_PIN, outputValue); + + // print the results to the serial monitor: + SerialUSB.print("sensor = " ); + SerialUSB.print(sensorValue); + SerialUSB.print("\t output = "); + SerialUSB.println(outputValue); + delay(100); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/b_Analog_In_Serial/b_Analog_In_Serial.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/b_Analog_In_Serial/b_Analog_In_Serial.ino new file mode 100644 index 000000000..8b5ab7d4e --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/b_Analog_In_Serial/b_Analog_In_Serial.ino @@ -0,0 +1,34 @@ +/* Analog input_Serial + + Reads an analog input pin, prints the results to the serial monitor. + + The circuit: + Potentiometer connected to analog pin 1. + Center pin of the potentiometer goes to the analog pin. + Side pins of the potentiometer go to +3.3V (VCC) and ground + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. +*/ + +// Analog input pin. You may need to change this number if your board +const int analogInputPin = 1; + +void setup() { + // Declare analogInputPin as INPUT_ANALOG: + pinMode(analogInputPin, INPUT_ANALOG); +} + +void loop() { + // Read the analog input into a variable: + int analogValue = analogRead(analogInputPin); + + // print the result: + SerialUSB.println(analogValue); + //need some delay because coming out too fast from USB COM port + delay(100); +} diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/c_Analong_In_Out_Serial/c_Analong_In_Out_Serial.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/c_Analong_In_Out_Serial/c_Analong_In_Out_Serial.ino new file mode 100644 index 000000000..75b318285 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/c_Analong_In_Out_Serial/c_Analong_In_Out_Serial.ino @@ -0,0 +1,40 @@ +/* Analong_In_Out_Serial + + Demonstrates analog input by reading an analog sensor on analog pin + 0 and turning on and off the status LED(Light Emitting Diode). + The amount of time the LED will be on and off depends on the + value obtained by analogRead(). + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +int sensorPin = 0; // Select the input pin for the potentiometer +int sensorValue = 0; // Variable to store the value coming from the sensor + +void setup() { + // Declare the sensorPin as INPUT_ANALOG: + pinMode(sensorPin, INPUT_ANALOG); + // Declare the LED's pin as an OUTPUT. (BOARD_LED_PIN is a built-in + // constant which is the pin number of the built-in LED. On the + // Maple, it is 13.) + pinMode(BOARD_LED_PIN, OUTPUT); +} + +void loop() { + // Read the value from the sensor: + sensorValue = analogRead(sensorPin); + // Turn the LED pin on: + digitalWrite(BOARD_LED_PIN, HIGH); + // Stop the program for milliseconds: + delay(sensorValue); + // Turn the LED pin off: + digitalWrite(BOARD_LED_PIN, LOW); + // Stop the program for for milliseconds: + delay(sensorValue); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/d_Battery_notifications/d_Battery_notifications.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/d_Battery_notifications/d_Battery_notifications.ino new file mode 100644 index 000000000..79e84b1f9 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/d_Battery_notifications/d_Battery_notifications.ino @@ -0,0 +1,38 @@ +/* Battery notifications + +This example measures charge of 11.1v 1Ah LiPo battery from Bioloid Premium Kit. + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. +*/ + +/*You need to do your own voltage divider Vout = (R2/(R2+R1))*Vin */ +const int An_CMpin = 0; //Pin A0 in CM-900 + +void setup(){ +pinMode(BOARD_LED_PIN,OUTPUT); +pinMode(An_CMpin, INPUT_ANALOG); // Set Analog input for pin A0 +} + +void loop(){ + float val = analogRead(An_CMpin)/10; // we read values from our battery + + //SerialUSB.println(val); + /* we do a little conversion, 910 is the result of (4095/(R2(R2+R1)))/10 */ + float BatVolts = ((val)/(910)); + float VoltsMul = BatVolts * 11.1; + + if(VoltsMul > 4 && VoltsMul < 5){ +/*Notification to know your battery is ok.*/ + digitalWrite(BOARD_LED_PIN,0); + delay(100); + digitalWrite(BOARD_LED_PIN,1); + delay(100); + } + +delay(500); // An small delay after each analog reading. +} diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/e_Calibration/e_Calibration.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/e_Calibration/e_Calibration.ino new file mode 100644 index 000000000..4723ef651 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/e_Calibration/e_Calibration.ino @@ -0,0 +1,74 @@ +/* Calibration + + Demonstrates one techinque for calibrating sensor input. The sensor + readings during the first five seconds of the sketch execution + define the minimum and maximum of expected values attached to the + sensor pin. + + The sensor minumum and maximum initial values may seem backwards. + Initially, you set the minimum high and listen for anything lower, + saving it as the new minumum. Likewise, you set the maximum low and + listen for anything higher as the new maximum. + + The circuit: + Analog sensor (potentiometer will do) attached to analog input 1 + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +// Constant (won't change): +const int sensorPin = 2; // pin that the sensor is attached to + +// Variables: +int sensorMin = 0; // minimum sensor value +int sensorMax = 4095; // maximum sensor value +int sensorValue = 0; // the sensor value + +void setup() { + // Declare the sensorPin as INPUT_ANALOG: + pinMode(sensorPin, INPUT_ANALOG); + + // Turn on the built-in LED to signal the start of the calibration + // period: + pinMode(BOARD_LED_PIN, PWM); + digitalWrite(BOARD_LED_PIN, HIGH); + + // Calibrate during the first five seconds: + while (millis() < 5000) { + sensorValue = analogRead(sensorPin); + + // Record the maximum sensor value: + if (sensorValue > sensorMax) { + sensorMax = sensorValue; + } + + // Record the minimum sensor value: + if (sensorValue < sensorMin) { + sensorMin = sensorValue; + } + } + + // Signal the end of the calibration period: + digitalWrite(BOARD_LED_PIN, LOW); +} + +void loop() { + // Read the sensor: + sensorValue = analogRead(sensorPin); + + // Apply the calibration to the sensor reading: + sensorValue = map(sensorValue, sensorMin, sensorMax, 0, 65535); + + // In case the sensor value is outside the range seen during calibration: + sensorValue = constrain(sensorValue, 0, 65535); + + // Fade the LED using the calibrated value: + analogWrite(BOARD_LED_PIN, sensorValue); + delay(100); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/f_Smoothing/f_Smoothing.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/f_Smoothing/f_Smoothing.ino new file mode 100644 index 000000000..243e20cef --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/f_Smoothing/f_Smoothing.ino @@ -0,0 +1,62 @@ +/*Smoothing + + Reads repeatedly from an analog input, calculating a running average + and printing it to the computer. Keeps ten readings in an array and + continually averages them. + + The circuit: + Analog sensor (potentiometer will do) attached to pin 1 + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. +*/ + +// Define the number of samples to keep track of The higher the number, +// the more the readings will be smoothed, but the slower the output will +// respond to the input. Using a constant rather than a normal variable lets +// use this value to determine the size of the readings array. +const int numReadings = 10; + +int readings[numReadings]; // the readings from the analog input +int index = 0; // the index of the current reading +int total = 0; // the running total +int average = 0; // the average + +int inputPin = 1; // analog input pin + +void setup() { + // Declare the input pin as INPUT_ANALOG: + pinMode(inputPin, INPUT_ANALOG); + + // Initialize all the readings to 0: + for (int thisReading = 0; thisReading < numReadings; thisReading++) { + readings[thisReading] = 0; + } +} + +void loop() { + // Subtract the last reading: + total = total - readings[index]; + // Read from the sensor: + readings[index] = analogRead(inputPin); + // Add the reading to the total: + total = total + readings[index]; + // Advance to the next position in the array: + index = index + 1; + + // If we're at the end of the array... + if (index >= numReadings) { + // ...wrap around to the beginning: + index = 0; + } + + // Calculate the average: + average = total / numReadings; + // Send it to the computer (as ASCII digits) + SerialUSB.println(average, DEC); + delay(100); +} diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/g_Scratch_Sensor_Board_Emulator/g_Scratch_Sensor_Board_Emulator.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/g_Scratch_Sensor_Board_Emulator/g_Scratch_Sensor_Board_Emulator.ino new file mode 100644 index 000000000..0fc7ad6f1 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/g_Scratch_Sensor_Board_Emulator/g_Scratch_Sensor_Board_Emulator.ino @@ -0,0 +1,76 @@ +/* Scratch_Sensor_Board_Emulator + + A program that simulates a Scratch board using an Arduino. This version reads the button and inputs A-D. + Version 0.6 + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +#include +OLLO myOLLO; + +void ScratchBoardSensorReport(int sensor, int value) +{ + SerialUSB.print( B10000000 + | ((sensor & B1111)<<3) + | ((value>>7) & B111),BYTE); + SerialUSB.print( value & B1111111, BYTE); +} + +void setup() +{ + + pinMode(BOARD_BUTTON_PIN, INPUT_PULLDOWN); + pinMode(BOARD_LED_PIN, OUTPUT); + myOLLO.begin(1,TOUCH_SENSOR); + myOLLO.begin(2, IR_SENSOR); + myOLLO.begin(3); + myOLLO.begin(4); + +} +int irSensor = 0; +int gyroX=0; +int gyroY=0; +void loop() +{ + + if(SerialUSB.available()){ + gyroX = myOLLO.read(3); + if(gyroX > 1000 && gyroX < 2000){ + gyroX = 1530; + } + gyroY = myOLLO.read(4); + if(gyroY > 1000 && gyroY < 2000){ + gyroY = 1530; + } + ScratchBoardSensorReport(0, map(gyroX, 0, 3000, 0, 1023) ); + ScratchBoardSensorReport(1, map(gyroY, 0, 3000, 0, 1023) ); + ScratchBoardSensorReport(2, 0/*analogRead(3)*/); + ScratchBoardSensorReport(3, 0/*analogRead(4)*/); + irSensor = myOLLO.read(2, IR_SENSOR); + if(irSensor > 250) + irSensor = 300; + ScratchBoardSensorReport(4, map(irSensor, 0, 300, 0, 1023)); + ScratchBoardSensorReport(5, 0); + ScratchBoardSensorReport(6, 0); + ScratchBoardSensorReport(7, (myOLLO.read(1, TOUCH_SENSOR) ? 1023 : 0)); + // Let Scratch catch up with us + delay(30); + toggleLED(); + } +} + + + + + + + + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/h_Oscilloscope/h_Oscilloscope.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/h_Oscilloscope/h_Oscilloscope.ino new file mode 100644 index 000000000..7b1acccb5 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/04. Analog/h_Oscilloscope/h_Oscilloscope.ino @@ -0,0 +1,155 @@ +/* +Oscilloscope + +This example shows how to make oscilloscope using OpenCM9.04 and Processing. +Processing codes are also available as the below. + +1. Pin 0 is conneced to probe(just wire is okay) +2. download this example to OpenCM9.04 and run it. +3. connect OpencM9.04 to PC using USB +4. compile the below Processing sketch and execute it on PC. +5. detected signal can be visually displayed. + +*/ + +void setup(){ + SerialUSB.begin(); + pinMode(0, INPUT_ANALOG); +} + +void loop(){ + int val = analogRead(0); + + SerialUSB.write( 0xff );//send header packet + SerialUSB.write( (val >> 8) & 0xff ); //send high byte + SerialUSB.write( val & 0xff ); //send low byte +} + + +//The following code shows the electrical signal visually using Processing +//This sketch program can be run on Processing. +//https://www.processing.org/ + +/* + * Oscilloscope + * Gives a visual rendering of analog pin 0 in realtime. + * + * This project is part of Accrochages + * See http://accrochages.drone.ws + * + * (c) 2008 Sofian Audry (info@sofianaudry.com) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + + /* +import processing.serial.*; + +Serial port; // Create object from Serial class +int val; // Data received from the serial port +int[] values; +float zoom; +float center; +float scale = 1; + +void setup() +{ + size(1280, 480); + // Open the port that the board is connected to and use the same speed (9600 bps) + port = new Serial(this, Serial.list()[0], 9600); // OpenCM9.04 포트를 알고 있을 경우 이렇게도 사용이 가능하다. port = new Serial(this, “COM3”, 9600); + values = new int[width]; + zoom = 1.0f; + smooth(); +} + +int getY(int val) { + return (int)(height/2 -(val-512+center)*scale / 1023.0f * (height - 1)); +} + +int getValue() { + int value = -1; + while (port.available() >= 3) { + if (port.read() == 0xff) { + value = (port.read() << 8) | (port.read()); + } + } + return value; +} + +void pushValue(int value) { + for (int i=0; i 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + Dxl.jointMode(ID_NUM); //jointMode() to use position mode +} + +void changeDirection(void){ + SerialUSB.print("Dxl_!\r\n"); + ExitFlag=1; +} + +void loop(){ + toggleLED(); + delay(100); + + if(ExitFlag==1) + { + Dxl.writeWord(ID_Num, Goal_Postion, 0); //Turn dynamixel ID 1 to position 0 + delay(500); // Wait for 1 second (1000 milliseconds) + Dxl.writeWord(ID_Num, Goal_Postion, 300);//Turn dynamixel ID 1 to position 300 + delay(500); // Wait for 1 second (1000 milliseconds) + + ExitFlag=0; + } +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/d_Timer_Interrupt_LED/d_Timer_Interrupt_LED.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/d_Timer_Interrupt_LED/d_Timer_Interrupt_LED.ino new file mode 100644 index 000000000..75bcb162f --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/d_Timer_Interrupt_LED/d_Timer_Interrupt_LED.ino @@ -0,0 +1,44 @@ +/* Timer_Interrupt_LED + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS.LTD + */ + +#define LED_RATE 100000 // in microseconds; should give 0.5Hz toggles + +HardwareTimer Timer(1); + +void setup() { + // Set up the LED to blink + pinMode(BOARD_LED_PIN, OUTPUT); + + // Pause the timer while we're configuring it + Timer.pause(); + + // Set up period + Timer.setPeriod(LED_RATE); // in microseconds + + // Set up an interrupt on channel 1 + Timer.setMode(TIMER_CH1, TIMER_OUTPUT_COMPARE); + Timer.setCompare(TIMER_CH1, 1); // Interrupt 1 count after each update + Timer.attachInterrupt(TIMER_CH1, handler_led); + + // Refresh the timer's count, prescale, and overflow + Timer.refresh(); + + // Start the timer counting + Timer.resume(); +} + +void loop() { + // Nothing! It's all in the handler_led() interrupt: +} + +void handler_led(void) { + toggleLED(); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/e_Timer_Interrupt_SerialUSB/e_Timer_Interrupt_SerialUSB.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/e_Timer_Interrupt_SerialUSB/e_Timer_Interrupt_SerialUSB.ino new file mode 100644 index 000000000..1688827b2 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/e_Timer_Interrupt_SerialUSB/e_Timer_Interrupt_SerialUSB.ino @@ -0,0 +1,48 @@ +/* Timer_Interrupt_SerualUSB + + 1 sec the results to the serial monitor with toggle LED blinking. + + Compatibility + CM900 O + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +#define LED_RATE 1000000 // in microseconds; should give 0.5Hz toggles +volatile unsigned int TimSec=0; +HardwareTimer Timer(1); + +void setup() { + // Set up the LED to blink + pinMode(BOARD_LED_PIN, OUTPUT); + + // Pause the timer while we're configuring it + Timer.pause(); + + // Set up period + Timer.setPeriod(LED_RATE); // in microseconds + + // Set up an interrupt on channel 1 + Timer.setMode(TIMER_CH1, TIMER_OUTPUT_COMPARE); + Timer.setCompare(TIMER_CH1, 1); // Interrupt 1 count after each update + Timer.attachInterrupt(TIMER_CH1, handler_led); + + // Refresh the timer's count, prescale, and overflow + Timer.refresh(); + + // Start the timer counting + Timer.resume(); +} + +void loop() { + // Nothing! It's all in the handler_led() interrupt: +} + +void handler_led(void) { + toggleLED(); + SerialUSB.print(TimSec++); + SerialUSB.print("sec\r\n"); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/f_Timer_Interrupt_Dynamixel/f_Timer_Interrupt_Dynamixel.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/f_Timer_Interrupt_Dynamixel/f_Timer_Interrupt_Dynamixel.ino new file mode 100644 index 000000000..ef2e23efe --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/f_Timer_Interrupt_Dynamixel/f_Timer_Interrupt_Dynamixel.ino @@ -0,0 +1,69 @@ +/* Timer_interrupt_Dynamixel + + This example demonstrate how to use TIMER Interrupt with Dynamixel, + toggleLED. + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + Ax MX Rx XL-320 Pro + CM900 O O O O O + OpenCM9.04 O O O O O + **** OpenCM9.04 MX-Series and Pro-Series in order to drive should be OpenCM 485EXP board **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. +*/ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +/* Address_Number_Define */ +#define Goal_Postion 30 + +#define LED_RATE 1000000 // in microseconds; should give 0.5Hz toggles +volatile unsigned int TimSec=0, DxlFlag=0, Pos=0; + +Dynamixel Dxl(DXL_BUS_SERIAL1); +HardwareTimer Timer(1);// Instanciate HardwareTimer class on timer device 1 + +void setup() { + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + // Set up the LED to blink + pinMode(BOARD_LED_PIN, OUTPUT); + // Pause the timer while we're configuring it + Timer.pause(); + + // Set up period + Timer.setPeriod(LED_RATE); // in microseconds + + // Set up an interrupt on channel 1 + Timer.setMode(TIMER_CH1, TIMER_OUTPUT_COMPARE); + Timer.setCompare(TIMER_CH1, 1); // Interrupt 1 count after each update + Timer.attachInterrupt(TIMER_CH1, handler_led); + + // Refresh the timer's count, prescale, and overflow + Timer.refresh(); + + // Start the timer counting + Timer.resume(); + + Dxl.jointMode(ID_NUM); +} + +void loop() { + Dxl.writeWord(ID_NUM, Goal_Postion, Pos); +} + +void handler_led(void) { + toggleLED(); + Pos=Pos+100; + if(Pos>1023)Pos=0; + +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/g_Read_Sensors_Using_Timer/g_Read_Sensors_Using_Timer.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/g_Read_Sensors_Using_Timer/g_Read_Sensors_Using_Timer.ino new file mode 100644 index 000000000..b7db7558c --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/05. Interrupt/g_Read_Sensors_Using_Timer/g_Read_Sensors_Using_Timer.ino @@ -0,0 +1,61 @@ +#include + +#define INTERVAL 100000 //micros + +OLLO myOLLO; +HardwareTimer Timer(1); +long before_start_time = 0; //前回の開始時間 + +void setup() { + + myOLLO.begin(1); + SerialUSB.begin(); + + Timer.pause(); + Timer.setPeriod(INTERVAL); //タイマ割り込み時間間隔を設定 + Timer.setMode(TIMER_CH1, TIMER_OUTPUT_COMPARE); + Timer.setCompare(TIMER_CH1, 1); + Timer.attachInterrupt(TIMER_CH1, getDMSValue); //割り込む関数を指定 + Timer.refresh(); + Timer.resume(); +} + +void loop() { + // Nothing! It's all in the handler_led() interrupt: +} + +void getDMSValue(void) { + long start_time = 0; //処理開始時間 + long interval_time = 0; //前回の割り込みからの経過時間 + int DMS_value = 0; + int tmp =0; + + start_time = micros(); //開始時間取得 + interval_time = start_time - before_start_time; + before_start_time = start_time; //更新 + + DMS_value = myOLLO.read(1); //距離センサ値取得 + + //距離が近づいてきたら + if(DMS_value >= 1000){ + for(int i=0; i< 100000; i++) { + tmp = tmp + i - tmp * i / tmp; + } + } + + //出力 + SerialUSB.print("[INTERVAL="); + SerialUSB.print(INTERVAL); + SerialUSB.print("] "); + SerialUSB.print("DMS="); + SerialUSB.print(DMS_value); + SerialUSB.print(", start_time="); + SerialUSB.print(start_time); + SerialUSB.print(", interval_time="); + SerialUSB.print(interval_time); + SerialUSB.print(", exec_time="); + SerialUSB.println(micros()- start_time); //処理時間計算 + +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/a_Dxl_Position/a_Dxl_Position.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/a_Dxl_Position/a_Dxl_Position.ino new file mode 100644 index 000000000..baede5763 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/a_Dxl_Position/a_Dxl_Position.ino @@ -0,0 +1,50 @@ +#include + +/* Dynamixel Basic Position Control Example + + Turns left the dynamixel , then turn right for one second, + repeatedly. + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ +/* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP +/* Dynamixel ID defines */ +#define ID_NUM 1 +/* Control table defines */ +#define GOAL_POSITION 30 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + //Turn dynamixel ID 1 to position 0 + Dxl.writeWord(ID_NUM, GOAL_POSITION, 0); //Compatible with all dynamixel serise + // Wait for 1 second (1000 milliseconds) + delay(1000); + //Turn dynamixel ID 1 to position 300 + Dxl.writeWord(ID_NUM, GOAL_POSITION, 300); + // Wait for 1 second (1000 milliseconds) + delay(1000); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/b_Dxl_Speed/b_Dxl_Speed.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/b_Dxl_Speed/b_Dxl_Speed.ino new file mode 100644 index 000000000..6304c27fe --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/b_Dxl_Speed/b_Dxl_Speed.ino @@ -0,0 +1,50 @@ +/* Dynamixel Speed and Position Control Example + + Turns left the dynamixel , then turn right for one second, + repeatedly with velocity 300 + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X +**** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ +/* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP +/* Dynamixel ID defines */ +#define ID_NUM 1 + +/* Control table defines */ +#define GOAL_SPEED 32 +#define GOAL_POSITION 30 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + Dxl.writeWord(ID_NUM, GOAL_SPEED, 300); //Dynamixel ID 1 Speed Control (Address_data : 0~1024) + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + //Turn dynamixel ID 1 to position 0 + Dxl.writeWord(ID_NUM, GOAL_POSITION, 0); //Compatible with all dynamixel serise + // Wait for 1 second (1000 milliseconds) + delay(1000); + //Turn dynamixel ID 1 to position 300 + Dxl.writeWord(ID_NUM, GOAL_POSITION, 300); + // Wait for 1 second (1000 milliseconds) + delay(1000); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/c_Dxl_Position_Speed/c_Dxl_Position_Speed.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/c_Dxl_Position_Speed/c_Dxl_Position_Speed.ino new file mode 100644 index 000000000..d19d99479 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/c_Dxl_Position_Speed/c_Dxl_Position_Speed.ino @@ -0,0 +1,44 @@ +#include + +/* Dynamixel setPosition Example + + Turns left the dynamixel , then turn right for one second, + repeatedly with different velocity. + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. +*/ +/* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP +/* Dynamixel ID defines */ +#define ID_NUM 1 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + /*ID 1 dynamixel moves to position 0 with velocity 100 */ + Dxl.setPosition(ID_NUM,0,100); + delay(1000);// it has more delay time for slow movement + /*ID 1 dynamixel moves to position 500 with velocity 300 */ + Dxl.setPosition(ID_NUM,500,300); + delay(500); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/d_Dxl_ID_Change/d_Dxl_ID_Change.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/d_Dxl_ID_Change/d_Dxl_ID_Change.ino new file mode 100644 index 000000000..8f4e04d71 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/d_Dxl_ID_Change/d_Dxl_ID_Change.ino @@ -0,0 +1,56 @@ +/* Dynamixel ID Change Example + + Dynamixel ID Change and Turns left the dynamixel , then turn right + for one second, repeatedly. + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +/* Dynamixel ID defines */ +#define NEW_ID 2 //New ID to be changed. + +/* Control table defines */ +#define ID_Change_Address 3 +#define Goal_Postion_Address 30 +#define Moving_Speed 32 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + +/*************** CAUTION *********************** +* All dynamixels in bus will be changed to ID 2 by using broadcast ID(0xFE) +* Please check if there is only one dynamixel that you want to change ID +************************************************/ + Dxl.writeByte(BROADCAST_ID, ID_Change_Address, NEW_ID); //Change current id to new id + Dxl.jointMode(NEW_ID); //jointMode() to use position mode +} + +void loop() { + /*Turn dynamixel to position 0 by new id*/ + Dxl.writeWord(NEW_ID, Goal_Postion_Address, 0); + // Wait for 1 second (1000 milliseconds) + delay(1000); + /*Turn dynamixel to position 300 by new id*/ + Dxl.writeWord(NEW_ID, Goal_Postion_Address, 300); + // Wait for 1 second (1000 milliseconds) + delay(1000); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/e_Dxl_Bps_Change/e_Dxl_Bps_Change.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/e_Dxl_Bps_Change/e_Dxl_Bps_Change.ino new file mode 100644 index 000000000..adc107068 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/e_Dxl_Bps_Change/e_Dxl_Bps_Change.ino @@ -0,0 +1,67 @@ +/* Dynamixel Baud Change Example + + This example shows how to set baud rate and ID using broadcast ID + All dynamixel in bus set to as 1Mbps , ID =1 + If you want your all dxl to reset ID and baud rate concurrentely. + utilize this example. + + ID=0xfe is broadcast ID, refer to ROBOTIS E-manual + + The sequence is described as the below + 1. init dxl bus as 57600bps + 2. All dxls are set to be ID = 1 + 3. New baud rate is set to be 1 Mbps + 4. After above changement, it is successfull if dxl moves well + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP +/* Dynamixel ID defines */ +#define ID_NUM 1 +/* Control table defines */ +#define GOAL_SPEED 32 +#define GOAL_POSITION 30 +#define BAUD_RATE 4 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(1);//dynamixel bus as 57600bps + + //AX MX RX Series + Dxl.writeByte(BROADCAST_ID, 3, ID_NUM); //set Dynamixel ID 1 + Dxl.writeByte(BROADCAST_ID, 4, 1); //Baud rate set to 1 Mbps + + //XL-320 + //Dxl.writeByte(ID_NUM, BAUD_RATE, 3); + + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + // Wait for 0.5 second (500 milliseconds) + delay(500); + /* Turn dynamixel ID 1 to position 0 on changed baud rate*/ + Dxl.writeWord(ID_NUM, GOAL_POSITION, 0); + // Wait for 0.5 second + delay(500); + /* Turn dynamixel ID 1 to position 1023 on changed baud rate*/ + Dxl.writeWord(ID_NUM, GOAL_POSITION, 1023); +} diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/f_Dxl_Wheel_Mode1/f_Dxl_Wheel_Mode1.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/f_Dxl_Wheel_Mode1/f_Dxl_Wheel_Mode1.ino new file mode 100644 index 000000000..8d7d8a1e7 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/f_Dxl_Wheel_Mode1/f_Dxl_Wheel_Mode1.ino @@ -0,0 +1,59 @@ +/* Dynamixel Wheel Mode Example + + This example shows how to use dynamixel as wheel mode + All dynamixels are set as joint mode in factory, + but if you want to make a wheel using dynamixel, + you have to change it to wheel mode by change CCW angle limit to 0 + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP +/* Dynamixel ID defines */ +#define ID_NUM 1 +/* Control table defines */ +#define GOAL_SPEED 32 +#define CCW_Angle_Limit 8 +#define CONTROL_MODE 11 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + + //AX MX RX Series + Dxl.writeWord(ID_NUM, CCW_Angle_Limit, 0); + //disable CCW Angle Limit(L) to use wheel mode + + //XL-320 + //Dxl.writeByte(ID_NUM, CONTROL_MODE, 1); +} + +void loop() { + //forward + Dxl.writeWord(ID_NUM, GOAL_SPEED, 400); + delay(5000); + //reverse + Dxl.writeWord(ID_NUM, GOAL_SPEED, 400 | 0x400); + delay(5000); + //stop + Dxl.writeWord(ID_NUM, GOAL_SPEED, 0); + delay(2000); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/g_Dxl_Wheel_Mode2/g_Dxl_Wheel_Mode2.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/g_Dxl_Wheel_Mode2/g_Dxl_Wheel_Mode2.ino new file mode 100644 index 000000000..283af606b --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/g_Dxl_Wheel_Mode2/g_Dxl_Wheel_Mode2.ino @@ -0,0 +1,67 @@ +/* Dynamixel Wheel Mode 2 Example + + This example shows how to implement RC Car using two dynamixels + The two dynamixels are set to as wheel mode by the way of changing + CCW_Angle_Limit to 0 + If you want to use a dynamixel as joint mode, set CCW_Angle_Limit + to 0x3FF(1023) in AX-12A case + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +/* Dynamixel ID defines */ +#define ID_Left_Wheel 1 +#define ID_Right_Wheel 2 + +/* Control table defines */ +#define CCW_Angle_Limit 8 //to change control mode +#define Goal_Postion 30 +#define Moving_Speed 32 + +#define CONTROL_MODE 11 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + //AX MX RX Series + Dxl.writeByte(ID_Left_Wheel, CCW_Angle_Limit, 0); //Dxl.jointMode(ID) can be used + Dxl.writeByte(ID_Right_Wheel, CCW_Angle_Limit, 0); + + //XL-320 + //Dxl.writeByte(ID_Left_Wheel, CONTROL_MODE, 1); //Dxl.jointMode(ID) can be used + //Dxl.writeByte(ID_Right_Wheel, CONTROL_MODE, 1); +} + +void loop() { + Dxl.writeWord(ID_Left_Wheel, Moving_Speed, 0); // stop at first + Dxl.writeWord(ID_Right_Wheel, Moving_Speed, 0); + delay(1000); // Wait for 1 sec + + Dxl.writeWord(ID_Left_Wheel, Moving_Speed, 300);// go ahead with velocity 300 + Dxl.writeWord(ID_Right_Wheel, Moving_Speed, 0x3FF | 300); + delay(2000); // Wait for 2 sec + + Dxl.writeWord(ID_Left_Wheel, Moving_Speed, 600); // speed up + Dxl.writeWord(ID_Right_Wheel, Moving_Speed, 0x3FF | 600); + delay(2000); // Wait for 2 sec +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/h_Dxl_SyncWrite1/h_Dxl_SyncWrite1.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/h_Dxl_SyncWrite1/h_Dxl_SyncWrite1.ino new file mode 100644 index 000000000..aac4a47ec --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/h_Dxl_SyncWrite1/h_Dxl_SyncWrite1.ino @@ -0,0 +1,69 @@ +/* Dynamixel SyncWrite + + This example shows same movement as previous syncwrite + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ +/* Dynamixel ID defines */ +#define ID_NUM_1 1 +#define ID_NUM_2 2 +#define ID_NUM_3 3 + +/* Control table defines */ +#define P_GOAL_POSITION 30 +#define P_GOAL_SPEED 32 + +/********* Sync write data ************** + * ID1, DATA1, DATA2..., ID2, DATA1, DATA2,... + ****************************************** + */ + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +word SyncPage1[9]= +{ + ID_NUM_1,0,100, // 3 Dynamixels are move to position 0 + ID_NUM_2,0,100, // with velocity 100 + ID_NUM_3,0,100}; +word SyncPage2[9]= +{ + ID_NUM_1,512,500, // 3 Dynamixels are move to position 512 + ID_NUM_2,512,500, // with velocity 500 + ID_NUM_3,512,500}; + +void setup(){ +// Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + //Set all dynamixels as same condition. + Dxl.writeWord( BROADCAST_ID, P_GOAL_POSITION, 0 ); + Dxl.writeWord( BROADCAST_ID, P_GOAL_SPEED, 0 ); +} + +void loop(){ +/* + * byte syncWrite(byte start_addr, byte num_of_data, int *param, int array_length); + */ + Dxl.syncWrite(30,2,SyncPage1,9); + delay(1000); + Dxl.syncWrite(30,2,SyncPage2,9); + delay(1000); +} + + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/i_Dxl_SyncWrite2/i_Dxl_SyncWrite2.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/i_Dxl_SyncWrite2/i_Dxl_SyncWrite2.ino new file mode 100644 index 000000000..52120d0fb --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/i_Dxl_SyncWrite2/i_Dxl_SyncWrite2.ino @@ -0,0 +1,79 @@ +/* Dynamixel SyncWrite2 + + Dynamixel SyncWrite exmaple using new packet methods + This example shows same movement as previous syncwrite + but, it made by new packet method, initPacket(), pushByte(), flushPacket() + It does not need any complex length fomula and parameter index. + After initPacket(), just push bytes you want to send to DXL bus and flushPacket(). + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O X X + OpenCM9.04 O O O X X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. +*/ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +#define NUM_ACTUATOR 5 // Number of actuator +#define CONTROL_PERIOD (1000) // msec (Large value is more slow) +#define MAX_POSITION 1023 +#define GOAL_SPEED 32 +#define GOAL_POSITION 30 + +word AmpPos = 512; +word wPresentPos; +word GoalPos = 0; +byte id[NUM_ACTUATOR]; +byte i; + +void setup() { + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + //Insert dynamixel ID number to array id[] + for(i=0; i MAX_POSITION ) + GoalPos -= MAX_POSITION; + delay(CONTROL_PERIOD); + +} diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/j_Dxl_ReadWrite/j_Dxl_ReadWrite.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/j_Dxl_ReadWrite/j_Dxl_ReadWrite.ino new file mode 100644 index 000000000..0fdc934d5 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/j_Dxl_ReadWrite/j_Dxl_ReadWrite.ino @@ -0,0 +1,66 @@ +/* Dynamixel ReadWrite + + Reads an dynaixel current position, and set goal position + turn left and right repeatly. + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ +/* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +/* Dynamixel ID defines */ +#define ID_NUM 1 +/* Control table defines */ +#define GOAL_POSITION 30 +#define MOVING 46 +#define XL_MOVING 49 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +byte isMoving = 0; +int goalPosition = 0; + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + //Check if ID 1 dynamixel is still moving, 46 is moving control address + //Please refer ROBOTIS support page + + //AX MX RX Series + isMoving = Dxl.readByte(ID_NUM, MOVING); + + //XL320 + //isMoving = Dxl.readByte(ID_NUM, XL_MOVING); + + //Check if the last communication is successful + if( isMoving == 0 ){ //if ID 1 dynamixel is stopped + + //Send instruction packet to move for goalPosition( control address is 30 ) + //Compatible with all dynamixel serise + Dxl.writeWord(ID_NUM, GOAL_POSITION, goalPosition ); + //toggle the position if goalPosition is 1000, set to 0, if 0, set to 1000 + if(goalPosition == 1000) + goalPosition = 0; + else + goalPosition = 1000; + } +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/k_Dxl_RegAction/k_Dxl_RegAction.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/k_Dxl_RegAction/k_Dxl_RegAction.ino new file mode 100644 index 000000000..92405098f --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/k_Dxl_RegAction/k_Dxl_RegAction.ino @@ -0,0 +1,64 @@ +/* Dynamixel Reg Action + + This example shows how to use reg/action instruction using new packet methods + Open serial monitor and type 'a' on keyboard + you can check moving dynamixel, type 'a' again -> moves its origin postion 0 + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O X X + OpenCM9.04 O O O X X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup(){ + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); +} +char temp;// need to receive from USB(PC) +uint32 GoalPos = 0; + +void loop(){ + /*initPacket method needs ID and instruction*/ + Dxl.initPacket(1,INST_REG_WRITE); + /* From now, insert byte data to packet without any index or data length*/ + Dxl.pushByte(30); + Dxl.pushByte(DXL_LOBYTE(GoalPos)); + Dxl.pushByte(DXL_HIBYTE(GoalPos)); + /* just transfer packet to dxl bus without any arguments*/ + Dxl.flushPacket(); + if(Dxl.getResult()==(1< Example > DYNAMIXEL > Tosser + 3. Now your OpenCM 9.04 is ready to works just like USB2DYNAMIXEL + 4. Run RoboPlus > DYNAMIXEL Wizard + 5. Connect to OpenCM USB COM port and then you can change control table of dynamixel. + * 2014-05-22 modified by ROBOTIS CO,,LTD. + */ + + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +int counter; +bool onlyOnceHappened; + +void blinkOnce() +{ + digitalWrite(BOARD_LED_PIN, LOW); + delay_us(100); + digitalWrite(BOARD_LED_PIN, HIGH); +} + +void setup() +{ + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + pinMode(BOARD_LED_PIN, OUTPUT); + + onlyOnceHappened=false; + counter=0; +} + +byte aByte=0; +uint8 aUint8; + +void loop() +{ + if (onlyOnceHappened==false) + { + blinkOnce(); + onlyOnceHappened=true; + delay (3000); //Some time to the user to activate the monitor/console + SerialUSB.println ("v1.1.1 Orders receiver started"); + } + + if (SerialUSB.available()) + { + aUint8=SerialUSB.read(); + blinkOnce(); + Dxl.writeRaw(aUint8); + // delay(20); + } + + if (Dxl.available()) + { + aByte=Dxl.readRaw(); + blinkOnce(); + SerialUSB.write(aByte); + } +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/m_Dxl_irsa/m_Dxl_irsa.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/m_Dxl_irsa/m_Dxl_irsa.ino new file mode 100644 index 000000000..26e5cbc8f --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/m_Dxl_irsa/m_Dxl_irsa.ino @@ -0,0 +1,119 @@ +/* + ******************************************************************************* + * IR Sensor Array Example (CM-900 version) + ******************************************************************************* + * The program reads the IR sensor pin states and uses those to control the + * tones played by the IR Sensor Array and a single AX-12W speed. + * IR4 stops rotation. + * IR1==4, IR2==2, IR3==1 => Summed and saved as variable 'left' + * IR7==4, IR6==2, IR5==1 => Summed and saved as variable 'right' + * if ((IR4 == 1) || (left==right)), then speed = 0 + * if (left > right), then speed = (left-right)*146 in CCW direction + * if (right > left), then speed = (right-left)*146 in CW direction + ******************************************************************************* + * 2014-05-22 modified by ROBOTIS CO,.LTD. + */ +// My gigantic dynamixel header file +#include + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +#define DXL_WHEEL_ID 2 +#define DXL_IRSA_ID 100 + +void setup() +{ + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + SerialUSB.begin(); + + // Waits 10 seconds for you to open the console (open too quickly after + // downloading new code, and you will get errors + delay(10000); + SerialUSB.print("Send any value to continue...\n"); + while(!SerialUSB.available()) + { + delay(1000); + digitalWrite(BOARD_LED_PIN, LOW); + SerialUSB.print("Send any value to continue...\n"); + delay(1000); + digitalWrite(BOARD_LED_PIN, HIGH); + } + SerialUSB.print("Now starting program\n"); + + Dxl.writeWord(DXL_WHEEL_ID, AXM_CW_ANGLE_LIMIT_L, 0); + Dxl.writeWord(DXL_WHEEL_ID, AXM_CCW_ANGLE_LIMIT_L, 0); + Dxl.writeByte(DXL_WHEEL_ID, AXM_TORQUE_ENABLE, 1); + Dxl.writeWord(DXL_WHEEL_ID, AXM_MOVING_SPEED_L, 0); + + delay(2000); +} +void loop() +{ + int ir=0; + while(1) + + ir = Dxl.readByte(DXL_IRSA_ID, IRSA_OBS_DET); + + // Print out in order as labeled on top of IRSA + SerialUSB.print(" 1234567\n "); + + int i; + int count=0; + + for (i=0; i<7; i++) + { + if (ir&(1<>2)&0x01); + // IR 7 6 5 extreme/large to center/small + int right = (ir>>4)&0x07; + if ((ir&0x08)) + { + speed = 0; + } + else if (left > right) + { + speed = ((left-right) * 146); + } + else if (right > left) + { + // OR by 0x0400 to change direction to CW + speed = ((right-left) * 146) | (0x0400); + } + else + { + speed = 0; + } + Dxl.writeWord(DXL_WHEEL_ID, AXM_MOVING_SPEED_L, speed); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/n_Dxl_Model_scan/n_Dxl_Model_scan.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/n_Dxl_Model_scan/n_Dxl_Model_scan.ino new file mode 100644 index 000000000..626e6dd07 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/n_Dxl_Model_scan/n_Dxl_Model_scan.ino @@ -0,0 +1,90 @@ +/* Dynamixel Bus Scanner + + Searches through all valid IDs to find all dynamixel devices currently on + the bus, and uses the Model Number to identify the device by name + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ + +// My gigantic dynamixel header file +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + pinMode(BOARD_LED_PIN, OUTPUT); + + // Waits 5 seconds for you to open the console (open too quickly after + // downloading new code, and you will get errors + delay(5000); + SerialUSB.print("Send any value to continue...\n"); + while(!SerialUSB.available()) + { + delay(1000); + digitalWrite(BOARD_LED_PIN, LOW); + SerialUSB.print("Send any value to continue...\n"); + delay(1000); + digitalWrite(BOARD_LED_PIN, HIGH); + } +} +int model; +void loop() { + // put your main code here, to run repeatedly: + for (int i=1; i<50; i++){ + SerialUSB.print(i); + delay(10); + + model = Dxl.readWord(i, 0); + + if(model == 12) + SerialUSB.println(": AX-12A"); + + else if(model == 300) + SerialUSB.println(": AX-12W"); + + else if(model == 18) + SerialUSB.println(": AX-18A"); + + else if(model == 29) + SerialUSB.println(": MX-28"); + + else if(model == 54) + SerialUSB.println(": MX-64"); + + else if(model == 64) + SerialUSB.println(": MX-106"); + + else if(model == 350) + SerialUSB.println(": XL-320"); + + else{ + if(model == 65535) model = 0; + SerialUSB.print(": Unknown : "); + SerialUSB.println(model); + } + } + + while(1){ + digitalWrite(BOARD_LED_PIN, LOW); + delay(100); + digitalWrite(BOARD_LED_PIN, HIGH); + delay(100); + } +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/o_Dxl_IR_Mouse/o_Dxl_IR_Mouse.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/o_Dxl_IR_Mouse/o_Dxl_IR_Mouse.ino new file mode 100644 index 000000000..9463b3e3d --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/o_Dxl_IR_Mouse/o_Dxl_IR_Mouse.ino @@ -0,0 +1,65 @@ +/* IR Mouse + + Using 2 dynamixels and 2 IR sensors, you can make mouse robot to avoid obstacles. + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + Ax MX Rx XL-320 Pro + CM900 O X X X X + OpenCM9.04 O X X X X + **** OpenCM9.04 MX-Series and Pro-Series in order to drive should be OpenCM 485EXP board **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. +*/ + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP +/* Dynamixel ID defines */ +#define ID_NUM1 1 +#define ID_NUM2 2 +/* Control table defines */ +#define GOAL_SPEED 32 + +#include +OLLO myOLLO; + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +int defaultSpeed = 1000; +void setup(){ + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + Dxl.wheelMode(ID_NUM1);//set id 1 as wheel mode + Dxl.wheelMode(ID_NUM2);//set id 2 as wheel mode + myOLLO.begin(1, IR_SENSOR);//IR Module must be connected at port 1. + myOLLO.begin(4, IR_SENSOR);//IR Module must be connected at port 4. +} +int leftIr=0; +int rightIr = 0; +void loop(){ + /*SerialUSB.print("Left ADC = "); + SerialUSB.print(myOLLO.read(1, IR_SENSOR)); //read ADC value from OLLO port 1 + SerialUSB.print(" Right ADC = "); + SerialUSB.println(myOLLO.read(4, IR_SENSOR)); //read ADC value from OLLO port 1 + */ + leftIr = myOLLO.read(1, IR_SENSOR); + rightIr = myOLLO.read(4, IR_SENSOR); + if( leftIr > 100){//If an obstacle is detected in the left + Dxl.writeWord(ID_NUM1,GOAL_SPEED, defaultSpeed );//change direction of ID 1 DXL + delay(500); + } + else if( rightIr > 100){ //If an obstacle is detected in the right + Dxl.writeWord(ID_NUM2,GOAL_SPEED, defaultSpeed | 0x400);//change direction of ID 2 DXL + delay(500); + } + Dxl.writeWord(ID_NUM1,GOAL_SPEED, defaultSpeed | 0x400); + Dxl.writeWord(ID_NUM2,GOAL_SPEED, defaultSpeed); + delay(60); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/p_Forward_Kinematics_4DOF/p_Forward_Kinematics_4DOF.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/p_Forward_Kinematics_4DOF/p_Forward_Kinematics_4DOF.ino new file mode 100644 index 000000000..b191fa1b3 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/p_Forward_Kinematics_4DOF/p_Forward_Kinematics_4DOF.ino @@ -0,0 +1,111 @@ + +/* Forward kinematics for 4DOF + + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + Ax MX Rx XL-320 Pro + CM900 O X X X X + OpenCM9.04 O X X X X + **** OpenCM9.04 MX-Series and Pro-Series in order to drive should be OpenCM 485EXP board **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. +*/ + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +float D2R = 3.14f/180.0f;//dgree -> radian +float l1 = 0.02; //length of link as mm +float l2 = 0.1; +float l3 = 0.13; +float d1 = 0.07; + +float q1 = -0*D2R; // θ1=q1, θ2=q2, θ3=q3 +float q2 = 0*D2R; // +float q3 = 90*D2R; // + +float x = 0.0f; // variable for θ1, θ2, θ3 +float y = 0.0f; +float z = 0.0f; +//Dxl IDs for 4DOF +int JOINT1_ID = 6; +int JOINT2_ID = 5; +int JOINT3_ID = 4; +int HAND_ID = 3; + +void setup() +{ + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + +} +//codes implemented forward kinematics +void forward_kinematics() +{ + float s1 = sin(q1); + float c1 = cos(q1); + float s2 = sin(q2); + float c2 = cos(q2); + float s3 = sin(q3); + float c3 = cos(q3); + //x, y, z for the expression + x = l1*c1 + l2*c1*c2 + l3*(c1*c2*c3-s1*s3); + y = l1*s1 + l2*s1*c2 + l3*(s1*c2*c3+c1*s3); + z = d1 - l2*s2 - l3*s2*c3; +} +int deg2pos(float de) +{ + int ret; + // 512 is the center point represents a center of 0 degrees + //Angle from side to side relative to the center point is calculated. + //Value of the input angle in order to match the angle of the motor was multiplied by 197. + ret = de * 197; + ret = ret+512; + return ret; +} +void motion_update() +{ + //move to calculated position using address 30 + Dxl.writeWord(JOINT1_ID, 30, deg2pos(q1)); + Dxl.writeWord(JOINT2_ID, 30, deg2pos(q2)); + Dxl.writeWord(JOINT3_ID, 30, deg2pos(q3)); +} +//Display input angle and position +void motion_print() +{ + SerialUSB.print("angles:"); + SerialUSB.print(" "); + SerialUSB.print(q1); + SerialUSB.print(" "); + SerialUSB.print(q2); + SerialUSB.print(" "); + SerialUSB.print(q3); + SerialUSB.println(" "); + + SerialUSB.print("end-effector pos.:"); + SerialUSB.print(" "); + SerialUSB.print(x); + SerialUSB.print(" "); + SerialUSB.print(y); + SerialUSB.print(" "); + SerialUSB.print(z); + SerialUSB.println(" "); +} + +void loop() +{ + //moves 4 DOF manipulator + forward_kinematics(); + motion_update(); + motion_print(); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/q_Motion_Page_Play/q_Motion_Page_Play.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/q_Motion_Page_Play/q_Motion_Page_Play.ino new file mode 100644 index 000000000..e17199eba --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/q_Motion_Page_Play/q_Motion_Page_Play.ino @@ -0,0 +1,231 @@ +/* Dynamixel Mode Change + + Compatibility + CM900 X + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O X X X X + OpenCM9.04 O X X X X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ + +#include +#include +OLLO myOLLO; +RC100 Controller; + +#define NUM_ACTUATOR 4 +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + + +word GoalPos[NUM_ACTUATOR], PrevGoalPos[NUM_ACTUATOR]; +byte id[NUM_ACTUATOR]; +word wGoalPos[NUM_ACTUATOR]; +int RcvData =0; +word SyncPage1[8]= +{ + 3,0, + 4,0, + 5,0, + 6,0}; + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + int i = 0; + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + Serial2.begin(57600); + myOLLO.begin(1, IR_SENSOR); + myOLLO.begin(2); + myOLLO.begin(3); + Dxl.writeWord(3, 30, 512); + Dxl.writeWord(4, 30, 512); + Dxl.writeWord(5, 30, 512); + Dxl.writeWord(6, 30, 512); + myOLLO.write(2,1,1); + myOLLO.write(3,1,1); + wGoalPos[0]= 512 ; + wGoalPos[1]= 512 ; + wGoalPos[2]= 512 ; + wGoalPos[3]= 512 ; + PrevGoalPos[0]= 512 ; + PrevGoalPos[1]= 512 ; + PrevGoalPos[2]= 512 ; + PrevGoalPos[3]= 512 ; + delay(1000); + + for(i = 3;i<=6;i++){ + Dxl.writeByte(i, 28, 128); + Dxl.writeByte(i, 29, 128); + } + + motionpage_1(); + motionpage_2(); +} + + +void loop(){ + char ch; + if(Serial2.available()){ + ch = Serial2.read(); + if(ch == 'g'){ + motionpage_3(); + motionpage_4(); + motionpage_5(); + motionpage_6(); + motionpage_7(); + motionpage_8(); + } + else if(ch == 'l'){ + motionpage_1(); + myOLLO.write(2,0,0); + myOLLO.write(3,0,0); + delay(50); + } + else if(ch == 'e'){ + myOLLO.write(2,1,1); + myOLLO.write(3,1,1); + delay(50); + } + } +} +void MotionPagePlay(word * wGoalPos, word wTimeMill, word wPauseTime) +{ + delay(wPauseTime); + word wNumOfStep = wTimeMill / 8; + word wCount; + int i = 0; + int ii = 1; + word wTempGoalPos[NUM_ACTUATOR]; + for (wCount = 0; wCount < wNumOfStep; wCount++) + { + for (i = 0; i PrevGoalPos[i]) + GoalPos[i] = PrevGoalPos[i] + (wGoalPos[i] - PrevGoalPos[i]) * wCount / wNumOfStep; + else + GoalPos[i] = PrevGoalPos[i] - (PrevGoalPos[i] - wGoalPos[i]) * wCount / wNumOfStep; + } + i=0; + for(ii = 1;ii<=9;ii+=2){ + SyncPage1[ii] = GoalPos[i]; + i++; + } + + Dxl.syncWrite(30,1, SyncPage1, 8); + delay(8); + + } + for (i = 0; i +OLLO myOLLO; + +/* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +int count = 1; +int flag = 0; +int mode_flag = 0; + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + pinMode(BOARD_BUTTON_PIN, INPUT_PULLDOWN); + pinMode(BOARD_LED_PIN, OUTPUT); + attachInterrupt(BOARD_BUTTON_PIN,changeMode, RISING); + myOLLO.begin(1, IR_SENSOR); + + wheel_change(); + +} + +void changeMode(void){ + flag = 0; + count = 1; + if(mode_flag == 0) + mode_flag = 1; + + else if(mode_flag == 1) + mode_flag = 0; + + delay(50); +} + +void loop() { + if(mode_flag == 0){ + digitalWrite(BOARD_LED_PIN, 0); + wheel_change(); + wheel_mode(); + } + else if(mode_flag == 1){ + digitalWrite(BOARD_LED_PIN, 1 ); + position_change(); + position_mode(); + } +} + +void wheel_change(){ + Dxl.writeByte(ID_NUM, 24, 0); + Dxl.writeByte(ID_NUM, 11, 1); + Dxl.writeByte(ID_NUM, 24, 1); +} + +void position_change(){ + Dxl.writeByte(ID_NUM, 24, 0); + Dxl.writeByte(ID_NUM, 11, 2); + Dxl.writeByte(ID_NUM, 24, 1); +} + +void wheel_mode(){ + Dxl.writeByte(ID_NUM, 25, count); + Dxl.writeWord(ID_NUM, 32, 146*count); + delay(1200); + + if(flag == 0){ + count++; + if(count >= 7) + flag = 1; + } + else if(flag == 1){ + count--; + if(count <= 1) + flag = 0; + } +} + +void position_mode(){ + if(myOLLO.read(1, IR_SENSOR) >= 300){ + Dxl.writeWord(1, 32, 1023); + if(flag == 0) flag = 1; + else if(flag == 1) flag = 0; + + if(flag == 0) + Dxl.writeWord(ID_NUM, 30, 1); + + else if(flag == 1) + Dxl.writeWord(ID_NUM, 30, 1023); + + delay(1000); + Dxl.writeByte(ID_NUM, 25, count); + count++; + if(count == 8) count = 1; + } + + +} + + + + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/s_Manipulator_4DOF/s_Manipulator_4DOF.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/s_Manipulator_4DOF/s_Manipulator_4DOF.ino new file mode 100644 index 000000000..32c9663e1 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/s_Manipulator_4DOF/s_Manipulator_4DOF.ino @@ -0,0 +1,206 @@ +/* Manipulator 4DOF + + Compatibility + CM900 X + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O X X X X + OpenCM9.04 O X X X X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ + #include +OLLO myOLLO; + +// My gigantic dynamixel header file +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + + +Dynamixel Dxl(DXL_BUS_SERIAL1); + + +#define NUM_ACTUATOR 4 +word GoalPos[NUM_ACTUATOR], PrevGoalPos[NUM_ACTUATOR]; +byte id[NUM_ACTUATOR]; +word wGoalPos[NUM_ACTUATOR]; + +int SyncPage1[8]= +{ + 3,0, + 4,0, + 5,0, + 6,0}; + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + int i = 0; + myOLLO.begin(1, IR_SENSOR); + myOLLO.begin(2); + myOLLO.begin(3); + Dxl.writeWord(3, 30, 512); + Dxl.writeWord(4, 30, 512); + Dxl.writeWord(5, 30, 512); + Dxl.writeWord(6, 30, 512); + myOLLO.write(2,1,1); + myOLLO.write(3,1,1); + wGoalPos[0]= 512 ; + wGoalPos[1]= 512 ; + wGoalPos[2]= 512 ; + wGoalPos[3]= 512 ; + PrevGoalPos[0]= 512 ; + PrevGoalPos[1]= 512 ; + PrevGoalPos[2]= 512 ; + PrevGoalPos[3]= 512 ; + delay(3000); + + for(i = 3;i<=6;i++){ + Dxl.writeByte(i, 28, 128); + Dxl.writeByte(i, 29, 128); + } + + motionpage_1(); + motionpage_2(); +} + + +void loop(){ + + motionpage_3(); + sensor_stop(); + motionpage_4(); + sensor_stop(); + motionpage_5(); + sensor_stop(); + motionpage_6(); + sensor_stop(); + motionpage_7(); + sensor_stop(); + motionpage_8(); + sensor_stop(); + +} + + +void MotionPagePlay(word * wGoalPos, word wTimeMill, word wPauseTime) +{ + delay(wPauseTime); + word wNumOfStep = wTimeMill / 8; + word wCount; + int i = 0; + int ii = 1; + word wTempGoalPos[NUM_ACTUATOR]; + for (wCount = 0; wCount < wNumOfStep; wCount++) + { + for (i = 0; i PrevGoalPos[i]) + GoalPos[i] = PrevGoalPos[i] + (wGoalPos[i] - PrevGoalPos[i]) * wCount / wNumOfStep; + else + GoalPos[i] = PrevGoalPos[i] - (PrevGoalPos[i] - wGoalPos[i]) * wCount / wNumOfStep; + } + i=0; + for(ii = 1;ii<=9;ii+=2){ + SyncPage1[ii] = GoalPos[i]; + i++; + } + + Dxl.syncWrite(30,1, SyncPage1, 8); + delay(8); + + } + for (i = 0; i 500){ + motionpage_1(); + myOLLO.write(2,0,0); + myOLLO.write(3,0,0); + delay(4000); + } + else{ + myOLLO.write(2,1,1); + myOLLO.write(3,1,1); + } + +} + + + + + + + + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/t_AX_XL320_Mixed/t_AX_XL320_Mixed.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/t_AX_XL320_Mixed/t_AX_XL320_Mixed.ino new file mode 100644 index 000000000..c959d858b --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/06. Dynamixel/t_AX_XL320_Mixed/t_AX_XL320_Mixed.ino @@ -0,0 +1,54 @@ +/* Dynamixel AX XL320 Mixed + + In this example, you can see how to use dxl protocol 1.0 and 2.0 at same time. + New setPacketType() method makes this possible. + Compatibility + CM900 X + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O X X O X + OpenCM9.04 O X X O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +/* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 +#define XL_320_ID_NUM 2 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + Dxl.setPacketType(DXL_PACKET_TYPE1); + Dxl.jointMode(1); + Dxl.setPacketType(DXL_PACKET_TYPE2); + Dxl.jointMode(2); +} + +void loop() { + // put your main code here, to run repeatedly: + Dxl.setPacketType(DXL_PACKET_TYPE1); + Dxl.goalPosition(ID_NUM, 1); + delay(1000); + Dxl.goalPosition(ID_NUM, 1023); + delay(1000); + + Dxl.setPacketType(DXL_PACKET_TYPE2); + Dxl.goalPosition(XL_320_ID_NUM, 1); + delay(500); + Dxl.goalPosition(XL_320_ID_NUM, 1023); + delay(500); +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/a_getModelNumber/a_getModelNumber.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/a_getModelNumber/a_getModelNumber.ino new file mode 100644 index 000000000..505300db7 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/a_getModelNumber/a_getModelNumber.ino @@ -0,0 +1,79 @@ +/* Dynamixel Model Scan + + Searches through all valid IDs to find all dynamixel devices currently on + the bus, and uses the Model Number to identify the device by name + ported from Dxl_Model_Scan by ROBOTIS CO,.LTD. +*/ +/* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +Dynamixel Dxl(DXL_BUS_SERIAL1); +void setup() { + // put your setup code here, to run once: + + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + pinMode(BOARD_LED_PIN, OUTPUT); + + // Waits 5 seconds for you to open the console + //(open too quickly after downloading new code, and you will get errors + delay(5000); + SerialUSB.print("Send any value to continue...\n"); + while(!SerialUSB.available()) + { + delay(1000); + digitalWrite(BOARD_LED_PIN, LOW); + SerialUSB.print("Send any value to continue...\n"); + delay(1000); + digitalWrite(BOARD_LED_PIN, HIGH); + } +} +int model; +void loop() { + // put your main code here, to run repeatedly: + for (int i=1; i<50; i++){ + SerialUSB.print(i); + delay(10); + + model = Dxl.getModelNumber(i); + + if(model == 12) + SerialUSB.println(": AX-12A"); + + else if(model == 300) + SerialUSB.println(": AX-12W"); + + else if(model == 18) + SerialUSB.println(": AX-18A"); + + else if(model == 29) + SerialUSB.println(": MX-28"); + + else if(model == 54) + SerialUSB.println(": MX-64"); + + else if(model == 64) + SerialUSB.println(": MX-106"); + + else if(model == 350) + SerialUSB.println(": XL-320"); + + else{ + if(model == 65535) model = 0; + SerialUSB.print(": Unknown : "); + SerialUSB.println(model); + } + + } + + while(1){ + digitalWrite(BOARD_LED_PIN, LOW); + delay(100); + digitalWrite(BOARD_LED_PIN, HIGH); + delay(100); + } +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/b_setID/b_setID.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/b_setID/b_setID.ino new file mode 100644 index 000000000..186381084 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/b_setID/b_setID.ino @@ -0,0 +1,52 @@ +/* Dynamixel ID Change Example + + Dynamixel ID Change and Turns left the dynamixel , then turn right for one + second, repeatedly. + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP +/* Dynamixel ID defines */ +#define NEW_ID 2 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); +/*************** CAUTION *********************** + * All dynamixels in bus will be changed to ID 2 by using broadcast ID(0xFE) + * Please check if there is only one dynamixel that you want to change ID + ************************************************/ + Dxl.setID(BROADCAST_ID, NEW_ID); //Dynamixel_Id_Change 1 to 2 + Dxl.jointMode(NEW_ID); //jointMode() is to use position mode +} + +void loop() { + /*Turn dynamixel ID 2 to position 0*/ + Dxl.goalPosition(NEW_ID, 0); + // Wait for 1 second (1000 milliseconds) + delay(1000); + /*Turn dynamixel ID 2 to position 300*/ + Dxl.goalPosition(NEW_ID, 300); + // Wait for 1 second (1000 milliseconds) + delay(1000); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/c_setBaud/c_setBaud.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/c_setBaud/c_setBaud.ino new file mode 100644 index 000000000..0c8a3a246 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/c_setBaud/c_setBaud.ino @@ -0,0 +1,59 @@ +/* Dynamixel Baud Change Example + + This example shows how to set baud rate and ID using broadcast ID + All dynamixel in bus set to as 1Mbps , ID =1 + If you want your all dxl to reset ID and baud rate concurrentely. + utilize this example. + + ID=0xfe is broadcast ID, refer to ROBOTIS E-manual + + + The sequence is described as the below + 1. init dxl bus as 57600bps + 2. All dxls are set to be ID = 1 + 3. New baud rate is set to be 1 Mbps + 4. After above changement, it is successfull if dxl moves well + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 +Dynamixel Dxl(DXL_BUS_SERIAL1); //Dynamixel on Serial1(USART1) + +void setup() { + // Initialize the dynamixel bus: + + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(1); //57600bps + Dxl.setID(BROADCAST_ID, ID_NUM); //All Dynamixel ID set to ID 1 + Dxl.setBaud(BROADCAST_ID, 1); //All Dynamixel Baud rate set to 1 Mbps + // Re-initialize dynamixel bus as 1Mbps + Dxl.begin(3); // initialize again as changed baud rate 1Mbps + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + delay(500); // Wait for 0.5 second (500 milliseconds) + Dxl.goalPosition(ID_NUM, 1); //Turn dynamixel ID 1 to position 1 + delay(500); // Wait for 0.5 second + Dxl.goalPosition(ID_NUM, 1023);//Turn dynamixel ID 1 to position 1023 +} + + + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/d_wheelMode/d_wheelMode.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/d_wheelMode/d_wheelMode.ino new file mode 100644 index 000000000..91c6437f2 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/d_wheelMode/d_wheelMode.ino @@ -0,0 +1,45 @@ +/* Dynamixel Wheel Mode Example + + This example shows how to use dynamixel as wheel mode + All dynamixels are set as joint mode in factory, + but if you want to make a wheel using dynamixel, + you have to change it to wheel mode by change controlmode to 1 + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.wheelMode(ID_NUM); //wheelMode() is to use wheel mode +} + +void loop() { + Dxl.goalSpeed(ID_NUM, 400); //forward + delay(5000); + Dxl.goalSpeed(ID_NUM, 400 | 0x400); //reverse + delay(5000); + Dxl.goalSpeed(ID_NUM, 0); //stop + delay(2000); +} + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/e_jointMode/e_jointMode.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/e_jointMode/e_jointMode.ino new file mode 100644 index 000000000..6cc3b5a09 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/e_jointMode/e_jointMode.ino @@ -0,0 +1,40 @@ +/* Dynamixel Position Mode Example + + This example shows how to use dynamixel as position mode + All dynamixels are set as joint mode in factory, + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + Dxl.goalPosition(ID_NUM, 1); //forward + delay(2000); + Dxl.goalPosition(ID_NUM, 1023); //reverse + delay(2000); +} diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/f_maxTorque/f_maxTorque.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/f_maxTorque/f_maxTorque.ino new file mode 100644 index 000000000..c71f44412 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/f_maxTorque/f_maxTorque.ino @@ -0,0 +1,45 @@ +/* Dynamixel Maximum Torque Example + + This example shows how to use dynamixel as maximum torque + All dynamixels are set as joint mode in factory, + but if you want to make a wheel using dynamixel, + you have to change it to maximum torque + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + + Dxl.maxTorque(ID_NUM,80); // it has maxtorque for weak movement + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + Dxl.goalPosition(ID_NUM, 1); //ID 1 dynamixel moves to position 1 + delay(2000); + Dxl.goalPosition(ID_NUM, 1023); //ID 1 dynamixel moves to position 1023 + delay(2000); +} diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/g_maxVolt/g_maxVolt.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/g_maxVolt/g_maxVolt.ino new file mode 100644 index 000000000..c9033351d --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/g_maxVolt/g_maxVolt.ino @@ -0,0 +1,46 @@ +/* Dynamixel Maximum Volatage Example + + This example shows how to use dynamixel as maximum Volatage + All dynamixels are set as joint mode in factory, + but if you want to change the maximum Volatage using dynamixel, + you have to change it to maximum Volatage by maximum Volatage to 80 + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 +#define LIMIT_VOLTAGE_ADDRESS 13 +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.maxVolt(ID_NUM, 80); // set maximum input voltage to dxl as 8V + Dxl.alarmShutdown(ID_NUM, 1); + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + Dxl.goalPosition(ID_NUM, 1); //ID 1 dynamixel moves to position 1 + delay(1000); + Dxl.goalPosition(ID_NUM, 1023); //ID 1 dynamixel moves to position 1023 + delay(1000); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/h_ccwcwAngleLimit/h_ccwcwAngleLimit.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/h_ccwcwAngleLimit/h_ccwcwAngleLimit.ino new file mode 100644 index 000000000..4bc6298cf --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/h_ccwcwAngleLimit/h_ccwcwAngleLimit.ino @@ -0,0 +1,47 @@ +/* Dynamixel ccwcwAngleLimit + + This example shows how to use dynamixel as maxvolt + All dynamixels are set as joint mode in factory, + but if you want to change the maxvolt using dynamixel, + you have to change it to maxvolt by maxvolt to 80 + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + Dxl.cwAngleLimit(ID_NUM, 300); //CW Angle Limit -> minimum 300 + Dxl.ccwAngleLimit(ID_NUM, 700); //CCW Angle Limit -> minimum 700 +} + +void loop() { + Dxl.goalPosition(ID_NUM, 1); //ID 1 dynamixel moves to position 1 + delay(2000); + Dxl.goalPosition(ID_NUM, 1023); //ID 1 dynamixel moves to position 1023 + delay(2000); +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/i_goalPosition/i_goalPosition.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/i_goalPosition/i_goalPosition.ino new file mode 100644 index 000000000..d80bdaaf7 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/i_goalPosition/i_goalPosition.ino @@ -0,0 +1,42 @@ +/* Dynamixel goalPosition + + Turns left the dynamixel , then turn right for one second, + repeatedly. + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + Dxl.goalPosition(ID_NUM, 1); //ID 1 dynamixel moves to position 1 + delay(2000); + Dxl.goalPosition(ID_NUM, 1023);//ID 1 dynamixel moves to position 1023 + delay(2000); +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/j_goalSpeed/j_goalSpeed.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/j_goalSpeed/j_goalSpeed.ino new file mode 100644 index 000000000..de3ab0d88 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/j_goalSpeed/j_goalSpeed.ino @@ -0,0 +1,43 @@ +/* Dynamixel goalSpeed + + Turns left the dynamixel , then turn right for one second, + repeatedly with velocity 300 + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X +**** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + Dxl.goalSpeed(ID_NUM, 100); //Dynamixel ID 1 Speed Control 100 setting + Dxl.jointMode(ID_NUM); //jointMode() is to use position mode +} + +void loop() { + Dxl.goalPosition(ID_NUM, 1); //ID 1 dynamixel moves to position 1 + delay(1000); + Dxl.goalPosition(ID_NUM, 300);//ID 1 dynamixel moves to position 300 + delay(1000); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/k_ledOn/k_ledOn.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/k_ledOn/k_ledOn.ino new file mode 100644 index 000000000..bf9c0a739 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/k_ledOn/k_ledOn.ino @@ -0,0 +1,44 @@ +/* Dynamixel ledOn + + This example shows how to use dynamixel as ledOn + + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 X X X O X + OpenCM9.04 X X X O X +**** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); +} + +void loop() { + int count = 0; + for(count = 0; count<=7;count++){ + Dxl.ledOn(ID_NUM, count);// XL-320 only movement XL-320 it has RGB LED + delay(500); + Dxl.ledOff(ID_NUM);//All Dynamixel LED off + delay(500); + } +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/l_complianceMargin/l_complianceMargin.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/l_complianceMargin/l_complianceMargin.ino new file mode 100644 index 000000000..50c453d7a --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/l_complianceMargin/l_complianceMargin.ino @@ -0,0 +1,42 @@ +/* Dynamixel complianceMargin + + This example shows how to use dynamixel as complianceMargin + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 +#define CW_VALUE 255 +#define CCW_VALUE 255 +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.complianceSlope(ID_NUM, CW_VALUE, CCW_VALUE); + //The range of the value is 0~255, and the unit is the same as Goal Position +} + +void loop() { + Dxl.goalPosition(ID_NUM, 1); //ID 1 dynamixel moves to position 1 + delay(2000); + Dxl.goalPosition(ID_NUM, 1023);//ID 1 dynamixel moves to position 1023 + delay(2000); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/m_complianceSlope/m_complianceSlope.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/m_complianceSlope/m_complianceSlope.ino new file mode 100644 index 000000000..3b9d75bec --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/m_complianceSlope/m_complianceSlope.ino @@ -0,0 +1,46 @@ +/* Dynamixel complianceSlope + + This example shows how to use dynamixel as complianceSlope + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X +**** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 +#define CW_VALUE 128 +#define CCW_VALUE 128 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.complianceSlope(ID_NUM, CW_VALUE, CW_VALUE); + //Compliance Slope is set in 7 steps, the higher the value, + //the more flexibility is obtained. + Dxl.jointMode(ID_NUM); +} + +void loop() { + Dxl.goalPosition(ID_NUM, 1); //ID 1 dynamixel moves to position 1 + delay(800); + Dxl.goalPosition(ID_NUM, 1023);//ID 1 dynamixel moves to position 1023 + delay(800); +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/n_CW_CCWTurnSpeed/n_CW_CCWTurnSpeed.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/n_CW_CCWTurnSpeed/n_CW_CCWTurnSpeed.ino new file mode 100644 index 000000000..89235035a --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/n_CW_CCWTurnSpeed/n_CW_CCWTurnSpeed.ino @@ -0,0 +1,39 @@ +/* Dynamixel CW/CCW Turn Speed + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + +} + +void loop() { + Dxl.cwTurn(ID_NUM, 500); //ID 1 dynamixel moves to position 1 + delay(2000); + Dxl.ccwTurn(ID_NUM, 500); //ID 1 dynamixel moves to position 1 + delay(2000); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/o_MixedJointWheelMode/o_MixedJointWheelMode.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/o_MixedJointWheelMode/o_MixedJointWheelMode.ino new file mode 100644 index 000000000..f9d54fe49 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/07. Dynamixel Easy/o_MixedJointWheelMode/o_MixedJointWheelMode.ino @@ -0,0 +1,59 @@ +/* Dynamixel CW/CCW Turn Speed + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X +**** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 + +Dynamixel Dxl(DXL_BUS_SERIAL1); + +void setup() { + // Initialize the dynamixel bus: + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); +} + +void loop() { + int count = 0; + + Dxl.jointMode(ID_NUM); + for(count = 1;count <= 3;count++){ + SerialUSB.println("Joint Mode Success -> O"); + SerialUSB.print("Count -> "); + SerialUSB.println(count); + + Dxl.goalPosition(ID_NUM, 1); //ID 1 dynamixel moves to position 1 + delay(2000); + Dxl.goalPosition(ID_NUM, 1023); //ID 1 dynamixel moves to position 1023 + delay(2000); + } + + Dxl.wheelMode(ID_NUM); + for(count = 1;count <= 3;count++){ + SerialUSB.println("Wheel Mode Success -> 0"); + SerialUSB.print("Count -> "); + SerialUSB.println(count); + + Dxl.goalSpeed(ID_NUM, 100); //ID 1 dynamixel moves to Speed 100 + delay(2000); + Dxl.goalSpeed(ID_NUM, 500); //ID 1 dynamixel moves to Speed 500 + delay(2000); + } +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/Gyro_XY_Read/Gyro_XY_Read.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/Gyro_XY_Read/Gyro_XY_Read.ino new file mode 100644 index 000000000..5480bd1ae --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/Gyro_XY_Read/Gyro_XY_Read.ino @@ -0,0 +1,33 @@ +/* OLLO Gyro(Sensor) XY Read + + connect Gyro Sensor Module(GS-12) to port 1 and 2. + + You can buy Gyro Sensor DYNAMIXEL in ROBOTIS-SHOP + http://www.robotis-shop-en.com/shop/step1.php?number=833&b_code=B20070914051413&c_code=C20100528062452 + You can also find all information + http://support.robotis.com/ + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +#include +OLLO myOLLO; + +void setup(){ + myOLLO.begin(1);//Gyro X Axis must be connected to port 1. + myOLLO.begin(2);//Gyro Y Axis must be connected to port 2. +} +void loop(){ + SerialUSB.print("X-Axis ADC = "); + SerialUSB.print(myOLLO.read(1)); //read X-Axis ADC value from OLLO port 1 + SerialUSB.print(" Y-Axis ADC = "); + SerialUSB.println(myOLLO.read(2)); //read X-Axis ADC value from OLLO port 2 + delay(60); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_COLOR_Read/OLLO_COLOR_Read.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_COLOR_Read/OLLO_COLOR_Read.ino new file mode 100644 index 000000000..2c1529c4b --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_COLOR_Read/OLLO_COLOR_Read.ino @@ -0,0 +1,35 @@ +/* OLLO Color sensor Read + + When push OLLO Color sensor module, read digital I/O from the port 2 + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +#include +OLLO myOLLO; + +void setup(){ + myOLLO.begin(2,COLOR_SENSOR);//OLLO Color Module must be connected at port 2. + +} +void loop(){ + SerialUSB.print("COLOR Read = "); + SerialUSB.println(myOLLO.read(2, COLOR_SENSOR)); + delay(100); +} + +/* Result ---> myOLLO.read(2, COLOR_SENSOR) +1 -> White +2 -> Black +3 -> Red +4 -> Green +5 -> Blue +6 -> Yellow +*/ + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_DMS_Read/OLLO_DMS_Read.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_DMS_Read/OLLO_DMS_Read.ino new file mode 100644 index 000000000..ad05b221e --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_DMS_Read/OLLO_DMS_Read.ino @@ -0,0 +1,31 @@ +/* OLLO DMS Sensor Read + + connect DMS Sensor Module(DMS-80) to port 1. + + You can buy DMS Sensor DYNAMIXEL in ROBOTIS-SHOP + http://www.robotis-shop-en.com/shop/step1.php?number=834&b_code=B20070914051413&c_code=C20100528062452 + You can also find all information + http://support.robotis.com/ + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +#include +OLLO myOLLO; + +void setup(){ + myOLLO.begin(1);//DMS Module must be connected at port 1. +} +void loop(){ + Serial.print("DMS Sensor ADC Value = "); + Serial.println(myOLLO.read(1)); //read ADC value from OLLO port 1 + delay(60); +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_IR_Read/OLLO_IR_Read.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_IR_Read/OLLO_IR_Read.ino new file mode 100644 index 000000000..5cbb335ac --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_IR_Read/OLLO_IR_Read.ino @@ -0,0 +1,33 @@ +/* + OLLO IR Sensor Read example + + connect IR Sensor Module(OIS-10) to port 1. + + You can buy IR Sensor DYNAMIXEL in ROBOTIS-SHOP + http://www.robotis-shop-en.com/shop/step1.php?number=750&b_code=B20070914051413&c_code=C20100528062452 + You can also find all information + http://support.robotis.com/ + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +#include +OLLO myOLLO; + +void setup(){ + Serial.begin(115200); + myOLLO.begin(1, IR_SENSOR);//IR Module must be connected at port 1. +} +void loop(){ + Serial.print("IR Sensor ADC = "); + Serial.println(myOLLO.read(1, IR_SENSOR)); //read ADC value from OLLO port 1 + delay(60); +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_LED_Blink/OLLO_LED_Blink.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_LED_Blink/OLLO_LED_Blink.ino new file mode 100644 index 000000000..b253f7d2f --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_LED_Blink/OLLO_LED_Blink.ino @@ -0,0 +1,32 @@ +/*OLLO LED Module example + + connect LED Module to port 3. + + You can buy LED Module DYNAMIXEL in ROBOTIS-SHOP + http://www.robotis-shop-en.com/shop/step1.php?number=751&b_code=B20070914051413&c_code=C20100528064118 + You can also find all information + http://support.robotis.com/ + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. +*/ + +#include +OLLO myOLLO; + +void setup(){ + myOLLO.begin(3);//LED Display Module must be connected at port 3. +} +void loop(){ + //write( port number, left LED(blue), right LED(yellow) ) + myOLLO.write(3,1,0);// or use myOLLO.write(3,1,0,0); + delay(100); + myOLLO.write(3,0,1);// or use myOLLO.write(3,0,0,1); + delay(100); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_Magnetic_Read/OLLO_Magnetic_Read.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_Magnetic_Read/OLLO_Magnetic_Read.ino new file mode 100644 index 000000000..a10e35d01 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_Magnetic_Read/OLLO_Magnetic_Read.ino @@ -0,0 +1,31 @@ +/* OLLO Magnetic sensor Read example + + connect Magnetic Sensor Module to port 2. + + You can buy Magnetic Sensor DYNAMIXEL in ROBOTIS-SHOP + http://www.robotis-shop-en.com/shop/step1.php?number=750&b_code=B20070914051413&c_code=C20100528062452 + //위 링크 수정 + + You can also find all information + http://support.robotis.com/ + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +#include +OLLO myOLLO; + +void setup(){ + myOLLO.begin(2, MAGNETIC_SENSOR);//OLLO Magnetic Module must be connected at port 2. + +} +void loop(){ + SerialUSB.print("Magenetic Read = "); + SerialUSB.println(myOLLO.read(2, MAGNETIC_SENSOR)); + delay(100); +} diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_PIR_Read/OLLO_PIR_Read.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_PIR_Read/OLLO_PIR_Read.ino new file mode 100644 index 000000000..9acf6d846 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_PIR_Read/OLLO_PIR_Read.ino @@ -0,0 +1,36 @@ +/* OLLO PIR sensor Read + + connect Temperature Sensor Module to port 2. + + You can buy PIR Sensor DYNAMIXEL in ROBOTIS-SHOP + http://www.robotis-shop-en.com/shop/step1.php?number=750&b_code=B20070914051413&c_code=C20100528062452 + //위 링크 수정 + + You can also find all information + http://support.robotis.com/ + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +#include +OLLO myOLLO; + +void setup(){ + myOLLO.begin(1,PIR_SENSOR);//OLLO PIR Module must be connected at port 2. + +} +void loop(){ + Serial.print("PIR Read = "); + Serial.println(myOLLO.read(1, PIR_SENSOR)); + delay(100); +} + + + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_TOUCH_Read/OLLO_TOUCH_Read.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_TOUCH_Read/OLLO_TOUCH_Read.ino new file mode 100644 index 000000000..23ae57573 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_TOUCH_Read/OLLO_TOUCH_Read.ino @@ -0,0 +1,35 @@ +/* OLLO Touch sensor interrupt + + connect Touch Sensor Module to port 2. + + You can buy Touch Sensor DYNAMIXEL in ROBOTIS-SHOP + http://www.robotis-shop-en.com/shop/step1.php?number=750&b_code=B20070914051413&c_code=C20100528062452 + //위 링크 수정 + + You can also find all information + http://support.robotis.com/ + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +#include +OLLO myOLLO; + +void setup(){ + myOLLO.begin(1,TOUCH_SENSOR);//OLLO Touch Module must be connected at port 2. + +} +void loop(){ + Serial.print("Touch Read = "); + Serial.println(myOLLO.read(1, TOUCH_SENSOR)); + delay(100); +} + + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_Temperature_Read/OLLO_Temperature_Read.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_Temperature_Read/OLLO_Temperature_Read.ino new file mode 100644 index 000000000..07e6cce19 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/08. Sensors/OLLO_Temperature_Read/OLLO_Temperature_Read.ino @@ -0,0 +1,33 @@ +/* OLLO Temperature Sensor Read + + connect Temperature Sensor Module to port 1. + + You can buy Temperature Sensor DYNAMIXEL in ROBOTIS-SHOP + http://www.robotis-shop-en.com/shop/step1.php?number=750&b_code=B20070914051413&c_code=C20100528062452 + //위 링크 수정 + + You can also find all information + http://support.robotis.com/ + + Compatibility + CM900 X + OpenCM9.04 O + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ + +#include +OLLO myOLLO; + +void setup(){ + myOLLO.begin(1, TEMPERATURE_SENSOR);//Temperature Module must be connected at port 1. +} +void loop(){ + SerialUSB.print("Temperature Sensor = "); + SerialUSB.println(myOLLO.read(1, TEMPERATURE_SENSOR)); //read ADC value from OLLO port 1 + delay(60); +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/09. Smart/Smart_FlagRobot/Smart_FlagRobot.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/09. Smart/Smart_FlagRobot/Smart_FlagRobot.ino new file mode 100644 index 000000000..d8ffb8182 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/09. Smart/Smart_FlagRobot/Smart_FlagRobot.ino @@ -0,0 +1,315 @@ +/* Smart FlagRobot Example + + This example shows R+SMART Kit FlagRobot example + You can find the information of R+SMART product in the below link. + http://support.robotis.com/ko/software/mobile_solution/r+smart/r+smartmain.htm + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 X X X O X + OpenCM9.04 X X X O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ + +#include +OLLO myOLLO; + + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +Dynamixel Dxl(DXL_BUS_SERIAL1); +Dynamixel Smart(DXL_BUS_SERIAL2); + +byte flagState = 0; +word inputTime = 1000; + +//위치:2,2, 아이템: 1, 크기: 30, 색상: 흰색 +unsigned int opportunityLabel = 18743559; +byte opportunityChance = 3; + +//위치:4,2, 아이템: 2, 크기: 30, 색상: 흰색 +unsigned int getFlagLabel = 18743817; +byte getFlag = 0; + +//목록 설정 +byte BlueUP = 3; +byte WhiteUP = 4; +byte BlueDown = 5; +byte WhiteDown = 6; + +word getFlagPosition = getFlag * 256; +word opportunityChancePosition = opportunityChance * 256; + +//위치:4,3, 아이템: 0, 크기: 50, 색상: 흰색 +unsigned int getFlagDisplay = 20054030 + getFlagPosition; +//위치:2,3, 아이템: 0, 크기: 50, 색상: 흰색 +unsigned int opportunityChanceDisplay = 20054028 + opportunityChancePosition; + +byte intputCheck = 0; + +byte BlueSwitch = 0; +byte WhiteSwitch = 0; +byte BeforeBlueSwitch = 0; +byte BeforeWhiteSwitch = 0; +byte randumNum = 0; +int touchTimercount = 0; + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Smart.begin(1); + + myOLLO.begin(1,IR_SENSOR); + myOLLO.begin(4,IR_SENSOR); + setting(); + + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.goalPosition(1, 512); + Dxl.goalPosition(2, 512); + delay(500); +} + +void loop() { + flagDisplay(); + delay(100); + sensorCheck(); + faceDisplay(); + scoreDisplay(); +} + +void setting(){ + //핸드폰 방향 설정 + Smart.writeByte(100, 10010, 2); + + //초기 표시 설정 + Smart.writeDword(100, 10160, opportunityLabel); + Smart.writeDword(100, 10160, getFlagLabel); + + Smart.writeDword(100, 10170, getFlagDisplay); + Smart.writeDword(100, 10170, opportunityChanceDisplay); + + //위치:3,3, 아이템: 0, 크기: 0 + Smart.writeWord(100, 10140, 13); + //위치:3,4, 아이템: 0, 크기: 0 + Smart.writeWord(100, 10140, 18); + + delay(2000); +} +void flagDisplay(){ + flagState = 0; + intputCheck = 0; + randumNum = (int)random(5); + //위치:3,3, 아이템: 3, 크기: 1 + Smart.writeDword(100, 10140, 66317); + //위치:1,3, 아이템: 0, 크기: 0 + Smart.writeDword(100, 10140, 11); + //위치:5,3, 아이템: 0, 크기: 0 + Smart.writeDword(100, 10140, 15); + + if(randumNum == 1){ + //위치:1,3, 아이템: 1, 크기: 1 + Smart.writeDword(100, 10140, 65803); + //TTS 청기내려 + Smart.writeDword(100, 10180, 5); + while(Smart.readByte(100, 10180)!= 0){ + sensorCheck(); + if(intputCheck == 1){ + break; + } + } + } + else if(randumNum == 2){ + //위치:1,3, 아이템: 1, 크기: 1 + Smart.writeDword(100, 10140, 65803); + //TTS 청기올려 + Smart.writeDword(100, 10180, 3); + while(Smart.readByte(100, 10180)!= 0){ + sensorCheck(); + if(intputCheck == 1){ + break; + } + } + } + else if(randumNum == 4){ + //위치:5,3, 아이템: 2, 크기: 1 + Smart.writeDword(100, 10140, 66063); + //TTS 백기내려 + Smart.writeDword(100, 10180, 6); + while(Smart.readByte(100, 10180)!= 0){ + sensorCheck(); + if(intputCheck == 1){ + break; + } + } + } + else if(randumNum == 5){ + //위치:1,3, 아이템: 1, 크기: 1 + Smart.writeDword(100, 10140, 66063); + //TTS 백기올려 + Smart.writeDword(100, 10180, 4); + while(Smart.readByte(100, 10180)!= 0){ + if(intputCheck == 1){ + break; + } + } + } +} + + +void intputDetect(){ + if(flagState != 0){ + + } + for(int touchTimercount = 0;touchTimercount< 10000;touchTimercount++){ + sensorCheck(); + if(intputCheck == 1){ + break; + } + } +} + +void faceDisplay(){ + if(BlueSwitch < 1 && WhiteSwitch < 1) + if(randumNum == 2 || randumNum == 5) + flagState = 2; + + if(flagState ==1){ + //위치:3,3, 아이템: 4, 크기: 1 + Smart.writeDword(100, 10140, 66573); + } + else if(flagState ==2){ + //위치:3,3, 아이템: 5, 크기: 1 + Smart.writeDword(100, 10140, 66829); + } + else{ + //위치:3,3, 아이템: 3, 크기: 1 + Smart.writeDword(100, 10140, 66317); + } +} +void scoreDisplay(){ + //깃발상태 (0: 대기, 1:캡쳐, 2:미스) + if(flagState == 1){ + getFlag++; + inputTime = inputTime - 100; + if(inputTime <= 0){ + inputTime = 0; + } + } + else if(flagState == 2){ + opportunityChance--; + } + + getFlagPosition = getFlag * 256; + opportunityChancePosition = opportunityChance * 256; + + //위치:4,3, 아이템: 0, 크기: 50, 색상: 흰색 + getFlagDisplay = 20054030 + getFlagPosition; + //위치:2,3, 아이템: 0, 크기: 50, 색상: 흰색 + opportunityChanceDisplay = 20054028 + opportunityChancePosition; + + Smart.writeDword(100, 10170, getFlagDisplay); + Smart.writeDword(100, 10170, opportunityChanceDisplay); + + if(opportunityChance == 0) + gameover(); + if(flagState == 1 || flagState == 2){ + delay(500); + } +} +void sensorCheck(){ + if(myOLLO.read(1, IR_SENSOR) >= 100) + BlueSwitch = 1; + else if(myOLLO.read(4, IR_SENSOR) >= 100) + WhiteSwitch = 1; + else{ + BlueSwitch = 0; + WhiteSwitch = 0; + } + if(BlueSwitch <1 && WhiteSwitch < 1){ + flagState = 0; + BeforeWhiteSwitch = 0; + BeforeBlueSwitch = 0; + } + else{ + if(BeforeWhiteSwitch == 0 && BeforeBlueSwitch == 0){ + if(BlueSwitch > 0){ + if(randumNum == 2){ + flagState = 1; + } + else { + flagState = 2; + } + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.goalPosition(1, 800); + delay(400); + Dxl.goalPosition(1, 512); + delay(200); + BeforeBlueSwitch = 1; + intputCheck = 1; + + } + else if(WhiteSwitch > 0){ + if( randumNum == 5){ + flagState = 1; + } + else{ + flagState = 2; + } + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.goalPosition(2, 200); + delay(400); + Dxl.goalPosition(2, 512); + delay(200); + BeforeWhiteSwitch = 1; + intputCheck = 1; + } + } + } +} +void gameover(){ + Smart.writeWord(100, 10200, 1); + while(Smart.readByte(100, 10200) != 0); + + //화면 클리어 + Smart.writeWord(100, 10140, 0); + Smart.writeWord(100, 10160, 0); + Smart.writeWord(100, 10170, 0); + + //GamgeOver 표시 + Smart.writeDword(100, 10140, 67085); + + //Retry 표시 + Smart.writeDword(100, 10140, 67346); + + //Retry 깜박임, 클릭시 게임 재시작 + while( Smart.readByte(100, 10310) != 18){ + for(int i = 0;i<=1;i++){ + if(i == 0){ + //위치:3,4, 아이템: 0, 크기: 0 + Smart.writeDword(100, 10140, 18); + } + else{ + //위치:3,4, 아이템: 7, 크기: 1 + Smart.writeDword(100, 10140, 67346); + } + for(int touchTimercount = 0;touchTimercount< 10000;touchTimercount++){ + if(Smart.readByte(100, 10310) == 18){ + break; + } + } + } + } + setting(); +} diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/a_485_EXP_Digital_IO/a_485_EXP_Digital_IO.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/a_485_EXP_Digital_IO/a_485_EXP_Digital_IO.ino new file mode 100644 index 000000000..2757b5e1c --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/a_485_EXP_Digital_IO/a_485_EXP_Digital_IO.ino @@ -0,0 +1,85 @@ +/* + 485 EXP Digital IO + + + Compatibility + CM900 X + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +/* 485 EXP switch, LED definces for 485 EXP device */ +#define RED_LED_485EXP 18 +#define GREEN_LED_485EXP 19 +#define BLUE_LED_485EXP 20 +#define BUTTON1_485EXP 16 +#define BUTTON2_485EXP 17 + + +Dynamixel Dxl(DXL_BUS_SERIAL3); + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + pinMode(RED_LED_485EXP, OUTPUT); + pinMode(GREEN_LED_485EXP, OUTPUT); + pinMode(BLUE_LED_485EXP, OUTPUT); + pinMode(BUTTON1_485EXP, INPUT); + pinMode(BUTTON2_485EXP, INPUT); + Dxl.ledOff(1); + Dxl.ledOff(2); +} +void loop() { + if(digitalRead(BUTTON2_485EXP) == 1){ + delay(100); + if(digitalRead(BUTTON2_485EXP) == 1){ + digitalWrite(RED_LED_485EXP, 0); + digitalWrite(GREEN_LED_485EXP, 0); + digitalWrite(BLUE_LED_485EXP, 0); + } + } + else if(digitalRead(BUTTON1_485EXP) == 1){ + delay(100); + if(digitalRead(BUTTON1_485EXP) == 1){ + digitalWrite(RED_LED_485EXP, 0); + digitalWrite(GREEN_LED_485EXP, 0); + digitalWrite(BLUE_LED_485EXP, 0); + } + } + else{ + digitalWrite(RED_LED_485EXP, 1); + digitalWrite(GREEN_LED_485EXP, 1); + digitalWrite(BLUE_LED_485EXP, 1); + } + for(int i = 1;i<=10;i++){ + Dxl.ledOff(i); + } + delay(80); + + for(int i = 1;i<=10;i++){ + Dxl.ledOn(i, 1); + } + delay(80); +} + + + + + + + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/b_DxlPro_Basic/b_DxlPro_Basic.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/b_DxlPro_Basic/b_DxlPro_Basic.ino new file mode 100644 index 000000000..afde1bea1 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/b_DxlPro_Basic/b_DxlPro_Basic.ino @@ -0,0 +1,60 @@ +/* Dynamixel Pro Basic Example + + Write 2 goal positions to ID 1 dynamixel pro + turn left and right repeatly. + Dynamixel pro use DXL protocol 2.0 + You can also find all information about DYNAMIXEL PRO and protocol 2.0 + http://support.robotis.com/ + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel check the movement + AX MX RX XL-320 Pro + CM900 X X X X O + OpenCM9.04 X X X X O + **** OpenCM9.04 MX-Series and Pro-Series in order to drive should be + OpenCM 485EXP board **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 +#define LED_GREEN 564 +#define GOAL_POSITION 596 +#define TORQUE_ENABLE 562 + +Dynamixel Dxl(DXL_BUS_SERIAL3); + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + //Toque on to move dynamixel pro + Dxl.writeByte(ID_NUM,TORQUE_ENABLE,1); +} + +void loop() { + + //Turn on green LED in DXL PRO + Dxl.writeByte(ID_NUM,LED_GREEN,255); + //Move to goal position 151875 refer to position limit + Dxl.writeDword(ID_NUM,GOAL_POSITION,151875); + delay(3000); + //Turn off green LED in DXL PRO + Dxl.writeByte(ID_NUM,LED_GREEN,0); + //Move to goal position -151875 refer to position limit + Dxl.writeDword(ID_NUM,GOAL_POSITION,-151875); + + delay(3000); + //Read DXL internal temperature + SerialUSB.print(" DXL PRO Temperature = "); + SerialUSB.println(Dxl.readByte(ID_NUM,625)); +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/c_DxlPro_readWrite/c_DxlPro_readWrite.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/c_DxlPro_readWrite/c_DxlPro_readWrite.ino new file mode 100644 index 000000000..c841582cf --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/c_DxlPro_readWrite/c_DxlPro_readWrite.ino @@ -0,0 +1,60 @@ +/* Dynamixel read/write Example + + Reads an dynaixel current movement, and set goal position + turn left and right repeatly. + You can also find all information about DYNAMIXEL PRO and protocol 2.0 + http://support.robotis.com/ + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel check the movement + AX MX RX XL-320 Pro + CM900 X X X X O + OpenCM9.04 X X X X O + **** OpenCM9.04 MX-Series and Pro-Series in order to drive should be + OpenCM 485EXP board **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. +*/ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 +#define TORQUE_ENABLE 562 +#define GOAL_POSITION 596 +#define MOVING 610 + +Dynamixel Dxl(DXL_BUS_SERIAL3); + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + //Toque is enable to move dynamixel pro + Dxl.writeByte(ID_NUM,TORQUE_ENABLE,1); +} +byte isMoving = 0; +int goalPosition = 0; +void loop() { + + //Check if ID 1 dynamixel is still moving, address 610 + //Please refer ROBOTIS support page + //Check if the last communication is successful + if(!Dxl.readByte(ID_NUM,MOVING)){ + + //Send instruction packet to move for goalPosition( control address is 596 ) + Dxl.writeDword(ID_NUM,GOAL_POSITION, goalPosition ); + //toggle the position + if(goalPosition == 151875) + goalPosition = -151875; + else + goalPosition = 151875; + + } + delay(500); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/d_DxlPro_Syncwrite/d_DxlPro_Syncwrite.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/d_DxlPro_Syncwrite/d_DxlPro_Syncwrite.ino new file mode 100644 index 000000000..e7e8c6cf0 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/d_DxlPro_Syncwrite/d_DxlPro_Syncwrite.ino @@ -0,0 +1,56 @@ +/* Dynamixel Syncwrite Example + + Write goal position with velocity to ID 1 dynamixel pro. + Dynamixel pro use DXL protocol 2.0. + You can also find all information about DYNAMIXEL PRO and protocol 2.0 + http://support.robotis.com/ + + Compatibility + CM900 O + OpenCM9.04 O + + Dynamixel check the movement + AX MX RX XL-320 Pro + CM900 X X X X O + OpenCM9.04 X X X X O + **** OpenCM9.04 MX-Series and Pro-Series in order to drive should be + OpenCM 485EXP board **** + + created 16 Nov 2012 + by ROBOTIS CO,.LTD. + */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +#define ID_NUM 1 +#define GOAL_POSITION 596 +#define TORQUE_ENABLE 562 + +Dynamixel Dxl(DXL_BUS_SERIAL3); + +int itemp1[3]; +int itemp2[3]; +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + Dxl.writeByte(ID_NUM,TORQUE_ENABLE,1); + + +} +void loop(){ + + itemp1[0] = 1; + itemp1[1] = 151875; //goal posiotion 1 + itemp1[2] = 10000; //velocity 1 + + itemp2[0] = 1; + itemp2[1] = -151875; //goal position 2 + itemp2[2] = 5000; //velocity 2 + Dxl.syncWrite(GOAL_POSITION,2,itemp1,3); + delay(3000); + Dxl.syncWrite(GOAL_POSITION,2,itemp2,3); + delay(3000); +} + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/e_Dxl_Mode_Change/e_Dxl_Mode_Change.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/e_Dxl_Mode_Change/e_Dxl_Mode_Change.ino new file mode 100644 index 000000000..b03264540 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/e_Dxl_Mode_Change/e_Dxl_Mode_Change.ino @@ -0,0 +1,163 @@ +/* Dynamixel Mode Change + + Compatibility + CM900 X + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 O O O O X + OpenCM9.04 O O O O X + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ + #include + OLLO myOLLO; + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +/* 485 EXP switch, LED definces for 485 EXP device */ +#define RED_LED_485EXP 18 +#define GREEN_LED_485EXP 19 +#define BLUE_LED_485EXP 20 +#define BUTTON1_485EXP 16 +#define BUTTON2_485EXP 17 + +/* Dynamixel ID defines */ +#define ID_NUM 1 + + +Dynamixel Dxl(DXL_BUS_SERIAL3); + +int count = 1; +int flag = 0; +int mode_flag = 0; + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + pinMode(BOARD_LED_PIN, OUTPUT); + + pinMode(BUTTON1_485EXP, INPUT_PULLDOWN); + pinMode(BUTTON2_485EXP, INPUT_PULLDOWN); + pinMode(RED_LED_485EXP, OUTPUT); + pinMode(GREEN_LED_485EXP, OUTPUT); + pinMode(BLUE_LED_485EXP, OUTPUT); + + attachInterrupt(BUTTON1_485EXP,wheel_mode_change, RISING); + attachInterrupt(BUTTON2_485EXP,position_mode_change, RISING); + myOLLO.begin(1, IR_SENSOR); + + // Dynamixel 2.0 Baudrate -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.wheelMode(ID_NUM); +} + +void wheel_mode_change(void){ + digitalWrite(BOARD_LED_PIN, 0); + count = 1; + mode_flag = 0; + Dxl.wheelMode(ID_NUM); +} + +void position_mode_change(void){ + digitalWrite(BOARD_LED_PIN, 1); + count = 1; + mode_flag = 1; + Dxl.jointMode(ID_NUM); +} + +void loop() { + if(mode_flag == 0){ + digitalWrite(BOARD_LED_PIN, 0); + wheel_mode(); + } + else if(mode_flag == 1){ + digitalWrite(BOARD_LED_PIN, 1 ); + position_mode(); + } +} + + + + +void wheel_mode(){ + Dxl.goalSpeed(ID_NUM, 146*count); + delay(1500); + + if(count == 1) + LED(0, 1, 1); + if(count == 4) + LED(0, 0, 1); + if(count == 6) + LED(0, 0, 0); + + if(flag == 0){ + count++; + if(count >= 7) + flag = 1; + } + else if(flag == 1){ + count--; + if(count <= 1) + flag = 0; + } +} + +void position_mode(){ + if(myOLLO.read(1, IR_SENSOR) < 50) + Dxl.goalSpeed(ID_NUM, 100); + else + Dxl.goalSpeed(ID_NUM,(myOLLO.read(1, IR_SENSOR))*2); + + + if(flag == 0) flag = 1; + else if(flag == 1) flag = 0; + + if(flag == 0){ + LED(0, 0, 0); + Dxl.goalPosition(ID_NUM,1); + } + else if(flag == 1){ + LED(1, 1, 1); + Dxl.goalPosition(ID_NUM,1023); + } + delay(1500); + + count++; + + + if(count == 8) count = 1; +} + +void LED(int num, int nnum1, int nnum2){ + if(num == 1) + digitalWrite(BLUE_LED_485EXP, 1); + else + digitalWrite(BLUE_LED_485EXP, 0); + + if(nnum1 == 1) + digitalWrite(GREEN_LED_485EXP, 1); + else + digitalWrite(GREEN_LED_485EXP, 0); + + if(nnum2 == 1) + digitalWrite(RED_LED_485EXP, 1); + else + digitalWrite(RED_LED_485EXP, 0); + + delay(10); +} + + + + + + + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/f_Convert_angle_to_dxl_position/f_Convert_angle_to_dxl_position.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/f_Convert_angle_to_dxl_position/f_Convert_angle_to_dxl_position.ino new file mode 100644 index 000000000..bc305f2d9 --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/f_Convert_angle_to_dxl_position/f_Convert_angle_to_dxl_position.ino @@ -0,0 +1,107 @@ +/* + Convert angle to goal position + + This example demonstrates how to convert angle degree to dxl goal position data + In this way you are with reference to the mathematical formula may be applied to DXL. + Compatibility + CM900 X + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 X X X X O + OpenCM9.04 X X X X O + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ + + /* Serial device defines for dxl bus */ +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485 EXP + +#define ID_NUM1 1 +#define ID_NUM2 2 +#define ID_NUM3 3 +#define TORQUE_ENABLE 562 +#define GOAL_POSITION 596 + + Dynamixel Dxl(DXL_BUS_SERIAL3); + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + Dxl.writeByte(BROADCAST_ID,TORQUE_ENABLE,1); +} + +int goal = 0; +int spd = 0; +int spd_1 = 13; +int spd_2 = 27; + +void loop() { + + goal = angle('a', 120); + spd = speed('a', spd_2); + Dxl.writeDword(ID_NUM1,600,spd); + Dxl.writeDword(ID_NUM1,GOAL_POSITION,goal); + goal = angle('b', 120); + spd = speed('b', spd_2); + Dxl.writeDword(ID_NUM2,600,spd); + Dxl.writeDword(ID_NUM2,GOAL_POSITION,goal); + goal = angle('c', 120); + spd = speed('c', spd_2); + Dxl.writeDword(ID_NUM3,600,spd); + Dxl.writeDword(ID_NUM3,GOAL_POSITION,goal); + delay(5000); + + goal = angle('a', -120); + spd = speed('a', spd_1); + Dxl.writeDword(ID_NUM1,600,spd); + Dxl.writeDword(ID_NUM1,GOAL_POSITION,goal); + goal = angle('b', -120); + spd = speed('b', spd_1); + Dxl.writeDword(ID_NUM2,600,spd); + Dxl.writeDword(ID_NUM2,GOAL_POSITION,goal); + goal = angle('c', -120); + spd = speed('c', spd_1); + Dxl.writeDword(ID_NUM3,600,spd); + Dxl.writeDword(ID_NUM3,GOAL_POSITION,goal); + delay(5000); +} + + +int angle(char model, int value_angle){ + int value = 0; + if(model == 'a'){ + value = ((value_angle * 103860) / 180); + return value; + } + else if(model == 'b'){ + value = ((value_angle * 125700) / 180); + return value; + } + else if(model == 'c'){ + value = ((value_angle * 251000) / 180); + return value; + } +} + +int speed(char model, int value_speed){ + int value = 0; + if(model == 'a'){ + return (value_speed * 290); + } + else if(model == 'b'){ + return (value_speed * 250); + } + else if(model == 'c'){ + return (value_speed * 500); + } +} + + + diff --git a/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/g_Goal_Acceleration/g_Goal_Acceleration.ino b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/g_Goal_Acceleration/g_Goal_Acceleration.ino new file mode 100644 index 000000000..c0385735f --- /dev/null +++ b/arduino/opencr_arduino/opencr/libraries/OpenCR/examples/10. 485 EXP/g_Goal_Acceleration/g_Goal_Acceleration.ino @@ -0,0 +1,140 @@ +/* Goal Acceleration + + In this example, you can see how to control goal acceleration in dxl pro. + + CM900 X + OpenCM9.04 O + + Dynamixel Compatibility + AX MX RX XL-320 Pro + CM900 X X X X O + OpenCM9.04 X X X X O + **** OpenCM 485 EXP board is needed to use 4 pin Dynamixel and Pro Series **** + + created 22 May 2014 + by ROBOTIS CO,.LTD. + */ + +#define DXL_BUS_SERIAL1 1 //Dynamixel on Serial1(USART1) <-OpenCM9.04 +#define DXL_BUS_SERIAL2 2 //Dynamixel on Serial2(USART2) <-LN101,BT210 +#define DXL_BUS_SERIAL3 3 //Dynamixel on Serial3(USART3) <-OpenCM 485EXP + +/* 485 EXP switch, LED definces for 485 EXP device */ +#define RED_485EXP 18 +#define GREEN_485EXP 19 +#define BLUE_485EXP 20 +#define BUTTON1_485EXP 16 +#define BUTTON2_485EXP 17 + +#define ID_NUM 1 +#define TORQUE_ENABLE 562 +#define GOAL_POSITION 596 +#define BAUD_RATE 8 +#define PRESENT_POSITION 611 +Dynamixel Dxl(DXL_BUS_SERIAL3); + +/* Minimum_Source*/ +int count = 0; +int ccount = 0; +int stop_flag = 0; + +void setup() { + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(3); + + pinMode(RED_485EXP, OUTPUT); + pinMode(GREEN_485EXP, OUTPUT); + pinMode(BLUE_485EXP, OUTPUT); + pinMode(BUTTON1_485EXP, INPUT); + pinMode(BUTTON2_485EXP, INPUT); + pinMode(BOARD_LED_PIN,OUTPUT); + + digitalWrite(RED_485EXP, 1); + digitalWrite(GREEN_485EXP, 1); + digitalWrite(BLUE_485EXP, 1); + + Dxl.writeByte(ID_NUM, BAUD_RATE, 1); + Dxl.writeByte(ID_NUM, BAUD_RATE, 1); + + // Dynamixel 2.0 Protocol -> 0: 9600, 1: 57600, 2: 115200, 3: 1Mbps + Dxl.begin(1); + + //p gain setting + Dxl.writeWord(ID_NUM, 594, 64); + + //Goal Position + //Dxl.writeDword(ID_NUM, GOAL_POSITION, 0); + + //Goal Accelation + Dxl.writeDword(ID_NUM, 606, 16); + delay(1000); + + + unsigned int a = 0; + while(1){ + if((int32)Dxl.readDword(1, PRESENT_POSITION) > -10000 && (int32)Dxl.readDword(1, PRESENT_POSITION) < 10000) + break; + } + toggleLED(); + + Dxl.writeByte(ID_NUM, TORQUE_ENABLE, 1); +} + +void loop() { + // put your main code here, to run repeatedly: + stop(); + stop_flag = 0; + if(digitalRead(BUTTON1_485EXP) == 1){ + delay(100); + if(digitalRead(BUTTON1_485EXP) == 1){ + delay(1000); + while(1){ + Dxl.writeDword(1, GOAL_POSITION, 62750); + + digitalWrite(GREEN_485EXP, 0); + delay(100); + while(abs((int32)Dxl.readDword(1, PRESENT_POSITION) - 62750) < 30 ){ + + stop(); + } + digitalWrite(GREEN_485EXP, 1); + + delayCount(); + if(stop_flag == 1) + break; + Dxl.writeDword(1, GOAL_POSITION, -62750); + + digitalWrite(GREEN_485EXP, 0); + delay(100); + while(abs((int32)Dxl.readDword(1, PRESENT_POSITION)- (-62750)) < 30 ){ + stop(); + } + digitalWrite(GREEN_485EXP, 1); + delayCount(); + if(stop_flag == 1) + break; + } + } + } +} + +void delayCount(){ + for(ccount = 0; ccount<30;ccount++){ + for(count = 0;count<65535;count++){ + stop(); + } + stop(); + } +} + +void stop(){ + if(digitalRead(BUTTON2_485EXP) == 1){ + delay(100); + if(digitalRead(BUTTON2_485EXP) == 1){ + delay(2000); + Dxl.writeDword(ID_NUM, GOAL_POSITION, 0); + delay(1500); + stop_flag = 1; + } + } +} \ No newline at end of file diff --git a/arduino/opencr_arduino/opencr/platform.txt b/arduino/opencr_arduino/opencr/platform.txt index a8e5045d6..9992989a5 100755 --- a/arduino/opencr_arduino/opencr/platform.txt +++ b/arduino/opencr_arduino/opencr/platform.txt @@ -20,7 +20,8 @@ compiler.warning_flags.all=-Wall -Wextra -DDEBUG_LEVEL=DEBUG_ALL # compiler variables # ---------------------- #compiler.path={runtime.tools.arm-none-eabi-gcc.path}/bin/ -compiler.path={runtime.hardware.path}/tools/gcc/bin/ +#compiler.path={runtime.hardware.path}/tools/gcc/bin/ +compiler.path={runtime.tools.opencr_gcc.path}/bin/ compiler.c.cmd=arm-none-eabi-gcc compiler.c.flags=-c -g -O2 -std=gnu99 -mfloat-abi=softfp -mfpu=fpv5-sp-d16 {compiler.warning_flags} -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -DBOARD_{build.variant} compiler.c.elf.cmd=arm-none-eabi-g++ @@ -108,10 +109,23 @@ recipe.size.regex.data=^(?:\.data|\.bss|\.noinit)\s+([0-9]+).* # ------------------- tools.opencr_ld.cmd=opencr_ld tools.opencr_ld.cmd.windows=opencr_ld.exe -tools.opencr_ld.path={runtime.hardware.path}/tools/win -tools.opencr_ld.path.macosx={runtime.hardware.path}/tools/macosx -tools.opencr_ld.path.linux={runtime.hardware.path}/tools/linux +#tools.opencr_ld.path={runtime.hardware.path}/tools/win +#tools.opencr_ld.path.macosx={runtime.hardware.path}/tools/macosx +#tools.opencr_ld.path.linux={runtime.hardware.path}/tools/linux +tools.opencr_ld.path={runtime.tools.opencr_tools.path}/win +tools.opencr_ld.path.macosx={runtime.tools.opencr_tools.path}/macosx +tools.opencr_ld.path.linux={runtime.tools.opencr_tools.path}/linux tools.opencr_ld.upload.params.verbose=-d tools.opencr_ld.upload.params.quiet=n tools.opencr_ld.upload.pattern="{path}/{cmd}" "{serial.port}" "115200" "{build.path}/{build.project_name}.bin" "1" + +tools.dfu_util.cmd=dfu-util +tools.dfu_util.cmd.windows=dfu-util.exe +tools.dfu_util.path={runtime.tools.opencr_tools.path}/win/dfu-util +tools.dfu_util.path.macosx={runtime.tools.opencr_tools.path}/macosx/dfu-util +tools.dfu_util.path.linux={runtime.tools.opencr_tools.path}/linux/dfu-util + +tools.dfu_util.bootloader.params.verbose=-v -v -v -v +tools.dfu_util.bootloader.params.quiet=-q -q +tools.dfu_tuil.bootloader.pattern="{path}/{cmd}" -d 0483:df11 -a 0 -s 0x08000000 -D "{runtime.hardware.path}/OpenCR/bootloaders/{bootloader.file}" diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/bsp/opencr/cfg/stm32f7xx_it.h b/arduino/opencr_arduino/opencr/variants/OpenCR/bsp/opencr/cfg/stm32f7xx_it.h index 026488dd8..72c1f39dd 100755 --- a/arduino/opencr_arduino/opencr/variants/OpenCR/bsp/opencr/cfg/stm32f7xx_it.h +++ b/arduino/opencr_arduino/opencr/variants/OpenCR/bsp/opencr/cfg/stm32f7xx_it.h @@ -58,8 +58,8 @@ void SVC_Handler(void); void DebugMon_Handler(void); void PendSV_Handler(void); void SysTick_Handler(void); -void USARTx_IRQHandler(void); -void EXTI15_10_IRQHandler(void); + + #ifdef __cplusplus } diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/pins_opencr.csv b/arduino/opencr_arduino/opencr/variants/OpenCR/pins_opencr.csv deleted file mode 100755 index cc5112182..000000000 --- a/arduino/opencr_arduino/opencr/variants/OpenCR/pins_opencr.csv +++ /dev/null @@ -1 +0,0 @@ -Position,Name,,Type,Signal,Label 116,PD2,0,I/O,UART5_RX, 113,PC12,1,I/O,UART5_TX, 1,PE2,2,I/O,, 2,PE3,3,I/O,, 3,PE4,4,I/O,, 4,PE5,5,I/O,, 5,PE6,6,I/O,, 7,PC13,7,I/O,, 18,PF6,8,I/O,, 29,PC3,9,I/O,, 41,PA5,10,I/O,, 87,PG2,11,I/O,, 88,PG3,12,I/O,, 128,PG13,13,Output,GPIO_Output,LD3 [Green Led] 99,PC9,14,I/O,I2C3_SDA,I2C3_SDA [ACP/RF_SDA] 100,PA8,15,I/O,I2C3_SCL,I2C3_SCL [ACP/RF_SCL] 98,PC8,16,I/O,, 112,PC11,17,I/O,, 118,PD4,18,I/O,, 119,PD5,19,I/O,, 123,PD7,20,I/O,, 124,PG9,21,I/O,, 19,PF7,22,I/O,SPI5_SCK,SPI5_SCK [L3GD20_SCL/SPC] 21,PF9,23,I/O,SPI5_MOSI,SPI5_MOSI [L3GD20_SDA/SDI/SDO] 20,PF8,24,I/O,SPI5_MISO,SPI5_MISO [L3GD20_SDO] 34,PA0/WKUP,25,I/O,GPIO_EXTI0,B1 [Blue PushButton] 8,PC14/OSC32_IN,26,I/O,RCC_OSC32_IN,PC14-OSC32_IN 9,PC15/OSC32_OUT,27,I/O,RCC_OSC32_OUT,PC15-OSC32_OUT 133,PB3,32,I/O,, 134,PB4,34,I/O,, 137,PB7,35,I/O,, 102,PA10,36,I/O,USART1_RX, 101,PA9,37,I/O,USART1_TX, 129,PG14,33,Output,GPIO_Output,LD4 [Red Led] 10,PF0,,I/O,FMC_A0,A0 11,PF1,,I/O,FMC_A1,A1 56,PG0,,I/O,FMC_A10,A10 57,PG1,,I/O,FMC_A11,A11 12,PF2,,I/O,FMC_A2,A2 13,PF3,,I/O,FMC_A3,A3 14,PF4,,I/O,FMC_A4,A4 15,PF5,,I/O,FMC_A5,A5 50,PF12,,I/O,FMC_A6,A6 53,PF13,,I/O,FMC_A7,A7 54,PF14,,I/O,FMC_A8,A8 55,PF15,,I/O,FMC_A9,A9 89,PG4,,I/O,FMC_BA0,BA0 90,PG5,,I/O,FMC_BA1,BA1 85,PD14,,I/O,FMC_D0,D0 86,PD15,,I/O,FMC_D1,D1 66,PE13,,I/O,FMC_D10,D10 67,PE14,,I/O,FMC_D11,D11 68,PE15,,I/O,FMC_D12,D12 77,PD8,,I/O,FMC_D13,D13 78,PD9,,I/O,FMC_D14,D14 79,PD10,,I/O,FMC_D15,D15 114,PD0,,I/O,FMC_D2,D2 115,PD1,,I/O,FMC_D3,D3 58,PE7,,I/O,FMC_D4,D4 59,PE8,,I/O,FMC_D5,D5 60,PE9,,I/O,FMC_D6,D6 63,PE10,,I/O,FMC_D7,D7 64,PE11,,I/O,FMC_D8,D8 65,PE12,,I/O,FMC_D9,D9 141,PE0,,I/O,FMC_NBL0,NBL0 [SDRAM_LDQM] 142,PE1,,I/O,FMC_NBL1,NBL1 [SDRAM_UDQM] 135,PB5,,I/O,FMC_SDCKE1,SDCKE1 93,PG8,,I/O,FMC_SDCLK,SDCLK 132,PG15,,I/O,FMC_SDNCAS,SDNCAS 136,PB6,,I/O,FMC_SDNE1,SDNE1 [SDRAM_CS] 49,PF11,,I/O,FMC_SDNRAS,SDNRAS 26,PC0,,I/O,FMC_SDNWE,SDNWE 35,PA1,29,I/O,GPIO_EXTI1,MEMS_INT1 [L3GD20_INT1] 110,PA15,31,I/O,GPIO_EXTI15,TP_INT1 [Touch Panel] 36,PA2,30,I/O,GPIO_EXTI2,MEMS_INT2 [L3GD20_INT2] 45,PC5,,I/O,GPIO_EXTI5,OTG_FS_OC [OTG_FS_OverCurrent] 48,PB2/BOOT1,,Input,GPIO_Input,BOOT1 80,PD11,,Input,GPIO_Input,TE [LCD-RGB_TE] 27,PC1,28,Output,GPIO_Output,NCS_MEMS_SPI [L3GD20_CS_I2C/SPI] 28,PC2,,Output,GPIO_Output,CSX [LCD-RGB_CSX] 43,PA7,,Output,GPIO_Output,ACP_RST 44,PC4,,Output,GPIO_Output,OTG_FS_PSO [OTG_FS_PowerSwitchOn] 81,PD12,,Output,GPIO_Output,RDX [LDC-RGB_RDX] 82,PD13,,Output,GPIO_Output,WRX_DCX [LCD-RGB_WRX_DCX] 122,PD6,,I/O,LTDC_B2,B2 126,PG11,,I/O,LTDC_B3,B3 127,PG12,,I/O,LTDC_B4,B4 37,PA3,,I/O,LTDC_B5,B5 139,PB8,,I/O,LTDC_B6,B6 140,PB9,,I/O,LTDC_B7,B7 92,PG7,,I/O,LTDC_CLK,DOTCLK [LCT-RGB_DOTCLK] 22,PF10,,I/O,LTDC_DE,ENABLE [LCD-RGB_ENABLE] 42,PA6,,I/O,LTDC_G2,G2 125,PG10,,I/O,LTDC_G3,G3 69,PB10,,I/O,LTDC_G4,G4 70,PB11,,I/O,LTDC_G5,G5 97,PC7,,I/O,LTDC_G6,G6 117,PD3,,I/O,LTDC_G7,G7 96,PC6,,I/O,LTDC_HSYNC,HSYNC 111,PC10,,I/O,LTDC_R2,R2 46,PB0,,I/O,LTDC_R3,R3 103,PA11,,I/O,LTDC_R4,R4 104,PA12,,I/O,LTDC_R5,R5 47,PB1,,I/O,LTDC_R6,R6 91,PG6,,I/O,LTDC_R7,R7 40,PA4,,I/O,LTDC_VSYNC,VSYNC 23,PH0/OSC_IN,,I/O,RCC_OSC_IN,PH0-OSC_IN 24,PH1/OSC_OUT,,I/O,RCC_OSC_OUT,PH1-OSC_OUT 109,PA14,,I/O,SYS_JTCK-SWCLK,SWCLK 105,PA13,,I/O,SYS_JTMS-SWDIO,SWDIO 75,PB14,,I/O,USB_OTG_HS_DM,OTG_FS_DM 76,PB15,,I/O,USB_OTG_HS_DP,OTG_FS_DP 73,PB12,,I/O,USB_OTG_HS_ID,OTG_FS_ID 74,PB13,,I/O,USB_OTG_HS_VBUS,VBUS_FS 138,BOOT0,,Boot,, 6,VBAT,,Power,, 16,VSS,,Power,, 17,VDD,,Power,, 30,VDD,,Power,, 31,VSSA,,Power,, 32,VREF+,,Power,, 33,VDDA,,Power,, 38,VSS,,Power,, 39,VDD,,Power,, 51,VSS,,Power,, 52,VDD,,Power,, 61,VSS,,Power,, 62,VDD,,Power,, 71,VCAP_1,,Power,, 72,VDD,,Power,, 83,VSS,,Power,, 84,VDD,,Power,, 94,VSS,,Power,, 95,VDD,,Power,, 106,VCAP_2,,Power,, 107,VSS,,Power,, 108,VDD,,Power,, 120,VSS,,Power,, 121,VDD,,Power,, 130,VSS,,Power,, 131,VDD,,Power,, 144,VDD,,Power,, 25,NRST,,Reset,, 143,PDR_ON,,Reset,, \ No newline at end of file diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv.c b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv.c index f9af4c88f..2abbf9d89 100755 --- a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv.c +++ b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv.c @@ -28,6 +28,8 @@ int drv_init() drv_uart_init(); drv_pwm_init(); drv_i2c_init(); + drv_exti_init(); + drv_dxl_init(); return 0; } diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv.h b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv.h index f822aafc7..1720288b5 100755 --- a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv.h +++ b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv.h @@ -19,6 +19,8 @@ #include "drv_spi.h" #include "drv_uart.h" #include "drv_i2c.h" +#include "drv_exti.h" +#include "drv_dxl.h" int drv_init(void); diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_adc.c b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_adc.c index 0753b6d8b..2886e5485 100755 --- a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_adc.c +++ b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_adc.c @@ -9,6 +9,7 @@ #include "variant.h" +ADC_HandleTypeDef hADC1; ADC_HandleTypeDef hADC3; @@ -32,10 +33,46 @@ int drv_adc_init() return -1; } + + hADC1.Instance = ADC1; + hADC1.Init.ClockPrescaler = ADC_CLOCKPRESCALER_PCLK_DIV4; + hADC1.Init.Resolution = ADC_RESOLUTION_12B; + hADC1.Init.ScanConvMode = DISABLE; + hADC1.Init.ContinuousConvMode = DISABLE; + hADC1.Init.DiscontinuousConvMode = DISABLE; + hADC1.Init.NbrOfDiscConversion = 0; + hADC1.Init.ExternalTrigConv = ADC_SOFTWARE_START; + hADC1.Init.DataAlign = ADC_DATAALIGN_RIGHT; + hADC1.Init.NbrOfConversion = 1; + hADC1.Init.DMAContinuousRequests = DISABLE; + hADC1.Init.EOCSelection = DISABLE; + + if (HAL_ADC_Init(&hADC1) != HAL_OK) + { + return -1; + } + return 0; } +void drv_adc_pin_init( uint32_t ulPin ) +{ + GPIO_InitTypeDef GPIO_InitStruct; + + + if( g_Pin2PortMapArray[ulPin].GPIOx_Port == NULL ) return; + + + HAL_GPIO_DeInit(g_Pin2PortMapArray[ulPin].GPIOx_Port, g_Pin2PortMapArray[ulPin].Pin_abstraction); + + GPIO_InitStruct.Pin = g_Pin2PortMapArray[ulPin].Pin_abstraction; + GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(g_Pin2PortMapArray[ulPin].GPIOx_Port, &GPIO_InitStruct); +} + + void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { uint8_t i; @@ -51,9 +88,16 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) { __HAL_RCC_ADC3_CLK_ENABLE(); } + if( hadc->Instance == ADC1 ) + { + __HAL_RCC_ADC1_CLK_ENABLE(); + } + + HAL_GPIO_DeInit(g_Pin2PortMapArray[i].GPIOx_Port, g_Pin2PortMapArray[i].Pin_abstraction); GPIO_InitStruct.Pin = g_Pin2PortMapArray[i].Pin_abstraction; GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; + GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(g_Pin2PortMapArray[i].GPIOx_Port, &GPIO_InitStruct); i++; @@ -74,6 +118,11 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) { __HAL_RCC_ADC3_CLK_DISABLE(); } + if( hadc->Instance == ADC1 ) + { + __HAL_RCC_ADC1_CLK_DISABLE(); + } + HAL_GPIO_DeInit(g_Pin2PortMapArray[i].GPIOx_Port, g_Pin2PortMapArray[i].Pin_abstraction); i++; diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_adc.h b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_adc.h index 196b484ba..c031065f9 100755 --- a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_adc.h +++ b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_adc.h @@ -21,13 +21,13 @@ #include "util.h" - +extern ADC_HandleTypeDef hADC1; extern ADC_HandleTypeDef hADC3; int drv_adc_init(); - +void drv_adc_pin_init( uint32_t ulPin ); #ifdef __cplusplus diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_dxl.c b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_dxl.c new file mode 100755 index 000000000..70be36f33 --- /dev/null +++ b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_dxl.c @@ -0,0 +1,36 @@ +/* + * drv_dxl.c + * + * Created on: 2016. 7. 13. + * Author: Baram, PBHP + */ + +#include "drv_dxl.h" +#include "variant.h" + + + + + +int drv_dxl_init() +{ + GPIO_InitTypeDef GPIO_InitStruct; + + + GPIO_InitStruct.Pin = GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + drv_dxl_tx_enable(FALSE); + + return 0; +} + + +void drv_dxl_tx_enable( BOOL enable ) +{ + if( enable == TRUE ) HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_SET); + else HAL_GPIO_WritePin(GPIOC, GPIO_PIN_9, GPIO_PIN_RESET); +} diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_dxl.h b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_dxl.h new file mode 100755 index 000000000..d0376a8ee --- /dev/null +++ b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_dxl.h @@ -0,0 +1,39 @@ +/* + * drv_dxl.h + * + * Created on: 2016. 7.23. + * Author: Baram, PBHP + */ + +#ifndef DRV_DXL_H +#define DRV_DXL_H + + +#ifdef __cplusplus + extern "C" { +#endif + + +#include "def.h" +#include "bsp.h" + + +#include "util.h" + + + + + + +int drv_dxl_init(); + +void drv_dxl_tx_enable( BOOL enable ); + + +#ifdef __cplusplus +} +#endif + + +#endif + diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_exti.c b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_exti.c new file mode 100755 index 000000000..b2ddf7e3e --- /dev/null +++ b/arduino/opencr_arduino/opencr/variants/OpenCR/src/drv_exti.c @@ -0,0 +1,286 @@ +/* + * drv_exti.c + * + * Created on: 2016. 7. 13. + * Author: Baram, PBHP + */ + +#include "drv_exti.h" +#include "variant.h" + + + +typedef struct +{ + uint8_t exti_enable; + uint16_t pin_channel; + uint16_t pin_number; + void (*exti_callback)(void); +} exti_data_t; + + +volatile exti_data_t exti_data[EXTI_COUNT]; + + +int drv_exti_init() +{ + uint32_t i; + + for( i=0; i= EXTI_COUNT ) return; + + ulPin = exti_data[int_num].pin_number; + + if( g_Pin2PortMapArray[ulPin].extiChannel == NO_EXTI ) return; + + exti_data[ g_Pin2PortMapArray[ulPin].extiChannel ].exti_enable = 1; + exti_data[ g_Pin2PortMapArray[ulPin].extiChannel ].pin_channel = g_Pin2PortMapArray[ulPin].Pin_abstraction; + exti_data[ g_Pin2PortMapArray[ulPin].extiChannel ].exti_callback = callback; + + + switch( mode ) + { + case CHANGE: + GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING_FALLING; + break; + + case FALLING: + GPIO_InitStructure.Mode = GPIO_MODE_IT_FALLING; + break; + + case RISING: + GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING; + break; + + default: + GPIO_InitStructure.Mode = GPIO_MODE_IT_RISING_FALLING; + return; + } + + + //GPIO_InitStructure.Pull = GPIO_NOPULL; + GPIO_InitStructure.Pin = g_Pin2PortMapArray[ulPin].Pin_abstraction; + HAL_GPIO_Init(g_Pin2PortMapArray[ulPin].GPIOx_Port, &GPIO_InitStructure); + + + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_0 ) + { + HAL_NVIC_SetPriority(EXTI0_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(EXTI0_IRQn); + } + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_1 ) + { + HAL_NVIC_SetPriority(EXTI1_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(EXTI1_IRQn); + } + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_2 ) + { + HAL_NVIC_SetPriority(EXTI2_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(EXTI2_IRQn); + } + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_3 ) + { + HAL_NVIC_SetPriority(EXTI3_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(EXTI3_IRQn); + } + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_4 ) + { + HAL_NVIC_SetPriority(EXTI4_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(EXTI4_IRQn); + } + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_5 + || g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_6 + || g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_7 + || g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_8 + || g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_9 ) + { + HAL_NVIC_SetPriority(EXTI9_5_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); + } + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_10 + || g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_11 + || g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_12 + || g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_13 + || g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_14 + || g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_15 ) + { + HAL_NVIC_SetPriority(EXTI15_10_IRQn, 2, 0); + HAL_NVIC_EnableIRQ(EXTI15_10_IRQn); + } +} + + +void drv_exti_detach( uint32_t int_num ) +{ + uint32_t i; + uint32_t ulPin; + GPIO_InitTypeDef GPIO_InitStructure; + + + if( int_num >= EXTI_COUNT ) return; + + ulPin = exti_data[int_num].pin_number; + + + if( g_Pin2PortMapArray[ulPin].extiChannel == NO_EXTI ) return; + + exti_data[ g_Pin2PortMapArray[ulPin].extiChannel ].exti_enable = 0; + exti_data[ g_Pin2PortMapArray[ulPin].extiChannel ].exti_callback = NULL; + + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_0 ) + { + HAL_NVIC_DisableIRQ(EXTI0_IRQn); + } + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_1 ) + { + HAL_NVIC_DisableIRQ(EXTI1_IRQn); + } + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_2 ) + { + HAL_NVIC_DisableIRQ(EXTI2_IRQn); + } + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_3 ) + { + HAL_NVIC_DisableIRQ(EXTI3_IRQn); + } + + if( g_Pin2PortMapArray[ulPin].Pin_abstraction == GPIO_PIN_4 ) + { + HAL_NVIC_DisableIRQ(EXTI4_IRQn); + } + + for( i=0; iInstance == USART6 ) Tx1_Handler(); if( UartHandle->Instance == USART2 ) Tx2_Handler(); + if( UartHandle->Instance == USART3 ) Tx3_Handler(); } @@ -55,6 +54,7 @@ void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle) if( UartHandle->Instance == USART6 ) Rx1_Handler(); if( UartHandle->Instance == USART2 ) Rx2_Handler(); + if( UartHandle->Instance == USART3 ) Rx3_Handler(); } @@ -107,6 +107,28 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart) HAL_NVIC_SetPriority(USART6_IRQn, 0, 0); HAL_NVIC_EnableIRQ (USART6_IRQn); } + else if(huart->Instance==USART3) + { + + /* Peripheral clock enable */ + __HAL_RCC_USART3_CLK_ENABLE(); + + GPIO_InitStruct.Pin = GPIO_PIN_10; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF7_USART3; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + + GPIO_InitStruct.Pin = GPIO_PIN_11; + GPIO_InitStruct.Alternate = GPIO_AF7_USART3; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* Peripheral interrupt init */ + HAL_NVIC_SetPriority(USART3_IRQn, 0, 0); + HAL_NVIC_EnableIRQ (USART3_IRQn); + } } @@ -143,4 +165,19 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart) /* Peripheral interrupt Deinit*/ HAL_NVIC_DisableIRQ(USART6_IRQn); } + else if(huart->Instance==USART3) + { + __USART3_FORCE_RESET(); + __USART3_RELEASE_RESET(); + + /* Peripheral clock disable */ + __HAL_RCC_USART3_CLK_DISABLE(); + + + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_10); + HAL_GPIO_DeInit(GPIOC, GPIO_PIN_11); + + /* Peripheral interrupt Deinit*/ + HAL_NVIC_DisableIRQ(USART3_IRQn); + } } diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/variant.cpp b/arduino/opencr_arduino/opencr/variants/OpenCR/variant.cpp index c146151ae..2563bac93 100755 --- a/arduino/opencr_arduino/opencr/variants/OpenCR/variant.cpp +++ b/arduino/opencr_arduino/opencr/variants/OpenCR/variant.cpp @@ -33,40 +33,46 @@ extern "C" { extern const Pin2PortMapArray g_Pin2PortMapArray[]= { - {GPIOC, GPIO_PIN_7, NULL, NO_ADC , NULL , NO_PWM }, // 0 UART6_RX - {GPIOC, GPIO_PIN_6, NULL, NO_ADC , NULL , NO_PWM }, // 1 UART6_TX - {GPIOG, GPIO_PIN_6, NULL, NO_ADC , NULL , NO_PWM }, // 2 - {GPIOB, GPIO_PIN_4, NULL, NO_ADC , &hTIM3 , TIM_CHANNEL_1 }, // 3 TIM3_CH1 - {GPIOG, GPIO_PIN_7, NULL, NO_ADC , NULL , NO_PWM }, // 4 - {GPIOA, GPIO_PIN_8, NULL, NO_ADC , &hTIM1 , TIM_CHANNEL_1 }, // 5 TIM1_CH1 - {GPIOA, GPIO_PIN_2, NULL, NO_ADC , &hTIM2 , TIM_CHANNEL_3 }, // 6 TIM2_CH3 - {GPIOC, GPIO_PIN_1, NULL, NO_ADC , NULL , NO_PWM }, // 7 - {GPIOC, GPIO_PIN_2, NULL, NO_ADC , NULL , NO_PWM }, // 8 - {GPIOA, GPIO_PIN_3, NULL, NO_ADC , &hTIM9 , TIM_CHANNEL_2 }, // 9 TIM9_CH2 - {GPIOB, GPIO_PIN_9, NULL, NO_ADC , &hTIM11, TIM_CHANNEL_1 }, // 10 TIM11_CH1 SPI2_NSS - {GPIOB, GPIO_PIN_15, NULL, NO_ADC , &hTIM12, TIM_CHANNEL_2 }, // 11 TIM12_CH2 SPI2_MOSI - {GPIOB, GPIO_PIN_14, NULL, NO_ADC , NULL , NO_PWM }, // 12 SPI2_MISO - {GPIOA, GPIO_PIN_9, NULL, NO_ADC , NULL , NO_PWM }, // 13 LED SPI2_SCK - {GPIOB, GPIO_PIN_7, NULL, NO_ADC , NULL , NO_PWM }, // 14 I2C1_SDA - {GPIOB, GPIO_PIN_8, NULL, NO_ADC , NULL , NO_PWM }, // 15 I2C1_SCL - - {GPIOA, GPIO_PIN_0, &hADC3, ADC_CHANNEL_0, NULL , NO_PWM }, // 16 A0 - {GPIOF, GPIO_PIN_10, &hADC3, ADC_CHANNEL_8, NULL , NO_PWM }, // 17 A1 - {GPIOF, GPIO_PIN_9, &hADC3, ADC_CHANNEL_7, NULL , NO_PWM }, // 18 A2 - {GPIOF, GPIO_PIN_8, &hADC3, ADC_CHANNEL_6, NULL , NO_PWM }, // 19 A3 - {GPIOF, GPIO_PIN_7, &hADC3, ADC_CHANNEL_5, NULL , NO_PWM }, // 20 A4 - {GPIOF, GPIO_PIN_6, &hADC3, ADC_CHANNEL_4, NULL , NO_PWM }, // 21 A5 - - {GPIOB, GPIO_PIN_10, NULL, NO_ADC , NULL , NO_PWM }, // 22 TEST_PIN_1 - {GPIOB, GPIO_PIN_11, NULL, NO_ADC , NULL , NO_PWM }, // 23 TEST_PIN_2 - {GPIOC, GPIO_PIN_13, NULL, NO_ADC , NULL , NO_PWM }, // 24 TEST_PIN_3 - {GPIOD, GPIO_PIN_2, NULL, NO_ADC , NULL , NO_PWM }, // 25 TEST_PIN_4 - {GPIOE, GPIO_PIN_3, NULL, NO_ADC , NULL , NO_PWM }, // 26 TEST_PIN_5 - {GPIOG, GPIO_PIN_2, NULL, NO_ADC , NULL , NO_PWM }, // 27 TEST_PIN_6 - {GPIOA, GPIO_PIN_4, NULL, NO_ADC , NULL , NO_PWM }, // 28 MPU CS - {GPIOC, GPIO_PIN_14, NULL, NO_ADC , NULL , NO_PWM }, - {GPIOC, GPIO_PIN_15, NULL, NO_ADC , NULL , NO_PWM }, - {NULL , 0 , NULL, NO_ADC , NULL , NO_PWM } + {GPIOC, GPIO_PIN_7, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 0 UART6_RX + {GPIOC, GPIO_PIN_6, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 1 UART6_TX + {GPIOG, GPIO_PIN_6, NULL, NO_ADC , NULL , NO_PWM , 0 }, // 2 EXTI_0 + {GPIOB, GPIO_PIN_4, NULL, NO_ADC , &hTIM3 , TIM_CHANNEL_1, 1 }, // 3 TIM3_CH1 EXTI_1 + {GPIOG, GPIO_PIN_7, NULL, NO_ADC , NULL , NO_PWM , 2 }, // 4 EXTI_2 + {GPIOA, GPIO_PIN_8, NULL, NO_ADC , &hTIM1 , TIM_CHANNEL_1, NO_EXTI }, // 5 TIM1_CH1 + {GPIOA, GPIO_PIN_2, NULL, NO_ADC , &hTIM2 , TIM_CHANNEL_3, NO_EXTI }, // 6 TIM2_CH3 + {GPIOC, GPIO_PIN_1, NULL, NO_ADC , NULL , NO_PWM , 3 }, // 7 EXTI_3 + {GPIOC, GPIO_PIN_2, NULL, NO_ADC , NULL , NO_PWM , 4 }, // 8 EXTI_4 + {GPIOA, GPIO_PIN_3, NULL, NO_ADC , &hTIM9 , TIM_CHANNEL_2, NO_EXTI }, // 9 TIM9_CH2 + {GPIOB, GPIO_PIN_9, NULL, NO_ADC , &hTIM11, TIM_CHANNEL_1, NO_EXTI }, // 10 TIM11_CH1 SPI2_NSS + {GPIOB, GPIO_PIN_15, NULL, NO_ADC , &hTIM12, TIM_CHANNEL_2, NO_EXTI }, // 11 TIM12_CH2 SPI2_MOSI + {GPIOB, GPIO_PIN_14, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 12 SPI2_MISO + {GPIOA, GPIO_PIN_9, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 13 LED SPI2_SCK + {GPIOB, GPIO_PIN_7, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 14 I2C1_SDA + {GPIOB, GPIO_PIN_8, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 15 I2C1_SCL + + {GPIOA, GPIO_PIN_0, &hADC3, ADC_CHANNEL_0 , NULL , NO_PWM , NO_EXTI }, // 16 A0 + {GPIOF, GPIO_PIN_10, &hADC3, ADC_CHANNEL_8 , NULL , NO_PWM , NO_EXTI }, // 17 A1 + {GPIOF, GPIO_PIN_9, &hADC3, ADC_CHANNEL_7 , NULL , NO_PWM , NO_EXTI }, // 18 A2 + {GPIOF, GPIO_PIN_8, &hADC3, ADC_CHANNEL_6 , NULL , NO_PWM , NO_EXTI }, // 19 A3 + {GPIOF, GPIO_PIN_7, &hADC3, ADC_CHANNEL_5 , NULL , NO_PWM , NO_EXTI }, // 20 A4 + {GPIOF, GPIO_PIN_6, &hADC3, ADC_CHANNEL_4 , NULL , NO_PWM , NO_EXTI }, // 21 A5 + + {GPIOB, GPIO_PIN_10, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 22 TEST_PIN_1 + {GPIOB, GPIO_PIN_11, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 23 TEST_PIN_2 + {GPIOC, GPIO_PIN_13, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 24 TEST_PIN_3 + {GPIOD, GPIO_PIN_2, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 25 TEST_PIN_4 + {GPIOE, GPIO_PIN_3, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 26 TEST_PIN_5 + {GPIOG, GPIO_PIN_2, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 27 TEST_PIN_6 + {GPIOA, GPIO_PIN_4, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 28 MPU CS + {GPIOC, GPIO_PIN_0, &hADC3, ADC_CHANNEL_10, NULL , NO_PWM , NO_EXTI }, // 29 BAT + + {GPIOB, GPIO_PIN_0, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 30 OLLO_P1_SIG1 + {GPIOC, GPIO_PIN_8, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 31 OLLO_P1_SIG2 + {GPIOA, GPIO_PIN_7, &hADC1, ADC_CHANNEL_7 , NULL , NO_PWM , 5 }, // 32 OLLO_P1_ADC EXTI_5 + {GPIOC, GPIO_PIN_5, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 33 OLLO_P2_SIG1 + {GPIOB, GPIO_PIN_1, NULL, NO_ADC , NULL , NO_PWM , NO_EXTI }, // 34 OLLO_P2_SIG2 + {GPIOC, GPIO_PIN_4, &hADC1, ADC_CHANNEL_14, NULL , NO_PWM , 6 }, // 35 OLLO_P2_ADC EXTI_6 + {NULL , 0 , NULL, NO_ADC , NULL , NO_PWM , NO_EXTI } }; @@ -89,14 +95,19 @@ void serialEvent1() { } void serialEvent2() __attribute__((weak)); void serialEvent2() { } +void serialEvent3() __attribute__((weak)); +void serialEvent3() { } UARTClass Serial1(&huart1, USART6_IRQn, 0, USART6); UARTClass Serial2(&huart2, USART2_IRQn, 1, USART2); +UARTClass Serial3(&huart3, USART3_IRQn, 2, USART3); void Tx1_Handler(void){ Serial1.TxHandler(); } void Rx1_Handler(void){ Serial1.RxHandler(); } void Tx2_Handler(void){ Serial2.TxHandler(); } void Rx2_Handler(void){ Serial2.RxHandler(); } +void Tx3_Handler(void){ Serial3.TxHandler(); } +void Rx3_Handler(void){ Serial3.RxHandler(); } @@ -106,6 +117,7 @@ void serialEventRun(void) if (Serial.available()) serialEvent(); if (Serial1.available()) serialEvent1(); if (Serial2.available()) serialEvent2(); + if (Serial3.available()) serialEvent3(); } USBSerial Serial; diff --git a/arduino/opencr_arduino/opencr/variants/OpenCR/variant.h b/arduino/opencr_arduino/opencr/variants/OpenCR/variant.h index f1622f933..86f4e5c3f 100755 --- a/arduino/opencr_arduino/opencr/variants/OpenCR/variant.h +++ b/arduino/opencr_arduino/opencr/variants/OpenCR/variant.h @@ -21,7 +21,7 @@ #define NO_ADC 0xffff #define NO_PWM 0xffff - +#define NO_EXTI 0xffff /*---------------------------------------------------------------------------- @@ -42,7 +42,7 @@ extern "C"{ extern UART_HandleTypeDef huart1; extern UART_HandleTypeDef huart2; - +extern UART_HandleTypeDef huart3; @@ -55,6 +55,7 @@ static const uint8_t A2 = 18; static const uint8_t A3 = 19; static const uint8_t A4 = 20; static const uint8_t A5 = 21; +static const uint8_t BAT = 29; @@ -69,6 +70,7 @@ typedef struct _Pin2PortMapArray TIM_HandleTypeDef *TIMx; uint32_t timerChannel; + uint32_t extiChannel; } Pin2PortMapArray ; @@ -78,6 +80,8 @@ void Rx1_Handler(void); void Tx1_Handler(void); void Rx2_Handler(void); void Tx2_Handler(void); +void Rx3_Handler(void); +void Tx3_Handler(void); #ifdef __cplusplus } @@ -93,32 +97,19 @@ void Tx2_Handler(void); extern USBSerial Serial; extern UARTClass Serial1; extern UARTClass Serial2; +extern UARTClass Serial3; #endif -#define SERIAL_PORT_MONITOR Serial -#define SERIAL_PORT_USBVIRTUAL SerialUSB -#define SERIAL_PORT_HARDWARE_OPEN Serial1 -#define SERIAL_PORT_HARDWARE_OPEN1 Serial2 -#define SERIAL_PORT_HARDWARE_OPEN2 Serial3 -#define SERIAL_PORT_HARDWARE Serial -#define SERIAL_PORT_HARDWARE1 Serial1 -#define SERIAL_PORT_HARDWARE2 Serial2 -#define WIRE_INTERFACES_COUNT 1 -#define PIN_WIRE_SDA (PB7) -#define PIN_WIRE_SCL (PB8) -#define WIRE_INTERFACE hi2c1 -#define WIRE_INTERFACE_ID I2C2 - -#define PIN_WIRE1_SDA (PB11) -#define PIN_WIRE1_SCL (PB10) -#define WIRE1_INTERFACE hi2c2 -#define WIRE1_INTERFACE_ID I2C2 +#define digitalPinToInterrupt(P) ( g_Pin2PortMapArray[P].extiChannel ) +#define WIRE_INTERFACES_COUNT 1 #define SPI_INTERFACES_COUNT 2 +#define EXTI_COUNT 7 +#define PINS_COUNT 64 #endif diff --git a/arduino/opencr_arduino/tools/linux/45-maple.rules b/arduino/opencr_arduino/tools/linux/45-maple.rules deleted file mode 100755 index d1bda5fb1..000000000 --- a/arduino/opencr_arduino/tools/linux/45-maple.rules +++ /dev/null @@ -1,5 +0,0 @@ -ATTRS{idProduct}=="1001", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev" -ATTRS{idProduct}=="1002", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev" -ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple" -ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple" - diff --git a/arduino/opencr_arduino/tools/linux/49-stlinkv1.rules b/arduino/opencr_arduino/tools/linux/49-stlinkv1.rules deleted file mode 100755 index d474d6a40..000000000 --- a/arduino/opencr_arduino/tools/linux/49-stlinkv1.rules +++ /dev/null @@ -1,11 +0,0 @@ -# stm32 discovery boards, with onboard st/linkv1 -# ie, STM32VL - -SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3744", \ - MODE:="0666", \ - SYMLINK+="stlinkv1_%n" - -# If you share your linux system with other users, or just don't like the -# idea of write permission for everybody, you can replace MODE:="0666" with -# OWNER:="yourusername" to create the device owned by you, or with -# GROUP:="somegroupname" and mange access using standard unix groups. diff --git a/arduino/opencr_arduino/tools/linux/49-stlinkv2-1.rules b/arduino/opencr_arduino/tools/linux/49-stlinkv2-1.rules deleted file mode 100755 index a5a79b91c..000000000 --- a/arduino/opencr_arduino/tools/linux/49-stlinkv2-1.rules +++ /dev/null @@ -1,12 +0,0 @@ -# stm32 nucleo boards, with onboard st/linkv2-1 -# ie, STM32F0, STM32F4. -# STM32VL has st/linkv1, which is quite different - -SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \ - MODE:="0666", \ - SYMLINK+="stlinkv2-1_%n" - -# If you share your linux system with other users, or just don't like the -# idea of write permission for everybody, you can replace MODE:="0666" with -# OWNER:="yourusername" to create the device owned by you, or with -# GROUP:="somegroupname" and mange access using standard unix groups. diff --git a/arduino/opencr_arduino/tools/linux/49-stlinkv2.rules b/arduino/opencr_arduino/tools/linux/49-stlinkv2.rules deleted file mode 100755 index a11215c57..000000000 --- a/arduino/opencr_arduino/tools/linux/49-stlinkv2.rules +++ /dev/null @@ -1,12 +0,0 @@ -# stm32 discovery boards, with onboard st/linkv2 -# ie, STM32L, STM32F4. -# STM32VL has st/linkv1, which is quite different - -SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", \ - MODE:="0666", \ - SYMLINK+="stlinkv2_%n" - -# If you share your linux system with other users, or just don't like the -# idea of write permission for everybody, you can replace MODE:="0666" with -# OWNER:="yourusername" to create the device owned by you, or with -# GROUP:="somegroupname" and mange access using standard unix groups. diff --git a/arduino/opencr_arduino/tools/linux/install.sh b/arduino/opencr_arduino/tools/linux/install.sh deleted file mode 100755 index 29ddb2f22..000000000 --- a/arduino/opencr_arduino/tools/linux/install.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -if sudo [ -w /etc/udev/rules.d ]; then - echo "Copying Maple-specific udev rules..." - sudo cp -v 45-maple.rules /etc/udev/rules.d/45-maple.rules - sudo chown root:root /etc/udev/rules.d/45-maple.rules - sudo chmod 644 /etc/udev/rules.d/45-maple.rules - sudo cp -v 49-stlinkv1.rules /etc/udev/rules.d/49-stlinkv1.rules - sudo chown root:root /etc/udev/rules.d/49-stlinkv1.rules - sudo chmod 644 /etc/udev/rules.d/49-stlinkv1.rules - sudo cp -v 49-stlinkv2.rules /etc/udev/rules.d/49-stlinkv2.rules - sudo chown root:root /etc/udev/rules.d/49-stlinkv2.rules - sudo chmod 644 /etc/udev/rules.d/49-stlinkv2.rules - sudo cp -v 49-stlinkv2-1.rules /etc/udev/rules.d/49-stlinkv2-1.rules - sudo chown root:root /etc/udev/rules.d/49-stlinkv2-1.rules - sudo chmod 644 /etc/udev/rules.d/49-stlinkv2-1.rules - echo "Reloading udev rules" - sudo udevadm control --reload-rules - echo "Adding current user to dialout group" - sudo adduser $USER dialout -else - echo "Couldn't copy to /etc/udev/rules.d/; you probably have to run this script as root? Or your distribution of Linux doesn't include udev; try running the IDE itself as root." -fi - diff --git a/arduino/opencr_arduino/tools/linux/maple_upload b/arduino/opencr_arduino/tools/linux/maple_upload deleted file mode 100755 index e799f3a90..000000000 --- a/arduino/opencr_arduino/tools/linux/maple_upload +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -#set -e - - - -if [ $# -lt 4 ]; then - echo "Usage: $0 $# " >&2 - exit 1 -fi -dummy_port="$1"; altID="$2"; usbID="$3"; binfile="$4"; dummy_port_fullpath="/dev/$1" -if [ $# -eq 5 ]; then - dfuse_addr="--dfuse-address $5" -else - dfuse_addr="" -fi - - -# Get the directory where the script is running. -DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) - -# ----------------- IMPORTANT ----------------- -# The 2nd parameter to upload-reset is the delay after resetting before it exits -# This value is in milliseonds -# You may need to tune this to your system -# 750ms to 1500ms seems to work on my Mac - - -"${DIR}/upload-reset" ${dummy_port_fullpath} 750 - - -#DFU_UTIL=$(dirname $0)/dfu-util/dfu-util -DFU_UTIL=/usr/bin/dfu-util -DFU_UTIL=${DIR}/dfu-util/dfu-util -if [ ! -x "${DFU_UTIL}" ]; then - echo "$0: error: cannot find ${DFU_UTIL}" >&2 - exit 2 -fi - -"${DFU_UTIL}" -d ${usbID} -a ${altID} -D ${binfile} ${dfuse_addr} -R diff --git a/arduino/opencr_arduino/tools/linux/readme.txt b/arduino/opencr_arduino/tools/linux/readme.txt deleted file mode 100755 index 2d13beb3c..000000000 --- a/arduino/opencr_arduino/tools/linux/readme.txt +++ /dev/null @@ -1 +0,0 @@ -The maple upload script needs its rights to be set to 755 \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/linux/serial_upload b/arduino/opencr_arduino/tools/linux/serial_upload deleted file mode 100755 index 05d17c6e5..000000000 --- a/arduino/opencr_arduino/tools/linux/serial_upload +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -$(dirname $0)/stm32flash/stm32flash -g 0x8000000 -b 230400 -w "$4" /dev/"$1" diff --git a/arduino/opencr_arduino/tools/linux/src/build_dfu-util.sh b/arduino/opencr_arduino/tools/linux/src/build_dfu-util.sh deleted file mode 100755 index 3563f576c..000000000 --- a/arduino/opencr_arduino/tools/linux/src/build_dfu-util.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -sudo apt-get build-dep dfu-util -sudo apt-get install build-essentials -sudo apt-get install libusb-1.0-0-dev -sudo apt-get install autoconf automake autotools-dev - -cd dfu-util -./autogen.sh -./configure -make -cp src/dfu-util ../../linux/dfu-util -cp src/dfu-suffix ../../linux/dfu-util -cp src/dfu-prefix ../../linux/dfu-util - diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/AUTHORS b/arduino/opencr_arduino/tools/linux/src/dfu-util/AUTHORS deleted file mode 100755 index 1b36c739c..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/AUTHORS +++ /dev/null @@ -1,30 +0,0 @@ -Authors ordered by first contribution. - -Harald Welte -Werner Almesberger -Michael Lauer -Jim Huang -Stefan Schmidt -Daniel Willmann -Mike Frysinger -Uwe Hermann -C. Scott Ananian -Bernard Blackham -Holger Freyther -Marc Singer -James Perkins -Tommi Keisala -Pascal Schweizer -Bradley Scott -Uwe Bonnes -Andrey Smirnov -Jussi Timperi -Hans Petter Selasky -Bo Shen -Henrique de Almeida Mendonca -Bernd Krumboeck -Dennis Meier -Veli-Pekka Peltola -Dave Hylands -Michael Grzeschik -Paul Fertser diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/COPYING b/arduino/opencr_arduino/tools/linux/src/dfu-util/COPYING deleted file mode 100755 index d60c31a97..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/ChangeLog b/arduino/opencr_arduino/tools/linux/src/dfu-util/ChangeLog deleted file mode 100755 index 37f1addba..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/ChangeLog +++ /dev/null @@ -1,93 +0,0 @@ -0.8: - o New, separate dfu-prefix tool (Uwe Bonnes) - o Allow filtering on serial number (Uwe Bonnes) - o Improved VID/PID/serial filtering (Bradley Scott) - o Support reading firmware from stdin (Tormod Volden) - o Warn if missing DFU suffix (Tormod Volden) - o Improved progress bar (Hans Petter Selasky) - o Fix dfuse leave option (Uwe Bonnes) - o Major code rework (Hans Petter Selasky) - o MS Visual Studio build support (Henrique Mendonca) - o dfuse-pack.py tool for .dfu files (Antonio Galeo) - o Many other fixes from many people - -2014-09-13: Tormod Volden - -0.7: - o Support for TI Stellaris devices (Tommi Keisala) - o Fix libusb detection on MacOSX (Marc Singer) - o Fix libusb detection on FreeBSD (Tormod Volden) - o Improved DfuSe support (Tormod Volden) - o Support all special commands (leave, unprotect, mass-erase) - o Arbitrary upload lengths - o "force" option for various possible (dangerous) overrides - -2012-10-07: Tormod Volden - -0.6: - o Add detach mode (Stefan Schmidt) - o Check return value on all libusb calls (Tormod Volden) - o Fix segmentation fault with -s option (Tormod Volden) - o Add DFU suffix manipulation tool (Stefan Schmidt) - o Port to Windows: (Tormod Volden, some parts based on work from Satz - Klauer) - o Port file handling to stdio streams - o Sleep() macros - o C99 types - o Pack structs - o Detect DfuSe device correctly on big-endian architectures (Tormod - Volden) - o Add dfuse progress indication on download (Tormod Volden) - o Cleanup: gcc pedantic, gcc extension, ... (Tormod Volden) - o Rely on page size from functional descriptor. Please report if you get - an error about it. (Tormod Volden) - o Add quirk for Maple since it reports wrong DFU version (Tormod Volden) - -2012-04-22: Stefan Schmidt - -0.5: - o DfuSe extension support for ST devices (Tormod Volden) - o Add initial support for bitWillDetach flag from DFU 1.1 (Tormod - Volden) - o Internal cleanup and some manual page fixes (Tormod Volden) - -2011-11-02: Stefan Schmidt - -0.4: - o Rework to use libusb-1.0 (Stefan Schmidt) - o DFU suffix support (Tormod Volden, Stefan Schmidt) - o Sspeed up DFU downloads directly into memory (Bernard Blackham) - o More flexible -d vid:pid parsing (Tormod Volden) - o Many bug fixes and cleanups - -2011-07-20: Stefan Schmidt - -0.3: - o quirks: Add OpenOCD to the poll timeout quirk table. - -2010-12-22: Stefan Schmidt - -0.2: - o Fix some typos on the website and the README (Antonio Ospite, Uwe - Hermann) - o Remove build rule for a static binary. We can use autotools for this. - (Mike Frysinger) - o Fix infinite loop in download error path (C. Scott Ananian) - o Break out to show the 'finished' in upload (C. Scott Ananian) - o Add GPLv2+ headers (Harald Welte) - o Remove dead code (commands.[ch]) remnescent of dfu-programmer (Harald - Welte) - o Simple quirk system with Openmoko quirk for missing bwPollTimeout (Tormod Volden) - o New default (1024) and clamping of transfer size (Tormod Volden) - o Verify sending of completion packet (Tormod Volden) - o Look for DFU functional descriptor among all descriptors (Tormod - Volden) - o Print out in which direction we are transferring data - o Abort in upload if the file already exists - -2010-11-17 Stefan Schmidt - -0.1: - Initial release - -2010-05-23 Stefan Schmidt diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/DEVICES.txt b/arduino/opencr_arduino/tools/linux/src/dfu-util/DEVICES.txt deleted file mode 100755 index bdd9f1f2e..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/DEVICES.txt +++ /dev/null @@ -1,20 +0,0 @@ -List of supported software and hardware products: - -Software user (bootloader, etc) -------------------------------- -- Sam7DFU: http://www.openpcd.org/Sam7dfu -- U-boot: DFU patches -- Barebox: http://www.barebox.org/ -- Leaflabs: http://code.google.com/p/leaflabs/ -- Blackmagic DFU - -Products using DFU ------------------- -- OpenPCD (sam7dfu) -- Openmoko Neo 1973 and Freerunner (u-boot with DFU patches) -- Leaflabs Maple -- ATUSB from Qi Hardware -- STM32F105/7, STM32F2/F3/F4 in System Bootloader -- Blackmagic debug probe -- NXP LPC31xx/LPC43XX, e.g. LPC-Link and LPC-Link2, need binaries - with LPC prefix and encoding (LPC-Link) diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/Makefile.am b/arduino/opencr_arduino/tools/linux/src/dfu-util/Makefile.am deleted file mode 100755 index 641dda58a..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = src doc - -EXTRA_DIST = autogen.sh TODO DEVICES.txt dfuse-pack.py diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/README b/arduino/opencr_arduino/tools/linux/src/dfu-util/README deleted file mode 100755 index 0f8f2621a..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/README +++ /dev/null @@ -1,20 +0,0 @@ -Dfu-util - Device Firmware Upgrade Utilities - -Dfu-util is the host side implementation of the DFU 1.0 [1] and DFU 1.1 [2] -specification of the USB forum. - -DFU is intended to download and upload firmware to devices connected over -USB. It ranges from small devices like micro-controller boards up to mobile -phones. With dfu-util you are able to download firmware to your device or -upload firmware from it. - -dfu-util has been tested with Openmoko Neo1973 and Freerunner and many -other devices. - -[1] DFU 1.0 spec: http://www.usb.org/developers/devclass_docs/usbdfu10.pdf -[2] DFU 1.1 spec: http://www.usb.org/developers/devclass_docs/DFU_1.1.pdf - -The official website is: - - http://dfu-util.gnumonks.org/ - diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/TODO b/arduino/opencr_arduino/tools/linux/src/dfu-util/TODO deleted file mode 100755 index 900c30c29..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/TODO +++ /dev/null @@ -1,14 +0,0 @@ -DfuSe: -- Do erase and write in two separate passes when downloading -- Skip "Set Address" command when downloading contiguous blocks -- Implement "Get Commands" command - -Devices: -- Research iPhone/iPod/iPad support - Heavily modified dfu-util fork here: - https://github.com/planetbeing/xpwn/tree/master/dfu-util -- Test against Niftylights - -Non-Code: -- Logo -- Re-License as LGPL for usage as library? diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/autogen.sh b/arduino/opencr_arduino/tools/linux/src/dfu-util/autogen.sh deleted file mode 100755 index e67aed39a..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/autogen.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -autoreconf -v -i diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/configure.ac b/arduino/opencr_arduino/tools/linux/src/dfu-util/configure.ac deleted file mode 100755 index 86221143f..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/configure.ac +++ /dev/null @@ -1,41 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59) -AC_INIT([dfu-util],[0.8],[dfu-util@lists.gnumonks.org],,[http://dfu-util.gnumonks.org]) -AC_CONFIG_AUX_DIR(m4) -AM_INIT_AUTOMAKE([foreign]) -AC_CONFIG_HEADERS([config.h]) - -# Test for new silent rules and enable only if they are available -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -# Checks for programs. -AC_PROG_CC - -# Checks for libraries. -# On FreeBSD the libusb-1.0 is called libusb and resides in system location -AC_CHECK_LIB([usb], [libusb_init],, [native_libusb=no],) -AS_IF([test x$native_libusb = xno], [ - PKG_CHECK_MODULES([USB], [libusb-1.0 >= 1.0.0],, - AC_MSG_ERROR([*** Required libusb-1.0 >= 1.0.0 not installed ***])) -]) -AC_CHECK_LIB([usbpath],[usb_path2devnum],,,-lusb) - -LIBS="$LIBS $USB_LIBS" -CFLAGS="$CFLAGS $USB_CFLAGS" - -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([usbpath.h windows.h sysexits.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_TYPE_SIZE_T - -# Checks for library functions. -AC_FUNC_MEMCMP -AC_CHECK_FUNCS([ftruncate getpagesize nanosleep err]) - -AC_CONFIG_FILES(Makefile src/Makefile doc/Makefile) -AC_OUTPUT diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/README b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/README deleted file mode 100755 index 00d3d1a96..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/README +++ /dev/null @@ -1,77 +0,0 @@ -Device: -------- -qi-hardware-atusb: -- Qi Hardware ben-wpan -- DFU implementation: - http://projects.qi-hardware.com/index.php/p/ben-wpan/source/tree/master/atusb/fw/usb -- Tester: Stefan Schmidt - -openpcd: -- OpenPCD RFID reader -- DFU implementation: SAM7DFU - http://www.openpcd.org/Sam7dfu, git://git.gnumonks.org/openpcd.git -- Tester: Stefan Schmidt - -simtrace: -- Sysmocom SimTrace -- DFU implementation: SAM7DFU - http://www.openpcd.org/Sam7dfu, git://git.gnumonks.org/openpcd.git -- Tester: Stefan Schmidt - -openmoko-freerunner: -- Openmoko Freerunner -- DFU implementation: Old U-Boot - http://git.openmoko.org/?p=u-boot.git;a=shortlog;h=refs/heads/mokopatches -- Tester: Stefan Schmidt - -openmoko-neo1973: -- Openmoko Neo1073 -- DFU implementation: Old U-Boot - http://git.openmoko.org/?p=u-boot.git;a=shortlog;h=refs/heads/mokopatches -- Tester: Stefan Schmidt - -tdk-bluetooth: -- TDK Corp. Bluetooth Adapter -- DFU implementation: closed soure -- Only upload has been tested -- Tester: Stefan Schmidt - -stm32f107: -- STM32 microcontrollers with built-in (ROM) DFU loader -- DFU implementation: Closed source but probably similar to the one - in their USB device libraries. Some relevant application notes: - http://www.st.com -> AN3156 and AN2606 -- Tested by Uwe Bonnes - -stm32f4discovery: -- STM32 microcontroller board with built-in (ROM) DFU loader -- DFU implementation: Closed source, probably similar to stm32f107. -- Tested by Joe Rothweiler - -dso-nano: -- DSO Nano pocket oscilloscope -- DFU implementation: Based on ST Microelectronics USB FS Library 1.0 - http://dsonano.googlecode.com/files/DS0201_OpenSource.rar -- Tester: Tormod Volden - -opc-20: -- Custom devices based on STM32F1xx -- DFU implementation: ST Microelectronics USB FS Device Library 3.1.0 - http://www.st.com -> um0424.zip -- Tester: Tormod Volden - -lpc-link, lpclink2: -- NXP LPCXpresso debug adapters -- Proprietary DFU implementation, uses special download files with - LPC prefix and encoding of the target firmware code -- Tested by Uwe Bonnes - -Adding the lsusb output and a download log of your device here helps -us to avoid regressions for hardware we cannot test while working on -the code. To extract the lsusb output use this command: -sudo lsusb -v -d $USBID > $DEVICE.lsusb -Prepare a description snippet as above, and send it to us. A log -(copy-paste of the command window) of a firmware download is also -nice, please use the double verbose option -v -v and include the -command line in the log file. - diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/dsonano.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/dsonano.lsusb deleted file mode 100755 index 140a7bc6c..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/dsonano.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 002 Device 004: ID 0483:df11 SGS Thomson Microelectronics -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 - bcdDevice 1.1a - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 DFU - iSerial 3 001 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 64mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 4 @Internal Flash /0x08000000/12*001Ka,116*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 5 @SPI Flash : M25P64/0x00000000/64*064Kg,64*064Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1.1a -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink.log b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink.log deleted file mode 100755 index 7de4dd3e6..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink.log +++ /dev/null @@ -1,59 +0,0 @@ -(The on-board LPC3154 has some encryption key set and LPCXpressoWIN.enc -is encrypted.) - -$ lsusb | grep NXP -Bus 003 Device 011: ID 0471:df55 Philips (or NXP) LPCXpresso LPC-Link - -$ dfu-util -v -v -v -R -D /opt/lpc/lpcxpresso/bin/LPCXpressoWIN.enc - -dfu-util 0.7 - -Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. -Copyright 2010-2012 Tormod Volden and Stefan Schmidt -This program is Free Software and has ABSOLUTELY NO WARRANTY -Please report bugs to dfu-util@lists.gnumonks.org - -dfu-util: Invalid DFU suffix signature -dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! -Deducing device DFU version from functional descriptor length -Opening DFU capable USB device... -ID 0471:df55 -Run-time device DFU version 0100 -Claiming USB DFU Runtime Interface... -Determining device status: -state = dfuIDLE, status = 0 -dfu-util: WARNING: Runtime device already in DFU state ?!? -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: -state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 0100 -Device returned transfer size 2048 -Copying data from PC to DFU device -Download [ ] 0% 0 bytes -Download [= ] 6% 2048 bytes -Download [=== ] 13% 4096 bytes -Download [==== ] 19% 6144 bytes -Download [====== ] 26% 8192 bytes -Download [======== ] 32% 10240 bytes -Download [========= ] 39% 12288 bytes -Download [=========== ] 45% 14336 bytes -Download [============= ] 52% 16384 bytes -Download [============== ] 59% 18432 bytes -Download [================ ] 65% 20480 bytes -Download [================== ] 72% 22528 bytes -Download [=================== ] 78% 24576 bytes -Download [===================== ] 85% 26624 bytes -Download [====================== ] 91% 28672 bytes -Download [======================== ] 98% 29192 bytes -Download [=========================] 100% 29192 bytes -Download done. -Sent a total of 29192 bytes -state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present -Done! -dfu-util: can't detach -Resetting USB to switch back to runtime mode - -$ lsusb | grep NXP -Bus 003 Device 012: ID 1fc9:0009 NXP Semiconductors diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink.lsusb deleted file mode 100755 index 867b2a2c5..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink.lsusb +++ /dev/null @@ -1,58 +0,0 @@ - -Bus 003 Device 008: ID 0471:df55 Philips (or NXP) LPCXpresso LPC-Link -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0471 Philips (or NXP) - idProduct 0xdf55 LPCXpresso LPC-Link - bcdDevice 0.01 - iManufacturer 0 - iProduct 0 - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 25 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 7 - bDescriptorType 33 - bmAttributes 1 - Will Not Detach - Manifestation Intolerant - Upload Unsupported - Download Supported - wDetachTimeout 65535 milliseconds - wTransferSize 2048 bytes -Device Qualifier (for other device speed): - bLength 10 - bDescriptorType 6 - bcdUSB 2.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - bNumConfigurations 1 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink2.log b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink2.log deleted file mode 100755 index 4681eff7d..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink2.log +++ /dev/null @@ -1,59 +0,0 @@ -$ lsusb | grep NXP -Bus 003 Device 013: ID 1fc9:000c NXP Semiconductors - -$ dfu-util -D ~/devel/dfu-util/firmware.bin.qthdr - -dfu-util 0.7 - -Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. -Copyright 2010-2012 Tormod Volden and Stefan Schmidt -This program is Free Software and has ABSOLUTELY NO WARRANTY -Please report bugs to dfu-util@lists.gnumonks.org - -dfu-util: Invalid DFU suffix signature -dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! -Possible unencryptes NXP LPC DFU prefix with the following properties -Payload length: 39 kiByte -Opening DFU capable USB device... -ID 1fc9:000c -Run-time device DFU version 0100 -Claiming USB DFU Runtime Interface... -Determining device status: -state = dfuIDLE, status = 0 -dfu-util: WARNING: Runtime device already in DFU state ?!? -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: -state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 0100 -Device returned transfer size 2048 -Copying data from PC to DFU device -Download [ ] 0% 0 bytes -Download [= ] 4% 2048 bytes -Download [== ] 9% 4096 bytes -Download [=== ] 14% 6144 bytes -Download [==== ] 19% 8192 bytes -Download [====== ] 24% 10240 bytes -Download [======= ] 28% 12288 bytes -Download [======== ] 33% 14336 bytes -Download [========= ] 38% 16384 bytes -Download [========== ] 43% 18432 bytes -Download [============ ] 48% 20480 bytes -Download [============= ] 53% 22528 bytes -Download [============== ] 57% 24576 bytes -Download [=============== ] 62% 26624 bytes -Download [================ ] 67% 28672 bytes -Download [================== ] 72% 30720 bytes -Download [=================== ] 77% 32768 bytes -Download [==================== ] 82% 34816 bytes -Download [===================== ] 86% 36864 bytes -Download [====================== ] 91% 38912 bytes -Download [======================== ] 96% 40356 bytes -Download [=========================] 100% 40356 bytes -Download done. -Sent a total of 40356 bytes -dfu-util: unable to read DFU status - -$ lsusb | grep NXP -Bus 003 Device 014: ID 1fc9:0018 NXP Semiconductors diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink2.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink2.lsusb deleted file mode 100755 index b833fca77..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/lpclink2.lsusb +++ /dev/null @@ -1,203 +0,0 @@ - -Bus 003 Device 007: ID 0c72:000c PEAK System PCAN-USB -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x0c72 PEAK System - idProduct 0x000c PCAN-USB - bcdDevice 1c.ff - iManufacturer 0 - iProduct 3 VER1:PEAK -VER2:02.8.01 -DAT :06.05.2004 -TIME:09:35:37 - ... - iSerial 0 - bNumConfigurations 3 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 2 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 394mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 3 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/opc-20.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/opc-20.lsusb deleted file mode 100755 index 580df90e5..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/opc-20.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 004: ID 0483:df11 SGS Thomson Microelectronics -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 - bcdDevice 2.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 DFU - iSerial 3 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/12*001Ka,116*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @SPI Flash : M25P64/0x00000000/128*64Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1a.01 -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb deleted file mode 100755 index 4c0abfb06..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb +++ /dev/null @@ -1,109 +0,0 @@ -Bus 003 Device 017: ID 1d50:5119 OpenMoko, Inc. GTA01/GTA02 U-Boot Bootloader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x5119 GTA01/GTA02 U-Boot Bootloader - bcdDevice 0.00 - iManufacturer 1 OpenMoko, Inc - iProduct 2 Neo1973 Bootloader U-Boot 1.3.2-moko12 - iSerial 3 0000000 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 81 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 7 USB Device Firmware Upgrade - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 8 RAM 0x32000000 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 9 u-boot - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 10 u-boot_env - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 3 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 11 kernel - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 4 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 12 splash - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 5 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 13 factory - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 6 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 14 rootfs - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 -Device Status: 0x0a00 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openmoko-freerunner.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openmoko-freerunner.lsusb deleted file mode 100755 index 835708dd8..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openmoko-freerunner.lsusb +++ /dev/null @@ -1,179 +0,0 @@ -Bus 005 Device 033: ID 1d50:5119 OpenMoko, Inc. GTA01/GTA02 U-Boot Bootloader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.10 - bDeviceClass 2 Communications - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x5119 GTA01/GTA02 U-Boot Bootloader - bcdDevice 0.00 - iManufacturer 1 OpenMoko, Inc - iProduct 2 Neo1973 Bootloader U-Boot 1.3.2-moko12 - iSerial 3 0000000 - bNumConfigurations 2 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 85 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 4 TTY via USB - bmAttributes 0x80 - (Bus Powered) - MaxPower 500mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 Control Interface - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 Bulk Data Interface - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 7 USB Device Firmware Upgrade - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 67 - bNumInterfaces 2 - bConfigurationValue 2 - iConfiguration 4 TTY via USB - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 Control Interface - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 Bulk Data Interface - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 -Device Status: 0x9a00 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openmoko-neo1973.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openmoko-neo1973.lsusb deleted file mode 100755 index 07789506a..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openmoko-neo1973.lsusb +++ /dev/null @@ -1,182 +0,0 @@ - -Bus 006 Device 020: ID 1457:5119 First International Computer, Inc. OpenMoko Neo1973 u-boot cdc_acm serial port -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.10 - bDeviceClass 2 Communications - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1457 First International Computer, Inc. - idProduct 0x5119 OpenMoko Neo1973 u-boot cdc_acm serial port - bcdDevice 0.00 - iManufacturer 1 - iProduct 2 - iSerial 3 - bNumConfigurations 2 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 85 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 4 - bmAttributes 0x80 - (Bus Powered) - MaxPower 500mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 7 - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 67 - bNumInterfaces 2 - bConfigurationValue 2 - iConfiguration 4 - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 -Device Status: 0x0006 - (Bus Powered) - Remote Wakeup Enabled - Test Mode diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openpcd.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openpcd.lsusb deleted file mode 100755 index f6255a943..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/openpcd.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 006 Device 016: ID 16c0:076b VOTI OpenPCD 13.56MHz RFID Reader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 8 - idVendor 0x16c0 VOTI - idProduct 0x076b OpenPCD 13.56MHz RFID Reader - bcdDevice 0.00 - iManufacturer 1 - iProduct 2 OpenPCD RFID Simulator - DFU Mode - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 0 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 3 - Will Not Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 256 bytes - bcdDFUVersion 1.00 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/qi-hardware-atusb.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/qi-hardware-atusb.lsusb deleted file mode 100755 index bfc1701e1..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/qi-hardware-atusb.lsusb +++ /dev/null @@ -1,59 +0,0 @@ - -Bus 006 Device 013: ID 20b7:1540 Qi Hardware ben-wpan, AT86RF230-based -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 255 Vendor Specific Class - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x20b7 Qi Hardware - idProduct 0x1540 ben-wpan, AT86RF230-based - bcdDevice 0.01 - iManufacturer 0 - iProduct 0 - iSerial 1 4630333438371508231a - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 34 - bNumInterfaces 2 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 40mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 255 Vendor Specific Class - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 0 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 0 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/simtrace.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/simtrace.lsusb deleted file mode 100755 index 578ddf0e1..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/simtrace.lsusb +++ /dev/null @@ -1,70 +0,0 @@ - -Bus 006 Device 017: ID 16c0:0762 VOTI -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 8 - idVendor 0x16c0 VOTI - idProduct 0x0762 - bcdDevice 0.00 - iManufacturer 1 sysmocom - systems for mobile communications GmbH - iProduct 2 SimTrace SIM Sniffer - DFU Mode - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 45 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 3 SimTrace DFU Configuration - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 SimTrace DFU Interface - Application Partition - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 SimTrace DFU Interface - Bootloader Partition - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 6 SimTrace DFU Interface - RAM - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 3 - Will Not Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 256 bytes - bcdDFUVersion 1.00 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/sparkcore.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/sparkcore.lsusb deleted file mode 100755 index b6029ffa5..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/sparkcore.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 008: ID 1d50:607f OpenMoko, Inc. -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x607f - bcdDevice 2.00 - iManufacturer 1 Spark Devices - iProduct 2 CORE DFU - iSerial 3 8D80527B5055 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/20*001Ka,108*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @SPI Flash : SST25x/0x00000000/512*04Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1.1a -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f107.bin-download b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f107.bin-download deleted file mode 100755 index 45b714f83..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f107.bin-download +++ /dev/null @@ -1,48 +0,0 @@ -> src/dfu-util --intf 0 --alt 0 -v -v -v -s 0x8000000 -D test3 -dfu-util 0.4 - -(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. -(C) 2010-2011 Tormod Volden (DfuSe support) -This program is Free Software and has ABSOLUTELY NO WARRANTY - -dfu-util does currently only support DFU version 1.0 - -Opening DFU USB device... ID 0483:df11 -Run-time device DFU version 011a -Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/128*002Kg" -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 011a -Device returned transfer size 2048 -No valid DFU suffix signature -Warning: File has no DFU suffix -DfuSe interface name: "Internal Flash " -Memory segment at 0x08000000 128 x 2048 = 262144 (rew) -Uploading to address = 0x08000000, size = 16384 -Erasing page size 2048 at address 0x08000000, page starting at 0x08000000 - Download from image offset 00000000 to memory 08000000-080007ff, size 2048 - Setting address pointer to 0x08000000 -Erasing page size 2048 at address 0x08000800, page starting at 0x08000800 - Download from image offset 00000800 to memory 08000800-08000fff, size 2048 - Setting address pointer to 0x08000800 -Erasing page size 2048 at address 0x08001000, page starting at 0x08001000 - Download from image offset 00001000 to memory 08001000-080017ff, size 2048 - Setting address pointer to 0x08001000 -Erasing page size 2048 at address 0x08001800, page starting at 0x08001800 - Download from image offset 00001800 to memory 08001800-08001fff, size 2048 - Setting address pointer to 0x08001800 -Erasing page size 2048 at address 0x08002000, page starting at 0x08002000 - Download from image offset 00002000 to memory 08002000-080027ff, size 2048 - Setting address pointer to 0x08002000 -Erasing page size 2048 at address 0x08002800, page starting at 0x08002800 - Download from image offset 00002800 to memory 08002800-08002fff, size 2048 - Setting address pointer to 0x08002800 -Erasing page size 2048 at address 0x08003000, page starting at 0x08003000 - Download from image offset 00003000 to memory 08003000-080037ff, size 2048 - Setting address pointer to 0x08003000 -Erasing page size 2048 at address 0x08003800, page starting at 0x08003800 - Download from image offset 00003800 to memory 08003800-08003fff, size 2048 - Setting address pointer to 0x08003800 - diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f107.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f107.lsusb deleted file mode 100755 index 14b45cda0..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f107.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 028: ID 0483:df11 SGS Thomson Microelectronics STM Device in DFU Mode -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 STM Device in DFU Mode - bcdDevice 20.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 0x418 DFU Bootloader - iSerial 3 STM32 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/128*002Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @Option Bytes /0x1FFFF800/01*016 g - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 2048 bytes - bcdDFUVersion 1.1a -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f4discovery.bin-download b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f4discovery.bin-download deleted file mode 100755 index 96e172216..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f4discovery.bin-download +++ /dev/null @@ -1,36 +0,0 @@ -dfu-util --device 0483:df11 --alt 0 \ - --dfuse-address 0x08000000 \ - -v -v -v \ - --download arm/iotoggle.bin -No valid DFU suffix signature -Warning: File has no DFU suffix -dfu-util 0.5 - -(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. -(C) 2010-2011 Tormod Volden (DfuSe support) -This program is Free Software and has ABSOLUTELY NO WARRANTY - -dfu-util does currently only support DFU version 1.0 - -Filter on vendor = 0x0483 product = 0xdf11 -Opening DFU capable USB device... ID 0483:df11 -Run-time device DFU version 011a -Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg" -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: state = dfuERROR, status = 10 -dfuERROR, clearing status -Determining device status: state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 011a -Device returned transfer size 2048 -DfuSe interface name: "Internal Flash " -Memory segment at 0x08000000 4 x 16384 = 65536 (rew) -Memory segment at 0x08010000 1 x 65536 = 65536 (rew) -Memory segment at 0x08020000 7 x 131072 = 917504 (rew) -Uploading to address = 0x08000000, size = 2308 -Erasing page size 16384 at address 0x08000000, page starting at 0x08000000 - Download from image offset 00000000 to memory 08000000-080007ff, size 2048 - Setting address pointer to 0x08000000 - Download from image offset 00000800 to memory 08000800-08000903, size 260 - Setting address pointer to 0x08000800 diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f4discovery.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f4discovery.lsusb deleted file mode 100755 index 0b870de91..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/stm32f4discovery.lsusb +++ /dev/null @@ -1,80 +0,0 @@ - -Bus 001 Device 010: ID 0483:df11 SGS Thomson Microelectronics STM Device in DFU Mode -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 STM Device in DFU Mode - bcdDevice 21.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 BOOTLOADER - iSerial 3 315A28A0B956 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 54 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @Option Bytes /0x1FFFC000/01*016 g - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 6 @OTP Memory /0x1FFF7800/01*512 g,01*016 g - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 3 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 7 @Device Feature/0xFFFF0000/01*004 g - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 2048 bytes - bcdDFUVersion 1.1a -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/tdk-bluetooth.lsusb b/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/tdk-bluetooth.lsusb deleted file mode 100755 index c0cfaceb6..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/device-logs/tdk-bluetooth.lsusb +++ /dev/null @@ -1,269 +0,0 @@ - -Bus 006 Device 014: ID 04bf:0320 TDK Corp. Bluetooth Adapter -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 224 Wireless - bDeviceSubClass 1 Radio Frequency - bDeviceProtocol 1 Bluetooth - bMaxPacketSize0 64 - idVendor 0x04bf TDK Corp. - idProduct 0x0320 Bluetooth Adapter - bcdDevice 26.52 - iManufacturer 1 Ezurio - iProduct 2 Turbo Bluetooth Adapter - iSerial 3 008098D4FFBD - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 193 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 64mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 3 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0000 1x 0 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0000 1x 0 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 1 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0009 1x 9 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0009 1x 9 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 2 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0011 1x 17 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0011 1x 17 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 3 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0019 1x 25 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0019 1x 25 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 4 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0021 1x 33 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0021 1x 33 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 5 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0031 1x 49 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0031 1x 49 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 7 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 5000 milliseconds - wTransferSize 1023 bytes -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/dfuse-pack.py b/arduino/opencr_arduino/tools/linux/src/dfu-util/dfuse-pack.py deleted file mode 100755 index 875cc5c6e..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/dfuse-pack.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/python - -# Written by Antonio Galea - 2010/11/18 -# Distributed under Gnu LGPL 3.0 -# see http://www.gnu.org/licenses/lgpl-3.0.txt - -import sys,struct,zlib,os -from optparse import OptionParser - -DEFAULT_DEVICE="0x0483:0xdf11" - -def named(tuple,names): - return dict(zip(names.split(),tuple)) -def consume(fmt,data,names): - n = struct.calcsize(fmt) - return named(struct.unpack(fmt,data[:n]),names),data[n:] -def cstring(string): - return string.split('\0',1)[0] -def compute_crc(data): - return 0xFFFFFFFF & -zlib.crc32(data) -1 - -def parse(file,dump_images=False): - print 'File: "%s"' % file - data = open(file,'rb').read() - crc = compute_crc(data[:-4]) - prefix, data = consume('<5sBIB',data,'signature version size targets') - print '%(signature)s v%(version)d, image size: %(size)d, targets: %(targets)d' % prefix - for t in range(prefix['targets']): - tprefix, data = consume('<6sBI255s2I',data,'signature altsetting named name size elements') - tprefix['num'] = t - if tprefix['named']: - tprefix['name'] = cstring(tprefix['name']) - else: - tprefix['name'] = '' - print '%(signature)s %(num)d, alt setting: %(altsetting)s, name: "%(name)s", size: %(size)d, elements: %(elements)d' % tprefix - tsize = tprefix['size'] - target, data = data[:tsize], data[tsize:] - for e in range(tprefix['elements']): - eprefix, target = consume('<2I',target,'address size') - eprefix['num'] = e - print ' %(num)d, address: 0x%(address)08x, size: %(size)d' % eprefix - esize = eprefix['size'] - image, target = target[:esize], target[esize:] - if dump_images: - out = '%s.target%d.image%d.bin' % (file,t,e) - open(out,'wb').write(image) - print ' DUMPED IMAGE TO "%s"' % out - if len(target): - print "target %d: PARSE ERROR" % t - suffix = named(struct.unpack('<4H3sBI',data[:16]),'device product vendor dfu ufd len crc') - print 'usb: %(vendor)04x:%(product)04x, device: 0x%(device)04x, dfu: 0x%(dfu)04x, %(ufd)s, %(len)d, 0x%(crc)08x' % suffix - if crc != suffix['crc']: - print "CRC ERROR: computed crc32 is 0x%08x" % crc - data = data[16:] - if data: - print "PARSE ERROR" - -def build(file,targets,device=DEFAULT_DEVICE): - data = '' - for t,target in enumerate(targets): - tdata = '' - for image in target: - tdata += struct.pack('<2I',image['address'],len(image['data']))+image['data'] - tdata = struct.pack('<6sBI255s2I','Target',0,1,'ST...',len(tdata),len(target)) + tdata - data += tdata - data = struct.pack('<5sBIB','DfuSe',1,len(data)+11,len(targets)) + data - v,d=map(lambda x: int(x,0) & 0xFFFF, device.split(':',1)) - data += struct.pack('<4H3sB',0,d,v,0x011a,'UFD',16) - crc = compute_crc(data) - data += struct.pack(' and -Harald Welte . Over time, nearly complete -support of DFU 1.0, DFU 1.1 and DfuSe ("1.1a") has been added. -.SH LICENCE -.B dfu-util -is covered by the GNU General Public License (GPL), version 2 or later. -.SH COPYRIGHT -This manual page was originally written by Uwe Hermann , -and is now part of the dfu-util project. diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/README_msvc.txt b/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/README_msvc.txt deleted file mode 100755 index 6e68ec6ff..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/README_msvc.txt +++ /dev/null @@ -1,10 +0,0 @@ -# (C) Roger Meier -# (C) Pascal Schweizer -# msvc folder is GPL-2.0+, LGPL-2.1+, BSD-3-Clause or MIT license(SPDX) - -Building dfu-util native on Windows with Visual Studio - -3rd party dependencies: -- libusbx ( git clone https://github.com/libusbx/libusbx.git ) - - getopt (part of libusbx: libusbx/examples/getopt) - diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/dfu-suffix_2010.vcxproj b/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/dfu-suffix_2010.vcxproj deleted file mode 100755 index 0c316c2e5..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/dfu-suffix_2010.vcxproj +++ /dev/null @@ -1,100 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA} - dfusuffix - dfu-suffix - - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\dll;$(LibraryPath) - $(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib - $(ExecutablePath) - - - $(ExecutablePath) - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\dll;$(LibraryPath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - Level3 - Disabled - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebug - - - true - - - - - Level3 - MaxSpeed - true - true - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - - - true - true - true - - - - - - - - - - - - - {a2169bc8-cf99-40bf-83f3-b0e38f7067bd} - - - {349ee8f9-7d25-4909-aaf5-ff3fade72187} - - - - - - \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/dfu-util_2010.sln b/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/dfu-util_2010.sln deleted file mode 100755 index ef797239b..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/dfu-util_2010.sln +++ /dev/null @@ -1,54 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dfu-util", "dfu-util_2010.vcxproj", "{0E071A60-7EF2-4427-BAA8-9143CACB5BCB}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C4F8746D-B27E-4806-95E5-2052174E923B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dfu-suffix", "dfu-suffix_2010.vcxproj", "{8F7600A2-3B37-4956-B39B-A1D43EF29EDA}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt_2010", "..\..\libusbx\msvc\getopt_2010.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "..\..\libusbx\msvc\libusb_static_2010.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|Win32.ActiveCfg = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|Win32.Build.0 = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|x64.ActiveCfg = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|Win32.ActiveCfg = Release|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|Win32.Build.0 = Release|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|x64.ActiveCfg = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|Win32.ActiveCfg = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|Win32.Build.0 = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|x64.ActiveCfg = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|Win32.ActiveCfg = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|Win32.Build.0 = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|x64.ActiveCfg = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.ActiveCfg = Debug|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.Build.0 = Debug|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.ActiveCfg = Debug|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.Build.0 = Debug|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.ActiveCfg = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.Build.0 = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.ActiveCfg = Release|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.Build.0 = Release|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/dfu-util_2010.vcxproj b/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/dfu-util_2010.vcxproj deleted file mode 100755 index 17a8bee1b..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/msvc/dfu-util_2010.vcxproj +++ /dev/null @@ -1,120 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB} - dfuutil - dfu-util - - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\getopt\$(Configuration);$(LibraryPath) - $(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib - $(ExecutablePath) - - - $(ExecutablePath) - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\getopt\$(Configuration);$(LibraryPath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - Level3 - Disabled - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebug - - - true - - - - - - - - - Level3 - MaxSpeed - true - true - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - - - true - true - true - - - copy $(SolutionDir)..\$(Platform)\$(Configuration)\dll\libusb-1.0.dll $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - - - - - - - - - - - - - - - - - - - - - - - {a2169bc8-cf99-40bf-83f3-b0e38f7067bd} - - - {349ee8f9-7d25-4909-aaf5-ff3fade72187} - - - - - - \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/Makefile.am b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/Makefile.am deleted file mode 100755 index 70179c411..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -AM_CFLAGS = -Wall -Wextra - -bin_PROGRAMS = dfu-util dfu-suffix dfu-prefix -dfu_util_SOURCES = main.c \ - portable.h \ - dfu_load.c \ - dfu_load.h \ - dfu_util.c \ - dfu_util.h \ - dfuse.c \ - dfuse.h \ - dfuse_mem.c \ - dfuse_mem.h \ - dfu.c \ - dfu.h \ - usb_dfu.h \ - dfu_file.c \ - dfu_file.h \ - quirks.c \ - quirks.h - -dfu_suffix_SOURCES = suffix.c \ - dfu_file.h \ - dfu_file.c - -dfu_prefix_SOURCES = prefix.c \ - dfu_file.h \ - dfu_file.c diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu.c b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu.c deleted file mode 100755 index 14d7673d1..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Low-level DFU communication routines, originally taken from - * $Id: dfu.c,v 1.3 2006/06/20 06:28:04 schmidtw Exp $ - * (part of dfu-programmer). - * - * Copyright 2005-2006 Weston Schmidt - * Copyright 2011-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include - -#include - -#include "portable.h" -#include "dfu.h" -#include "quirks.h" - -static int dfu_timeout = 5000; /* 5 seconds - default */ - -/* - * DFU_DETACH Request (DFU Spec 1.0, Section 5.1) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * timeout - the timeout in ms the USB device should wait for a pending - * USB reset before giving up and terminating the operation - * - * returns 0 or < 0 on error - */ -int dfu_detach( libusb_device_handle *device, - const unsigned short interface, - const unsigned short timeout ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DETACH, - /* wValue */ timeout, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -/* - * DFU_DNLOAD Request (DFU Spec 1.0, Section 6.1.1) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the total number of bytes to transfer to the USB - * device - must be less than wTransferSize - * data - the data to transfer - * - * returns the number of bytes written or < 0 on error - */ -int dfu_download( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ) -{ - int status; - - status = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DNLOAD, - /* wValue */ transaction, - /* wIndex */ interface, - /* Data */ data, - /* wLength */ length, - dfu_timeout ); - return status; -} - - -/* - * DFU_UPLOAD Request (DFU Spec 1.0, Section 6.2) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the maximum number of bytes to receive from the USB - * device - must be less than wTransferSize - * data - the buffer to put the received data in - * - * returns the number of bytes received or < 0 on error - */ -int dfu_upload( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ) -{ - int status; - - status = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_UPLOAD, - /* wValue */ transaction, - /* wIndex */ interface, - /* Data */ data, - /* wLength */ length, - dfu_timeout ); - return status; -} - - -/* - * DFU_GETSTATUS Request (DFU Spec 1.0, Section 6.1.2) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * status - the data structure to be populated with the results - * - * return the number of bytes read in or < 0 on an error - */ -int dfu_get_status( struct dfu_if *dif, struct dfu_status *status ) -{ - unsigned char buffer[6]; - int result; - - /* Initialize the status data structure */ - status->bStatus = DFU_STATUS_ERROR_UNKNOWN; - status->bwPollTimeout = 0; - status->bState = STATE_DFU_ERROR; - status->iString = 0; - - result = libusb_control_transfer( dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_GETSTATUS, - /* wValue */ 0, - /* wIndex */ dif->interface, - /* Data */ buffer, - /* wLength */ 6, - dfu_timeout ); - - if( 6 == result ) { - status->bStatus = buffer[0]; - if (dif->quirks & QUIRK_POLLTIMEOUT) - status->bwPollTimeout = DEFAULT_POLLTIMEOUT; - else - status->bwPollTimeout = ((0xff & buffer[3]) << 16) | - ((0xff & buffer[2]) << 8) | - (0xff & buffer[1]); - status->bState = buffer[4]; - status->iString = buffer[5]; - } - - return result; -} - - -/* - * DFU_CLRSTATUS Request (DFU Spec 1.0, Section 6.1.3) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * - * return 0 or < 0 on an error - */ -int dfu_clear_status( libusb_device_handle *device, - const unsigned short interface ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT| LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_CLRSTATUS, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -/* - * DFU_GETSTATE Request (DFU Spec 1.0, Section 6.1.5) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the maximum number of bytes to receive from the USB - * device - must be less than wTransferSize - * data - the buffer to put the received data in - * - * returns the state or < 0 on error - */ -int dfu_get_state( libusb_device_handle *device, - const unsigned short interface ) -{ - int result; - unsigned char buffer[1]; - - result = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_GETSTATE, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ buffer, - /* wLength */ 1, - dfu_timeout ); - - /* Return the error if there is one. */ - if (result < 1) - return -1; - - /* Return the state. */ - return buffer[0]; -} - - -/* - * DFU_ABORT Request (DFU Spec 1.0, Section 6.1.4) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * - * returns 0 or < 0 on an error - */ -int dfu_abort( libusb_device_handle *device, - const unsigned short interface ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_ABORT, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -const char* dfu_state_to_string( int state ) -{ - const char *message; - - switch (state) { - case STATE_APP_IDLE: - message = "appIDLE"; - break; - case STATE_APP_DETACH: - message = "appDETACH"; - break; - case STATE_DFU_IDLE: - message = "dfuIDLE"; - break; - case STATE_DFU_DOWNLOAD_SYNC: - message = "dfuDNLOAD-SYNC"; - break; - case STATE_DFU_DOWNLOAD_BUSY: - message = "dfuDNBUSY"; - break; - case STATE_DFU_DOWNLOAD_IDLE: - message = "dfuDNLOAD-IDLE"; - break; - case STATE_DFU_MANIFEST_SYNC: - message = "dfuMANIFEST-SYNC"; - break; - case STATE_DFU_MANIFEST: - message = "dfuMANIFEST"; - break; - case STATE_DFU_MANIFEST_WAIT_RESET: - message = "dfuMANIFEST-WAIT-RESET"; - break; - case STATE_DFU_UPLOAD_IDLE: - message = "dfuUPLOAD-IDLE"; - break; - case STATE_DFU_ERROR: - message = "dfuERROR"; - break; - default: - message = NULL; - break; - } - - return message; -} - -/* Chapter 6.1.2 */ -static const char *dfu_status_names[] = { - /* DFU_STATUS_OK */ - "No error condition is present", - /* DFU_STATUS_errTARGET */ - "File is not targeted for use by this device", - /* DFU_STATUS_errFILE */ - "File is for this device but fails some vendor-specific test", - /* DFU_STATUS_errWRITE */ - "Device is unable to write memory", - /* DFU_STATUS_errERASE */ - "Memory erase function failed", - /* DFU_STATUS_errCHECK_ERASED */ - "Memory erase check failed", - /* DFU_STATUS_errPROG */ - "Program memory function failed", - /* DFU_STATUS_errVERIFY */ - "Programmed memory failed verification", - /* DFU_STATUS_errADDRESS */ - "Cannot program memory due to received address that is out of range", - /* DFU_STATUS_errNOTDONE */ - "Received DFU_DNLOAD with wLength = 0, but device does not think that it has all data yet", - /* DFU_STATUS_errFIRMWARE */ - "Device's firmware is corrupt. It cannot return to run-time (non-DFU) operations", - /* DFU_STATUS_errVENDOR */ - "iString indicates a vendor specific error", - /* DFU_STATUS_errUSBR */ - "Device detected unexpected USB reset signalling", - /* DFU_STATUS_errPOR */ - "Device detected unexpected power on reset", - /* DFU_STATUS_errUNKNOWN */ - "Something went wrong, but the device does not know what it was", - /* DFU_STATUS_errSTALLEDPKT */ - "Device stalled an unexpected request" -}; - - -const char *dfu_status_to_string(int status) -{ - if (status > DFU_STATUS_errSTALLEDPKT) - return "INVALID"; - return dfu_status_names[status]; -} - -int dfu_abort_to_idle(struct dfu_if *dif) -{ - int ret; - struct dfu_status dst; - - ret = dfu_abort(dif->dev_handle, dif->interface); - if (ret < 0) { - errx(EX_IOERR, "Error sending dfu abort request"); - exit(1); - } - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during abort get_status"); - exit(1); - } - if (dst.bState != DFU_STATE_dfuIDLE) { - errx(EX_IOERR, "Failed to enter idle state on abort"); - exit(1); - } - milli_sleep(dst.bwPollTimeout); - return ret; -} diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu.h b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu.h deleted file mode 100755 index 8e3caeb7b..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * dfu-programmer - * - * $Id: dfu.h,v 1.2 2005/09/25 01:27:42 schmidtw Exp $ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFU_H -#define DFU_H - -#include -#include "usb_dfu.h" - -/* DFU states */ -#define STATE_APP_IDLE 0x00 -#define STATE_APP_DETACH 0x01 -#define STATE_DFU_IDLE 0x02 -#define STATE_DFU_DOWNLOAD_SYNC 0x03 -#define STATE_DFU_DOWNLOAD_BUSY 0x04 -#define STATE_DFU_DOWNLOAD_IDLE 0x05 -#define STATE_DFU_MANIFEST_SYNC 0x06 -#define STATE_DFU_MANIFEST 0x07 -#define STATE_DFU_MANIFEST_WAIT_RESET 0x08 -#define STATE_DFU_UPLOAD_IDLE 0x09 -#define STATE_DFU_ERROR 0x0a - - -/* DFU status */ -#define DFU_STATUS_OK 0x00 -#define DFU_STATUS_ERROR_TARGET 0x01 -#define DFU_STATUS_ERROR_FILE 0x02 -#define DFU_STATUS_ERROR_WRITE 0x03 -#define DFU_STATUS_ERROR_ERASE 0x04 -#define DFU_STATUS_ERROR_CHECK_ERASED 0x05 -#define DFU_STATUS_ERROR_PROG 0x06 -#define DFU_STATUS_ERROR_VERIFY 0x07 -#define DFU_STATUS_ERROR_ADDRESS 0x08 -#define DFU_STATUS_ERROR_NOTDONE 0x09 -#define DFU_STATUS_ERROR_FIRMWARE 0x0a -#define DFU_STATUS_ERROR_VENDOR 0x0b -#define DFU_STATUS_ERROR_USBR 0x0c -#define DFU_STATUS_ERROR_POR 0x0d -#define DFU_STATUS_ERROR_UNKNOWN 0x0e -#define DFU_STATUS_ERROR_STALLEDPKT 0x0f - -/* DFU commands */ -#define DFU_DETACH 0 -#define DFU_DNLOAD 1 -#define DFU_UPLOAD 2 -#define DFU_GETSTATUS 3 -#define DFU_CLRSTATUS 4 -#define DFU_GETSTATE 5 -#define DFU_ABORT 6 - -/* DFU interface */ -#define DFU_IFF_DFU 0x0001 /* DFU Mode, (not Runtime) */ - -/* This is based off of DFU_GETSTATUS - * - * 1 unsigned byte bStatus - * 3 unsigned byte bwPollTimeout - * 1 unsigned byte bState - * 1 unsigned byte iString -*/ - -struct dfu_status { - unsigned char bStatus; - unsigned int bwPollTimeout; - unsigned char bState; - unsigned char iString; -}; - -struct dfu_if { - struct usb_dfu_func_descriptor func_dfu; - uint16_t quirks; - uint16_t busnum; - uint16_t devnum; - uint16_t vendor; - uint16_t product; - uint16_t bcdDevice; - uint8_t configuration; - uint8_t interface; - uint8_t altsetting; - uint8_t flags; - uint8_t bMaxPacketSize0; - char *alt_name; - char *serial_name; - libusb_device *dev; - libusb_device_handle *dev_handle; - struct dfu_if *next; -}; - -int dfu_detach( libusb_device_handle *device, - const unsigned short interface, - const unsigned short timeout ); -int dfu_download( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ); -int dfu_upload( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ); -int dfu_get_status( struct dfu_if *dif, - struct dfu_status *status ); -int dfu_clear_status( libusb_device_handle *device, - const unsigned short interface ); -int dfu_get_state( libusb_device_handle *device, - const unsigned short interface ); -int dfu_abort( libusb_device_handle *device, - const unsigned short interface ); -int dfu_abort_to_idle( struct dfu_if *dif); - -const char *dfu_state_to_string( int state ); - -const char *dfu_status_to_string( int status ); - -#endif /* DFU_H */ diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_file.c b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_file.c deleted file mode 100755 index 7c897d4f6..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_file.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Load or store DFU files including suffix and prefix - * - * Copyright 2014 Tormod Volden - * Copyright 2012 Stefan Schmidt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -#define DFU_SUFFIX_LENGTH 16 -#define LMDFU_PREFIX_LENGTH 8 -#define LPCDFU_PREFIX_LENGTH 16 -#define PROGRESS_BAR_WIDTH 25 -#define STDIN_CHUNK_SIZE 65536 - -static const unsigned long crc32_table[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}; - -static uint32_t crc32_byte(uint32_t accum, uint8_t delta) -{ - return crc32_table[(accum ^ delta) & 0xff] ^ (accum >> 8); -} - -static int probe_prefix(struct dfu_file *file) -{ - uint8_t *prefix = file->firmware; - - if (file->size.total < LMDFU_PREFIX_LENGTH) - return 1; - if ((prefix[0] == 0x01) && (prefix[1] == 0x00)) { - file->prefix_type = LMDFU_PREFIX; - file->size.prefix = LMDFU_PREFIX_LENGTH; - file->lmdfu_address = 1024 * ((prefix[3] << 8) | prefix[2]); - } - else if (((prefix[0] & 0x3f) == 0x1a) && ((prefix[1] & 0x3f)== 0x3f)) { - file->prefix_type = LPCDFU_UNENCRYPTED_PREFIX; - file->size.prefix = LPCDFU_PREFIX_LENGTH; - } - - if (file->size.prefix + file->size.suffix > file->size.total) - return 1; - return 0; -} - -void dfu_progress_bar(const char *desc, unsigned long long curr, - unsigned long long max) -{ - static char buf[PROGRESS_BAR_WIDTH + 1]; - static unsigned long long last_progress = -1; - static time_t last_time; - time_t curr_time = time(NULL); - unsigned long long progress; - unsigned long long x; - - /* check for not known maximum */ - if (max < curr) - max = curr + 1; - /* make none out of none give zero */ - if (max == 0 && curr == 0) - max = 1; - - /* compute completion */ - progress = (PROGRESS_BAR_WIDTH * curr) / max; - if (progress > PROGRESS_BAR_WIDTH) - progress = PROGRESS_BAR_WIDTH; - if (progress == last_progress && - curr_time == last_time) - return; - last_progress = progress; - last_time = curr_time; - - for (x = 0; x != PROGRESS_BAR_WIDTH; x++) { - if (x < progress) - buf[x] = '='; - else - buf[x] = ' '; - } - buf[x] = 0; - - printf("\r%s\t[%s] %3lld%% %12lld bytes", desc, buf, - (100ULL * curr) / max, curr); - - if (progress == PROGRESS_BAR_WIDTH) - printf("\n%s done.\n", desc); -} - -void *dfu_malloc(size_t size) -{ - void *ptr = malloc(size); - if (ptr == NULL) - errx(EX_SOFTWARE, "Cannot allocate memory of size %d bytes", (int)size); - return (ptr); -} - -uint32_t dfu_file_write_crc(int f, uint32_t crc, const void *buf, int size) -{ - int x; - - /* compute CRC */ - for (x = 0; x != size; x++) - crc = crc32_byte(crc, ((uint8_t *)buf)[x]); - - /* write data */ - if (write(f, buf, size) != size) - err(EX_IOERR, "Could not write %d bytes to file %d", size, f); - - return (crc); -} - -void dfu_load_file(struct dfu_file *file, enum suffix_req check_suffix, enum prefix_req check_prefix) -{ - off_t offset; - int f; - int i; - int res; - - file->size.prefix = 0; - file->size.suffix = 0; - - /* default values, if no valid suffix is found */ - file->bcdDFU = 0; - file->idVendor = 0xffff; /* wildcard value */ - file->idProduct = 0xffff; /* wildcard value */ - file->bcdDevice = 0xffff; /* wildcard value */ - - /* default values, if no valid prefix is found */ - file->lmdfu_address = 0; - - free(file->firmware); - - if (!strcmp(file->name, "-")) { - int read_bytes; - -#ifdef WIN32 - _setmode( _fileno( stdin ), _O_BINARY ); -#endif - file->firmware = (uint8_t*) dfu_malloc(STDIN_CHUNK_SIZE); - read_bytes = fread(file->firmware, 1, STDIN_CHUNK_SIZE, stdin); - file->size.total = read_bytes; - while (read_bytes == STDIN_CHUNK_SIZE) { - file->firmware = (uint8_t*) realloc(file->firmware, file->size.total + STDIN_CHUNK_SIZE); - if (!file->firmware) - err(EX_IOERR, "Could not allocate firmware buffer"); - read_bytes = fread(file->firmware + file->size.total, 1, STDIN_CHUNK_SIZE, stdin); - file->size.total += read_bytes; - } - if (verbose) - printf("Read %i bytes from stdin\n", file->size.total); - /* Never require suffix when reading from stdin */ - check_suffix = MAYBE_SUFFIX; - } else { - f = open(file->name, O_RDONLY | O_BINARY); - if (f < 0) - err(EX_IOERR, "Could not open file %s for reading", file->name); - - offset = lseek(f, 0, SEEK_END); - - if ((int)offset < 0 || (int)offset != offset) - err(EX_IOERR, "File size is too big"); - - if (lseek(f, 0, SEEK_SET) != 0) - err(EX_IOERR, "Could not seek to beginning"); - - file->size.total = offset; - file->firmware = dfu_malloc(file->size.total); - - if (read(f, file->firmware, file->size.total) != file->size.total) { - err(EX_IOERR, "Could not read %d bytes from %s", - file->size.total, file->name); - } - close(f); - } - - /* Check for possible DFU file suffix by trying to parse one */ - { - uint32_t crc = 0xffffffff; - const uint8_t *dfusuffix; - int missing_suffix = 0; - const char *reason; - - if (file->size.total < DFU_SUFFIX_LENGTH) { - reason = "File too short for DFU suffix"; - missing_suffix = 1; - goto checked; - } - - dfusuffix = file->firmware + file->size.total - - DFU_SUFFIX_LENGTH; - - for (i = 0; i < file->size.total - 4; i++) - crc = crc32_byte(crc, file->firmware[i]); - - if (dfusuffix[10] != 'D' || - dfusuffix[9] != 'F' || - dfusuffix[8] != 'U') { - reason = "Invalid DFU suffix signature"; - missing_suffix = 1; - goto checked; - } - - file->dwCRC = (dfusuffix[15] << 24) + - (dfusuffix[14] << 16) + - (dfusuffix[13] << 8) + - dfusuffix[12]; - - if (file->dwCRC != crc) { - reason = "DFU suffix CRC does not match"; - missing_suffix = 1; - goto checked; - } - - /* At this point we believe we have a DFU suffix - so we require further checks to succeed */ - - file->bcdDFU = (dfusuffix[7] << 8) + dfusuffix[6]; - - if (verbose) - printf("DFU suffix version %x\n", file->bcdDFU); - - file->size.suffix = dfusuffix[11]; - - if (file->size.suffix < DFU_SUFFIX_LENGTH) { - errx(EX_IOERR, "Unsupported DFU suffix length %d", - file->size.suffix); - } - - if (file->size.suffix > file->size.total) { - errx(EX_IOERR, "Invalid DFU suffix length %d", - file->size.suffix); - } - - file->idVendor = (dfusuffix[5] << 8) + dfusuffix[4]; - file->idProduct = (dfusuffix[3] << 8) + dfusuffix[2]; - file->bcdDevice = (dfusuffix[1] << 8) + dfusuffix[0]; - -checked: - if (missing_suffix) { - if (check_suffix == NEEDS_SUFFIX) { - warnx("%s", reason); - errx(EX_IOERR, "Valid DFU suffix needed"); - } else if (check_suffix == MAYBE_SUFFIX) { - warnx("%s", reason); - warnx("A valid DFU suffix will be required in " - "a future dfu-util release!!!"); - } - } else { - if (check_suffix == NO_SUFFIX) { - errx(EX_SOFTWARE, "Please remove existing DFU suffix before adding a new one.\n"); - } - } - } - res = probe_prefix(file); - if ((res || file->size.prefix == 0) && check_prefix == NEEDS_PREFIX) - errx(EX_IOERR, "Valid DFU prefix needed"); - if (file->size.prefix && check_prefix == NO_PREFIX) - errx(EX_IOERR, "A prefix already exists, please delete it first"); - if (file->size.prefix && verbose) { - uint8_t *data = file->firmware; - if (file->prefix_type == LMDFU_PREFIX) - printf("Possible TI Stellaris DFU prefix with " - "the following properties\n" - "Address: 0x%08x\n" - "Payload length: %d\n", - file->lmdfu_address, - data[4] | (data[5] << 8) | - (data[6] << 16) | (data[7] << 14)); - else if (file->prefix_type == LPCDFU_UNENCRYPTED_PREFIX) - printf("Possible unencrypted NXP LPC DFU prefix with " - "the following properties\n" - "Payload length: %d kiByte\n", - data[2] >>1 | (data[3] << 7) ); - else - errx(EX_IOERR, "Unknown DFU prefix type"); - } -} - -void dfu_store_file(struct dfu_file *file, int write_suffix, int write_prefix) -{ - uint32_t crc = 0xffffffff; - int f; - - f = open(file->name, O_WRONLY | O_BINARY | O_TRUNC | O_CREAT, 0666); - if (f < 0) - err(EX_IOERR, "Could not open file %s for writing", file->name); - - /* write prefix, if any */ - if (write_prefix) { - if (file->prefix_type == LMDFU_PREFIX) { - uint8_t lmdfu_prefix[LMDFU_PREFIX_LENGTH]; - uint32_t addr = file->lmdfu_address / 1024; - - /* lmdfu_dfu_prefix payload length excludes prefix and suffix */ - uint32_t len = file->size.total - - file->size.prefix - file->size.suffix; - - lmdfu_prefix[0] = 0x01; /* STELLARIS_DFU_PROG */ - lmdfu_prefix[1] = 0x00; /* Reserved */ - lmdfu_prefix[2] = (uint8_t)(addr & 0xff); - lmdfu_prefix[3] = (uint8_t)(addr >> 8); - lmdfu_prefix[4] = (uint8_t)(len & 0xff); - lmdfu_prefix[5] = (uint8_t)(len >> 8) & 0xff; - lmdfu_prefix[6] = (uint8_t)(len >> 16) & 0xff; - lmdfu_prefix[7] = (uint8_t)(len >> 24); - - crc = dfu_file_write_crc(f, crc, lmdfu_prefix, LMDFU_PREFIX_LENGTH); - } - if (file->prefix_type == LPCDFU_UNENCRYPTED_PREFIX) { - uint8_t lpcdfu_prefix[LPCDFU_PREFIX_LENGTH] = {0}; - int i; - - /* Payload is firmware and prefix rounded to 512 bytes */ - uint32_t len = (file->size.total - file->size.suffix + 511) /512; - - lpcdfu_prefix[0] = 0x1a; /* Unencypted*/ - lpcdfu_prefix[1] = 0x3f; /* Reserved */ - lpcdfu_prefix[2] = (uint8_t)(len & 0xff); - lpcdfu_prefix[3] = (uint8_t)((len >> 8) & 0xff); - for (i = 12; i < LPCDFU_PREFIX_LENGTH; i++) - lpcdfu_prefix[i] = 0xff; - - crc = dfu_file_write_crc(f, crc, lpcdfu_prefix, LPCDFU_PREFIX_LENGTH); - } - } - /* write firmware binary */ - crc = dfu_file_write_crc(f, crc, file->firmware + file->size.prefix, - file->size.total - file->size.prefix - file->size.suffix); - - /* write suffix, if any */ - if (write_suffix) { - uint8_t dfusuffix[DFU_SUFFIX_LENGTH]; - - dfusuffix[0] = file->bcdDevice & 0xff; - dfusuffix[1] = file->bcdDevice >> 8; - dfusuffix[2] = file->idProduct & 0xff; - dfusuffix[3] = file->idProduct >> 8; - dfusuffix[4] = file->idVendor & 0xff; - dfusuffix[5] = file->idVendor >> 8; - dfusuffix[6] = file->bcdDFU & 0xff; - dfusuffix[7] = file->bcdDFU >> 8; - dfusuffix[8] = 'U'; - dfusuffix[9] = 'F'; - dfusuffix[10] = 'D'; - dfusuffix[11] = DFU_SUFFIX_LENGTH; - - crc = dfu_file_write_crc(f, crc, dfusuffix, - DFU_SUFFIX_LENGTH - 4); - - dfusuffix[12] = crc; - dfusuffix[13] = crc >> 8; - dfusuffix[14] = crc >> 16; - dfusuffix[15] = crc >> 24; - - crc = dfu_file_write_crc(f, crc, dfusuffix + 12, 4); - } - close(f); -} - -void show_suffix_and_prefix(struct dfu_file *file) -{ - if (file->size.prefix == LMDFU_PREFIX_LENGTH) { - printf("The file %s contains a TI Stellaris DFU prefix with the following properties:\n", file->name); - printf("Address:\t0x%08x\n", file->lmdfu_address); - } else if (file->size.prefix == LPCDFU_PREFIX_LENGTH) { - uint8_t * prefix = file->firmware; - printf("The file %s contains a NXP unencrypted LPC DFU prefix with the following properties:\n", file->name); - printf("Size:\t%5d kiB\n", prefix[2]>>1|prefix[3]<<7); - } else if (file->size.prefix != 0) { - printf("The file %s contains an unknown prefix\n", file->name); - } - if (file->size.suffix > 0) { - printf("The file %s contains a DFU suffix with the following properties:\n", file->name); - printf("BCD device:\t0x%04X\n", file->bcdDevice); - printf("Product ID:\t0x%04X\n",file->idProduct); - printf("Vendor ID:\t0x%04X\n", file->idVendor); - printf("BCD DFU:\t0x%04X\n", file->bcdDFU); - printf("Length:\t\t%i\n", file->size.suffix); - printf("CRC:\t\t0x%08X\n", file->dwCRC); - } -} diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_file.h b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_file.h deleted file mode 100755 index abebd44f4..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_file.h +++ /dev/null @@ -1,60 +0,0 @@ - -#ifndef DFU_FILE_H -#define DFU_FILE_H - -#include - -struct dfu_file { - /* File name */ - const char *name; - /* Pointer to file loaded into memory */ - uint8_t *firmware; - /* Different sizes */ - struct { - int total; - int prefix; - int suffix; - } size; - /* From prefix fields */ - uint32_t lmdfu_address; - /* From prefix fields */ - uint32_t prefix_type; - - /* From DFU suffix fields */ - uint32_t dwCRC; - uint16_t bcdDFU; - uint16_t idVendor; - uint16_t idProduct; - uint16_t bcdDevice; -}; - -enum suffix_req { - NO_SUFFIX, - NEEDS_SUFFIX, - MAYBE_SUFFIX -}; - -enum prefix_req { - NO_PREFIX, - NEEDS_PREFIX, - MAYBE_PREFIX -}; - -enum prefix_type { - ZERO_PREFIX, - LMDFU_PREFIX, - LPCDFU_UNENCRYPTED_PREFIX -}; - -extern int verbose; - -void dfu_load_file(struct dfu_file *file, enum suffix_req check_suffix, enum prefix_req check_prefix); -void dfu_store_file(struct dfu_file *file, int write_suffix, int write_prefix); - -void dfu_progress_bar(const char *desc, unsigned long long curr, - unsigned long long max); -void *dfu_malloc(size_t size); -uint32_t dfu_file_write_crc(int f, uint32_t crc, const void *buf, int size); -void show_suffix_and_prefix(struct dfu_file *file); - -#endif /* DFU_FILE_H */ diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_load.c b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_load.c deleted file mode 100755 index 64f7009df..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_load.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * DFU transfer routines - * - * This is supposed to be a general DFU implementation, as specified in the - * USB DFU 1.0 and 1.1 specification. - * - * The code was originally intended to interface with a USB device running the - * "sam7dfu" firmware (see http://www.openpcd.org/) on an AT91SAM7 processor. - * - * Copyright 2007-2008 Harald Welte - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "quirks.h" - -int dfuload_do_upload(struct dfu_if *dif, int xfer_size, - int expected_size, int fd) -{ - int total_bytes = 0; - unsigned short transaction = 0; - unsigned char *buf; - int ret; - - buf = dfu_malloc(xfer_size); - - printf("Copying data from DFU device to PC\n"); - dfu_progress_bar("Upload", 0, 1); - - while (1) { - int rc; - rc = dfu_upload(dif->dev_handle, dif->interface, - xfer_size, transaction++, buf); - if (rc < 0) { - warnx("Error during upload"); - ret = rc; - goto out_free; - } - - dfu_file_write_crc(fd, 0, buf, rc); - total_bytes += rc; - - if (total_bytes < 0) - errx(EX_SOFTWARE, "Received too many bytes (wraparound)"); - - if (rc < xfer_size) { - /* last block, return */ - ret = total_bytes; - break; - } - dfu_progress_bar("Upload", total_bytes, expected_size); - } - ret = 0; - -out_free: - dfu_progress_bar("Upload", total_bytes, total_bytes); - if (total_bytes == 0) - printf("\nFailed.\n"); - free(buf); - if (verbose) - printf("Received a total of %i bytes\n", total_bytes); - if (expected_size != 0 && total_bytes != expected_size) - errx(EX_SOFTWARE, "Unexpected number of bytes uploaded from device"); - return ret; -} - -int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file) -{ - int bytes_sent; - int expected_size; - unsigned char *buf; - unsigned short transaction = 0; - struct dfu_status dst; - int ret; - - printf("Copying data from PC to DFU device\n"); - - buf = file->firmware; - expected_size = file->size.total - file->size.suffix; - bytes_sent = 0; - - dfu_progress_bar("Download", 0, 1); - while (bytes_sent < expected_size) { - int bytes_left; - int chunk_size; - - bytes_left = expected_size - bytes_sent; - if (bytes_left < xfer_size) - chunk_size = bytes_left; - else - chunk_size = xfer_size; - - ret = dfu_download(dif->dev_handle, dif->interface, - chunk_size, transaction++, chunk_size ? buf : NULL); - if (ret < 0) { - warnx("Error during download"); - goto out; - } - bytes_sent += chunk_size; - buf += chunk_size; - - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during download get_status"); - goto out; - } - - if (dst.bState == DFU_STATE_dfuDNLOAD_IDLE || - dst.bState == DFU_STATE_dfuERROR) - break; - - /* Wait while device executes flashing */ - milli_sleep(dst.bwPollTimeout); - - } while (1); - if (dst.bStatus != DFU_STATUS_OK) { - printf(" failed!\n"); - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - ret = -1; - goto out; - } - dfu_progress_bar("Download", bytes_sent, bytes_sent + bytes_left); - } - - /* send one zero sized download request to signalize end */ - ret = dfu_download(dif->dev_handle, dif->interface, - 0, transaction, NULL); - if (ret < 0) { - errx(EX_IOERR, "Error sending completion packet"); - goto out; - } - - dfu_progress_bar("Download", bytes_sent, bytes_sent); - - if (verbose) - printf("Sent a total of %i bytes\n", bytes_sent); - -get_status: - /* Transition to MANIFEST_SYNC state */ - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - warnx("unable to read DFU status after completion"); - goto out; - } - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - - milli_sleep(dst.bwPollTimeout); - - /* FIXME: deal correctly with ManifestationTolerant=0 / WillDetach bits */ - switch (dst.bState) { - case DFU_STATE_dfuMANIFEST_SYNC: - case DFU_STATE_dfuMANIFEST: - /* some devices (e.g. TAS1020b) need some time before we - * can obtain the status */ - milli_sleep(1000); - goto get_status; - break; - case DFU_STATE_dfuIDLE: - break; - } - printf("Done!\n"); - -out: - return bytes_sent; -} diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_load.h b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_load.h deleted file mode 100755 index be23e9b4f..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_load.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef DFU_LOAD_H -#define DFU_LOAD_H - -int dfuload_do_upload(struct dfu_if *dif, int xfer_size, int expected_size, int fd); -int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file); - -#endif /* DFU_LOAD_H */ diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_util.c b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_util.c deleted file mode 100755 index b94c7ccd3..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_util.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Functions for detecting DFU USB entities - * - * Written by Harald Welte - * Copyright 2007-2008 by OpenMoko, Inc. - * Copyright 2013 Hans Petter Selasky - * - * Based on existing code of dfu-programmer-0.4 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "dfu_util.h" -#include "dfuse.h" -#include "quirks.h" - -#ifdef HAVE_USBPATH_H -#include -#endif - -/* - * Look for a descriptor in a concatenated descriptor list. Will - * return upon the first match of the given descriptor type. Returns length of - * found descriptor, limited to res_size - */ -static int find_descriptor(const uint8_t *desc_list, int list_len, - uint8_t desc_type, void *res_buf, int res_size) -{ - int p = 0; - - if (list_len < 2) - return (-1); - - while (p + 1 < list_len) { - int desclen; - - desclen = (int) desc_list[p]; - if (desclen == 0) { - warnx("Invalid descriptor list"); - return -1; - } - if (desc_list[p + 1] == desc_type) { - if (desclen > res_size) - desclen = res_size; - if (p + desclen > list_len) - desclen = list_len - p; - memcpy(res_buf, &desc_list[p], desclen); - return desclen; - } - p += (int) desc_list[p]; - } - return -1; -} - -static void probe_configuration(libusb_device *dev, struct libusb_device_descriptor *desc) -{ - struct usb_dfu_func_descriptor func_dfu; - libusb_device_handle *devh; - struct dfu_if *pdfu; - struct libusb_config_descriptor *cfg; - const struct libusb_interface_descriptor *intf; - const struct libusb_interface *uif; - char alt_name[MAX_DESC_STR_LEN + 1]; - char serial_name[MAX_DESC_STR_LEN + 1]; - int cfg_idx; - int intf_idx; - int alt_idx; - int ret; - int has_dfu; - - for (cfg_idx = 0; cfg_idx != desc->bNumConfigurations; cfg_idx++) { - memset(&func_dfu, 0, sizeof(func_dfu)); - has_dfu = 0; - - ret = libusb_get_config_descriptor(dev, cfg_idx, &cfg); - if (ret != 0) - return; - if (match_config_index > -1 && match_config_index != cfg->bConfigurationValue) { - libusb_free_config_descriptor(cfg); - continue; - } - - /* - * In some cases, noticably FreeBSD if uid != 0, - * the configuration descriptors are empty - */ - if (!cfg) - return; - - ret = find_descriptor(cfg->extra, cfg->extra_length, - USB_DT_DFU, &func_dfu, sizeof(func_dfu)); - if (ret > -1) - goto found_dfu; - - for (intf_idx = 0; intf_idx < cfg->bNumInterfaces; - intf_idx++) { - uif = &cfg->interface[intf_idx]; - if (!uif) - break; - - for (alt_idx = 0; alt_idx < cfg->interface[intf_idx].num_altsetting; - alt_idx++) { - intf = &uif->altsetting[alt_idx]; - - ret = find_descriptor(intf->extra, intf->extra_length, USB_DT_DFU, - &func_dfu, sizeof(func_dfu)); - if (ret > -1) - goto found_dfu; - - if (intf->bInterfaceClass != 0xfe || - intf->bInterfaceSubClass != 1) - continue; - - has_dfu = 1; - } - } - if (has_dfu) { - /* - * Finally try to retrieve it requesting the - * device directly This is not supported on - * all devices for non-standard types - */ - if (libusb_open(dev, &devh) == 0) { - ret = libusb_get_descriptor(devh, USB_DT_DFU, 0, - (void *)&func_dfu, sizeof(func_dfu)); - libusb_close(devh); - if (ret > -1) - goto found_dfu; - } - warnx("Device has DFU interface, " - "but has no DFU functional descriptor"); - - /* fake version 1.0 */ - func_dfu.bLength = 7; - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - goto found_dfu; - } - libusb_free_config_descriptor(cfg); - continue; - -found_dfu: - if (func_dfu.bLength == 7) { - printf("Deducing device DFU version from functional descriptor " - "length\n"); - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - } else if (func_dfu.bLength < 9) { - printf("Error obtaining DFU functional descriptor\n"); - printf("Please report this as a bug!\n"); - printf("Warning: Assuming DFU version 1.0\n"); - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - printf("Warning: Transfer size can not be detected\n"); - func_dfu.wTransferSize = 0; - } - - for (intf_idx = 0; intf_idx < cfg->bNumInterfaces; - intf_idx++) { - if (match_iface_index > -1 && match_iface_index != intf_idx) - continue; - - uif = &cfg->interface[intf_idx]; - if (!uif) - break; - - for (alt_idx = 0; - alt_idx < uif->num_altsetting; alt_idx++) { - int dfu_mode; - - intf = &uif->altsetting[alt_idx]; - - if (intf->bInterfaceClass != 0xfe || - intf->bInterfaceSubClass != 1) - continue; - - dfu_mode = (intf->bInterfaceProtocol == 2); - /* e.g. DSO Nano has bInterfaceProtocol 0 instead of 2 */ - if (func_dfu.bcdDFUVersion == 0x011a && intf->bInterfaceProtocol == 0) - dfu_mode = 1; - - if (dfu_mode && - match_iface_alt_index > -1 && match_iface_alt_index != alt_idx) - continue; - - if (dfu_mode) { - if ((match_vendor_dfu >= 0 && match_vendor_dfu != desc->idVendor) || - (match_product_dfu >= 0 && match_product_dfu != desc->idProduct)) { - continue; - } - } else { - if ((match_vendor >= 0 && match_vendor != desc->idVendor) || - (match_product >= 0 && match_product != desc->idProduct)) { - continue; - } - } - - if (libusb_open(dev, &devh)) { - warnx("Cannot open DFU device %04x:%04x", desc->idVendor, desc->idProduct); - break; - } - if (intf->iInterface != 0) - ret = libusb_get_string_descriptor_ascii(devh, - intf->iInterface, (void *)alt_name, MAX_DESC_STR_LEN); - else - ret = -1; - if (ret < 1) - strcpy(alt_name, "UNKNOWN"); - if (desc->iSerialNumber != 0) - ret = libusb_get_string_descriptor_ascii(devh, - desc->iSerialNumber, (void *)serial_name, MAX_DESC_STR_LEN); - else - ret = -1; - if (ret < 1) - strcpy(serial_name, "UNKNOWN"); - libusb_close(devh); - - if (dfu_mode && - match_iface_alt_name != NULL && strcmp(alt_name, match_iface_alt_name)) - continue; - - if (dfu_mode) { - if (match_serial_dfu != NULL && strcmp(match_serial_dfu, serial_name)) - continue; - } else { - if (match_serial != NULL && strcmp(match_serial, serial_name)) - continue; - } - - pdfu = dfu_malloc(sizeof(*pdfu)); - - memset(pdfu, 0, sizeof(*pdfu)); - - pdfu->func_dfu = func_dfu; - pdfu->dev = libusb_ref_device(dev); - pdfu->quirks = get_quirks(desc->idVendor, - desc->idProduct, desc->bcdDevice); - pdfu->vendor = desc->idVendor; - pdfu->product = desc->idProduct; - pdfu->bcdDevice = desc->bcdDevice; - pdfu->configuration = cfg->bConfigurationValue; - pdfu->interface = intf->bInterfaceNumber; - pdfu->altsetting = intf->bAlternateSetting; - pdfu->devnum = libusb_get_device_address(dev); - pdfu->busnum = libusb_get_bus_number(dev); - pdfu->alt_name = strdup(alt_name); - if (pdfu->alt_name == NULL) - errx(EX_SOFTWARE, "Out of memory"); - pdfu->serial_name = strdup(serial_name); - if (pdfu->serial_name == NULL) - errx(EX_SOFTWARE, "Out of memory"); - if (dfu_mode) - pdfu->flags |= DFU_IFF_DFU; - if (pdfu->quirks & QUIRK_FORCE_DFU11) { - pdfu->func_dfu.bcdDFUVersion = - libusb_cpu_to_le16(0x0110); - } - pdfu->bMaxPacketSize0 = desc->bMaxPacketSize0; - - /* queue into list */ - pdfu->next = dfu_root; - dfu_root = pdfu; - } - } - libusb_free_config_descriptor(cfg); - } -} - -void probe_devices(libusb_context *ctx) -{ - libusb_device **list; - ssize_t num_devs; - ssize_t i; - - num_devs = libusb_get_device_list(ctx, &list); - for (i = 0; i < num_devs; ++i) { - struct libusb_device_descriptor desc; - struct libusb_device *dev = list[i]; - - if (match_bus > -1 && match_bus != libusb_get_bus_number(dev)) - continue; - if (match_device > -1 && match_device != libusb_get_device_address(dev)) - continue; - if (libusb_get_device_descriptor(dev, &desc)) - continue; - probe_configuration(dev, &desc); - } - libusb_free_device_list(list, 0); -} - -void disconnect_devices(void) -{ - struct dfu_if *pdfu; - struct dfu_if *prev = NULL; - - for (pdfu = dfu_root; pdfu != NULL; pdfu = pdfu->next) { - free(prev); - libusb_unref_device(pdfu->dev); - free(pdfu->alt_name); - free(pdfu->serial_name); - prev = pdfu; - } - free(prev); - dfu_root = NULL; -} - -void print_dfu_if(struct dfu_if *dfu_if) -{ - printf("Found %s: [%04x:%04x] ver=%04x, devnum=%u, cfg=%u, intf=%u, " - "alt=%u, name=\"%s\", serial=\"%s\"\n", - dfu_if->flags & DFU_IFF_DFU ? "DFU" : "Runtime", - dfu_if->vendor, dfu_if->product, - dfu_if->bcdDevice, dfu_if->devnum, - dfu_if->configuration, dfu_if->interface, - dfu_if->altsetting, dfu_if->alt_name, - dfu_if->serial_name); -} - -/* Walk the device tree and print out DFU devices */ -void list_dfu_interfaces(void) -{ - struct dfu_if *pdfu; - - for (pdfu = dfu_root; pdfu != NULL; pdfu = pdfu->next) - print_dfu_if(pdfu); -} diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_util.h b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_util.h deleted file mode 100755 index fc0c19dca..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfu_util.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef DFU_UTIL_H -#define DFU_UTIL_H - -/* USB string descriptor should contain max 126 UTF-16 characters - * but 253 would even accomodate any UTF-8 encoding */ -#define MAX_DESC_STR_LEN 253 - -enum mode { - MODE_NONE, - MODE_VERSION, - MODE_LIST, - MODE_DETACH, - MODE_UPLOAD, - MODE_DOWNLOAD -}; - -extern struct dfu_if *dfu_root; -extern int match_bus; -extern int match_device; -extern int match_vendor; -extern int match_product; -extern int match_vendor_dfu; -extern int match_product_dfu; -extern int match_config_index; -extern int match_iface_index; -extern int match_iface_alt_index; -extern const char *match_iface_alt_name; -extern const char *match_serial; -extern const char *match_serial_dfu; - -void probe_devices(libusb_context *); -void disconnect_devices(void); -void print_dfu_if(struct dfu_if *); -void list_dfu_interfaces(void); - -#endif /* DFU_UTIL_H */ diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse.c b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse.c deleted file mode 100755 index fce29fed6..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse.c +++ /dev/null @@ -1,652 +0,0 @@ -/* - * DfuSe specific functions - * - * This implements the ST Microsystems DFU extensions (DfuSe) - * as per the DfuSe 1.1a specification (ST documents AN3156, AN2606) - * The DfuSe file format is described in ST document UM0391. - * - * Copyright 2010-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfuse.h" -#include "dfuse_mem.h" - -#define DFU_TIMEOUT 5000 - -extern int verbose; -static unsigned int last_erased_page = 1; /* non-aligned value, won't match */ -static struct memsegment *mem_layout; -static unsigned int dfuse_address = 0; -static unsigned int dfuse_length = 0; -static int dfuse_force = 0; -static int dfuse_leave = 0; -static int dfuse_unprotect = 0; -static int dfuse_mass_erase = 0; - -unsigned int quad2uint(unsigned char *p) -{ - return (*p + (*(p + 1) << 8) + (*(p + 2) << 16) + (*(p + 3) << 24)); -} - -void dfuse_parse_options(const char *options) -{ - char *end; - const char *endword; - unsigned int number; - - /* address, possibly empty, must be first */ - if (*options != ':') { - endword = strchr(options, ':'); - if (!endword) - endword = options + strlen(options); /* GNU strchrnul */ - - number = strtoul(options, &end, 0); - if (end == endword) { - dfuse_address = number; - } else { - errx(EX_IOERR, "Invalid dfuse address: %s", options); - } - options = endword; - } - - while (*options) { - if (*options == ':') { - options++; - continue; - } - endword = strchr(options, ':'); - if (!endword) - endword = options + strlen(options); - - if (!strncmp(options, "force", endword - options)) { - dfuse_force++; - options += 5; - continue; - } - if (!strncmp(options, "leave", endword - options)) { - dfuse_leave = 1; - options += 5; - continue; - } - if (!strncmp(options, "unprotect", endword - options)) { - dfuse_unprotect = 1; - options += 9; - continue; - } - if (!strncmp(options, "mass-erase", endword - options)) { - dfuse_mass_erase = 1; - options += 10; - continue; - } - - /* any valid number is interpreted as upload length */ - number = strtoul(options, &end, 0); - if (end == endword) { - dfuse_length = number; - } else { - errx(EX_IOERR, "Invalid dfuse modifier: %s", options); - } - options = endword; - } -} - -/* DFU_UPLOAD request for DfuSe 1.1a */ -int dfuse_upload(struct dfu_if *dif, const unsigned short length, - unsigned char *data, unsigned short transaction) -{ - int status; - - status = libusb_control_transfer(dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | - LIBUSB_REQUEST_TYPE_CLASS | - LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_UPLOAD, - /* wValue */ transaction, - /* wIndex */ dif->interface, - /* Data */ data, - /* wLength */ length, - DFU_TIMEOUT); - if (status < 0) { - errx(EX_IOERR, "%s: libusb_control_msg returned %d", - __FUNCTION__, status); - } - return status; -} - -/* DFU_DNLOAD request for DfuSe 1.1a */ -int dfuse_download(struct dfu_if *dif, const unsigned short length, - unsigned char *data, unsigned short transaction) -{ - int status; - - status = libusb_control_transfer(dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | - LIBUSB_REQUEST_TYPE_CLASS | - LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DNLOAD, - /* wValue */ transaction, - /* wIndex */ dif->interface, - /* Data */ data, - /* wLength */ length, - DFU_TIMEOUT); - if (status < 0) { - errx(EX_IOERR, "%s: libusb_control_transfer returned %d", - __FUNCTION__, status); - } - return status; -} - -/* DfuSe only commands */ -/* Leaves the device in dfuDNLOAD-IDLE state */ -int dfuse_special_command(struct dfu_if *dif, unsigned int address, - enum dfuse_command command) -{ - const char* dfuse_command_name[] = { "SET_ADDRESS" , "ERASE_PAGE", - "MASS_ERASE", "READ_UNPROTECT"}; - unsigned char buf[5]; - int length; - int ret; - struct dfu_status dst; - int firstpoll = 1; - - if (command == ERASE_PAGE) { - struct memsegment *segment; - int page_size; - - segment = find_segment(mem_layout, address); - if (!segment || !(segment->memtype & DFUSE_ERASABLE)) { - errx(EX_IOERR, "Page at 0x%08x can not be erased", - address); - } - page_size = segment->pagesize; - if (verbose > 1) - printf("Erasing page size %i at address 0x%08x, page " - "starting at 0x%08x\n", page_size, address, - address & ~(page_size - 1)); - buf[0] = 0x41; /* Erase command */ - length = 5; - last_erased_page = address & ~(page_size - 1); - } else if (command == SET_ADDRESS) { - if (verbose > 2) - printf(" Setting address pointer to 0x%08x\n", - address); - buf[0] = 0x21; /* Set Address Pointer command */ - length = 5; - } else if (command == MASS_ERASE) { - buf[0] = 0x41; /* Mass erase command when length = 1 */ - length = 1; - } else if (command == READ_UNPROTECT) { - buf[0] = 0x92; - length = 1; - } else { - errx(EX_IOERR, "Non-supported special command %d", command); - } - buf[1] = address & 0xff; - buf[2] = (address >> 8) & 0xff; - buf[3] = (address >> 16) & 0xff; - buf[4] = (address >> 24) & 0xff; - - ret = dfuse_download(dif, length, buf, 0); - if (ret < 0) { - errx(EX_IOERR, "Error during special command \"%s\" download", - dfuse_command_name[command]); - } - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during special command \"%s\" get_status", - dfuse_command_name[command]); - } - if (firstpoll) { - firstpoll = 0; - if (dst.bState != DFU_STATE_dfuDNBUSY) { - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - errx(EX_IOERR, "Wrong state after command \"%s\" download", - dfuse_command_name[command]); - } - } - /* wait while command is executed */ - if (verbose) - printf(" Poll timeout %i ms\n", dst.bwPollTimeout); - milli_sleep(dst.bwPollTimeout); - if (command == READ_UNPROTECT) - return ret; - } while (dst.bState == DFU_STATE_dfuDNBUSY); - - if (dst.bStatus != DFU_STATUS_OK) { - errx(EX_IOERR, "%s not correctly executed", - dfuse_command_name[command]); - } - return ret; -} - -int dfuse_dnload_chunk(struct dfu_if *dif, unsigned char *data, int size, - int transaction) -{ - int bytes_sent; - struct dfu_status dst; - int ret; - - ret = dfuse_download(dif, size, size ? data : NULL, transaction); - if (ret < 0) { - errx(EX_IOERR, "Error during download"); - return ret; - } - bytes_sent = ret; - - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during download get_status"); - return ret; - } - milli_sleep(dst.bwPollTimeout); - } while (dst.bState != DFU_STATE_dfuDNLOAD_IDLE && - dst.bState != DFU_STATE_dfuERROR && - dst.bState != DFU_STATE_dfuMANIFEST); - - if (dst.bState == DFU_STATE_dfuMANIFEST) - printf("Transitioning to dfuMANIFEST state\n"); - - if (dst.bStatus != DFU_STATUS_OK) { - printf(" failed!\n"); - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - return -1; - } - return bytes_sent; -} - -int dfuse_do_upload(struct dfu_if *dif, int xfer_size, int fd, - const char *dfuse_options) -{ - int total_bytes = 0; - int upload_limit = 0; - unsigned char *buf; - int transaction; - int ret; - - buf = dfu_malloc(xfer_size); - - if (dfuse_options) - dfuse_parse_options(dfuse_options); - if (dfuse_length) - upload_limit = dfuse_length; - if (dfuse_address) { - struct memsegment *segment; - - mem_layout = parse_memory_layout((char *)dif->alt_name); - if (!mem_layout) - errx(EX_IOERR, "Failed to parse memory layout"); - - segment = find_segment(mem_layout, dfuse_address); - if (!dfuse_force && - (!segment || !(segment->memtype & DFUSE_READABLE))) - errx(EX_IOERR, "Page at 0x%08x is not readable", - dfuse_address); - - if (!upload_limit) { - upload_limit = segment->end - dfuse_address + 1; - printf("Limiting upload to end of memory segment, " - "%i bytes\n", upload_limit); - } - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfu_abort_to_idle(dif); - } else { - /* Boot loader decides the start address, unknown to us */ - /* Use a short length to lower risk of running out of bounds */ - if (!upload_limit) - upload_limit = 0x4000; - printf("Limiting default upload to %i bytes\n", upload_limit); - } - - dfu_progress_bar("Upload", 0, 1); - - transaction = 2; - while (1) { - int rc; - - /* last chunk can be smaller than original xfer_size */ - if (upload_limit - total_bytes < xfer_size) - xfer_size = upload_limit - total_bytes; - rc = dfuse_upload(dif, xfer_size, buf, transaction++); - if (rc < 0) { - ret = rc; - goto out_free; - } - - dfu_file_write_crc(fd, 0, buf, rc); - total_bytes += rc; - - if (total_bytes < 0) - errx(EX_SOFTWARE, "Received too many bytes"); - - if (rc < xfer_size || total_bytes >= upload_limit) { - /* last block, return successfully */ - ret = total_bytes; - break; - } - dfu_progress_bar("Upload", total_bytes, upload_limit); - } - - dfu_progress_bar("Upload", total_bytes, total_bytes); - - dfu_abort_to_idle(dif); - if (dfuse_leave) { - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfuse_dnload_chunk(dif, NULL, 0, 2); /* Zero-size */ - } - - out_free: - free(buf); - - return ret; -} - -/* Writes an element of any size to the device, taking care of page erases */ -/* returns 0 on success, otherwise -EINVAL */ -int dfuse_dnload_element(struct dfu_if *dif, unsigned int dwElementAddress, - unsigned int dwElementSize, unsigned char *data, - int xfer_size) -{ - int p; - int ret; - struct memsegment *segment; - - /* Check at least that we can write to the last address */ - segment = - find_segment(mem_layout, dwElementAddress + dwElementSize - 1); - if (!segment || !(segment->memtype & DFUSE_WRITEABLE)) { - errx(EX_IOERR, "Last page at 0x%08x is not writeable", - dwElementAddress + dwElementSize - 1); - } - - dfu_progress_bar("Download", 0, 1); - - for (p = 0; p < (int)dwElementSize; p += xfer_size) { - int page_size; - unsigned int erase_address; - unsigned int address = dwElementAddress + p; - int chunk_size = xfer_size; - - segment = find_segment(mem_layout, address); - if (!segment || !(segment->memtype & DFUSE_WRITEABLE)) { - errx(EX_IOERR, "Page at 0x%08x is not writeable", - address); - } - page_size = segment->pagesize; - - /* check if this is the last chunk */ - if (p + chunk_size > (int)dwElementSize) - chunk_size = dwElementSize - p; - - /* Erase only for flash memory downloads */ - if ((segment->memtype & DFUSE_ERASABLE) && !dfuse_mass_erase) { - /* erase all involved pages */ - for (erase_address = address; - erase_address < address + chunk_size; - erase_address += page_size) - if ((erase_address & ~(page_size - 1)) != - last_erased_page) - dfuse_special_command(dif, - erase_address, - ERASE_PAGE); - - if (((address + chunk_size - 1) & ~(page_size - 1)) != - last_erased_page) { - if (verbose > 2) - printf(" Chunk extends into next page," - " erase it as well\n"); - dfuse_special_command(dif, - address + chunk_size - 1, - ERASE_PAGE); - } - } - - if (verbose) { - printf(" Download from image offset " - "%08x to memory %08x-%08x, size %i\n", - p, address, address + chunk_size - 1, - chunk_size); - } else { - dfu_progress_bar("Download", p, dwElementSize); - } - - dfuse_special_command(dif, address, SET_ADDRESS); - - /* transaction = 2 for no address offset */ - ret = dfuse_dnload_chunk(dif, data + p, chunk_size, 2); - if (ret != chunk_size) { - errx(EX_IOERR, "Failed to write whole chunk: " - "%i of %i bytes", ret, chunk_size); - return -EINVAL; - } - } - if (!verbose) - dfu_progress_bar("Download", dwElementSize, dwElementSize); - return 0; -} - -static void -dfuse_memcpy(unsigned char *dst, unsigned char **src, int *rem, int size) -{ - if (size > *rem) { - errx(EX_IOERR, "Corrupt DfuSe file: " - "Cannot read %d bytes from %d bytes", size, *rem); - } - if (dst != NULL) - memcpy(dst, *src, size); - (*src) += size; - (*rem) -= size; -} - -/* Download raw binary file to DfuSe device */ -int dfuse_do_bin_dnload(struct dfu_if *dif, int xfer_size, - struct dfu_file *file, unsigned int start_address) -{ - unsigned int dwElementAddress; - unsigned int dwElementSize; - unsigned char *data; - int ret; - - dwElementAddress = start_address; - dwElementSize = file->size.total - - file->size.suffix - file->size.prefix; - - printf("Downloading to address = 0x%08x, size = %i\n", - dwElementAddress, dwElementSize); - - data = file->firmware + file->size.prefix; - - ret = dfuse_dnload_element(dif, dwElementAddress, dwElementSize, data, - xfer_size); - if (ret != 0) - goto out_free; - - printf("File downloaded successfully\n"); - ret = dwElementSize; - - out_free: - return ret; -} - -/* Parse a DfuSe file and download contents to device */ -int dfuse_do_dfuse_dnload(struct dfu_if *dif, int xfer_size, - struct dfu_file *file) -{ - uint8_t dfuprefix[11]; - uint8_t targetprefix[274]; - uint8_t elementheader[8]; - int image; - int element; - int bTargets; - int bAlternateSetting; - int dwNbElements; - unsigned int dwElementAddress; - unsigned int dwElementSize; - uint8_t *data; - int ret; - int rem; - int bFirstAddressSaved = 0; - - rem = file->size.total - file->size.prefix - file->size.suffix; - data = file->firmware + file->size.prefix; - - /* Must be larger than a minimal DfuSe header and suffix */ - if (rem < (int)(sizeof(dfuprefix) + - sizeof(targetprefix) + sizeof(elementheader))) { - errx(EX_SOFTWARE, "File too small for a DfuSe file"); - } - - dfuse_memcpy(dfuprefix, &data, &rem, sizeof(dfuprefix)); - - if (strncmp((char *)dfuprefix, "DfuSe", 5)) { - errx(EX_IOERR, "No valid DfuSe signature"); - return -EINVAL; - } - if (dfuprefix[5] != 0x01) { - errx(EX_IOERR, "DFU format revision %i not supported", - dfuprefix[5]); - return -EINVAL; - } - bTargets = dfuprefix[10]; - printf("file contains %i DFU images\n", bTargets); - - for (image = 1; image <= bTargets; image++) { - printf("parsing DFU image %i\n", image); - dfuse_memcpy(targetprefix, &data, &rem, sizeof(targetprefix)); - if (strncmp((char *)targetprefix, "Target", 6)) { - errx(EX_IOERR, "No valid target signature"); - return -EINVAL; - } - bAlternateSetting = targetprefix[6]; - dwNbElements = quad2uint((unsigned char *)targetprefix + 270); - printf("image for alternate setting %i, ", bAlternateSetting); - printf("(%i elements, ", dwNbElements); - printf("total size = %i)\n", - quad2uint((unsigned char *)targetprefix + 266)); - if (bAlternateSetting != dif->altsetting) - printf("Warning: Image does not match current alternate" - " setting.\n" - "Please rerun with the correct -a option setting" - " to download this image!\n"); - for (element = 1; element <= dwNbElements; element++) { - printf("parsing element %i, ", element); - dfuse_memcpy(elementheader, &data, &rem, sizeof(elementheader)); - dwElementAddress = - quad2uint((unsigned char *)elementheader); - dwElementSize = - quad2uint((unsigned char *)elementheader + 4); - printf("address = 0x%08x, ", dwElementAddress); - printf("size = %i\n", dwElementSize); - - if (!bFirstAddressSaved) { - bFirstAddressSaved = 1; - dfuse_address = dwElementAddress; - } - /* sanity check */ - if ((int)dwElementSize > rem) - errx(EX_SOFTWARE, "File too small for element size"); - - if (bAlternateSetting == dif->altsetting) { - ret = dfuse_dnload_element(dif, dwElementAddress, - dwElementSize, data, xfer_size); - } else { - ret = 0; - } - - /* advance read pointer */ - dfuse_memcpy(NULL, &data, &rem, dwElementSize); - - if (ret != 0) - return ret; - } - } - - if (rem != 0) - warnx("%d bytes leftover", rem); - - printf("done parsing DfuSe file\n"); - - return 0; -} - -int dfuse_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file, - const char *dfuse_options) -{ - int ret; - - if (dfuse_options) - dfuse_parse_options(dfuse_options); - mem_layout = parse_memory_layout((char *)dif->alt_name); - if (!mem_layout) { - errx(EX_IOERR, "Failed to parse memory layout"); - } - if (dfuse_unprotect) { - if (!dfuse_force) { - errx(EX_IOERR, "The read unprotect command " - "will erase the flash memory" - "and can only be used with force\n"); - } - dfuse_special_command(dif, 0, READ_UNPROTECT); - printf("Device disconnects, erases flash and resets now\n"); - exit(0); - } - if (dfuse_mass_erase) { - if (!dfuse_force) { - errx(EX_IOERR, "The mass erase command " - "can only be used with force"); - } - printf("Performing mass erase, this can take a moment\n"); - dfuse_special_command(dif, 0, MASS_ERASE); - } - if (dfuse_address) { - if (file->bcdDFU == 0x11a) { - errx(EX_IOERR, "This is a DfuSe file, not " - "meant for raw download"); - } - ret = dfuse_do_bin_dnload(dif, xfer_size, file, dfuse_address); - } else { - if (file->bcdDFU != 0x11a) { - warnx("Only DfuSe file version 1.1a is supported"); - errx(EX_IOERR, "(for raw binary download, use the " - "--dfuse-address option)"); - } - ret = dfuse_do_dfuse_dnload(dif, xfer_size, file); - } - free_segment_list(mem_layout); - - dfu_abort_to_idle(dif); - - if (dfuse_leave) { - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfuse_dnload_chunk(dif, NULL, 0, 2); /* Zero-size */ - } - return ret; -} diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse.h b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse.h deleted file mode 100755 index ed1108cfc..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse.h +++ /dev/null @@ -1,35 +0,0 @@ -/* This implements the ST Microsystems DFU extensions (DfuSe) - * as per the DfuSe 1.1a specification (Document UM0391) - * - * (C) 2010-2012 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFUSE_H -#define DFUSE_H - -#include "dfu.h" - -enum dfuse_command { SET_ADDRESS, ERASE_PAGE, MASS_ERASE, READ_UNPROTECT }; - -int dfuse_special_command(struct dfu_if *dif, unsigned int address, - enum dfuse_command command); -int dfuse_do_upload(struct dfu_if *dif, int xfer_size, int fd, - const char *dfuse_options); -int dfuse_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file, - const char *dfuse_options); - -#endif /* DFUSE_H */ diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse_mem.c b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse_mem.c deleted file mode 100755 index a91aacf5f..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse_mem.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Helper functions for reading the memory map of a device - * following the ST DfuSe 1.1a specification. - * - * Copyright 2011-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" -#include "dfuse_mem.h" - -int add_segment(struct memsegment **segment_list, struct memsegment segment) -{ - struct memsegment *new_element; - - new_element = dfu_malloc(sizeof(struct memsegment)); - *new_element = segment; - new_element->next = NULL; - - if (*segment_list == NULL) - /* list can be empty on first call */ - *segment_list = new_element; - else { - struct memsegment *next_element; - - /* find last element in list */ - next_element = *segment_list; - while (next_element->next != NULL) - next_element = next_element->next; - next_element->next = new_element; - } - return 0; -} - -struct memsegment *find_segment(struct memsegment *segment_list, - unsigned int address) -{ - while (segment_list != NULL) { - if (segment_list->start <= address && - segment_list->end >= address) - return segment_list; - segment_list = segment_list->next; - } - return NULL; -} - -void free_segment_list(struct memsegment *segment_list) -{ - struct memsegment *next_element; - - while (segment_list->next != NULL) { - next_element = segment_list->next; - free(segment_list); - segment_list = next_element; - } - free(segment_list); -} - -/* Parse memory map from interface descriptor string - * encoded as per ST document UM0424 section 4.3.2. - */ -struct memsegment *parse_memory_layout(char *intf_desc) -{ - - char multiplier, memtype; - unsigned int address; - int sectors, size; - char *name, *typestring; - int ret; - int count = 0; - char separator; - int scanned; - struct memsegment *segment_list = NULL; - struct memsegment segment; - - name = dfu_malloc(strlen(intf_desc)); - - ret = sscanf(intf_desc, "@%[^/]%n", name, &scanned); - if (ret < 1) { - free(name); - warnx("Could not read name, sscanf returned %d", ret); - return NULL; - } - printf("DfuSe interface name: \"%s\"\n", name); - - intf_desc += scanned; - typestring = dfu_malloc(strlen(intf_desc)); - - while (ret = sscanf(intf_desc, "/0x%x/%n", &address, &scanned), - ret > 0) { - - intf_desc += scanned; - while (ret = sscanf(intf_desc, "%d*%d%c%[^,/]%n", - §ors, &size, &multiplier, typestring, - &scanned), ret > 2) { - intf_desc += scanned; - - count++; - memtype = 0; - if (ret == 4) { - if (strlen(typestring) == 1 - && typestring[0] != '/') - memtype = typestring[0]; - else { - warnx("Parsing type identifier '%s' " - "failed for segment %i", - typestring, count); - continue; - } - } - - /* Quirk for STM32F4 devices */ - if (strcmp(name, "Device Feature") == 0) - memtype = 'e'; - - switch (multiplier) { - case 'B': - break; - case 'K': - size *= 1024; - break; - case 'M': - size *= 1024 * 1024; - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - if (!memtype) { - warnx("Non-valid multiplier '%c', " - "interpreted as type " - "identifier instead", - multiplier); - memtype = multiplier; - break; - } - /* fallthrough if memtype was already set */ - default: - warnx("Non-valid multiplier '%c', " - "assuming bytes", multiplier); - } - - if (!memtype) { - warnx("No valid type for segment %d\n", count); - continue; - } - - segment.start = address; - segment.end = address + sectors * size - 1; - segment.pagesize = size; - segment.memtype = memtype & 7; - add_segment(&segment_list, segment); - - if (verbose) - printf("Memory segment at 0x%08x %3d x %4d = " - "%5d (%s%s%s)\n", - address, sectors, size, sectors * size, - memtype & DFUSE_READABLE ? "r" : "", - memtype & DFUSE_ERASABLE ? "e" : "", - memtype & DFUSE_WRITEABLE ? "w" : ""); - - address += sectors * size; - - separator = *intf_desc; - if (separator == ',') - intf_desc += 1; - else - break; - } /* while per segment */ - - } /* while per address */ - free(name); - free(typestring); - - return segment_list; -} diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse_mem.h b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse_mem.h deleted file mode 100755 index 0181f0c16..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/dfuse_mem.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Helper functions for reading the memory map in a device - * following the ST DfuSe 1.1a specification. - * - * (C) 2011 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFUSE_MEM_H -#define DFUSE_MEM_H - -#define DFUSE_READABLE 1 -#define DFUSE_ERASABLE 2 -#define DFUSE_WRITEABLE 4 - -struct memsegment { - unsigned int start; - unsigned int end; - int pagesize; - int memtype; - struct memsegment *next; -}; - -int add_segment(struct memsegment **list, struct memsegment new_element); - -struct memsegment *find_segment(struct memsegment *list, unsigned int address); - -void free_segment_list(struct memsegment *list); - -struct memsegment *parse_memory_layout(char *intf_desc_str); - -#endif /* DFUSE_MEM_H */ diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/main.c b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/main.c deleted file mode 100755 index acaed2f08..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/main.c +++ /dev/null @@ -1,699 +0,0 @@ -/* - * dfu-util - * - * Copyright 2007-2008 by OpenMoko, Inc. - * Copyright 2013-2014 Hans Petter Selasky - * - * Written by Harald Welte - * - * Based on existing code of dfu-programmer-0.4 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "dfu_util.h" -#include "dfuse.h" -#include "quirks.h" - -#ifdef HAVE_USBPATH_H -#include -#endif - -int verbose = 0; - -struct dfu_if *dfu_root = NULL; - -int match_bus = -1; -int match_device = -1; -int match_vendor = -1; -int match_product = -1; -int match_vendor_dfu = -1; -int match_product_dfu = -1; -int match_config_index = -1; -int match_iface_index = -1; -int match_iface_alt_index = -1; -const char *match_iface_alt_name = NULL; -const char *match_serial = NULL; -const char *match_serial_dfu = NULL; - -static int parse_match_value(const char *str, int default_value) -{ - char *remainder; - int value; - - if (str == NULL) { - value = default_value; - } else if (*str == '*') { - value = -1; /* Match anything */ - } else if (*str == '-') { - value = 0x10000; /* Impossible vendor/product ID */ - } else { - value = strtoul(str, &remainder, 16); - if (remainder == str) { - value = default_value; - } - } - return value; -} - -static void parse_vendprod(const char *str) -{ - const char *comma; - const char *colon; - - /* Default to match any DFU device in runtime or DFU mode */ - match_vendor = -1; - match_product = -1; - match_vendor_dfu = -1; - match_product_dfu = -1; - - comma = strchr(str, ','); - if (comma == str) { - /* DFU mode vendor/product being specified without any runtime - * vendor/product specification, so don't match any runtime device */ - match_vendor = match_product = 0x10000; - } else { - colon = strchr(str, ':'); - if (colon != NULL) { - ++colon; - if ((comma != NULL) && (colon > comma)) { - colon = NULL; - } - } - match_vendor = parse_match_value(str, match_vendor); - match_product = parse_match_value(colon, match_product); - if (comma != NULL) { - /* Both runtime and DFU mode vendor/product specifications are - * available, so default DFU mode match components to the given - * runtime match components */ - match_vendor_dfu = match_vendor; - match_product_dfu = match_product; - } - } - if (comma != NULL) { - ++comma; - colon = strchr(comma, ':'); - if (colon != NULL) { - ++colon; - } - match_vendor_dfu = parse_match_value(comma, match_vendor_dfu); - match_product_dfu = parse_match_value(colon, match_product_dfu); - } -} - -static void parse_serial(char *str) -{ - char *comma; - - match_serial = str; - comma = strchr(str, ','); - if (comma == NULL) { - match_serial_dfu = match_serial; - } else { - *comma++ = 0; - match_serial_dfu = comma; - } - if (*match_serial == 0) match_serial = NULL; - if (*match_serial_dfu == 0) match_serial_dfu = NULL; -} - -#ifdef HAVE_USBPATH_H - -static int resolve_device_path(char *path) -{ - int res; - - res = usb_path2devnum(path); - if (res < 0) - return -EINVAL; - if (!res) - return 0; - - match_bus = atoi(path); - match_device = res; - - return 0; -} - -#else /* HAVE_USBPATH_H */ - -static int resolve_device_path(char *path) -{ - (void)path; /* Eliminate unused variable warning */ - errx(EX_SOFTWARE, "USB device paths are not supported by this dfu-util.\n"); -} - -#endif /* !HAVE_USBPATH_H */ - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-util [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -v --verbose\t\t\tPrint verbose debug statements\n" - " -l --list\t\t\tList currently attached DFU capable devices\n"); - fprintf(stderr, " -e --detach\t\t\tDetach currently attached DFU capable devices\n" - " -E --detach-delay seconds\tTime to wait before reopening a device after detach\n" - " -d --device :[,:]\n" - "\t\t\t\tSpecify Vendor/Product ID(s) of DFU device\n" - " -p --path \tSpecify path to DFU device\n" - " -c --cfg \t\tSpecify the Configuration of DFU device\n" - " -i --intf \t\tSpecify the DFU Interface number\n" - " -S --serial [,]\n" - "\t\t\t\tSpecify Serial String of DFU device\n" - " -a --alt \t\tSpecify the Altsetting of the DFU Interface\n" - "\t\t\t\tby name or by number\n"); - fprintf(stderr, " -t --transfer-size \tSpecify the number of bytes per USB Transfer\n" - " -U --upload \t\tRead firmware from device into \n" - " -Z --upload-size \tSpecify the expected upload size in bytes\n" - " -D --download \t\tWrite firmware from into device\n" - " -R --reset\t\t\tIssue USB Reset signalling once we're finished\n" - " -s --dfuse-address
\tST DfuSe mode, specify target address for\n" - "\t\t\t\traw file download or upload. Not applicable for\n" - "\t\t\t\tDfuSe file (.dfu) downloads\n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf(PACKAGE_STRING "\n\n"); - printf("Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.\n" - "Copyright 2010-2014 Tormod Volden and Stefan Schmidt\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to " PACKAGE_BUGREPORT "\n\n"); -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "verbose", 0, 0, 'v' }, - { "list", 0, 0, 'l' }, - { "detach", 0, 0, 'e' }, - { "detach-delay", 1, 0, 'E' }, - { "device", 1, 0, 'd' }, - { "path", 1, 0, 'p' }, - { "configuration", 1, 0, 'c' }, - { "cfg", 1, 0, 'c' }, - { "interface", 1, 0, 'i' }, - { "intf", 1, 0, 'i' }, - { "altsetting", 1, 0, 'a' }, - { "alt", 1, 0, 'a' }, - { "serial", 1, 0, 'S' }, - { "transfer-size", 1, 0, 't' }, - { "upload", 1, 0, 'U' }, - { "upload-size", 1, 0, 'Z' }, - { "download", 1, 0, 'D' }, - { "reset", 0, 0, 'R' }, - { "dfuse-address", 1, 0, 's' }, - { 0, 0, 0, 0 } -}; - -int main(int argc, char **argv) -{ - int expected_size = 0; - unsigned int transfer_size = 0; - enum mode mode = MODE_NONE; - struct dfu_status status; - libusb_context *ctx; - struct dfu_file file; - char *end; - int final_reset = 0; - int ret; - int dfuse_device = 0; - int fd; - const char *dfuse_options = NULL; - int detach_delay = 5; - uint16_t runtime_vendor; - uint16_t runtime_product; - - memset(&file, 0, sizeof(file)); - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVvleE:d:p:c:i:a:S:t:U:D:Rs:Z:", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - mode = MODE_VERSION; - break; - case 'v': - verbose++; - break; - case 'l': - mode = MODE_LIST; - break; - case 'e': - mode = MODE_DETACH; - match_iface_alt_index = 0; - match_iface_index = 0; - break; - case 'E': - detach_delay = atoi(optarg); - break; - case 'd': - parse_vendprod(optarg); - break; - case 'p': - /* Parse device path */ - ret = resolve_device_path(optarg); - if (ret < 0) - errx(EX_SOFTWARE, "Unable to parse '%s'", optarg); - if (!ret) - errx(EX_SOFTWARE, "Cannot find '%s'", optarg); - break; - case 'c': - /* Configuration */ - match_config_index = atoi(optarg); - break; - case 'i': - /* Interface */ - match_iface_index = atoi(optarg); - break; - case 'a': - /* Interface Alternate Setting */ - match_iface_alt_index = strtoul(optarg, &end, 0); - if (*end) { - match_iface_alt_name = optarg; - match_iface_alt_index = -1; - } - break; - case 'S': - parse_serial(optarg); - break; - case 't': - transfer_size = atoi(optarg); - break; - case 'U': - mode = MODE_UPLOAD; - file.name = optarg; - break; - case 'Z': - expected_size = atoi(optarg); - break; - case 'D': - mode = MODE_DOWNLOAD; - file.name = optarg; - break; - case 'R': - final_reset = 1; - break; - case 's': - dfuse_options = optarg; - break; - default: - help(); - break; - } - } - - print_version(); - if (mode == MODE_VERSION) { - exit(0); - } - - if (mode == MODE_NONE) { - fprintf(stderr, "You need to specify one of -D or -U\n"); - help(); - } - - if (match_config_index == 0) { - /* Handle "-c 0" (unconfigured device) as don't care */ - match_config_index = -1; - } - - if (mode == MODE_DOWNLOAD) { - dfu_load_file(&file, MAYBE_SUFFIX, MAYBE_PREFIX); - /* If the user didn't specify product and/or vendor IDs to match, - * use any IDs from the file suffix for device matching */ - if (match_vendor < 0 && file.idVendor != 0xffff) { - match_vendor = file.idVendor; - printf("Match vendor ID from file: %04x\n", match_vendor); - } - if (match_product < 0 && file.idProduct != 0xffff) { - match_product = file.idProduct; - printf("Match product ID from file: %04x\n", match_product); - } - } - - ret = libusb_init(&ctx); - if (ret) - errx(EX_IOERR, "unable to initialize libusb: %i", ret); - - if (verbose > 2) { - libusb_set_debug(ctx, 255); - } - - probe_devices(ctx); - - if (mode == MODE_LIST) { - list_dfu_interfaces(); - exit(0); - } - - if (dfu_root == NULL) { - errx(EX_IOERR, "No DFU capable USB device available"); - } else if (dfu_root->next != NULL) { - /* We cannot safely support more than one DFU capable device - * with same vendor/product ID, since during DFU we need to do - * a USB bus reset, after which the target device will get a - * new address */ - errx(EX_IOERR, "More than one DFU capable USB device found! " - "Try `--list' and specify the serial number " - "or disconnect all but one device\n"); - } - - /* We have exactly one device. Its libusb_device is now in dfu_root->dev */ - - printf("Opening DFU capable USB device...\n"); - ret = libusb_open(dfu_root->dev, &dfu_root->dev_handle); - if (ret || !dfu_root->dev_handle) - errx(EX_IOERR, "Cannot open device"); - - printf("ID %04x:%04x\n", dfu_root->vendor, dfu_root->product); - - printf("Run-time device DFU version %04x\n", - libusb_le16_to_cpu(dfu_root->func_dfu.bcdDFUVersion)); - - /* Transition from run-Time mode to DFU mode */ - if (!(dfu_root->flags & DFU_IFF_DFU)) { - int err; - /* In the 'first round' during runtime mode, there can only be one - * DFU Interface descriptor according to the DFU Spec. */ - - /* FIXME: check if the selected device really has only one */ - - runtime_vendor = dfu_root->vendor; - runtime_product = dfu_root->product; - - printf("Claiming USB DFU Runtime Interface...\n"); - if (libusb_claim_interface(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "Cannot claim interface %d", - dfu_root->interface); - } - - if (libusb_set_interface_alt_setting(dfu_root->dev_handle, dfu_root->interface, 0) < 0) { - errx(EX_IOERR, "Cannot set alt interface zero"); - } - - printf("Determining device status: "); - - err = dfu_get_status(dfu_root, &status); - if (err == LIBUSB_ERROR_PIPE) { - printf("Device does not implement get_status, assuming appIDLE\n"); - status.bStatus = DFU_STATUS_OK; - status.bwPollTimeout = 0; - status.bState = DFU_STATE_appIDLE; - status.iString = 0; - } else if (err < 0) { - errx(EX_IOERR, "error get_status"); - } else { - printf("state = %s, status = %d\n", - dfu_state_to_string(status.bState), status.bStatus); - } - milli_sleep(status.bwPollTimeout); - - switch (status.bState) { - case DFU_STATE_appIDLE: - case DFU_STATE_appDETACH: - printf("Device really in Runtime Mode, send DFU " - "detach request...\n"); - if (dfu_detach(dfu_root->dev_handle, - dfu_root->interface, 1000) < 0) { - warnx("error detaching"); - } - if (dfu_root->func_dfu.bmAttributes & USB_DFU_WILL_DETACH) { - printf("Device will detach and reattach...\n"); - } else { - printf("Resetting USB...\n"); - ret = libusb_reset_device(dfu_root->dev_handle); - if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) - errx(EX_IOERR, "error resetting " - "after detach"); - } - break; - case DFU_STATE_dfuERROR: - printf("dfuERROR, clearing status\n"); - if (dfu_clear_status(dfu_root->dev_handle, - dfu_root->interface) < 0) { - errx(EX_IOERR, "error clear_status"); - } - /* fall through */ - default: - warnx("WARNING: Runtime device already in DFU state ?!?"); - libusb_release_interface(dfu_root->dev_handle, - dfu_root->interface); - goto dfustate; - } - libusb_release_interface(dfu_root->dev_handle, - dfu_root->interface); - libusb_close(dfu_root->dev_handle); - dfu_root->dev_handle = NULL; - - if (mode == MODE_DETACH) { - libusb_exit(ctx); - exit(0); - } - - /* keeping handles open might prevent re-enumeration */ - disconnect_devices(); - - milli_sleep(detach_delay * 1000); - - /* Change match vendor and product to impossible values to force - * only DFU mode matches in the following probe */ - match_vendor = match_product = 0x10000; - - probe_devices(ctx); - - if (dfu_root == NULL) { - errx(EX_IOERR, "Lost device after RESET?"); - } else if (dfu_root->next != NULL) { - errx(EX_IOERR, "More than one DFU capable USB device found! " - "Try `--list' and specify the serial number " - "or disconnect all but one device"); - } - - /* Check for DFU mode device */ - if (!(dfu_root->flags | DFU_IFF_DFU)) - errx(EX_SOFTWARE, "Device is not in DFU mode"); - - printf("Opening DFU USB Device...\n"); - ret = libusb_open(dfu_root->dev, &dfu_root->dev_handle); - if (ret || !dfu_root->dev_handle) { - errx(EX_IOERR, "Cannot open device"); - } - } else { - /* we're already in DFU mode, so we can skip the detach/reset - * procedure */ - /* If a match vendor/product was specified, use that as the runtime - * vendor/product, otherwise use the DFU mode vendor/product */ - runtime_vendor = match_vendor < 0 ? dfu_root->vendor : match_vendor; - runtime_product = match_product < 0 ? dfu_root->product : match_product; - } - -dfustate: -#if 0 - printf("Setting Configuration %u...\n", dfu_root->configuration); - if (libusb_set_configuration(dfu_root->dev_handle, dfu_root->configuration) < 0) { - errx(EX_IOERR, "Cannot set configuration"); - } -#endif - printf("Claiming USB DFU Interface...\n"); - if (libusb_claim_interface(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "Cannot claim interface"); - } - - printf("Setting Alternate Setting #%d ...\n", dfu_root->altsetting); - if (libusb_set_interface_alt_setting(dfu_root->dev_handle, dfu_root->interface, dfu_root->altsetting) < 0) { - errx(EX_IOERR, "Cannot set alternate interface"); - } - -status_again: - printf("Determining device status: "); - if (dfu_get_status(dfu_root, &status ) < 0) { - errx(EX_IOERR, "error get_status"); - } - printf("state = %s, status = %d\n", - dfu_state_to_string(status.bState), status.bStatus); - - milli_sleep(status.bwPollTimeout); - - switch (status.bState) { - case DFU_STATE_appIDLE: - case DFU_STATE_appDETACH: - errx(EX_IOERR, "Device still in Runtime Mode!"); - break; - case DFU_STATE_dfuERROR: - printf("dfuERROR, clearing status\n"); - if (dfu_clear_status(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "error clear_status"); - } - goto status_again; - break; - case DFU_STATE_dfuDNLOAD_IDLE: - case DFU_STATE_dfuUPLOAD_IDLE: - printf("aborting previous incomplete transfer\n"); - if (dfu_abort(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "can't send DFU_ABORT"); - } - goto status_again; - break; - case DFU_STATE_dfuIDLE: - printf("dfuIDLE, continuing\n"); - break; - default: - break; - } - - if (DFU_STATUS_OK != status.bStatus ) { - printf("WARNING: DFU Status: '%s'\n", - dfu_status_to_string(status.bStatus)); - /* Clear our status & try again. */ - if (dfu_clear_status(dfu_root->dev_handle, dfu_root->interface) < 0) - errx(EX_IOERR, "USB communication error"); - if (dfu_get_status(dfu_root, &status) < 0) - errx(EX_IOERR, "USB communication error"); - if (DFU_STATUS_OK != status.bStatus) - errx(EX_SOFTWARE, "Status is not OK: %d", status.bStatus); - - milli_sleep(status.bwPollTimeout); - } - - printf("DFU mode device DFU version %04x\n", - libusb_le16_to_cpu(dfu_root->func_dfu.bcdDFUVersion)); - - if (dfu_root->func_dfu.bcdDFUVersion == libusb_cpu_to_le16(0x11a)) - dfuse_device = 1; - - /* If not overridden by the user */ - if (!transfer_size) { - transfer_size = libusb_le16_to_cpu( - dfu_root->func_dfu.wTransferSize); - if (transfer_size) { - printf("Device returned transfer size %i\n", - transfer_size); - } else { - errx(EX_IOERR, "Transfer size must be specified"); - } - } - -#ifdef HAVE_GETPAGESIZE -/* autotools lie when cross-compiling for Windows using mingw32/64 */ -#ifndef __MINGW32__ - /* limitation of Linux usbdevio */ - if ((int)transfer_size > getpagesize()) { - transfer_size = getpagesize(); - printf("Limited transfer size to %i\n", transfer_size); - } -#endif /* __MINGW32__ */ -#endif /* HAVE_GETPAGESIZE */ - - if (transfer_size < dfu_root->bMaxPacketSize0) { - transfer_size = dfu_root->bMaxPacketSize0; - printf("Adjusted transfer size to %i\n", transfer_size); - } - - switch (mode) { - case MODE_UPLOAD: - /* open for "exclusive" writing */ - fd = open(file.name, O_WRONLY | O_BINARY | O_CREAT | O_EXCL | O_TRUNC, 0666); - if (fd < 0) - err(EX_IOERR, "Cannot open file %s for writing", file.name); - - if (dfuse_device || dfuse_options) { - if (dfuse_do_upload(dfu_root, transfer_size, fd, - dfuse_options) < 0) - exit(1); - } else { - if (dfuload_do_upload(dfu_root, transfer_size, - expected_size, fd) < 0) { - exit(1); - } - } - close(fd); - break; - - case MODE_DOWNLOAD: - if (((file.idVendor != 0xffff && file.idVendor != runtime_vendor) || - (file.idProduct != 0xffff && file.idProduct != runtime_product)) && - ((file.idVendor != 0xffff && file.idVendor != dfu_root->vendor) || - (file.idProduct != 0xffff && file.idProduct != dfu_root->product))) { - errx(EX_IOERR, "Error: File ID %04x:%04x does " - "not match device (%04x:%04x or %04x:%04x)", - file.idVendor, file.idProduct, - runtime_vendor, runtime_product, - dfu_root->vendor, dfu_root->product); - } - if (dfuse_device || dfuse_options || file.bcdDFU == 0x11a) { - if (dfuse_do_dnload(dfu_root, transfer_size, &file, - dfuse_options) < 0) - exit(1); - } else { - if (dfuload_do_dnload(dfu_root, transfer_size, &file) < 0) - exit(1); - } - break; - case MODE_DETACH: - if (dfu_detach(dfu_root->dev_handle, dfu_root->interface, 1000) < 0) { - warnx("can't detach"); - } - break; - default: - errx(EX_IOERR, "Unsupported mode: %u", mode); - break; - } - - if (final_reset) { - if (dfu_detach(dfu_root->dev_handle, dfu_root->interface, 1000) < 0) { - /* Even if detach failed, just carry on to leave the - device in a known state */ - warnx("can't detach"); - } - printf("Resetting USB to switch back to runtime mode\n"); - ret = libusb_reset_device(dfu_root->dev_handle); - if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) { - errx(EX_IOERR, "error resetting after download"); - } - } - - libusb_close(dfu_root->dev_handle); - dfu_root->dev_handle = NULL; - libusb_exit(ctx); - - return (0); -} diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/portable.h b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/portable.h deleted file mode 100755 index cf8d5df38..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/portable.h +++ /dev/null @@ -1,72 +0,0 @@ - -#ifndef PORTABLE_H -#define PORTABLE_H - -#ifdef HAVE_CONFIG_H -# include "config.h" -#else -# define PACKAGE "dfu-util" -# define PACKAGE_VERSION "0.8-msvc" -# define PACKAGE_STRING "dfu-util 0.8-msvc" -# define PACKAGE_BUGREPORT "dfu-util@lists.gnumonks.org" -#endif /* HAVE_CONFIG_H */ - -#ifdef HAVE_FTRUNCATE -# include -#else -# include -#endif /* HAVE_FTRUNCATE */ - -#ifdef HAVE_NANOSLEEP -# include -# define milli_sleep(msec) do {\ - if (msec) {\ - struct timespec nanosleepDelay = { (msec) / 1000, ((msec) % 1000) * 1000000 };\ - nanosleep(&nanosleepDelay, NULL);\ - } } while (0) -#elif defined HAVE_WINDOWS_H -# define milli_sleep(msec) do {\ - if (msec) {\ - Sleep(msec);\ - } } while (0) -#else -# error "Can't get no sleep! Please report" -#endif /* HAVE_NANOSLEEP */ - -#ifdef HAVE_ERR -# include -#else -# include -# include -# define warnx(...) do {\ - fprintf(stderr, __VA_ARGS__);\ - fprintf(stderr, "\n"); } while (0) -# define errx(eval, ...) do {\ - warnx(__VA_ARGS__);\ - exit(eval); } while (0) -# define warn(...) do {\ - fprintf(stderr, "%s: ", strerror(errno));\ - warnx(__VA_ARGS__); } while (0) -# define err(eval, ...) do {\ - warn(__VA_ARGS__);\ - exit(eval); } while (0) -#endif /* HAVE_ERR */ - -#ifdef HAVE_SYSEXITS_H -# include -#else -# define EX_OK 0 /* successful termination */ -# define EX_USAGE 64 /* command line usage error */ -# define EX_SOFTWARE 70 /* internal software error */ -# define EX_IOERR 74 /* input/output error */ -#endif /* HAVE_SYSEXITS_H */ - -#ifndef O_BINARY -# define O_BINARY 0 -#endif - -#ifndef off_t -# define off_t long int -#endif - -#endif /* PORTABLE_H */ diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/prefix.c b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/prefix.c deleted file mode 100755 index be8e3faf3..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/prefix.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * dfu-prefix - * - * Copyright 2011-2012 Stefan Schmidt - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Uwe Bonnes - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -enum mode { - MODE_NONE, - MODE_ADD, - MODE_DEL, - MODE_CHECK -}; - -int verbose; - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-prefix [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -c --check \t\tCheck DFU prefix of \n" - " -D --delete \t\tDelete DFU prefix from \n" - " -a --add \t\tAdd DFU prefix to \n" - "In combination with -a:\n" - ); - fprintf(stderr, " -s --stellaris-address
Add TI Stellaris address prefix to \n" - "In combination with -D or -c:\n" - " -T --stellaris\t\tAct on TI Stellaris address prefix of \n" - "In combination with -a or -D or -c:\n" - " -L --lpc-prefix\t\tUse NXP LPC DFU prefix format\n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf("dfu-prefix (%s) %s\n\n", PACKAGE, PACKAGE_VERSION); - printf("Copyright 2011-2012 Stefan Schmidt, 2014 Uwe Bonnes\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to %s\n\n", PACKAGE_BUGREPORT); - -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "check", 1, 0, 'c' }, - { "add", 1, 0, 'a' }, - { "delete", 1, 0, 'D' }, - { "stellaris-address", 1, 0, 's' }, - { "stellaris", 0, 0, 'T' }, - { "LPC", 0, 0, 'L' }, -}; -int main(int argc, char **argv) -{ - struct dfu_file file; - enum mode mode = MODE_NONE; - enum prefix_type type = ZERO_PREFIX; - uint32_t lmdfu_flash_address = 0; - char *end; - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - print_version(); - - memset(&file, 0, sizeof(file)); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVc:a:D:p:v:d:s:TL", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - exit(0); - break; - case 'D': - file.name = optarg; - mode = MODE_DEL; - break; - case 'c': - file.name = optarg; - mode = MODE_CHECK; - break; - case 'a': - file.name = optarg; - mode = MODE_ADD; - break; - case 's': - lmdfu_flash_address = strtoul(optarg, &end, 0); - if (*end) { - errx(EX_IOERR, "Invalid lmdfu " - "address: %s", optarg); - } - /* fall-through */ - case 'T': - type = LMDFU_PREFIX; - break; - case 'L': - type = LPCDFU_UNENCRYPTED_PREFIX; - break; - default: - help(); - break; - } - } - - if (!file.name) { - fprintf(stderr, "You need to specify a filename\n"); - help(); - } - - switch(mode) { - case MODE_ADD: - if (type == ZERO_PREFIX) - errx(EX_IOERR, "Prefix type must be specified"); - dfu_load_file(&file, MAYBE_SUFFIX, NO_PREFIX); - file.lmdfu_address = lmdfu_flash_address; - file.prefix_type = type; - printf("Adding prefix to file\n"); - dfu_store_file(&file, file.size.suffix != 0, 1); - break; - - case MODE_CHECK: - dfu_load_file(&file, MAYBE_SUFFIX, MAYBE_PREFIX); - show_suffix_and_prefix(&file); - if (type > ZERO_PREFIX && file.prefix_type != type) - errx(EX_IOERR, "No prefix of requested type"); - break; - - case MODE_DEL: - dfu_load_file(&file, MAYBE_SUFFIX, NEEDS_PREFIX); - if (type > ZERO_PREFIX && file.prefix_type != type) - errx(EX_IOERR, "No prefix of requested type"); - printf("Removing prefix from file\n"); - /* if there was a suffix, rewrite it */ - dfu_store_file(&file, file.size.suffix != 0, 0); - break; - - default: - help(); - break; - } - return (0); -} diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/quirks.c b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/quirks.c deleted file mode 100755 index de394a615..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/quirks.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Simple quirk system for dfu-util - * - * Copyright 2010-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include "quirks.h" - -uint16_t get_quirks(uint16_t vendor, uint16_t product, uint16_t bcdDevice) -{ - uint16_t quirks = 0; - - /* Device returns bogus bwPollTimeout values */ - if ((vendor == VENDOR_OPENMOKO || vendor == VENDOR_FIC) && - product >= PRODUCT_FREERUNNER_FIRST && - product <= PRODUCT_FREERUNNER_LAST) - quirks |= QUIRK_POLLTIMEOUT; - - if (vendor == VENDOR_VOTI && - product == PRODUCT_OPENPCD) - quirks |= QUIRK_POLLTIMEOUT; - - /* Reports wrong DFU version in DFU descriptor */ - if (vendor == VENDOR_LEAFLABS && - product == PRODUCT_MAPLE3 && - bcdDevice == 0x0200) - quirks |= QUIRK_FORCE_DFU11; - - /* old devices(bcdDevice == 0) return bogus bwPollTimeout values */ - if (vendor == VENDOR_SIEMENS && - (product == PRODUCT_PXM40 || product == PRODUCT_PXM50) && - bcdDevice == 0) - quirks |= QUIRK_POLLTIMEOUT; - - /* M-Audio Transit returns bogus bwPollTimeout values */ - if (vendor == VENDOR_MIDIMAN && - product == PRODUCT_TRANSIT) - quirks |= QUIRK_POLLTIMEOUT; - - return (quirks); -} diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/quirks.h b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/quirks.h deleted file mode 100755 index 0e4b3ec58..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/quirks.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef DFU_QUIRKS_H -#define DFU_QUIRKS_H - -#define VENDOR_OPENMOKO 0x1d50 /* Openmoko Freerunner / GTA02 */ -#define VENDOR_FIC 0x1457 /* Openmoko Freerunner / GTA02 */ -#define VENDOR_VOTI 0x16c0 /* OpenPCD Reader */ -#define VENDOR_LEAFLABS 0x1eaf /* Maple */ -#define VENDOR_SIEMENS 0x0908 /* Siemens AG */ -#define VENDOR_MIDIMAN 0x0763 /* Midiman */ - -#define PRODUCT_FREERUNNER_FIRST 0x5117 -#define PRODUCT_FREERUNNER_LAST 0x5126 -#define PRODUCT_OPENPCD 0x076b -#define PRODUCT_MAPLE3 0x0003 /* rev 3 and 5 */ -#define PRODUCT_PXM40 0x02c4 /* Siemens AG, PXM 40 */ -#define PRODUCT_PXM50 0x02c5 /* Siemens AG, PXM 50 */ -#define PRODUCT_TRANSIT 0x2806 /* M-Audio Transit (Midiman) */ - -#define QUIRK_POLLTIMEOUT (1<<0) -#define QUIRK_FORCE_DFU11 (1<<1) - -/* Fallback value, works for OpenMoko */ -#define DEFAULT_POLLTIMEOUT 5 - -uint16_t get_quirks(uint16_t vendor, uint16_t product, uint16_t bcdDevice); - -#endif /* DFU_QUIRKS_H */ diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/suffix.c b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/suffix.c deleted file mode 100755 index 0df248f51..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/suffix.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * dfu-suffix - * - * Copyright 2011-2012 Stefan Schmidt - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -enum mode { - MODE_NONE, - MODE_ADD, - MODE_DEL, - MODE_CHECK -}; - -int verbose; - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-suffix [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -c --check \t\tCheck DFU suffix of \n" - " -a --add \t\tAdd DFU suffix to \n" - " -D --delete \t\tDelete DFU suffix from \n" - " -p --pid \t\tAdd product ID into DFU suffix in \n" - " -v --vid \t\tAdd vendor ID into DFU suffix in \n" - " -d --did \t\tAdd device ID into DFU suffix in \n" - " -S --spec \t\tAdd DFU specification ID into DFU suffix in \n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf("dfu-suffix (%s) %s\n\n", PACKAGE, PACKAGE_VERSION); - printf("Copyright 2011-2012 Stefan Schmidt, 2013-2014 Tormod Volden\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to %s\n\n", PACKAGE_BUGREPORT); - -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "check", 1, 0, 'c' }, - { "add", 1, 0, 'a' }, - { "delete", 1, 0, 'D' }, - { "pid", 1, 0, 'p' }, - { "vid", 1, 0, 'v' }, - { "did", 1, 0, 'd' }, - { "spec", 1, 0, 'S' }, -}; - -int main(int argc, char **argv) -{ - struct dfu_file file; - int pid, vid, did, spec; - enum mode mode = MODE_NONE; - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - print_version(); - - pid = vid = did = 0xffff; - spec = 0x0100; /* Default to bcdDFU version 1.0 */ - memset(&file, 0, sizeof(file)); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVc:a:D:p:v:d:S:s:T", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - exit(0); - break; - case 'D': - file.name = optarg; - mode = MODE_DEL; - break; - case 'p': - pid = strtol(optarg, NULL, 16); - break; - case 'v': - vid = strtol(optarg, NULL, 16); - break; - case 'd': - did = strtol(optarg, NULL, 16); - break; - case 'S': - spec = strtol(optarg, NULL, 16); - break; - case 'c': - file.name = optarg; - mode = MODE_CHECK; - break; - case 'a': - file.name = optarg; - mode = MODE_ADD; - break; - default: - help(); - break; - } - } - - if (!file.name) { - fprintf(stderr, "You need to specify a filename\n"); - help(); - } - - if (spec != 0x0100 && spec != 0x011a) { - fprintf(stderr, "Only DFU specification 0x0100 and 0x011a supported\n"); - help(); - } - - switch(mode) { - case MODE_ADD: - dfu_load_file(&file, NO_SUFFIX, MAYBE_PREFIX); - file.idVendor = vid; - file.idProduct = pid; - file.bcdDevice = did; - file.bcdDFU = spec; - /* always write suffix, rewrite prefix if there was one */ - dfu_store_file(&file, 1, file.size.prefix != 0); - printf("Suffix successfully added to file\n"); - break; - - case MODE_CHECK: - dfu_load_file(&file, NEEDS_SUFFIX, MAYBE_PREFIX); - show_suffix_and_prefix(&file); - break; - - case MODE_DEL: - dfu_load_file(&file, NEEDS_SUFFIX, MAYBE_PREFIX); - dfu_store_file(&file, 0, file.size.prefix != 0); - if (file.size.suffix) /* had a suffix */ - printf("Suffix successfully removed from file\n"); - break; - - default: - help(); - break; - } - return (0); -} diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/usb_dfu.h b/arduino/opencr_arduino/tools/linux/src/dfu-util/src/usb_dfu.h deleted file mode 100755 index 660bedcbf..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/src/usb_dfu.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef USB_DFU_H -#define USB_DFU_H -/* USB Device Firmware Update Implementation for OpenPCD - * (C) 2006 by Harald Welte - * - * Protocol definitions for USB DFU - * - * This ought to be compliant to the USB DFU Spec 1.0 as available from - * http://www.usb.org/developers/devclass_docs/usbdfu10.pdf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define USB_DT_DFU 0x21 - -#ifdef _MSC_VER -# pragma pack(push) -# pragma pack(1) -#endif /* _MSC_VER */ -struct usb_dfu_func_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bmAttributes; -#define USB_DFU_CAN_DOWNLOAD (1 << 0) -#define USB_DFU_CAN_UPLOAD (1 << 1) -#define USB_DFU_MANIFEST_TOL (1 << 2) -#define USB_DFU_WILL_DETACH (1 << 3) - uint16_t wDetachTimeOut; - uint16_t wTransferSize; - uint16_t bcdDFUVersion; -#ifdef _MSC_VER -}; -# pragma pack(pop) -#elif defined __GNUC__ -} __attribute__ ((packed)); -#else - #warning "No way to pack struct on this compiler? This will break!" -#endif /* _MSC_VER */ - -#define USB_DT_DFU_SIZE 9 - -#define USB_TYPE_DFU (LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE) - -/* DFU class-specific requests (Section 3, DFU Rev 1.1) */ -#define USB_REQ_DFU_DETACH 0x00 -#define USB_REQ_DFU_DNLOAD 0x01 -#define USB_REQ_DFU_UPLOAD 0x02 -#define USB_REQ_DFU_GETSTATUS 0x03 -#define USB_REQ_DFU_CLRSTATUS 0x04 -#define USB_REQ_DFU_GETSTATE 0x05 -#define USB_REQ_DFU_ABORT 0x06 - -/* DFU_GETSTATUS bStatus values (Section 6.1.2, DFU Rev 1.1) */ -#define DFU_STATUS_OK 0x00 -#define DFU_STATUS_errTARGET 0x01 -#define DFU_STATUS_errFILE 0x02 -#define DFU_STATUS_errWRITE 0x03 -#define DFU_STATUS_errERASE 0x04 -#define DFU_STATUS_errCHECK_ERASED 0x05 -#define DFU_STATUS_errPROG 0x06 -#define DFU_STATUS_errVERIFY 0x07 -#define DFU_STATUS_errADDRESS 0x08 -#define DFU_STATUS_errNOTDONE 0x09 -#define DFU_STATUS_errFIRMWARE 0x0a -#define DFU_STATUS_errVENDOR 0x0b -#define DFU_STATUS_errUSBR 0x0c -#define DFU_STATUS_errPOR 0x0d -#define DFU_STATUS_errUNKNOWN 0x0e -#define DFU_STATUS_errSTALLEDPKT 0x0f - -enum dfu_state { - DFU_STATE_appIDLE = 0, - DFU_STATE_appDETACH = 1, - DFU_STATE_dfuIDLE = 2, - DFU_STATE_dfuDNLOAD_SYNC = 3, - DFU_STATE_dfuDNBUSY = 4, - DFU_STATE_dfuDNLOAD_IDLE = 5, - DFU_STATE_dfuMANIFEST_SYNC = 6, - DFU_STATE_dfuMANIFEST = 7, - DFU_STATE_dfuMANIFEST_WAIT_RST = 8, - DFU_STATE_dfuUPLOAD_IDLE = 9, - DFU_STATE_dfuERROR = 10 -}; - -#endif /* USB_DFU_H */ diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/www/build.html b/arduino/opencr_arduino/tools/linux/src/dfu-util/www/build.html deleted file mode 100755 index f3036e40c..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/www/build.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - Building dfu-util from source - - - - - - - - - -
-

How to build dfu-util from source

- -

Prerequisites for building from git

-

Mac OS X

-

-First install MacPorts (and if you are on 10.6 or older, the Java Developer Package) and then run: -

-
-	sudo port install libusb-devel git-core
-
- -

FreeBSD

-
-	sudo pkg_add -r git pkgconf
-
- -

Ubuntu and Debian and derivatives

-
-	sudo apt-get build-dep dfu-util
-	sudo apt-get install libusb-1.0-0-dev
-
- -

Get the source code and build it

-

-The first time you will have to clone the git repository: -

-
-	git clone git://gitorious.org/dfu-util/dfu-util.git
-	cd dfu-util
-
-

-If you later want to update to latest git version, just run this: -

-
-	make maintainer-clean
-	git pull
-
-

-To build the source: -

-
-	./autogen.sh
-	./configure  # on most systems
-	make
-
- -

-If you are building on Mac OS X, replace the ./configure command with: -

-
-	./configure --libdir=/opt/local/lib --includedir=/opt/local/include  # on MacOSX only
-
- -

-Your dfu-util binary will be inside the src folder. Use it from there, or install it to /usr/local/bin by running "sudo make install". -

- -

Cross-building for Windows

- -

-Windows binaries can be built in a MinGW -environment, on a Windows computer or cross-hosted in another OS. -To build it on a Debian or Ubuntu host, first install build dependencies: -

-
-	sudo apt-get build-dep libusb-1.0-0 dfu-util
-	sudo apt-get install mingw32
-
- -

-The below example builds dfu-util 0.8 and libusb 1.0.19 from unpacked release -tarballs. If you instead build from git, you will have to run "./autogen.sh" -before running the "./configure" steps. -

- -
-mkdir -p build
-cd libusb-1.0.19
-PKG_CONFIG_PATH=$PWD/../build/lib/pkgconfig ./configure \
-    --host=i586-mingw32msvc --prefix=$PWD/../build
-# WINVER workaround needed for 1.0.19 only
-make CFLAGS="-DWINVER=0x0501"
-make install
-cd ..
-
-cd dfu-util-0.8
-PKG_CONFIG_PATH=$PWD/../build/lib/pkgconfig ./configure \
-    --host=i586-mingw32msvc --prefix=$PWD/../build
-make
-make install
-cd ..
-
-The build files will now be in build/bin. -

- -

Building on Windows using MinGW

-This assumes using release tarballs or having run ./autogen.sh on -the git sources. -
-cd libusb-1.0.19
-./configure --prefix=$HOME
-# WINVER workaround needed for 1.0.19 only
-# MKDIR_P setting should not really be needed...
-make CFLAGS="-DWINVER=0x0501" MKDIR_P="mkdir -p"
-make install
-cd ..
-
-cd dfu-util-0.8
-./configure USB_CFLAGS="-I$HOME/include/libusb-1.0" \
-            USB_LIBS="-L $HOME/lib -lusb-1.0" PKG_CONFIG=true
-make
-make install
-cd ..
-
-To link libusb statically into dfu-util.exe use instead of "make": -
-make LDFLAGS=-static
-
-The built executables (and DLL) will now be under $HOME/bin. - -

-[Back to dfu-util main page] -

- -
- - diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/www/dfu-util.1.html b/arduino/opencr_arduino/tools/linux/src/dfu-util/www/dfu-util.1.html deleted file mode 100755 index 62ca40b5d..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/www/dfu-util.1.html +++ /dev/null @@ -1,411 +0,0 @@ - - -Man page of DFU-UTIL - - -

DFU-UTIL(1)

- -  -

NAME

- -dfu-util - Device firmware update (DFU) USB programmer -  -

SYNOPSIS

- - -
-
-dfu-util - --l - -[-v] - -[-d - -vid:pid[,vid:pid]] - -[-p - -path] - -[-c - -configuration] - -[-i - -interface] - -[-a - -alt-intf] - -[-S - -serial[,serial]] - - -
-dfu-util - -[-v] - -[-d - -vid:pid[,vid:pid]] - -[-p - -path] - -[-c - -configuration] - -[-i - -interface] - -[-a - -alt-intf] - -[-S - -serial[,serial]] - -[-t - -size] - -[-Z - -size] - -[-s - -address] - -[-R] - -[-D|-U - -file] - - -
-dfu-util - -[-hV] - -
-  -

DESCRIPTION

- -dfu-util - -is a program that implements the host (computer) side of the USB DFU -(Universal Serial Bus Device Firmware Upgrade) protocol. -

-dfu-util communicates with devices that implement the device side of the -USB DFU protocol, and is often used to upgrade the firmware of such -devices. -  -

OPTIONS

- -
-
-l, --list - -
-List the currently attached DFU capable USB devices. -
-d, --device [Run-Time VENDOR]:[Run-Time PRODUCT][,[DFU Mode VENDOR]:[DFU Mode PRODUCT]] - -
-
-Specify run-time and/or DFU mode vendor and/or product IDs of the DFU device -to work with. VENDOR and PRODUCT are hexadecimal numbers (no prefix -needed), "*" (match any), or "-" (match nothing). By default, any DFU capable -device in either run-time or DFU mode will be considered. -

-If you only have one standards-compliant DFU device attached to your computer, -this parameter is optional. However, as soon as you have multiple DFU devices -connected, dfu-util will detect this and abort, asking you to specify which -device to use. -

-If only run-time IDs are specified (e.g. "--device 1457:51ab"), then in -addition to the specified run-time IDs, any DFU mode devices will also be -considered. This is beneficial to allow a DFU capable device to be found -again after a switch to DFU mode, since the vendor and/or product ID of a -device usually changes in DFU mode. -

-If only DFU mode IDs are specified (e.g. "--device ,951:26"), then all -run-time devices will be ignored, making it easy to target a specific device in -DFU mode. -

-If both run-time and DFU mode IDs are specified (e.g. "--device -1457:51ab,:2bc"), then unspecified DFU mode components will use the run-time -value specified. -

-Examples: -

-
--device 1457:51ab,951:26 - -
-
- -Work with a device in run-time mode with -vendor ID 0x1457 and product ID 0x51ab, or in DFU mode with vendor ID 0x0951 -and product ID 0x0026 -

-

--device 1457:51ab,:2bc - -
-
- -Work with a device in run-time mode with vendor ID 0x1457 and product ID -0x51ab, or in DFU mode with vendor ID 0x1457 and product ID 0x02bc -

-

--device 1457:51ab - -
-
- -Work with a device in run-time mode with vendor ID 0x1457 and product ID -0x51ab, or in DFU mode with any vendor and product ID -

-

--device ,951:26 - -
-
- -Work with a device in DFU mode with vendor ID 0x0951 and product ID 0x0026 -

-

--device *,- - -
-
- -Work with any device in run-time mode, and ignore any device in DFU mode -

-

--device , - -
-
- -Ignore any device in run-time mode, and Work with any device in DFU mode -
-
- -
-p, --path BUS-PORT. ... .PORT - -
-Specify the path to the DFU device. -
-c, --cfg CONFIG-NR - -
-Specify the configuration of the DFU device. Note that this is only used for matching, the configuration is not set by dfu-util. -
-i, --intf INTF-NR - -
-Specify the DFU interface number. -
-a, --alt ALT - -
-Specify the altsetting of the DFU interface by name or by number. -
-S, --serial [Run-Time SERIAL][,[DFU Mode SERIAL]] - -
-Specify the run-time and DFU mode serial numbers used to further restrict -device matches. If multiple, identical DFU devices are simultaneously -connected to a system then vendor and product ID will be insufficient for -targeting a single device. In this situation, it may be possible to use this -parameter to specify a serial number which also must match. -

-If only a single serial number is specified, then the same serial number is -used in both run-time and DFU mode. An empty serial number will match any -serial number in the corresponding mode. -

-t, --transfer-size SIZE - -
-Specify the number of bytes per USB transfer. The optimal value is -usually determined automatically so this option is rarely useful. If -you need to use this option for a device, please report it as a bug. -
-Z, --upload-size SIZE - -
-Specify the expected upload size, in bytes. -
-U, --upload FILE - -
-Read firmware from device into -FILE. - -
-D, --download FILE - -
-Write firmware from -FILE - -into device. -
-R, --reset - -
-Issue USB reset signalling after upload or download has finished. -
-s, --dfuse-address address - -
-Specify target address for raw binary download/upload on DfuSe devices. Do -not - -use this for downloading DfuSe (.dfu) files. Modifiers can be added -to the address, separated by a colon, to perform special DfuSE commands such -as "leave" DFU mode, "unprotect" and "mass-erase" flash memory. -
-v, --verbose - -
-Print more information about dfu-util's operation. A second --v - -will turn on verbose logging of USB requests. Repeat this option to further -increase verbosity. -
-h, --help - -
-Show a help text and exit. -
-V, --version - -
-Show version information and exit. -
-  -

EXAMPLES

- -  -

Using dfu-util in the OpenMoko project

- -(with the Neo1973 hardware) -

- -Flashing the rootfs: -
- - $ dfu-util -a rootfs -R -D /path/to/openmoko-devel-image.jffs2 - -

- -Flashing the kernel: -
- - $ dfu-util -a kernel -R -D /path/to/uImage - -

- -Flashing the bootloader: -
- - $ dfu-util -a u-boot -R -D /path/to/u-boot.bin - -

- -Copying a kernel into RAM: -
- - $ dfu-util -a 0 -R -D /path/to/uImage - -

-Once this has finished, the kernel will be available at the default load -address of 0x32000000 in Neo1973 RAM. -Note: - -You cannot transfer more than 2MB of data into RAM using this method. -

-  -

Using dfu-util with a DfuSe device

- -

- -Flashing a -.dfu - -(special DfuSe format) file to the device: -
- - $ dfu-util -a 0 -D /path/to/dfuse-image.dfu - -

- -Reading out 1 KB of flash starting at address 0x8000000: -
- - $ dfu-util -a 0 -s 0x08000000:1024 -U newfile.bin - -

- -Flashing a binary file to address 0x8004000 of device memory and -ask the device to leave DFU mode: -
- - $ dfu-util -a 0 -s 0x08004000:leave -D /path/to/image.bin - - -  -

BUGS

- -Please report any bugs to the dfu-util mailing list at -dfu-util@lists.gnumonks.org. - -Please use the ---verbose option (repeated as necessary) to provide more - -information in your bug report. -  -

SEE ALSO

- -The dfu-util home page is -http://dfu-util.gnumonks.org - -  -

HISTORY

- -dfu-util was originally written for the OpenMoko project by -Weston Schmidt <weston_schmidt@yahoo.com> and -Harald Welte <hwelte@hmw-consulting.de>. Over time, nearly complete -support of DFU 1.0, DFU 1.1 and DfuSe ("1.1a") has been added. -  -

LICENCE

- -dfu-util - -is covered by the GNU General Public License (GPL), version 2 or later. -  -

COPYRIGHT

- -This manual page was originally written by Uwe Hermann <uwe@hermann-uwe.de>, -and is now part of the dfu-util project. -

- -


- 

Index

-
-
NAME
-
SYNOPSIS
-
DESCRIPTION
-
OPTIONS
-
EXAMPLES
-
-
Using dfu-util in the OpenMoko project
-
Using dfu-util with a DfuSe device
-
-
BUGS
-
SEE ALSO
-
HISTORY
-
LICENCE
-
COPYRIGHT
-
-
-This document was created by man2html, -using the doc/dfu-util.1 manual page from dfu-util 0.8.
-Time: 14:40:57 GMT, September 13, 2014 - - diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/www/dfuse.html b/arduino/opencr_arduino/tools/linux/src/dfu-util/www/dfuse.html deleted file mode 100755 index 35e4ffa9f..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/www/dfuse.html +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - DfuSe and dfu-util - - - - - - - - - -
-

Using dfu-util with DfuSe devices

-

DfuSe

-

- DfuSe (DFU with ST Microsystems extensions) is a protocol based on - DFU 1.1. However, in expanding the functionality of the DFU protocol, - ST Microsystems broke all compatibility with the DFU 1.1 standard. - DfuSe devices report the DFU version as "1.1a". -

-

- DfuSe can be used to download firmware and other data - from a host computer to a conforming device (or upload in the - opposite direction) over USB similar to standard DFU. -

-

- The main difference from standard DFU is that the target address in - the device (flash) memory is specified by the host, so that a - download can be performed to parts of the device memory. The host - program is also responsible for erasing flash pages before they - are written to. -

-

.dfu files

-

- A special file format is defined by ST Microsystems to carry firmware - for DfuSe devices. The file contains target information such as address - and alternate interface information in addition to the binary data. - Several blocks of binary data can be combined in one .dfu file. -

-

Alternate interfaces

-

- Different memory locations of the device may have different - characteristics that the host program (dfu-util) has to take - into considerations, such as flash memory page size, read-only - versus read-write segments, the need to erase, and so on. - These parameters are reported by the device in the string - descriptors meant for describing the USB interfaces. - The host program decodes these strings to build a memory map of - the device. Different memory units or address spaces are listed - in separate alternate interface settings that must be selected - according to the memory unit to access. -

-

- Note that dfu-util leaves it to the user to select alternate - interface. When parsing a .dfu file it will skip file segments - not matching the selected alternate interface. Also, some - DfuSe device firmware implementations ignore the setting of - alternate interface and deduct the memory unit from the - address, since they have no address space overlap. -

-

DfuSe special commands

-

- DfuSe special commands are used by the host program during normal - downloads or uploads, such as SET_ADDRESS and ERASE_PAGE. Also - the normal DFU_DNLOAD and DFU_UPLOAD commands have special - implementations in DfuSe. - Many DfuSe devices also support commands to leave DFU mode, - read unprotect the flash memory or mass erase the flash memory. - dfu-util (from version 0.7) - supports adding "leave", "unprotect", or "mass-erase" - to the -s option argument to send such requests in combination - with a download request. These modifiers are separated with a colon. -

-

- Some DfuSe devices have their DfuSe bootloader running from flash - memory. Erasing the whole flash memory would therefore destroy - the DfuSe bootloader itself and practically brick the device - for most users. Any use of modifiers such as "unprotect" - and "mass-erase" therefore needs to be combined with the "force" - modifer. This is not included in the examples, to not encourage - ignorant users to copy and paste such instructions and shoot - themselves in the foot. -

-

- Devices based on for instance STM32F103 all run the bootloader - from flash, since there is no USB bootloader in ROM. -

-

- For instance STM32F107, STM32F2xx and STM32F4xx devices have a - DfuSe bootloader in ROM, so the flash can be erased while - keeping the device available for USB DFU transfers as long - as the device designers use this built-in bootloader and have - not implemented another DfuSe bootloader in flash that the user is - dependent upon. -

-

- Well-written bootloaders running from flash will report their - own memory region as read-only and not eraseable, but this does - not prevent dfu-util from sending a "unprotect" or "mass-erase" - request which overrides this, if the user insists. -

-

Example usage

-

- Flashing a .dfu (special DfuSe format) file to the device: -

-
-         $ dfu-util -a 0 -D /path/to/dfuse-image.dfu
-	
-

- Reading out 1 KB of flash starting at address 0x8000000: -

-
-         $ dfu-util -a 0 -s 0x08000000:1024 -U newfile.bin
-	
-

- Flashing a binary file to address 0x8004000 of device memory and ask - the device to leave DFU mode: -

-
-         $ dfu-util -a 0 -s 0x08004000:leave -D /path/to/image.bin
-	
-

- [Back to dfu-util main page] -

- -
- - diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/www/index.html b/arduino/opencr_arduino/tools/linux/src/dfu-util/www/index.html deleted file mode 100755 index 108ddaf66..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/www/index.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - dfu-util Homepage - - - - - - - - - -
-

dfu-util - Device Firmware Upgrade Utilities

-

Description

-

- dfu-util is a host side implementation of the DFU 1.0 and DFU 1.1 specifications of the USB forum. - - DFU is intended to download and upload firmware to/from devices connected - over USB. It ranges from small devices like micro-controller boards - to mobile phones. Using dfu-util you can download firmware to your - DFU-enabled device or upload firmware from it. dfu-util has been - tested with the Openmoko Neo1973 and Freerunner and many other devices. -

-

- See the manual page for examples of use. -

-

Supported Devices

- -

Releases

-

- Releases of the dfu-util software can be found in the - releases folder. - The current release is 0.8. -

-

- We offer binaries for Microsoft Windows and some other platforms. - dfu-util uses libusb 1.0 to access your device, so - on Windows you have to register the device with the WinUSB driver - (alternatively libusb-win32 or libusbK), please see the libusbx wiki - for more details. -

-

- Mac OS X users can also get dfu-util from Homebrew with "brew install dfu-util" or from MacPorts. -

-

- Most Linux distributions ship dfu-util in binary packages for those - who do not want to compile dfu-util from source. - On Debian, Ubuntu, Fedora and Gentoo you can install it through the - normal software package tools. For other distributions -(namely OpenSuSe, Mandriva, and CentOS) Holger Freyther was kind enough to -provide binary packages through the Open Build Service. -

-

Development

-

- Development happens in a GIT repository. Browse it via the web -interface or clone it with: -

-
-	git clone git://gitorious.org/dfu-util/dfu-util.git
-	
-

- See our build instructions for how to - build the source on different platforms. -

-

License

-

- This software is licensed under the GPL version 2. -

-

Contact

-

- If you have questions about the development or use of dfu-util please - send an e-mail to our dedicated -mailing list for dfu-util. -

-

People

-

- dfu-util was originally written by - Harald Welte partially based on code from - dfu-programmer 0.4 and is currently maintained by Stefan Schmidt and - Tormod Volden. -

- -
- - diff --git a/arduino/opencr_arduino/tools/linux/src/dfu-util/www/simple.css b/arduino/opencr_arduino/tools/linux/src/dfu-util/www/simple.css deleted file mode 100755 index 98100bc5c..000000000 --- a/arduino/opencr_arduino/tools/linux/src/dfu-util/www/simple.css +++ /dev/null @@ -1,56 +0,0 @@ -body { - margin: 10px; - font-size: 0.82em; - background-color: #EEE; -} - -h1 { - clear: both; - padding: 0 0 12px 0; - margin: 0; - font-size: 2em; - font-weight: bold; -} - -h2 { - clear: both; - margin: 0; - font-size: 1.5em; - font-weight: normal; -} - -h3 { - clear: both; - margin: 15px 0 0 0; - font-size: 1.0em; - font-weight: bold; -} - -p { - line-height: 20px; - padding: 8px 0 8px 0; - margin: 0; - font-size: 1.1em; -} - -pre { - white-space: pre-wrap; - background-color: #CCC; - padding: 3px; -} - -a:hover { - background-color: #DDD; -} - -#middlebox { - width: 600px; - margin: 0px auto; - text-align: left; -} - -#footer { - height: 100px; - padding: 28px 3px 0 0; - margin: 20px 0 20px 0; -} diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/README.md b/arduino/opencr_arduino/tools/linux/src/maple_loader/README.md deleted file mode 100755 index c6c937950..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/README.md +++ /dev/null @@ -1,5 +0,0 @@ -These files build the maple_loader.jar file used on Windows to reset the Sketch via USB Serial, so that the bootloader will run in dfu upload mode, ready for a new sketch to be uploaded - -The files were written by @bobC (github) and have been slightly modified by me (Roger Clark), so that dfu-util no longer attempts to reset the board after upload. -This change to dfu-util's reset command line argument, was required because dfu-util was showing errors on some Windows systems, because the bootloader had reset its self after upload, -before dfu-util had chance to tell it to reset. \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build.xml b/arduino/opencr_arduino/tools/linux/src/maple_loader/build.xml deleted file mode 100755 index 80bdd6fdb..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/build.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project maple_loader. - - - diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/built-jar.properties b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/built-jar.properties deleted file mode 100755 index 10752d534..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/built-jar.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Mon, 20 Jul 2015 11:21:26 +1000 - - -C\:\\Users\\rclark\\Desktop\\maple-asp-master\\installer\\maple_loader= diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/CliTemplate/CliMain.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/CliTemplate/CliMain.class deleted file mode 100755 index 37ee63000..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/CliTemplate/CliMain.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/CliTemplate/DFUUploader.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/CliTemplate/DFUUploader.class deleted file mode 100755 index 77087b052..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/CliTemplate/DFUUploader.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/CliTemplate/ExecCommand.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/CliTemplate/ExecCommand.class deleted file mode 100755 index ad95f7984..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/CliTemplate/ExecCommand.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/Base.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/Base.class deleted file mode 100755 index 4aa0bde02..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/Base.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/Preferences.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/Preferences.class deleted file mode 100755 index 89cf01004..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/Preferences.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/Serial.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/Serial.class deleted file mode 100755 index cceccdd27..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/Serial.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/SerialException.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/SerialException.class deleted file mode 100755 index 71048dd3a..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/SerialException.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class deleted file mode 100755 index 37250e770..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class deleted file mode 100755 index e22c8d499..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/debug/RunnerException.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/debug/RunnerException.class deleted file mode 100755 index 710f79650..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/debug/RunnerException.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class b/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class deleted file mode 100755 index 27eca6262..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/dist/README.TXT b/arduino/opencr_arduino/tools/linux/src/maple_loader/dist/README.TXT deleted file mode 100755 index 255b89c68..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/dist/README.TXT +++ /dev/null @@ -1,32 +0,0 @@ -======================== -BUILD OUTPUT DESCRIPTION -======================== - -When you build an Java application project that has a main class, the IDE -automatically copies all of the JAR -files on the projects classpath to your projects dist/lib folder. The IDE -also adds each of the JAR files to the Class-Path element in the application -JAR files manifest file (MANIFEST.MF). - -To run the project from the command line, go to the dist folder and -type the following: - -java -jar "maple_loader.jar" - -To distribute this project, zip up the dist folder (including the lib folder) -and distribute the ZIP file. - -Notes: - -* If two JAR files on the project classpath have the same name, only the first -JAR file is copied to the lib folder. -* Only JAR files are copied to the lib folder. -If the classpath contains other types of files or folders, these files (folders) -are not copied. -* If a library on the projects classpath also has a Class-Path element -specified in the manifest,the content of the Class-Path element has to be on -the projects runtime path. -* To set a main class in a standard Java project, right-click the project node -in the Projects window and choose Properties. Then click Run and enter the -class name in the Main Class field. Alternatively, you can manually type the -class name in the manifest Main-Class element. diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/dist/lib/jssc.jar b/arduino/opencr_arduino/tools/linux/src/maple_loader/dist/lib/jssc.jar deleted file mode 100755 index eb74f154a..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/dist/lib/jssc.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/dist/maple_loader.jar b/arduino/opencr_arduino/tools/linux/src/maple_loader/dist/maple_loader.jar deleted file mode 100755 index e1f9965c1..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/dist/maple_loader.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/jars/jssc.jar b/arduino/opencr_arduino/tools/linux/src/maple_loader/jars/jssc.jar deleted file mode 100755 index eb74f154a..000000000 Binary files a/arduino/opencr_arduino/tools/linux/src/maple_loader/jars/jssc.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/manifest.mf b/arduino/opencr_arduino/tools/linux/src/maple_loader/manifest.mf deleted file mode 100755 index 328e8e5bc..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/build-impl.xml b/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/build-impl.xml deleted file mode 100755 index a66f34964..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/build-impl.xml +++ /dev/null @@ -1,1413 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/genfiles.properties b/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/genfiles.properties deleted file mode 100755 index c13672132..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=2e6a03ba -build.xml.script.CRC32=4676ee6b -build.xml.stylesheet.CRC32=8064a381@1.75.2.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=2e6a03ba -nbproject/build-impl.xml.script.CRC32=392b3f79 -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/private/config.properties b/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/private/config.properties deleted file mode 100755 index e69de29bb..000000000 diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/private/private.properties b/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/private/private.properties deleted file mode 100755 index e5c9f10c4..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/private/private.properties +++ /dev/null @@ -1,6 +0,0 @@ -compile.on.save=true -do.depend=false -do.jar=true -javac.debug=true -javadoc.preview=true -user.properties.file=C:\\Users\\rclark\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/private/private.xml b/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/private/private.xml deleted file mode 100755 index a1bbd60c9..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/private/private.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - file:/C:/Users/rclark/Desktop/maple-asp-master/installer/maple_loader/src/CliTemplate/CliMain.java - file:/C:/Users/rclark/Desktop/maple-asp-master/installer/maple_loader/src/CliTemplate/DFUUploader.java - - - diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/project.properties b/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/project.properties deleted file mode 100755 index 7f48d719f..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/project.properties +++ /dev/null @@ -1,79 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=maple_loader -application.vendor=bob -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/maple_loader.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.jssc.jar=dist/lib/jssc.jar -file.reference.jssc.jar-1=jars/jssc.jar -includes=** -jar.compress=false -javac.classpath=\ - ${file.reference.jssc.jar}:\ - ${file.reference.jssc.jar-1} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.7 -javac.target=1.7 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=CliTemplate.CliMain -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/project.xml b/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/project.xml deleted file mode 100755 index 92218a925..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/nbproject/project.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - maple_loader - - - - - - - - - diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/CliTemplate/CliMain.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/CliTemplate/CliMain.java deleted file mode 100755 index c7dc9f098..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/CliTemplate/CliMain.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package CliTemplate; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import processing.app.Preferences; - -//import processing.app.I18n; -import processing.app.helpers.ProcessUtils; - -/** - * - * @author cousinr - */ -public class CliMain { - - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - - String comPort = args[0]; // - String altIf = args[1]; // - String usbID = args[2]; // "1EAF:0003"; - String binFile = args[3]; // bin file - - System.out.println("maple_loader v0.1"); - - Preferences.set ("serial.port",comPort); - Preferences.set ("serial.parity","N"); - Preferences.setInteger ("serial.databits", 8); - Preferences.setInteger ("serial.debug_rate",9600); - Preferences.setInteger ("serial.stopbits",1); - - Preferences.setInteger ("programDelay",1200); - - Preferences.set ("upload.usbID", usbID); - Preferences.set ("upload.altID", altIf); - Preferences.setBoolean ("upload.auto_reset", true); - Preferences.setBoolean ("upload.verbose", false); - - // - DFUUploader dfuUploader = new DFUUploader(); - try { - //dfuUploader.uploadViaDFU(binFile); - dfuUploader.uploadViaDFU(binFile); - } catch (Exception e) - { - System.err.print (MessageFormat.format("an error occurred! {0}\n", e.getMessage())); - } - } -} diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/CliTemplate/DFUUploader.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/CliTemplate/DFUUploader.java deleted file mode 100755 index 3dee0b4b7..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/CliTemplate/DFUUploader.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - DFUUploader - uploader implementation using DFU - - Copyright (c) 2010 - Andrew Meyer - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - -package CliTemplate; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import processing.app.Preferences; -import processing.app.Serial; -import processing.app.debug.MessageConsumer; -import processing.app.debug.MessageSiphon; -import processing.app.debug.RunnerException; - -/** - * - * @author bob - */ -public class DFUUploader implements MessageConsumer { - - boolean firstErrorFound; - boolean secondErrorFound; - // part of the PdeMessageConsumer interface - boolean notFoundError; - boolean verbose; - RunnerException exception; - - static final String SUPER_BADNESS = - "Compiler error!"; - - public boolean uploadUsingPreferences(String binPath, boolean verbose) - throws RunnerException { - - this.verbose = verbose; - - return uploadViaDFU(binPath); - } - - // works with old and new versions of dfu-util - private boolean found_device (String dfuData, String usbID) - { - return dfuData.contains(("Found DFU: [0x"+usbID.substring(0,4)).toUpperCase()) || - dfuData.contains(("Found DFU: ["+usbID.substring(0,4)).toUpperCase()); - } - - public boolean uploadViaDFU (String binPath) - throws RunnerException { - - this.verbose = Preferences.getBoolean ("upload.verbose"); - - /* todo, check for size overruns! */ - String fileType="bin"; - - if (fileType.equals("bin")) { - String usbID = Preferences.get("upload.usbID"); - if (usbID == null) { - /* fall back on default */ - /* this isnt great because is default Avrdude or dfu-util? */ - usbID = Preferences.get("upload.usbID"); - } - - /* if auto-reset, then emit the reset pulse on dtr/rts */ - if (Preferences.get("upload.auto_reset") != null) { - if (Preferences.get("upload.auto_reset").toLowerCase().equals("true")) { - System.out.println("Resetting to bootloader via DTR pulse"); - emitResetPulse(); - } - } else { - System.out.println("Resetting to bootloader via DTR pulse"); - emitResetPulse(); - } - - String dfuList = new String(); - List commandCheck = new ArrayList(); - commandCheck.add("dfu-util"); - commandCheck.add("-l"); - long startChecking = System.currentTimeMillis(); - System.out.println("Searching for DFU device [" + usbID + "]..."); - do { - try { - Thread.sleep(100); - } catch (InterruptedException e) {} - dfuList = executeCheckCommand(commandCheck); - //System.out.println(dfuList); - } - while ( !found_device (dfuList.toUpperCase(), usbID) && (System.currentTimeMillis() - startChecking < 7000)); - - if ( !found_device (dfuList.toUpperCase(), usbID) ) - { - System.out.println(dfuList); - System.err.println("Couldn't find the DFU device: [" + usbID + "]"); - return false; - } - System.out.println("Found it!"); - - /* todo, add handle to let user choose altIf at upload time! */ - String altIf = Preferences.get("upload.altID"); - - List commandDownloader = new ArrayList(); - commandDownloader.add("dfu-util"); - commandDownloader.add("-a "+altIf); - commandDownloader.add("-R"); - commandDownloader.add("-d "+usbID); - commandDownloader.add("-D"+ binPath); //"./thisbin.bin"); - - return executeUploadCommand(commandDownloader); - } - - System.err.println("Only .bin files are supported at this time"); - return false; - } - - /* we need to ensure both RTS and DTR are low to start, - then pulse DTR on its own. This is the reset signal - maple responds to - */ - private void emitResetPulse() throws RunnerException { - - /* wait a while for the device to reboot */ - int programDelay = Preferences.getInteger("programDelay"); - - try { - Serial serialPort = new Serial(); - - // try to toggle DTR/RTS (old scheme) - serialPort.setRTS(false); - serialPort.setDTR(false); - serialPort.setDTR(true); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.setDTR(false); - - // try magic number - serialPort.setRTS(true); - serialPort.setDTR(true); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.setDTR(false); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.write("1EAF"); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.dispose(); - - } catch(Exception e) { - System.err.println("Reset via USB Serial Failed! Did you select the right serial port?\nAssuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...\n"); - } - } - - protected String executeCheckCommand(Collection commandDownloader) - throws RunnerException - { - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - notFoundError = false; - int result=0; // pre-initialized to quiet a bogus warning from jikes - - String userdir = System.getProperty("user.dir") + File.separator; - String returnStr = new String(); - - try { - String[] commandArray = new String[commandDownloader.size()]; - commandDownloader.toArray(commandArray); - - String armBasePath; - - //armBasePath = new String(Base.getHardwarePath() + "/tools/arm/bin/"); - armBasePath = ""; - - commandArray[0] = armBasePath + commandArray[0]; - - if (verbose || Preferences.getBoolean("upload.verbose")) { - for(int i = 0; i < commandArray.length; i++) { - System.out.print(commandArray[i] + " "); - } - System.out.println(); - } - - Process process = Runtime.getRuntime().exec(commandArray); - BufferedReader stdInput = new BufferedReader(new - InputStreamReader(process.getInputStream())); - BufferedReader stdError = new BufferedReader(new - InputStreamReader(process.getErrorStream())); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - // - boolean busy = true; - while (busy) { - try { - result = process.waitFor(); - busy = false; - } catch (InterruptedException intExc) { - } - } - - String s; - while ((s = stdInput.readLine()) != null) { - returnStr += s + "\n"; - } - - process.destroy(); - - if(exception!=null) { - exception.hideStackTrace(); - throw exception; - } - if(result!=0) return "Error!"; - } catch (Exception e) { - e.printStackTrace(); - } - //System.out.println("result2 is "+result); - // if the result isn't a known, expected value it means that something - // is fairly wrong, one possibility is that jikes has crashed. - // - if (exception != null) throw exception; - - if ((result != 0) && (result != 1 )) { - exception = new RunnerException(SUPER_BADNESS); - } - - return returnStr; // ? true : false; - - } - - // Need to overload this from Uploader to use the system-wide dfu-util - protected boolean executeUploadCommand(Collection commandDownloader) - throws RunnerException - { - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - notFoundError = false; - int result=0; // pre-initialized to quiet a bogus warning from jikes - - String userdir = System.getProperty("user.dir") + File.separator; - - try { - String[] commandArray = new String[commandDownloader.size()]; - commandDownloader.toArray(commandArray); - - String armBasePath; - - //armBasePath = new String(Base.getHardwarePath() + "/tools/arm/bin/"); - armBasePath = ""; - - commandArray[0] = armBasePath + commandArray[0]; - - if (verbose || Preferences.getBoolean("upload.verbose")) { - for(int i = 0; i < commandArray.length; i++) { - System.out.print(commandArray[i] + " "); - } - System.out.println(); - } - - Process process = Runtime.getRuntime().exec(commandArray); - new MessageSiphon(process.getInputStream(), this); - new MessageSiphon(process.getErrorStream(), this); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - // - boolean compiling = true; - while (compiling) { - try { - result = process.waitFor(); - compiling = false; - } catch (InterruptedException intExc) { - } - } - if(exception!=null) { - exception.hideStackTrace(); - throw exception; - } - if(result!=0) - return false; - } catch (Exception e) { - e.printStackTrace(); - } - //System.out.println("result2 is "+result); - // if the result isn't a known, expected value it means that something - // is fairly wrong, one possibility is that jikes has crashed. - // - if (exception != null) throw exception; - - if ((result != 0) && (result != 1 )) { - exception = new RunnerException(SUPER_BADNESS); - //editor.error(exception); - //PdeBase.openURL(BUGS_URL); - //throw new PdeException(SUPER_BADNESS); - } - - return (result == 0); // ? true : false; - - } - - // deal with messages from dfu-util... - public void message(String s) { - - if(s.indexOf("dfu-util - (C) ") != -1) { return; } - if(s.indexOf("This program is Free Software and has ABSOLUTELY NO WARRANTY") != -1) { return; } - - if(s.indexOf("No DFU capable USB device found") != -1) { - System.err.print(s); - exception = new RunnerException("Problem uploading via dfu-util: No Maple found"); - return; - } - - if(s.indexOf("Operation not perimitted") != -1) { - System.err.print(s); - exception = new RunnerException("Problem uploading via dfu-util: Insufficient privilages"); - return; - } - - // else just print everything... - System.out.print(s); - } - -} diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/CliTemplate/ExecCommand.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/CliTemplate/ExecCommand.java deleted file mode 100755 index 3d6c106b7..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/CliTemplate/ExecCommand.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package CliTemplate; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; - -import processing.app.debug.MessageConsumer; -import processing.app.debug.MessageSiphon; -import processing.app.debug.RunnerException; -import processing.app.helpers.ProcessUtils; - -/** - * - * @author cousinr - */ -public class ExecCommand implements MessageConsumer { - - private boolean verbose = true; - private boolean firstErrorFound; - private boolean secondErrorFound; - private RunnerException exception; - - /** - * Either succeeds or throws a RunnerException fit for public consumption. - * - * @param command - * @throws RunnerException - */ - public void execAsynchronously(String[] command) throws RunnerException { - - // eliminate any empty array entries - List stringList = new ArrayList<>(); - for (String string : command) { - string = string.trim(); - if (string.length() != 0) - stringList.add(string); - } - command = stringList.toArray(new String[stringList.size()]); - if (command.length == 0) - return; - int result = 0; - - if (verbose) { - for (String c : command) - System.out.print(c + " "); - System.out.println(); - } - - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - - Process process; - try { - process = ProcessUtils.exec(command); - } catch (IOException e) { - RunnerException re = new RunnerException(e.getMessage()); - re.hideStackTrace(); - throw re; - } - - MessageSiphon in = new MessageSiphon(process.getInputStream(), this); - MessageSiphon err = new MessageSiphon(process.getErrorStream(), this); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - boolean compiling = true; - while (compiling) { - try { - in.join(); - err.join(); - result = process.waitFor(); - //System.out.println("result is " + result); - compiling = false; - } catch (InterruptedException ignored) { } - } - - // an error was queued up by message(), barf this back to compile(), - // which will barf it back to Editor. if you're having trouble - // discerning the imagery, consider how cows regurgitate their food - // to digest it, and the fact that they have five stomaches. - // - //System.out.println("throwing up " + exception); - if (exception != null) - throw exception; - - if (result > 1) { - // a failure in the tool (e.g. unable to locate a sub-executable) - System.err.println(MessageFormat.format("{0} returned {1}", command[0], result)); - } - - if (result != 0) { - RunnerException re = new RunnerException(MessageFormat.format("exit code: {0}", result)); - re.hideStackTrace(); - throw re; - } - } - - /** - * Part of the MessageConsumer interface, this is called - * whenever a piece (usually a line) of error message is spewed - * out from the compiler. The errors are parsed for their contents - * and line number, which is then reported back to Editor. - * @param s - */ - @Override - public void message(String s) { - int i; - - - System.err.print(s); - } - -} diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/Base.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/Base.java deleted file mode 100755 index c3a174dcb..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/Base.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-10 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - - -/** - * The base class for the main processing application. - * Primary role of this class is for platform identification and - * general interaction with the system (launching URLs, loading - * files and images, etc) that comes from that. - */ -public class Base { - - /** - * returns true if running on windows. - */ - static public boolean isWindows() { - //return PApplet.platform == PConstants.WINDOWS; - return System.getProperty("os.name").indexOf("Windows") != -1; - } - - - /** - * true if running on linux. - */ - static public boolean isLinux() { - //return PApplet.platform == PConstants.LINUX; - return System.getProperty("os.name").indexOf("Linux") != -1; - } - - - -} diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/Preferences.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/Preferences.java deleted file mode 100755 index 6368e38af..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/Preferences.java +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-09 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - -import java.io.*; -import java.util.*; - - -/** - * Storage class for user preferences and environment settings. - *

- * This class no longer uses the Properties class, since - * properties files are iso8859-1, which is highly likely to - * be a problem when trying to save sketch folders and locations. - *

- * The GUI portion in here is really ugly, as it uses exact layout. This was - * done in frustration one evening (and pre-Swing), but that's long since past, - * and it should all be moved to a proper swing layout like BoxLayout. - *

- * This is very poorly put together, that the preferences panel and the actual - * preferences i/o is part of the same code. But there hasn't yet been a - * compelling reason to bother with the separation aside from concern about - * being lectured by strangers who feel that it doesn't look like what they - * learned in CS class. - *

- * Would also be possible to change this to use the Java Preferences API. - * Some useful articles - * here and - * here. - * However, haven't implemented this yet for lack of time, but more - * importantly, because it would entail writing to the registry (on Windows), - * or an obscure file location (on Mac OS X) and make it far more difficult to - * find the preferences to tweak them by hand (no! stay out of regedit!) - * or to reset the preferences by simply deleting the preferences.txt file. - */ -public class Preferences { - - // what to call the feller - - static final String PREFS_FILE = "preferences.txt"; - - - // prompt text stuff - - static final String PROMPT_YES = "Yes"; - static final String PROMPT_NO = "No"; - static final String PROMPT_CANCEL = "Cancel"; - static final String PROMPT_OK = "OK"; - static final String PROMPT_BROWSE = "Browse"; - - /** - * Standardized width for buttons. Mac OS X 10.3 wants 70 as its default, - * Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper. - */ - static public int BUTTON_WIDTH = 80; - - /** - * Standardized button height. Mac OS X 10.3 (Java 1.4) wants 29, - * presumably because it now includes the blue border, where it didn't - * in Java 1.3. Windows XP only wants 23 (not sure what default Linux - * would be). Because of the disparity, on Mac OS X, it will be set - * inside a static block. - */ - static public int BUTTON_HEIGHT = 24; - - // value for the size bars, buttons, etc - - static final int GRID_SIZE = 33; - - - // indents and spacing standards. these probably need to be modified - // per platform as well, since macosx is so huge, windows is smaller, - // and linux is all over the map - - static final int GUI_BIG = 13; - static final int GUI_BETWEEN = 10; - static final int GUI_SMALL = 6; - - - - // data model - - static Hashtable table = new Hashtable();; - static File preferencesFile; - - - static protected void init(String commandLinePrefs) { - - - } - - - public Preferences() { - - } - - // ................................................................. - - // ................................................................. - - // ................................................................. - - // ................................................................. - - - - static public String get(String attribute) { - return (String) table.get(attribute); - } - - static public void set(String attribute, String value) { - table.put(attribute, value); - } - - - static public boolean getBoolean(String attribute) { - String value = get(attribute); - return (new Boolean(value)).booleanValue(); - } - - - static public void setBoolean(String attribute, boolean value) { - set(attribute, value ? "true" : "false"); - } - - - static public int getInteger(String attribute) { - return Integer.parseInt(get(attribute)); - } - - - static public void setInteger(String key, int value) { - set(key, String.valueOf(value)); - } - -} diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/Serial.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/Serial.java deleted file mode 100755 index 04566a738..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/Serial.java +++ /dev/null @@ -1,527 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - PSerial - class for serial port goodness - Part of the Processing project - http://processing.org - - Copyright (c) 2004 Ben Fry & Casey Reas - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA -*/ - -package processing.app; -//import processing.core.*; - - -import java.io.*; -import java.text.MessageFormat; -import java.util.*; -import jssc.SerialPort; -import jssc.SerialPortEvent; -import jssc.SerialPortEventListener; -import jssc.SerialPortException; -import jssc.SerialPortList; -import processing.app.debug.MessageConsumer; - - -public class Serial implements SerialPortEventListener { - - //PApplet parent; - - // properties can be passed in for default values - // otherwise defaults to 9600 N81 - - // these could be made static, which might be a solution - // for the classloading problem.. because if code ran again, - // the static class would have an object that could be closed - - SerialPort port; - - int rate; - int parity; - int databits; - int stopbits; - boolean monitor = false; - - // read buffer and streams - - InputStream input; - OutputStream output; - - byte buffer[] = new byte[32768]; - int bufferIndex; - int bufferLast; - - MessageConsumer consumer; - - public Serial(boolean monitor) throws SerialException { - this(Preferences.get("serial.port"), - Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - this.monitor = monitor; - } - - public Serial() throws SerialException { - this(Preferences.get("serial.port"), - Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(int irate) throws SerialException { - this(Preferences.get("serial.port"), irate, - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname, int irate) throws SerialException { - this(iname, irate, Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname) throws SerialException { - this(iname, Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname, int irate, - char iparity, int idatabits, float istopbits) - throws SerialException { - //if (port != null) port.close(); - //this.parent = parent; - //parent.attach(this); - - this.rate = irate; - - parity = SerialPort.PARITY_NONE; - if (iparity == 'E') parity = SerialPort.PARITY_EVEN; - if (iparity == 'O') parity = SerialPort.PARITY_ODD; - - this.databits = idatabits; - - stopbits = SerialPort.STOPBITS_1; - if (istopbits == 1.5f) stopbits = SerialPort.STOPBITS_1_5; - if (istopbits == 2) stopbits = SerialPort.STOPBITS_2; - - try { - port = new SerialPort(iname); - port.openPort(); - port.setParams(rate, databits, stopbits, parity, true, true); - port.addEventListener(this); - } catch (Exception e) { - throw new SerialException(MessageFormat.format("Error opening serial port ''{0}''.", iname), e); - } - - if (port == null) { - throw new SerialException("Serial port '" + iname + "' not found. Did you select the right one from the Tools > Serial Port menu?"); - } - } - - - public void setup() { - //parent.registerCall(this, DISPOSE); - } - - public void dispose() throws IOException { - if (port != null) { - try { - if (port.isOpened()) { - port.closePort(); // close the port - } - } catch (SerialPortException e) { - throw new IOException(e); - } finally { - port = null; - } - } - } - - public void addListener(MessageConsumer consumer) { - this.consumer = consumer; - } - - public synchronized void serialEvent(SerialPortEvent serialEvent) { - if (serialEvent.isRXCHAR()) { - try { - byte[] buf = port.readBytes(serialEvent.getEventValue()); - if (buf.length > 0) { - if (bufferLast == buffer.length) { - byte temp[] = new byte[bufferLast << 1]; - System.arraycopy(buffer, 0, temp, 0, bufferLast); - buffer = temp; - } - if (monitor) { - System.out.print(new String(buf)); - } - if (this.consumer != null) { - this.consumer.message(new String(buf)); - } - } - } catch (SerialPortException e) { - errorMessage("serialEvent", e); - } - } - } - - - /** - * Returns the number of bytes that have been read from serial - * and are waiting to be dealt with by the user. - */ - public synchronized int available() { - return (bufferLast - bufferIndex); - } - - - /** - * Ignore all the bytes read so far and empty the buffer. - */ - public synchronized void clear() { - bufferLast = 0; - bufferIndex = 0; - } - - - /** - * Returns a number between 0 and 255 for the next byte that's - * waiting in the buffer. - * Returns -1 if there was no byte (although the user should - * first check available() to see if things are ready to avoid this) - */ - public synchronized int read() { - if (bufferIndex == bufferLast) return -1; - - int outgoing = buffer[bufferIndex++] & 0xff; - if (bufferIndex == bufferLast) { // rewind - bufferIndex = 0; - bufferLast = 0; - } - return outgoing; - } - - - /** - * Returns the next byte in the buffer as a char. - * Returns -1, or 0xffff, if nothing is there. - */ - public synchronized char readChar() { - if (bufferIndex == bufferLast) return (char)(-1); - return (char) read(); - } - - - /** - * Return a byte array of anything that's in the serial buffer. - * Not particularly memory/speed efficient, because it creates - * a byte array on each read, but it's easier to use than - * readBytes(byte b[]) (see below). - */ - public synchronized byte[] readBytes() { - if (bufferIndex == bufferLast) return null; - - int length = bufferLast - bufferIndex; - byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex = 0; // rewind - bufferLast = 0; - return outgoing; - } - - - /** - * Grab whatever is in the serial buffer, and stuff it into a - * byte buffer passed in by the user. This is more memory/time - * efficient than readBytes() returning a byte[] array. - *

- * Returns an int for how many bytes were read. If more bytes - * are available than can fit into the byte array, only those - * that will fit are read. - */ - public synchronized int readBytes(byte outgoing[]) { - if (bufferIndex == bufferLast) return 0; - - int length = bufferLast - bufferIndex; - if (length > outgoing.length) length = outgoing.length; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex += length; - if (bufferIndex == bufferLast) { - bufferIndex = 0; // rewind - bufferLast = 0; - } - return length; - } - - - /** - * Reads from the serial port into a buffer of bytes up to and - * including a particular character. If the character isn't in - * the serial buffer, then 'null' is returned. - */ - public synchronized byte[] readBytesUntil(int interesting) { - if (bufferIndex == bufferLast) return null; - byte what = (byte)interesting; - - int found = -1; - for (int k = bufferIndex; k < bufferLast; k++) { - if (buffer[k] == what) { - found = k; - break; - } - } - if (found == -1) return null; - - int length = found - bufferIndex + 1; - byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex = 0; // rewind - bufferLast = 0; - return outgoing; - } - - - /** - * Reads from the serial port into a buffer of bytes until a - * particular character. If the character isn't in the serial - * buffer, then 'null' is returned. - *

- * If outgoing[] is not big enough, then -1 is returned, - * and an error message is printed on the console. - * If nothing is in the buffer, zero is returned. - * If 'interesting' byte is not in the buffer, then 0 is returned. - */ - public synchronized int readBytesUntil(int interesting, byte outgoing[]) { - if (bufferIndex == bufferLast) return 0; - byte what = (byte)interesting; - - int found = -1; - for (int k = bufferIndex; k < bufferLast; k++) { - if (buffer[k] == what) { - found = k; - break; - } - } - if (found == -1) return 0; - - int length = found - bufferIndex + 1; - if (length > outgoing.length) { - System.err.println("readBytesUntil() byte buffer is" + - " too small for the " + length + - " bytes up to and including char " + interesting); - return -1; - } - //byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex += length; - if (bufferIndex == bufferLast) { - bufferIndex = 0; // rewind - bufferLast = 0; - } - return length; - } - - - /** - * Return whatever has been read from the serial port so far - * as a String. It assumes that the incoming characters are ASCII. - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public synchronized String readString() { - if (bufferIndex == bufferLast) return null; - return new String(readBytes()); - } - - - /** - * Combination of readBytesUntil and readString. See caveats in - * each function. Returns null if it still hasn't found what - * you're looking for. - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public synchronized String readStringUntil(int interesting) { - byte b[] = readBytesUntil(interesting); - if (b == null) return null; - return new String(b); - } - - - /** - * This will handle both ints, bytes and chars transparently. - */ - public void write(int what) { // will also cover char - try { - port.writeInt(what & 0xff); - } catch (SerialPortException e) { - errorMessage("write", e); - } - } - - - public void write(byte bytes[]) { - try { - port.writeBytes(bytes); - } catch (SerialPortException e) { - errorMessage("write", e); - } - } - - - /** - * Write a String to the output. Note that this doesn't account - * for Unicode (two bytes per char), nor will it send UTF8 - * characters.. It assumes that you mean to send a byte buffer - * (most often the case for networking and serial i/o) and - * will only use the bottom 8 bits of each char in the string. - * (Meaning that internally it uses String.getBytes) - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public void write(String what) { - write(what.getBytes()); - } - - public void setDTR(boolean state) { - try { - port.setDTR(state); - } catch (SerialPortException e) { - errorMessage("setDTR", e); - } - } - - public void setRTS(boolean state) { - try { - port.setRTS(state); - } catch (SerialPortException e) { - errorMessage("setRTS", e); - } - } - - static public List list() { - return Arrays.asList(SerialPortList.getPortNames()); - } - - - /** - * General error reporting, all corraled here just in case - * I think of something slightly more intelligent to do. - */ - static public void errorMessage(String where, Throwable e) { - System.err.println("Error inside Serial." + where + "()"); - e.printStackTrace(); - } -} - - - /* - class SerialMenuListener implements ItemListener { - //public SerialMenuListener() { } - - public void itemStateChanged(ItemEvent e) { - int count = serialMenu.getItemCount(); - for (int i = 0; i < count; i++) { - ((CheckboxMenuItem)serialMenu.getItem(i)).setState(false); - } - CheckboxMenuItem item = (CheckboxMenuItem)e.getSource(); - item.setState(true); - String name = item.getLabel(); - //System.out.println(item.getLabel()); - PdeBase.properties.put("serial.port", name); - //System.out.println("set to " + get("serial.port")); - } - } - */ - - - /* - protected Vector buildPortList() { - // get list of names for serial ports - // have the default port checked (if present) - Vector list = new Vector(); - - //SerialMenuListener listener = new SerialMenuListener(); - boolean problem = false; - - // if this is failing, it may be because - // lib/javax.comm.properties is missing. - // java is weird about how it searches for java.comm.properties - // so it tends to be very fragile. i.e. quotes in the CLASSPATH - // environment variable will hose things. - try { - //System.out.println("building port list"); - Enumeration portList = CommPortIdentifier.getPortIdentifiers(); - while (portList.hasMoreElements()) { - CommPortIdentifier portId = - (CommPortIdentifier) portList.nextElement(); - //System.out.println(portId); - - if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { - //if (portId.getName().equals(port)) { - String name = portId.getName(); - //CheckboxMenuItem mi = - //new CheckboxMenuItem(name, name.equals(defaultName)); - - //mi.addItemListener(listener); - //serialMenu.add(mi); - list.addElement(name); - } - } - } catch (UnsatisfiedLinkError e) { - e.printStackTrace(); - problem = true; - - } catch (Exception e) { - System.out.println("exception building serial menu"); - e.printStackTrace(); - } - - //if (serialMenu.getItemCount() == 0) { - //System.out.println("dimming serial menu"); - //serialMenu.setEnabled(false); - //} - - // only warn them if this is the first time - if (problem && PdeBase.firstTime) { - JOptionPane.showMessageDialog(this, //frame, - "Serial port support not installed.\n" + - "Check the readme for instructions\n" + - "if you need to use the serial port. ", - "Serial Port Warning", - JOptionPane.WARNING_MESSAGE); - } - return list; - } - */ - - - diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/SerialException.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/SerialException.java deleted file mode 100755 index 525c24078..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/SerialException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Copyright (c) 2007 David A. Mellis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - -public class SerialException extends Exception { - public SerialException() { - super(); - } - - public SerialException(String message) { - super(message); - } - - public SerialException(String message, Throwable cause) { - super(message, cause); - } - - public SerialException(Throwable cause) { - super(cause); - } -} diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/debug/MessageConsumer.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/debug/MessageConsumer.java deleted file mode 100755 index 5e2042943..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/debug/MessageConsumer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-06 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - - -/** - * Interface for dealing with parser/compiler output. - *

- * Different instances of MessageStream need to do different things with - * messages. In particular, a stream instance used for parsing output from - * the compiler compiler has to interpret its messages differently than one - * parsing output from the runtime. - *

- * Classes which consume messages and do something with them - * should implement this interface. - */ -public interface MessageConsumer { - - public void message(String s); - -} diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/debug/MessageSiphon.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/debug/MessageSiphon.java deleted file mode 100755 index 26901c3f4..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/debug/MessageSiphon.java +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-06 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.SocketException; - -/** - * Slurps up messages from compiler. - */ -public class MessageSiphon implements Runnable { - - private final BufferedReader streamReader; - private final MessageConsumer consumer; - - private Thread thread; - private boolean canRun; - - public MessageSiphon(InputStream stream, MessageConsumer consumer) { - this.streamReader = new BufferedReader(new InputStreamReader(stream)); - this.consumer = consumer; - this.canRun = true; - - thread = new Thread(this); - // don't set priority too low, otherwise exceptions won't - // bubble up in time (i.e. compile errors have a weird delay) - //thread.setPriority(Thread.MIN_PRIORITY); - thread.setPriority(Thread.MAX_PRIORITY - 1); - thread.start(); - } - - - public void run() { - try { - // process data until we hit EOF; this will happily block - // (effectively sleeping the thread) until new data comes in. - // when the program is finally done, null will come through. - // - String currentLine; - while (canRun && (currentLine = streamReader.readLine()) != null) { - // \n is added again because readLine() strips it out - //EditorConsole.systemOut.println("messaging in"); - consumer.message(currentLine + "\n"); - //EditorConsole.systemOut.println("messaging out"); - } - //EditorConsole.systemOut.println("messaging thread done"); - } catch (NullPointerException npe) { - // Fairly common exception during shutdown - } catch (SocketException e) { - // socket has been close while we were wainting for data. nothing to see here, move along - } catch (Exception e) { - // On Linux and sometimes on Mac OS X, a "bad file descriptor" - // message comes up when closing an applet that's run externally. - // That message just gets supressed here.. - String mess = e.getMessage(); - if ((mess != null) && - (mess.indexOf("Bad file descriptor") != -1)) { - //if (e.getMessage().indexOf("Bad file descriptor") == -1) { - //System.err.println("MessageSiphon err " + e); - //e.printStackTrace(); - } else { - e.printStackTrace(); - } - } finally { - thread = null; - } - } - - // Wait until the MessageSiphon thread is complete. - public void join() throws java.lang.InterruptedException { - // Grab a temp copy in case another thread nulls the "thread" - // member variable - Thread t = thread; - if (t != null) t.join(); - } - - public void stop() { - this.canRun = false; - } - -} diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/debug/RunnerException.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/debug/RunnerException.java deleted file mode 100755 index 0a67d1e80..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/debug/RunnerException.java +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-08 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - - -/** - * An exception with a line number attached that occurs - * during either compile time or run time. - */ -@SuppressWarnings("serial") -public class RunnerException extends Exception { - protected String message; - protected int codeIndex; - protected int codeLine; - protected int codeColumn; - protected boolean showStackTrace; - - - public RunnerException(String message) { - this(message, true); - } - - public RunnerException(String message, boolean showStackTrace) { - this(message, -1, -1, -1, showStackTrace); - } - - public RunnerException(String message, int file, int line) { - this(message, file, line, -1, true); - } - - - public RunnerException(String message, int file, int line, int column) { - this(message, file, line, column, true); - } - - - public RunnerException(String message, int file, int line, int column, - boolean showStackTrace) { - this.message = message; - this.codeIndex = file; - this.codeLine = line; - this.codeColumn = column; - this.showStackTrace = showStackTrace; - } - - - public RunnerException(Exception e) { - super(e); - this.showStackTrace = true; - } - - /** - * Override getMessage() in Throwable, so that I can set - * the message text outside the constructor. - */ - public String getMessage() { - return message; - } - - - public void setMessage(String message) { - this.message = message; - } - - - public int getCodeIndex() { - return codeIndex; - } - - - public void setCodeIndex(int index) { - codeIndex = index; - } - - - public boolean hasCodeIndex() { - return codeIndex != -1; - } - - - public int getCodeLine() { - return codeLine; - } - - - public void setCodeLine(int line) { - this.codeLine = line; - } - - - public boolean hasCodeLine() { - return codeLine != -1; - } - - - public void setCodeColumn(int column) { - this.codeColumn = column; - } - - - public int getCodeColumn() { - return codeColumn; - } - - - public void showStackTrace() { - showStackTrace = true; - } - - - public void hideStackTrace() { - showStackTrace = false; - } - - - /** - * Nix the java.lang crap out of an exception message - * because it scares the children. - *

- * This function must be static to be used with super() - * in each of the constructors above. - */ - /* - static public final String massage(String msg) { - if (msg.indexOf("java.lang.") == 0) { - //int dot = msg.lastIndexOf('.'); - msg = msg.substring("java.lang.".length()); - } - return msg; - //return (dot == -1) ? msg : msg.substring(dot+1); - } - */ - - - public void printStackTrace() { - if (showStackTrace) { - super.printStackTrace(); - } - } -} diff --git a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/helpers/ProcessUtils.java b/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/helpers/ProcessUtils.java deleted file mode 100755 index c023f5810..000000000 --- a/arduino/opencr_arduino/tools/linux/src/maple_loader/src/processing/app/helpers/ProcessUtils.java +++ /dev/null @@ -1,32 +0,0 @@ -package processing.app.helpers; - -//import processing.app.Base; - -import java.io.IOException; -import java.util.Map; - -import processing.app.Base; - -public class ProcessUtils { - - public static Process exec(String[] command) throws IOException { - // No problems on linux and mac - if (!Base.isWindows()) { - return Runtime.getRuntime().exec(command); - } - - // Brutal hack to workaround windows command line parsing. - // http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly - // http://msdn.microsoft.com/en-us/library/a1y7w461.aspx - // http://bugs.sun.com/view_bug.do?bug_id=6468220 - // http://bugs.sun.com/view_bug.do?bug_id=6518827 - String[] cmdLine = new String[command.length]; - for (int i = 0; i < command.length; i++) - cmdLine[i] = command[i].replace("\"", "\\\""); - - ProcessBuilder pb = new ProcessBuilder(cmdLine); - Map env = pb.environment(); - env.put("CYGWIN", "nodosfilewarning"); - return pb.start(); - } -} diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/AUTHORS b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/AUTHORS deleted file mode 100755 index d096f2205..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/AUTHORS +++ /dev/null @@ -1,19 +0,0 @@ -Authors ordered by first contribution. - -Geoffrey McRae -Bret Olmsted -Tormod Volden -Jakob Malm -Reuben Dowle -Matthias Kubisch -Paul Fertser -Daniel Strnad -Jérémie Rapin -Christian Pointner -Mats Erik Andersson -Alexey Borovik -Antonio Borneo -Armin van der Togt -Brian Silverman -Georg Hofmann -Luis Rodrigues diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/Android.mk b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/Android.mk deleted file mode 100755 index 7be3d0018..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/Android.mk +++ /dev/null @@ -1,20 +0,0 @@ -TOP_LOCAL_PATH := $(call my-dir) - -include $(call all-named-subdir-makefiles, parsers) - -LOCAL_PATH := $(TOP_LOCAL_PATH) - -include $(CLEAR_VARS) -LOCAL_MODULE := stm32flash -LOCAL_SRC_FILES := \ - dev_table.c \ - i2c.c \ - init.c \ - main.c \ - port.c \ - serial_common.c \ - serial_platform.c \ - stm32.c \ - utils.c -LOCAL_STATIC_LIBRARIES := libparsers -include $(BUILD_EXECUTABLE) diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/HOWTO b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/HOWTO deleted file mode 100755 index d8f32eb04..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/HOWTO +++ /dev/null @@ -1,35 +0,0 @@ -Add new interfaces: -===================================================================== -Current version 0.4 supports the following interfaces: -- UART Windows (either "COMn" and "\\.\COMn"); -- UART posix/Linux (e.g. "/dev/ttyUSB0"); -- I2C Linux through standard driver "i2c-dev" (e.g. "/dev/i2c-n"). - -Starting from version 0.4, the back-end of stm32flash is modular and -ready to be expanded to support new interfaces. -I'm planning adding SPI on Linux through standard driver "spidev". -You are invited to contribute with more interfaces. - -To add a new interface you need to add a new file, populate the struct -port_interface (check at the end of files i2c.c, serial_posix.c and -serial_w32.c) and provide the relative functions to operate on the -interface: open/close, read/write, get_cfg_str and the optional gpio. -The include the new drive in Makefile and register the new struct -port_interface in file port.c in struct port_interface *ports[]. - -There are several USB-I2C adapter in the market, each providing its -own libraries to communicate with the I2C bus. -Could be interesting to provide as back-end a bridge between stm32flash -and such libraries (I have no plan on this item). - - -Add new STM32 devices: -===================================================================== -Add a new line in file dev_table.c, in table devices[]. -The fields of the table are listed in stm32.h, struct stm32_dev. - - -Cross compile on Linux host for Windows target with MinGW: -===================================================================== -I'm using a 64 bit Arch Linux machines, and I usually run: - make CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/I2C.txt b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/I2C.txt deleted file mode 100755 index 4c05ff62d..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/I2C.txt +++ /dev/null @@ -1,94 +0,0 @@ -About I2C back-end communication in stm32flash -========================================================================== - -Starting from version v0.4, beside the serial communication port, -stm32flash adds support for I2C port to talk with STM32 bootloader. - -The current I2C back-end supports only the API provided by Linux kernel -driver "i2c-dev", so only I2C controllers with Linux kernel driver can be -used. -In Linux source code, most of the drivers for I2C and SMBUS controllers -are in - ./drivers/i2c/busses/ -Only I2C is supported by STM32 bootloader, so check the section below -about SMBUS. -No I2C support for Windows is available in stm32flash v0.4. - -Thanks to the new modular back-end, stm32flash can be easily extended to -support new back-ends and API. Check HOWTO file in stm32flash source code -for details. - -In the market there are several USB-to-I2C dongles; most of them are not -supported by kernel drivers. Manufacturer provide proprietary userspace -libraries using not standardized API. -These API and dongles could be supported in feature versions. - -There are currently 3 versions of STM32 bootloader for I2C communications: -- v1.0 using I2C clock stretching synchronization between host and STM32; -- v1.1 superset of v1.0, adds non stretching commands; -- v1.2 superset of v1.1, adds CRC command and compatibility with i2cdetect. -Details in ST application note AN2606. -All the bootloaders above are tested and working with stm32flash. - - -SMBUS controllers -========================================================================== - -Almost 50% of the drivers in Linux source code folder - ./drivers/i2c/busses/ -are for controllers that "only" support SMBUS protocol. They can NOT -operate with STM32 bootloader. -To identify if your controller supports I2C, use command: - i2cdetect -F n -where "n" is the number of the I2C interface (e.g. n=3 for "/dev/i2c-3"). -Controllers that supports I2C will report - I2C yes -Controller that support both I2C and SMBUS are ok. - -If you are interested on details about SMBUS protocol, you can download -the current specs from - http://smbus.org/specs/smbus20.pdf -and you can read the files in Linux source code - ./Documentation/i2c/i2c-protocol - ./Documentation/i2c/smbus-protocol - - -About bootloader v1.0 -========================================================================== - -Version v1.0 can have issues with some I2C controllers due to use of clock -stretching during commands that require long operations, like flash erase -and programming. - -Clock stretching is a technique to synchronize host and I2C device. When -I2C device wants to force a delay in the communication, it push "low" the -I2C clock; the I2C controller detects it and waits until I2C clock returns -"high". -Most I2C controllers set a "timeout" for clock stretching, ranging from -few milli-seconds to seconds depending on specific HW or SW driver. - -It is possible that the timeout in your I2C controller is smaller than the -delay required for flash erase or programming. In this case the I2C -controller will timeout and report error to stm32flash. -There is no possibility for stm32flash to retry, so it can only signal the -error and exit. - -To by-pass the issue with bootloader v1.0 you can modify the kernel driver -of your I2C controller. Not an easy job, since every controller has its own -way to handle the timeout. - -In my case I'm using the I2C controller integrated in the VGA port of my -laptop HP EliteBook 8460p. I built the 0.25$ VGA-to-I2C adapter reported in - http://www.paintyourdragon.com/?p=43 -To change the timeout of the I2C controller I had to modify the kernel file - drivers/gpu/drm/radeon/radeon_i2c.c -line 969 -- i2c->bit.timeout = usecs_to_jiffies(2200); /* from VESA */ -+ i2c->bit.timeout = msecs_to_jiffies(5000); /* 5s for STM32 */ -and recompile it. -Then - $> modprobe i2c-dev - $> chmod 666 /dev/i2c-7 - #> stm32flash -a 0x39 /dev/i2c-7 - -2014-09-16 Antonio Borneo diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/Makefile b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/Makefile deleted file mode 100755 index 0328d5588..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -PREFIX = /usr/local -CFLAGS += -Wall -g - -INSTALL = install - -OBJS = dev_table.o \ - i2c.o \ - init.o \ - main.o \ - port.o \ - serial_common.o \ - serial_platform.o \ - stm32.o \ - utils.o - -LIBOBJS = parsers/parsers.a - -all: stm32flash - -serial_platform.o: serial_posix.c serial_w32.c - -parsers/parsers.a: - cd parsers && $(MAKE) parsers.a - -stm32flash: $(OBJS) $(LIBOBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBOBJS) - -clean: - rm -f $(OBJS) stm32flash - cd parsers && $(MAKE) $@ - -install: all - $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin - $(INSTALL) -m 755 stm32flash $(DESTDIR)$(PREFIX)/bin - $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/man/man1 - $(INSTALL) -m 644 stm32flash.1 $(DESTDIR)$(PREFIX)/share/man/man1 - -.PHONY: all clean install diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/TODO b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/TODO deleted file mode 100755 index 41df614ff..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/TODO +++ /dev/null @@ -1,7 +0,0 @@ - -stm32: -- Add support for variable page size - -AUTHORS: -- Add contributors from Geoffrey's commits - diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/dev_table.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/dev_table.c deleted file mode 100755 index 399cd9d08..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/dev_table.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "stm32.h" - -/* - * Device table, corresponds to the "Bootloader device-dependant parameters" - * table in ST document AN2606. - * Note that the option bytes upper range is inclusive! - */ -const stm32_dev_t devices[] = { - /* F0 */ - {0x440, "STM32F051xx" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 4, 1024, 0x1FFFF800, 0x1FFFF80B, 0x1FFFEC00, 0x1FFFF800}, - {0x444, "STM32F030/F031" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 4, 1024, 0x1FFFF800, 0x1FFFF80B, 0x1FFFEC00, 0x1FFFF800}, - {0x445, "STM32F042xx" , 0x20001800, 0x20001800, 0x08000000, 0x08008000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC400, 0x1FFFF800}, - {0x448, "STM32F072xx" , 0x20001800, 0x20004000, 0x08000000, 0x08020000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC800, 0x1FFFF800}, - /* F1 */ - {0x412, "Low-density" , 0x20000200, 0x20002800, 0x08000000, 0x08008000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x410, "Medium-density" , 0x20000200, 0x20005000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x414, "High-density" , 0x20000200, 0x20010000, 0x08000000, 0x08080000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x420, "Medium-density VL" , 0x20000200, 0x20002000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x428, "High-density VL" , 0x20000200, 0x20008000, 0x08000000, 0x08080000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x418, "Connectivity line" , 0x20001000, 0x20010000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFB000, 0x1FFFF800}, - {0x430, "XL-density" , 0x20000800, 0x20018000, 0x08000000, 0x08100000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFE000, 0x1FFFF800}, - /* Note that F2 and F4 devices have sectors of different page sizes - and only the first sectors (of one page size) are included here */ - /* F2 */ - {0x411, "STM32F2xx" , 0x20002000, 0x20020000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77DF}, - /* F3 */ - {0x432, "STM32F373/8" , 0x20001400, 0x20008000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x422, "F302xB/303xB/358" , 0x20001400, 0x20010000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x439, "STM32F302x4(6/8)" , 0x20001800, 0x20004000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x438, "F303x4/334/328" , 0x20001800, 0x20003000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - /* F4 */ - {0x413, "STM32F40/1" , 0x20002000, 0x20020000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77DF}, - /* 0x419 is also used for STM32F429/39 but with other bootloader ID... */ - {0x419, "STM32F427/37" , 0x20002000, 0x20030000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - {0x423, "STM32F401xB(C)" , 0x20003000, 0x20010000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - {0x433, "STM32F401xD(E)" , 0x20003000, 0x20018000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - /* L0 */ - {0x417, "L05xxx/06xxx" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 32, 128, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - /* L1 */ - {0x416, "L1xxx6(8/B)" , 0x20000800, 0x20004000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - {0x429, "L1xxx6(8/B)A" , 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - {0x427, "L1xxxC" , 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF02000}, - {0x436, "L1xxxD" , 0x20001000, 0x2000C000, 0x08000000, 0x08060000, 16, 256, 0x1ff80000, 0x1ff8000F, 0x1FF00000, 0x1FF02000}, - {0x437, "L1xxxE" , 0x20001000, 0x20014000, 0x08000000, 0x08060000, 16, 256, 0x1ff80000, 0x1ff8000F, 0x1FF00000, 0x1FF02000}, - /* These are not (yet) in AN2606: */ - {0x641, "Medium_Density PL" , 0x20000200, 0x00005000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x9a8, "STM32W-128K" , 0x20000200, 0x20002000, 0x08000000, 0x08020000, 1, 1024, 0, 0, 0, 0}, - {0x9b0, "STM32W-256K" , 0x20000200, 0x20004000, 0x08000000, 0x08040000, 1, 2048, 0, 0, 0, 0}, - {0x0} -}; diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/gpl-2.0.txt b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/gpl-2.0.txt deleted file mode 100755 index d159169d1..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/gpl-2.0.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/i2c.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/i2c.c deleted file mode 100755 index 10e6bb15a..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/i2c.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - - -#if !defined(__linux__) - -static port_err_t i2c_open(struct port_interface *port, - struct port_options *ops) -{ - return PORT_ERR_NODEV; -} - -struct port_interface port_i2c = { - .name = "i2c", - .open = i2c_open, -}; - -#else - -#ifdef __ANDROID__ -#define I2C_SLAVE 0x0703 /* Use this slave address */ -#define I2C_FUNCS 0x0705 /* Get the adapter functionality mask */ -/* To determine what functionality is present */ -#define I2C_FUNC_I2C 0x00000001 -#else -#include -#include -#endif - -#include - -struct i2c_priv { - int fd; - int addr; -}; - -static port_err_t i2c_open(struct port_interface *port, - struct port_options *ops) -{ - struct i2c_priv *h; - int fd, addr, ret; - unsigned long funcs; - - /* 1. check device name match */ - if (strncmp(ops->device, "/dev/i2c-", strlen("/dev/i2c-"))) - return PORT_ERR_NODEV; - - /* 2. check options */ - addr = ops->bus_addr; - if (addr < 0x03 || addr > 0x77) { - fprintf(stderr, "I2C address out of range [0x03-0x77]\n"); - return PORT_ERR_UNKNOWN; - } - - /* 3. open it */ - h = calloc(sizeof(*h), 1); - if (h == NULL) { - fprintf(stderr, "End of memory\n"); - return PORT_ERR_UNKNOWN; - } - fd = open(ops->device, O_RDWR); - if (fd < 0) { - fprintf(stderr, "Unable to open special file \"%s\"\n", - ops->device); - free(h); - return PORT_ERR_UNKNOWN; - } - - /* 3.5. Check capabilities */ - ret = ioctl(fd, I2C_FUNCS, &funcs); - if (ret < 0) { - fprintf(stderr, "I2C ioctl(funcs) error %d\n", errno); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - if ((funcs & I2C_FUNC_I2C) == 0) { - fprintf(stderr, "Error: controller is not I2C, only SMBUS.\n"); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - - /* 4. set options */ - ret = ioctl(fd, I2C_SLAVE, addr); - if (ret < 0) { - fprintf(stderr, "I2C ioctl(slave) error %d\n", errno); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - - h->fd = fd; - h->addr = addr; - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t i2c_close(struct port_interface *port) -{ - struct i2c_priv *h; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - close(h->fd); - free(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t i2c_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - struct i2c_priv *h; - int ret; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - ret = read(h->fd, buf, nbyte); - if (ret != nbyte) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; -} - -static port_err_t i2c_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - struct i2c_priv *h; - int ret; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - ret = write(h->fd, buf, nbyte); - if (ret != nbyte) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; -} - -static port_err_t i2c_gpio(struct port_interface *port, serial_gpio_t n, - int level) -{ - return PORT_ERR_OK; -} - -static const char *i2c_get_cfg_str(struct port_interface *port) -{ - struct i2c_priv *h; - static char str[11]; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return "INVALID"; - snprintf(str, sizeof(str), "addr 0x%2x", h->addr); - return str; -} - -static struct varlen_cmd i2c_cmd_get_reply[] = { - {0x10, 11}, - {0x11, 17}, - {0x12, 18}, - { /* sentinel */ } -}; - -struct port_interface port_i2c = { - .name = "i2c", - .flags = PORT_STRETCH_W, - .open = i2c_open, - .close = i2c_close, - .read = i2c_read, - .write = i2c_write, - .gpio = i2c_gpio, - .cmd_get_reply = i2c_cmd_get_reply, - .get_cfg_str = i2c_get_cfg_str, -}; - -#endif diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/init.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/init.c deleted file mode 100755 index 77a571bd8..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/init.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include "init.h" -#include "serial.h" -#include "stm32.h" -#include "port.h" - -struct gpio_list { - struct gpio_list *next; - int gpio; -}; - - -static int write_to(const char *filename, const char *value) -{ - int fd, ret; - - fd = open(filename, O_WRONLY); - if (fd < 0) { - fprintf(stderr, "Cannot open file \"%s\"\n", filename); - return 0; - } - ret = write(fd, value, strlen(value)); - if (ret < 0) { - fprintf(stderr, "Error writing in file \"%s\"\n", filename); - close(fd); - return 0; - } - close(fd); - return 1; -} - -#if !defined(__linux__) -static int drive_gpio(int n, int level, struct gpio_list **gpio_to_release) -{ - fprintf(stderr, "GPIO control only available in Linux\n"); - return 0; -} -#else -static int drive_gpio(int n, int level, struct gpio_list **gpio_to_release) -{ - char num[16]; /* sized to carry MAX_INT */ - char file[48]; /* sized to carry longest filename */ - struct stat buf; - struct gpio_list *new; - int ret; - - sprintf(file, "/sys/class/gpio/gpio%d/direction", n); - ret = stat(file, &buf); - if (ret) { - /* file miss, GPIO not exported yet */ - sprintf(num, "%d", n); - ret = write_to("/sys/class/gpio/export", num); - if (!ret) - return 0; - ret = stat(file, &buf); - if (ret) { - fprintf(stderr, "GPIO %d not available\n", n); - return 0; - } - new = (struct gpio_list *)malloc(sizeof(struct gpio_list)); - if (new == NULL) { - fprintf(stderr, "Out of memory\n"); - return 0; - } - new->gpio = n; - new->next = *gpio_to_release; - *gpio_to_release = new; - } - - return write_to(file, level ? "high" : "low"); -} -#endif - -static int release_gpio(int n) -{ - char num[16]; /* sized to carry MAX_INT */ - - sprintf(num, "%d", n); - return write_to("/sys/class/gpio/unexport", num); -} - -static int gpio_sequence(struct port_interface *port, const char *s, size_t l) -{ - struct gpio_list *gpio_to_release = NULL, *to_free; - int ret, level, gpio; - - ret = 1; - while (ret == 1 && *s && l > 0) { - if (*s == '-') { - level = 0; - s++; - l--; - } else - level = 1; - - if (isdigit(*s)) { - gpio = atoi(s); - while (isdigit(*s)) { - s++; - l--; - } - } else if (!strncmp(s, "rts", 3)) { - gpio = -GPIO_RTS; - s += 3; - l -= 3; - } else if (!strncmp(s, "dtr", 3)) { - gpio = -GPIO_DTR; - s += 3; - l -= 3; - } else if (!strncmp(s, "brk", 3)) { - gpio = -GPIO_BRK; - s += 3; - l -= 3; - } else { - fprintf(stderr, "Character \'%c\' is not a digit\n", *s); - ret = 0; - break; - } - - if (*s && (l > 0)) { - if (*s == ',') { - s++; - l--; - } else { - fprintf(stderr, "Character \'%c\' is not a separator\n", *s); - ret = 0; - break; - } - } - if (gpio < 0) - ret = (port->gpio(port, -gpio, level) == PORT_ERR_OK); - else - ret = drive_gpio(gpio, level, &gpio_to_release); - usleep(100000); - } - - while (gpio_to_release) { - release_gpio(gpio_to_release->gpio); - to_free = gpio_to_release; - gpio_to_release = gpio_to_release->next; - free(to_free); - } - usleep(500000); - return ret; -} - -static int gpio_bl_entry(struct port_interface *port, const char *seq) -{ - char *s; - - if (seq == NULL || seq[0] == ':') - return 1; - - s = strchr(seq, ':'); - if (s == NULL) - return gpio_sequence(port, seq, strlen(seq)); - - return gpio_sequence(port, seq, s - seq); -} - -static int gpio_bl_exit(struct port_interface *port, const char *seq) -{ - char *s; - - if (seq == NULL) - return 1; - - s = strchr(seq, ':'); - if (s == NULL || s[1] == '\0') - return 1; - - return gpio_sequence(port, s + 1, strlen(s + 1)); -} - -int init_bl_entry(struct port_interface *port, const char *seq) -{ - if (seq) - return gpio_bl_entry(port, seq); - - return 1; -} - -int init_bl_exit(stm32_t *stm, struct port_interface *port, const char *seq) -{ - if (seq) - return gpio_bl_exit(port, seq); - - if (stm32_reset_device(stm) != STM32_ERR_OK) - return 0; - return 1; -} diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/init.h b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/init.h deleted file mode 100755 index 6075b519b..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/init.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _INIT_H -#define _INIT_H - -#include "stm32.h" -#include "port.h" - -int init_bl_entry(struct port_interface *port, const char *seq); -int init_bl_exit(stm32_t *stm, struct port_interface *port, const char *seq); - -#endif diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/main.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/main.c deleted file mode 100755 index f081d6131..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/main.c +++ /dev/null @@ -1,774 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright 2010 Geoffrey McRae - Copyright 2011 Steve Markgraf - Copyright 2012 Tormod Volden - Copyright 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "init.h" -#include "utils.h" -#include "serial.h" -#include "stm32.h" -#include "parsers/parser.h" -#include "port.h" - -#include "parsers/binary.h" -#include "parsers/hex.h" - -#define VERSION "Arduino_STM32_0.9" - -/* device globals */ -stm32_t *stm = NULL; - -void *p_st = NULL; -parser_t *parser = NULL; - -/* settings */ -struct port_options port_opts = { - .device = NULL, - .baudRate = SERIAL_BAUD_57600, - .serial_mode = "8e1", - .bus_addr = 0, - .rx_frame_max = STM32_MAX_RX_FRAME, - .tx_frame_max = STM32_MAX_TX_FRAME, -}; -int rd = 0; -int wr = 0; -int wu = 0; -int rp = 0; -int ur = 0; -int eraseOnly = 0; -int crc = 0; -int npages = 0; -int spage = 0; -int no_erase = 0; -char verify = 0; -int retry = 10; -char exec_flag = 0; -uint32_t execute = 0; -char init_flag = 1; -char force_binary = 0; -char reset_flag = 0; -char *filename; -char *gpio_seq = NULL; -uint32_t start_addr = 0; -uint32_t readwrite_len = 0; - -/* functions */ -int parse_options(int argc, char *argv[]); -void show_help(char *name); - -static int is_addr_in_ram(uint32_t addr) -{ - return addr >= stm->dev->ram_start && addr < stm->dev->ram_end; -} - -static int is_addr_in_flash(uint32_t addr) -{ - return addr >= stm->dev->fl_start && addr < stm->dev->fl_end; -} - -static int flash_addr_to_page_floor(uint32_t addr) -{ - if (!is_addr_in_flash(addr)) - return 0; - - return (addr - stm->dev->fl_start) / stm->dev->fl_ps; -} - -static int flash_addr_to_page_ceil(uint32_t addr) -{ - if (!(addr >= stm->dev->fl_start && addr <= stm->dev->fl_end)) - return 0; - - return (addr + stm->dev->fl_ps - 1 - stm->dev->fl_start) - / stm->dev->fl_ps; -} - -static uint32_t flash_page_to_addr(int page) -{ - return stm->dev->fl_start + page * stm->dev->fl_ps; -} - -int main(int argc, char* argv[]) { - struct port_interface *port = NULL; - int ret = 1; - stm32_err_t s_err; - parser_err_t perr; - FILE *diag = stdout; - - fprintf(diag, "stm32flash " VERSION "\n\n"); - fprintf(diag, "http://github.com/rogerclarkmelbourne/arduino_stm32\n\n"); - if (parse_options(argc, argv) != 0) - goto close; - - if (rd && filename[0] == '-') { - diag = stderr; - } - - if (wr) { - /* first try hex */ - if (!force_binary) { - parser = &PARSER_HEX; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - } - - if (force_binary || (perr = parser->open(p_st, filename, 0)) != PARSER_ERR_OK) { - if (force_binary || perr == PARSER_ERR_INVALID_FILE) { - if (!force_binary) { - parser->close(p_st); - p_st = NULL; - } - - /* now try binary */ - parser = &PARSER_BINARY; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - perr = parser->open(p_st, filename, 0); - } - - /* if still have an error, fail */ - if (perr != PARSER_ERR_OK) { - fprintf(stderr, "%s ERROR: %s\n", parser->name, parser_errstr(perr)); - if (perr == PARSER_ERR_SYSTEM) perror(filename); - goto close; - } - } - - fprintf(diag, "Using Parser : %s\n", parser->name); - } else { - parser = &PARSER_BINARY; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - } - - if (port_open(&port_opts, &port) != PORT_ERR_OK) { - fprintf(stderr, "Failed to open port: %s\n", port_opts.device); - goto close; - } - - fprintf(diag, "Interface %s: %s\n", port->name, port->get_cfg_str(port)); - if (init_flag && init_bl_entry(port, gpio_seq) == 0) - goto close; - stm = stm32_init(port, init_flag); - if (!stm) - goto close; - - fprintf(diag, "Version : 0x%02x\n", stm->bl_version); - if (port->flags & PORT_GVR_ETX) { - fprintf(diag, "Option 1 : 0x%02x\n", stm->option1); - fprintf(diag, "Option 2 : 0x%02x\n", stm->option2); - } - fprintf(diag, "Device ID : 0x%04x (%s)\n", stm->pid, stm->dev->name); - fprintf(diag, "- RAM : %dKiB (%db reserved by bootloader)\n", (stm->dev->ram_end - 0x20000000) / 1024, stm->dev->ram_start - 0x20000000); - fprintf(diag, "- Flash : %dKiB (sector size: %dx%d)\n", (stm->dev->fl_end - stm->dev->fl_start ) / 1024, stm->dev->fl_pps, stm->dev->fl_ps); - fprintf(diag, "- Option RAM : %db\n", stm->dev->opt_end - stm->dev->opt_start + 1); - fprintf(diag, "- System RAM : %dKiB\n", (stm->dev->mem_end - stm->dev->mem_start) / 1024); - - uint8_t buffer[256]; - uint32_t addr, start, end; - unsigned int len; - int failed = 0; - int first_page, num_pages; - - /* - * Cleanup addresses: - * - * Starting from options - * start_addr, readwrite_len, spage, npages - * and using device memory size, compute - * start, end, first_page, num_pages - */ - if (start_addr || readwrite_len) { - start = start_addr; - - if (is_addr_in_flash(start)) - end = stm->dev->fl_end; - else { - no_erase = 1; - if (is_addr_in_ram(start)) - end = stm->dev->ram_end; - else - end = start + sizeof(uint32_t); - } - - if (readwrite_len && (end > start + readwrite_len)) - end = start + readwrite_len; - - first_page = flash_addr_to_page_floor(start); - if (!first_page && end == stm->dev->fl_end) - num_pages = 0xff; /* mass erase */ - else - num_pages = flash_addr_to_page_ceil(end) - first_page; - } else if (!spage && !npages) { - start = stm->dev->fl_start; - end = stm->dev->fl_end; - first_page = 0; - num_pages = 0xff; /* mass erase */ - } else { - first_page = spage; - start = flash_page_to_addr(first_page); - if (start > stm->dev->fl_end) { - fprintf(stderr, "Address range exceeds flash size.\n"); - goto close; - } - - if (npages) { - num_pages = npages; - end = flash_page_to_addr(first_page + num_pages); - if (end > stm->dev->fl_end) - end = stm->dev->fl_end; - } else { - end = stm->dev->fl_end; - num_pages = flash_addr_to_page_ceil(end) - first_page; - } - - if (!first_page && end == stm->dev->fl_end) - num_pages = 0xff; /* mass erase */ - } - - if (rd) { - unsigned int max_len = port_opts.rx_frame_max; - - fprintf(diag, "Memory read\n"); - - perr = parser->open(p_st, filename, 1); - if (perr != PARSER_ERR_OK) { - fprintf(stderr, "%s ERROR: %s\n", parser->name, parser_errstr(perr)); - if (perr == PARSER_ERR_SYSTEM) - perror(filename); - goto close; - } - - fflush(diag); - addr = start; - while(addr < end) { - uint32_t left = end - addr; - len = max_len > left ? left : max_len; - s_err = stm32_read_memory(stm, addr, buffer, len); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read memory at address 0x%08x, target write-protected?\n", addr); - goto close; - } - if (parser->write(p_st, buffer, len) != PARSER_ERR_OK) - { - fprintf(stderr, "Failed to write data to file\n"); - goto close; - } - addr += len; - - fprintf(diag, - "\rRead address 0x%08x (%.2f%%) ", - addr, - (100.0f / (float)(end - start)) * (float)(addr - start) - ); - fflush(diag); - } - fprintf(diag, "Done.\n"); - ret = 0; - goto close; - } else if (rp) { - fprintf(stdout, "Read-Protecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_readprot_memory(stm); - fprintf(stdout, "Done.\n"); - } else if (ur) { - fprintf(stdout, "Read-UnProtecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_runprot_memory(stm); - fprintf(stdout, "Done.\n"); - } else if (eraseOnly) { - ret = 0; - fprintf(stdout, "Erasing flash\n"); - - if (num_pages != 0xff && - (start != flash_page_to_addr(first_page) - || end != flash_page_to_addr(first_page + num_pages))) { - fprintf(stderr, "Specified start & length are invalid (must be page aligned)\n"); - ret = 1; - goto close; - } - - s_err = stm32_erase_memory(stm, first_page, num_pages); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to erase memory\n"); - ret = 1; - goto close; - } - } else if (wu) { - fprintf(diag, "Write-unprotecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_wunprot_memory(stm); - fprintf(diag, "Done.\n"); - - } else if (wr) { - fprintf(diag, "Write to memory\n"); - - off_t offset = 0; - ssize_t r; - unsigned int size; - unsigned int max_wlen, max_rlen; - - max_wlen = port_opts.tx_frame_max - 2; /* skip len and crc */ - max_wlen &= ~3; /* 32 bit aligned */ - - max_rlen = port_opts.rx_frame_max; - max_rlen = max_rlen < max_wlen ? max_rlen : max_wlen; - - /* Assume data from stdin is whole device */ - if (filename[0] == '-' && filename[1] == '\0') - size = end - start; - else - size = parser->size(p_st); - - // TODO: It is possible to write to non-page boundaries, by reading out flash - // from partial pages and combining with the input data - // if ((start % stm->dev->fl_ps) != 0 || (end % stm->dev->fl_ps) != 0) { - // fprintf(stderr, "Specified start & length are invalid (must be page aligned)\n"); - // goto close; - // } - - // TODO: If writes are not page aligned, we should probably read out existing flash - // contents first, so it can be preserved and combined with new data - if (!no_erase && num_pages) { - fprintf(diag, "Erasing memory\n"); - s_err = stm32_erase_memory(stm, first_page, num_pages); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to erase memory\n"); - goto close; - } - } - - fflush(diag); - addr = start; - while(addr < end && offset < size) { - uint32_t left = end - addr; - len = max_wlen > left ? left : max_wlen; - len = len > size - offset ? size - offset : len; - - if (parser->read(p_st, buffer, &len) != PARSER_ERR_OK) - goto close; - - if (len == 0) { - if (filename[0] == '-') { - break; - } else { - fprintf(stderr, "Failed to read input file\n"); - goto close; - } - } - - again: - s_err = stm32_write_memory(stm, addr, buffer, len); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to write memory at address 0x%08x\n", addr); - goto close; - } - - if (verify) { - uint8_t compare[len]; - unsigned int offset, rlen; - - offset = 0; - while (offset < len) { - rlen = len - offset; - rlen = rlen < max_rlen ? rlen : max_rlen; - s_err = stm32_read_memory(stm, addr + offset, compare + offset, rlen); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read memory at address 0x%08x\n", addr + offset); - goto close; - } - offset += rlen; - } - - for(r = 0; r < len; ++r) - if (buffer[r] != compare[r]) { - if (failed == retry) { - fprintf(stderr, "Failed to verify at address 0x%08x, expected 0x%02x and found 0x%02x\n", - (uint32_t)(addr + r), - buffer [r], - compare[r] - ); - goto close; - } - ++failed; - goto again; - } - - failed = 0; - } - - addr += len; - offset += len; - - fprintf(diag, - "\rWrote %saddress 0x%08x (%.2f%%) ", - verify ? "and verified " : "", - addr, - (100.0f / size) * offset - ); - fflush(diag); - - } - - fprintf(diag, "Done.\n"); - ret = 0; - goto close; - } else if (crc) { - uint32_t crc_val = 0; - - fprintf(diag, "CRC computation\n"); - - s_err = stm32_crc_wrapper(stm, start, end - start, &crc_val); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read CRC\n"); - goto close; - } - fprintf(diag, "CRC(0x%08x-0x%08x) = 0x%08x\n", start, end, - crc_val); - ret = 0; - goto close; - } else - ret = 0; - -close: - if (stm && exec_flag && ret == 0) { - if (execute == 0) - execute = stm->dev->fl_start; - - fprintf(diag, "\nStarting execution at address 0x%08x... ", execute); - fflush(diag); - if (stm32_go(stm, execute) == STM32_ERR_OK) { - reset_flag = 0; - fprintf(diag, "done.\n"); - } else - fprintf(diag, "failed.\n"); - } - - if (stm && reset_flag) { - fprintf(diag, "\nResetting device... "); - fflush(diag); - if (init_bl_exit(stm, port, gpio_seq)) - fprintf(diag, "done.\n"); - else fprintf(diag, "failed.\n"); - } - - if (p_st ) parser->close(p_st); - if (stm ) stm32_close (stm); - if (port) - port->close(port); - - fprintf(diag, "\n"); - return ret; -} - -int parse_options(int argc, char *argv[]) -{ - int c; - char *pLen; - - while ((c = getopt(argc, argv, "a:b:m:r:w:e:vn:g:jkfcChuos:S:F:i:R")) != -1) { - switch(c) { - case 'a': - port_opts.bus_addr = strtoul(optarg, NULL, 0); - break; - - case 'b': - port_opts.baudRate = serial_get_baud(strtoul(optarg, NULL, 0)); - if (port_opts.baudRate == SERIAL_BAUD_INVALID) { - serial_baud_t baudrate; - fprintf(stderr, "Invalid baud rate, valid options are:\n"); - for (baudrate = SERIAL_BAUD_1200; baudrate != SERIAL_BAUD_INVALID; ++baudrate) - fprintf(stderr, " %d\n", serial_get_baud_int(baudrate)); - return 1; - } - break; - - case 'm': - if (strlen(optarg) != 3 - || serial_get_bits(optarg) == SERIAL_BITS_INVALID - || serial_get_parity(optarg) == SERIAL_PARITY_INVALID - || serial_get_stopbit(optarg) == SERIAL_STOPBIT_INVALID) { - fprintf(stderr, "Invalid serial mode\n"); - return 1; - } - port_opts.serial_mode = optarg; - break; - - case 'r': - case 'w': - rd = rd || c == 'r'; - wr = wr || c == 'w'; - if (rd && wr) { - fprintf(stderr, "ERROR: Invalid options, can't read & write at the same time\n"); - return 1; - } - filename = optarg; - if (filename[0] == '-') { - force_binary = 1; - } - break; - case 'e': - if (readwrite_len || start_addr) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } - npages = strtoul(optarg, NULL, 0); - if (npages > 0xFF || npages < 0) { - fprintf(stderr, "ERROR: You need to specify a page count between 0 and 255"); - return 1; - } - if (!npages) - no_erase = 1; - break; - case 'u': - wu = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't write unprotect and read/write at the same time\n"); - return 1; - } - break; - - case 'j': - rp = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't read protect and read/write at the same time\n"); - return 1; - } - break; - - case 'k': - ur = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't read unprotect and read/write at the same time\n"); - return 1; - } - break; - - case 'o': - eraseOnly = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't erase-only and read/write at the same time\n"); - return 1; - } - break; - - case 'v': - verify = 1; - break; - - case 'n': - retry = strtoul(optarg, NULL, 0); - break; - - case 'g': - exec_flag = 1; - execute = strtoul(optarg, NULL, 0); - if (execute % 4 != 0) { - fprintf(stderr, "ERROR: Execution address must be word-aligned\n"); - return 1; - } - break; - case 's': - if (readwrite_len || start_addr) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } - spage = strtoul(optarg, NULL, 0); - break; - case 'S': - if (spage || npages) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } else { - start_addr = strtoul(optarg, &pLen, 0); - if (*pLen == ':') { - pLen++; - readwrite_len = strtoul(pLen, NULL, 0); - if (readwrite_len == 0) { - fprintf(stderr, "ERROR: Invalid options, can't specify zero length\n"); - return 1; - } - } - } - break; - case 'F': - port_opts.rx_frame_max = strtoul(optarg, &pLen, 0); - if (*pLen == ':') { - pLen++; - port_opts.tx_frame_max = strtoul(pLen, NULL, 0); - } - if (port_opts.rx_frame_max < 0 - || port_opts.tx_frame_max < 0) { - fprintf(stderr, "ERROR: Invalid negative value for option -F\n"); - return 1; - } - if (port_opts.rx_frame_max == 0) - port_opts.rx_frame_max = STM32_MAX_RX_FRAME; - if (port_opts.tx_frame_max == 0) - port_opts.tx_frame_max = STM32_MAX_TX_FRAME; - if (port_opts.rx_frame_max < 20 - || port_opts.tx_frame_max < 5) { - fprintf(stderr, "ERROR: current code cannot work with small frames.\n"); - fprintf(stderr, "min(RX) = 20, min(TX) = 5\n"); - return 1; - } - if (port_opts.rx_frame_max > STM32_MAX_RX_FRAME) { - fprintf(stderr, "WARNING: Ignore RX length in option -F\n"); - port_opts.rx_frame_max = STM32_MAX_RX_FRAME; - } - if (port_opts.tx_frame_max > STM32_MAX_TX_FRAME) { - fprintf(stderr, "WARNING: Ignore TX length in option -F\n"); - port_opts.tx_frame_max = STM32_MAX_TX_FRAME; - } - break; - case 'f': - force_binary = 1; - break; - - case 'c': - init_flag = 0; - break; - - case 'h': - show_help(argv[0]); - exit(0); - - case 'i': - gpio_seq = optarg; - break; - - case 'R': - reset_flag = 1; - break; - - case 'C': - crc = 1; - break; - } - } - - for (c = optind; c < argc; ++c) { - if (port_opts.device) { - fprintf(stderr, "ERROR: Invalid parameter specified\n"); - show_help(argv[0]); - return 1; - } - port_opts.device = argv[c]; - } - - if (port_opts.device == NULL) { - fprintf(stderr, "ERROR: Device not specified\n"); - show_help(argv[0]); - return 1; - } - - if (!wr && verify) { - fprintf(stderr, "ERROR: Invalid usage, -v is only valid when writing\n"); - show_help(argv[0]); - return 1; - } - - return 0; -} - -void show_help(char *name) { - fprintf(stderr, - "Usage: %s [-bvngfhc] [-[rw] filename] [tty_device | i2c_device]\n" - " -a bus_address Bus address (e.g. for I2C port)\n" - " -b rate Baud rate (default 57600)\n" - " -m mode Serial port mode (default 8e1)\n" - " -r filename Read flash to file (or - stdout)\n" - " -w filename Write flash from file (or - stdout)\n" - " -C Compute CRC of flash content\n" - " -u Disable the flash write-protection\n" - " -j Enable the flash read-protection\n" - " -k Disable the flash read-protection\n" - " -o Erase only\n" - " -e n Only erase n pages before writing the flash\n" - " -v Verify writes\n" - " -n count Retry failed writes up to count times (default 10)\n" - " -g address Start execution at specified address (0 = flash start)\n" - " -S address[:length] Specify start address and optionally length for\n" - " read/write/erase operations\n" - " -F RX_length[:TX_length] Specify the max length of RX and TX frame\n" - " -s start_page Flash at specified page (0 = flash start)\n" - " -f Force binary parser\n" - " -h Show this help\n" - " -c Resume the connection (don't send initial INIT)\n" - " *Baud rate must be kept the same as the first init*\n" - " This is useful if the reset fails\n" - " -i GPIO_string GPIO sequence to enter/exit bootloader mode\n" - " GPIO_string=[entry_seq][:[exit_seq]]\n" - " sequence=[-]n[,sequence]\n" - " -R Reset device at exit.\n" - "\n" - "Examples:\n" - " Get device information:\n" - " %s /dev/ttyS0\n" - " or:\n" - " %s /dev/i2c-0\n" - "\n" - " Write with verify and then start execution:\n" - " %s -w filename -v -g 0x0 /dev/ttyS0\n" - "\n" - " Read flash to file:\n" - " %s -r filename /dev/ttyS0\n" - "\n" - " Read 100 bytes of flash from 0x1000 to stdout:\n" - " %s -r - -S 0x1000:100 /dev/ttyS0\n" - "\n" - " Start execution:\n" - " %s -g 0x0 /dev/ttyS0\n" - "\n" - " GPIO sequence:\n" - " - entry sequence: GPIO_3=low, GPIO_2=low, GPIO_2=high\n" - " - exit sequence: GPIO_3=high, GPIO_2=low, GPIO_2=high\n" - " %s -i -3,-2,2:3,-2,2 /dev/ttyS0\n", - name, - name, - name, - name, - name, - name, - name, - name - ); -} - diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/Android.mk b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/Android.mk deleted file mode 100755 index afec18cd5..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := libparsers -LOCAL_SRC_FILES := binary.c hex.c -include $(BUILD_STATIC_LIBRARY) diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/Makefile b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/Makefile deleted file mode 100755 index bb7df1e02..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -CFLAGS += -Wall -g - -all: parsers.a - -parsers.a: binary.o hex.o - $(AR) rc $@ binary.o hex.o - -clean: - rm -f *.o parsers.a - -.PHONY: all clean diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/binary.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/binary.c deleted file mode 100755 index f491952bb..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/binary.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include - -#include "binary.h" - -typedef struct { - int fd; - char write; - struct stat stat; -} binary_t; - -void* binary_init() { - return calloc(sizeof(binary_t), 1); -} - -parser_err_t binary_open(void *storage, const char *filename, const char write) { - binary_t *st = storage; - if (write) { - if (filename[0] == '-') - st->fd = 1; - else - st->fd = open( - filename, -#ifndef __WIN32__ - O_WRONLY | O_CREAT | O_TRUNC, -#else - O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, -#endif -#ifndef __WIN32__ - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#else - 0 -#endif - ); - st->stat.st_size = 0; - } else { - if (filename[0] == '-') { - st->fd = 0; - } else { - if (stat(filename, &st->stat) != 0) - return PARSER_ERR_INVALID_FILE; - st->fd = open(filename, -#ifndef __WIN32__ - O_RDONLY -#else - O_RDONLY | O_BINARY -#endif - ); - } - } - - st->write = write; - return st->fd == -1 ? PARSER_ERR_SYSTEM : PARSER_ERR_OK; -} - -parser_err_t binary_close(void *storage) { - binary_t *st = storage; - - if (st->fd) close(st->fd); - free(st); - return PARSER_ERR_OK; -} - -unsigned int binary_size(void *storage) { - binary_t *st = storage; - return st->stat.st_size; -} - -parser_err_t binary_read(void *storage, void *data, unsigned int *len) { - binary_t *st = storage; - unsigned int left = *len; - if (st->write) return PARSER_ERR_WRONLY; - - ssize_t r; - while(left > 0) { - r = read(st->fd, data, left); - /* If there is no data to read at all, return OK, but with zero read */ - if (r == 0 && left == *len) { - *len = 0; - return PARSER_ERR_OK; - } - if (r <= 0) return PARSER_ERR_SYSTEM; - left -= r; - data += r; - } - - *len = *len - left; - return PARSER_ERR_OK; -} - -parser_err_t binary_write(void *storage, void *data, unsigned int len) { - binary_t *st = storage; - if (!st->write) return PARSER_ERR_RDONLY; - - ssize_t r; - while(len > 0) { - r = write(st->fd, data, len); - if (r < 1) return PARSER_ERR_SYSTEM; - st->stat.st_size += r; - - len -= r; - data += r; - } - - return PARSER_ERR_OK; -} - -parser_t PARSER_BINARY = { - "Raw BINARY", - binary_init, - binary_open, - binary_close, - binary_size, - binary_read, - binary_write -}; - diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/binary.h b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/binary.h deleted file mode 100755 index d989acfa0..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/binary.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _PARSER_BINARY_H -#define _PARSER_BINARY_H - -#include "parser.h" - -extern parser_t PARSER_BINARY; -#endif diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/hex.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/hex.c deleted file mode 100755 index 3baf85623..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/hex.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include - -#include "hex.h" -#include "../utils.h" - -typedef struct { - size_t data_len, offset; - uint8_t *data; - uint8_t base; -} hex_t; - -void* hex_init() { - return calloc(sizeof(hex_t), 1); -} - -parser_err_t hex_open(void *storage, const char *filename, const char write) { - hex_t *st = storage; - if (write) { - return PARSER_ERR_RDONLY; - } else { - char mark; - int i, fd; - uint8_t checksum; - unsigned int c; - uint32_t base = 0; - unsigned int last_address = 0x0; - - fd = open(filename, O_RDONLY); - if (fd < 0) - return PARSER_ERR_SYSTEM; - - /* read in the file */ - - while(read(fd, &mark, 1) != 0) { - if (mark == '\n' || mark == '\r') continue; - if (mark != ':') - return PARSER_ERR_INVALID_FILE; - - char buffer[9]; - unsigned int reclen, address, type; - uint8_t *record = NULL; - - /* get the reclen, address, and type */ - buffer[8] = 0; - if (read(fd, &buffer, 8) != 8) return PARSER_ERR_INVALID_FILE; - if (sscanf(buffer, "%2x%4x%2x", &reclen, &address, &type) != 3) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* setup the checksum */ - checksum = - reclen + - ((address & 0xFF00) >> 8) + - ((address & 0x00FF) >> 0) + - type; - - switch(type) { - /* data record */ - case 0: - c = address - last_address; - st->data = realloc(st->data, st->data_len + c + reclen); - - /* if there is a gap, set it to 0xff and increment the length */ - if (c > 0) { - memset(&st->data[st->data_len], 0xff, c); - st->data_len += c; - } - - last_address = address + reclen; - record = &st->data[st->data_len]; - st->data_len += reclen; - break; - - /* extended segment address record */ - case 2: - base = 0; - break; - - /* extended linear address record */ - case 4: - base = address; - break; - } - - buffer[2] = 0; - for(i = 0; i < reclen; ++i) { - if (read(fd, &buffer, 2) != 2 || sscanf(buffer, "%2x", &c) != 1) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* add the byte to the checksum */ - checksum += c; - - switch(type) { - case 0: - if (record != NULL) { - record[i] = c; - } else { - return PARSER_ERR_INVALID_FILE; - } - break; - - case 2: - case 4: - base = (base << 8) | c; - break; - } - } - - /* read, scan, and verify the checksum */ - if ( - read(fd, &buffer, 2 ) != 2 || - sscanf(buffer, "%2x", &c) != 1 || - (uint8_t)(checksum + c) != 0x00 - ) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - switch(type) { - /* EOF */ - case 1: - close(fd); - return PARSER_ERR_OK; - - /* address record */ - case 2: base = base << 4; - case 4: base = be_u32(base); - /* Reset last_address since our base changed */ - last_address = 0; - - if (st->base == 0) { - st->base = base; - break; - } - - /* we cant cope with files out of order */ - if (base < st->base) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* if there is a gap, enlarge and fill with zeros */ - unsigned int len = base - st->base; - if (len > st->data_len) { - st->data = realloc(st->data, len); - memset(&st->data[st->data_len], 0, len - st->data_len); - st->data_len = len; - } - break; - } - } - - close(fd); - return PARSER_ERR_OK; - } -} - -parser_err_t hex_close(void *storage) { - hex_t *st = storage; - if (st) free(st->data); - free(st); - return PARSER_ERR_OK; -} - -unsigned int hex_size(void *storage) { - hex_t *st = storage; - return st->data_len; -} - -parser_err_t hex_read(void *storage, void *data, unsigned int *len) { - hex_t *st = storage; - unsigned int left = st->data_len - st->offset; - unsigned int get = left > *len ? *len : left; - - memcpy(data, &st->data[st->offset], get); - st->offset += get; - - *len = get; - return PARSER_ERR_OK; -} - -parser_err_t hex_write(void *storage, void *data, unsigned int len) { - return PARSER_ERR_RDONLY; -} - -parser_t PARSER_HEX = { - "Intel HEX", - hex_init, - hex_open, - hex_close, - hex_size, - hex_read, - hex_write -}; - diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/hex.h b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/hex.h deleted file mode 100755 index 02413c9c9..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/hex.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _PARSER_HEX_H -#define _PARSER_HEX_H - -#include "parser.h" - -extern parser_t PARSER_HEX; -#endif diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/parser.h b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/parser.h deleted file mode 100755 index c2fae3cf8..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/parsers/parser.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_PARSER -#define _H_PARSER - -enum parser_err { - PARSER_ERR_OK, - PARSER_ERR_SYSTEM, - PARSER_ERR_INVALID_FILE, - PARSER_ERR_WRONLY, - PARSER_ERR_RDONLY -}; -typedef enum parser_err parser_err_t; - -struct parser { - const char *name; - void* (*init )(); /* initialise the parser */ - parser_err_t (*open )(void *storage, const char *filename, const char write); /* open the file for read|write */ - parser_err_t (*close)(void *storage); /* close and free the parser */ - unsigned int (*size )(void *storage); /* get the total data size */ - parser_err_t (*read )(void *storage, void *data, unsigned int *len); /* read a block of data */ - parser_err_t (*write)(void *storage, void *data, unsigned int len); /* write a block of data */ -}; -typedef struct parser parser_t; - -static inline const char* parser_errstr(parser_err_t err) { - switch(err) { - case PARSER_ERR_OK : return "OK"; - case PARSER_ERR_SYSTEM : return "System Error"; - case PARSER_ERR_INVALID_FILE: return "Invalid File"; - case PARSER_ERR_WRONLY : return "Parser can only write"; - case PARSER_ERR_RDONLY : return "Parser can only read"; - default: - return "Unknown Error"; - } -} - -#endif diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/port.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/port.c deleted file mode 100755 index 08e58cc34..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/port.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include "serial.h" -#include "port.h" - - -extern struct port_interface port_serial; -extern struct port_interface port_i2c; - -static struct port_interface *ports[] = { - &port_serial, - &port_i2c, - NULL, -}; - - -port_err_t port_open(struct port_options *ops, struct port_interface **outport) -{ - int ret; - static struct port_interface **port; - - for (port = ports; *port; port++) { - ret = (*port)->open(*port, ops); - if (ret == PORT_ERR_NODEV) - continue; - if (ret == PORT_ERR_OK) - break; - fprintf(stderr, "Error probing interface \"%s\"\n", - (*port)->name); - } - if (*port == NULL) { - fprintf(stderr, "Cannot handle device \"%s\"\n", - ops->device); - return PORT_ERR_UNKNOWN; - } - - *outport = *port; - return PORT_ERR_OK; -} diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/port.h b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/port.h deleted file mode 100755 index 290f03496..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/port.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_PORT -#define _H_PORT - -typedef enum { - PORT_ERR_OK = 0, - PORT_ERR_NODEV, /* No such device */ - PORT_ERR_TIMEDOUT, /* Operation timed out */ - PORT_ERR_UNKNOWN, -} port_err_t; - -/* flags */ -#define PORT_BYTE (1 << 0) /* byte (not frame) oriented */ -#define PORT_GVR_ETX (1 << 1) /* cmd GVR returns protection status */ -#define PORT_CMD_INIT (1 << 2) /* use INIT cmd to autodetect speed */ -#define PORT_RETRY (1 << 3) /* allowed read() retry after timeout */ -#define PORT_STRETCH_W (1 << 4) /* warning for no-stretching commands */ - -/* all options and flags used to open and configure an interface */ -struct port_options { - const char *device; - serial_baud_t baudRate; - const char *serial_mode; - int bus_addr; - int rx_frame_max; - int tx_frame_max; -}; - -/* - * Specify the length of reply for command GET - * This is helpful for frame-oriented protocols, e.g. i2c, to avoid time - * consuming try-fail-timeout-retry operation. - * On byte-oriented protocols, i.e. UART, this information would be skipped - * after read the first byte, so not needed. - */ -struct varlen_cmd { - uint8_t version; - uint8_t length; -}; - -struct port_interface { - const char *name; - unsigned flags; - port_err_t (*open)(struct port_interface *port, struct port_options *ops); - port_err_t (*close)(struct port_interface *port); - port_err_t (*read)(struct port_interface *port, void *buf, size_t nbyte); - port_err_t (*write)(struct port_interface *port, void *buf, size_t nbyte); - port_err_t (*gpio)(struct port_interface *port, serial_gpio_t n, int level); - const char *(*get_cfg_str)(struct port_interface *port); - struct varlen_cmd *cmd_get_reply; - void *private; -}; - -port_err_t port_open(struct port_options *ops, struct port_interface **outport); - -#endif diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/protocol.txt b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/protocol.txt deleted file mode 100755 index 039109908..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/protocol.txt +++ /dev/null @@ -1,19 +0,0 @@ -The communication protocol used by ST bootloader is documented in following ST -application notes, depending on communication port. - -In current version of stm32flash are supported only UART and I2C ports. - -* AN3154: CAN protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/CD00264321.pdf - -* AN3155: USART protocol used in the STM32(TM) bootloader - http://www.st.com/web/en/resource/technical/document/application_note/CD00264342.pdf - -* AN4221: I2C protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/DM00072315.pdf - -* AN4286: SPI protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/DM00081379.pdf - -Boot mode selection for STM32 is documented in ST application note AN2606, available in ST website: - http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial.h b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial.h deleted file mode 100755 index 227ba163b..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _SERIAL_H -#define _SERIAL_H - -typedef struct serial serial_t; - -typedef enum { - SERIAL_PARITY_NONE, - SERIAL_PARITY_EVEN, - SERIAL_PARITY_ODD, - - SERIAL_PARITY_INVALID -} serial_parity_t; - -typedef enum { - SERIAL_BITS_5, - SERIAL_BITS_6, - SERIAL_BITS_7, - SERIAL_BITS_8, - - SERIAL_BITS_INVALID -} serial_bits_t; - -typedef enum { - SERIAL_BAUD_1200, - SERIAL_BAUD_1800, - SERIAL_BAUD_2400, - SERIAL_BAUD_4800, - SERIAL_BAUD_9600, - SERIAL_BAUD_19200, - SERIAL_BAUD_38400, - SERIAL_BAUD_57600, - SERIAL_BAUD_115200, - SERIAL_BAUD_128000, - SERIAL_BAUD_230400, - SERIAL_BAUD_256000, - SERIAL_BAUD_460800, - SERIAL_BAUD_500000, - SERIAL_BAUD_576000, - SERIAL_BAUD_921600, - SERIAL_BAUD_1000000, - SERIAL_BAUD_1500000, - SERIAL_BAUD_2000000, - - SERIAL_BAUD_INVALID -} serial_baud_t; - -typedef enum { - SERIAL_STOPBIT_1, - SERIAL_STOPBIT_2, - - SERIAL_STOPBIT_INVALID -} serial_stopbit_t; - -typedef enum { - GPIO_RTS = 1, - GPIO_DTR, - GPIO_BRK, -} serial_gpio_t; - -/* common helper functions */ -serial_baud_t serial_get_baud(const unsigned int baud); -unsigned int serial_get_baud_int(const serial_baud_t baud); -serial_bits_t serial_get_bits(const char *mode); -unsigned int serial_get_bits_int(const serial_bits_t bits); -serial_parity_t serial_get_parity(const char *mode); -char serial_get_parity_str(const serial_parity_t parity); -serial_stopbit_t serial_get_stopbit(const char *mode); -unsigned int serial_get_stopbit_int(const serial_stopbit_t stopbit); - -#endif diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_common.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_common.c deleted file mode 100755 index 43e48e1ac..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_common.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "serial.h" - -serial_baud_t serial_get_baud(const unsigned int baud) { - switch(baud) { - case 1200: return SERIAL_BAUD_1200 ; - case 1800: return SERIAL_BAUD_1800 ; - case 2400: return SERIAL_BAUD_2400 ; - case 4800: return SERIAL_BAUD_4800 ; - case 9600: return SERIAL_BAUD_9600 ; - case 19200: return SERIAL_BAUD_19200 ; - case 38400: return SERIAL_BAUD_38400 ; - case 57600: return SERIAL_BAUD_57600 ; - case 115200: return SERIAL_BAUD_115200; - case 128000: return SERIAL_BAUD_128000; - case 230400: return SERIAL_BAUD_230400; - case 256000: return SERIAL_BAUD_256000; - case 460800: return SERIAL_BAUD_460800; - case 500000: return SERIAL_BAUD_500000; - case 576000: return SERIAL_BAUD_576000; - case 921600: return SERIAL_BAUD_921600; - case 1000000: return SERIAL_BAUD_1000000; - case 1500000: return SERIAL_BAUD_1500000; - case 2000000: return SERIAL_BAUD_2000000; - - default: - return SERIAL_BAUD_INVALID; - } -} - -unsigned int serial_get_baud_int(const serial_baud_t baud) { - switch(baud) { - case SERIAL_BAUD_1200 : return 1200 ; - case SERIAL_BAUD_1800 : return 1800 ; - case SERIAL_BAUD_2400 : return 2400 ; - case SERIAL_BAUD_4800 : return 4800 ; - case SERIAL_BAUD_9600 : return 9600 ; - case SERIAL_BAUD_19200 : return 19200 ; - case SERIAL_BAUD_38400 : return 38400 ; - case SERIAL_BAUD_57600 : return 57600 ; - case SERIAL_BAUD_115200: return 115200; - case SERIAL_BAUD_128000: return 128000; - case SERIAL_BAUD_230400: return 230400; - case SERIAL_BAUD_256000: return 256000; - case SERIAL_BAUD_460800: return 460800; - case SERIAL_BAUD_500000: return 500000; - case SERIAL_BAUD_576000: return 576000; - case SERIAL_BAUD_921600: return 921600; - case SERIAL_BAUD_1000000: return 1000000; - case SERIAL_BAUD_1500000: return 1500000; - case SERIAL_BAUD_2000000: return 2000000; - - case SERIAL_BAUD_INVALID: - default: - return 0; - } -} - -serial_bits_t serial_get_bits(const char *mode) { - if (!mode) - return SERIAL_BITS_INVALID; - switch(mode[0]) { - case '5': return SERIAL_BITS_5; - case '6': return SERIAL_BITS_6; - case '7': return SERIAL_BITS_7; - case '8': return SERIAL_BITS_8; - - default: - return SERIAL_BITS_INVALID; - } -} - -unsigned int serial_get_bits_int(const serial_bits_t bits) { - switch(bits) { - case SERIAL_BITS_5: return 5; - case SERIAL_BITS_6: return 6; - case SERIAL_BITS_7: return 7; - case SERIAL_BITS_8: return 8; - - default: - return 0; - } -} - -serial_parity_t serial_get_parity(const char *mode) { - if (!mode || !mode[0]) - return SERIAL_PARITY_INVALID; - switch(mode[1]) { - case 'N': - case 'n': - return SERIAL_PARITY_NONE; - case 'E': - case 'e': - return SERIAL_PARITY_EVEN; - case 'O': - case 'o': - return SERIAL_PARITY_ODD; - - default: - return SERIAL_PARITY_INVALID; - } -} - -char serial_get_parity_str(const serial_parity_t parity) { - switch(parity) { - case SERIAL_PARITY_NONE: return 'N'; - case SERIAL_PARITY_EVEN: return 'E'; - case SERIAL_PARITY_ODD : return 'O'; - - default: - return ' '; - } -} - -serial_stopbit_t serial_get_stopbit(const char *mode) { - if (!mode || !mode[0] || !mode[1]) - return SERIAL_STOPBIT_INVALID; - switch(mode[2]) { - case '1': return SERIAL_STOPBIT_1; - case '2': return SERIAL_STOPBIT_2; - - default: - return SERIAL_STOPBIT_INVALID; - } -} - -unsigned int serial_get_stopbit_int(const serial_stopbit_t stopbit) { - switch(stopbit) { - case SERIAL_STOPBIT_1: return 1; - case SERIAL_STOPBIT_2: return 2; - - default: - return 0; - } -} - diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_platform.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_platform.c deleted file mode 100755 index 98e256921..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_platform.c +++ /dev/null @@ -1,5 +0,0 @@ -#if defined(__WIN32__) || defined(__CYGWIN__) -# include "serial_w32.c" -#else -# include "serial_posix.c" -#endif diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_posix.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_posix.c deleted file mode 100755 index 284b35b20..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_posix.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - -struct serial { - int fd; - struct termios oldtio; - struct termios newtio; - char setup_str[11]; -}; - -static serial_t *serial_open(const char *device) -{ - serial_t *h = calloc(sizeof(serial_t), 1); - - h->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); - if (h->fd < 0) { - free(h); - return NULL; - } - fcntl(h->fd, F_SETFL, 0); - - tcgetattr(h->fd, &h->oldtio); - tcgetattr(h->fd, &h->newtio); - - return h; -} - -static void serial_flush(const serial_t *h) -{ - tcflush(h->fd, TCIFLUSH); -} - -static void serial_close(serial_t *h) -{ - serial_flush(h); - tcsetattr(h->fd, TCSANOW, &h->oldtio); - close(h->fd); - free(h); -} - -static port_err_t serial_setup(serial_t *h, const serial_baud_t baud, - const serial_bits_t bits, - const serial_parity_t parity, - const serial_stopbit_t stopbit) -{ - speed_t port_baud; - tcflag_t port_bits; - tcflag_t port_parity; - tcflag_t port_stop; - struct termios settings; - - switch (baud) { - case SERIAL_BAUD_1200: port_baud = B1200; break; - case SERIAL_BAUD_1800: port_baud = B1800; break; - case SERIAL_BAUD_2400: port_baud = B2400; break; - case SERIAL_BAUD_4800: port_baud = B4800; break; - case SERIAL_BAUD_9600: port_baud = B9600; break; - case SERIAL_BAUD_19200: port_baud = B19200; break; - case SERIAL_BAUD_38400: port_baud = B38400; break; - case SERIAL_BAUD_57600: port_baud = B57600; break; - case SERIAL_BAUD_115200: port_baud = B115200; break; - case SERIAL_BAUD_230400: port_baud = B230400; break; -#ifdef B460800 - case SERIAL_BAUD_460800: port_baud = B460800; break; -#endif /* B460800 */ -#ifdef B921600 - case SERIAL_BAUD_921600: port_baud = B921600; break; -#endif /* B921600 */ -#ifdef B500000 - case SERIAL_BAUD_500000: port_baud = B500000; break; -#endif /* B500000 */ -#ifdef B576000 - case SERIAL_BAUD_576000: port_baud = B576000; break; -#endif /* B576000 */ -#ifdef B1000000 - case SERIAL_BAUD_1000000: port_baud = B1000000; break; -#endif /* B1000000 */ -#ifdef B1500000 - case SERIAL_BAUD_1500000: port_baud = B1500000; break; -#endif /* B1500000 */ -#ifdef B2000000 - case SERIAL_BAUD_2000000: port_baud = B2000000; break; -#endif /* B2000000 */ - - case SERIAL_BAUD_INVALID: - default: - return PORT_ERR_UNKNOWN; - } - - switch (bits) { - case SERIAL_BITS_5: port_bits = CS5; break; - case SERIAL_BITS_6: port_bits = CS6; break; - case SERIAL_BITS_7: port_bits = CS7; break; - case SERIAL_BITS_8: port_bits = CS8; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (parity) { - case SERIAL_PARITY_NONE: port_parity = 0; break; - case SERIAL_PARITY_EVEN: port_parity = PARENB; break; - case SERIAL_PARITY_ODD: port_parity = PARENB | PARODD; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (stopbit) { - case SERIAL_STOPBIT_1: port_stop = 0; break; - case SERIAL_STOPBIT_2: port_stop = CSTOPB; break; - - default: - return PORT_ERR_UNKNOWN; - } - - /* reset the settings */ -#ifndef __sun /* Used by GNU and BSD. Ignore __SVR4 in test. */ - cfmakeraw(&h->newtio); -#else /* __sun */ - h->newtio.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR - | IGNCR | ICRNL | IXON); - if (port_parity) - h->newtio.c_iflag |= INPCK; - - h->newtio.c_oflag &= ~OPOST; - h->newtio.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); - h->newtio.c_cflag &= ~(CSIZE | PARENB); - h->newtio.c_cflag |= CS8; -#endif /* __sun */ -#ifdef __QNXNTO__ - h->newtio.c_cflag &= ~(CSIZE | IHFLOW | OHFLOW); -#else - h->newtio.c_cflag &= ~(CSIZE | CRTSCTS); -#endif - h->newtio.c_cflag &= ~(CSIZE | CRTSCTS); - h->newtio.c_iflag &= ~(IXON | IXOFF | IXANY | IGNPAR); - h->newtio.c_lflag &= ~(ECHOK | ECHOCTL | ECHOKE); - h->newtio.c_oflag &= ~(OPOST | ONLCR); - - /* setup the new settings */ - cfsetispeed(&h->newtio, port_baud); - cfsetospeed(&h->newtio, port_baud); - h->newtio.c_cflag |= - port_parity | - port_bits | - port_stop | - CLOCAL | - CREAD; - - h->newtio.c_cc[VMIN] = 0; - h->newtio.c_cc[VTIME] = 5; /* in units of 0.1 s */ - - /* set the settings */ - serial_flush(h); - if (tcsetattr(h->fd, TCSANOW, &h->newtio) != 0) - return PORT_ERR_UNKNOWN; - -/* this check fails on CDC-ACM devices, bits 16 and 17 of cflag differ! - * it has been disabled below for now -jcw, 2015-11-09 - if (settings.c_cflag != h->newtio.c_cflag) - fprintf(stderr, "c_cflag mismatch %lx\n", - settings.c_cflag ^ h->newtio.c_cflag); - */ - - /* confirm they were set */ - tcgetattr(h->fd, &settings); - if (settings.c_iflag != h->newtio.c_iflag || - settings.c_oflag != h->newtio.c_oflag || - //settings.c_cflag != h->newtio.c_cflag || - settings.c_lflag != h->newtio.c_lflag) - return PORT_ERR_UNKNOWN; - - snprintf(h->setup_str, sizeof(h->setup_str), "%u %d%c%d", - serial_get_baud_int(baud), - serial_get_bits_int(bits), - serial_get_parity_str(parity), - serial_get_stopbit_int(stopbit)); - return PORT_ERR_OK; -} - -/* - * Roger clark. - * This function is no longer used. But has just been commented out in case it needs - * to be reinstated in the future - -static int startswith(const char *haystack, const char *needle) { - return strncmp(haystack, needle, strlen(needle)) == 0; -} -*/ - -static int is_tty(const char *path) { - char resolved[PATH_MAX]; - - if(!realpath(path, resolved)) return 0; - - - /* - * Roger Clark - * Commented out this check, because on OSX some devices are /dev/cu - * and some users use symbolic links to devices, hence the name may not even start - * with /dev - - if(startswith(resolved, "/dev/tty")) return 1; - - return 0; - */ - - return 1; -} - -static port_err_t serial_posix_open(struct port_interface *port, - struct port_options *ops) -{ - serial_t *h; - - /* 1. check device name match */ - if (!is_tty(ops->device)) - return PORT_ERR_NODEV; - - /* 2. check options */ - if (ops->baudRate == SERIAL_BAUD_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_bits(ops->serial_mode) == SERIAL_BITS_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_parity(ops->serial_mode) == SERIAL_PARITY_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_stopbit(ops->serial_mode) == SERIAL_STOPBIT_INVALID) - return PORT_ERR_UNKNOWN; - - /* 3. open it */ - h = serial_open(ops->device); - if (h == NULL) - return PORT_ERR_UNKNOWN; - - /* 4. set options */ - if (serial_setup(h, ops->baudRate, - serial_get_bits(ops->serial_mode), - serial_get_parity(ops->serial_mode), - serial_get_stopbit(ops->serial_mode) - ) != PORT_ERR_OK) { - serial_close(h); - return PORT_ERR_UNKNOWN; - } - - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t serial_posix_close(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - serial_close(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t serial_posix_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - ssize_t r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - r = read(h->fd, pos, nbyte); - if (r == 0) - return PORT_ERR_TIMEDOUT; - if (r < 0) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_posix_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - ssize_t r; - const uint8_t *pos = (const uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - r = write(h->fd, pos, nbyte); - if (r < 1) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_posix_gpio(struct port_interface *port, - serial_gpio_t n, int level) -{ - serial_t *h; - int bit, lines; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - switch (n) { - case GPIO_RTS: - bit = TIOCM_RTS; - break; - - case GPIO_DTR: - bit = TIOCM_DTR; - break; - - case GPIO_BRK: - if (level == 0) - return PORT_ERR_OK; - if (tcsendbreak(h->fd, 1)) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; - - default: - return PORT_ERR_UNKNOWN; - } - - /* handle RTS/DTR */ - if (ioctl(h->fd, TIOCMGET, &lines)) - return PORT_ERR_UNKNOWN; - lines = level ? lines | bit : lines & ~bit; - if (ioctl(h->fd, TIOCMSET, &lines)) - return PORT_ERR_UNKNOWN; - - return PORT_ERR_OK; -} - -static const char *serial_posix_get_cfg_str(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - return h ? h->setup_str : "INVALID"; -} - -struct port_interface port_serial = { - .name = "serial_posix", - .flags = PORT_BYTE | PORT_GVR_ETX | PORT_CMD_INIT | PORT_RETRY, - .open = serial_posix_open, - .close = serial_posix_close, - .read = serial_posix_read, - .write = serial_posix_write, - .gpio = serial_posix_gpio, - .get_cfg_str = serial_posix_get_cfg_str, -}; diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_w32.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_w32.c deleted file mode 100755 index 56772c0a0..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/serial_w32.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2010 Gareth McMullin - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - -struct serial { - HANDLE fd; - DCB oldtio; - DCB newtio; - char setup_str[11]; -}; - -static serial_t *serial_open(const char *device) -{ - serial_t *h = calloc(sizeof(serial_t), 1); - char *devName; - - /* timeout in ms */ - COMMTIMEOUTS timeouts = {MAXDWORD, MAXDWORD, 500, 0, 0}; - - /* Fix the device name if required */ - if (strlen(device) > 4 && device[0] != '\\') { - devName = calloc(1, strlen(device) + 5); - sprintf(devName, "\\\\.\\%s", device); - } else { - devName = (char *)device; - } - - /* Create file handle for port */ - h->fd = CreateFile(devName, GENERIC_READ | GENERIC_WRITE, - 0, /* Exclusive access */ - NULL, /* No security */ - OPEN_EXISTING, - 0, /* No overlap */ - NULL); - - if (devName != device) - free(devName); - - if (h->fd == INVALID_HANDLE_VALUE) { - if (GetLastError() == ERROR_FILE_NOT_FOUND) - fprintf(stderr, "File not found: %s\n", device); - return NULL; - } - - SetupComm(h->fd, 4096, 4096); /* Set input and output buffer size */ - - SetCommTimeouts(h->fd, &timeouts); - - SetCommMask(h->fd, EV_ERR); /* Notify us of error events */ - - GetCommState(h->fd, &h->oldtio); /* Retrieve port parameters */ - GetCommState(h->fd, &h->newtio); /* Retrieve port parameters */ - - /* PurgeComm(h->fd, PURGE_RXABORT | PURGE_TXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR); */ - - return h; -} - -static void serial_flush(const serial_t *h) -{ - /* We shouldn't need to flush in non-overlapping (blocking) mode */ - /* tcflush(h->fd, TCIFLUSH); */ -} - -static void serial_close(serial_t *h) -{ - serial_flush(h); - SetCommState(h->fd, &h->oldtio); - CloseHandle(h->fd); - free(h); -} - -static port_err_t serial_setup(serial_t *h, - const serial_baud_t baud, - const serial_bits_t bits, - const serial_parity_t parity, - const serial_stopbit_t stopbit) -{ - switch (baud) { - case SERIAL_BAUD_1200: h->newtio.BaudRate = CBR_1200; break; - /* case SERIAL_BAUD_1800: h->newtio.BaudRate = CBR_1800; break; */ - case SERIAL_BAUD_2400: h->newtio.BaudRate = CBR_2400; break; - case SERIAL_BAUD_4800: h->newtio.BaudRate = CBR_4800; break; - case SERIAL_BAUD_9600: h->newtio.BaudRate = CBR_9600; break; - case SERIAL_BAUD_19200: h->newtio.BaudRate = CBR_19200; break; - case SERIAL_BAUD_38400: h->newtio.BaudRate = CBR_38400; break; - case SERIAL_BAUD_57600: h->newtio.BaudRate = CBR_57600; break; - case SERIAL_BAUD_115200: h->newtio.BaudRate = CBR_115200; break; - case SERIAL_BAUD_128000: h->newtio.BaudRate = CBR_128000; break; - case SERIAL_BAUD_256000: h->newtio.BaudRate = CBR_256000; break; - /* These are not defined in WinBase.h and might work or not */ - case SERIAL_BAUD_230400: h->newtio.BaudRate = 230400; break; - case SERIAL_BAUD_460800: h->newtio.BaudRate = 460800; break; - case SERIAL_BAUD_500000: h->newtio.BaudRate = 500000; break; - case SERIAL_BAUD_576000: h->newtio.BaudRate = 576000; break; - case SERIAL_BAUD_921600: h->newtio.BaudRate = 921600; break; - case SERIAL_BAUD_1000000: h->newtio.BaudRate = 1000000; break; - case SERIAL_BAUD_1500000: h->newtio.BaudRate = 1500000; break; - case SERIAL_BAUD_2000000: h->newtio.BaudRate = 2000000; break; - case SERIAL_BAUD_INVALID: - - default: - return PORT_ERR_UNKNOWN; - } - - switch (bits) { - case SERIAL_BITS_5: h->newtio.ByteSize = 5; break; - case SERIAL_BITS_6: h->newtio.ByteSize = 6; break; - case SERIAL_BITS_7: h->newtio.ByteSize = 7; break; - case SERIAL_BITS_8: h->newtio.ByteSize = 8; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (parity) { - case SERIAL_PARITY_NONE: h->newtio.Parity = NOPARITY; break; - case SERIAL_PARITY_EVEN: h->newtio.Parity = EVENPARITY; break; - case SERIAL_PARITY_ODD: h->newtio.Parity = ODDPARITY; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (stopbit) { - case SERIAL_STOPBIT_1: h->newtio.StopBits = ONESTOPBIT; break; - case SERIAL_STOPBIT_2: h->newtio.StopBits = TWOSTOPBITS; break; - - default: - return PORT_ERR_UNKNOWN; - } - - /* reset the settings */ - h->newtio.fOutxCtsFlow = FALSE; - h->newtio.fOutxDsrFlow = FALSE; - h->newtio.fOutX = FALSE; - h->newtio.fInX = FALSE; - h->newtio.fNull = 0; - h->newtio.fAbortOnError = 0; - - /* set the settings */ - serial_flush(h); - if (!SetCommState(h->fd, &h->newtio)) - return PORT_ERR_UNKNOWN; - - snprintf(h->setup_str, sizeof(h->setup_str), "%u %d%c%d", - serial_get_baud_int(baud), - serial_get_bits_int(bits), - serial_get_parity_str(parity), - serial_get_stopbit_int(stopbit) - ); - return PORT_ERR_OK; -} - -static port_err_t serial_w32_open(struct port_interface *port, - struct port_options *ops) -{ - serial_t *h; - - /* 1. check device name match */ - if (!((strlen(ops->device) == 4 || strlen(ops->device) == 5) - && !strncmp(ops->device, "COM", 3) && isdigit(ops->device[3])) - && !(!strncmp(ops->device, "\\\\.\\COM", strlen("\\\\.\\COM")) - && isdigit(ops->device[strlen("\\\\.\\COM")]))) - return PORT_ERR_NODEV; - - /* 2. check options */ - if (ops->baudRate == SERIAL_BAUD_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_bits(ops->serial_mode) == SERIAL_BITS_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_parity(ops->serial_mode) == SERIAL_PARITY_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_stopbit(ops->serial_mode) == SERIAL_STOPBIT_INVALID) - return PORT_ERR_UNKNOWN; - - /* 3. open it */ - h = serial_open(ops->device); - if (h == NULL) - return PORT_ERR_UNKNOWN; - - /* 4. set options */ - if (serial_setup(h, ops->baudRate, - serial_get_bits(ops->serial_mode), - serial_get_parity(ops->serial_mode), - serial_get_stopbit(ops->serial_mode) - ) != PORT_ERR_OK) { - serial_close(h); - return PORT_ERR_UNKNOWN; - } - - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t serial_w32_close(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - serial_close(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t serial_w32_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - DWORD r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - ReadFile(h->fd, pos, nbyte, &r, NULL); - if (r == 0) - return PORT_ERR_TIMEDOUT; - if (r < 0) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_w32_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - DWORD r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - if (!WriteFile(h->fd, pos, nbyte, &r, NULL)) - return PORT_ERR_UNKNOWN; - if (r < 1) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_w32_gpio(struct port_interface *port, - serial_gpio_t n, int level) -{ - serial_t *h; - int bit; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - switch (n) { - case GPIO_RTS: - bit = level ? SETRTS : CLRRTS; - break; - - case GPIO_DTR: - bit = level ? SETDTR : CLRDTR; - break; - - case GPIO_BRK: - if (level == 0) - return PORT_ERR_OK; - if (EscapeCommFunction(h->fd, SETBREAK) == 0) - return PORT_ERR_UNKNOWN; - usleep(500000); - if (EscapeCommFunction(h->fd, CLRBREAK) == 0) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; - - default: - return PORT_ERR_UNKNOWN; - } - - /* handle RTS/DTR */ - if (EscapeCommFunction(h->fd, bit) == 0) - return PORT_ERR_UNKNOWN; - - return PORT_ERR_OK; -} - -static const char *serial_w32_get_cfg_str(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - return h ? h->setup_str : "INVALID"; -} - -struct port_interface port_serial = { - .name = "serial_w32", - .flags = PORT_BYTE | PORT_GVR_ETX | PORT_CMD_INIT | PORT_RETRY, - .open = serial_w32_open, - .close = serial_w32_close, - .read = serial_w32_read, - .write = serial_w32_write, - .gpio = serial_w32_gpio, - .get_cfg_str = serial_w32_get_cfg_str, -}; diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/stm32.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/stm32.c deleted file mode 100755 index 74047d244..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/stm32.c +++ /dev/null @@ -1,1048 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright 2010 Geoffrey McRae - Copyright 2012-2014 Tormod Volden - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include - -#include "stm32.h" -#include "port.h" -#include "utils.h" - -#define STM32_ACK 0x79 -#define STM32_NACK 0x1F -#define STM32_BUSY 0x76 - -#define STM32_CMD_INIT 0x7F -#define STM32_CMD_GET 0x00 /* get the version and command supported */ -#define STM32_CMD_GVR 0x01 /* get version and read protection status */ -#define STM32_CMD_GID 0x02 /* get ID */ -#define STM32_CMD_RM 0x11 /* read memory */ -#define STM32_CMD_GO 0x21 /* go */ -#define STM32_CMD_WM 0x31 /* write memory */ -#define STM32_CMD_WM_NS 0x32 /* no-stretch write memory */ -#define STM32_CMD_ER 0x43 /* erase */ -#define STM32_CMD_EE 0x44 /* extended erase */ -#define STM32_CMD_EE_NS 0x45 /* extended erase no-stretch */ -#define STM32_CMD_WP 0x63 /* write protect */ -#define STM32_CMD_WP_NS 0x64 /* write protect no-stretch */ -#define STM32_CMD_UW 0x73 /* write unprotect */ -#define STM32_CMD_UW_NS 0x74 /* write unprotect no-stretch */ -#define STM32_CMD_RP 0x82 /* readout protect */ -#define STM32_CMD_RP_NS 0x83 /* readout protect no-stretch */ -#define STM32_CMD_UR 0x92 /* readout unprotect */ -#define STM32_CMD_UR_NS 0x93 /* readout unprotect no-stretch */ -#define STM32_CMD_CRC 0xA1 /* compute CRC */ -#define STM32_CMD_ERR 0xFF /* not a valid command */ - -#define STM32_RESYNC_TIMEOUT 35 /* seconds */ -#define STM32_MASSERASE_TIMEOUT 35 /* seconds */ -#define STM32_SECTERASE_TIMEOUT 5 /* seconds */ -#define STM32_BLKWRITE_TIMEOUT 1 /* seconds */ -#define STM32_WUNPROT_TIMEOUT 1 /* seconds */ -#define STM32_WPROT_TIMEOUT 1 /* seconds */ -#define STM32_RPROT_TIMEOUT 1 /* seconds */ - -#define STM32_CMD_GET_LENGTH 17 /* bytes in the reply */ - -struct stm32_cmd { - uint8_t get; - uint8_t gvr; - uint8_t gid; - uint8_t rm; - uint8_t go; - uint8_t wm; - uint8_t er; /* this may be extended erase */ - uint8_t wp; - uint8_t uw; - uint8_t rp; - uint8_t ur; - uint8_t crc; -}; - -/* Reset code for ARMv7-M (Cortex-M3) and ARMv6-M (Cortex-M0) - * see ARMv7-M or ARMv6-M Architecture Reference Manual (table B3-8) - * or "The definitive guide to the ARM Cortex-M3", section 14.4. - */ -static const uint8_t stm_reset_code[] = { - 0x01, 0x49, // ldr r1, [pc, #4] ; () - 0x02, 0x4A, // ldr r2, [pc, #8] ; () - 0x0A, 0x60, // str r2, [r1, #0] - 0xfe, 0xe7, // endless: b endless - 0x0c, 0xed, 0x00, 0xe0, // .word 0xe000ed0c = NVIC AIRCR register address - 0x04, 0x00, 0xfa, 0x05 // .word 0x05fa0004 = VECTKEY | SYSRESETREQ -}; - -static const uint32_t stm_reset_code_length = sizeof(stm_reset_code); - -extern const stm32_dev_t devices[]; - -static void stm32_warn_stretching(const char *f) -{ - fprintf(stderr, "Attention !!!\n"); - fprintf(stderr, "\tThis %s error could be caused by your I2C\n", f); - fprintf(stderr, "\tcontroller not accepting \"clock stretching\"\n"); - fprintf(stderr, "\tas required by bootloader.\n"); - fprintf(stderr, "\tCheck \"I2C.txt\" in stm32flash source code.\n"); -} - -static stm32_err_t stm32_get_ack_timeout(const stm32_t *stm, time_t timeout) -{ - struct port_interface *port = stm->port; - uint8_t byte; - port_err_t p_err; - time_t t0, t1; - - if (!(port->flags & PORT_RETRY)) - timeout = 0; - - if (timeout) - time(&t0); - - do { - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_TIMEDOUT && timeout) { - time(&t1); - if (t1 < t0 + timeout) - continue; - } - - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to read ACK byte\n"); - return STM32_ERR_UNKNOWN; - } - - if (byte == STM32_ACK) - return STM32_ERR_OK; - if (byte == STM32_NACK) - return STM32_ERR_NACK; - if (byte != STM32_BUSY) { - fprintf(stderr, "Got byte 0x%02x instead of ACK\n", - byte); - return STM32_ERR_UNKNOWN; - } - } while (1); -} - -static stm32_err_t stm32_get_ack(const stm32_t *stm) -{ - return stm32_get_ack_timeout(stm, 0); -} - -static stm32_err_t stm32_send_command_timeout(const stm32_t *stm, - const uint8_t cmd, - time_t timeout) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - port_err_t p_err; - uint8_t buf[2]; - - buf[0] = cmd; - buf[1] = cmd ^ 0xFF; - p_err = port->write(port, buf, 2); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send command\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, timeout); - if (s_err == STM32_ERR_OK) - return STM32_ERR_OK; - if (s_err == STM32_ERR_NACK) - fprintf(stderr, "Got NACK from device on command 0x%02x\n", cmd); - else - fprintf(stderr, "Unexpected reply from device on command 0x%02x\n", cmd); - return STM32_ERR_UNKNOWN; -} - -static stm32_err_t stm32_send_command(const stm32_t *stm, const uint8_t cmd) -{ - return stm32_send_command_timeout(stm, cmd, 0); -} - -/* if we have lost sync, send a wrong command and expect a NACK */ -static stm32_err_t stm32_resync(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - uint8_t buf[2], ack; - time_t t0, t1; - - time(&t0); - t1 = t0; - - buf[0] = STM32_CMD_ERR; - buf[1] = STM32_CMD_ERR ^ 0xFF; - while (t1 < t0 + STM32_RESYNC_TIMEOUT) { - p_err = port->write(port, buf, 2); - if (p_err != PORT_ERR_OK) { - usleep(500000); - time(&t1); - continue; - } - p_err = port->read(port, &ack, 1); - if (p_err != PORT_ERR_OK) { - time(&t1); - continue; - } - if (ack == STM32_NACK) - return STM32_ERR_OK; - time(&t1); - } - return STM32_ERR_UNKNOWN; -} - -/* - * some command receive reply frame with variable length, and length is - * embedded in reply frame itself. - * We can guess the length, but if we guess wrong the protocol gets out - * of sync. - * Use resync for frame oriented interfaces (e.g. I2C) and byte-by-byte - * read for byte oriented interfaces (e.g. UART). - * - * to run safely, data buffer should be allocated for 256+1 bytes - * - * len is value of the first byte in the frame. - */ -static stm32_err_t stm32_guess_len_cmd(const stm32_t *stm, uint8_t cmd, - uint8_t *data, unsigned int len) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - if (port->flags & PORT_BYTE) { - /* interface is UART-like */ - p_err = port->read(port, data, 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - len = data[0]; - p_err = port->read(port, data + 1, len + 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; - } - - p_err = port->read(port, data, len + 2); - if (p_err == PORT_ERR_OK && len == data[0]) - return STM32_ERR_OK; - if (p_err != PORT_ERR_OK) { - /* restart with only one byte */ - if (stm32_resync(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - p_err = port->read(port, data, 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - } - - fprintf(stderr, "Re sync (len = %d)\n", data[0]); - if (stm32_resync(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - len = data[0]; - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - p_err = port->read(port, data, len + 2); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; -} - -/* - * Some interface, e.g. UART, requires a specific init sequence to let STM32 - * autodetect the interface speed. - * The sequence is only required one time after reset. - * stm32flash has command line flag "-c" to prevent sending the init sequence - * in case it was already sent before. - * User can easily forget adding "-c". In this case the bootloader would - * interpret the init sequence as part of a command message, then waiting for - * the rest of the message blocking the interface. - * This function sends the init sequence and, in case of timeout, recovers - * the interface. - */ -static stm32_err_t stm32_send_init_seq(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - uint8_t byte, cmd = STM32_CMD_INIT; - - p_err = port->write(port, &cmd, 1); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send init to device\n"); - return STM32_ERR_UNKNOWN; - } - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_OK && byte == STM32_ACK) - return STM32_ERR_OK; - if (p_err == PORT_ERR_OK && byte == STM32_NACK) { - /* We could get error later, but let's continue, for now. */ - fprintf(stderr, - "Warning: the interface was not closed properly.\n"); - return STM32_ERR_OK; - } - if (p_err != PORT_ERR_TIMEDOUT) { - fprintf(stderr, "Failed to init device.\n"); - return STM32_ERR_UNKNOWN; - } - - /* - * Check if previous STM32_CMD_INIT was taken as first byte - * of a command. Send a new byte, we should get back a NACK. - */ - p_err = port->write(port, &cmd, 1); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send init to device\n"); - return STM32_ERR_UNKNOWN; - } - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_OK && byte == STM32_NACK) - return STM32_ERR_OK; - fprintf(stderr, "Failed to init device.\n"); - return STM32_ERR_UNKNOWN; -} - -/* find newer command by higher code */ -#define newer(prev, a) (((prev) == STM32_CMD_ERR) \ - ? (a) \ - : (((prev) > (a)) ? (prev) : (a))) - -stm32_t *stm32_init(struct port_interface *port, const char init) -{ - uint8_t len, val, buf[257]; - stm32_t *stm; - int i, new_cmds; - - stm = calloc(sizeof(stm32_t), 1); - stm->cmd = malloc(sizeof(stm32_cmd_t)); - memset(stm->cmd, STM32_CMD_ERR, sizeof(stm32_cmd_t)); - stm->port = port; - - if ((port->flags & PORT_CMD_INIT) && init) - if (stm32_send_init_seq(stm) != STM32_ERR_OK) - return NULL; - - /* get the version and read protection status */ - if (stm32_send_command(stm, STM32_CMD_GVR) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - /* From AN, only UART bootloader returns 3 bytes */ - len = (port->flags & PORT_GVR_ETX) ? 3 : 1; - if (port->read(port, buf, len) != PORT_ERR_OK) - return NULL; - stm->version = buf[0]; - stm->option1 = (port->flags & PORT_GVR_ETX) ? buf[1] : 0; - stm->option2 = (port->flags & PORT_GVR_ETX) ? buf[2] : 0; - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - /* get the bootloader information */ - len = STM32_CMD_GET_LENGTH; - if (port->cmd_get_reply) - for (i = 0; port->cmd_get_reply[i].length; i++) - if (stm->version == port->cmd_get_reply[i].version) { - len = port->cmd_get_reply[i].length; - break; - } - if (stm32_guess_len_cmd(stm, STM32_CMD_GET, buf, len) != STM32_ERR_OK) - return NULL; - len = buf[0] + 1; - stm->bl_version = buf[1]; - new_cmds = 0; - for (i = 1; i < len; i++) { - val = buf[i + 1]; - switch (val) { - case STM32_CMD_GET: - stm->cmd->get = val; break; - case STM32_CMD_GVR: - stm->cmd->gvr = val; break; - case STM32_CMD_GID: - stm->cmd->gid = val; break; - case STM32_CMD_RM: - stm->cmd->rm = val; break; - case STM32_CMD_GO: - stm->cmd->go = val; break; - case STM32_CMD_WM: - case STM32_CMD_WM_NS: - stm->cmd->wm = newer(stm->cmd->wm, val); - break; - case STM32_CMD_ER: - case STM32_CMD_EE: - case STM32_CMD_EE_NS: - stm->cmd->er = newer(stm->cmd->er, val); - break; - case STM32_CMD_WP: - case STM32_CMD_WP_NS: - stm->cmd->wp = newer(stm->cmd->wp, val); - break; - case STM32_CMD_UW: - case STM32_CMD_UW_NS: - stm->cmd->uw = newer(stm->cmd->uw, val); - break; - case STM32_CMD_RP: - case STM32_CMD_RP_NS: - stm->cmd->rp = newer(stm->cmd->rp, val); - break; - case STM32_CMD_UR: - case STM32_CMD_UR_NS: - stm->cmd->ur = newer(stm->cmd->ur, val); - break; - case STM32_CMD_CRC: - stm->cmd->crc = newer(stm->cmd->crc, val); - break; - default: - if (new_cmds++ == 0) - fprintf(stderr, - "GET returns unknown commands (0x%2x", - val); - else - fprintf(stderr, ", 0x%2x", val); - } - } - if (new_cmds) - fprintf(stderr, ")\n"); - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - if (stm->cmd->get == STM32_CMD_ERR - || stm->cmd->gvr == STM32_CMD_ERR - || stm->cmd->gid == STM32_CMD_ERR) { - fprintf(stderr, "Error: bootloader did not returned correct information from GET command\n"); - return NULL; - } - - /* get the device ID */ - if (stm32_guess_len_cmd(stm, stm->cmd->gid, buf, 1) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - len = buf[0] + 1; - if (len < 2) { - stm32_close(stm); - fprintf(stderr, "Only %d bytes sent in the PID, unknown/unsupported device\n", len); - return NULL; - } - stm->pid = (buf[1] << 8) | buf[2]; - if (len > 2) { - fprintf(stderr, "This bootloader returns %d extra bytes in PID:", len); - for (i = 2; i <= len ; i++) - fprintf(stderr, " %02x", buf[i]); - fprintf(stderr, "\n"); - } - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - stm->dev = devices; - while (stm->dev->id != 0x00 && stm->dev->id != stm->pid) - ++stm->dev; - - if (!stm->dev->id) { - fprintf(stderr, "Unknown/unsupported device (Device ID: 0x%03x)\n", stm->pid); - stm32_close(stm); - return NULL; - } - - return stm; -} - -void stm32_close(stm32_t *stm) -{ - if (stm) - free(stm->cmd); - free(stm); -} - -stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address, - uint8_t data[], unsigned int len) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (!len) - return STM32_ERR_OK; - - if (len > 256) { - fprintf(stderr, "Error: READ length limit at 256 bytes\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->rm == STM32_CMD_ERR) { - fprintf(stderr, "Error: READ command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->rm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_send_command(stm, len - 1) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (port->read(port, data, len) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - return STM32_ERR_OK; -} - -stm32_err_t stm32_write_memory(const stm32_t *stm, uint32_t address, - const uint8_t data[], unsigned int len) -{ - struct port_interface *port = stm->port; - uint8_t cs, buf[256 + 2]; - unsigned int i, aligned_len; - stm32_err_t s_err; - - if (!len) - return STM32_ERR_OK; - - if (len > 256) { - fprintf(stderr, "Error: READ length limit at 256 bytes\n"); - return STM32_ERR_UNKNOWN; - } - - /* must be 32bit aligned */ - if (address & 0x3 || len & 0x3) { - fprintf(stderr, "Error: WRITE address and length must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->wm == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - /* send the address and checksum */ - if (stm32_send_command(stm, stm->cmd->wm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - aligned_len = (len + 3) & ~3; - cs = aligned_len - 1; - buf[0] = aligned_len - 1; - for (i = 0; i < len; i++) { - cs ^= data[i]; - buf[i + 1] = data[i]; - } - /* padding data */ - for (i = len; i < aligned_len; i++) { - cs ^= 0xFF; - buf[i + 1] = 0xFF; - } - buf[aligned_len + 1] = cs; - if (port->write(port, buf, aligned_len + 2) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_BLKWRITE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->wm != STM32_CMD_WM_NS) - stm32_warn_stretching("write"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_wunprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->uw == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE UNPROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->uw) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_WUNPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to WRITE UNPROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->uw != STM32_CMD_UW_NS) - stm32_warn_stretching("WRITE UNPROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_wprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->wp == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE PROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->wp) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_WPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to WRITE PROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->wp != STM32_CMD_WP_NS) - stm32_warn_stretching("WRITE PROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_runprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->ur == STM32_CMD_ERR) { - fprintf(stderr, "Error: READOUT UNPROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->ur) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to READOUT UNPROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->ur != STM32_CMD_UR_NS) - stm32_warn_stretching("READOUT UNPROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_readprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->rp == STM32_CMD_ERR) { - fprintf(stderr, "Error: READOUT PROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->rp) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_RPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to READOUT PROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->rp != STM32_CMD_RP_NS) - stm32_warn_stretching("READOUT PROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_erase_memory(const stm32_t *stm, uint8_t spage, uint8_t pages) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - port_err_t p_err; - - if (!pages) - return STM32_ERR_OK; - - if (stm->cmd->er == STM32_CMD_ERR) { - fprintf(stderr, "Error: ERASE command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->er) != STM32_ERR_OK) { - fprintf(stderr, "Can't initiate chip erase!\n"); - return STM32_ERR_UNKNOWN; - } - - /* The erase command reported by the bootloader is either 0x43, 0x44 or 0x45 */ - /* 0x44 is Extended Erase, a 2 byte based protocol and needs to be handled differently. */ - /* 0x45 is clock no-stretching version of Extended Erase for I2C port. */ - if (stm->cmd->er != STM32_CMD_ER) { - /* Not all chips using Extended Erase support mass erase */ - /* Currently known as not supporting mass erase is the Ultra Low Power STM32L15xx range */ - /* So if someone has not overridden the default, but uses one of these chips, take it out of */ - /* mass erase mode, so it will be done page by page. This maximum might not be correct either! */ - if (stm->pid == 0x416 && pages == 0xFF) - pages = 0xF8; /* works for the STM32L152RB with 128Kb flash */ - - if (pages == 0xFF) { - uint8_t buf[3]; - - /* 0xFFFF the magic number for mass erase */ - buf[0] = 0xFF; - buf[1] = 0xFF; - buf[2] = 0x00; /* checksum */ - if (port->write(port, buf, 3) != PORT_ERR_OK) { - fprintf(stderr, "Mass erase error.\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Mass erase failed. Try specifying the number of pages to be erased.\n"); - if (port->flags & PORT_STRETCH_W - && stm->cmd->er != STM32_CMD_EE_NS) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } - - uint16_t pg_num; - uint8_t pg_byte; - uint8_t cs = 0; - uint8_t *buf; - int i = 0; - - buf = malloc(2 + 2 * pages + 1); - if (!buf) - return STM32_ERR_UNKNOWN; - - /* Number of pages to be erased - 1, two bytes, MSB first */ - pg_byte = (pages - 1) >> 8; - buf[i++] = pg_byte; - cs ^= pg_byte; - pg_byte = (pages - 1) & 0xFF; - buf[i++] = pg_byte; - cs ^= pg_byte; - - for (pg_num = spage; pg_num < spage + pages; pg_num++) { - pg_byte = pg_num >> 8; - cs ^= pg_byte; - buf[i++] = pg_byte; - pg_byte = pg_num & 0xFF; - cs ^= pg_byte; - buf[i++] = pg_byte; - } - buf[i++] = cs; - p_err = port->write(port, buf, i); - free(buf); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Page-by-page erase error.\n"); - return STM32_ERR_UNKNOWN; - } - - s_err = stm32_get_ack_timeout(stm, pages * STM32_SECTERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Page-by-page erase failed. Check the maximum pages your device supports.\n"); - if (port->flags & PORT_STRETCH_W - && stm->cmd->er != STM32_CMD_EE_NS) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - - return STM32_ERR_OK; - } - - /* And now the regular erase (0x43) for all other chips */ - if (pages == 0xFF) { - s_err = stm32_send_command_timeout(stm, 0xFF, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } else { - uint8_t cs = 0; - uint8_t pg_num; - uint8_t *buf; - int i = 0; - - buf = malloc(1 + pages + 1); - if (!buf) - return STM32_ERR_UNKNOWN; - - buf[i++] = pages - 1; - cs ^= (pages-1); - for (pg_num = spage; pg_num < (pages + spage); pg_num++) { - buf[i++] = pg_num; - cs ^= pg_num; - } - buf[i++] = cs; - p_err = port->write(port, buf, i); - free(buf); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Erase failed.\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } -} - -static stm32_err_t stm32_run_raw_code(const stm32_t *stm, - uint32_t target_address, - const uint8_t *code, uint32_t code_size) -{ - uint32_t stack_le = le_u32(0x20002000); - uint32_t code_address_le = le_u32(target_address + 8); - uint32_t length = code_size + 8; - uint8_t *mem, *pos; - uint32_t address, w; - - /* Must be 32-bit aligned */ - if (target_address & 0x3) { - fprintf(stderr, "Error: code address must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - mem = malloc(length); - if (!mem) - return STM32_ERR_UNKNOWN; - - memcpy(mem, &stack_le, sizeof(uint32_t)); - memcpy(mem + 4, &code_address_le, sizeof(uint32_t)); - memcpy(mem + 8, code, code_size); - - pos = mem; - address = target_address; - while (length > 0) { - w = length > 256 ? 256 : length; - if (stm32_write_memory(stm, address, pos, w) != STM32_ERR_OK) { - free(mem); - return STM32_ERR_UNKNOWN; - } - - address += w; - pos += w; - length -= w; - } - - free(mem); - return stm32_go(stm, target_address); -} - -stm32_err_t stm32_go(const stm32_t *stm, uint32_t address) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (stm->cmd->go == STM32_CMD_ERR) { - fprintf(stderr, "Error: GO command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->go) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; -} - -stm32_err_t stm32_reset_device(const stm32_t *stm) -{ - uint32_t target_address = stm->dev->ram_start; - - return stm32_run_raw_code(stm, target_address, stm_reset_code, stm_reset_code_length); -} - -stm32_err_t stm32_crc_memory(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (address & 0x3 || length & 0x3) { - fprintf(stderr, "Start and end addresses must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->crc == STM32_CMD_ERR) { - fprintf(stderr, "Error: CRC command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->crc) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = length >> 24; - buf[1] = (length >> 16) & 0xFF; - buf[2] = (length >> 8) & 0xFF; - buf[3] = length & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (port->read(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (buf[4] != (buf[0] ^ buf[1] ^ buf[2] ^ buf[3])) - return STM32_ERR_UNKNOWN; - - *crc = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; - return STM32_ERR_OK; -} - -/* - * CRC computed by STM32 is similar to the standard crc32_be() - * implemented, for example, in Linux kernel in ./lib/crc32.c - * But STM32 computes it on units of 32 bits word and swaps the - * bytes of the word before the computation. - * Due to byte swap, I cannot use any CRC available in existing - * libraries, so here is a simple not optimized implementation. - */ -#define CRCPOLY_BE 0x04c11db7 -#define CRC_MSBMASK 0x80000000 -#define CRC_INIT_VALUE 0xFFFFFFFF -uint32_t stm32_sw_crc(uint32_t crc, uint8_t *buf, unsigned int len) -{ - int i; - uint32_t data; - - if (len & 0x3) { - fprintf(stderr, "Buffer length must be multiple of 4 bytes\n"); - return 0; - } - - while (len) { - data = *buf++; - data |= *buf++ << 8; - data |= *buf++ << 16; - data |= *buf++ << 24; - len -= 4; - - crc ^= data; - - for (i = 0; i < 32; i++) - if (crc & CRC_MSBMASK) - crc = (crc << 1) ^ CRCPOLY_BE; - else - crc = (crc << 1); - } - return crc; -} - -stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc) -{ - uint8_t buf[256]; - uint32_t start, total_len, len, current_crc; - - if (address & 0x3 || length & 0x3) { - fprintf(stderr, "Start and end addresses must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->crc != STM32_CMD_ERR) - return stm32_crc_memory(stm, address, length, crc); - - start = address; - total_len = length; - current_crc = CRC_INIT_VALUE; - while (length) { - len = length > 256 ? 256 : length; - if (stm32_read_memory(stm, address, buf, len) != STM32_ERR_OK) { - fprintf(stderr, - "Failed to read memory at address 0x%08x, target write-protected?\n", - address); - return STM32_ERR_UNKNOWN; - } - current_crc = stm32_sw_crc(current_crc, buf, len); - length -= len; - address += len; - - fprintf(stderr, - "\rCRC address 0x%08x (%.2f%%) ", - address, - (100.0f / (float)total_len) * (float)(address - start) - ); - fflush(stderr); - } - fprintf(stderr, "Done.\n"); - *crc = current_crc; - return STM32_ERR_OK; -} diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/stm32.h b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/stm32.h deleted file mode 100755 index 1688fcb4b..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/stm32.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _STM32_H -#define _STM32_H - -#include -#include "serial.h" - -#define STM32_MAX_RX_FRAME 256 /* cmd read memory */ -#define STM32_MAX_TX_FRAME (1 + 256 + 1) /* cmd write memory */ - -typedef enum { - STM32_ERR_OK = 0, - STM32_ERR_UNKNOWN, /* Generic error */ - STM32_ERR_NACK, - STM32_ERR_NO_CMD, /* Command not available in bootloader */ -} stm32_err_t; - -typedef struct stm32 stm32_t; -typedef struct stm32_cmd stm32_cmd_t; -typedef struct stm32_dev stm32_dev_t; - -struct stm32 { - const serial_t *serial; - struct port_interface *port; - uint8_t bl_version; - uint8_t version; - uint8_t option1, option2; - uint16_t pid; - stm32_cmd_t *cmd; - const stm32_dev_t *dev; -}; - -struct stm32_dev { - uint16_t id; - const char *name; - uint32_t ram_start, ram_end; - uint32_t fl_start, fl_end; - uint16_t fl_pps; // pages per sector - uint16_t fl_ps; // page size - uint32_t opt_start, opt_end; - uint32_t mem_start, mem_end; -}; - -stm32_t *stm32_init(struct port_interface *port, const char init); -void stm32_close(stm32_t *stm); -stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address, - uint8_t data[], unsigned int len); -stm32_err_t stm32_write_memory(const stm32_t *stm, uint32_t address, - const uint8_t data[], unsigned int len); -stm32_err_t stm32_wunprot_memory(const stm32_t *stm); -stm32_err_t stm32_wprot_memory(const stm32_t *stm); -stm32_err_t stm32_erase_memory(const stm32_t *stm, uint8_t spage, - uint8_t pages); -stm32_err_t stm32_go(const stm32_t *stm, uint32_t address); -stm32_err_t stm32_reset_device(const stm32_t *stm); -stm32_err_t stm32_readprot_memory(const stm32_t *stm); -stm32_err_t stm32_runprot_memory(const stm32_t *stm); -stm32_err_t stm32_crc_memory(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc); -stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc); -uint32_t stm32_sw_crc(uint32_t crc, uint8_t *buf, unsigned int len); - -#endif - diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/stm32flash.1 b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/stm32flash.1 deleted file mode 100755 index d37292f6a..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/stm32flash.1 +++ /dev/null @@ -1,407 +0,0 @@ -.TH STM32FLASH 1 "2013\-11\-03" STM32FLASH "User command" -.SH NAME -stm32flash \- flashing utility for STM32 and STM32W through UART or I2C -.SH SYNOPSIS -.B stm32flash -.RB [ \-cfhjkouvCR ] -.RB [ \-a -.IR bus_address ] -.RB [ \-b -.IR baud_rate ] -.RB [ \-m -.IR serial_mode ] -.RB [ \-r -.IR filename ] -.RB [ \-w -.IR filename ] -.RB [ \-e -.IR num ] -.RB [ \-n -.IR count ] -.RB [ \-g -.IR address ] -.RB [ \-s -.IR start_page ] -.RB [ \-S -.IR address [: length ]] -.RB [ \-F -.IR RX_length [: TX_length ]] -.RB [ \-i -.IR GPIO_string ] -.RI [ tty_device -.R | -.IR i2c_device ] - -.SH DESCRIPTION -.B stm32flash -reads or writes the flash memory of STM32 and STM32W. - -It requires the STM32[W] to embed a bootloader compliant with ST -application note AN3155. -.B stm32flash -uses the serial port -.I tty_device -to interact with the bootloader of STM32[W]. - -.SH OPTIONS -.TP -.BI "\-a" " bus_address" -Specify address on bus for -.IR i2c_device . -This option is mandatory for I2C interface. - -.TP -.BI "\-b" " baud_rate" -Specify baud rate speed of -.IR tty_device . -Please notice that the ST bootloader can automatically detect the baud rate, -as explaned in chapter 2 of AN3155. -This option could be required together with option -.B "\-c" -or if following interaction with bootloader is expected. -Default is -.IR 57600 . - -.TP -.BI "\-m" " mode" -Specify the format of UART data. -.I mode -is a three characters long string where each character specifies, in -this strict order, character size, parity and stop bits. -The only values currenly used are -.I 8e1 -for standard STM32 bootloader and -.I 8n1 -for standard STM32W bootloader. -Default is -.IR 8e1 . - -.TP -.BI "\-r" " filename" -Specify to read the STM32[W] flash and write its content in -.I filename -in raw binary format (see below -.BR "FORMAT CONVERSION" ). - -.TP -.BI "\-w" " filename" -Specify to write the STM32[W] flash with the content of -.IR filename . -File format can be either raw binary or intel hex (see below -.BR "FORMAT CONVERSION" ). -The file format is automatically detected. -To by\-pass format detection and force binary mode (e.g. to -write an intel hex content in STM32[W] flash), use -.B \-f -option. - -.TP -.B \-u -Specify to disable write\-protection from STM32[W] flash. -The STM32[W] will be reset after this operation. - -.TP -.B \-j -Enable the flash read\-protection. - -.TP -.B \-k -Disable the flash read\-protection. - -.TP -.B \-o -Erase only. - -.TP -.BI "\-e" " num" -Specify to erase only -.I num -pages before writing the flash. Default is to erase the whole flash. With -.B \-e 0 -the flash would not be erased. - -.TP -.B \-v -Specify to verify flash content after write operation. - -.TP -.BI "\-n" " count" -Specify to retry failed writes up to -.I count -times. Default is 10 times. - -.TP -.BI "\-g" " address" -Specify address to start execution from (0 = flash start). - -.TP -.BI "\-s" " start_page" -Specify flash page offset (0 = flash start). - -.TP -.BI "\-S" " address" "[:" "length" "]" -Specify start address and optionally length for read/write/erase/crc operations. - -.TP -.BI "\-F" " RX_length" "[:" "TX_length" "]" -Specify the maximum frame size for the current interface. -Due to STM32 bootloader protocol, host will never handle frames bigger than -256 byte in RX or 258 byte in TX. -Due to current code, lowest limit in RX is 20 byte (to read a complete reply -of command GET). Minimum limit in TX is 5 byte, required by protocol. - -.TP -.B \-f -Force binary parser while reading file with -.BR "\-w" "." - -.TP -.B \-h -Show help. - -.TP -.B \-c -Specify to resume the existing UART connection and don't send initial -INIT sequence to detect baud rate. Baud rate must be kept the same as the -existing connection. This is useful if the reset fails. - -.TP -.BI "\-i" " GPIO_string" -Specify the GPIO sequences on the host to force STM32[W] to enter and -exit bootloader mode. GPIO can either be real GPIO connected from host to -STM32[W] beside the UART connection, or UART's modem signals used as -GPIO. (See below -.B BOOTLOADER GPIO SEQUENCE -for the format of -.I GPIO_string -and further explanation). - -.TP -.B \-C -Specify to compute CRC on memory content. -By default the CRC is computed on the whole flash content. -Use -.B "\-S" -to provide different memory address range. - -.TP -.B \-R -Specify to reset the device at exit. -This option is ignored if either -.BR "\-g" "," -.BR "\-j" "," -.B "\-k" -or -.B "\-u" -is also specified. - -.SH BOOTLOADER GPIO SEQUENCE -This feature is currently available on Linux host only. - -As explained in ST application note AN2606, after reset the STM32 will -execute either the application program in user flash or the bootloader, -depending on the level applied at specific pins of STM32 during reset. - -STM32 bootloader is automatically activated by configuring the pins -BOOT0="high" and BOOT1="low" and then by applying a reset. -Application program in user flash is activated by configuring the pin -BOOT0="low" (the level on BOOT1 is ignored) and then by applying a reset. - -When GPIO from host computer are connected to either configuration and -reset pins of STM32, -.B stm32flash -can control the host GPIO to reset STM32 and to force execution of -bootloader or execution of application program. - -The sequence of GPIO values to entry to and exit from bootloader mode is -provided with command line option -.B "\-i" -.IR "GPIO_string" . - -.PD 0 -The format of -.IR "GPIO_string" " is:" -.RS -GPIO_string = [entry sequence][:[exit sequence]] -.P -sequence = [\-]n[,sequence] -.RE -.P -In the above sequences, negative numbers correspond to GPIO at "low" level; -numbers without sign correspond to GPIO at "high" level. -The value "n" can either be the GPIO number on the host system or the -string "rts", "dtr" or "brk". The strings "rts" and "dtr" drive the -corresponding UART's modem lines RTS and DTR as GPIO. -The string "brk" forces the UART to send a BREAK sequence on TX line; -after BREAK the UART is returned in normal "non\-break" mode. -Note: the string "\-brk" has no effect and is ignored. -.PD - -.PD 0 -As example, let's suppose the following connection between host and STM32: -.IP \(bu 2 -host GPIO_3 connected to reset pin of STM32; -.IP \(bu 2 -host GPIO_4 connected to STM32 pin BOOT0; -.IP \(bu 2 -host GPIO_5 connected to STM32 pin BOOT1. -.PD -.P - -In this case, the sequence to enter in bootloader mode is: first put -GPIO_4="high" and GPIO_5="low"; then send reset pulse by GPIO_3="low" -followed by GPIO_3="high". -The corresponding string for -.I GPIO_string -is "4,\-5,\-3,3". - -To exit from bootloade and run the application program, the sequence is: -put GPIO_4="low"; then send reset pulse. -The corresponding string for -.I GPIO_string -is "\-4,\-3,3". - -The complete command line flag is "\-i 4,\-5,\-3,3:\-4,\-3,3". - -STM32W uses pad PA5 to select boot mode; if during reset PA5 is "low" then -STM32W will enter in bootloader mode; if PA5 is "high" it will execute the -program in flash. - -As example, supposing GPIO_3 connected to PA5 and GPIO_2 to STM32W's reset. -The command: -.PD 0 -.RS -stm32flash \-i \-3,\-2,2:3,\-2,2 /dev/ttyS0 -.RE -provides: -.IP \(bu 2 -entry sequence: GPIO_3=low, GPIO_2=low, GPIO_2=high -.IP \(bu 2 -exit sequence: GPIO_3=high, GPIO_2=low, GPIO_2=high -.PD - -.SH EXAMPLES -Get device information: -.RS -.PD 0 -.P -stm32flash /dev/ttyS0 -.PD -.RE - -Write with verify and then start execution: -.RS -.PD 0 -.P -stm32flash \-w filename \-v \-g 0x0 /dev/ttyS0 -.PD -.RE - -Read flash to file: -.RS -.PD 0 -.P -stm32flash \-r filename /dev/ttyS0 -.PD -.RE - -Start execution: -.RS -.PD 0 -.P -stm32flash \-g 0x0 /dev/ttyS0 -.PD -.RE - -Specify: -.PD 0 -.IP \(bu 2 -entry sequence: RTS=low, DTR=low, DTR=high -.IP \(bu 2 -exit sequence: RTS=high, DTR=low, DTR=high -.P -.RS -stm32flash \-i \-rts,\-dtr,dtr:rts,\-dtr,dtr /dev/ttyS0 -.PD -.RE - -.SH FORMAT CONVERSION -Flash images provided by ST or created with ST tools are often in file -format Motorola S\-Record. -Conversion between raw binary, intel hex and Motorola S\-Record can be -done through software package SRecord. - -.SH AUTHORS -The original software package -.B stm32flash -is written by -.I Geoffrey McRae -and is since 2012 maintained by -.IR "Tormod Volden " . - -Man page and extension to STM32W and I2C are written by -.IR "Antonio Borneo " . - -Please report any bugs at the project homepage -http://stm32flash.googlecode.com . - -.SH SEE ALSO -.BR "srec_cat" "(1)," " srec_intel" "(5)," " srec_motorola" "(5)." - -The communication protocol used by ST bootloader is documented in -following ST application notes, depending on communication port. -The current version of -.B stm32flash -only supports -.I UART -and -.I I2C -ports. -.PD 0 -.P -.IP \(bu 2 -AN3154: CAN protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/CD00264321.pdf -.RE - -.P -.IP \(bu 2 -AN3155: USART protocol used in the STM32(TM) bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/CD00264342.pdf -.RE - -.P -.IP \(bu 2 -AN4221: I2C protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/DM00072315.pdf -.RE - -.P -.IP \(bu 2 -AN4286: SPI protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/DM00081379.pdf -.RE - -.PD - - -Boot mode selection for STM32 is documented in ST application note -AN2606, available from the ST website: -.PD 0 -.P -http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf -.PD - -.SH LICENSE -.B stm32flash -is distributed under GNU GENERAL PUBLIC LICENSE Version 2. -Copy of the license is available within the source code in the file -.IR "gpl\-2.0.txt" . diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/utils.c b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/utils.c deleted file mode 100755 index 271bb3ed7..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/utils.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include "utils.h" - -/* detect CPU endian */ -char cpu_le() { - const uint32_t cpu_le_test = 0x12345678; - return ((const unsigned char*)&cpu_le_test)[0] == 0x78; -} - -uint32_t be_u32(const uint32_t v) { - if (cpu_le()) - return ((v & 0xFF000000) >> 24) | - ((v & 0x00FF0000) >> 8) | - ((v & 0x0000FF00) << 8) | - ((v & 0x000000FF) << 24); - return v; -} - -uint32_t le_u32(const uint32_t v) { - if (!cpu_le()) - return ((v & 0xFF000000) >> 24) | - ((v & 0x00FF0000) >> 8) | - ((v & 0x0000FF00) << 8) | - ((v & 0x000000FF) << 24); - return v; -} diff --git a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/utils.h b/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/utils.h deleted file mode 100755 index a8d37d2d5..000000000 --- a/arduino/opencr_arduino/tools/linux/src/stm32flash_serial/src/utils.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_UTILS -#define _H_UTILS - -#include - -char cpu_le(); -uint32_t be_u32(const uint32_t v); -uint32_t le_u32(const uint32_t v); - -#endif diff --git a/arduino/opencr_arduino/tools/linux/src/upload-reset/upload-reset.c b/arduino/opencr_arduino/tools/linux/src/upload-reset/upload-reset.c deleted file mode 100755 index 1d03bff51..000000000 --- a/arduino/opencr_arduino/tools/linux/src/upload-reset/upload-reset.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (C) 2015 Roger Clark - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * - * Utility to send the reset sequence on RTS and DTR and chars - * which resets the libmaple and causes the bootloader to be run - * - * - * - * Terminal control code by Heiko Noordhof (see copyright below) - */ - - - -/* Copyright (C) 2003 Heiko Noordhof - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Function prototypes (belong in a seperate header file) */ -int openserial(char *devicename); -void closeserial(void); -int setDTR(unsigned short level); -int setRTS(unsigned short level); - - -/* Two globals for use by this module only */ -static int fd; -static struct termios oldterminfo; - - -void closeserial(void) -{ - tcsetattr(fd, TCSANOW, &oldterminfo); - close(fd); -} - - -int openserial(char *devicename) -{ - struct termios attr; - - if ((fd = open(devicename, O_RDWR)) == -1) return 0; /* Error */ - atexit(closeserial); - - if (tcgetattr(fd, &oldterminfo) == -1) return 0; /* Error */ - attr = oldterminfo; - attr.c_cflag |= CRTSCTS | CLOCAL; - attr.c_oflag = 0; - if (tcflush(fd, TCIOFLUSH) == -1) return 0; /* Error */ - if (tcsetattr(fd, TCSANOW, &attr) == -1) return 0; /* Error */ - - /* Set the lines to a known state, and */ - /* finally return non-zero is successful. */ - return setRTS(0) && setDTR(0); -} - - -/* For the two functions below: - * level=0 to set line to LOW - * level=1 to set line to HIGH - */ - -int setRTS(unsigned short level) -{ - int status; - - if (ioctl(fd, TIOCMGET, &status) == -1) { - perror("setRTS(): TIOCMGET"); - return 0; - } - if (level) status |= TIOCM_RTS; - else status &= ~TIOCM_RTS; - if (ioctl(fd, TIOCMSET, &status) == -1) { - perror("setRTS(): TIOCMSET"); - return 0; - } - return 1; -} - - -int setDTR(unsigned short level) -{ - int status; - - if (ioctl(fd, TIOCMGET, &status) == -1) { - perror("setDTR(): TIOCMGET"); - return 0; - } - if (level) status |= TIOCM_DTR; - else status &= ~TIOCM_DTR; - if (ioctl(fd, TIOCMSET, &status) == -1) { - perror("setDTR: TIOCMSET"); - return 0; - } - return 1; -} - -/* This portion of code was written by Roger Clark - * It was informed by various other pieces of code written by Leaflabs to reset their - * Maple and Maple mini boards - */ - -main(int argc, char *argv[]) -{ - - if (argc<2 || argc >3) - { - printf("Usage upload-reset \n\r"); - return; - } - - if (openserial(argv[1])) - { - // Send magic sequence of DTR and RTS followed by the magic word "1EAF" - setRTS(false); - setDTR(false); - setDTR(true); - - usleep(50000L); - - setDTR(false); - setRTS(true); - setDTR(true); - - usleep(50000L); - - setDTR(false); - - usleep(50000L); - - write(fd,"1EAF",4); - - closeserial(); - if (argc==3) - { - usleep(atol(argv[2])*1000L); - } - } - else - { - printf("Failed to open serial device.\n\r"); - } -} diff --git a/arduino/opencr_arduino/tools/linux/stlink/st-flash b/arduino/opencr_arduino/tools/linux/stlink/st-flash deleted file mode 100755 index 951b11a38..000000000 Binary files a/arduino/opencr_arduino/tools/linux/stlink/st-flash and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/stlink/st-info b/arduino/opencr_arduino/tools/linux/stlink/st-info deleted file mode 100755 index 0787606f4..000000000 Binary files a/arduino/opencr_arduino/tools/linux/stlink/st-info and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/stlink/st-term b/arduino/opencr_arduino/tools/linux/stlink/st-term deleted file mode 100755 index b5425db23..000000000 Binary files a/arduino/opencr_arduino/tools/linux/stlink/st-term and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/stlink/st-util b/arduino/opencr_arduino/tools/linux/stlink/st-util deleted file mode 100755 index c6a007864..000000000 Binary files a/arduino/opencr_arduino/tools/linux/stlink/st-util and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/stlink_upload b/arduino/opencr_arduino/tools/linux/stlink_upload deleted file mode 100755 index 24e528d5b..000000000 --- a/arduino/opencr_arduino/tools/linux/stlink_upload +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# Check for leaf device. -function leaf_status() -{ - -this_leaf_status=$(lsusb |grep "1eaf" | awk '{ print $NF}') -# Find the mode of the leaf bootloader -case $this_leaf_status in - "1eaf:0003") - echo "dfu" - ;; - "1eaf:0004") - echo "ttyACMx" - ;; - *) - #echo "$this_leaf_status" - echo "unknown" - ;; -esac -} - -# You will need the usb-reset code, see https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Using-a-generic-stm32-board-on-linux-with-Maple-bootloader -# -USBRESET=$(which usb-reset) || USBRESET="./usb-reset" - -# Check to see if a maple compatible board is attached -LEAF_STATUS=$(leaf_status) -echo "USB Status [$LEAF_STATUS]" - -$(dirname $0)/stlink/st-flash write "$4" 0x8000000 - -sleep 4 -# Reset the usb device to bring up the tty rather than DFU -"$USBRESET" "/dev/bus/usb/$(lsusb |grep "1eaf" |awk '{print $2,$4}'|sed 's/\://g'|sed 's/ /\//g')" >/dev/null 2>&1 -# Check to see if a maple compatible board is attached -LEAF_STATUS=$(leaf_status) -echo "USB Status [$LEAF_STATUS]" -# Check to see if the tty came up -TTY_DEV=$(find /dev -cmin -2 |grep ttyAC) -echo -e "Waiting for tty device $TTY_DEV \n" -sleep 20 -echo -e "$TTY_DEV should now be available.\n" -exit 0 - diff --git a/arduino/opencr_arduino/tools/linux/stm32flash/stm32flash b/arduino/opencr_arduino/tools/linux/stm32flash/stm32flash deleted file mode 100755 index 16872bba6..000000000 Binary files a/arduino/opencr_arduino/tools/linux/stm32flash/stm32flash and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/upload-reset b/arduino/opencr_arduino/tools/linux/upload-reset deleted file mode 100755 index 26985b857..000000000 Binary files a/arduino/opencr_arduino/tools/linux/upload-reset and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux/upload_router b/arduino/opencr_arduino/tools/linux/upload_router deleted file mode 100755 index b74244d29..000000000 --- a/arduino/opencr_arduino/tools/linux/upload_router +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash -# Translates the windows Arduino IDE upload call - something like.. -# -# upload_router ttyUSB0 1 1EAF:0003 /tmp/build9114565021046468906.tmp/STM32_Blink.cpp maple_dfu 0 -# -# to the linux dfu-util equivalent of the form... -# -# dfu-util -D ./STM32_Blink.cpp.bin -d 1eaf:0003 --intf 0 --alt 1 -# -# - -function leaf_status() -{ - -this_leaf_status=$(lsusb |grep "1eaf" | awk '{ print $NF}') -# Find the mode of the leaf bootloader -case $this_leaf_status in - "1eaf:0003") - echo "dfu" - ;; - "1eaf:0004") - echo "ttyACMx" - ;; - *) - #echo "$this_leaf_status" - echo "unknown" - ;; -esac -} - - -DEVICE="$3" -# Lowercase the 1eaf device name, since in Windows land everybody shouts. -DEVICE=${DEVICE,,} - -BINFILE="$4.bin" -INTERFACE="$6" -ALT_INTERFACE="$2" - -# You will need the usb-reset code, see https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Using-a-generic-stm32-board-on-linux-with-Maple-bootloader -# -USBRESET=$(which usb-reset) || USBRESET="./usb-reset" - -# Check to see if a maple compatible board is attached -LEAF_STATUS=$(leaf_status) - -# Borard not found, or no boot loader on board. -if [[ $(leaf_status) = "unknown" ]] -then - echo "STM32 Maple Bootloader compatible board not found." - sleep 5 - exit 1 -fi - -# We got this far, so we need to get the board in bootloader mode. -# After the timeout period, the board goes back in to serial mode, we need it in dfu mode, which happens for the first few seconds at power on -# so we ask the user to unplug and re-plug the board. -echo -e "\n\rSTM32 Maple board is in $LEAF_STATUS mode." - -echo "Please unplug and replug the USB cable to the Maple device." -sleep 2 -# On unplugging the board will be "unknown" -while [[ $(leaf_status) != "unknown" ]] -do - echo -n "." - sleep 1 -done -# On re-plugging the board will be "dfu" -while [[ $(leaf_status) != "dfu" ]] -do - echo -n "." - sleep 1 -done - -echo -e "\n\rProgramming STM32 device with dfu-util" -until dfu-util -D "$BINFILE" -d "$DEVICE" --intf "$INTERFACE" --alt "$ALT_INTERFACE" 2>&1 -do - echo -n "." - sleep 1 -done - -echo -e "\n\rUnplug and replug the USB cable to the STM32 board again please...." -while [[ $(leaf_status) != "unknown" ]] -do - echo -n "." - sleep 1 -done - -echo -e "\n\rReconnecting" -while [[ $(leaf_status) = "unknown" ]] -do - echo -n "." - sleep 1 -done - -echo -e "\n\rWaiting for bootloader to exit." -for i in {1..6} -do - echo -n "." - sleep 1 -done - -"$USBRESET" "/dev/bus/usb/$(lsusb |grep "1eaf" |awk '{print $2,$4}'|sed 's/\://g'|sed 's/ /\//g')" >/dev/null 2>&1 - -while [[ $(leaf_status) = "unknown" ]] -do - echo -n "." - sleep 1 -done -THIS_TTY=$(find /dev/ttyACM* -cmin -2) -echo -e "\n\rSTM32 Maple board serial port re-created..." -echo -e "\n\rSerial port is $THIS_TTY Please allow 15 seconds before attempting to read from serial port." diff --git a/arduino/opencr_arduino/tools/linux64/45-maple.rules b/arduino/opencr_arduino/tools/linux64/45-maple.rules deleted file mode 100755 index d1bda5fb1..000000000 --- a/arduino/opencr_arduino/tools/linux64/45-maple.rules +++ /dev/null @@ -1,5 +0,0 @@ -ATTRS{idProduct}=="1001", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev" -ATTRS{idProduct}=="1002", ATTRS{idVendor}=="0110", MODE="664", GROUP="plugdev" -ATTRS{idProduct}=="0003", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple" -ATTRS{idProduct}=="0004", ATTRS{idVendor}=="1eaf", MODE="664", GROUP="plugdev" SYMLINK+="maple" - diff --git a/arduino/opencr_arduino/tools/linux64/49-stlinkv1.rules b/arduino/opencr_arduino/tools/linux64/49-stlinkv1.rules deleted file mode 100755 index d474d6a40..000000000 --- a/arduino/opencr_arduino/tools/linux64/49-stlinkv1.rules +++ /dev/null @@ -1,11 +0,0 @@ -# stm32 discovery boards, with onboard st/linkv1 -# ie, STM32VL - -SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3744", \ - MODE:="0666", \ - SYMLINK+="stlinkv1_%n" - -# If you share your linux system with other users, or just don't like the -# idea of write permission for everybody, you can replace MODE:="0666" with -# OWNER:="yourusername" to create the device owned by you, or with -# GROUP:="somegroupname" and mange access using standard unix groups. diff --git a/arduino/opencr_arduino/tools/linux64/49-stlinkv2-1.rules b/arduino/opencr_arduino/tools/linux64/49-stlinkv2-1.rules deleted file mode 100755 index a5a79b91c..000000000 --- a/arduino/opencr_arduino/tools/linux64/49-stlinkv2-1.rules +++ /dev/null @@ -1,12 +0,0 @@ -# stm32 nucleo boards, with onboard st/linkv2-1 -# ie, STM32F0, STM32F4. -# STM32VL has st/linkv1, which is quite different - -SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \ - MODE:="0666", \ - SYMLINK+="stlinkv2-1_%n" - -# If you share your linux system with other users, or just don't like the -# idea of write permission for everybody, you can replace MODE:="0666" with -# OWNER:="yourusername" to create the device owned by you, or with -# GROUP:="somegroupname" and mange access using standard unix groups. diff --git a/arduino/opencr_arduino/tools/linux64/49-stlinkv2.rules b/arduino/opencr_arduino/tools/linux64/49-stlinkv2.rules deleted file mode 100755 index a11215c57..000000000 --- a/arduino/opencr_arduino/tools/linux64/49-stlinkv2.rules +++ /dev/null @@ -1,12 +0,0 @@ -# stm32 discovery boards, with onboard st/linkv2 -# ie, STM32L, STM32F4. -# STM32VL has st/linkv1, which is quite different - -SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", \ - MODE:="0666", \ - SYMLINK+="stlinkv2_%n" - -# If you share your linux system with other users, or just don't like the -# idea of write permission for everybody, you can replace MODE:="0666" with -# OWNER:="yourusername" to create the device owned by you, or with -# GROUP:="somegroupname" and mange access using standard unix groups. diff --git a/arduino/opencr_arduino/tools/linux64/install.sh b/arduino/opencr_arduino/tools/linux64/install.sh deleted file mode 100755 index 29ddb2f22..000000000 --- a/arduino/opencr_arduino/tools/linux64/install.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -if sudo [ -w /etc/udev/rules.d ]; then - echo "Copying Maple-specific udev rules..." - sudo cp -v 45-maple.rules /etc/udev/rules.d/45-maple.rules - sudo chown root:root /etc/udev/rules.d/45-maple.rules - sudo chmod 644 /etc/udev/rules.d/45-maple.rules - sudo cp -v 49-stlinkv1.rules /etc/udev/rules.d/49-stlinkv1.rules - sudo chown root:root /etc/udev/rules.d/49-stlinkv1.rules - sudo chmod 644 /etc/udev/rules.d/49-stlinkv1.rules - sudo cp -v 49-stlinkv2.rules /etc/udev/rules.d/49-stlinkv2.rules - sudo chown root:root /etc/udev/rules.d/49-stlinkv2.rules - sudo chmod 644 /etc/udev/rules.d/49-stlinkv2.rules - sudo cp -v 49-stlinkv2-1.rules /etc/udev/rules.d/49-stlinkv2-1.rules - sudo chown root:root /etc/udev/rules.d/49-stlinkv2-1.rules - sudo chmod 644 /etc/udev/rules.d/49-stlinkv2-1.rules - echo "Reloading udev rules" - sudo udevadm control --reload-rules - echo "Adding current user to dialout group" - sudo adduser $USER dialout -else - echo "Couldn't copy to /etc/udev/rules.d/; you probably have to run this script as root? Or your distribution of Linux doesn't include udev; try running the IDE itself as root." -fi - diff --git a/arduino/opencr_arduino/tools/linux64/maple_upload b/arduino/opencr_arduino/tools/linux64/maple_upload deleted file mode 100755 index e799f3a90..000000000 --- a/arduino/opencr_arduino/tools/linux64/maple_upload +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash - -#set -e - - - -if [ $# -lt 4 ]; then - echo "Usage: $0 $# " >&2 - exit 1 -fi -dummy_port="$1"; altID="$2"; usbID="$3"; binfile="$4"; dummy_port_fullpath="/dev/$1" -if [ $# -eq 5 ]; then - dfuse_addr="--dfuse-address $5" -else - dfuse_addr="" -fi - - -# Get the directory where the script is running. -DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) - -# ----------------- IMPORTANT ----------------- -# The 2nd parameter to upload-reset is the delay after resetting before it exits -# This value is in milliseonds -# You may need to tune this to your system -# 750ms to 1500ms seems to work on my Mac - - -"${DIR}/upload-reset" ${dummy_port_fullpath} 750 - - -#DFU_UTIL=$(dirname $0)/dfu-util/dfu-util -DFU_UTIL=/usr/bin/dfu-util -DFU_UTIL=${DIR}/dfu-util/dfu-util -if [ ! -x "${DFU_UTIL}" ]; then - echo "$0: error: cannot find ${DFU_UTIL}" >&2 - exit 2 -fi - -"${DFU_UTIL}" -d ${usbID} -a ${altID} -D ${binfile} ${dfuse_addr} -R diff --git a/arduino/opencr_arduino/tools/linux64/readme.txt b/arduino/opencr_arduino/tools/linux64/readme.txt deleted file mode 100755 index 2d13beb3c..000000000 --- a/arduino/opencr_arduino/tools/linux64/readme.txt +++ /dev/null @@ -1 +0,0 @@ -The maple upload script needs its rights to be set to 755 \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/linux64/serial_upload b/arduino/opencr_arduino/tools/linux64/serial_upload deleted file mode 100755 index 05d17c6e5..000000000 --- a/arduino/opencr_arduino/tools/linux64/serial_upload +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -$(dirname $0)/stm32flash/stm32flash -g 0x8000000 -b 230400 -w "$4" /dev/"$1" diff --git a/arduino/opencr_arduino/tools/linux64/src/build_dfu-util.sh b/arduino/opencr_arduino/tools/linux64/src/build_dfu-util.sh deleted file mode 100755 index 3563f576c..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/build_dfu-util.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -sudo apt-get build-dep dfu-util -sudo apt-get install build-essentials -sudo apt-get install libusb-1.0-0-dev -sudo apt-get install autoconf automake autotools-dev - -cd dfu-util -./autogen.sh -./configure -make -cp src/dfu-util ../../linux/dfu-util -cp src/dfu-suffix ../../linux/dfu-util -cp src/dfu-prefix ../../linux/dfu-util - diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/AUTHORS b/arduino/opencr_arduino/tools/linux64/src/dfu-util/AUTHORS deleted file mode 100755 index 1b36c739c..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/AUTHORS +++ /dev/null @@ -1,30 +0,0 @@ -Authors ordered by first contribution. - -Harald Welte -Werner Almesberger -Michael Lauer -Jim Huang -Stefan Schmidt -Daniel Willmann -Mike Frysinger -Uwe Hermann -C. Scott Ananian -Bernard Blackham -Holger Freyther -Marc Singer -James Perkins -Tommi Keisala -Pascal Schweizer -Bradley Scott -Uwe Bonnes -Andrey Smirnov -Jussi Timperi -Hans Petter Selasky -Bo Shen -Henrique de Almeida Mendonca -Bernd Krumboeck -Dennis Meier -Veli-Pekka Peltola -Dave Hylands -Michael Grzeschik -Paul Fertser diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/COPYING b/arduino/opencr_arduino/tools/linux64/src/dfu-util/COPYING deleted file mode 100755 index d60c31a97..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/ChangeLog b/arduino/opencr_arduino/tools/linux64/src/dfu-util/ChangeLog deleted file mode 100755 index 37f1addba..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/ChangeLog +++ /dev/null @@ -1,93 +0,0 @@ -0.8: - o New, separate dfu-prefix tool (Uwe Bonnes) - o Allow filtering on serial number (Uwe Bonnes) - o Improved VID/PID/serial filtering (Bradley Scott) - o Support reading firmware from stdin (Tormod Volden) - o Warn if missing DFU suffix (Tormod Volden) - o Improved progress bar (Hans Petter Selasky) - o Fix dfuse leave option (Uwe Bonnes) - o Major code rework (Hans Petter Selasky) - o MS Visual Studio build support (Henrique Mendonca) - o dfuse-pack.py tool for .dfu files (Antonio Galeo) - o Many other fixes from many people - -2014-09-13: Tormod Volden - -0.7: - o Support for TI Stellaris devices (Tommi Keisala) - o Fix libusb detection on MacOSX (Marc Singer) - o Fix libusb detection on FreeBSD (Tormod Volden) - o Improved DfuSe support (Tormod Volden) - o Support all special commands (leave, unprotect, mass-erase) - o Arbitrary upload lengths - o "force" option for various possible (dangerous) overrides - -2012-10-07: Tormod Volden - -0.6: - o Add detach mode (Stefan Schmidt) - o Check return value on all libusb calls (Tormod Volden) - o Fix segmentation fault with -s option (Tormod Volden) - o Add DFU suffix manipulation tool (Stefan Schmidt) - o Port to Windows: (Tormod Volden, some parts based on work from Satz - Klauer) - o Port file handling to stdio streams - o Sleep() macros - o C99 types - o Pack structs - o Detect DfuSe device correctly on big-endian architectures (Tormod - Volden) - o Add dfuse progress indication on download (Tormod Volden) - o Cleanup: gcc pedantic, gcc extension, ... (Tormod Volden) - o Rely on page size from functional descriptor. Please report if you get - an error about it. (Tormod Volden) - o Add quirk for Maple since it reports wrong DFU version (Tormod Volden) - -2012-04-22: Stefan Schmidt - -0.5: - o DfuSe extension support for ST devices (Tormod Volden) - o Add initial support for bitWillDetach flag from DFU 1.1 (Tormod - Volden) - o Internal cleanup and some manual page fixes (Tormod Volden) - -2011-11-02: Stefan Schmidt - -0.4: - o Rework to use libusb-1.0 (Stefan Schmidt) - o DFU suffix support (Tormod Volden, Stefan Schmidt) - o Sspeed up DFU downloads directly into memory (Bernard Blackham) - o More flexible -d vid:pid parsing (Tormod Volden) - o Many bug fixes and cleanups - -2011-07-20: Stefan Schmidt - -0.3: - o quirks: Add OpenOCD to the poll timeout quirk table. - -2010-12-22: Stefan Schmidt - -0.2: - o Fix some typos on the website and the README (Antonio Ospite, Uwe - Hermann) - o Remove build rule for a static binary. We can use autotools for this. - (Mike Frysinger) - o Fix infinite loop in download error path (C. Scott Ananian) - o Break out to show the 'finished' in upload (C. Scott Ananian) - o Add GPLv2+ headers (Harald Welte) - o Remove dead code (commands.[ch]) remnescent of dfu-programmer (Harald - Welte) - o Simple quirk system with Openmoko quirk for missing bwPollTimeout (Tormod Volden) - o New default (1024) and clamping of transfer size (Tormod Volden) - o Verify sending of completion packet (Tormod Volden) - o Look for DFU functional descriptor among all descriptors (Tormod - Volden) - o Print out in which direction we are transferring data - o Abort in upload if the file already exists - -2010-11-17 Stefan Schmidt - -0.1: - Initial release - -2010-05-23 Stefan Schmidt diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/DEVICES.txt b/arduino/opencr_arduino/tools/linux64/src/dfu-util/DEVICES.txt deleted file mode 100755 index bdd9f1f2e..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/DEVICES.txt +++ /dev/null @@ -1,20 +0,0 @@ -List of supported software and hardware products: - -Software user (bootloader, etc) -------------------------------- -- Sam7DFU: http://www.openpcd.org/Sam7dfu -- U-boot: DFU patches -- Barebox: http://www.barebox.org/ -- Leaflabs: http://code.google.com/p/leaflabs/ -- Blackmagic DFU - -Products using DFU ------------------- -- OpenPCD (sam7dfu) -- Openmoko Neo 1973 and Freerunner (u-boot with DFU patches) -- Leaflabs Maple -- ATUSB from Qi Hardware -- STM32F105/7, STM32F2/F3/F4 in System Bootloader -- Blackmagic debug probe -- NXP LPC31xx/LPC43XX, e.g. LPC-Link and LPC-Link2, need binaries - with LPC prefix and encoding (LPC-Link) diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/Makefile.am b/arduino/opencr_arduino/tools/linux64/src/dfu-util/Makefile.am deleted file mode 100755 index 641dda58a..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = src doc - -EXTRA_DIST = autogen.sh TODO DEVICES.txt dfuse-pack.py diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/README b/arduino/opencr_arduino/tools/linux64/src/dfu-util/README deleted file mode 100755 index 0f8f2621a..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/README +++ /dev/null @@ -1,20 +0,0 @@ -Dfu-util - Device Firmware Upgrade Utilities - -Dfu-util is the host side implementation of the DFU 1.0 [1] and DFU 1.1 [2] -specification of the USB forum. - -DFU is intended to download and upload firmware to devices connected over -USB. It ranges from small devices like micro-controller boards up to mobile -phones. With dfu-util you are able to download firmware to your device or -upload firmware from it. - -dfu-util has been tested with Openmoko Neo1973 and Freerunner and many -other devices. - -[1] DFU 1.0 spec: http://www.usb.org/developers/devclass_docs/usbdfu10.pdf -[2] DFU 1.1 spec: http://www.usb.org/developers/devclass_docs/DFU_1.1.pdf - -The official website is: - - http://dfu-util.gnumonks.org/ - diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/TODO b/arduino/opencr_arduino/tools/linux64/src/dfu-util/TODO deleted file mode 100755 index 900c30c29..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/TODO +++ /dev/null @@ -1,14 +0,0 @@ -DfuSe: -- Do erase and write in two separate passes when downloading -- Skip "Set Address" command when downloading contiguous blocks -- Implement "Get Commands" command - -Devices: -- Research iPhone/iPod/iPad support - Heavily modified dfu-util fork here: - https://github.com/planetbeing/xpwn/tree/master/dfu-util -- Test against Niftylights - -Non-Code: -- Logo -- Re-License as LGPL for usage as library? diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/autogen.sh b/arduino/opencr_arduino/tools/linux64/src/dfu-util/autogen.sh deleted file mode 100755 index e67aed39a..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/autogen.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -autoreconf -v -i diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/configure.ac b/arduino/opencr_arduino/tools/linux64/src/dfu-util/configure.ac deleted file mode 100755 index 86221143f..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/configure.ac +++ /dev/null @@ -1,41 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59) -AC_INIT([dfu-util],[0.8],[dfu-util@lists.gnumonks.org],,[http://dfu-util.gnumonks.org]) -AC_CONFIG_AUX_DIR(m4) -AM_INIT_AUTOMAKE([foreign]) -AC_CONFIG_HEADERS([config.h]) - -# Test for new silent rules and enable only if they are available -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -# Checks for programs. -AC_PROG_CC - -# Checks for libraries. -# On FreeBSD the libusb-1.0 is called libusb and resides in system location -AC_CHECK_LIB([usb], [libusb_init],, [native_libusb=no],) -AS_IF([test x$native_libusb = xno], [ - PKG_CHECK_MODULES([USB], [libusb-1.0 >= 1.0.0],, - AC_MSG_ERROR([*** Required libusb-1.0 >= 1.0.0 not installed ***])) -]) -AC_CHECK_LIB([usbpath],[usb_path2devnum],,,-lusb) - -LIBS="$LIBS $USB_LIBS" -CFLAGS="$CFLAGS $USB_CFLAGS" - -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([usbpath.h windows.h sysexits.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_TYPE_SIZE_T - -# Checks for library functions. -AC_FUNC_MEMCMP -AC_CHECK_FUNCS([ftruncate getpagesize nanosleep err]) - -AC_CONFIG_FILES(Makefile src/Makefile doc/Makefile) -AC_OUTPUT diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/README b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/README deleted file mode 100755 index 00d3d1a96..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/README +++ /dev/null @@ -1,77 +0,0 @@ -Device: -------- -qi-hardware-atusb: -- Qi Hardware ben-wpan -- DFU implementation: - http://projects.qi-hardware.com/index.php/p/ben-wpan/source/tree/master/atusb/fw/usb -- Tester: Stefan Schmidt - -openpcd: -- OpenPCD RFID reader -- DFU implementation: SAM7DFU - http://www.openpcd.org/Sam7dfu, git://git.gnumonks.org/openpcd.git -- Tester: Stefan Schmidt - -simtrace: -- Sysmocom SimTrace -- DFU implementation: SAM7DFU - http://www.openpcd.org/Sam7dfu, git://git.gnumonks.org/openpcd.git -- Tester: Stefan Schmidt - -openmoko-freerunner: -- Openmoko Freerunner -- DFU implementation: Old U-Boot - http://git.openmoko.org/?p=u-boot.git;a=shortlog;h=refs/heads/mokopatches -- Tester: Stefan Schmidt - -openmoko-neo1973: -- Openmoko Neo1073 -- DFU implementation: Old U-Boot - http://git.openmoko.org/?p=u-boot.git;a=shortlog;h=refs/heads/mokopatches -- Tester: Stefan Schmidt - -tdk-bluetooth: -- TDK Corp. Bluetooth Adapter -- DFU implementation: closed soure -- Only upload has been tested -- Tester: Stefan Schmidt - -stm32f107: -- STM32 microcontrollers with built-in (ROM) DFU loader -- DFU implementation: Closed source but probably similar to the one - in their USB device libraries. Some relevant application notes: - http://www.st.com -> AN3156 and AN2606 -- Tested by Uwe Bonnes - -stm32f4discovery: -- STM32 microcontroller board with built-in (ROM) DFU loader -- DFU implementation: Closed source, probably similar to stm32f107. -- Tested by Joe Rothweiler - -dso-nano: -- DSO Nano pocket oscilloscope -- DFU implementation: Based on ST Microelectronics USB FS Library 1.0 - http://dsonano.googlecode.com/files/DS0201_OpenSource.rar -- Tester: Tormod Volden - -opc-20: -- Custom devices based on STM32F1xx -- DFU implementation: ST Microelectronics USB FS Device Library 3.1.0 - http://www.st.com -> um0424.zip -- Tester: Tormod Volden - -lpc-link, lpclink2: -- NXP LPCXpresso debug adapters -- Proprietary DFU implementation, uses special download files with - LPC prefix and encoding of the target firmware code -- Tested by Uwe Bonnes - -Adding the lsusb output and a download log of your device here helps -us to avoid regressions for hardware we cannot test while working on -the code. To extract the lsusb output use this command: -sudo lsusb -v -d $USBID > $DEVICE.lsusb -Prepare a description snippet as above, and send it to us. A log -(copy-paste of the command window) of a firmware download is also -nice, please use the double verbose option -v -v and include the -command line in the log file. - diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/dsonano.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/dsonano.lsusb deleted file mode 100755 index 140a7bc6c..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/dsonano.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 002 Device 004: ID 0483:df11 SGS Thomson Microelectronics -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 - bcdDevice 1.1a - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 DFU - iSerial 3 001 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 64mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 4 @Internal Flash /0x08000000/12*001Ka,116*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 5 @SPI Flash : M25P64/0x00000000/64*064Kg,64*064Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1.1a -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink.log b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink.log deleted file mode 100755 index 7de4dd3e6..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink.log +++ /dev/null @@ -1,59 +0,0 @@ -(The on-board LPC3154 has some encryption key set and LPCXpressoWIN.enc -is encrypted.) - -$ lsusb | grep NXP -Bus 003 Device 011: ID 0471:df55 Philips (or NXP) LPCXpresso LPC-Link - -$ dfu-util -v -v -v -R -D /opt/lpc/lpcxpresso/bin/LPCXpressoWIN.enc - -dfu-util 0.7 - -Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. -Copyright 2010-2012 Tormod Volden and Stefan Schmidt -This program is Free Software and has ABSOLUTELY NO WARRANTY -Please report bugs to dfu-util@lists.gnumonks.org - -dfu-util: Invalid DFU suffix signature -dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! -Deducing device DFU version from functional descriptor length -Opening DFU capable USB device... -ID 0471:df55 -Run-time device DFU version 0100 -Claiming USB DFU Runtime Interface... -Determining device status: -state = dfuIDLE, status = 0 -dfu-util: WARNING: Runtime device already in DFU state ?!? -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: -state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 0100 -Device returned transfer size 2048 -Copying data from PC to DFU device -Download [ ] 0% 0 bytes -Download [= ] 6% 2048 bytes -Download [=== ] 13% 4096 bytes -Download [==== ] 19% 6144 bytes -Download [====== ] 26% 8192 bytes -Download [======== ] 32% 10240 bytes -Download [========= ] 39% 12288 bytes -Download [=========== ] 45% 14336 bytes -Download [============= ] 52% 16384 bytes -Download [============== ] 59% 18432 bytes -Download [================ ] 65% 20480 bytes -Download [================== ] 72% 22528 bytes -Download [=================== ] 78% 24576 bytes -Download [===================== ] 85% 26624 bytes -Download [====================== ] 91% 28672 bytes -Download [======================== ] 98% 29192 bytes -Download [=========================] 100% 29192 bytes -Download done. -Sent a total of 29192 bytes -state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present -Done! -dfu-util: can't detach -Resetting USB to switch back to runtime mode - -$ lsusb | grep NXP -Bus 003 Device 012: ID 1fc9:0009 NXP Semiconductors diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink.lsusb deleted file mode 100755 index 867b2a2c5..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink.lsusb +++ /dev/null @@ -1,58 +0,0 @@ - -Bus 003 Device 008: ID 0471:df55 Philips (or NXP) LPCXpresso LPC-Link -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0471 Philips (or NXP) - idProduct 0xdf55 LPCXpresso LPC-Link - bcdDevice 0.01 - iManufacturer 0 - iProduct 0 - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 25 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 7 - bDescriptorType 33 - bmAttributes 1 - Will Not Detach - Manifestation Intolerant - Upload Unsupported - Download Supported - wDetachTimeout 65535 milliseconds - wTransferSize 2048 bytes -Device Qualifier (for other device speed): - bLength 10 - bDescriptorType 6 - bcdUSB 2.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - bNumConfigurations 1 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink2.log b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink2.log deleted file mode 100755 index 4681eff7d..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink2.log +++ /dev/null @@ -1,59 +0,0 @@ -$ lsusb | grep NXP -Bus 003 Device 013: ID 1fc9:000c NXP Semiconductors - -$ dfu-util -D ~/devel/dfu-util/firmware.bin.qthdr - -dfu-util 0.7 - -Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. -Copyright 2010-2012 Tormod Volden and Stefan Schmidt -This program is Free Software and has ABSOLUTELY NO WARRANTY -Please report bugs to dfu-util@lists.gnumonks.org - -dfu-util: Invalid DFU suffix signature -dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! -Possible unencryptes NXP LPC DFU prefix with the following properties -Payload length: 39 kiByte -Opening DFU capable USB device... -ID 1fc9:000c -Run-time device DFU version 0100 -Claiming USB DFU Runtime Interface... -Determining device status: -state = dfuIDLE, status = 0 -dfu-util: WARNING: Runtime device already in DFU state ?!? -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: -state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 0100 -Device returned transfer size 2048 -Copying data from PC to DFU device -Download [ ] 0% 0 bytes -Download [= ] 4% 2048 bytes -Download [== ] 9% 4096 bytes -Download [=== ] 14% 6144 bytes -Download [==== ] 19% 8192 bytes -Download [====== ] 24% 10240 bytes -Download [======= ] 28% 12288 bytes -Download [======== ] 33% 14336 bytes -Download [========= ] 38% 16384 bytes -Download [========== ] 43% 18432 bytes -Download [============ ] 48% 20480 bytes -Download [============= ] 53% 22528 bytes -Download [============== ] 57% 24576 bytes -Download [=============== ] 62% 26624 bytes -Download [================ ] 67% 28672 bytes -Download [================== ] 72% 30720 bytes -Download [=================== ] 77% 32768 bytes -Download [==================== ] 82% 34816 bytes -Download [===================== ] 86% 36864 bytes -Download [====================== ] 91% 38912 bytes -Download [======================== ] 96% 40356 bytes -Download [=========================] 100% 40356 bytes -Download done. -Sent a total of 40356 bytes -dfu-util: unable to read DFU status - -$ lsusb | grep NXP -Bus 003 Device 014: ID 1fc9:0018 NXP Semiconductors diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink2.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink2.lsusb deleted file mode 100755 index b833fca77..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/lpclink2.lsusb +++ /dev/null @@ -1,203 +0,0 @@ - -Bus 003 Device 007: ID 0c72:000c PEAK System PCAN-USB -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x0c72 PEAK System - idProduct 0x000c PCAN-USB - bcdDevice 1c.ff - iManufacturer 0 - iProduct 3 VER1:PEAK -VER2:02.8.01 -DAT :06.05.2004 -TIME:09:35:37 - ... - iSerial 0 - bNumConfigurations 3 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 2 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 394mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 3 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/opc-20.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/opc-20.lsusb deleted file mode 100755 index 580df90e5..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/opc-20.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 004: ID 0483:df11 SGS Thomson Microelectronics -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 - bcdDevice 2.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 DFU - iSerial 3 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/12*001Ka,116*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @SPI Flash : M25P64/0x00000000/128*64Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1a.01 -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb deleted file mode 100755 index 4c0abfb06..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb +++ /dev/null @@ -1,109 +0,0 @@ -Bus 003 Device 017: ID 1d50:5119 OpenMoko, Inc. GTA01/GTA02 U-Boot Bootloader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x5119 GTA01/GTA02 U-Boot Bootloader - bcdDevice 0.00 - iManufacturer 1 OpenMoko, Inc - iProduct 2 Neo1973 Bootloader U-Boot 1.3.2-moko12 - iSerial 3 0000000 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 81 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 7 USB Device Firmware Upgrade - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 8 RAM 0x32000000 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 9 u-boot - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 10 u-boot_env - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 3 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 11 kernel - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 4 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 12 splash - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 5 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 13 factory - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 6 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 14 rootfs - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 -Device Status: 0x0a00 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openmoko-freerunner.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openmoko-freerunner.lsusb deleted file mode 100755 index 835708dd8..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openmoko-freerunner.lsusb +++ /dev/null @@ -1,179 +0,0 @@ -Bus 005 Device 033: ID 1d50:5119 OpenMoko, Inc. GTA01/GTA02 U-Boot Bootloader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.10 - bDeviceClass 2 Communications - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x5119 GTA01/GTA02 U-Boot Bootloader - bcdDevice 0.00 - iManufacturer 1 OpenMoko, Inc - iProduct 2 Neo1973 Bootloader U-Boot 1.3.2-moko12 - iSerial 3 0000000 - bNumConfigurations 2 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 85 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 4 TTY via USB - bmAttributes 0x80 - (Bus Powered) - MaxPower 500mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 Control Interface - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 Bulk Data Interface - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 7 USB Device Firmware Upgrade - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 67 - bNumInterfaces 2 - bConfigurationValue 2 - iConfiguration 4 TTY via USB - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 Control Interface - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 Bulk Data Interface - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 -Device Status: 0x9a00 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openmoko-neo1973.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openmoko-neo1973.lsusb deleted file mode 100755 index 07789506a..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openmoko-neo1973.lsusb +++ /dev/null @@ -1,182 +0,0 @@ - -Bus 006 Device 020: ID 1457:5119 First International Computer, Inc. OpenMoko Neo1973 u-boot cdc_acm serial port -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.10 - bDeviceClass 2 Communications - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1457 First International Computer, Inc. - idProduct 0x5119 OpenMoko Neo1973 u-boot cdc_acm serial port - bcdDevice 0.00 - iManufacturer 1 - iProduct 2 - iSerial 3 - bNumConfigurations 2 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 85 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 4 - bmAttributes 0x80 - (Bus Powered) - MaxPower 500mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 7 - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 67 - bNumInterfaces 2 - bConfigurationValue 2 - iConfiguration 4 - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 -Device Status: 0x0006 - (Bus Powered) - Remote Wakeup Enabled - Test Mode diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openpcd.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openpcd.lsusb deleted file mode 100755 index f6255a943..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/openpcd.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 006 Device 016: ID 16c0:076b VOTI OpenPCD 13.56MHz RFID Reader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 8 - idVendor 0x16c0 VOTI - idProduct 0x076b OpenPCD 13.56MHz RFID Reader - bcdDevice 0.00 - iManufacturer 1 - iProduct 2 OpenPCD RFID Simulator - DFU Mode - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 0 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 3 - Will Not Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 256 bytes - bcdDFUVersion 1.00 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/qi-hardware-atusb.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/qi-hardware-atusb.lsusb deleted file mode 100755 index bfc1701e1..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/qi-hardware-atusb.lsusb +++ /dev/null @@ -1,59 +0,0 @@ - -Bus 006 Device 013: ID 20b7:1540 Qi Hardware ben-wpan, AT86RF230-based -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 255 Vendor Specific Class - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x20b7 Qi Hardware - idProduct 0x1540 ben-wpan, AT86RF230-based - bcdDevice 0.01 - iManufacturer 0 - iProduct 0 - iSerial 1 4630333438371508231a - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 34 - bNumInterfaces 2 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 40mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 255 Vendor Specific Class - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 0 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 0 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/simtrace.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/simtrace.lsusb deleted file mode 100755 index 578ddf0e1..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/simtrace.lsusb +++ /dev/null @@ -1,70 +0,0 @@ - -Bus 006 Device 017: ID 16c0:0762 VOTI -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 8 - idVendor 0x16c0 VOTI - idProduct 0x0762 - bcdDevice 0.00 - iManufacturer 1 sysmocom - systems for mobile communications GmbH - iProduct 2 SimTrace SIM Sniffer - DFU Mode - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 45 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 3 SimTrace DFU Configuration - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 SimTrace DFU Interface - Application Partition - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 SimTrace DFU Interface - Bootloader Partition - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 6 SimTrace DFU Interface - RAM - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 3 - Will Not Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 256 bytes - bcdDFUVersion 1.00 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/sparkcore.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/sparkcore.lsusb deleted file mode 100755 index b6029ffa5..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/sparkcore.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 008: ID 1d50:607f OpenMoko, Inc. -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x607f - bcdDevice 2.00 - iManufacturer 1 Spark Devices - iProduct 2 CORE DFU - iSerial 3 8D80527B5055 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/20*001Ka,108*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @SPI Flash : SST25x/0x00000000/512*04Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1.1a -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f107.bin-download b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f107.bin-download deleted file mode 100755 index 45b714f83..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f107.bin-download +++ /dev/null @@ -1,48 +0,0 @@ -> src/dfu-util --intf 0 --alt 0 -v -v -v -s 0x8000000 -D test3 -dfu-util 0.4 - -(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. -(C) 2010-2011 Tormod Volden (DfuSe support) -This program is Free Software and has ABSOLUTELY NO WARRANTY - -dfu-util does currently only support DFU version 1.0 - -Opening DFU USB device... ID 0483:df11 -Run-time device DFU version 011a -Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/128*002Kg" -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 011a -Device returned transfer size 2048 -No valid DFU suffix signature -Warning: File has no DFU suffix -DfuSe interface name: "Internal Flash " -Memory segment at 0x08000000 128 x 2048 = 262144 (rew) -Uploading to address = 0x08000000, size = 16384 -Erasing page size 2048 at address 0x08000000, page starting at 0x08000000 - Download from image offset 00000000 to memory 08000000-080007ff, size 2048 - Setting address pointer to 0x08000000 -Erasing page size 2048 at address 0x08000800, page starting at 0x08000800 - Download from image offset 00000800 to memory 08000800-08000fff, size 2048 - Setting address pointer to 0x08000800 -Erasing page size 2048 at address 0x08001000, page starting at 0x08001000 - Download from image offset 00001000 to memory 08001000-080017ff, size 2048 - Setting address pointer to 0x08001000 -Erasing page size 2048 at address 0x08001800, page starting at 0x08001800 - Download from image offset 00001800 to memory 08001800-08001fff, size 2048 - Setting address pointer to 0x08001800 -Erasing page size 2048 at address 0x08002000, page starting at 0x08002000 - Download from image offset 00002000 to memory 08002000-080027ff, size 2048 - Setting address pointer to 0x08002000 -Erasing page size 2048 at address 0x08002800, page starting at 0x08002800 - Download from image offset 00002800 to memory 08002800-08002fff, size 2048 - Setting address pointer to 0x08002800 -Erasing page size 2048 at address 0x08003000, page starting at 0x08003000 - Download from image offset 00003000 to memory 08003000-080037ff, size 2048 - Setting address pointer to 0x08003000 -Erasing page size 2048 at address 0x08003800, page starting at 0x08003800 - Download from image offset 00003800 to memory 08003800-08003fff, size 2048 - Setting address pointer to 0x08003800 - diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f107.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f107.lsusb deleted file mode 100755 index 14b45cda0..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f107.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 028: ID 0483:df11 SGS Thomson Microelectronics STM Device in DFU Mode -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 STM Device in DFU Mode - bcdDevice 20.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 0x418 DFU Bootloader - iSerial 3 STM32 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/128*002Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @Option Bytes /0x1FFFF800/01*016 g - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 2048 bytes - bcdDFUVersion 1.1a -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f4discovery.bin-download b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f4discovery.bin-download deleted file mode 100755 index 96e172216..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f4discovery.bin-download +++ /dev/null @@ -1,36 +0,0 @@ -dfu-util --device 0483:df11 --alt 0 \ - --dfuse-address 0x08000000 \ - -v -v -v \ - --download arm/iotoggle.bin -No valid DFU suffix signature -Warning: File has no DFU suffix -dfu-util 0.5 - -(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. -(C) 2010-2011 Tormod Volden (DfuSe support) -This program is Free Software and has ABSOLUTELY NO WARRANTY - -dfu-util does currently only support DFU version 1.0 - -Filter on vendor = 0x0483 product = 0xdf11 -Opening DFU capable USB device... ID 0483:df11 -Run-time device DFU version 011a -Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg" -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: state = dfuERROR, status = 10 -dfuERROR, clearing status -Determining device status: state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 011a -Device returned transfer size 2048 -DfuSe interface name: "Internal Flash " -Memory segment at 0x08000000 4 x 16384 = 65536 (rew) -Memory segment at 0x08010000 1 x 65536 = 65536 (rew) -Memory segment at 0x08020000 7 x 131072 = 917504 (rew) -Uploading to address = 0x08000000, size = 2308 -Erasing page size 16384 at address 0x08000000, page starting at 0x08000000 - Download from image offset 00000000 to memory 08000000-080007ff, size 2048 - Setting address pointer to 0x08000000 - Download from image offset 00000800 to memory 08000800-08000903, size 260 - Setting address pointer to 0x08000800 diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f4discovery.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f4discovery.lsusb deleted file mode 100755 index 0b870de91..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/stm32f4discovery.lsusb +++ /dev/null @@ -1,80 +0,0 @@ - -Bus 001 Device 010: ID 0483:df11 SGS Thomson Microelectronics STM Device in DFU Mode -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 STM Device in DFU Mode - bcdDevice 21.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 BOOTLOADER - iSerial 3 315A28A0B956 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 54 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @Option Bytes /0x1FFFC000/01*016 g - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 6 @OTP Memory /0x1FFF7800/01*512 g,01*016 g - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 3 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 7 @Device Feature/0xFFFF0000/01*004 g - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 2048 bytes - bcdDFUVersion 1.1a -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/tdk-bluetooth.lsusb b/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/tdk-bluetooth.lsusb deleted file mode 100755 index c0cfaceb6..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/device-logs/tdk-bluetooth.lsusb +++ /dev/null @@ -1,269 +0,0 @@ - -Bus 006 Device 014: ID 04bf:0320 TDK Corp. Bluetooth Adapter -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 224 Wireless - bDeviceSubClass 1 Radio Frequency - bDeviceProtocol 1 Bluetooth - bMaxPacketSize0 64 - idVendor 0x04bf TDK Corp. - idProduct 0x0320 Bluetooth Adapter - bcdDevice 26.52 - iManufacturer 1 Ezurio - iProduct 2 Turbo Bluetooth Adapter - iSerial 3 008098D4FFBD - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 193 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 64mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 3 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0000 1x 0 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0000 1x 0 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 1 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0009 1x 9 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0009 1x 9 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 2 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0011 1x 17 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0011 1x 17 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 3 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0019 1x 25 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0019 1x 25 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 4 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0021 1x 33 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0021 1x 33 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 5 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0031 1x 49 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0031 1x 49 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 7 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 5000 milliseconds - wTransferSize 1023 bytes -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/dfuse-pack.py b/arduino/opencr_arduino/tools/linux64/src/dfu-util/dfuse-pack.py deleted file mode 100755 index 875cc5c6e..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/dfuse-pack.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/python - -# Written by Antonio Galea - 2010/11/18 -# Distributed under Gnu LGPL 3.0 -# see http://www.gnu.org/licenses/lgpl-3.0.txt - -import sys,struct,zlib,os -from optparse import OptionParser - -DEFAULT_DEVICE="0x0483:0xdf11" - -def named(tuple,names): - return dict(zip(names.split(),tuple)) -def consume(fmt,data,names): - n = struct.calcsize(fmt) - return named(struct.unpack(fmt,data[:n]),names),data[n:] -def cstring(string): - return string.split('\0',1)[0] -def compute_crc(data): - return 0xFFFFFFFF & -zlib.crc32(data) -1 - -def parse(file,dump_images=False): - print 'File: "%s"' % file - data = open(file,'rb').read() - crc = compute_crc(data[:-4]) - prefix, data = consume('<5sBIB',data,'signature version size targets') - print '%(signature)s v%(version)d, image size: %(size)d, targets: %(targets)d' % prefix - for t in range(prefix['targets']): - tprefix, data = consume('<6sBI255s2I',data,'signature altsetting named name size elements') - tprefix['num'] = t - if tprefix['named']: - tprefix['name'] = cstring(tprefix['name']) - else: - tprefix['name'] = '' - print '%(signature)s %(num)d, alt setting: %(altsetting)s, name: "%(name)s", size: %(size)d, elements: %(elements)d' % tprefix - tsize = tprefix['size'] - target, data = data[:tsize], data[tsize:] - for e in range(tprefix['elements']): - eprefix, target = consume('<2I',target,'address size') - eprefix['num'] = e - print ' %(num)d, address: 0x%(address)08x, size: %(size)d' % eprefix - esize = eprefix['size'] - image, target = target[:esize], target[esize:] - if dump_images: - out = '%s.target%d.image%d.bin' % (file,t,e) - open(out,'wb').write(image) - print ' DUMPED IMAGE TO "%s"' % out - if len(target): - print "target %d: PARSE ERROR" % t - suffix = named(struct.unpack('<4H3sBI',data[:16]),'device product vendor dfu ufd len crc') - print 'usb: %(vendor)04x:%(product)04x, device: 0x%(device)04x, dfu: 0x%(dfu)04x, %(ufd)s, %(len)d, 0x%(crc)08x' % suffix - if crc != suffix['crc']: - print "CRC ERROR: computed crc32 is 0x%08x" % crc - data = data[16:] - if data: - print "PARSE ERROR" - -def build(file,targets,device=DEFAULT_DEVICE): - data = '' - for t,target in enumerate(targets): - tdata = '' - for image in target: - tdata += struct.pack('<2I',image['address'],len(image['data']))+image['data'] - tdata = struct.pack('<6sBI255s2I','Target',0,1,'ST...',len(tdata),len(target)) + tdata - data += tdata - data = struct.pack('<5sBIB','DfuSe',1,len(data)+11,len(targets)) + data - v,d=map(lambda x: int(x,0) & 0xFFFF, device.split(':',1)) - data += struct.pack('<4H3sB',0,d,v,0x011a,'UFD',16) - crc = compute_crc(data) - data += struct.pack(' and -Harald Welte . Over time, nearly complete -support of DFU 1.0, DFU 1.1 and DfuSe ("1.1a") has been added. -.SH LICENCE -.B dfu-util -is covered by the GNU General Public License (GPL), version 2 or later. -.SH COPYRIGHT -This manual page was originally written by Uwe Hermann , -and is now part of the dfu-util project. diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/README_msvc.txt b/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/README_msvc.txt deleted file mode 100755 index 6e68ec6ff..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/README_msvc.txt +++ /dev/null @@ -1,10 +0,0 @@ -# (C) Roger Meier -# (C) Pascal Schweizer -# msvc folder is GPL-2.0+, LGPL-2.1+, BSD-3-Clause or MIT license(SPDX) - -Building dfu-util native on Windows with Visual Studio - -3rd party dependencies: -- libusbx ( git clone https://github.com/libusbx/libusbx.git ) - - getopt (part of libusbx: libusbx/examples/getopt) - diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/dfu-suffix_2010.vcxproj b/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/dfu-suffix_2010.vcxproj deleted file mode 100755 index 0c316c2e5..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/dfu-suffix_2010.vcxproj +++ /dev/null @@ -1,100 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA} - dfusuffix - dfu-suffix - - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\dll;$(LibraryPath) - $(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib - $(ExecutablePath) - - - $(ExecutablePath) - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\dll;$(LibraryPath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - Level3 - Disabled - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebug - - - true - - - - - Level3 - MaxSpeed - true - true - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - - - true - true - true - - - - - - - - - - - - - {a2169bc8-cf99-40bf-83f3-b0e38f7067bd} - - - {349ee8f9-7d25-4909-aaf5-ff3fade72187} - - - - - - \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/dfu-util_2010.sln b/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/dfu-util_2010.sln deleted file mode 100755 index ef797239b..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/dfu-util_2010.sln +++ /dev/null @@ -1,54 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dfu-util", "dfu-util_2010.vcxproj", "{0E071A60-7EF2-4427-BAA8-9143CACB5BCB}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C4F8746D-B27E-4806-95E5-2052174E923B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dfu-suffix", "dfu-suffix_2010.vcxproj", "{8F7600A2-3B37-4956-B39B-A1D43EF29EDA}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt_2010", "..\..\libusbx\msvc\getopt_2010.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "..\..\libusbx\msvc\libusb_static_2010.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|Win32.ActiveCfg = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|Win32.Build.0 = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|x64.ActiveCfg = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|Win32.ActiveCfg = Release|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|Win32.Build.0 = Release|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|x64.ActiveCfg = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|Win32.ActiveCfg = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|Win32.Build.0 = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|x64.ActiveCfg = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|Win32.ActiveCfg = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|Win32.Build.0 = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|x64.ActiveCfg = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.ActiveCfg = Debug|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.Build.0 = Debug|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.ActiveCfg = Debug|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.Build.0 = Debug|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.ActiveCfg = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.Build.0 = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.ActiveCfg = Release|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.Build.0 = Release|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/dfu-util_2010.vcxproj b/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/dfu-util_2010.vcxproj deleted file mode 100755 index 17a8bee1b..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/msvc/dfu-util_2010.vcxproj +++ /dev/null @@ -1,120 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB} - dfuutil - dfu-util - - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\getopt\$(Configuration);$(LibraryPath) - $(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib - $(ExecutablePath) - - - $(ExecutablePath) - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\getopt\$(Configuration);$(LibraryPath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - Level3 - Disabled - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebug - - - true - - - - - - - - - Level3 - MaxSpeed - true - true - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - - - true - true - true - - - copy $(SolutionDir)..\$(Platform)\$(Configuration)\dll\libusb-1.0.dll $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - - - - - - - - - - - - - - - - - - - - - - - {a2169bc8-cf99-40bf-83f3-b0e38f7067bd} - - - {349ee8f9-7d25-4909-aaf5-ff3fade72187} - - - - - - \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/Makefile.am b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/Makefile.am deleted file mode 100755 index 70179c411..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -AM_CFLAGS = -Wall -Wextra - -bin_PROGRAMS = dfu-util dfu-suffix dfu-prefix -dfu_util_SOURCES = main.c \ - portable.h \ - dfu_load.c \ - dfu_load.h \ - dfu_util.c \ - dfu_util.h \ - dfuse.c \ - dfuse.h \ - dfuse_mem.c \ - dfuse_mem.h \ - dfu.c \ - dfu.h \ - usb_dfu.h \ - dfu_file.c \ - dfu_file.h \ - quirks.c \ - quirks.h - -dfu_suffix_SOURCES = suffix.c \ - dfu_file.h \ - dfu_file.c - -dfu_prefix_SOURCES = prefix.c \ - dfu_file.h \ - dfu_file.c diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu.c b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu.c deleted file mode 100755 index 14d7673d1..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Low-level DFU communication routines, originally taken from - * $Id: dfu.c,v 1.3 2006/06/20 06:28:04 schmidtw Exp $ - * (part of dfu-programmer). - * - * Copyright 2005-2006 Weston Schmidt - * Copyright 2011-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include - -#include - -#include "portable.h" -#include "dfu.h" -#include "quirks.h" - -static int dfu_timeout = 5000; /* 5 seconds - default */ - -/* - * DFU_DETACH Request (DFU Spec 1.0, Section 5.1) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * timeout - the timeout in ms the USB device should wait for a pending - * USB reset before giving up and terminating the operation - * - * returns 0 or < 0 on error - */ -int dfu_detach( libusb_device_handle *device, - const unsigned short interface, - const unsigned short timeout ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DETACH, - /* wValue */ timeout, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -/* - * DFU_DNLOAD Request (DFU Spec 1.0, Section 6.1.1) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the total number of bytes to transfer to the USB - * device - must be less than wTransferSize - * data - the data to transfer - * - * returns the number of bytes written or < 0 on error - */ -int dfu_download( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ) -{ - int status; - - status = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DNLOAD, - /* wValue */ transaction, - /* wIndex */ interface, - /* Data */ data, - /* wLength */ length, - dfu_timeout ); - return status; -} - - -/* - * DFU_UPLOAD Request (DFU Spec 1.0, Section 6.2) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the maximum number of bytes to receive from the USB - * device - must be less than wTransferSize - * data - the buffer to put the received data in - * - * returns the number of bytes received or < 0 on error - */ -int dfu_upload( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ) -{ - int status; - - status = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_UPLOAD, - /* wValue */ transaction, - /* wIndex */ interface, - /* Data */ data, - /* wLength */ length, - dfu_timeout ); - return status; -} - - -/* - * DFU_GETSTATUS Request (DFU Spec 1.0, Section 6.1.2) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * status - the data structure to be populated with the results - * - * return the number of bytes read in or < 0 on an error - */ -int dfu_get_status( struct dfu_if *dif, struct dfu_status *status ) -{ - unsigned char buffer[6]; - int result; - - /* Initialize the status data structure */ - status->bStatus = DFU_STATUS_ERROR_UNKNOWN; - status->bwPollTimeout = 0; - status->bState = STATE_DFU_ERROR; - status->iString = 0; - - result = libusb_control_transfer( dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_GETSTATUS, - /* wValue */ 0, - /* wIndex */ dif->interface, - /* Data */ buffer, - /* wLength */ 6, - dfu_timeout ); - - if( 6 == result ) { - status->bStatus = buffer[0]; - if (dif->quirks & QUIRK_POLLTIMEOUT) - status->bwPollTimeout = DEFAULT_POLLTIMEOUT; - else - status->bwPollTimeout = ((0xff & buffer[3]) << 16) | - ((0xff & buffer[2]) << 8) | - (0xff & buffer[1]); - status->bState = buffer[4]; - status->iString = buffer[5]; - } - - return result; -} - - -/* - * DFU_CLRSTATUS Request (DFU Spec 1.0, Section 6.1.3) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * - * return 0 or < 0 on an error - */ -int dfu_clear_status( libusb_device_handle *device, - const unsigned short interface ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT| LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_CLRSTATUS, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -/* - * DFU_GETSTATE Request (DFU Spec 1.0, Section 6.1.5) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the maximum number of bytes to receive from the USB - * device - must be less than wTransferSize - * data - the buffer to put the received data in - * - * returns the state or < 0 on error - */ -int dfu_get_state( libusb_device_handle *device, - const unsigned short interface ) -{ - int result; - unsigned char buffer[1]; - - result = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_GETSTATE, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ buffer, - /* wLength */ 1, - dfu_timeout ); - - /* Return the error if there is one. */ - if (result < 1) - return -1; - - /* Return the state. */ - return buffer[0]; -} - - -/* - * DFU_ABORT Request (DFU Spec 1.0, Section 6.1.4) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * - * returns 0 or < 0 on an error - */ -int dfu_abort( libusb_device_handle *device, - const unsigned short interface ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_ABORT, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -const char* dfu_state_to_string( int state ) -{ - const char *message; - - switch (state) { - case STATE_APP_IDLE: - message = "appIDLE"; - break; - case STATE_APP_DETACH: - message = "appDETACH"; - break; - case STATE_DFU_IDLE: - message = "dfuIDLE"; - break; - case STATE_DFU_DOWNLOAD_SYNC: - message = "dfuDNLOAD-SYNC"; - break; - case STATE_DFU_DOWNLOAD_BUSY: - message = "dfuDNBUSY"; - break; - case STATE_DFU_DOWNLOAD_IDLE: - message = "dfuDNLOAD-IDLE"; - break; - case STATE_DFU_MANIFEST_SYNC: - message = "dfuMANIFEST-SYNC"; - break; - case STATE_DFU_MANIFEST: - message = "dfuMANIFEST"; - break; - case STATE_DFU_MANIFEST_WAIT_RESET: - message = "dfuMANIFEST-WAIT-RESET"; - break; - case STATE_DFU_UPLOAD_IDLE: - message = "dfuUPLOAD-IDLE"; - break; - case STATE_DFU_ERROR: - message = "dfuERROR"; - break; - default: - message = NULL; - break; - } - - return message; -} - -/* Chapter 6.1.2 */ -static const char *dfu_status_names[] = { - /* DFU_STATUS_OK */ - "No error condition is present", - /* DFU_STATUS_errTARGET */ - "File is not targeted for use by this device", - /* DFU_STATUS_errFILE */ - "File is for this device but fails some vendor-specific test", - /* DFU_STATUS_errWRITE */ - "Device is unable to write memory", - /* DFU_STATUS_errERASE */ - "Memory erase function failed", - /* DFU_STATUS_errCHECK_ERASED */ - "Memory erase check failed", - /* DFU_STATUS_errPROG */ - "Program memory function failed", - /* DFU_STATUS_errVERIFY */ - "Programmed memory failed verification", - /* DFU_STATUS_errADDRESS */ - "Cannot program memory due to received address that is out of range", - /* DFU_STATUS_errNOTDONE */ - "Received DFU_DNLOAD with wLength = 0, but device does not think that it has all data yet", - /* DFU_STATUS_errFIRMWARE */ - "Device's firmware is corrupt. It cannot return to run-time (non-DFU) operations", - /* DFU_STATUS_errVENDOR */ - "iString indicates a vendor specific error", - /* DFU_STATUS_errUSBR */ - "Device detected unexpected USB reset signalling", - /* DFU_STATUS_errPOR */ - "Device detected unexpected power on reset", - /* DFU_STATUS_errUNKNOWN */ - "Something went wrong, but the device does not know what it was", - /* DFU_STATUS_errSTALLEDPKT */ - "Device stalled an unexpected request" -}; - - -const char *dfu_status_to_string(int status) -{ - if (status > DFU_STATUS_errSTALLEDPKT) - return "INVALID"; - return dfu_status_names[status]; -} - -int dfu_abort_to_idle(struct dfu_if *dif) -{ - int ret; - struct dfu_status dst; - - ret = dfu_abort(dif->dev_handle, dif->interface); - if (ret < 0) { - errx(EX_IOERR, "Error sending dfu abort request"); - exit(1); - } - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during abort get_status"); - exit(1); - } - if (dst.bState != DFU_STATE_dfuIDLE) { - errx(EX_IOERR, "Failed to enter idle state on abort"); - exit(1); - } - milli_sleep(dst.bwPollTimeout); - return ret; -} diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu.h b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu.h deleted file mode 100755 index 8e3caeb7b..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * dfu-programmer - * - * $Id: dfu.h,v 1.2 2005/09/25 01:27:42 schmidtw Exp $ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFU_H -#define DFU_H - -#include -#include "usb_dfu.h" - -/* DFU states */ -#define STATE_APP_IDLE 0x00 -#define STATE_APP_DETACH 0x01 -#define STATE_DFU_IDLE 0x02 -#define STATE_DFU_DOWNLOAD_SYNC 0x03 -#define STATE_DFU_DOWNLOAD_BUSY 0x04 -#define STATE_DFU_DOWNLOAD_IDLE 0x05 -#define STATE_DFU_MANIFEST_SYNC 0x06 -#define STATE_DFU_MANIFEST 0x07 -#define STATE_DFU_MANIFEST_WAIT_RESET 0x08 -#define STATE_DFU_UPLOAD_IDLE 0x09 -#define STATE_DFU_ERROR 0x0a - - -/* DFU status */ -#define DFU_STATUS_OK 0x00 -#define DFU_STATUS_ERROR_TARGET 0x01 -#define DFU_STATUS_ERROR_FILE 0x02 -#define DFU_STATUS_ERROR_WRITE 0x03 -#define DFU_STATUS_ERROR_ERASE 0x04 -#define DFU_STATUS_ERROR_CHECK_ERASED 0x05 -#define DFU_STATUS_ERROR_PROG 0x06 -#define DFU_STATUS_ERROR_VERIFY 0x07 -#define DFU_STATUS_ERROR_ADDRESS 0x08 -#define DFU_STATUS_ERROR_NOTDONE 0x09 -#define DFU_STATUS_ERROR_FIRMWARE 0x0a -#define DFU_STATUS_ERROR_VENDOR 0x0b -#define DFU_STATUS_ERROR_USBR 0x0c -#define DFU_STATUS_ERROR_POR 0x0d -#define DFU_STATUS_ERROR_UNKNOWN 0x0e -#define DFU_STATUS_ERROR_STALLEDPKT 0x0f - -/* DFU commands */ -#define DFU_DETACH 0 -#define DFU_DNLOAD 1 -#define DFU_UPLOAD 2 -#define DFU_GETSTATUS 3 -#define DFU_CLRSTATUS 4 -#define DFU_GETSTATE 5 -#define DFU_ABORT 6 - -/* DFU interface */ -#define DFU_IFF_DFU 0x0001 /* DFU Mode, (not Runtime) */ - -/* This is based off of DFU_GETSTATUS - * - * 1 unsigned byte bStatus - * 3 unsigned byte bwPollTimeout - * 1 unsigned byte bState - * 1 unsigned byte iString -*/ - -struct dfu_status { - unsigned char bStatus; - unsigned int bwPollTimeout; - unsigned char bState; - unsigned char iString; -}; - -struct dfu_if { - struct usb_dfu_func_descriptor func_dfu; - uint16_t quirks; - uint16_t busnum; - uint16_t devnum; - uint16_t vendor; - uint16_t product; - uint16_t bcdDevice; - uint8_t configuration; - uint8_t interface; - uint8_t altsetting; - uint8_t flags; - uint8_t bMaxPacketSize0; - char *alt_name; - char *serial_name; - libusb_device *dev; - libusb_device_handle *dev_handle; - struct dfu_if *next; -}; - -int dfu_detach( libusb_device_handle *device, - const unsigned short interface, - const unsigned short timeout ); -int dfu_download( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ); -int dfu_upload( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ); -int dfu_get_status( struct dfu_if *dif, - struct dfu_status *status ); -int dfu_clear_status( libusb_device_handle *device, - const unsigned short interface ); -int dfu_get_state( libusb_device_handle *device, - const unsigned short interface ); -int dfu_abort( libusb_device_handle *device, - const unsigned short interface ); -int dfu_abort_to_idle( struct dfu_if *dif); - -const char *dfu_state_to_string( int state ); - -const char *dfu_status_to_string( int status ); - -#endif /* DFU_H */ diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_file.c b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_file.c deleted file mode 100755 index 7c897d4f6..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_file.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Load or store DFU files including suffix and prefix - * - * Copyright 2014 Tormod Volden - * Copyright 2012 Stefan Schmidt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -#define DFU_SUFFIX_LENGTH 16 -#define LMDFU_PREFIX_LENGTH 8 -#define LPCDFU_PREFIX_LENGTH 16 -#define PROGRESS_BAR_WIDTH 25 -#define STDIN_CHUNK_SIZE 65536 - -static const unsigned long crc32_table[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}; - -static uint32_t crc32_byte(uint32_t accum, uint8_t delta) -{ - return crc32_table[(accum ^ delta) & 0xff] ^ (accum >> 8); -} - -static int probe_prefix(struct dfu_file *file) -{ - uint8_t *prefix = file->firmware; - - if (file->size.total < LMDFU_PREFIX_LENGTH) - return 1; - if ((prefix[0] == 0x01) && (prefix[1] == 0x00)) { - file->prefix_type = LMDFU_PREFIX; - file->size.prefix = LMDFU_PREFIX_LENGTH; - file->lmdfu_address = 1024 * ((prefix[3] << 8) | prefix[2]); - } - else if (((prefix[0] & 0x3f) == 0x1a) && ((prefix[1] & 0x3f)== 0x3f)) { - file->prefix_type = LPCDFU_UNENCRYPTED_PREFIX; - file->size.prefix = LPCDFU_PREFIX_LENGTH; - } - - if (file->size.prefix + file->size.suffix > file->size.total) - return 1; - return 0; -} - -void dfu_progress_bar(const char *desc, unsigned long long curr, - unsigned long long max) -{ - static char buf[PROGRESS_BAR_WIDTH + 1]; - static unsigned long long last_progress = -1; - static time_t last_time; - time_t curr_time = time(NULL); - unsigned long long progress; - unsigned long long x; - - /* check for not known maximum */ - if (max < curr) - max = curr + 1; - /* make none out of none give zero */ - if (max == 0 && curr == 0) - max = 1; - - /* compute completion */ - progress = (PROGRESS_BAR_WIDTH * curr) / max; - if (progress > PROGRESS_BAR_WIDTH) - progress = PROGRESS_BAR_WIDTH; - if (progress == last_progress && - curr_time == last_time) - return; - last_progress = progress; - last_time = curr_time; - - for (x = 0; x != PROGRESS_BAR_WIDTH; x++) { - if (x < progress) - buf[x] = '='; - else - buf[x] = ' '; - } - buf[x] = 0; - - printf("\r%s\t[%s] %3lld%% %12lld bytes", desc, buf, - (100ULL * curr) / max, curr); - - if (progress == PROGRESS_BAR_WIDTH) - printf("\n%s done.\n", desc); -} - -void *dfu_malloc(size_t size) -{ - void *ptr = malloc(size); - if (ptr == NULL) - errx(EX_SOFTWARE, "Cannot allocate memory of size %d bytes", (int)size); - return (ptr); -} - -uint32_t dfu_file_write_crc(int f, uint32_t crc, const void *buf, int size) -{ - int x; - - /* compute CRC */ - for (x = 0; x != size; x++) - crc = crc32_byte(crc, ((uint8_t *)buf)[x]); - - /* write data */ - if (write(f, buf, size) != size) - err(EX_IOERR, "Could not write %d bytes to file %d", size, f); - - return (crc); -} - -void dfu_load_file(struct dfu_file *file, enum suffix_req check_suffix, enum prefix_req check_prefix) -{ - off_t offset; - int f; - int i; - int res; - - file->size.prefix = 0; - file->size.suffix = 0; - - /* default values, if no valid suffix is found */ - file->bcdDFU = 0; - file->idVendor = 0xffff; /* wildcard value */ - file->idProduct = 0xffff; /* wildcard value */ - file->bcdDevice = 0xffff; /* wildcard value */ - - /* default values, if no valid prefix is found */ - file->lmdfu_address = 0; - - free(file->firmware); - - if (!strcmp(file->name, "-")) { - int read_bytes; - -#ifdef WIN32 - _setmode( _fileno( stdin ), _O_BINARY ); -#endif - file->firmware = (uint8_t*) dfu_malloc(STDIN_CHUNK_SIZE); - read_bytes = fread(file->firmware, 1, STDIN_CHUNK_SIZE, stdin); - file->size.total = read_bytes; - while (read_bytes == STDIN_CHUNK_SIZE) { - file->firmware = (uint8_t*) realloc(file->firmware, file->size.total + STDIN_CHUNK_SIZE); - if (!file->firmware) - err(EX_IOERR, "Could not allocate firmware buffer"); - read_bytes = fread(file->firmware + file->size.total, 1, STDIN_CHUNK_SIZE, stdin); - file->size.total += read_bytes; - } - if (verbose) - printf("Read %i bytes from stdin\n", file->size.total); - /* Never require suffix when reading from stdin */ - check_suffix = MAYBE_SUFFIX; - } else { - f = open(file->name, O_RDONLY | O_BINARY); - if (f < 0) - err(EX_IOERR, "Could not open file %s for reading", file->name); - - offset = lseek(f, 0, SEEK_END); - - if ((int)offset < 0 || (int)offset != offset) - err(EX_IOERR, "File size is too big"); - - if (lseek(f, 0, SEEK_SET) != 0) - err(EX_IOERR, "Could not seek to beginning"); - - file->size.total = offset; - file->firmware = dfu_malloc(file->size.total); - - if (read(f, file->firmware, file->size.total) != file->size.total) { - err(EX_IOERR, "Could not read %d bytes from %s", - file->size.total, file->name); - } - close(f); - } - - /* Check for possible DFU file suffix by trying to parse one */ - { - uint32_t crc = 0xffffffff; - const uint8_t *dfusuffix; - int missing_suffix = 0; - const char *reason; - - if (file->size.total < DFU_SUFFIX_LENGTH) { - reason = "File too short for DFU suffix"; - missing_suffix = 1; - goto checked; - } - - dfusuffix = file->firmware + file->size.total - - DFU_SUFFIX_LENGTH; - - for (i = 0; i < file->size.total - 4; i++) - crc = crc32_byte(crc, file->firmware[i]); - - if (dfusuffix[10] != 'D' || - dfusuffix[9] != 'F' || - dfusuffix[8] != 'U') { - reason = "Invalid DFU suffix signature"; - missing_suffix = 1; - goto checked; - } - - file->dwCRC = (dfusuffix[15] << 24) + - (dfusuffix[14] << 16) + - (dfusuffix[13] << 8) + - dfusuffix[12]; - - if (file->dwCRC != crc) { - reason = "DFU suffix CRC does not match"; - missing_suffix = 1; - goto checked; - } - - /* At this point we believe we have a DFU suffix - so we require further checks to succeed */ - - file->bcdDFU = (dfusuffix[7] << 8) + dfusuffix[6]; - - if (verbose) - printf("DFU suffix version %x\n", file->bcdDFU); - - file->size.suffix = dfusuffix[11]; - - if (file->size.suffix < DFU_SUFFIX_LENGTH) { - errx(EX_IOERR, "Unsupported DFU suffix length %d", - file->size.suffix); - } - - if (file->size.suffix > file->size.total) { - errx(EX_IOERR, "Invalid DFU suffix length %d", - file->size.suffix); - } - - file->idVendor = (dfusuffix[5] << 8) + dfusuffix[4]; - file->idProduct = (dfusuffix[3] << 8) + dfusuffix[2]; - file->bcdDevice = (dfusuffix[1] << 8) + dfusuffix[0]; - -checked: - if (missing_suffix) { - if (check_suffix == NEEDS_SUFFIX) { - warnx("%s", reason); - errx(EX_IOERR, "Valid DFU suffix needed"); - } else if (check_suffix == MAYBE_SUFFIX) { - warnx("%s", reason); - warnx("A valid DFU suffix will be required in " - "a future dfu-util release!!!"); - } - } else { - if (check_suffix == NO_SUFFIX) { - errx(EX_SOFTWARE, "Please remove existing DFU suffix before adding a new one.\n"); - } - } - } - res = probe_prefix(file); - if ((res || file->size.prefix == 0) && check_prefix == NEEDS_PREFIX) - errx(EX_IOERR, "Valid DFU prefix needed"); - if (file->size.prefix && check_prefix == NO_PREFIX) - errx(EX_IOERR, "A prefix already exists, please delete it first"); - if (file->size.prefix && verbose) { - uint8_t *data = file->firmware; - if (file->prefix_type == LMDFU_PREFIX) - printf("Possible TI Stellaris DFU prefix with " - "the following properties\n" - "Address: 0x%08x\n" - "Payload length: %d\n", - file->lmdfu_address, - data[4] | (data[5] << 8) | - (data[6] << 16) | (data[7] << 14)); - else if (file->prefix_type == LPCDFU_UNENCRYPTED_PREFIX) - printf("Possible unencrypted NXP LPC DFU prefix with " - "the following properties\n" - "Payload length: %d kiByte\n", - data[2] >>1 | (data[3] << 7) ); - else - errx(EX_IOERR, "Unknown DFU prefix type"); - } -} - -void dfu_store_file(struct dfu_file *file, int write_suffix, int write_prefix) -{ - uint32_t crc = 0xffffffff; - int f; - - f = open(file->name, O_WRONLY | O_BINARY | O_TRUNC | O_CREAT, 0666); - if (f < 0) - err(EX_IOERR, "Could not open file %s for writing", file->name); - - /* write prefix, if any */ - if (write_prefix) { - if (file->prefix_type == LMDFU_PREFIX) { - uint8_t lmdfu_prefix[LMDFU_PREFIX_LENGTH]; - uint32_t addr = file->lmdfu_address / 1024; - - /* lmdfu_dfu_prefix payload length excludes prefix and suffix */ - uint32_t len = file->size.total - - file->size.prefix - file->size.suffix; - - lmdfu_prefix[0] = 0x01; /* STELLARIS_DFU_PROG */ - lmdfu_prefix[1] = 0x00; /* Reserved */ - lmdfu_prefix[2] = (uint8_t)(addr & 0xff); - lmdfu_prefix[3] = (uint8_t)(addr >> 8); - lmdfu_prefix[4] = (uint8_t)(len & 0xff); - lmdfu_prefix[5] = (uint8_t)(len >> 8) & 0xff; - lmdfu_prefix[6] = (uint8_t)(len >> 16) & 0xff; - lmdfu_prefix[7] = (uint8_t)(len >> 24); - - crc = dfu_file_write_crc(f, crc, lmdfu_prefix, LMDFU_PREFIX_LENGTH); - } - if (file->prefix_type == LPCDFU_UNENCRYPTED_PREFIX) { - uint8_t lpcdfu_prefix[LPCDFU_PREFIX_LENGTH] = {0}; - int i; - - /* Payload is firmware and prefix rounded to 512 bytes */ - uint32_t len = (file->size.total - file->size.suffix + 511) /512; - - lpcdfu_prefix[0] = 0x1a; /* Unencypted*/ - lpcdfu_prefix[1] = 0x3f; /* Reserved */ - lpcdfu_prefix[2] = (uint8_t)(len & 0xff); - lpcdfu_prefix[3] = (uint8_t)((len >> 8) & 0xff); - for (i = 12; i < LPCDFU_PREFIX_LENGTH; i++) - lpcdfu_prefix[i] = 0xff; - - crc = dfu_file_write_crc(f, crc, lpcdfu_prefix, LPCDFU_PREFIX_LENGTH); - } - } - /* write firmware binary */ - crc = dfu_file_write_crc(f, crc, file->firmware + file->size.prefix, - file->size.total - file->size.prefix - file->size.suffix); - - /* write suffix, if any */ - if (write_suffix) { - uint8_t dfusuffix[DFU_SUFFIX_LENGTH]; - - dfusuffix[0] = file->bcdDevice & 0xff; - dfusuffix[1] = file->bcdDevice >> 8; - dfusuffix[2] = file->idProduct & 0xff; - dfusuffix[3] = file->idProduct >> 8; - dfusuffix[4] = file->idVendor & 0xff; - dfusuffix[5] = file->idVendor >> 8; - dfusuffix[6] = file->bcdDFU & 0xff; - dfusuffix[7] = file->bcdDFU >> 8; - dfusuffix[8] = 'U'; - dfusuffix[9] = 'F'; - dfusuffix[10] = 'D'; - dfusuffix[11] = DFU_SUFFIX_LENGTH; - - crc = dfu_file_write_crc(f, crc, dfusuffix, - DFU_SUFFIX_LENGTH - 4); - - dfusuffix[12] = crc; - dfusuffix[13] = crc >> 8; - dfusuffix[14] = crc >> 16; - dfusuffix[15] = crc >> 24; - - crc = dfu_file_write_crc(f, crc, dfusuffix + 12, 4); - } - close(f); -} - -void show_suffix_and_prefix(struct dfu_file *file) -{ - if (file->size.prefix == LMDFU_PREFIX_LENGTH) { - printf("The file %s contains a TI Stellaris DFU prefix with the following properties:\n", file->name); - printf("Address:\t0x%08x\n", file->lmdfu_address); - } else if (file->size.prefix == LPCDFU_PREFIX_LENGTH) { - uint8_t * prefix = file->firmware; - printf("The file %s contains a NXP unencrypted LPC DFU prefix with the following properties:\n", file->name); - printf("Size:\t%5d kiB\n", prefix[2]>>1|prefix[3]<<7); - } else if (file->size.prefix != 0) { - printf("The file %s contains an unknown prefix\n", file->name); - } - if (file->size.suffix > 0) { - printf("The file %s contains a DFU suffix with the following properties:\n", file->name); - printf("BCD device:\t0x%04X\n", file->bcdDevice); - printf("Product ID:\t0x%04X\n",file->idProduct); - printf("Vendor ID:\t0x%04X\n", file->idVendor); - printf("BCD DFU:\t0x%04X\n", file->bcdDFU); - printf("Length:\t\t%i\n", file->size.suffix); - printf("CRC:\t\t0x%08X\n", file->dwCRC); - } -} diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_file.h b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_file.h deleted file mode 100755 index abebd44f4..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_file.h +++ /dev/null @@ -1,60 +0,0 @@ - -#ifndef DFU_FILE_H -#define DFU_FILE_H - -#include - -struct dfu_file { - /* File name */ - const char *name; - /* Pointer to file loaded into memory */ - uint8_t *firmware; - /* Different sizes */ - struct { - int total; - int prefix; - int suffix; - } size; - /* From prefix fields */ - uint32_t lmdfu_address; - /* From prefix fields */ - uint32_t prefix_type; - - /* From DFU suffix fields */ - uint32_t dwCRC; - uint16_t bcdDFU; - uint16_t idVendor; - uint16_t idProduct; - uint16_t bcdDevice; -}; - -enum suffix_req { - NO_SUFFIX, - NEEDS_SUFFIX, - MAYBE_SUFFIX -}; - -enum prefix_req { - NO_PREFIX, - NEEDS_PREFIX, - MAYBE_PREFIX -}; - -enum prefix_type { - ZERO_PREFIX, - LMDFU_PREFIX, - LPCDFU_UNENCRYPTED_PREFIX -}; - -extern int verbose; - -void dfu_load_file(struct dfu_file *file, enum suffix_req check_suffix, enum prefix_req check_prefix); -void dfu_store_file(struct dfu_file *file, int write_suffix, int write_prefix); - -void dfu_progress_bar(const char *desc, unsigned long long curr, - unsigned long long max); -void *dfu_malloc(size_t size); -uint32_t dfu_file_write_crc(int f, uint32_t crc, const void *buf, int size); -void show_suffix_and_prefix(struct dfu_file *file); - -#endif /* DFU_FILE_H */ diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_load.c b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_load.c deleted file mode 100755 index 64f7009df..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_load.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * DFU transfer routines - * - * This is supposed to be a general DFU implementation, as specified in the - * USB DFU 1.0 and 1.1 specification. - * - * The code was originally intended to interface with a USB device running the - * "sam7dfu" firmware (see http://www.openpcd.org/) on an AT91SAM7 processor. - * - * Copyright 2007-2008 Harald Welte - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "quirks.h" - -int dfuload_do_upload(struct dfu_if *dif, int xfer_size, - int expected_size, int fd) -{ - int total_bytes = 0; - unsigned short transaction = 0; - unsigned char *buf; - int ret; - - buf = dfu_malloc(xfer_size); - - printf("Copying data from DFU device to PC\n"); - dfu_progress_bar("Upload", 0, 1); - - while (1) { - int rc; - rc = dfu_upload(dif->dev_handle, dif->interface, - xfer_size, transaction++, buf); - if (rc < 0) { - warnx("Error during upload"); - ret = rc; - goto out_free; - } - - dfu_file_write_crc(fd, 0, buf, rc); - total_bytes += rc; - - if (total_bytes < 0) - errx(EX_SOFTWARE, "Received too many bytes (wraparound)"); - - if (rc < xfer_size) { - /* last block, return */ - ret = total_bytes; - break; - } - dfu_progress_bar("Upload", total_bytes, expected_size); - } - ret = 0; - -out_free: - dfu_progress_bar("Upload", total_bytes, total_bytes); - if (total_bytes == 0) - printf("\nFailed.\n"); - free(buf); - if (verbose) - printf("Received a total of %i bytes\n", total_bytes); - if (expected_size != 0 && total_bytes != expected_size) - errx(EX_SOFTWARE, "Unexpected number of bytes uploaded from device"); - return ret; -} - -int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file) -{ - int bytes_sent; - int expected_size; - unsigned char *buf; - unsigned short transaction = 0; - struct dfu_status dst; - int ret; - - printf("Copying data from PC to DFU device\n"); - - buf = file->firmware; - expected_size = file->size.total - file->size.suffix; - bytes_sent = 0; - - dfu_progress_bar("Download", 0, 1); - while (bytes_sent < expected_size) { - int bytes_left; - int chunk_size; - - bytes_left = expected_size - bytes_sent; - if (bytes_left < xfer_size) - chunk_size = bytes_left; - else - chunk_size = xfer_size; - - ret = dfu_download(dif->dev_handle, dif->interface, - chunk_size, transaction++, chunk_size ? buf : NULL); - if (ret < 0) { - warnx("Error during download"); - goto out; - } - bytes_sent += chunk_size; - buf += chunk_size; - - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during download get_status"); - goto out; - } - - if (dst.bState == DFU_STATE_dfuDNLOAD_IDLE || - dst.bState == DFU_STATE_dfuERROR) - break; - - /* Wait while device executes flashing */ - milli_sleep(dst.bwPollTimeout); - - } while (1); - if (dst.bStatus != DFU_STATUS_OK) { - printf(" failed!\n"); - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - ret = -1; - goto out; - } - dfu_progress_bar("Download", bytes_sent, bytes_sent + bytes_left); - } - - /* send one zero sized download request to signalize end */ - ret = dfu_download(dif->dev_handle, dif->interface, - 0, transaction, NULL); - if (ret < 0) { - errx(EX_IOERR, "Error sending completion packet"); - goto out; - } - - dfu_progress_bar("Download", bytes_sent, bytes_sent); - - if (verbose) - printf("Sent a total of %i bytes\n", bytes_sent); - -get_status: - /* Transition to MANIFEST_SYNC state */ - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - warnx("unable to read DFU status after completion"); - goto out; - } - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - - milli_sleep(dst.bwPollTimeout); - - /* FIXME: deal correctly with ManifestationTolerant=0 / WillDetach bits */ - switch (dst.bState) { - case DFU_STATE_dfuMANIFEST_SYNC: - case DFU_STATE_dfuMANIFEST: - /* some devices (e.g. TAS1020b) need some time before we - * can obtain the status */ - milli_sleep(1000); - goto get_status; - break; - case DFU_STATE_dfuIDLE: - break; - } - printf("Done!\n"); - -out: - return bytes_sent; -} diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_load.h b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_load.h deleted file mode 100755 index be23e9b4f..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_load.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef DFU_LOAD_H -#define DFU_LOAD_H - -int dfuload_do_upload(struct dfu_if *dif, int xfer_size, int expected_size, int fd); -int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file); - -#endif /* DFU_LOAD_H */ diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_util.c b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_util.c deleted file mode 100755 index b94c7ccd3..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_util.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Functions for detecting DFU USB entities - * - * Written by Harald Welte - * Copyright 2007-2008 by OpenMoko, Inc. - * Copyright 2013 Hans Petter Selasky - * - * Based on existing code of dfu-programmer-0.4 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "dfu_util.h" -#include "dfuse.h" -#include "quirks.h" - -#ifdef HAVE_USBPATH_H -#include -#endif - -/* - * Look for a descriptor in a concatenated descriptor list. Will - * return upon the first match of the given descriptor type. Returns length of - * found descriptor, limited to res_size - */ -static int find_descriptor(const uint8_t *desc_list, int list_len, - uint8_t desc_type, void *res_buf, int res_size) -{ - int p = 0; - - if (list_len < 2) - return (-1); - - while (p + 1 < list_len) { - int desclen; - - desclen = (int) desc_list[p]; - if (desclen == 0) { - warnx("Invalid descriptor list"); - return -1; - } - if (desc_list[p + 1] == desc_type) { - if (desclen > res_size) - desclen = res_size; - if (p + desclen > list_len) - desclen = list_len - p; - memcpy(res_buf, &desc_list[p], desclen); - return desclen; - } - p += (int) desc_list[p]; - } - return -1; -} - -static void probe_configuration(libusb_device *dev, struct libusb_device_descriptor *desc) -{ - struct usb_dfu_func_descriptor func_dfu; - libusb_device_handle *devh; - struct dfu_if *pdfu; - struct libusb_config_descriptor *cfg; - const struct libusb_interface_descriptor *intf; - const struct libusb_interface *uif; - char alt_name[MAX_DESC_STR_LEN + 1]; - char serial_name[MAX_DESC_STR_LEN + 1]; - int cfg_idx; - int intf_idx; - int alt_idx; - int ret; - int has_dfu; - - for (cfg_idx = 0; cfg_idx != desc->bNumConfigurations; cfg_idx++) { - memset(&func_dfu, 0, sizeof(func_dfu)); - has_dfu = 0; - - ret = libusb_get_config_descriptor(dev, cfg_idx, &cfg); - if (ret != 0) - return; - if (match_config_index > -1 && match_config_index != cfg->bConfigurationValue) { - libusb_free_config_descriptor(cfg); - continue; - } - - /* - * In some cases, noticably FreeBSD if uid != 0, - * the configuration descriptors are empty - */ - if (!cfg) - return; - - ret = find_descriptor(cfg->extra, cfg->extra_length, - USB_DT_DFU, &func_dfu, sizeof(func_dfu)); - if (ret > -1) - goto found_dfu; - - for (intf_idx = 0; intf_idx < cfg->bNumInterfaces; - intf_idx++) { - uif = &cfg->interface[intf_idx]; - if (!uif) - break; - - for (alt_idx = 0; alt_idx < cfg->interface[intf_idx].num_altsetting; - alt_idx++) { - intf = &uif->altsetting[alt_idx]; - - ret = find_descriptor(intf->extra, intf->extra_length, USB_DT_DFU, - &func_dfu, sizeof(func_dfu)); - if (ret > -1) - goto found_dfu; - - if (intf->bInterfaceClass != 0xfe || - intf->bInterfaceSubClass != 1) - continue; - - has_dfu = 1; - } - } - if (has_dfu) { - /* - * Finally try to retrieve it requesting the - * device directly This is not supported on - * all devices for non-standard types - */ - if (libusb_open(dev, &devh) == 0) { - ret = libusb_get_descriptor(devh, USB_DT_DFU, 0, - (void *)&func_dfu, sizeof(func_dfu)); - libusb_close(devh); - if (ret > -1) - goto found_dfu; - } - warnx("Device has DFU interface, " - "but has no DFU functional descriptor"); - - /* fake version 1.0 */ - func_dfu.bLength = 7; - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - goto found_dfu; - } - libusb_free_config_descriptor(cfg); - continue; - -found_dfu: - if (func_dfu.bLength == 7) { - printf("Deducing device DFU version from functional descriptor " - "length\n"); - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - } else if (func_dfu.bLength < 9) { - printf("Error obtaining DFU functional descriptor\n"); - printf("Please report this as a bug!\n"); - printf("Warning: Assuming DFU version 1.0\n"); - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - printf("Warning: Transfer size can not be detected\n"); - func_dfu.wTransferSize = 0; - } - - for (intf_idx = 0; intf_idx < cfg->bNumInterfaces; - intf_idx++) { - if (match_iface_index > -1 && match_iface_index != intf_idx) - continue; - - uif = &cfg->interface[intf_idx]; - if (!uif) - break; - - for (alt_idx = 0; - alt_idx < uif->num_altsetting; alt_idx++) { - int dfu_mode; - - intf = &uif->altsetting[alt_idx]; - - if (intf->bInterfaceClass != 0xfe || - intf->bInterfaceSubClass != 1) - continue; - - dfu_mode = (intf->bInterfaceProtocol == 2); - /* e.g. DSO Nano has bInterfaceProtocol 0 instead of 2 */ - if (func_dfu.bcdDFUVersion == 0x011a && intf->bInterfaceProtocol == 0) - dfu_mode = 1; - - if (dfu_mode && - match_iface_alt_index > -1 && match_iface_alt_index != alt_idx) - continue; - - if (dfu_mode) { - if ((match_vendor_dfu >= 0 && match_vendor_dfu != desc->idVendor) || - (match_product_dfu >= 0 && match_product_dfu != desc->idProduct)) { - continue; - } - } else { - if ((match_vendor >= 0 && match_vendor != desc->idVendor) || - (match_product >= 0 && match_product != desc->idProduct)) { - continue; - } - } - - if (libusb_open(dev, &devh)) { - warnx("Cannot open DFU device %04x:%04x", desc->idVendor, desc->idProduct); - break; - } - if (intf->iInterface != 0) - ret = libusb_get_string_descriptor_ascii(devh, - intf->iInterface, (void *)alt_name, MAX_DESC_STR_LEN); - else - ret = -1; - if (ret < 1) - strcpy(alt_name, "UNKNOWN"); - if (desc->iSerialNumber != 0) - ret = libusb_get_string_descriptor_ascii(devh, - desc->iSerialNumber, (void *)serial_name, MAX_DESC_STR_LEN); - else - ret = -1; - if (ret < 1) - strcpy(serial_name, "UNKNOWN"); - libusb_close(devh); - - if (dfu_mode && - match_iface_alt_name != NULL && strcmp(alt_name, match_iface_alt_name)) - continue; - - if (dfu_mode) { - if (match_serial_dfu != NULL && strcmp(match_serial_dfu, serial_name)) - continue; - } else { - if (match_serial != NULL && strcmp(match_serial, serial_name)) - continue; - } - - pdfu = dfu_malloc(sizeof(*pdfu)); - - memset(pdfu, 0, sizeof(*pdfu)); - - pdfu->func_dfu = func_dfu; - pdfu->dev = libusb_ref_device(dev); - pdfu->quirks = get_quirks(desc->idVendor, - desc->idProduct, desc->bcdDevice); - pdfu->vendor = desc->idVendor; - pdfu->product = desc->idProduct; - pdfu->bcdDevice = desc->bcdDevice; - pdfu->configuration = cfg->bConfigurationValue; - pdfu->interface = intf->bInterfaceNumber; - pdfu->altsetting = intf->bAlternateSetting; - pdfu->devnum = libusb_get_device_address(dev); - pdfu->busnum = libusb_get_bus_number(dev); - pdfu->alt_name = strdup(alt_name); - if (pdfu->alt_name == NULL) - errx(EX_SOFTWARE, "Out of memory"); - pdfu->serial_name = strdup(serial_name); - if (pdfu->serial_name == NULL) - errx(EX_SOFTWARE, "Out of memory"); - if (dfu_mode) - pdfu->flags |= DFU_IFF_DFU; - if (pdfu->quirks & QUIRK_FORCE_DFU11) { - pdfu->func_dfu.bcdDFUVersion = - libusb_cpu_to_le16(0x0110); - } - pdfu->bMaxPacketSize0 = desc->bMaxPacketSize0; - - /* queue into list */ - pdfu->next = dfu_root; - dfu_root = pdfu; - } - } - libusb_free_config_descriptor(cfg); - } -} - -void probe_devices(libusb_context *ctx) -{ - libusb_device **list; - ssize_t num_devs; - ssize_t i; - - num_devs = libusb_get_device_list(ctx, &list); - for (i = 0; i < num_devs; ++i) { - struct libusb_device_descriptor desc; - struct libusb_device *dev = list[i]; - - if (match_bus > -1 && match_bus != libusb_get_bus_number(dev)) - continue; - if (match_device > -1 && match_device != libusb_get_device_address(dev)) - continue; - if (libusb_get_device_descriptor(dev, &desc)) - continue; - probe_configuration(dev, &desc); - } - libusb_free_device_list(list, 0); -} - -void disconnect_devices(void) -{ - struct dfu_if *pdfu; - struct dfu_if *prev = NULL; - - for (pdfu = dfu_root; pdfu != NULL; pdfu = pdfu->next) { - free(prev); - libusb_unref_device(pdfu->dev); - free(pdfu->alt_name); - free(pdfu->serial_name); - prev = pdfu; - } - free(prev); - dfu_root = NULL; -} - -void print_dfu_if(struct dfu_if *dfu_if) -{ - printf("Found %s: [%04x:%04x] ver=%04x, devnum=%u, cfg=%u, intf=%u, " - "alt=%u, name=\"%s\", serial=\"%s\"\n", - dfu_if->flags & DFU_IFF_DFU ? "DFU" : "Runtime", - dfu_if->vendor, dfu_if->product, - dfu_if->bcdDevice, dfu_if->devnum, - dfu_if->configuration, dfu_if->interface, - dfu_if->altsetting, dfu_if->alt_name, - dfu_if->serial_name); -} - -/* Walk the device tree and print out DFU devices */ -void list_dfu_interfaces(void) -{ - struct dfu_if *pdfu; - - for (pdfu = dfu_root; pdfu != NULL; pdfu = pdfu->next) - print_dfu_if(pdfu); -} diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_util.h b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_util.h deleted file mode 100755 index fc0c19dca..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfu_util.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef DFU_UTIL_H -#define DFU_UTIL_H - -/* USB string descriptor should contain max 126 UTF-16 characters - * but 253 would even accomodate any UTF-8 encoding */ -#define MAX_DESC_STR_LEN 253 - -enum mode { - MODE_NONE, - MODE_VERSION, - MODE_LIST, - MODE_DETACH, - MODE_UPLOAD, - MODE_DOWNLOAD -}; - -extern struct dfu_if *dfu_root; -extern int match_bus; -extern int match_device; -extern int match_vendor; -extern int match_product; -extern int match_vendor_dfu; -extern int match_product_dfu; -extern int match_config_index; -extern int match_iface_index; -extern int match_iface_alt_index; -extern const char *match_iface_alt_name; -extern const char *match_serial; -extern const char *match_serial_dfu; - -void probe_devices(libusb_context *); -void disconnect_devices(void); -void print_dfu_if(struct dfu_if *); -void list_dfu_interfaces(void); - -#endif /* DFU_UTIL_H */ diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse.c b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse.c deleted file mode 100755 index fce29fed6..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse.c +++ /dev/null @@ -1,652 +0,0 @@ -/* - * DfuSe specific functions - * - * This implements the ST Microsystems DFU extensions (DfuSe) - * as per the DfuSe 1.1a specification (ST documents AN3156, AN2606) - * The DfuSe file format is described in ST document UM0391. - * - * Copyright 2010-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfuse.h" -#include "dfuse_mem.h" - -#define DFU_TIMEOUT 5000 - -extern int verbose; -static unsigned int last_erased_page = 1; /* non-aligned value, won't match */ -static struct memsegment *mem_layout; -static unsigned int dfuse_address = 0; -static unsigned int dfuse_length = 0; -static int dfuse_force = 0; -static int dfuse_leave = 0; -static int dfuse_unprotect = 0; -static int dfuse_mass_erase = 0; - -unsigned int quad2uint(unsigned char *p) -{ - return (*p + (*(p + 1) << 8) + (*(p + 2) << 16) + (*(p + 3) << 24)); -} - -void dfuse_parse_options(const char *options) -{ - char *end; - const char *endword; - unsigned int number; - - /* address, possibly empty, must be first */ - if (*options != ':') { - endword = strchr(options, ':'); - if (!endword) - endword = options + strlen(options); /* GNU strchrnul */ - - number = strtoul(options, &end, 0); - if (end == endword) { - dfuse_address = number; - } else { - errx(EX_IOERR, "Invalid dfuse address: %s", options); - } - options = endword; - } - - while (*options) { - if (*options == ':') { - options++; - continue; - } - endword = strchr(options, ':'); - if (!endword) - endword = options + strlen(options); - - if (!strncmp(options, "force", endword - options)) { - dfuse_force++; - options += 5; - continue; - } - if (!strncmp(options, "leave", endword - options)) { - dfuse_leave = 1; - options += 5; - continue; - } - if (!strncmp(options, "unprotect", endword - options)) { - dfuse_unprotect = 1; - options += 9; - continue; - } - if (!strncmp(options, "mass-erase", endword - options)) { - dfuse_mass_erase = 1; - options += 10; - continue; - } - - /* any valid number is interpreted as upload length */ - number = strtoul(options, &end, 0); - if (end == endword) { - dfuse_length = number; - } else { - errx(EX_IOERR, "Invalid dfuse modifier: %s", options); - } - options = endword; - } -} - -/* DFU_UPLOAD request for DfuSe 1.1a */ -int dfuse_upload(struct dfu_if *dif, const unsigned short length, - unsigned char *data, unsigned short transaction) -{ - int status; - - status = libusb_control_transfer(dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | - LIBUSB_REQUEST_TYPE_CLASS | - LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_UPLOAD, - /* wValue */ transaction, - /* wIndex */ dif->interface, - /* Data */ data, - /* wLength */ length, - DFU_TIMEOUT); - if (status < 0) { - errx(EX_IOERR, "%s: libusb_control_msg returned %d", - __FUNCTION__, status); - } - return status; -} - -/* DFU_DNLOAD request for DfuSe 1.1a */ -int dfuse_download(struct dfu_if *dif, const unsigned short length, - unsigned char *data, unsigned short transaction) -{ - int status; - - status = libusb_control_transfer(dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | - LIBUSB_REQUEST_TYPE_CLASS | - LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DNLOAD, - /* wValue */ transaction, - /* wIndex */ dif->interface, - /* Data */ data, - /* wLength */ length, - DFU_TIMEOUT); - if (status < 0) { - errx(EX_IOERR, "%s: libusb_control_transfer returned %d", - __FUNCTION__, status); - } - return status; -} - -/* DfuSe only commands */ -/* Leaves the device in dfuDNLOAD-IDLE state */ -int dfuse_special_command(struct dfu_if *dif, unsigned int address, - enum dfuse_command command) -{ - const char* dfuse_command_name[] = { "SET_ADDRESS" , "ERASE_PAGE", - "MASS_ERASE", "READ_UNPROTECT"}; - unsigned char buf[5]; - int length; - int ret; - struct dfu_status dst; - int firstpoll = 1; - - if (command == ERASE_PAGE) { - struct memsegment *segment; - int page_size; - - segment = find_segment(mem_layout, address); - if (!segment || !(segment->memtype & DFUSE_ERASABLE)) { - errx(EX_IOERR, "Page at 0x%08x can not be erased", - address); - } - page_size = segment->pagesize; - if (verbose > 1) - printf("Erasing page size %i at address 0x%08x, page " - "starting at 0x%08x\n", page_size, address, - address & ~(page_size - 1)); - buf[0] = 0x41; /* Erase command */ - length = 5; - last_erased_page = address & ~(page_size - 1); - } else if (command == SET_ADDRESS) { - if (verbose > 2) - printf(" Setting address pointer to 0x%08x\n", - address); - buf[0] = 0x21; /* Set Address Pointer command */ - length = 5; - } else if (command == MASS_ERASE) { - buf[0] = 0x41; /* Mass erase command when length = 1 */ - length = 1; - } else if (command == READ_UNPROTECT) { - buf[0] = 0x92; - length = 1; - } else { - errx(EX_IOERR, "Non-supported special command %d", command); - } - buf[1] = address & 0xff; - buf[2] = (address >> 8) & 0xff; - buf[3] = (address >> 16) & 0xff; - buf[4] = (address >> 24) & 0xff; - - ret = dfuse_download(dif, length, buf, 0); - if (ret < 0) { - errx(EX_IOERR, "Error during special command \"%s\" download", - dfuse_command_name[command]); - } - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during special command \"%s\" get_status", - dfuse_command_name[command]); - } - if (firstpoll) { - firstpoll = 0; - if (dst.bState != DFU_STATE_dfuDNBUSY) { - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - errx(EX_IOERR, "Wrong state after command \"%s\" download", - dfuse_command_name[command]); - } - } - /* wait while command is executed */ - if (verbose) - printf(" Poll timeout %i ms\n", dst.bwPollTimeout); - milli_sleep(dst.bwPollTimeout); - if (command == READ_UNPROTECT) - return ret; - } while (dst.bState == DFU_STATE_dfuDNBUSY); - - if (dst.bStatus != DFU_STATUS_OK) { - errx(EX_IOERR, "%s not correctly executed", - dfuse_command_name[command]); - } - return ret; -} - -int dfuse_dnload_chunk(struct dfu_if *dif, unsigned char *data, int size, - int transaction) -{ - int bytes_sent; - struct dfu_status dst; - int ret; - - ret = dfuse_download(dif, size, size ? data : NULL, transaction); - if (ret < 0) { - errx(EX_IOERR, "Error during download"); - return ret; - } - bytes_sent = ret; - - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during download get_status"); - return ret; - } - milli_sleep(dst.bwPollTimeout); - } while (dst.bState != DFU_STATE_dfuDNLOAD_IDLE && - dst.bState != DFU_STATE_dfuERROR && - dst.bState != DFU_STATE_dfuMANIFEST); - - if (dst.bState == DFU_STATE_dfuMANIFEST) - printf("Transitioning to dfuMANIFEST state\n"); - - if (dst.bStatus != DFU_STATUS_OK) { - printf(" failed!\n"); - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - return -1; - } - return bytes_sent; -} - -int dfuse_do_upload(struct dfu_if *dif, int xfer_size, int fd, - const char *dfuse_options) -{ - int total_bytes = 0; - int upload_limit = 0; - unsigned char *buf; - int transaction; - int ret; - - buf = dfu_malloc(xfer_size); - - if (dfuse_options) - dfuse_parse_options(dfuse_options); - if (dfuse_length) - upload_limit = dfuse_length; - if (dfuse_address) { - struct memsegment *segment; - - mem_layout = parse_memory_layout((char *)dif->alt_name); - if (!mem_layout) - errx(EX_IOERR, "Failed to parse memory layout"); - - segment = find_segment(mem_layout, dfuse_address); - if (!dfuse_force && - (!segment || !(segment->memtype & DFUSE_READABLE))) - errx(EX_IOERR, "Page at 0x%08x is not readable", - dfuse_address); - - if (!upload_limit) { - upload_limit = segment->end - dfuse_address + 1; - printf("Limiting upload to end of memory segment, " - "%i bytes\n", upload_limit); - } - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfu_abort_to_idle(dif); - } else { - /* Boot loader decides the start address, unknown to us */ - /* Use a short length to lower risk of running out of bounds */ - if (!upload_limit) - upload_limit = 0x4000; - printf("Limiting default upload to %i bytes\n", upload_limit); - } - - dfu_progress_bar("Upload", 0, 1); - - transaction = 2; - while (1) { - int rc; - - /* last chunk can be smaller than original xfer_size */ - if (upload_limit - total_bytes < xfer_size) - xfer_size = upload_limit - total_bytes; - rc = dfuse_upload(dif, xfer_size, buf, transaction++); - if (rc < 0) { - ret = rc; - goto out_free; - } - - dfu_file_write_crc(fd, 0, buf, rc); - total_bytes += rc; - - if (total_bytes < 0) - errx(EX_SOFTWARE, "Received too many bytes"); - - if (rc < xfer_size || total_bytes >= upload_limit) { - /* last block, return successfully */ - ret = total_bytes; - break; - } - dfu_progress_bar("Upload", total_bytes, upload_limit); - } - - dfu_progress_bar("Upload", total_bytes, total_bytes); - - dfu_abort_to_idle(dif); - if (dfuse_leave) { - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfuse_dnload_chunk(dif, NULL, 0, 2); /* Zero-size */ - } - - out_free: - free(buf); - - return ret; -} - -/* Writes an element of any size to the device, taking care of page erases */ -/* returns 0 on success, otherwise -EINVAL */ -int dfuse_dnload_element(struct dfu_if *dif, unsigned int dwElementAddress, - unsigned int dwElementSize, unsigned char *data, - int xfer_size) -{ - int p; - int ret; - struct memsegment *segment; - - /* Check at least that we can write to the last address */ - segment = - find_segment(mem_layout, dwElementAddress + dwElementSize - 1); - if (!segment || !(segment->memtype & DFUSE_WRITEABLE)) { - errx(EX_IOERR, "Last page at 0x%08x is not writeable", - dwElementAddress + dwElementSize - 1); - } - - dfu_progress_bar("Download", 0, 1); - - for (p = 0; p < (int)dwElementSize; p += xfer_size) { - int page_size; - unsigned int erase_address; - unsigned int address = dwElementAddress + p; - int chunk_size = xfer_size; - - segment = find_segment(mem_layout, address); - if (!segment || !(segment->memtype & DFUSE_WRITEABLE)) { - errx(EX_IOERR, "Page at 0x%08x is not writeable", - address); - } - page_size = segment->pagesize; - - /* check if this is the last chunk */ - if (p + chunk_size > (int)dwElementSize) - chunk_size = dwElementSize - p; - - /* Erase only for flash memory downloads */ - if ((segment->memtype & DFUSE_ERASABLE) && !dfuse_mass_erase) { - /* erase all involved pages */ - for (erase_address = address; - erase_address < address + chunk_size; - erase_address += page_size) - if ((erase_address & ~(page_size - 1)) != - last_erased_page) - dfuse_special_command(dif, - erase_address, - ERASE_PAGE); - - if (((address + chunk_size - 1) & ~(page_size - 1)) != - last_erased_page) { - if (verbose > 2) - printf(" Chunk extends into next page," - " erase it as well\n"); - dfuse_special_command(dif, - address + chunk_size - 1, - ERASE_PAGE); - } - } - - if (verbose) { - printf(" Download from image offset " - "%08x to memory %08x-%08x, size %i\n", - p, address, address + chunk_size - 1, - chunk_size); - } else { - dfu_progress_bar("Download", p, dwElementSize); - } - - dfuse_special_command(dif, address, SET_ADDRESS); - - /* transaction = 2 for no address offset */ - ret = dfuse_dnload_chunk(dif, data + p, chunk_size, 2); - if (ret != chunk_size) { - errx(EX_IOERR, "Failed to write whole chunk: " - "%i of %i bytes", ret, chunk_size); - return -EINVAL; - } - } - if (!verbose) - dfu_progress_bar("Download", dwElementSize, dwElementSize); - return 0; -} - -static void -dfuse_memcpy(unsigned char *dst, unsigned char **src, int *rem, int size) -{ - if (size > *rem) { - errx(EX_IOERR, "Corrupt DfuSe file: " - "Cannot read %d bytes from %d bytes", size, *rem); - } - if (dst != NULL) - memcpy(dst, *src, size); - (*src) += size; - (*rem) -= size; -} - -/* Download raw binary file to DfuSe device */ -int dfuse_do_bin_dnload(struct dfu_if *dif, int xfer_size, - struct dfu_file *file, unsigned int start_address) -{ - unsigned int dwElementAddress; - unsigned int dwElementSize; - unsigned char *data; - int ret; - - dwElementAddress = start_address; - dwElementSize = file->size.total - - file->size.suffix - file->size.prefix; - - printf("Downloading to address = 0x%08x, size = %i\n", - dwElementAddress, dwElementSize); - - data = file->firmware + file->size.prefix; - - ret = dfuse_dnload_element(dif, dwElementAddress, dwElementSize, data, - xfer_size); - if (ret != 0) - goto out_free; - - printf("File downloaded successfully\n"); - ret = dwElementSize; - - out_free: - return ret; -} - -/* Parse a DfuSe file and download contents to device */ -int dfuse_do_dfuse_dnload(struct dfu_if *dif, int xfer_size, - struct dfu_file *file) -{ - uint8_t dfuprefix[11]; - uint8_t targetprefix[274]; - uint8_t elementheader[8]; - int image; - int element; - int bTargets; - int bAlternateSetting; - int dwNbElements; - unsigned int dwElementAddress; - unsigned int dwElementSize; - uint8_t *data; - int ret; - int rem; - int bFirstAddressSaved = 0; - - rem = file->size.total - file->size.prefix - file->size.suffix; - data = file->firmware + file->size.prefix; - - /* Must be larger than a minimal DfuSe header and suffix */ - if (rem < (int)(sizeof(dfuprefix) + - sizeof(targetprefix) + sizeof(elementheader))) { - errx(EX_SOFTWARE, "File too small for a DfuSe file"); - } - - dfuse_memcpy(dfuprefix, &data, &rem, sizeof(dfuprefix)); - - if (strncmp((char *)dfuprefix, "DfuSe", 5)) { - errx(EX_IOERR, "No valid DfuSe signature"); - return -EINVAL; - } - if (dfuprefix[5] != 0x01) { - errx(EX_IOERR, "DFU format revision %i not supported", - dfuprefix[5]); - return -EINVAL; - } - bTargets = dfuprefix[10]; - printf("file contains %i DFU images\n", bTargets); - - for (image = 1; image <= bTargets; image++) { - printf("parsing DFU image %i\n", image); - dfuse_memcpy(targetprefix, &data, &rem, sizeof(targetprefix)); - if (strncmp((char *)targetprefix, "Target", 6)) { - errx(EX_IOERR, "No valid target signature"); - return -EINVAL; - } - bAlternateSetting = targetprefix[6]; - dwNbElements = quad2uint((unsigned char *)targetprefix + 270); - printf("image for alternate setting %i, ", bAlternateSetting); - printf("(%i elements, ", dwNbElements); - printf("total size = %i)\n", - quad2uint((unsigned char *)targetprefix + 266)); - if (bAlternateSetting != dif->altsetting) - printf("Warning: Image does not match current alternate" - " setting.\n" - "Please rerun with the correct -a option setting" - " to download this image!\n"); - for (element = 1; element <= dwNbElements; element++) { - printf("parsing element %i, ", element); - dfuse_memcpy(elementheader, &data, &rem, sizeof(elementheader)); - dwElementAddress = - quad2uint((unsigned char *)elementheader); - dwElementSize = - quad2uint((unsigned char *)elementheader + 4); - printf("address = 0x%08x, ", dwElementAddress); - printf("size = %i\n", dwElementSize); - - if (!bFirstAddressSaved) { - bFirstAddressSaved = 1; - dfuse_address = dwElementAddress; - } - /* sanity check */ - if ((int)dwElementSize > rem) - errx(EX_SOFTWARE, "File too small for element size"); - - if (bAlternateSetting == dif->altsetting) { - ret = dfuse_dnload_element(dif, dwElementAddress, - dwElementSize, data, xfer_size); - } else { - ret = 0; - } - - /* advance read pointer */ - dfuse_memcpy(NULL, &data, &rem, dwElementSize); - - if (ret != 0) - return ret; - } - } - - if (rem != 0) - warnx("%d bytes leftover", rem); - - printf("done parsing DfuSe file\n"); - - return 0; -} - -int dfuse_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file, - const char *dfuse_options) -{ - int ret; - - if (dfuse_options) - dfuse_parse_options(dfuse_options); - mem_layout = parse_memory_layout((char *)dif->alt_name); - if (!mem_layout) { - errx(EX_IOERR, "Failed to parse memory layout"); - } - if (dfuse_unprotect) { - if (!dfuse_force) { - errx(EX_IOERR, "The read unprotect command " - "will erase the flash memory" - "and can only be used with force\n"); - } - dfuse_special_command(dif, 0, READ_UNPROTECT); - printf("Device disconnects, erases flash and resets now\n"); - exit(0); - } - if (dfuse_mass_erase) { - if (!dfuse_force) { - errx(EX_IOERR, "The mass erase command " - "can only be used with force"); - } - printf("Performing mass erase, this can take a moment\n"); - dfuse_special_command(dif, 0, MASS_ERASE); - } - if (dfuse_address) { - if (file->bcdDFU == 0x11a) { - errx(EX_IOERR, "This is a DfuSe file, not " - "meant for raw download"); - } - ret = dfuse_do_bin_dnload(dif, xfer_size, file, dfuse_address); - } else { - if (file->bcdDFU != 0x11a) { - warnx("Only DfuSe file version 1.1a is supported"); - errx(EX_IOERR, "(for raw binary download, use the " - "--dfuse-address option)"); - } - ret = dfuse_do_dfuse_dnload(dif, xfer_size, file); - } - free_segment_list(mem_layout); - - dfu_abort_to_idle(dif); - - if (dfuse_leave) { - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfuse_dnload_chunk(dif, NULL, 0, 2); /* Zero-size */ - } - return ret; -} diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse.h b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse.h deleted file mode 100755 index ed1108cfc..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse.h +++ /dev/null @@ -1,35 +0,0 @@ -/* This implements the ST Microsystems DFU extensions (DfuSe) - * as per the DfuSe 1.1a specification (Document UM0391) - * - * (C) 2010-2012 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFUSE_H -#define DFUSE_H - -#include "dfu.h" - -enum dfuse_command { SET_ADDRESS, ERASE_PAGE, MASS_ERASE, READ_UNPROTECT }; - -int dfuse_special_command(struct dfu_if *dif, unsigned int address, - enum dfuse_command command); -int dfuse_do_upload(struct dfu_if *dif, int xfer_size, int fd, - const char *dfuse_options); -int dfuse_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file, - const char *dfuse_options); - -#endif /* DFUSE_H */ diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse_mem.c b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse_mem.c deleted file mode 100755 index a91aacf5f..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse_mem.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Helper functions for reading the memory map of a device - * following the ST DfuSe 1.1a specification. - * - * Copyright 2011-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" -#include "dfuse_mem.h" - -int add_segment(struct memsegment **segment_list, struct memsegment segment) -{ - struct memsegment *new_element; - - new_element = dfu_malloc(sizeof(struct memsegment)); - *new_element = segment; - new_element->next = NULL; - - if (*segment_list == NULL) - /* list can be empty on first call */ - *segment_list = new_element; - else { - struct memsegment *next_element; - - /* find last element in list */ - next_element = *segment_list; - while (next_element->next != NULL) - next_element = next_element->next; - next_element->next = new_element; - } - return 0; -} - -struct memsegment *find_segment(struct memsegment *segment_list, - unsigned int address) -{ - while (segment_list != NULL) { - if (segment_list->start <= address && - segment_list->end >= address) - return segment_list; - segment_list = segment_list->next; - } - return NULL; -} - -void free_segment_list(struct memsegment *segment_list) -{ - struct memsegment *next_element; - - while (segment_list->next != NULL) { - next_element = segment_list->next; - free(segment_list); - segment_list = next_element; - } - free(segment_list); -} - -/* Parse memory map from interface descriptor string - * encoded as per ST document UM0424 section 4.3.2. - */ -struct memsegment *parse_memory_layout(char *intf_desc) -{ - - char multiplier, memtype; - unsigned int address; - int sectors, size; - char *name, *typestring; - int ret; - int count = 0; - char separator; - int scanned; - struct memsegment *segment_list = NULL; - struct memsegment segment; - - name = dfu_malloc(strlen(intf_desc)); - - ret = sscanf(intf_desc, "@%[^/]%n", name, &scanned); - if (ret < 1) { - free(name); - warnx("Could not read name, sscanf returned %d", ret); - return NULL; - } - printf("DfuSe interface name: \"%s\"\n", name); - - intf_desc += scanned; - typestring = dfu_malloc(strlen(intf_desc)); - - while (ret = sscanf(intf_desc, "/0x%x/%n", &address, &scanned), - ret > 0) { - - intf_desc += scanned; - while (ret = sscanf(intf_desc, "%d*%d%c%[^,/]%n", - §ors, &size, &multiplier, typestring, - &scanned), ret > 2) { - intf_desc += scanned; - - count++; - memtype = 0; - if (ret == 4) { - if (strlen(typestring) == 1 - && typestring[0] != '/') - memtype = typestring[0]; - else { - warnx("Parsing type identifier '%s' " - "failed for segment %i", - typestring, count); - continue; - } - } - - /* Quirk for STM32F4 devices */ - if (strcmp(name, "Device Feature") == 0) - memtype = 'e'; - - switch (multiplier) { - case 'B': - break; - case 'K': - size *= 1024; - break; - case 'M': - size *= 1024 * 1024; - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - if (!memtype) { - warnx("Non-valid multiplier '%c', " - "interpreted as type " - "identifier instead", - multiplier); - memtype = multiplier; - break; - } - /* fallthrough if memtype was already set */ - default: - warnx("Non-valid multiplier '%c', " - "assuming bytes", multiplier); - } - - if (!memtype) { - warnx("No valid type for segment %d\n", count); - continue; - } - - segment.start = address; - segment.end = address + sectors * size - 1; - segment.pagesize = size; - segment.memtype = memtype & 7; - add_segment(&segment_list, segment); - - if (verbose) - printf("Memory segment at 0x%08x %3d x %4d = " - "%5d (%s%s%s)\n", - address, sectors, size, sectors * size, - memtype & DFUSE_READABLE ? "r" : "", - memtype & DFUSE_ERASABLE ? "e" : "", - memtype & DFUSE_WRITEABLE ? "w" : ""); - - address += sectors * size; - - separator = *intf_desc; - if (separator == ',') - intf_desc += 1; - else - break; - } /* while per segment */ - - } /* while per address */ - free(name); - free(typestring); - - return segment_list; -} diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse_mem.h b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse_mem.h deleted file mode 100755 index 0181f0c16..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/dfuse_mem.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Helper functions for reading the memory map in a device - * following the ST DfuSe 1.1a specification. - * - * (C) 2011 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFUSE_MEM_H -#define DFUSE_MEM_H - -#define DFUSE_READABLE 1 -#define DFUSE_ERASABLE 2 -#define DFUSE_WRITEABLE 4 - -struct memsegment { - unsigned int start; - unsigned int end; - int pagesize; - int memtype; - struct memsegment *next; -}; - -int add_segment(struct memsegment **list, struct memsegment new_element); - -struct memsegment *find_segment(struct memsegment *list, unsigned int address); - -void free_segment_list(struct memsegment *list); - -struct memsegment *parse_memory_layout(char *intf_desc_str); - -#endif /* DFUSE_MEM_H */ diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/main.c b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/main.c deleted file mode 100755 index acaed2f08..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/main.c +++ /dev/null @@ -1,699 +0,0 @@ -/* - * dfu-util - * - * Copyright 2007-2008 by OpenMoko, Inc. - * Copyright 2013-2014 Hans Petter Selasky - * - * Written by Harald Welte - * - * Based on existing code of dfu-programmer-0.4 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "dfu_util.h" -#include "dfuse.h" -#include "quirks.h" - -#ifdef HAVE_USBPATH_H -#include -#endif - -int verbose = 0; - -struct dfu_if *dfu_root = NULL; - -int match_bus = -1; -int match_device = -1; -int match_vendor = -1; -int match_product = -1; -int match_vendor_dfu = -1; -int match_product_dfu = -1; -int match_config_index = -1; -int match_iface_index = -1; -int match_iface_alt_index = -1; -const char *match_iface_alt_name = NULL; -const char *match_serial = NULL; -const char *match_serial_dfu = NULL; - -static int parse_match_value(const char *str, int default_value) -{ - char *remainder; - int value; - - if (str == NULL) { - value = default_value; - } else if (*str == '*') { - value = -1; /* Match anything */ - } else if (*str == '-') { - value = 0x10000; /* Impossible vendor/product ID */ - } else { - value = strtoul(str, &remainder, 16); - if (remainder == str) { - value = default_value; - } - } - return value; -} - -static void parse_vendprod(const char *str) -{ - const char *comma; - const char *colon; - - /* Default to match any DFU device in runtime or DFU mode */ - match_vendor = -1; - match_product = -1; - match_vendor_dfu = -1; - match_product_dfu = -1; - - comma = strchr(str, ','); - if (comma == str) { - /* DFU mode vendor/product being specified without any runtime - * vendor/product specification, so don't match any runtime device */ - match_vendor = match_product = 0x10000; - } else { - colon = strchr(str, ':'); - if (colon != NULL) { - ++colon; - if ((comma != NULL) && (colon > comma)) { - colon = NULL; - } - } - match_vendor = parse_match_value(str, match_vendor); - match_product = parse_match_value(colon, match_product); - if (comma != NULL) { - /* Both runtime and DFU mode vendor/product specifications are - * available, so default DFU mode match components to the given - * runtime match components */ - match_vendor_dfu = match_vendor; - match_product_dfu = match_product; - } - } - if (comma != NULL) { - ++comma; - colon = strchr(comma, ':'); - if (colon != NULL) { - ++colon; - } - match_vendor_dfu = parse_match_value(comma, match_vendor_dfu); - match_product_dfu = parse_match_value(colon, match_product_dfu); - } -} - -static void parse_serial(char *str) -{ - char *comma; - - match_serial = str; - comma = strchr(str, ','); - if (comma == NULL) { - match_serial_dfu = match_serial; - } else { - *comma++ = 0; - match_serial_dfu = comma; - } - if (*match_serial == 0) match_serial = NULL; - if (*match_serial_dfu == 0) match_serial_dfu = NULL; -} - -#ifdef HAVE_USBPATH_H - -static int resolve_device_path(char *path) -{ - int res; - - res = usb_path2devnum(path); - if (res < 0) - return -EINVAL; - if (!res) - return 0; - - match_bus = atoi(path); - match_device = res; - - return 0; -} - -#else /* HAVE_USBPATH_H */ - -static int resolve_device_path(char *path) -{ - (void)path; /* Eliminate unused variable warning */ - errx(EX_SOFTWARE, "USB device paths are not supported by this dfu-util.\n"); -} - -#endif /* !HAVE_USBPATH_H */ - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-util [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -v --verbose\t\t\tPrint verbose debug statements\n" - " -l --list\t\t\tList currently attached DFU capable devices\n"); - fprintf(stderr, " -e --detach\t\t\tDetach currently attached DFU capable devices\n" - " -E --detach-delay seconds\tTime to wait before reopening a device after detach\n" - " -d --device :[,:]\n" - "\t\t\t\tSpecify Vendor/Product ID(s) of DFU device\n" - " -p --path \tSpecify path to DFU device\n" - " -c --cfg \t\tSpecify the Configuration of DFU device\n" - " -i --intf \t\tSpecify the DFU Interface number\n" - " -S --serial [,]\n" - "\t\t\t\tSpecify Serial String of DFU device\n" - " -a --alt \t\tSpecify the Altsetting of the DFU Interface\n" - "\t\t\t\tby name or by number\n"); - fprintf(stderr, " -t --transfer-size \tSpecify the number of bytes per USB Transfer\n" - " -U --upload \t\tRead firmware from device into \n" - " -Z --upload-size \tSpecify the expected upload size in bytes\n" - " -D --download \t\tWrite firmware from into device\n" - " -R --reset\t\t\tIssue USB Reset signalling once we're finished\n" - " -s --dfuse-address

\tST DfuSe mode, specify target address for\n" - "\t\t\t\traw file download or upload. Not applicable for\n" - "\t\t\t\tDfuSe file (.dfu) downloads\n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf(PACKAGE_STRING "\n\n"); - printf("Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.\n" - "Copyright 2010-2014 Tormod Volden and Stefan Schmidt\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to " PACKAGE_BUGREPORT "\n\n"); -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "verbose", 0, 0, 'v' }, - { "list", 0, 0, 'l' }, - { "detach", 0, 0, 'e' }, - { "detach-delay", 1, 0, 'E' }, - { "device", 1, 0, 'd' }, - { "path", 1, 0, 'p' }, - { "configuration", 1, 0, 'c' }, - { "cfg", 1, 0, 'c' }, - { "interface", 1, 0, 'i' }, - { "intf", 1, 0, 'i' }, - { "altsetting", 1, 0, 'a' }, - { "alt", 1, 0, 'a' }, - { "serial", 1, 0, 'S' }, - { "transfer-size", 1, 0, 't' }, - { "upload", 1, 0, 'U' }, - { "upload-size", 1, 0, 'Z' }, - { "download", 1, 0, 'D' }, - { "reset", 0, 0, 'R' }, - { "dfuse-address", 1, 0, 's' }, - { 0, 0, 0, 0 } -}; - -int main(int argc, char **argv) -{ - int expected_size = 0; - unsigned int transfer_size = 0; - enum mode mode = MODE_NONE; - struct dfu_status status; - libusb_context *ctx; - struct dfu_file file; - char *end; - int final_reset = 0; - int ret; - int dfuse_device = 0; - int fd; - const char *dfuse_options = NULL; - int detach_delay = 5; - uint16_t runtime_vendor; - uint16_t runtime_product; - - memset(&file, 0, sizeof(file)); - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVvleE:d:p:c:i:a:S:t:U:D:Rs:Z:", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - mode = MODE_VERSION; - break; - case 'v': - verbose++; - break; - case 'l': - mode = MODE_LIST; - break; - case 'e': - mode = MODE_DETACH; - match_iface_alt_index = 0; - match_iface_index = 0; - break; - case 'E': - detach_delay = atoi(optarg); - break; - case 'd': - parse_vendprod(optarg); - break; - case 'p': - /* Parse device path */ - ret = resolve_device_path(optarg); - if (ret < 0) - errx(EX_SOFTWARE, "Unable to parse '%s'", optarg); - if (!ret) - errx(EX_SOFTWARE, "Cannot find '%s'", optarg); - break; - case 'c': - /* Configuration */ - match_config_index = atoi(optarg); - break; - case 'i': - /* Interface */ - match_iface_index = atoi(optarg); - break; - case 'a': - /* Interface Alternate Setting */ - match_iface_alt_index = strtoul(optarg, &end, 0); - if (*end) { - match_iface_alt_name = optarg; - match_iface_alt_index = -1; - } - break; - case 'S': - parse_serial(optarg); - break; - case 't': - transfer_size = atoi(optarg); - break; - case 'U': - mode = MODE_UPLOAD; - file.name = optarg; - break; - case 'Z': - expected_size = atoi(optarg); - break; - case 'D': - mode = MODE_DOWNLOAD; - file.name = optarg; - break; - case 'R': - final_reset = 1; - break; - case 's': - dfuse_options = optarg; - break; - default: - help(); - break; - } - } - - print_version(); - if (mode == MODE_VERSION) { - exit(0); - } - - if (mode == MODE_NONE) { - fprintf(stderr, "You need to specify one of -D or -U\n"); - help(); - } - - if (match_config_index == 0) { - /* Handle "-c 0" (unconfigured device) as don't care */ - match_config_index = -1; - } - - if (mode == MODE_DOWNLOAD) { - dfu_load_file(&file, MAYBE_SUFFIX, MAYBE_PREFIX); - /* If the user didn't specify product and/or vendor IDs to match, - * use any IDs from the file suffix for device matching */ - if (match_vendor < 0 && file.idVendor != 0xffff) { - match_vendor = file.idVendor; - printf("Match vendor ID from file: %04x\n", match_vendor); - } - if (match_product < 0 && file.idProduct != 0xffff) { - match_product = file.idProduct; - printf("Match product ID from file: %04x\n", match_product); - } - } - - ret = libusb_init(&ctx); - if (ret) - errx(EX_IOERR, "unable to initialize libusb: %i", ret); - - if (verbose > 2) { - libusb_set_debug(ctx, 255); - } - - probe_devices(ctx); - - if (mode == MODE_LIST) { - list_dfu_interfaces(); - exit(0); - } - - if (dfu_root == NULL) { - errx(EX_IOERR, "No DFU capable USB device available"); - } else if (dfu_root->next != NULL) { - /* We cannot safely support more than one DFU capable device - * with same vendor/product ID, since during DFU we need to do - * a USB bus reset, after which the target device will get a - * new address */ - errx(EX_IOERR, "More than one DFU capable USB device found! " - "Try `--list' and specify the serial number " - "or disconnect all but one device\n"); - } - - /* We have exactly one device. Its libusb_device is now in dfu_root->dev */ - - printf("Opening DFU capable USB device...\n"); - ret = libusb_open(dfu_root->dev, &dfu_root->dev_handle); - if (ret || !dfu_root->dev_handle) - errx(EX_IOERR, "Cannot open device"); - - printf("ID %04x:%04x\n", dfu_root->vendor, dfu_root->product); - - printf("Run-time device DFU version %04x\n", - libusb_le16_to_cpu(dfu_root->func_dfu.bcdDFUVersion)); - - /* Transition from run-Time mode to DFU mode */ - if (!(dfu_root->flags & DFU_IFF_DFU)) { - int err; - /* In the 'first round' during runtime mode, there can only be one - * DFU Interface descriptor according to the DFU Spec. */ - - /* FIXME: check if the selected device really has only one */ - - runtime_vendor = dfu_root->vendor; - runtime_product = dfu_root->product; - - printf("Claiming USB DFU Runtime Interface...\n"); - if (libusb_claim_interface(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "Cannot claim interface %d", - dfu_root->interface); - } - - if (libusb_set_interface_alt_setting(dfu_root->dev_handle, dfu_root->interface, 0) < 0) { - errx(EX_IOERR, "Cannot set alt interface zero"); - } - - printf("Determining device status: "); - - err = dfu_get_status(dfu_root, &status); - if (err == LIBUSB_ERROR_PIPE) { - printf("Device does not implement get_status, assuming appIDLE\n"); - status.bStatus = DFU_STATUS_OK; - status.bwPollTimeout = 0; - status.bState = DFU_STATE_appIDLE; - status.iString = 0; - } else if (err < 0) { - errx(EX_IOERR, "error get_status"); - } else { - printf("state = %s, status = %d\n", - dfu_state_to_string(status.bState), status.bStatus); - } - milli_sleep(status.bwPollTimeout); - - switch (status.bState) { - case DFU_STATE_appIDLE: - case DFU_STATE_appDETACH: - printf("Device really in Runtime Mode, send DFU " - "detach request...\n"); - if (dfu_detach(dfu_root->dev_handle, - dfu_root->interface, 1000) < 0) { - warnx("error detaching"); - } - if (dfu_root->func_dfu.bmAttributes & USB_DFU_WILL_DETACH) { - printf("Device will detach and reattach...\n"); - } else { - printf("Resetting USB...\n"); - ret = libusb_reset_device(dfu_root->dev_handle); - if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) - errx(EX_IOERR, "error resetting " - "after detach"); - } - break; - case DFU_STATE_dfuERROR: - printf("dfuERROR, clearing status\n"); - if (dfu_clear_status(dfu_root->dev_handle, - dfu_root->interface) < 0) { - errx(EX_IOERR, "error clear_status"); - } - /* fall through */ - default: - warnx("WARNING: Runtime device already in DFU state ?!?"); - libusb_release_interface(dfu_root->dev_handle, - dfu_root->interface); - goto dfustate; - } - libusb_release_interface(dfu_root->dev_handle, - dfu_root->interface); - libusb_close(dfu_root->dev_handle); - dfu_root->dev_handle = NULL; - - if (mode == MODE_DETACH) { - libusb_exit(ctx); - exit(0); - } - - /* keeping handles open might prevent re-enumeration */ - disconnect_devices(); - - milli_sleep(detach_delay * 1000); - - /* Change match vendor and product to impossible values to force - * only DFU mode matches in the following probe */ - match_vendor = match_product = 0x10000; - - probe_devices(ctx); - - if (dfu_root == NULL) { - errx(EX_IOERR, "Lost device after RESET?"); - } else if (dfu_root->next != NULL) { - errx(EX_IOERR, "More than one DFU capable USB device found! " - "Try `--list' and specify the serial number " - "or disconnect all but one device"); - } - - /* Check for DFU mode device */ - if (!(dfu_root->flags | DFU_IFF_DFU)) - errx(EX_SOFTWARE, "Device is not in DFU mode"); - - printf("Opening DFU USB Device...\n"); - ret = libusb_open(dfu_root->dev, &dfu_root->dev_handle); - if (ret || !dfu_root->dev_handle) { - errx(EX_IOERR, "Cannot open device"); - } - } else { - /* we're already in DFU mode, so we can skip the detach/reset - * procedure */ - /* If a match vendor/product was specified, use that as the runtime - * vendor/product, otherwise use the DFU mode vendor/product */ - runtime_vendor = match_vendor < 0 ? dfu_root->vendor : match_vendor; - runtime_product = match_product < 0 ? dfu_root->product : match_product; - } - -dfustate: -#if 0 - printf("Setting Configuration %u...\n", dfu_root->configuration); - if (libusb_set_configuration(dfu_root->dev_handle, dfu_root->configuration) < 0) { - errx(EX_IOERR, "Cannot set configuration"); - } -#endif - printf("Claiming USB DFU Interface...\n"); - if (libusb_claim_interface(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "Cannot claim interface"); - } - - printf("Setting Alternate Setting #%d ...\n", dfu_root->altsetting); - if (libusb_set_interface_alt_setting(dfu_root->dev_handle, dfu_root->interface, dfu_root->altsetting) < 0) { - errx(EX_IOERR, "Cannot set alternate interface"); - } - -status_again: - printf("Determining device status: "); - if (dfu_get_status(dfu_root, &status ) < 0) { - errx(EX_IOERR, "error get_status"); - } - printf("state = %s, status = %d\n", - dfu_state_to_string(status.bState), status.bStatus); - - milli_sleep(status.bwPollTimeout); - - switch (status.bState) { - case DFU_STATE_appIDLE: - case DFU_STATE_appDETACH: - errx(EX_IOERR, "Device still in Runtime Mode!"); - break; - case DFU_STATE_dfuERROR: - printf("dfuERROR, clearing status\n"); - if (dfu_clear_status(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "error clear_status"); - } - goto status_again; - break; - case DFU_STATE_dfuDNLOAD_IDLE: - case DFU_STATE_dfuUPLOAD_IDLE: - printf("aborting previous incomplete transfer\n"); - if (dfu_abort(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "can't send DFU_ABORT"); - } - goto status_again; - break; - case DFU_STATE_dfuIDLE: - printf("dfuIDLE, continuing\n"); - break; - default: - break; - } - - if (DFU_STATUS_OK != status.bStatus ) { - printf("WARNING: DFU Status: '%s'\n", - dfu_status_to_string(status.bStatus)); - /* Clear our status & try again. */ - if (dfu_clear_status(dfu_root->dev_handle, dfu_root->interface) < 0) - errx(EX_IOERR, "USB communication error"); - if (dfu_get_status(dfu_root, &status) < 0) - errx(EX_IOERR, "USB communication error"); - if (DFU_STATUS_OK != status.bStatus) - errx(EX_SOFTWARE, "Status is not OK: %d", status.bStatus); - - milli_sleep(status.bwPollTimeout); - } - - printf("DFU mode device DFU version %04x\n", - libusb_le16_to_cpu(dfu_root->func_dfu.bcdDFUVersion)); - - if (dfu_root->func_dfu.bcdDFUVersion == libusb_cpu_to_le16(0x11a)) - dfuse_device = 1; - - /* If not overridden by the user */ - if (!transfer_size) { - transfer_size = libusb_le16_to_cpu( - dfu_root->func_dfu.wTransferSize); - if (transfer_size) { - printf("Device returned transfer size %i\n", - transfer_size); - } else { - errx(EX_IOERR, "Transfer size must be specified"); - } - } - -#ifdef HAVE_GETPAGESIZE -/* autotools lie when cross-compiling for Windows using mingw32/64 */ -#ifndef __MINGW32__ - /* limitation of Linux usbdevio */ - if ((int)transfer_size > getpagesize()) { - transfer_size = getpagesize(); - printf("Limited transfer size to %i\n", transfer_size); - } -#endif /* __MINGW32__ */ -#endif /* HAVE_GETPAGESIZE */ - - if (transfer_size < dfu_root->bMaxPacketSize0) { - transfer_size = dfu_root->bMaxPacketSize0; - printf("Adjusted transfer size to %i\n", transfer_size); - } - - switch (mode) { - case MODE_UPLOAD: - /* open for "exclusive" writing */ - fd = open(file.name, O_WRONLY | O_BINARY | O_CREAT | O_EXCL | O_TRUNC, 0666); - if (fd < 0) - err(EX_IOERR, "Cannot open file %s for writing", file.name); - - if (dfuse_device || dfuse_options) { - if (dfuse_do_upload(dfu_root, transfer_size, fd, - dfuse_options) < 0) - exit(1); - } else { - if (dfuload_do_upload(dfu_root, transfer_size, - expected_size, fd) < 0) { - exit(1); - } - } - close(fd); - break; - - case MODE_DOWNLOAD: - if (((file.idVendor != 0xffff && file.idVendor != runtime_vendor) || - (file.idProduct != 0xffff && file.idProduct != runtime_product)) && - ((file.idVendor != 0xffff && file.idVendor != dfu_root->vendor) || - (file.idProduct != 0xffff && file.idProduct != dfu_root->product))) { - errx(EX_IOERR, "Error: File ID %04x:%04x does " - "not match device (%04x:%04x or %04x:%04x)", - file.idVendor, file.idProduct, - runtime_vendor, runtime_product, - dfu_root->vendor, dfu_root->product); - } - if (dfuse_device || dfuse_options || file.bcdDFU == 0x11a) { - if (dfuse_do_dnload(dfu_root, transfer_size, &file, - dfuse_options) < 0) - exit(1); - } else { - if (dfuload_do_dnload(dfu_root, transfer_size, &file) < 0) - exit(1); - } - break; - case MODE_DETACH: - if (dfu_detach(dfu_root->dev_handle, dfu_root->interface, 1000) < 0) { - warnx("can't detach"); - } - break; - default: - errx(EX_IOERR, "Unsupported mode: %u", mode); - break; - } - - if (final_reset) { - if (dfu_detach(dfu_root->dev_handle, dfu_root->interface, 1000) < 0) { - /* Even if detach failed, just carry on to leave the - device in a known state */ - warnx("can't detach"); - } - printf("Resetting USB to switch back to runtime mode\n"); - ret = libusb_reset_device(dfu_root->dev_handle); - if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) { - errx(EX_IOERR, "error resetting after download"); - } - } - - libusb_close(dfu_root->dev_handle); - dfu_root->dev_handle = NULL; - libusb_exit(ctx); - - return (0); -} diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/portable.h b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/portable.h deleted file mode 100755 index cf8d5df38..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/portable.h +++ /dev/null @@ -1,72 +0,0 @@ - -#ifndef PORTABLE_H -#define PORTABLE_H - -#ifdef HAVE_CONFIG_H -# include "config.h" -#else -# define PACKAGE "dfu-util" -# define PACKAGE_VERSION "0.8-msvc" -# define PACKAGE_STRING "dfu-util 0.8-msvc" -# define PACKAGE_BUGREPORT "dfu-util@lists.gnumonks.org" -#endif /* HAVE_CONFIG_H */ - -#ifdef HAVE_FTRUNCATE -# include -#else -# include -#endif /* HAVE_FTRUNCATE */ - -#ifdef HAVE_NANOSLEEP -# include -# define milli_sleep(msec) do {\ - if (msec) {\ - struct timespec nanosleepDelay = { (msec) / 1000, ((msec) % 1000) * 1000000 };\ - nanosleep(&nanosleepDelay, NULL);\ - } } while (0) -#elif defined HAVE_WINDOWS_H -# define milli_sleep(msec) do {\ - if (msec) {\ - Sleep(msec);\ - } } while (0) -#else -# error "Can't get no sleep! Please report" -#endif /* HAVE_NANOSLEEP */ - -#ifdef HAVE_ERR -# include -#else -# include -# include -# define warnx(...) do {\ - fprintf(stderr, __VA_ARGS__);\ - fprintf(stderr, "\n"); } while (0) -# define errx(eval, ...) do {\ - warnx(__VA_ARGS__);\ - exit(eval); } while (0) -# define warn(...) do {\ - fprintf(stderr, "%s: ", strerror(errno));\ - warnx(__VA_ARGS__); } while (0) -# define err(eval, ...) do {\ - warn(__VA_ARGS__);\ - exit(eval); } while (0) -#endif /* HAVE_ERR */ - -#ifdef HAVE_SYSEXITS_H -# include -#else -# define EX_OK 0 /* successful termination */ -# define EX_USAGE 64 /* command line usage error */ -# define EX_SOFTWARE 70 /* internal software error */ -# define EX_IOERR 74 /* input/output error */ -#endif /* HAVE_SYSEXITS_H */ - -#ifndef O_BINARY -# define O_BINARY 0 -#endif - -#ifndef off_t -# define off_t long int -#endif - -#endif /* PORTABLE_H */ diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/prefix.c b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/prefix.c deleted file mode 100755 index be8e3faf3..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/prefix.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * dfu-prefix - * - * Copyright 2011-2012 Stefan Schmidt - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Uwe Bonnes - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -enum mode { - MODE_NONE, - MODE_ADD, - MODE_DEL, - MODE_CHECK -}; - -int verbose; - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-prefix [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -c --check \t\tCheck DFU prefix of \n" - " -D --delete \t\tDelete DFU prefix from \n" - " -a --add \t\tAdd DFU prefix to \n" - "In combination with -a:\n" - ); - fprintf(stderr, " -s --stellaris-address
Add TI Stellaris address prefix to \n" - "In combination with -D or -c:\n" - " -T --stellaris\t\tAct on TI Stellaris address prefix of \n" - "In combination with -a or -D or -c:\n" - " -L --lpc-prefix\t\tUse NXP LPC DFU prefix format\n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf("dfu-prefix (%s) %s\n\n", PACKAGE, PACKAGE_VERSION); - printf("Copyright 2011-2012 Stefan Schmidt, 2014 Uwe Bonnes\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to %s\n\n", PACKAGE_BUGREPORT); - -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "check", 1, 0, 'c' }, - { "add", 1, 0, 'a' }, - { "delete", 1, 0, 'D' }, - { "stellaris-address", 1, 0, 's' }, - { "stellaris", 0, 0, 'T' }, - { "LPC", 0, 0, 'L' }, -}; -int main(int argc, char **argv) -{ - struct dfu_file file; - enum mode mode = MODE_NONE; - enum prefix_type type = ZERO_PREFIX; - uint32_t lmdfu_flash_address = 0; - char *end; - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - print_version(); - - memset(&file, 0, sizeof(file)); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVc:a:D:p:v:d:s:TL", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - exit(0); - break; - case 'D': - file.name = optarg; - mode = MODE_DEL; - break; - case 'c': - file.name = optarg; - mode = MODE_CHECK; - break; - case 'a': - file.name = optarg; - mode = MODE_ADD; - break; - case 's': - lmdfu_flash_address = strtoul(optarg, &end, 0); - if (*end) { - errx(EX_IOERR, "Invalid lmdfu " - "address: %s", optarg); - } - /* fall-through */ - case 'T': - type = LMDFU_PREFIX; - break; - case 'L': - type = LPCDFU_UNENCRYPTED_PREFIX; - break; - default: - help(); - break; - } - } - - if (!file.name) { - fprintf(stderr, "You need to specify a filename\n"); - help(); - } - - switch(mode) { - case MODE_ADD: - if (type == ZERO_PREFIX) - errx(EX_IOERR, "Prefix type must be specified"); - dfu_load_file(&file, MAYBE_SUFFIX, NO_PREFIX); - file.lmdfu_address = lmdfu_flash_address; - file.prefix_type = type; - printf("Adding prefix to file\n"); - dfu_store_file(&file, file.size.suffix != 0, 1); - break; - - case MODE_CHECK: - dfu_load_file(&file, MAYBE_SUFFIX, MAYBE_PREFIX); - show_suffix_and_prefix(&file); - if (type > ZERO_PREFIX && file.prefix_type != type) - errx(EX_IOERR, "No prefix of requested type"); - break; - - case MODE_DEL: - dfu_load_file(&file, MAYBE_SUFFIX, NEEDS_PREFIX); - if (type > ZERO_PREFIX && file.prefix_type != type) - errx(EX_IOERR, "No prefix of requested type"); - printf("Removing prefix from file\n"); - /* if there was a suffix, rewrite it */ - dfu_store_file(&file, file.size.suffix != 0, 0); - break; - - default: - help(); - break; - } - return (0); -} diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/quirks.c b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/quirks.c deleted file mode 100755 index de394a615..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/quirks.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Simple quirk system for dfu-util - * - * Copyright 2010-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include "quirks.h" - -uint16_t get_quirks(uint16_t vendor, uint16_t product, uint16_t bcdDevice) -{ - uint16_t quirks = 0; - - /* Device returns bogus bwPollTimeout values */ - if ((vendor == VENDOR_OPENMOKO || vendor == VENDOR_FIC) && - product >= PRODUCT_FREERUNNER_FIRST && - product <= PRODUCT_FREERUNNER_LAST) - quirks |= QUIRK_POLLTIMEOUT; - - if (vendor == VENDOR_VOTI && - product == PRODUCT_OPENPCD) - quirks |= QUIRK_POLLTIMEOUT; - - /* Reports wrong DFU version in DFU descriptor */ - if (vendor == VENDOR_LEAFLABS && - product == PRODUCT_MAPLE3 && - bcdDevice == 0x0200) - quirks |= QUIRK_FORCE_DFU11; - - /* old devices(bcdDevice == 0) return bogus bwPollTimeout values */ - if (vendor == VENDOR_SIEMENS && - (product == PRODUCT_PXM40 || product == PRODUCT_PXM50) && - bcdDevice == 0) - quirks |= QUIRK_POLLTIMEOUT; - - /* M-Audio Transit returns bogus bwPollTimeout values */ - if (vendor == VENDOR_MIDIMAN && - product == PRODUCT_TRANSIT) - quirks |= QUIRK_POLLTIMEOUT; - - return (quirks); -} diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/quirks.h b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/quirks.h deleted file mode 100755 index 0e4b3ec58..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/quirks.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef DFU_QUIRKS_H -#define DFU_QUIRKS_H - -#define VENDOR_OPENMOKO 0x1d50 /* Openmoko Freerunner / GTA02 */ -#define VENDOR_FIC 0x1457 /* Openmoko Freerunner / GTA02 */ -#define VENDOR_VOTI 0x16c0 /* OpenPCD Reader */ -#define VENDOR_LEAFLABS 0x1eaf /* Maple */ -#define VENDOR_SIEMENS 0x0908 /* Siemens AG */ -#define VENDOR_MIDIMAN 0x0763 /* Midiman */ - -#define PRODUCT_FREERUNNER_FIRST 0x5117 -#define PRODUCT_FREERUNNER_LAST 0x5126 -#define PRODUCT_OPENPCD 0x076b -#define PRODUCT_MAPLE3 0x0003 /* rev 3 and 5 */ -#define PRODUCT_PXM40 0x02c4 /* Siemens AG, PXM 40 */ -#define PRODUCT_PXM50 0x02c5 /* Siemens AG, PXM 50 */ -#define PRODUCT_TRANSIT 0x2806 /* M-Audio Transit (Midiman) */ - -#define QUIRK_POLLTIMEOUT (1<<0) -#define QUIRK_FORCE_DFU11 (1<<1) - -/* Fallback value, works for OpenMoko */ -#define DEFAULT_POLLTIMEOUT 5 - -uint16_t get_quirks(uint16_t vendor, uint16_t product, uint16_t bcdDevice); - -#endif /* DFU_QUIRKS_H */ diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/suffix.c b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/suffix.c deleted file mode 100755 index 0df248f51..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/suffix.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * dfu-suffix - * - * Copyright 2011-2012 Stefan Schmidt - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -enum mode { - MODE_NONE, - MODE_ADD, - MODE_DEL, - MODE_CHECK -}; - -int verbose; - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-suffix [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -c --check \t\tCheck DFU suffix of \n" - " -a --add \t\tAdd DFU suffix to \n" - " -D --delete \t\tDelete DFU suffix from \n" - " -p --pid \t\tAdd product ID into DFU suffix in \n" - " -v --vid \t\tAdd vendor ID into DFU suffix in \n" - " -d --did \t\tAdd device ID into DFU suffix in \n" - " -S --spec \t\tAdd DFU specification ID into DFU suffix in \n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf("dfu-suffix (%s) %s\n\n", PACKAGE, PACKAGE_VERSION); - printf("Copyright 2011-2012 Stefan Schmidt, 2013-2014 Tormod Volden\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to %s\n\n", PACKAGE_BUGREPORT); - -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "check", 1, 0, 'c' }, - { "add", 1, 0, 'a' }, - { "delete", 1, 0, 'D' }, - { "pid", 1, 0, 'p' }, - { "vid", 1, 0, 'v' }, - { "did", 1, 0, 'd' }, - { "spec", 1, 0, 'S' }, -}; - -int main(int argc, char **argv) -{ - struct dfu_file file; - int pid, vid, did, spec; - enum mode mode = MODE_NONE; - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - print_version(); - - pid = vid = did = 0xffff; - spec = 0x0100; /* Default to bcdDFU version 1.0 */ - memset(&file, 0, sizeof(file)); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVc:a:D:p:v:d:S:s:T", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - exit(0); - break; - case 'D': - file.name = optarg; - mode = MODE_DEL; - break; - case 'p': - pid = strtol(optarg, NULL, 16); - break; - case 'v': - vid = strtol(optarg, NULL, 16); - break; - case 'd': - did = strtol(optarg, NULL, 16); - break; - case 'S': - spec = strtol(optarg, NULL, 16); - break; - case 'c': - file.name = optarg; - mode = MODE_CHECK; - break; - case 'a': - file.name = optarg; - mode = MODE_ADD; - break; - default: - help(); - break; - } - } - - if (!file.name) { - fprintf(stderr, "You need to specify a filename\n"); - help(); - } - - if (spec != 0x0100 && spec != 0x011a) { - fprintf(stderr, "Only DFU specification 0x0100 and 0x011a supported\n"); - help(); - } - - switch(mode) { - case MODE_ADD: - dfu_load_file(&file, NO_SUFFIX, MAYBE_PREFIX); - file.idVendor = vid; - file.idProduct = pid; - file.bcdDevice = did; - file.bcdDFU = spec; - /* always write suffix, rewrite prefix if there was one */ - dfu_store_file(&file, 1, file.size.prefix != 0); - printf("Suffix successfully added to file\n"); - break; - - case MODE_CHECK: - dfu_load_file(&file, NEEDS_SUFFIX, MAYBE_PREFIX); - show_suffix_and_prefix(&file); - break; - - case MODE_DEL: - dfu_load_file(&file, NEEDS_SUFFIX, MAYBE_PREFIX); - dfu_store_file(&file, 0, file.size.prefix != 0); - if (file.size.suffix) /* had a suffix */ - printf("Suffix successfully removed from file\n"); - break; - - default: - help(); - break; - } - return (0); -} diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/usb_dfu.h b/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/usb_dfu.h deleted file mode 100755 index 660bedcbf..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/src/usb_dfu.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef USB_DFU_H -#define USB_DFU_H -/* USB Device Firmware Update Implementation for OpenPCD - * (C) 2006 by Harald Welte - * - * Protocol definitions for USB DFU - * - * This ought to be compliant to the USB DFU Spec 1.0 as available from - * http://www.usb.org/developers/devclass_docs/usbdfu10.pdf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define USB_DT_DFU 0x21 - -#ifdef _MSC_VER -# pragma pack(push) -# pragma pack(1) -#endif /* _MSC_VER */ -struct usb_dfu_func_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bmAttributes; -#define USB_DFU_CAN_DOWNLOAD (1 << 0) -#define USB_DFU_CAN_UPLOAD (1 << 1) -#define USB_DFU_MANIFEST_TOL (1 << 2) -#define USB_DFU_WILL_DETACH (1 << 3) - uint16_t wDetachTimeOut; - uint16_t wTransferSize; - uint16_t bcdDFUVersion; -#ifdef _MSC_VER -}; -# pragma pack(pop) -#elif defined __GNUC__ -} __attribute__ ((packed)); -#else - #warning "No way to pack struct on this compiler? This will break!" -#endif /* _MSC_VER */ - -#define USB_DT_DFU_SIZE 9 - -#define USB_TYPE_DFU (LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE) - -/* DFU class-specific requests (Section 3, DFU Rev 1.1) */ -#define USB_REQ_DFU_DETACH 0x00 -#define USB_REQ_DFU_DNLOAD 0x01 -#define USB_REQ_DFU_UPLOAD 0x02 -#define USB_REQ_DFU_GETSTATUS 0x03 -#define USB_REQ_DFU_CLRSTATUS 0x04 -#define USB_REQ_DFU_GETSTATE 0x05 -#define USB_REQ_DFU_ABORT 0x06 - -/* DFU_GETSTATUS bStatus values (Section 6.1.2, DFU Rev 1.1) */ -#define DFU_STATUS_OK 0x00 -#define DFU_STATUS_errTARGET 0x01 -#define DFU_STATUS_errFILE 0x02 -#define DFU_STATUS_errWRITE 0x03 -#define DFU_STATUS_errERASE 0x04 -#define DFU_STATUS_errCHECK_ERASED 0x05 -#define DFU_STATUS_errPROG 0x06 -#define DFU_STATUS_errVERIFY 0x07 -#define DFU_STATUS_errADDRESS 0x08 -#define DFU_STATUS_errNOTDONE 0x09 -#define DFU_STATUS_errFIRMWARE 0x0a -#define DFU_STATUS_errVENDOR 0x0b -#define DFU_STATUS_errUSBR 0x0c -#define DFU_STATUS_errPOR 0x0d -#define DFU_STATUS_errUNKNOWN 0x0e -#define DFU_STATUS_errSTALLEDPKT 0x0f - -enum dfu_state { - DFU_STATE_appIDLE = 0, - DFU_STATE_appDETACH = 1, - DFU_STATE_dfuIDLE = 2, - DFU_STATE_dfuDNLOAD_SYNC = 3, - DFU_STATE_dfuDNBUSY = 4, - DFU_STATE_dfuDNLOAD_IDLE = 5, - DFU_STATE_dfuMANIFEST_SYNC = 6, - DFU_STATE_dfuMANIFEST = 7, - DFU_STATE_dfuMANIFEST_WAIT_RST = 8, - DFU_STATE_dfuUPLOAD_IDLE = 9, - DFU_STATE_dfuERROR = 10 -}; - -#endif /* USB_DFU_H */ diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/build.html b/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/build.html deleted file mode 100755 index f3036e40c..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/build.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - Building dfu-util from source - - - - - - - - - -
-

How to build dfu-util from source

- -

Prerequisites for building from git

-

Mac OS X

-

-First install MacPorts (and if you are on 10.6 or older, the Java Developer Package) and then run: -

-
-	sudo port install libusb-devel git-core
-
- -

FreeBSD

-
-	sudo pkg_add -r git pkgconf
-
- -

Ubuntu and Debian and derivatives

-
-	sudo apt-get build-dep dfu-util
-	sudo apt-get install libusb-1.0-0-dev
-
- -

Get the source code and build it

-

-The first time you will have to clone the git repository: -

-
-	git clone git://gitorious.org/dfu-util/dfu-util.git
-	cd dfu-util
-
-

-If you later want to update to latest git version, just run this: -

-
-	make maintainer-clean
-	git pull
-
-

-To build the source: -

-
-	./autogen.sh
-	./configure  # on most systems
-	make
-
- -

-If you are building on Mac OS X, replace the ./configure command with: -

-
-	./configure --libdir=/opt/local/lib --includedir=/opt/local/include  # on MacOSX only
-
- -

-Your dfu-util binary will be inside the src folder. Use it from there, or install it to /usr/local/bin by running "sudo make install". -

- -

Cross-building for Windows

- -

-Windows binaries can be built in a MinGW -environment, on a Windows computer or cross-hosted in another OS. -To build it on a Debian or Ubuntu host, first install build dependencies: -

-
-	sudo apt-get build-dep libusb-1.0-0 dfu-util
-	sudo apt-get install mingw32
-
- -

-The below example builds dfu-util 0.8 and libusb 1.0.19 from unpacked release -tarballs. If you instead build from git, you will have to run "./autogen.sh" -before running the "./configure" steps. -

- -
-mkdir -p build
-cd libusb-1.0.19
-PKG_CONFIG_PATH=$PWD/../build/lib/pkgconfig ./configure \
-    --host=i586-mingw32msvc --prefix=$PWD/../build
-# WINVER workaround needed for 1.0.19 only
-make CFLAGS="-DWINVER=0x0501"
-make install
-cd ..
-
-cd dfu-util-0.8
-PKG_CONFIG_PATH=$PWD/../build/lib/pkgconfig ./configure \
-    --host=i586-mingw32msvc --prefix=$PWD/../build
-make
-make install
-cd ..
-
-The build files will now be in build/bin. -

- -

Building on Windows using MinGW

-This assumes using release tarballs or having run ./autogen.sh on -the git sources. -
-cd libusb-1.0.19
-./configure --prefix=$HOME
-# WINVER workaround needed for 1.0.19 only
-# MKDIR_P setting should not really be needed...
-make CFLAGS="-DWINVER=0x0501" MKDIR_P="mkdir -p"
-make install
-cd ..
-
-cd dfu-util-0.8
-./configure USB_CFLAGS="-I$HOME/include/libusb-1.0" \
-            USB_LIBS="-L $HOME/lib -lusb-1.0" PKG_CONFIG=true
-make
-make install
-cd ..
-
-To link libusb statically into dfu-util.exe use instead of "make": -
-make LDFLAGS=-static
-
-The built executables (and DLL) will now be under $HOME/bin. - -

-[Back to dfu-util main page] -

- -
- - diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/dfu-util.1.html b/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/dfu-util.1.html deleted file mode 100755 index 62ca40b5d..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/dfu-util.1.html +++ /dev/null @@ -1,411 +0,0 @@ - - -Man page of DFU-UTIL - - -

DFU-UTIL(1)

- -  -

NAME

- -dfu-util - Device firmware update (DFU) USB programmer -  -

SYNOPSIS

- - -
-
-dfu-util - --l - -[-v] - -[-d - -vid:pid[,vid:pid]] - -[-p - -path] - -[-c - -configuration] - -[-i - -interface] - -[-a - -alt-intf] - -[-S - -serial[,serial]] - - -
-dfu-util - -[-v] - -[-d - -vid:pid[,vid:pid]] - -[-p - -path] - -[-c - -configuration] - -[-i - -interface] - -[-a - -alt-intf] - -[-S - -serial[,serial]] - -[-t - -size] - -[-Z - -size] - -[-s - -address] - -[-R] - -[-D|-U - -file] - - -
-dfu-util - -[-hV] - -
-  -

DESCRIPTION

- -dfu-util - -is a program that implements the host (computer) side of the USB DFU -(Universal Serial Bus Device Firmware Upgrade) protocol. -

-dfu-util communicates with devices that implement the device side of the -USB DFU protocol, and is often used to upgrade the firmware of such -devices. -  -

OPTIONS

- -
-
-l, --list - -
-List the currently attached DFU capable USB devices. -
-d, --device [Run-Time VENDOR]:[Run-Time PRODUCT][,[DFU Mode VENDOR]:[DFU Mode PRODUCT]] - -
-
-Specify run-time and/or DFU mode vendor and/or product IDs of the DFU device -to work with. VENDOR and PRODUCT are hexadecimal numbers (no prefix -needed), "*" (match any), or "-" (match nothing). By default, any DFU capable -device in either run-time or DFU mode will be considered. -

-If you only have one standards-compliant DFU device attached to your computer, -this parameter is optional. However, as soon as you have multiple DFU devices -connected, dfu-util will detect this and abort, asking you to specify which -device to use. -

-If only run-time IDs are specified (e.g. "--device 1457:51ab"), then in -addition to the specified run-time IDs, any DFU mode devices will also be -considered. This is beneficial to allow a DFU capable device to be found -again after a switch to DFU mode, since the vendor and/or product ID of a -device usually changes in DFU mode. -

-If only DFU mode IDs are specified (e.g. "--device ,951:26"), then all -run-time devices will be ignored, making it easy to target a specific device in -DFU mode. -

-If both run-time and DFU mode IDs are specified (e.g. "--device -1457:51ab,:2bc"), then unspecified DFU mode components will use the run-time -value specified. -

-Examples: -

-
--device 1457:51ab,951:26 - -
-
- -Work with a device in run-time mode with -vendor ID 0x1457 and product ID 0x51ab, or in DFU mode with vendor ID 0x0951 -and product ID 0x0026 -

-

--device 1457:51ab,:2bc - -
-
- -Work with a device in run-time mode with vendor ID 0x1457 and product ID -0x51ab, or in DFU mode with vendor ID 0x1457 and product ID 0x02bc -

-

--device 1457:51ab - -
-
- -Work with a device in run-time mode with vendor ID 0x1457 and product ID -0x51ab, or in DFU mode with any vendor and product ID -

-

--device ,951:26 - -
-
- -Work with a device in DFU mode with vendor ID 0x0951 and product ID 0x0026 -

-

--device *,- - -
-
- -Work with any device in run-time mode, and ignore any device in DFU mode -

-

--device , - -
-
- -Ignore any device in run-time mode, and Work with any device in DFU mode -
-
- -
-p, --path BUS-PORT. ... .PORT - -
-Specify the path to the DFU device. -
-c, --cfg CONFIG-NR - -
-Specify the configuration of the DFU device. Note that this is only used for matching, the configuration is not set by dfu-util. -
-i, --intf INTF-NR - -
-Specify the DFU interface number. -
-a, --alt ALT - -
-Specify the altsetting of the DFU interface by name or by number. -
-S, --serial [Run-Time SERIAL][,[DFU Mode SERIAL]] - -
-Specify the run-time and DFU mode serial numbers used to further restrict -device matches. If multiple, identical DFU devices are simultaneously -connected to a system then vendor and product ID will be insufficient for -targeting a single device. In this situation, it may be possible to use this -parameter to specify a serial number which also must match. -

-If only a single serial number is specified, then the same serial number is -used in both run-time and DFU mode. An empty serial number will match any -serial number in the corresponding mode. -

-t, --transfer-size SIZE - -
-Specify the number of bytes per USB transfer. The optimal value is -usually determined automatically so this option is rarely useful. If -you need to use this option for a device, please report it as a bug. -
-Z, --upload-size SIZE - -
-Specify the expected upload size, in bytes. -
-U, --upload FILE - -
-Read firmware from device into -FILE. - -
-D, --download FILE - -
-Write firmware from -FILE - -into device. -
-R, --reset - -
-Issue USB reset signalling after upload or download has finished. -
-s, --dfuse-address address - -
-Specify target address for raw binary download/upload on DfuSe devices. Do -not - -use this for downloading DfuSe (.dfu) files. Modifiers can be added -to the address, separated by a colon, to perform special DfuSE commands such -as "leave" DFU mode, "unprotect" and "mass-erase" flash memory. -
-v, --verbose - -
-Print more information about dfu-util's operation. A second --v - -will turn on verbose logging of USB requests. Repeat this option to further -increase verbosity. -
-h, --help - -
-Show a help text and exit. -
-V, --version - -
-Show version information and exit. -
-  -

EXAMPLES

- -  -

Using dfu-util in the OpenMoko project

- -(with the Neo1973 hardware) -

- -Flashing the rootfs: -
- - $ dfu-util -a rootfs -R -D /path/to/openmoko-devel-image.jffs2 - -

- -Flashing the kernel: -
- - $ dfu-util -a kernel -R -D /path/to/uImage - -

- -Flashing the bootloader: -
- - $ dfu-util -a u-boot -R -D /path/to/u-boot.bin - -

- -Copying a kernel into RAM: -
- - $ dfu-util -a 0 -R -D /path/to/uImage - -

-Once this has finished, the kernel will be available at the default load -address of 0x32000000 in Neo1973 RAM. -Note: - -You cannot transfer more than 2MB of data into RAM using this method. -

-  -

Using dfu-util with a DfuSe device

- -

- -Flashing a -.dfu - -(special DfuSe format) file to the device: -
- - $ dfu-util -a 0 -D /path/to/dfuse-image.dfu - -

- -Reading out 1 KB of flash starting at address 0x8000000: -
- - $ dfu-util -a 0 -s 0x08000000:1024 -U newfile.bin - -

- -Flashing a binary file to address 0x8004000 of device memory and -ask the device to leave DFU mode: -
- - $ dfu-util -a 0 -s 0x08004000:leave -D /path/to/image.bin - - -  -

BUGS

- -Please report any bugs to the dfu-util mailing list at -dfu-util@lists.gnumonks.org. - -Please use the ---verbose option (repeated as necessary) to provide more - -information in your bug report. -  -

SEE ALSO

- -The dfu-util home page is -http://dfu-util.gnumonks.org - -  -

HISTORY

- -dfu-util was originally written for the OpenMoko project by -Weston Schmidt <weston_schmidt@yahoo.com> and -Harald Welte <hwelte@hmw-consulting.de>. Over time, nearly complete -support of DFU 1.0, DFU 1.1 and DfuSe ("1.1a") has been added. -  -

LICENCE

- -dfu-util - -is covered by the GNU General Public License (GPL), version 2 or later. -  -

COPYRIGHT

- -This manual page was originally written by Uwe Hermann <uwe@hermann-uwe.de>, -and is now part of the dfu-util project. -

- -


- 

Index

-
-
NAME
-
SYNOPSIS
-
DESCRIPTION
-
OPTIONS
-
EXAMPLES
-
-
Using dfu-util in the OpenMoko project
-
Using dfu-util with a DfuSe device
-
-
BUGS
-
SEE ALSO
-
HISTORY
-
LICENCE
-
COPYRIGHT
-
-
-This document was created by man2html, -using the doc/dfu-util.1 manual page from dfu-util 0.8.
-Time: 14:40:57 GMT, September 13, 2014 - - diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/dfuse.html b/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/dfuse.html deleted file mode 100755 index 35e4ffa9f..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/dfuse.html +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - DfuSe and dfu-util - - - - - - - - - -
-

Using dfu-util with DfuSe devices

-

DfuSe

-

- DfuSe (DFU with ST Microsystems extensions) is a protocol based on - DFU 1.1. However, in expanding the functionality of the DFU protocol, - ST Microsystems broke all compatibility with the DFU 1.1 standard. - DfuSe devices report the DFU version as "1.1a". -

-

- DfuSe can be used to download firmware and other data - from a host computer to a conforming device (or upload in the - opposite direction) over USB similar to standard DFU. -

-

- The main difference from standard DFU is that the target address in - the device (flash) memory is specified by the host, so that a - download can be performed to parts of the device memory. The host - program is also responsible for erasing flash pages before they - are written to. -

-

.dfu files

-

- A special file format is defined by ST Microsystems to carry firmware - for DfuSe devices. The file contains target information such as address - and alternate interface information in addition to the binary data. - Several blocks of binary data can be combined in one .dfu file. -

-

Alternate interfaces

-

- Different memory locations of the device may have different - characteristics that the host program (dfu-util) has to take - into considerations, such as flash memory page size, read-only - versus read-write segments, the need to erase, and so on. - These parameters are reported by the device in the string - descriptors meant for describing the USB interfaces. - The host program decodes these strings to build a memory map of - the device. Different memory units or address spaces are listed - in separate alternate interface settings that must be selected - according to the memory unit to access. -

-

- Note that dfu-util leaves it to the user to select alternate - interface. When parsing a .dfu file it will skip file segments - not matching the selected alternate interface. Also, some - DfuSe device firmware implementations ignore the setting of - alternate interface and deduct the memory unit from the - address, since they have no address space overlap. -

-

DfuSe special commands

-

- DfuSe special commands are used by the host program during normal - downloads or uploads, such as SET_ADDRESS and ERASE_PAGE. Also - the normal DFU_DNLOAD and DFU_UPLOAD commands have special - implementations in DfuSe. - Many DfuSe devices also support commands to leave DFU mode, - read unprotect the flash memory or mass erase the flash memory. - dfu-util (from version 0.7) - supports adding "leave", "unprotect", or "mass-erase" - to the -s option argument to send such requests in combination - with a download request. These modifiers are separated with a colon. -

-

- Some DfuSe devices have their DfuSe bootloader running from flash - memory. Erasing the whole flash memory would therefore destroy - the DfuSe bootloader itself and practically brick the device - for most users. Any use of modifiers such as "unprotect" - and "mass-erase" therefore needs to be combined with the "force" - modifer. This is not included in the examples, to not encourage - ignorant users to copy and paste such instructions and shoot - themselves in the foot. -

-

- Devices based on for instance STM32F103 all run the bootloader - from flash, since there is no USB bootloader in ROM. -

-

- For instance STM32F107, STM32F2xx and STM32F4xx devices have a - DfuSe bootloader in ROM, so the flash can be erased while - keeping the device available for USB DFU transfers as long - as the device designers use this built-in bootloader and have - not implemented another DfuSe bootloader in flash that the user is - dependent upon. -

-

- Well-written bootloaders running from flash will report their - own memory region as read-only and not eraseable, but this does - not prevent dfu-util from sending a "unprotect" or "mass-erase" - request which overrides this, if the user insists. -

-

Example usage

-

- Flashing a .dfu (special DfuSe format) file to the device: -

-
-         $ dfu-util -a 0 -D /path/to/dfuse-image.dfu
-	
-

- Reading out 1 KB of flash starting at address 0x8000000: -

-
-         $ dfu-util -a 0 -s 0x08000000:1024 -U newfile.bin
-	
-

- Flashing a binary file to address 0x8004000 of device memory and ask - the device to leave DFU mode: -

-
-         $ dfu-util -a 0 -s 0x08004000:leave -D /path/to/image.bin
-	
-

- [Back to dfu-util main page] -

- -
- - diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/index.html b/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/index.html deleted file mode 100755 index 108ddaf66..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/index.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - dfu-util Homepage - - - - - - - - - -
-

dfu-util - Device Firmware Upgrade Utilities

-

Description

-

- dfu-util is a host side implementation of the DFU 1.0 and DFU 1.1 specifications of the USB forum. - - DFU is intended to download and upload firmware to/from devices connected - over USB. It ranges from small devices like micro-controller boards - to mobile phones. Using dfu-util you can download firmware to your - DFU-enabled device or upload firmware from it. dfu-util has been - tested with the Openmoko Neo1973 and Freerunner and many other devices. -

-

- See the manual page for examples of use. -

-

Supported Devices

- -

Releases

-

- Releases of the dfu-util software can be found in the - releases folder. - The current release is 0.8. -

-

- We offer binaries for Microsoft Windows and some other platforms. - dfu-util uses libusb 1.0 to access your device, so - on Windows you have to register the device with the WinUSB driver - (alternatively libusb-win32 or libusbK), please see the libusbx wiki - for more details. -

-

- Mac OS X users can also get dfu-util from Homebrew with "brew install dfu-util" or from MacPorts. -

-

- Most Linux distributions ship dfu-util in binary packages for those - who do not want to compile dfu-util from source. - On Debian, Ubuntu, Fedora and Gentoo you can install it through the - normal software package tools. For other distributions -(namely OpenSuSe, Mandriva, and CentOS) Holger Freyther was kind enough to -provide binary packages through the Open Build Service. -

-

Development

-

- Development happens in a GIT repository. Browse it via the web -interface or clone it with: -

-
-	git clone git://gitorious.org/dfu-util/dfu-util.git
-	
-

- See our build instructions for how to - build the source on different platforms. -

-

License

-

- This software is licensed under the GPL version 2. -

-

Contact

-

- If you have questions about the development or use of dfu-util please - send an e-mail to our dedicated -mailing list for dfu-util. -

-

People

-

- dfu-util was originally written by - Harald Welte partially based on code from - dfu-programmer 0.4 and is currently maintained by Stefan Schmidt and - Tormod Volden. -

- -
- - diff --git a/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/simple.css b/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/simple.css deleted file mode 100755 index 98100bc5c..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/dfu-util/www/simple.css +++ /dev/null @@ -1,56 +0,0 @@ -body { - margin: 10px; - font-size: 0.82em; - background-color: #EEE; -} - -h1 { - clear: both; - padding: 0 0 12px 0; - margin: 0; - font-size: 2em; - font-weight: bold; -} - -h2 { - clear: both; - margin: 0; - font-size: 1.5em; - font-weight: normal; -} - -h3 { - clear: both; - margin: 15px 0 0 0; - font-size: 1.0em; - font-weight: bold; -} - -p { - line-height: 20px; - padding: 8px 0 8px 0; - margin: 0; - font-size: 1.1em; -} - -pre { - white-space: pre-wrap; - background-color: #CCC; - padding: 3px; -} - -a:hover { - background-color: #DDD; -} - -#middlebox { - width: 600px; - margin: 0px auto; - text-align: left; -} - -#footer { - height: 100px; - padding: 28px 3px 0 0; - margin: 20px 0 20px 0; -} diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/README.md b/arduino/opencr_arduino/tools/linux64/src/maple_loader/README.md deleted file mode 100755 index c6c937950..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/README.md +++ /dev/null @@ -1,5 +0,0 @@ -These files build the maple_loader.jar file used on Windows to reset the Sketch via USB Serial, so that the bootloader will run in dfu upload mode, ready for a new sketch to be uploaded - -The files were written by @bobC (github) and have been slightly modified by me (Roger Clark), so that dfu-util no longer attempts to reset the board after upload. -This change to dfu-util's reset command line argument, was required because dfu-util was showing errors on some Windows systems, because the bootloader had reset its self after upload, -before dfu-util had chance to tell it to reset. \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build.xml b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build.xml deleted file mode 100755 index 80bdd6fdb..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project maple_loader. - - - diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/built-jar.properties b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/built-jar.properties deleted file mode 100755 index 10752d534..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/built-jar.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Mon, 20 Jul 2015 11:21:26 +1000 - - -C\:\\Users\\rclark\\Desktop\\maple-asp-master\\installer\\maple_loader= diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/CliTemplate/CliMain.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/CliTemplate/CliMain.class deleted file mode 100755 index 37ee63000..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/CliTemplate/CliMain.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/CliTemplate/DFUUploader.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/CliTemplate/DFUUploader.class deleted file mode 100755 index 77087b052..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/CliTemplate/DFUUploader.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/CliTemplate/ExecCommand.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/CliTemplate/ExecCommand.class deleted file mode 100755 index ad95f7984..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/CliTemplate/ExecCommand.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/Base.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/Base.class deleted file mode 100755 index 4aa0bde02..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/Base.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/Preferences.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/Preferences.class deleted file mode 100755 index 89cf01004..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/Preferences.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/Serial.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/Serial.class deleted file mode 100755 index cceccdd27..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/Serial.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/SerialException.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/SerialException.class deleted file mode 100755 index 71048dd3a..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/SerialException.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class deleted file mode 100755 index 37250e770..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class deleted file mode 100755 index e22c8d499..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/debug/RunnerException.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/debug/RunnerException.class deleted file mode 100755 index 710f79650..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/debug/RunnerException.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class b/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class deleted file mode 100755 index 27eca6262..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/dist/README.TXT b/arduino/opencr_arduino/tools/linux64/src/maple_loader/dist/README.TXT deleted file mode 100755 index 255b89c68..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/dist/README.TXT +++ /dev/null @@ -1,32 +0,0 @@ -======================== -BUILD OUTPUT DESCRIPTION -======================== - -When you build an Java application project that has a main class, the IDE -automatically copies all of the JAR -files on the projects classpath to your projects dist/lib folder. The IDE -also adds each of the JAR files to the Class-Path element in the application -JAR files manifest file (MANIFEST.MF). - -To run the project from the command line, go to the dist folder and -type the following: - -java -jar "maple_loader.jar" - -To distribute this project, zip up the dist folder (including the lib folder) -and distribute the ZIP file. - -Notes: - -* If two JAR files on the project classpath have the same name, only the first -JAR file is copied to the lib folder. -* Only JAR files are copied to the lib folder. -If the classpath contains other types of files or folders, these files (folders) -are not copied. -* If a library on the projects classpath also has a Class-Path element -specified in the manifest,the content of the Class-Path element has to be on -the projects runtime path. -* To set a main class in a standard Java project, right-click the project node -in the Projects window and choose Properties. Then click Run and enter the -class name in the Main Class field. Alternatively, you can manually type the -class name in the manifest Main-Class element. diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/dist/lib/jssc.jar b/arduino/opencr_arduino/tools/linux64/src/maple_loader/dist/lib/jssc.jar deleted file mode 100755 index eb74f154a..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/dist/lib/jssc.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/dist/maple_loader.jar b/arduino/opencr_arduino/tools/linux64/src/maple_loader/dist/maple_loader.jar deleted file mode 100755 index e1f9965c1..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/dist/maple_loader.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/jars/jssc.jar b/arduino/opencr_arduino/tools/linux64/src/maple_loader/jars/jssc.jar deleted file mode 100755 index eb74f154a..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/src/maple_loader/jars/jssc.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/manifest.mf b/arduino/opencr_arduino/tools/linux64/src/maple_loader/manifest.mf deleted file mode 100755 index 328e8e5bc..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/build-impl.xml b/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/build-impl.xml deleted file mode 100755 index a66f34964..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/build-impl.xml +++ /dev/null @@ -1,1413 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/genfiles.properties b/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/genfiles.properties deleted file mode 100755 index c13672132..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=2e6a03ba -build.xml.script.CRC32=4676ee6b -build.xml.stylesheet.CRC32=8064a381@1.75.2.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=2e6a03ba -nbproject/build-impl.xml.script.CRC32=392b3f79 -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/private/config.properties b/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/private/config.properties deleted file mode 100755 index e69de29bb..000000000 diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/private/private.properties b/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/private/private.properties deleted file mode 100755 index e5c9f10c4..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/private/private.properties +++ /dev/null @@ -1,6 +0,0 @@ -compile.on.save=true -do.depend=false -do.jar=true -javac.debug=true -javadoc.preview=true -user.properties.file=C:\\Users\\rclark\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/private/private.xml b/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/private/private.xml deleted file mode 100755 index a1bbd60c9..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/private/private.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - file:/C:/Users/rclark/Desktop/maple-asp-master/installer/maple_loader/src/CliTemplate/CliMain.java - file:/C:/Users/rclark/Desktop/maple-asp-master/installer/maple_loader/src/CliTemplate/DFUUploader.java - - - diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/project.properties b/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/project.properties deleted file mode 100755 index 7f48d719f..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/project.properties +++ /dev/null @@ -1,79 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=maple_loader -application.vendor=bob -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/maple_loader.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.jssc.jar=dist/lib/jssc.jar -file.reference.jssc.jar-1=jars/jssc.jar -includes=** -jar.compress=false -javac.classpath=\ - ${file.reference.jssc.jar}:\ - ${file.reference.jssc.jar-1} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.7 -javac.target=1.7 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=CliTemplate.CliMain -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/project.xml b/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/project.xml deleted file mode 100755 index 92218a925..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/nbproject/project.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - maple_loader - - - - - - - - - diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/CliTemplate/CliMain.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/CliTemplate/CliMain.java deleted file mode 100755 index c7dc9f098..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/CliTemplate/CliMain.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package CliTemplate; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import processing.app.Preferences; - -//import processing.app.I18n; -import processing.app.helpers.ProcessUtils; - -/** - * - * @author cousinr - */ -public class CliMain { - - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - - String comPort = args[0]; // - String altIf = args[1]; // - String usbID = args[2]; // "1EAF:0003"; - String binFile = args[3]; // bin file - - System.out.println("maple_loader v0.1"); - - Preferences.set ("serial.port",comPort); - Preferences.set ("serial.parity","N"); - Preferences.setInteger ("serial.databits", 8); - Preferences.setInteger ("serial.debug_rate",9600); - Preferences.setInteger ("serial.stopbits",1); - - Preferences.setInteger ("programDelay",1200); - - Preferences.set ("upload.usbID", usbID); - Preferences.set ("upload.altID", altIf); - Preferences.setBoolean ("upload.auto_reset", true); - Preferences.setBoolean ("upload.verbose", false); - - // - DFUUploader dfuUploader = new DFUUploader(); - try { - //dfuUploader.uploadViaDFU(binFile); - dfuUploader.uploadViaDFU(binFile); - } catch (Exception e) - { - System.err.print (MessageFormat.format("an error occurred! {0}\n", e.getMessage())); - } - } -} diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/CliTemplate/DFUUploader.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/CliTemplate/DFUUploader.java deleted file mode 100755 index 3dee0b4b7..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/CliTemplate/DFUUploader.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - DFUUploader - uploader implementation using DFU - - Copyright (c) 2010 - Andrew Meyer - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - -package CliTemplate; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import processing.app.Preferences; -import processing.app.Serial; -import processing.app.debug.MessageConsumer; -import processing.app.debug.MessageSiphon; -import processing.app.debug.RunnerException; - -/** - * - * @author bob - */ -public class DFUUploader implements MessageConsumer { - - boolean firstErrorFound; - boolean secondErrorFound; - // part of the PdeMessageConsumer interface - boolean notFoundError; - boolean verbose; - RunnerException exception; - - static final String SUPER_BADNESS = - "Compiler error!"; - - public boolean uploadUsingPreferences(String binPath, boolean verbose) - throws RunnerException { - - this.verbose = verbose; - - return uploadViaDFU(binPath); - } - - // works with old and new versions of dfu-util - private boolean found_device (String dfuData, String usbID) - { - return dfuData.contains(("Found DFU: [0x"+usbID.substring(0,4)).toUpperCase()) || - dfuData.contains(("Found DFU: ["+usbID.substring(0,4)).toUpperCase()); - } - - public boolean uploadViaDFU (String binPath) - throws RunnerException { - - this.verbose = Preferences.getBoolean ("upload.verbose"); - - /* todo, check for size overruns! */ - String fileType="bin"; - - if (fileType.equals("bin")) { - String usbID = Preferences.get("upload.usbID"); - if (usbID == null) { - /* fall back on default */ - /* this isnt great because is default Avrdude or dfu-util? */ - usbID = Preferences.get("upload.usbID"); - } - - /* if auto-reset, then emit the reset pulse on dtr/rts */ - if (Preferences.get("upload.auto_reset") != null) { - if (Preferences.get("upload.auto_reset").toLowerCase().equals("true")) { - System.out.println("Resetting to bootloader via DTR pulse"); - emitResetPulse(); - } - } else { - System.out.println("Resetting to bootloader via DTR pulse"); - emitResetPulse(); - } - - String dfuList = new String(); - List commandCheck = new ArrayList(); - commandCheck.add("dfu-util"); - commandCheck.add("-l"); - long startChecking = System.currentTimeMillis(); - System.out.println("Searching for DFU device [" + usbID + "]..."); - do { - try { - Thread.sleep(100); - } catch (InterruptedException e) {} - dfuList = executeCheckCommand(commandCheck); - //System.out.println(dfuList); - } - while ( !found_device (dfuList.toUpperCase(), usbID) && (System.currentTimeMillis() - startChecking < 7000)); - - if ( !found_device (dfuList.toUpperCase(), usbID) ) - { - System.out.println(dfuList); - System.err.println("Couldn't find the DFU device: [" + usbID + "]"); - return false; - } - System.out.println("Found it!"); - - /* todo, add handle to let user choose altIf at upload time! */ - String altIf = Preferences.get("upload.altID"); - - List commandDownloader = new ArrayList(); - commandDownloader.add("dfu-util"); - commandDownloader.add("-a "+altIf); - commandDownloader.add("-R"); - commandDownloader.add("-d "+usbID); - commandDownloader.add("-D"+ binPath); //"./thisbin.bin"); - - return executeUploadCommand(commandDownloader); - } - - System.err.println("Only .bin files are supported at this time"); - return false; - } - - /* we need to ensure both RTS and DTR are low to start, - then pulse DTR on its own. This is the reset signal - maple responds to - */ - private void emitResetPulse() throws RunnerException { - - /* wait a while for the device to reboot */ - int programDelay = Preferences.getInteger("programDelay"); - - try { - Serial serialPort = new Serial(); - - // try to toggle DTR/RTS (old scheme) - serialPort.setRTS(false); - serialPort.setDTR(false); - serialPort.setDTR(true); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.setDTR(false); - - // try magic number - serialPort.setRTS(true); - serialPort.setDTR(true); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.setDTR(false); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.write("1EAF"); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.dispose(); - - } catch(Exception e) { - System.err.println("Reset via USB Serial Failed! Did you select the right serial port?\nAssuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...\n"); - } - } - - protected String executeCheckCommand(Collection commandDownloader) - throws RunnerException - { - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - notFoundError = false; - int result=0; // pre-initialized to quiet a bogus warning from jikes - - String userdir = System.getProperty("user.dir") + File.separator; - String returnStr = new String(); - - try { - String[] commandArray = new String[commandDownloader.size()]; - commandDownloader.toArray(commandArray); - - String armBasePath; - - //armBasePath = new String(Base.getHardwarePath() + "/tools/arm/bin/"); - armBasePath = ""; - - commandArray[0] = armBasePath + commandArray[0]; - - if (verbose || Preferences.getBoolean("upload.verbose")) { - for(int i = 0; i < commandArray.length; i++) { - System.out.print(commandArray[i] + " "); - } - System.out.println(); - } - - Process process = Runtime.getRuntime().exec(commandArray); - BufferedReader stdInput = new BufferedReader(new - InputStreamReader(process.getInputStream())); - BufferedReader stdError = new BufferedReader(new - InputStreamReader(process.getErrorStream())); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - // - boolean busy = true; - while (busy) { - try { - result = process.waitFor(); - busy = false; - } catch (InterruptedException intExc) { - } - } - - String s; - while ((s = stdInput.readLine()) != null) { - returnStr += s + "\n"; - } - - process.destroy(); - - if(exception!=null) { - exception.hideStackTrace(); - throw exception; - } - if(result!=0) return "Error!"; - } catch (Exception e) { - e.printStackTrace(); - } - //System.out.println("result2 is "+result); - // if the result isn't a known, expected value it means that something - // is fairly wrong, one possibility is that jikes has crashed. - // - if (exception != null) throw exception; - - if ((result != 0) && (result != 1 )) { - exception = new RunnerException(SUPER_BADNESS); - } - - return returnStr; // ? true : false; - - } - - // Need to overload this from Uploader to use the system-wide dfu-util - protected boolean executeUploadCommand(Collection commandDownloader) - throws RunnerException - { - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - notFoundError = false; - int result=0; // pre-initialized to quiet a bogus warning from jikes - - String userdir = System.getProperty("user.dir") + File.separator; - - try { - String[] commandArray = new String[commandDownloader.size()]; - commandDownloader.toArray(commandArray); - - String armBasePath; - - //armBasePath = new String(Base.getHardwarePath() + "/tools/arm/bin/"); - armBasePath = ""; - - commandArray[0] = armBasePath + commandArray[0]; - - if (verbose || Preferences.getBoolean("upload.verbose")) { - for(int i = 0; i < commandArray.length; i++) { - System.out.print(commandArray[i] + " "); - } - System.out.println(); - } - - Process process = Runtime.getRuntime().exec(commandArray); - new MessageSiphon(process.getInputStream(), this); - new MessageSiphon(process.getErrorStream(), this); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - // - boolean compiling = true; - while (compiling) { - try { - result = process.waitFor(); - compiling = false; - } catch (InterruptedException intExc) { - } - } - if(exception!=null) { - exception.hideStackTrace(); - throw exception; - } - if(result!=0) - return false; - } catch (Exception e) { - e.printStackTrace(); - } - //System.out.println("result2 is "+result); - // if the result isn't a known, expected value it means that something - // is fairly wrong, one possibility is that jikes has crashed. - // - if (exception != null) throw exception; - - if ((result != 0) && (result != 1 )) { - exception = new RunnerException(SUPER_BADNESS); - //editor.error(exception); - //PdeBase.openURL(BUGS_URL); - //throw new PdeException(SUPER_BADNESS); - } - - return (result == 0); // ? true : false; - - } - - // deal with messages from dfu-util... - public void message(String s) { - - if(s.indexOf("dfu-util - (C) ") != -1) { return; } - if(s.indexOf("This program is Free Software and has ABSOLUTELY NO WARRANTY") != -1) { return; } - - if(s.indexOf("No DFU capable USB device found") != -1) { - System.err.print(s); - exception = new RunnerException("Problem uploading via dfu-util: No Maple found"); - return; - } - - if(s.indexOf("Operation not perimitted") != -1) { - System.err.print(s); - exception = new RunnerException("Problem uploading via dfu-util: Insufficient privilages"); - return; - } - - // else just print everything... - System.out.print(s); - } - -} diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/CliTemplate/ExecCommand.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/CliTemplate/ExecCommand.java deleted file mode 100755 index 3d6c106b7..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/CliTemplate/ExecCommand.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package CliTemplate; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; - -import processing.app.debug.MessageConsumer; -import processing.app.debug.MessageSiphon; -import processing.app.debug.RunnerException; -import processing.app.helpers.ProcessUtils; - -/** - * - * @author cousinr - */ -public class ExecCommand implements MessageConsumer { - - private boolean verbose = true; - private boolean firstErrorFound; - private boolean secondErrorFound; - private RunnerException exception; - - /** - * Either succeeds or throws a RunnerException fit for public consumption. - * - * @param command - * @throws RunnerException - */ - public void execAsynchronously(String[] command) throws RunnerException { - - // eliminate any empty array entries - List stringList = new ArrayList<>(); - for (String string : command) { - string = string.trim(); - if (string.length() != 0) - stringList.add(string); - } - command = stringList.toArray(new String[stringList.size()]); - if (command.length == 0) - return; - int result = 0; - - if (verbose) { - for (String c : command) - System.out.print(c + " "); - System.out.println(); - } - - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - - Process process; - try { - process = ProcessUtils.exec(command); - } catch (IOException e) { - RunnerException re = new RunnerException(e.getMessage()); - re.hideStackTrace(); - throw re; - } - - MessageSiphon in = new MessageSiphon(process.getInputStream(), this); - MessageSiphon err = new MessageSiphon(process.getErrorStream(), this); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - boolean compiling = true; - while (compiling) { - try { - in.join(); - err.join(); - result = process.waitFor(); - //System.out.println("result is " + result); - compiling = false; - } catch (InterruptedException ignored) { } - } - - // an error was queued up by message(), barf this back to compile(), - // which will barf it back to Editor. if you're having trouble - // discerning the imagery, consider how cows regurgitate their food - // to digest it, and the fact that they have five stomaches. - // - //System.out.println("throwing up " + exception); - if (exception != null) - throw exception; - - if (result > 1) { - // a failure in the tool (e.g. unable to locate a sub-executable) - System.err.println(MessageFormat.format("{0} returned {1}", command[0], result)); - } - - if (result != 0) { - RunnerException re = new RunnerException(MessageFormat.format("exit code: {0}", result)); - re.hideStackTrace(); - throw re; - } - } - - /** - * Part of the MessageConsumer interface, this is called - * whenever a piece (usually a line) of error message is spewed - * out from the compiler. The errors are parsed for their contents - * and line number, which is then reported back to Editor. - * @param s - */ - @Override - public void message(String s) { - int i; - - - System.err.print(s); - } - -} diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/Base.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/Base.java deleted file mode 100755 index c3a174dcb..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/Base.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-10 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - - -/** - * The base class for the main processing application. - * Primary role of this class is for platform identification and - * general interaction with the system (launching URLs, loading - * files and images, etc) that comes from that. - */ -public class Base { - - /** - * returns true if running on windows. - */ - static public boolean isWindows() { - //return PApplet.platform == PConstants.WINDOWS; - return System.getProperty("os.name").indexOf("Windows") != -1; - } - - - /** - * true if running on linux. - */ - static public boolean isLinux() { - //return PApplet.platform == PConstants.LINUX; - return System.getProperty("os.name").indexOf("Linux") != -1; - } - - - -} diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/Preferences.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/Preferences.java deleted file mode 100755 index 6368e38af..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/Preferences.java +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-09 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - -import java.io.*; -import java.util.*; - - -/** - * Storage class for user preferences and environment settings. - *

- * This class no longer uses the Properties class, since - * properties files are iso8859-1, which is highly likely to - * be a problem when trying to save sketch folders and locations. - *

- * The GUI portion in here is really ugly, as it uses exact layout. This was - * done in frustration one evening (and pre-Swing), but that's long since past, - * and it should all be moved to a proper swing layout like BoxLayout. - *

- * This is very poorly put together, that the preferences panel and the actual - * preferences i/o is part of the same code. But there hasn't yet been a - * compelling reason to bother with the separation aside from concern about - * being lectured by strangers who feel that it doesn't look like what they - * learned in CS class. - *

- * Would also be possible to change this to use the Java Preferences API. - * Some useful articles - * here and - * here. - * However, haven't implemented this yet for lack of time, but more - * importantly, because it would entail writing to the registry (on Windows), - * or an obscure file location (on Mac OS X) and make it far more difficult to - * find the preferences to tweak them by hand (no! stay out of regedit!) - * or to reset the preferences by simply deleting the preferences.txt file. - */ -public class Preferences { - - // what to call the feller - - static final String PREFS_FILE = "preferences.txt"; - - - // prompt text stuff - - static final String PROMPT_YES = "Yes"; - static final String PROMPT_NO = "No"; - static final String PROMPT_CANCEL = "Cancel"; - static final String PROMPT_OK = "OK"; - static final String PROMPT_BROWSE = "Browse"; - - /** - * Standardized width for buttons. Mac OS X 10.3 wants 70 as its default, - * Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper. - */ - static public int BUTTON_WIDTH = 80; - - /** - * Standardized button height. Mac OS X 10.3 (Java 1.4) wants 29, - * presumably because it now includes the blue border, where it didn't - * in Java 1.3. Windows XP only wants 23 (not sure what default Linux - * would be). Because of the disparity, on Mac OS X, it will be set - * inside a static block. - */ - static public int BUTTON_HEIGHT = 24; - - // value for the size bars, buttons, etc - - static final int GRID_SIZE = 33; - - - // indents and spacing standards. these probably need to be modified - // per platform as well, since macosx is so huge, windows is smaller, - // and linux is all over the map - - static final int GUI_BIG = 13; - static final int GUI_BETWEEN = 10; - static final int GUI_SMALL = 6; - - - - // data model - - static Hashtable table = new Hashtable();; - static File preferencesFile; - - - static protected void init(String commandLinePrefs) { - - - } - - - public Preferences() { - - } - - // ................................................................. - - // ................................................................. - - // ................................................................. - - // ................................................................. - - - - static public String get(String attribute) { - return (String) table.get(attribute); - } - - static public void set(String attribute, String value) { - table.put(attribute, value); - } - - - static public boolean getBoolean(String attribute) { - String value = get(attribute); - return (new Boolean(value)).booleanValue(); - } - - - static public void setBoolean(String attribute, boolean value) { - set(attribute, value ? "true" : "false"); - } - - - static public int getInteger(String attribute) { - return Integer.parseInt(get(attribute)); - } - - - static public void setInteger(String key, int value) { - set(key, String.valueOf(value)); - } - -} diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/Serial.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/Serial.java deleted file mode 100755 index 04566a738..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/Serial.java +++ /dev/null @@ -1,527 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - PSerial - class for serial port goodness - Part of the Processing project - http://processing.org - - Copyright (c) 2004 Ben Fry & Casey Reas - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA -*/ - -package processing.app; -//import processing.core.*; - - -import java.io.*; -import java.text.MessageFormat; -import java.util.*; -import jssc.SerialPort; -import jssc.SerialPortEvent; -import jssc.SerialPortEventListener; -import jssc.SerialPortException; -import jssc.SerialPortList; -import processing.app.debug.MessageConsumer; - - -public class Serial implements SerialPortEventListener { - - //PApplet parent; - - // properties can be passed in for default values - // otherwise defaults to 9600 N81 - - // these could be made static, which might be a solution - // for the classloading problem.. because if code ran again, - // the static class would have an object that could be closed - - SerialPort port; - - int rate; - int parity; - int databits; - int stopbits; - boolean monitor = false; - - // read buffer and streams - - InputStream input; - OutputStream output; - - byte buffer[] = new byte[32768]; - int bufferIndex; - int bufferLast; - - MessageConsumer consumer; - - public Serial(boolean monitor) throws SerialException { - this(Preferences.get("serial.port"), - Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - this.monitor = monitor; - } - - public Serial() throws SerialException { - this(Preferences.get("serial.port"), - Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(int irate) throws SerialException { - this(Preferences.get("serial.port"), irate, - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname, int irate) throws SerialException { - this(iname, irate, Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname) throws SerialException { - this(iname, Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname, int irate, - char iparity, int idatabits, float istopbits) - throws SerialException { - //if (port != null) port.close(); - //this.parent = parent; - //parent.attach(this); - - this.rate = irate; - - parity = SerialPort.PARITY_NONE; - if (iparity == 'E') parity = SerialPort.PARITY_EVEN; - if (iparity == 'O') parity = SerialPort.PARITY_ODD; - - this.databits = idatabits; - - stopbits = SerialPort.STOPBITS_1; - if (istopbits == 1.5f) stopbits = SerialPort.STOPBITS_1_5; - if (istopbits == 2) stopbits = SerialPort.STOPBITS_2; - - try { - port = new SerialPort(iname); - port.openPort(); - port.setParams(rate, databits, stopbits, parity, true, true); - port.addEventListener(this); - } catch (Exception e) { - throw new SerialException(MessageFormat.format("Error opening serial port ''{0}''.", iname), e); - } - - if (port == null) { - throw new SerialException("Serial port '" + iname + "' not found. Did you select the right one from the Tools > Serial Port menu?"); - } - } - - - public void setup() { - //parent.registerCall(this, DISPOSE); - } - - public void dispose() throws IOException { - if (port != null) { - try { - if (port.isOpened()) { - port.closePort(); // close the port - } - } catch (SerialPortException e) { - throw new IOException(e); - } finally { - port = null; - } - } - } - - public void addListener(MessageConsumer consumer) { - this.consumer = consumer; - } - - public synchronized void serialEvent(SerialPortEvent serialEvent) { - if (serialEvent.isRXCHAR()) { - try { - byte[] buf = port.readBytes(serialEvent.getEventValue()); - if (buf.length > 0) { - if (bufferLast == buffer.length) { - byte temp[] = new byte[bufferLast << 1]; - System.arraycopy(buffer, 0, temp, 0, bufferLast); - buffer = temp; - } - if (monitor) { - System.out.print(new String(buf)); - } - if (this.consumer != null) { - this.consumer.message(new String(buf)); - } - } - } catch (SerialPortException e) { - errorMessage("serialEvent", e); - } - } - } - - - /** - * Returns the number of bytes that have been read from serial - * and are waiting to be dealt with by the user. - */ - public synchronized int available() { - return (bufferLast - bufferIndex); - } - - - /** - * Ignore all the bytes read so far and empty the buffer. - */ - public synchronized void clear() { - bufferLast = 0; - bufferIndex = 0; - } - - - /** - * Returns a number between 0 and 255 for the next byte that's - * waiting in the buffer. - * Returns -1 if there was no byte (although the user should - * first check available() to see if things are ready to avoid this) - */ - public synchronized int read() { - if (bufferIndex == bufferLast) return -1; - - int outgoing = buffer[bufferIndex++] & 0xff; - if (bufferIndex == bufferLast) { // rewind - bufferIndex = 0; - bufferLast = 0; - } - return outgoing; - } - - - /** - * Returns the next byte in the buffer as a char. - * Returns -1, or 0xffff, if nothing is there. - */ - public synchronized char readChar() { - if (bufferIndex == bufferLast) return (char)(-1); - return (char) read(); - } - - - /** - * Return a byte array of anything that's in the serial buffer. - * Not particularly memory/speed efficient, because it creates - * a byte array on each read, but it's easier to use than - * readBytes(byte b[]) (see below). - */ - public synchronized byte[] readBytes() { - if (bufferIndex == bufferLast) return null; - - int length = bufferLast - bufferIndex; - byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex = 0; // rewind - bufferLast = 0; - return outgoing; - } - - - /** - * Grab whatever is in the serial buffer, and stuff it into a - * byte buffer passed in by the user. This is more memory/time - * efficient than readBytes() returning a byte[] array. - *

- * Returns an int for how many bytes were read. If more bytes - * are available than can fit into the byte array, only those - * that will fit are read. - */ - public synchronized int readBytes(byte outgoing[]) { - if (bufferIndex == bufferLast) return 0; - - int length = bufferLast - bufferIndex; - if (length > outgoing.length) length = outgoing.length; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex += length; - if (bufferIndex == bufferLast) { - bufferIndex = 0; // rewind - bufferLast = 0; - } - return length; - } - - - /** - * Reads from the serial port into a buffer of bytes up to and - * including a particular character. If the character isn't in - * the serial buffer, then 'null' is returned. - */ - public synchronized byte[] readBytesUntil(int interesting) { - if (bufferIndex == bufferLast) return null; - byte what = (byte)interesting; - - int found = -1; - for (int k = bufferIndex; k < bufferLast; k++) { - if (buffer[k] == what) { - found = k; - break; - } - } - if (found == -1) return null; - - int length = found - bufferIndex + 1; - byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex = 0; // rewind - bufferLast = 0; - return outgoing; - } - - - /** - * Reads from the serial port into a buffer of bytes until a - * particular character. If the character isn't in the serial - * buffer, then 'null' is returned. - *

- * If outgoing[] is not big enough, then -1 is returned, - * and an error message is printed on the console. - * If nothing is in the buffer, zero is returned. - * If 'interesting' byte is not in the buffer, then 0 is returned. - */ - public synchronized int readBytesUntil(int interesting, byte outgoing[]) { - if (bufferIndex == bufferLast) return 0; - byte what = (byte)interesting; - - int found = -1; - for (int k = bufferIndex; k < bufferLast; k++) { - if (buffer[k] == what) { - found = k; - break; - } - } - if (found == -1) return 0; - - int length = found - bufferIndex + 1; - if (length > outgoing.length) { - System.err.println("readBytesUntil() byte buffer is" + - " too small for the " + length + - " bytes up to and including char " + interesting); - return -1; - } - //byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex += length; - if (bufferIndex == bufferLast) { - bufferIndex = 0; // rewind - bufferLast = 0; - } - return length; - } - - - /** - * Return whatever has been read from the serial port so far - * as a String. It assumes that the incoming characters are ASCII. - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public synchronized String readString() { - if (bufferIndex == bufferLast) return null; - return new String(readBytes()); - } - - - /** - * Combination of readBytesUntil and readString. See caveats in - * each function. Returns null if it still hasn't found what - * you're looking for. - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public synchronized String readStringUntil(int interesting) { - byte b[] = readBytesUntil(interesting); - if (b == null) return null; - return new String(b); - } - - - /** - * This will handle both ints, bytes and chars transparently. - */ - public void write(int what) { // will also cover char - try { - port.writeInt(what & 0xff); - } catch (SerialPortException e) { - errorMessage("write", e); - } - } - - - public void write(byte bytes[]) { - try { - port.writeBytes(bytes); - } catch (SerialPortException e) { - errorMessage("write", e); - } - } - - - /** - * Write a String to the output. Note that this doesn't account - * for Unicode (two bytes per char), nor will it send UTF8 - * characters.. It assumes that you mean to send a byte buffer - * (most often the case for networking and serial i/o) and - * will only use the bottom 8 bits of each char in the string. - * (Meaning that internally it uses String.getBytes) - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public void write(String what) { - write(what.getBytes()); - } - - public void setDTR(boolean state) { - try { - port.setDTR(state); - } catch (SerialPortException e) { - errorMessage("setDTR", e); - } - } - - public void setRTS(boolean state) { - try { - port.setRTS(state); - } catch (SerialPortException e) { - errorMessage("setRTS", e); - } - } - - static public List list() { - return Arrays.asList(SerialPortList.getPortNames()); - } - - - /** - * General error reporting, all corraled here just in case - * I think of something slightly more intelligent to do. - */ - static public void errorMessage(String where, Throwable e) { - System.err.println("Error inside Serial." + where + "()"); - e.printStackTrace(); - } -} - - - /* - class SerialMenuListener implements ItemListener { - //public SerialMenuListener() { } - - public void itemStateChanged(ItemEvent e) { - int count = serialMenu.getItemCount(); - for (int i = 0; i < count; i++) { - ((CheckboxMenuItem)serialMenu.getItem(i)).setState(false); - } - CheckboxMenuItem item = (CheckboxMenuItem)e.getSource(); - item.setState(true); - String name = item.getLabel(); - //System.out.println(item.getLabel()); - PdeBase.properties.put("serial.port", name); - //System.out.println("set to " + get("serial.port")); - } - } - */ - - - /* - protected Vector buildPortList() { - // get list of names for serial ports - // have the default port checked (if present) - Vector list = new Vector(); - - //SerialMenuListener listener = new SerialMenuListener(); - boolean problem = false; - - // if this is failing, it may be because - // lib/javax.comm.properties is missing. - // java is weird about how it searches for java.comm.properties - // so it tends to be very fragile. i.e. quotes in the CLASSPATH - // environment variable will hose things. - try { - //System.out.println("building port list"); - Enumeration portList = CommPortIdentifier.getPortIdentifiers(); - while (portList.hasMoreElements()) { - CommPortIdentifier portId = - (CommPortIdentifier) portList.nextElement(); - //System.out.println(portId); - - if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { - //if (portId.getName().equals(port)) { - String name = portId.getName(); - //CheckboxMenuItem mi = - //new CheckboxMenuItem(name, name.equals(defaultName)); - - //mi.addItemListener(listener); - //serialMenu.add(mi); - list.addElement(name); - } - } - } catch (UnsatisfiedLinkError e) { - e.printStackTrace(); - problem = true; - - } catch (Exception e) { - System.out.println("exception building serial menu"); - e.printStackTrace(); - } - - //if (serialMenu.getItemCount() == 0) { - //System.out.println("dimming serial menu"); - //serialMenu.setEnabled(false); - //} - - // only warn them if this is the first time - if (problem && PdeBase.firstTime) { - JOptionPane.showMessageDialog(this, //frame, - "Serial port support not installed.\n" + - "Check the readme for instructions\n" + - "if you need to use the serial port. ", - "Serial Port Warning", - JOptionPane.WARNING_MESSAGE); - } - return list; - } - */ - - - diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/SerialException.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/SerialException.java deleted file mode 100755 index 525c24078..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/SerialException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Copyright (c) 2007 David A. Mellis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - -public class SerialException extends Exception { - public SerialException() { - super(); - } - - public SerialException(String message) { - super(message); - } - - public SerialException(String message, Throwable cause) { - super(message, cause); - } - - public SerialException(Throwable cause) { - super(cause); - } -} diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/debug/MessageConsumer.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/debug/MessageConsumer.java deleted file mode 100755 index 5e2042943..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/debug/MessageConsumer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-06 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - - -/** - * Interface for dealing with parser/compiler output. - *

- * Different instances of MessageStream need to do different things with - * messages. In particular, a stream instance used for parsing output from - * the compiler compiler has to interpret its messages differently than one - * parsing output from the runtime. - *

- * Classes which consume messages and do something with them - * should implement this interface. - */ -public interface MessageConsumer { - - public void message(String s); - -} diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/debug/MessageSiphon.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/debug/MessageSiphon.java deleted file mode 100755 index 26901c3f4..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/debug/MessageSiphon.java +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-06 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.SocketException; - -/** - * Slurps up messages from compiler. - */ -public class MessageSiphon implements Runnable { - - private final BufferedReader streamReader; - private final MessageConsumer consumer; - - private Thread thread; - private boolean canRun; - - public MessageSiphon(InputStream stream, MessageConsumer consumer) { - this.streamReader = new BufferedReader(new InputStreamReader(stream)); - this.consumer = consumer; - this.canRun = true; - - thread = new Thread(this); - // don't set priority too low, otherwise exceptions won't - // bubble up in time (i.e. compile errors have a weird delay) - //thread.setPriority(Thread.MIN_PRIORITY); - thread.setPriority(Thread.MAX_PRIORITY - 1); - thread.start(); - } - - - public void run() { - try { - // process data until we hit EOF; this will happily block - // (effectively sleeping the thread) until new data comes in. - // when the program is finally done, null will come through. - // - String currentLine; - while (canRun && (currentLine = streamReader.readLine()) != null) { - // \n is added again because readLine() strips it out - //EditorConsole.systemOut.println("messaging in"); - consumer.message(currentLine + "\n"); - //EditorConsole.systemOut.println("messaging out"); - } - //EditorConsole.systemOut.println("messaging thread done"); - } catch (NullPointerException npe) { - // Fairly common exception during shutdown - } catch (SocketException e) { - // socket has been close while we were wainting for data. nothing to see here, move along - } catch (Exception e) { - // On Linux and sometimes on Mac OS X, a "bad file descriptor" - // message comes up when closing an applet that's run externally. - // That message just gets supressed here.. - String mess = e.getMessage(); - if ((mess != null) && - (mess.indexOf("Bad file descriptor") != -1)) { - //if (e.getMessage().indexOf("Bad file descriptor") == -1) { - //System.err.println("MessageSiphon err " + e); - //e.printStackTrace(); - } else { - e.printStackTrace(); - } - } finally { - thread = null; - } - } - - // Wait until the MessageSiphon thread is complete. - public void join() throws java.lang.InterruptedException { - // Grab a temp copy in case another thread nulls the "thread" - // member variable - Thread t = thread; - if (t != null) t.join(); - } - - public void stop() { - this.canRun = false; - } - -} diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/debug/RunnerException.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/debug/RunnerException.java deleted file mode 100755 index 0a67d1e80..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/debug/RunnerException.java +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-08 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - - -/** - * An exception with a line number attached that occurs - * during either compile time or run time. - */ -@SuppressWarnings("serial") -public class RunnerException extends Exception { - protected String message; - protected int codeIndex; - protected int codeLine; - protected int codeColumn; - protected boolean showStackTrace; - - - public RunnerException(String message) { - this(message, true); - } - - public RunnerException(String message, boolean showStackTrace) { - this(message, -1, -1, -1, showStackTrace); - } - - public RunnerException(String message, int file, int line) { - this(message, file, line, -1, true); - } - - - public RunnerException(String message, int file, int line, int column) { - this(message, file, line, column, true); - } - - - public RunnerException(String message, int file, int line, int column, - boolean showStackTrace) { - this.message = message; - this.codeIndex = file; - this.codeLine = line; - this.codeColumn = column; - this.showStackTrace = showStackTrace; - } - - - public RunnerException(Exception e) { - super(e); - this.showStackTrace = true; - } - - /** - * Override getMessage() in Throwable, so that I can set - * the message text outside the constructor. - */ - public String getMessage() { - return message; - } - - - public void setMessage(String message) { - this.message = message; - } - - - public int getCodeIndex() { - return codeIndex; - } - - - public void setCodeIndex(int index) { - codeIndex = index; - } - - - public boolean hasCodeIndex() { - return codeIndex != -1; - } - - - public int getCodeLine() { - return codeLine; - } - - - public void setCodeLine(int line) { - this.codeLine = line; - } - - - public boolean hasCodeLine() { - return codeLine != -1; - } - - - public void setCodeColumn(int column) { - this.codeColumn = column; - } - - - public int getCodeColumn() { - return codeColumn; - } - - - public void showStackTrace() { - showStackTrace = true; - } - - - public void hideStackTrace() { - showStackTrace = false; - } - - - /** - * Nix the java.lang crap out of an exception message - * because it scares the children. - *

- * This function must be static to be used with super() - * in each of the constructors above. - */ - /* - static public final String massage(String msg) { - if (msg.indexOf("java.lang.") == 0) { - //int dot = msg.lastIndexOf('.'); - msg = msg.substring("java.lang.".length()); - } - return msg; - //return (dot == -1) ? msg : msg.substring(dot+1); - } - */ - - - public void printStackTrace() { - if (showStackTrace) { - super.printStackTrace(); - } - } -} diff --git a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/helpers/ProcessUtils.java b/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/helpers/ProcessUtils.java deleted file mode 100755 index c023f5810..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/maple_loader/src/processing/app/helpers/ProcessUtils.java +++ /dev/null @@ -1,32 +0,0 @@ -package processing.app.helpers; - -//import processing.app.Base; - -import java.io.IOException; -import java.util.Map; - -import processing.app.Base; - -public class ProcessUtils { - - public static Process exec(String[] command) throws IOException { - // No problems on linux and mac - if (!Base.isWindows()) { - return Runtime.getRuntime().exec(command); - } - - // Brutal hack to workaround windows command line parsing. - // http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly - // http://msdn.microsoft.com/en-us/library/a1y7w461.aspx - // http://bugs.sun.com/view_bug.do?bug_id=6468220 - // http://bugs.sun.com/view_bug.do?bug_id=6518827 - String[] cmdLine = new String[command.length]; - for (int i = 0; i < command.length; i++) - cmdLine[i] = command[i].replace("\"", "\\\""); - - ProcessBuilder pb = new ProcessBuilder(cmdLine); - Map env = pb.environment(); - env.put("CYGWIN", "nodosfilewarning"); - return pb.start(); - } -} diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/AUTHORS b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/AUTHORS deleted file mode 100755 index d096f2205..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/AUTHORS +++ /dev/null @@ -1,19 +0,0 @@ -Authors ordered by first contribution. - -Geoffrey McRae -Bret Olmsted -Tormod Volden -Jakob Malm -Reuben Dowle -Matthias Kubisch -Paul Fertser -Daniel Strnad -Jérémie Rapin -Christian Pointner -Mats Erik Andersson -Alexey Borovik -Antonio Borneo -Armin van der Togt -Brian Silverman -Georg Hofmann -Luis Rodrigues diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/Android.mk b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/Android.mk deleted file mode 100755 index 7be3d0018..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/Android.mk +++ /dev/null @@ -1,20 +0,0 @@ -TOP_LOCAL_PATH := $(call my-dir) - -include $(call all-named-subdir-makefiles, parsers) - -LOCAL_PATH := $(TOP_LOCAL_PATH) - -include $(CLEAR_VARS) -LOCAL_MODULE := stm32flash -LOCAL_SRC_FILES := \ - dev_table.c \ - i2c.c \ - init.c \ - main.c \ - port.c \ - serial_common.c \ - serial_platform.c \ - stm32.c \ - utils.c -LOCAL_STATIC_LIBRARIES := libparsers -include $(BUILD_EXECUTABLE) diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/HOWTO b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/HOWTO deleted file mode 100755 index d8f32eb04..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/HOWTO +++ /dev/null @@ -1,35 +0,0 @@ -Add new interfaces: -===================================================================== -Current version 0.4 supports the following interfaces: -- UART Windows (either "COMn" and "\\.\COMn"); -- UART posix/Linux (e.g. "/dev/ttyUSB0"); -- I2C Linux through standard driver "i2c-dev" (e.g. "/dev/i2c-n"). - -Starting from version 0.4, the back-end of stm32flash is modular and -ready to be expanded to support new interfaces. -I'm planning adding SPI on Linux through standard driver "spidev". -You are invited to contribute with more interfaces. - -To add a new interface you need to add a new file, populate the struct -port_interface (check at the end of files i2c.c, serial_posix.c and -serial_w32.c) and provide the relative functions to operate on the -interface: open/close, read/write, get_cfg_str and the optional gpio. -The include the new drive in Makefile and register the new struct -port_interface in file port.c in struct port_interface *ports[]. - -There are several USB-I2C adapter in the market, each providing its -own libraries to communicate with the I2C bus. -Could be interesting to provide as back-end a bridge between stm32flash -and such libraries (I have no plan on this item). - - -Add new STM32 devices: -===================================================================== -Add a new line in file dev_table.c, in table devices[]. -The fields of the table are listed in stm32.h, struct stm32_dev. - - -Cross compile on Linux host for Windows target with MinGW: -===================================================================== -I'm using a 64 bit Arch Linux machines, and I usually run: - make CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/I2C.txt b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/I2C.txt deleted file mode 100755 index 4c05ff62d..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/I2C.txt +++ /dev/null @@ -1,94 +0,0 @@ -About I2C back-end communication in stm32flash -========================================================================== - -Starting from version v0.4, beside the serial communication port, -stm32flash adds support for I2C port to talk with STM32 bootloader. - -The current I2C back-end supports only the API provided by Linux kernel -driver "i2c-dev", so only I2C controllers with Linux kernel driver can be -used. -In Linux source code, most of the drivers for I2C and SMBUS controllers -are in - ./drivers/i2c/busses/ -Only I2C is supported by STM32 bootloader, so check the section below -about SMBUS. -No I2C support for Windows is available in stm32flash v0.4. - -Thanks to the new modular back-end, stm32flash can be easily extended to -support new back-ends and API. Check HOWTO file in stm32flash source code -for details. - -In the market there are several USB-to-I2C dongles; most of them are not -supported by kernel drivers. Manufacturer provide proprietary userspace -libraries using not standardized API. -These API and dongles could be supported in feature versions. - -There are currently 3 versions of STM32 bootloader for I2C communications: -- v1.0 using I2C clock stretching synchronization between host and STM32; -- v1.1 superset of v1.0, adds non stretching commands; -- v1.2 superset of v1.1, adds CRC command and compatibility with i2cdetect. -Details in ST application note AN2606. -All the bootloaders above are tested and working with stm32flash. - - -SMBUS controllers -========================================================================== - -Almost 50% of the drivers in Linux source code folder - ./drivers/i2c/busses/ -are for controllers that "only" support SMBUS protocol. They can NOT -operate with STM32 bootloader. -To identify if your controller supports I2C, use command: - i2cdetect -F n -where "n" is the number of the I2C interface (e.g. n=3 for "/dev/i2c-3"). -Controllers that supports I2C will report - I2C yes -Controller that support both I2C and SMBUS are ok. - -If you are interested on details about SMBUS protocol, you can download -the current specs from - http://smbus.org/specs/smbus20.pdf -and you can read the files in Linux source code - ./Documentation/i2c/i2c-protocol - ./Documentation/i2c/smbus-protocol - - -About bootloader v1.0 -========================================================================== - -Version v1.0 can have issues with some I2C controllers due to use of clock -stretching during commands that require long operations, like flash erase -and programming. - -Clock stretching is a technique to synchronize host and I2C device. When -I2C device wants to force a delay in the communication, it push "low" the -I2C clock; the I2C controller detects it and waits until I2C clock returns -"high". -Most I2C controllers set a "timeout" for clock stretching, ranging from -few milli-seconds to seconds depending on specific HW or SW driver. - -It is possible that the timeout in your I2C controller is smaller than the -delay required for flash erase or programming. In this case the I2C -controller will timeout and report error to stm32flash. -There is no possibility for stm32flash to retry, so it can only signal the -error and exit. - -To by-pass the issue with bootloader v1.0 you can modify the kernel driver -of your I2C controller. Not an easy job, since every controller has its own -way to handle the timeout. - -In my case I'm using the I2C controller integrated in the VGA port of my -laptop HP EliteBook 8460p. I built the 0.25$ VGA-to-I2C adapter reported in - http://www.paintyourdragon.com/?p=43 -To change the timeout of the I2C controller I had to modify the kernel file - drivers/gpu/drm/radeon/radeon_i2c.c -line 969 -- i2c->bit.timeout = usecs_to_jiffies(2200); /* from VESA */ -+ i2c->bit.timeout = msecs_to_jiffies(5000); /* 5s for STM32 */ -and recompile it. -Then - $> modprobe i2c-dev - $> chmod 666 /dev/i2c-7 - #> stm32flash -a 0x39 /dev/i2c-7 - -2014-09-16 Antonio Borneo diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/Makefile b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/Makefile deleted file mode 100755 index 0328d5588..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -PREFIX = /usr/local -CFLAGS += -Wall -g - -INSTALL = install - -OBJS = dev_table.o \ - i2c.o \ - init.o \ - main.o \ - port.o \ - serial_common.o \ - serial_platform.o \ - stm32.o \ - utils.o - -LIBOBJS = parsers/parsers.a - -all: stm32flash - -serial_platform.o: serial_posix.c serial_w32.c - -parsers/parsers.a: - cd parsers && $(MAKE) parsers.a - -stm32flash: $(OBJS) $(LIBOBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBOBJS) - -clean: - rm -f $(OBJS) stm32flash - cd parsers && $(MAKE) $@ - -install: all - $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin - $(INSTALL) -m 755 stm32flash $(DESTDIR)$(PREFIX)/bin - $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/man/man1 - $(INSTALL) -m 644 stm32flash.1 $(DESTDIR)$(PREFIX)/share/man/man1 - -.PHONY: all clean install diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/TODO b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/TODO deleted file mode 100755 index 41df614ff..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/TODO +++ /dev/null @@ -1,7 +0,0 @@ - -stm32: -- Add support for variable page size - -AUTHORS: -- Add contributors from Geoffrey's commits - diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/dev_table.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/dev_table.c deleted file mode 100755 index 399cd9d08..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/dev_table.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "stm32.h" - -/* - * Device table, corresponds to the "Bootloader device-dependant parameters" - * table in ST document AN2606. - * Note that the option bytes upper range is inclusive! - */ -const stm32_dev_t devices[] = { - /* F0 */ - {0x440, "STM32F051xx" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 4, 1024, 0x1FFFF800, 0x1FFFF80B, 0x1FFFEC00, 0x1FFFF800}, - {0x444, "STM32F030/F031" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 4, 1024, 0x1FFFF800, 0x1FFFF80B, 0x1FFFEC00, 0x1FFFF800}, - {0x445, "STM32F042xx" , 0x20001800, 0x20001800, 0x08000000, 0x08008000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC400, 0x1FFFF800}, - {0x448, "STM32F072xx" , 0x20001800, 0x20004000, 0x08000000, 0x08020000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC800, 0x1FFFF800}, - /* F1 */ - {0x412, "Low-density" , 0x20000200, 0x20002800, 0x08000000, 0x08008000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x410, "Medium-density" , 0x20000200, 0x20005000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x414, "High-density" , 0x20000200, 0x20010000, 0x08000000, 0x08080000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x420, "Medium-density VL" , 0x20000200, 0x20002000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x428, "High-density VL" , 0x20000200, 0x20008000, 0x08000000, 0x08080000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x418, "Connectivity line" , 0x20001000, 0x20010000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFB000, 0x1FFFF800}, - {0x430, "XL-density" , 0x20000800, 0x20018000, 0x08000000, 0x08100000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFE000, 0x1FFFF800}, - /* Note that F2 and F4 devices have sectors of different page sizes - and only the first sectors (of one page size) are included here */ - /* F2 */ - {0x411, "STM32F2xx" , 0x20002000, 0x20020000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77DF}, - /* F3 */ - {0x432, "STM32F373/8" , 0x20001400, 0x20008000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x422, "F302xB/303xB/358" , 0x20001400, 0x20010000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x439, "STM32F302x4(6/8)" , 0x20001800, 0x20004000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x438, "F303x4/334/328" , 0x20001800, 0x20003000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - /* F4 */ - {0x413, "STM32F40/1" , 0x20002000, 0x20020000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77DF}, - /* 0x419 is also used for STM32F429/39 but with other bootloader ID... */ - {0x419, "STM32F427/37" , 0x20002000, 0x20030000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - {0x423, "STM32F401xB(C)" , 0x20003000, 0x20010000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - {0x433, "STM32F401xD(E)" , 0x20003000, 0x20018000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - /* L0 */ - {0x417, "L05xxx/06xxx" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 32, 128, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - /* L1 */ - {0x416, "L1xxx6(8/B)" , 0x20000800, 0x20004000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - {0x429, "L1xxx6(8/B)A" , 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - {0x427, "L1xxxC" , 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF02000}, - {0x436, "L1xxxD" , 0x20001000, 0x2000C000, 0x08000000, 0x08060000, 16, 256, 0x1ff80000, 0x1ff8000F, 0x1FF00000, 0x1FF02000}, - {0x437, "L1xxxE" , 0x20001000, 0x20014000, 0x08000000, 0x08060000, 16, 256, 0x1ff80000, 0x1ff8000F, 0x1FF00000, 0x1FF02000}, - /* These are not (yet) in AN2606: */ - {0x641, "Medium_Density PL" , 0x20000200, 0x00005000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x9a8, "STM32W-128K" , 0x20000200, 0x20002000, 0x08000000, 0x08020000, 1, 1024, 0, 0, 0, 0}, - {0x9b0, "STM32W-256K" , 0x20000200, 0x20004000, 0x08000000, 0x08040000, 1, 2048, 0, 0, 0, 0}, - {0x0} -}; diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/gpl-2.0.txt b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/gpl-2.0.txt deleted file mode 100755 index d159169d1..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/gpl-2.0.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/i2c.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/i2c.c deleted file mode 100755 index 10e6bb15a..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/i2c.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - - -#if !defined(__linux__) - -static port_err_t i2c_open(struct port_interface *port, - struct port_options *ops) -{ - return PORT_ERR_NODEV; -} - -struct port_interface port_i2c = { - .name = "i2c", - .open = i2c_open, -}; - -#else - -#ifdef __ANDROID__ -#define I2C_SLAVE 0x0703 /* Use this slave address */ -#define I2C_FUNCS 0x0705 /* Get the adapter functionality mask */ -/* To determine what functionality is present */ -#define I2C_FUNC_I2C 0x00000001 -#else -#include -#include -#endif - -#include - -struct i2c_priv { - int fd; - int addr; -}; - -static port_err_t i2c_open(struct port_interface *port, - struct port_options *ops) -{ - struct i2c_priv *h; - int fd, addr, ret; - unsigned long funcs; - - /* 1. check device name match */ - if (strncmp(ops->device, "/dev/i2c-", strlen("/dev/i2c-"))) - return PORT_ERR_NODEV; - - /* 2. check options */ - addr = ops->bus_addr; - if (addr < 0x03 || addr > 0x77) { - fprintf(stderr, "I2C address out of range [0x03-0x77]\n"); - return PORT_ERR_UNKNOWN; - } - - /* 3. open it */ - h = calloc(sizeof(*h), 1); - if (h == NULL) { - fprintf(stderr, "End of memory\n"); - return PORT_ERR_UNKNOWN; - } - fd = open(ops->device, O_RDWR); - if (fd < 0) { - fprintf(stderr, "Unable to open special file \"%s\"\n", - ops->device); - free(h); - return PORT_ERR_UNKNOWN; - } - - /* 3.5. Check capabilities */ - ret = ioctl(fd, I2C_FUNCS, &funcs); - if (ret < 0) { - fprintf(stderr, "I2C ioctl(funcs) error %d\n", errno); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - if ((funcs & I2C_FUNC_I2C) == 0) { - fprintf(stderr, "Error: controller is not I2C, only SMBUS.\n"); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - - /* 4. set options */ - ret = ioctl(fd, I2C_SLAVE, addr); - if (ret < 0) { - fprintf(stderr, "I2C ioctl(slave) error %d\n", errno); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - - h->fd = fd; - h->addr = addr; - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t i2c_close(struct port_interface *port) -{ - struct i2c_priv *h; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - close(h->fd); - free(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t i2c_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - struct i2c_priv *h; - int ret; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - ret = read(h->fd, buf, nbyte); - if (ret != nbyte) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; -} - -static port_err_t i2c_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - struct i2c_priv *h; - int ret; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - ret = write(h->fd, buf, nbyte); - if (ret != nbyte) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; -} - -static port_err_t i2c_gpio(struct port_interface *port, serial_gpio_t n, - int level) -{ - return PORT_ERR_OK; -} - -static const char *i2c_get_cfg_str(struct port_interface *port) -{ - struct i2c_priv *h; - static char str[11]; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return "INVALID"; - snprintf(str, sizeof(str), "addr 0x%2x", h->addr); - return str; -} - -static struct varlen_cmd i2c_cmd_get_reply[] = { - {0x10, 11}, - {0x11, 17}, - {0x12, 18}, - { /* sentinel */ } -}; - -struct port_interface port_i2c = { - .name = "i2c", - .flags = PORT_STRETCH_W, - .open = i2c_open, - .close = i2c_close, - .read = i2c_read, - .write = i2c_write, - .gpio = i2c_gpio, - .cmd_get_reply = i2c_cmd_get_reply, - .get_cfg_str = i2c_get_cfg_str, -}; - -#endif diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/init.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/init.c deleted file mode 100755 index 77a571bd8..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/init.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include "init.h" -#include "serial.h" -#include "stm32.h" -#include "port.h" - -struct gpio_list { - struct gpio_list *next; - int gpio; -}; - - -static int write_to(const char *filename, const char *value) -{ - int fd, ret; - - fd = open(filename, O_WRONLY); - if (fd < 0) { - fprintf(stderr, "Cannot open file \"%s\"\n", filename); - return 0; - } - ret = write(fd, value, strlen(value)); - if (ret < 0) { - fprintf(stderr, "Error writing in file \"%s\"\n", filename); - close(fd); - return 0; - } - close(fd); - return 1; -} - -#if !defined(__linux__) -static int drive_gpio(int n, int level, struct gpio_list **gpio_to_release) -{ - fprintf(stderr, "GPIO control only available in Linux\n"); - return 0; -} -#else -static int drive_gpio(int n, int level, struct gpio_list **gpio_to_release) -{ - char num[16]; /* sized to carry MAX_INT */ - char file[48]; /* sized to carry longest filename */ - struct stat buf; - struct gpio_list *new; - int ret; - - sprintf(file, "/sys/class/gpio/gpio%d/direction", n); - ret = stat(file, &buf); - if (ret) { - /* file miss, GPIO not exported yet */ - sprintf(num, "%d", n); - ret = write_to("/sys/class/gpio/export", num); - if (!ret) - return 0; - ret = stat(file, &buf); - if (ret) { - fprintf(stderr, "GPIO %d not available\n", n); - return 0; - } - new = (struct gpio_list *)malloc(sizeof(struct gpio_list)); - if (new == NULL) { - fprintf(stderr, "Out of memory\n"); - return 0; - } - new->gpio = n; - new->next = *gpio_to_release; - *gpio_to_release = new; - } - - return write_to(file, level ? "high" : "low"); -} -#endif - -static int release_gpio(int n) -{ - char num[16]; /* sized to carry MAX_INT */ - - sprintf(num, "%d", n); - return write_to("/sys/class/gpio/unexport", num); -} - -static int gpio_sequence(struct port_interface *port, const char *s, size_t l) -{ - struct gpio_list *gpio_to_release = NULL, *to_free; - int ret, level, gpio; - - ret = 1; - while (ret == 1 && *s && l > 0) { - if (*s == '-') { - level = 0; - s++; - l--; - } else - level = 1; - - if (isdigit(*s)) { - gpio = atoi(s); - while (isdigit(*s)) { - s++; - l--; - } - } else if (!strncmp(s, "rts", 3)) { - gpio = -GPIO_RTS; - s += 3; - l -= 3; - } else if (!strncmp(s, "dtr", 3)) { - gpio = -GPIO_DTR; - s += 3; - l -= 3; - } else if (!strncmp(s, "brk", 3)) { - gpio = -GPIO_BRK; - s += 3; - l -= 3; - } else { - fprintf(stderr, "Character \'%c\' is not a digit\n", *s); - ret = 0; - break; - } - - if (*s && (l > 0)) { - if (*s == ',') { - s++; - l--; - } else { - fprintf(stderr, "Character \'%c\' is not a separator\n", *s); - ret = 0; - break; - } - } - if (gpio < 0) - ret = (port->gpio(port, -gpio, level) == PORT_ERR_OK); - else - ret = drive_gpio(gpio, level, &gpio_to_release); - usleep(100000); - } - - while (gpio_to_release) { - release_gpio(gpio_to_release->gpio); - to_free = gpio_to_release; - gpio_to_release = gpio_to_release->next; - free(to_free); - } - usleep(500000); - return ret; -} - -static int gpio_bl_entry(struct port_interface *port, const char *seq) -{ - char *s; - - if (seq == NULL || seq[0] == ':') - return 1; - - s = strchr(seq, ':'); - if (s == NULL) - return gpio_sequence(port, seq, strlen(seq)); - - return gpio_sequence(port, seq, s - seq); -} - -static int gpio_bl_exit(struct port_interface *port, const char *seq) -{ - char *s; - - if (seq == NULL) - return 1; - - s = strchr(seq, ':'); - if (s == NULL || s[1] == '\0') - return 1; - - return gpio_sequence(port, s + 1, strlen(s + 1)); -} - -int init_bl_entry(struct port_interface *port, const char *seq) -{ - if (seq) - return gpio_bl_entry(port, seq); - - return 1; -} - -int init_bl_exit(stm32_t *stm, struct port_interface *port, const char *seq) -{ - if (seq) - return gpio_bl_exit(port, seq); - - if (stm32_reset_device(stm) != STM32_ERR_OK) - return 0; - return 1; -} diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/init.h b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/init.h deleted file mode 100755 index 6075b519b..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/init.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _INIT_H -#define _INIT_H - -#include "stm32.h" -#include "port.h" - -int init_bl_entry(struct port_interface *port, const char *seq); -int init_bl_exit(stm32_t *stm, struct port_interface *port, const char *seq); - -#endif diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/main.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/main.c deleted file mode 100755 index f081d6131..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/main.c +++ /dev/null @@ -1,774 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright 2010 Geoffrey McRae - Copyright 2011 Steve Markgraf - Copyright 2012 Tormod Volden - Copyright 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "init.h" -#include "utils.h" -#include "serial.h" -#include "stm32.h" -#include "parsers/parser.h" -#include "port.h" - -#include "parsers/binary.h" -#include "parsers/hex.h" - -#define VERSION "Arduino_STM32_0.9" - -/* device globals */ -stm32_t *stm = NULL; - -void *p_st = NULL; -parser_t *parser = NULL; - -/* settings */ -struct port_options port_opts = { - .device = NULL, - .baudRate = SERIAL_BAUD_57600, - .serial_mode = "8e1", - .bus_addr = 0, - .rx_frame_max = STM32_MAX_RX_FRAME, - .tx_frame_max = STM32_MAX_TX_FRAME, -}; -int rd = 0; -int wr = 0; -int wu = 0; -int rp = 0; -int ur = 0; -int eraseOnly = 0; -int crc = 0; -int npages = 0; -int spage = 0; -int no_erase = 0; -char verify = 0; -int retry = 10; -char exec_flag = 0; -uint32_t execute = 0; -char init_flag = 1; -char force_binary = 0; -char reset_flag = 0; -char *filename; -char *gpio_seq = NULL; -uint32_t start_addr = 0; -uint32_t readwrite_len = 0; - -/* functions */ -int parse_options(int argc, char *argv[]); -void show_help(char *name); - -static int is_addr_in_ram(uint32_t addr) -{ - return addr >= stm->dev->ram_start && addr < stm->dev->ram_end; -} - -static int is_addr_in_flash(uint32_t addr) -{ - return addr >= stm->dev->fl_start && addr < stm->dev->fl_end; -} - -static int flash_addr_to_page_floor(uint32_t addr) -{ - if (!is_addr_in_flash(addr)) - return 0; - - return (addr - stm->dev->fl_start) / stm->dev->fl_ps; -} - -static int flash_addr_to_page_ceil(uint32_t addr) -{ - if (!(addr >= stm->dev->fl_start && addr <= stm->dev->fl_end)) - return 0; - - return (addr + stm->dev->fl_ps - 1 - stm->dev->fl_start) - / stm->dev->fl_ps; -} - -static uint32_t flash_page_to_addr(int page) -{ - return stm->dev->fl_start + page * stm->dev->fl_ps; -} - -int main(int argc, char* argv[]) { - struct port_interface *port = NULL; - int ret = 1; - stm32_err_t s_err; - parser_err_t perr; - FILE *diag = stdout; - - fprintf(diag, "stm32flash " VERSION "\n\n"); - fprintf(diag, "http://github.com/rogerclarkmelbourne/arduino_stm32\n\n"); - if (parse_options(argc, argv) != 0) - goto close; - - if (rd && filename[0] == '-') { - diag = stderr; - } - - if (wr) { - /* first try hex */ - if (!force_binary) { - parser = &PARSER_HEX; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - } - - if (force_binary || (perr = parser->open(p_st, filename, 0)) != PARSER_ERR_OK) { - if (force_binary || perr == PARSER_ERR_INVALID_FILE) { - if (!force_binary) { - parser->close(p_st); - p_st = NULL; - } - - /* now try binary */ - parser = &PARSER_BINARY; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - perr = parser->open(p_st, filename, 0); - } - - /* if still have an error, fail */ - if (perr != PARSER_ERR_OK) { - fprintf(stderr, "%s ERROR: %s\n", parser->name, parser_errstr(perr)); - if (perr == PARSER_ERR_SYSTEM) perror(filename); - goto close; - } - } - - fprintf(diag, "Using Parser : %s\n", parser->name); - } else { - parser = &PARSER_BINARY; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - } - - if (port_open(&port_opts, &port) != PORT_ERR_OK) { - fprintf(stderr, "Failed to open port: %s\n", port_opts.device); - goto close; - } - - fprintf(diag, "Interface %s: %s\n", port->name, port->get_cfg_str(port)); - if (init_flag && init_bl_entry(port, gpio_seq) == 0) - goto close; - stm = stm32_init(port, init_flag); - if (!stm) - goto close; - - fprintf(diag, "Version : 0x%02x\n", stm->bl_version); - if (port->flags & PORT_GVR_ETX) { - fprintf(diag, "Option 1 : 0x%02x\n", stm->option1); - fprintf(diag, "Option 2 : 0x%02x\n", stm->option2); - } - fprintf(diag, "Device ID : 0x%04x (%s)\n", stm->pid, stm->dev->name); - fprintf(diag, "- RAM : %dKiB (%db reserved by bootloader)\n", (stm->dev->ram_end - 0x20000000) / 1024, stm->dev->ram_start - 0x20000000); - fprintf(diag, "- Flash : %dKiB (sector size: %dx%d)\n", (stm->dev->fl_end - stm->dev->fl_start ) / 1024, stm->dev->fl_pps, stm->dev->fl_ps); - fprintf(diag, "- Option RAM : %db\n", stm->dev->opt_end - stm->dev->opt_start + 1); - fprintf(diag, "- System RAM : %dKiB\n", (stm->dev->mem_end - stm->dev->mem_start) / 1024); - - uint8_t buffer[256]; - uint32_t addr, start, end; - unsigned int len; - int failed = 0; - int first_page, num_pages; - - /* - * Cleanup addresses: - * - * Starting from options - * start_addr, readwrite_len, spage, npages - * and using device memory size, compute - * start, end, first_page, num_pages - */ - if (start_addr || readwrite_len) { - start = start_addr; - - if (is_addr_in_flash(start)) - end = stm->dev->fl_end; - else { - no_erase = 1; - if (is_addr_in_ram(start)) - end = stm->dev->ram_end; - else - end = start + sizeof(uint32_t); - } - - if (readwrite_len && (end > start + readwrite_len)) - end = start + readwrite_len; - - first_page = flash_addr_to_page_floor(start); - if (!first_page && end == stm->dev->fl_end) - num_pages = 0xff; /* mass erase */ - else - num_pages = flash_addr_to_page_ceil(end) - first_page; - } else if (!spage && !npages) { - start = stm->dev->fl_start; - end = stm->dev->fl_end; - first_page = 0; - num_pages = 0xff; /* mass erase */ - } else { - first_page = spage; - start = flash_page_to_addr(first_page); - if (start > stm->dev->fl_end) { - fprintf(stderr, "Address range exceeds flash size.\n"); - goto close; - } - - if (npages) { - num_pages = npages; - end = flash_page_to_addr(first_page + num_pages); - if (end > stm->dev->fl_end) - end = stm->dev->fl_end; - } else { - end = stm->dev->fl_end; - num_pages = flash_addr_to_page_ceil(end) - first_page; - } - - if (!first_page && end == stm->dev->fl_end) - num_pages = 0xff; /* mass erase */ - } - - if (rd) { - unsigned int max_len = port_opts.rx_frame_max; - - fprintf(diag, "Memory read\n"); - - perr = parser->open(p_st, filename, 1); - if (perr != PARSER_ERR_OK) { - fprintf(stderr, "%s ERROR: %s\n", parser->name, parser_errstr(perr)); - if (perr == PARSER_ERR_SYSTEM) - perror(filename); - goto close; - } - - fflush(diag); - addr = start; - while(addr < end) { - uint32_t left = end - addr; - len = max_len > left ? left : max_len; - s_err = stm32_read_memory(stm, addr, buffer, len); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read memory at address 0x%08x, target write-protected?\n", addr); - goto close; - } - if (parser->write(p_st, buffer, len) != PARSER_ERR_OK) - { - fprintf(stderr, "Failed to write data to file\n"); - goto close; - } - addr += len; - - fprintf(diag, - "\rRead address 0x%08x (%.2f%%) ", - addr, - (100.0f / (float)(end - start)) * (float)(addr - start) - ); - fflush(diag); - } - fprintf(diag, "Done.\n"); - ret = 0; - goto close; - } else if (rp) { - fprintf(stdout, "Read-Protecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_readprot_memory(stm); - fprintf(stdout, "Done.\n"); - } else if (ur) { - fprintf(stdout, "Read-UnProtecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_runprot_memory(stm); - fprintf(stdout, "Done.\n"); - } else if (eraseOnly) { - ret = 0; - fprintf(stdout, "Erasing flash\n"); - - if (num_pages != 0xff && - (start != flash_page_to_addr(first_page) - || end != flash_page_to_addr(first_page + num_pages))) { - fprintf(stderr, "Specified start & length are invalid (must be page aligned)\n"); - ret = 1; - goto close; - } - - s_err = stm32_erase_memory(stm, first_page, num_pages); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to erase memory\n"); - ret = 1; - goto close; - } - } else if (wu) { - fprintf(diag, "Write-unprotecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_wunprot_memory(stm); - fprintf(diag, "Done.\n"); - - } else if (wr) { - fprintf(diag, "Write to memory\n"); - - off_t offset = 0; - ssize_t r; - unsigned int size; - unsigned int max_wlen, max_rlen; - - max_wlen = port_opts.tx_frame_max - 2; /* skip len and crc */ - max_wlen &= ~3; /* 32 bit aligned */ - - max_rlen = port_opts.rx_frame_max; - max_rlen = max_rlen < max_wlen ? max_rlen : max_wlen; - - /* Assume data from stdin is whole device */ - if (filename[0] == '-' && filename[1] == '\0') - size = end - start; - else - size = parser->size(p_st); - - // TODO: It is possible to write to non-page boundaries, by reading out flash - // from partial pages and combining with the input data - // if ((start % stm->dev->fl_ps) != 0 || (end % stm->dev->fl_ps) != 0) { - // fprintf(stderr, "Specified start & length are invalid (must be page aligned)\n"); - // goto close; - // } - - // TODO: If writes are not page aligned, we should probably read out existing flash - // contents first, so it can be preserved and combined with new data - if (!no_erase && num_pages) { - fprintf(diag, "Erasing memory\n"); - s_err = stm32_erase_memory(stm, first_page, num_pages); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to erase memory\n"); - goto close; - } - } - - fflush(diag); - addr = start; - while(addr < end && offset < size) { - uint32_t left = end - addr; - len = max_wlen > left ? left : max_wlen; - len = len > size - offset ? size - offset : len; - - if (parser->read(p_st, buffer, &len) != PARSER_ERR_OK) - goto close; - - if (len == 0) { - if (filename[0] == '-') { - break; - } else { - fprintf(stderr, "Failed to read input file\n"); - goto close; - } - } - - again: - s_err = stm32_write_memory(stm, addr, buffer, len); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to write memory at address 0x%08x\n", addr); - goto close; - } - - if (verify) { - uint8_t compare[len]; - unsigned int offset, rlen; - - offset = 0; - while (offset < len) { - rlen = len - offset; - rlen = rlen < max_rlen ? rlen : max_rlen; - s_err = stm32_read_memory(stm, addr + offset, compare + offset, rlen); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read memory at address 0x%08x\n", addr + offset); - goto close; - } - offset += rlen; - } - - for(r = 0; r < len; ++r) - if (buffer[r] != compare[r]) { - if (failed == retry) { - fprintf(stderr, "Failed to verify at address 0x%08x, expected 0x%02x and found 0x%02x\n", - (uint32_t)(addr + r), - buffer [r], - compare[r] - ); - goto close; - } - ++failed; - goto again; - } - - failed = 0; - } - - addr += len; - offset += len; - - fprintf(diag, - "\rWrote %saddress 0x%08x (%.2f%%) ", - verify ? "and verified " : "", - addr, - (100.0f / size) * offset - ); - fflush(diag); - - } - - fprintf(diag, "Done.\n"); - ret = 0; - goto close; - } else if (crc) { - uint32_t crc_val = 0; - - fprintf(diag, "CRC computation\n"); - - s_err = stm32_crc_wrapper(stm, start, end - start, &crc_val); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read CRC\n"); - goto close; - } - fprintf(diag, "CRC(0x%08x-0x%08x) = 0x%08x\n", start, end, - crc_val); - ret = 0; - goto close; - } else - ret = 0; - -close: - if (stm && exec_flag && ret == 0) { - if (execute == 0) - execute = stm->dev->fl_start; - - fprintf(diag, "\nStarting execution at address 0x%08x... ", execute); - fflush(diag); - if (stm32_go(stm, execute) == STM32_ERR_OK) { - reset_flag = 0; - fprintf(diag, "done.\n"); - } else - fprintf(diag, "failed.\n"); - } - - if (stm && reset_flag) { - fprintf(diag, "\nResetting device... "); - fflush(diag); - if (init_bl_exit(stm, port, gpio_seq)) - fprintf(diag, "done.\n"); - else fprintf(diag, "failed.\n"); - } - - if (p_st ) parser->close(p_st); - if (stm ) stm32_close (stm); - if (port) - port->close(port); - - fprintf(diag, "\n"); - return ret; -} - -int parse_options(int argc, char *argv[]) -{ - int c; - char *pLen; - - while ((c = getopt(argc, argv, "a:b:m:r:w:e:vn:g:jkfcChuos:S:F:i:R")) != -1) { - switch(c) { - case 'a': - port_opts.bus_addr = strtoul(optarg, NULL, 0); - break; - - case 'b': - port_opts.baudRate = serial_get_baud(strtoul(optarg, NULL, 0)); - if (port_opts.baudRate == SERIAL_BAUD_INVALID) { - serial_baud_t baudrate; - fprintf(stderr, "Invalid baud rate, valid options are:\n"); - for (baudrate = SERIAL_BAUD_1200; baudrate != SERIAL_BAUD_INVALID; ++baudrate) - fprintf(stderr, " %d\n", serial_get_baud_int(baudrate)); - return 1; - } - break; - - case 'm': - if (strlen(optarg) != 3 - || serial_get_bits(optarg) == SERIAL_BITS_INVALID - || serial_get_parity(optarg) == SERIAL_PARITY_INVALID - || serial_get_stopbit(optarg) == SERIAL_STOPBIT_INVALID) { - fprintf(stderr, "Invalid serial mode\n"); - return 1; - } - port_opts.serial_mode = optarg; - break; - - case 'r': - case 'w': - rd = rd || c == 'r'; - wr = wr || c == 'w'; - if (rd && wr) { - fprintf(stderr, "ERROR: Invalid options, can't read & write at the same time\n"); - return 1; - } - filename = optarg; - if (filename[0] == '-') { - force_binary = 1; - } - break; - case 'e': - if (readwrite_len || start_addr) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } - npages = strtoul(optarg, NULL, 0); - if (npages > 0xFF || npages < 0) { - fprintf(stderr, "ERROR: You need to specify a page count between 0 and 255"); - return 1; - } - if (!npages) - no_erase = 1; - break; - case 'u': - wu = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't write unprotect and read/write at the same time\n"); - return 1; - } - break; - - case 'j': - rp = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't read protect and read/write at the same time\n"); - return 1; - } - break; - - case 'k': - ur = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't read unprotect and read/write at the same time\n"); - return 1; - } - break; - - case 'o': - eraseOnly = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't erase-only and read/write at the same time\n"); - return 1; - } - break; - - case 'v': - verify = 1; - break; - - case 'n': - retry = strtoul(optarg, NULL, 0); - break; - - case 'g': - exec_flag = 1; - execute = strtoul(optarg, NULL, 0); - if (execute % 4 != 0) { - fprintf(stderr, "ERROR: Execution address must be word-aligned\n"); - return 1; - } - break; - case 's': - if (readwrite_len || start_addr) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } - spage = strtoul(optarg, NULL, 0); - break; - case 'S': - if (spage || npages) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } else { - start_addr = strtoul(optarg, &pLen, 0); - if (*pLen == ':') { - pLen++; - readwrite_len = strtoul(pLen, NULL, 0); - if (readwrite_len == 0) { - fprintf(stderr, "ERROR: Invalid options, can't specify zero length\n"); - return 1; - } - } - } - break; - case 'F': - port_opts.rx_frame_max = strtoul(optarg, &pLen, 0); - if (*pLen == ':') { - pLen++; - port_opts.tx_frame_max = strtoul(pLen, NULL, 0); - } - if (port_opts.rx_frame_max < 0 - || port_opts.tx_frame_max < 0) { - fprintf(stderr, "ERROR: Invalid negative value for option -F\n"); - return 1; - } - if (port_opts.rx_frame_max == 0) - port_opts.rx_frame_max = STM32_MAX_RX_FRAME; - if (port_opts.tx_frame_max == 0) - port_opts.tx_frame_max = STM32_MAX_TX_FRAME; - if (port_opts.rx_frame_max < 20 - || port_opts.tx_frame_max < 5) { - fprintf(stderr, "ERROR: current code cannot work with small frames.\n"); - fprintf(stderr, "min(RX) = 20, min(TX) = 5\n"); - return 1; - } - if (port_opts.rx_frame_max > STM32_MAX_RX_FRAME) { - fprintf(stderr, "WARNING: Ignore RX length in option -F\n"); - port_opts.rx_frame_max = STM32_MAX_RX_FRAME; - } - if (port_opts.tx_frame_max > STM32_MAX_TX_FRAME) { - fprintf(stderr, "WARNING: Ignore TX length in option -F\n"); - port_opts.tx_frame_max = STM32_MAX_TX_FRAME; - } - break; - case 'f': - force_binary = 1; - break; - - case 'c': - init_flag = 0; - break; - - case 'h': - show_help(argv[0]); - exit(0); - - case 'i': - gpio_seq = optarg; - break; - - case 'R': - reset_flag = 1; - break; - - case 'C': - crc = 1; - break; - } - } - - for (c = optind; c < argc; ++c) { - if (port_opts.device) { - fprintf(stderr, "ERROR: Invalid parameter specified\n"); - show_help(argv[0]); - return 1; - } - port_opts.device = argv[c]; - } - - if (port_opts.device == NULL) { - fprintf(stderr, "ERROR: Device not specified\n"); - show_help(argv[0]); - return 1; - } - - if (!wr && verify) { - fprintf(stderr, "ERROR: Invalid usage, -v is only valid when writing\n"); - show_help(argv[0]); - return 1; - } - - return 0; -} - -void show_help(char *name) { - fprintf(stderr, - "Usage: %s [-bvngfhc] [-[rw] filename] [tty_device | i2c_device]\n" - " -a bus_address Bus address (e.g. for I2C port)\n" - " -b rate Baud rate (default 57600)\n" - " -m mode Serial port mode (default 8e1)\n" - " -r filename Read flash to file (or - stdout)\n" - " -w filename Write flash from file (or - stdout)\n" - " -C Compute CRC of flash content\n" - " -u Disable the flash write-protection\n" - " -j Enable the flash read-protection\n" - " -k Disable the flash read-protection\n" - " -o Erase only\n" - " -e n Only erase n pages before writing the flash\n" - " -v Verify writes\n" - " -n count Retry failed writes up to count times (default 10)\n" - " -g address Start execution at specified address (0 = flash start)\n" - " -S address[:length] Specify start address and optionally length for\n" - " read/write/erase operations\n" - " -F RX_length[:TX_length] Specify the max length of RX and TX frame\n" - " -s start_page Flash at specified page (0 = flash start)\n" - " -f Force binary parser\n" - " -h Show this help\n" - " -c Resume the connection (don't send initial INIT)\n" - " *Baud rate must be kept the same as the first init*\n" - " This is useful if the reset fails\n" - " -i GPIO_string GPIO sequence to enter/exit bootloader mode\n" - " GPIO_string=[entry_seq][:[exit_seq]]\n" - " sequence=[-]n[,sequence]\n" - " -R Reset device at exit.\n" - "\n" - "Examples:\n" - " Get device information:\n" - " %s /dev/ttyS0\n" - " or:\n" - " %s /dev/i2c-0\n" - "\n" - " Write with verify and then start execution:\n" - " %s -w filename -v -g 0x0 /dev/ttyS0\n" - "\n" - " Read flash to file:\n" - " %s -r filename /dev/ttyS0\n" - "\n" - " Read 100 bytes of flash from 0x1000 to stdout:\n" - " %s -r - -S 0x1000:100 /dev/ttyS0\n" - "\n" - " Start execution:\n" - " %s -g 0x0 /dev/ttyS0\n" - "\n" - " GPIO sequence:\n" - " - entry sequence: GPIO_3=low, GPIO_2=low, GPIO_2=high\n" - " - exit sequence: GPIO_3=high, GPIO_2=low, GPIO_2=high\n" - " %s -i -3,-2,2:3,-2,2 /dev/ttyS0\n", - name, - name, - name, - name, - name, - name, - name, - name - ); -} - diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/Android.mk b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/Android.mk deleted file mode 100755 index afec18cd5..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := libparsers -LOCAL_SRC_FILES := binary.c hex.c -include $(BUILD_STATIC_LIBRARY) diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/Makefile b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/Makefile deleted file mode 100755 index bb7df1e02..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -CFLAGS += -Wall -g - -all: parsers.a - -parsers.a: binary.o hex.o - $(AR) rc $@ binary.o hex.o - -clean: - rm -f *.o parsers.a - -.PHONY: all clean diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/binary.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/binary.c deleted file mode 100755 index f491952bb..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/binary.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include - -#include "binary.h" - -typedef struct { - int fd; - char write; - struct stat stat; -} binary_t; - -void* binary_init() { - return calloc(sizeof(binary_t), 1); -} - -parser_err_t binary_open(void *storage, const char *filename, const char write) { - binary_t *st = storage; - if (write) { - if (filename[0] == '-') - st->fd = 1; - else - st->fd = open( - filename, -#ifndef __WIN32__ - O_WRONLY | O_CREAT | O_TRUNC, -#else - O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, -#endif -#ifndef __WIN32__ - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#else - 0 -#endif - ); - st->stat.st_size = 0; - } else { - if (filename[0] == '-') { - st->fd = 0; - } else { - if (stat(filename, &st->stat) != 0) - return PARSER_ERR_INVALID_FILE; - st->fd = open(filename, -#ifndef __WIN32__ - O_RDONLY -#else - O_RDONLY | O_BINARY -#endif - ); - } - } - - st->write = write; - return st->fd == -1 ? PARSER_ERR_SYSTEM : PARSER_ERR_OK; -} - -parser_err_t binary_close(void *storage) { - binary_t *st = storage; - - if (st->fd) close(st->fd); - free(st); - return PARSER_ERR_OK; -} - -unsigned int binary_size(void *storage) { - binary_t *st = storage; - return st->stat.st_size; -} - -parser_err_t binary_read(void *storage, void *data, unsigned int *len) { - binary_t *st = storage; - unsigned int left = *len; - if (st->write) return PARSER_ERR_WRONLY; - - ssize_t r; - while(left > 0) { - r = read(st->fd, data, left); - /* If there is no data to read at all, return OK, but with zero read */ - if (r == 0 && left == *len) { - *len = 0; - return PARSER_ERR_OK; - } - if (r <= 0) return PARSER_ERR_SYSTEM; - left -= r; - data += r; - } - - *len = *len - left; - return PARSER_ERR_OK; -} - -parser_err_t binary_write(void *storage, void *data, unsigned int len) { - binary_t *st = storage; - if (!st->write) return PARSER_ERR_RDONLY; - - ssize_t r; - while(len > 0) { - r = write(st->fd, data, len); - if (r < 1) return PARSER_ERR_SYSTEM; - st->stat.st_size += r; - - len -= r; - data += r; - } - - return PARSER_ERR_OK; -} - -parser_t PARSER_BINARY = { - "Raw BINARY", - binary_init, - binary_open, - binary_close, - binary_size, - binary_read, - binary_write -}; - diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/binary.h b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/binary.h deleted file mode 100755 index d989acfa0..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/binary.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _PARSER_BINARY_H -#define _PARSER_BINARY_H - -#include "parser.h" - -extern parser_t PARSER_BINARY; -#endif diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/hex.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/hex.c deleted file mode 100755 index 3baf85623..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/hex.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include - -#include "hex.h" -#include "../utils.h" - -typedef struct { - size_t data_len, offset; - uint8_t *data; - uint8_t base; -} hex_t; - -void* hex_init() { - return calloc(sizeof(hex_t), 1); -} - -parser_err_t hex_open(void *storage, const char *filename, const char write) { - hex_t *st = storage; - if (write) { - return PARSER_ERR_RDONLY; - } else { - char mark; - int i, fd; - uint8_t checksum; - unsigned int c; - uint32_t base = 0; - unsigned int last_address = 0x0; - - fd = open(filename, O_RDONLY); - if (fd < 0) - return PARSER_ERR_SYSTEM; - - /* read in the file */ - - while(read(fd, &mark, 1) != 0) { - if (mark == '\n' || mark == '\r') continue; - if (mark != ':') - return PARSER_ERR_INVALID_FILE; - - char buffer[9]; - unsigned int reclen, address, type; - uint8_t *record = NULL; - - /* get the reclen, address, and type */ - buffer[8] = 0; - if (read(fd, &buffer, 8) != 8) return PARSER_ERR_INVALID_FILE; - if (sscanf(buffer, "%2x%4x%2x", &reclen, &address, &type) != 3) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* setup the checksum */ - checksum = - reclen + - ((address & 0xFF00) >> 8) + - ((address & 0x00FF) >> 0) + - type; - - switch(type) { - /* data record */ - case 0: - c = address - last_address; - st->data = realloc(st->data, st->data_len + c + reclen); - - /* if there is a gap, set it to 0xff and increment the length */ - if (c > 0) { - memset(&st->data[st->data_len], 0xff, c); - st->data_len += c; - } - - last_address = address + reclen; - record = &st->data[st->data_len]; - st->data_len += reclen; - break; - - /* extended segment address record */ - case 2: - base = 0; - break; - - /* extended linear address record */ - case 4: - base = address; - break; - } - - buffer[2] = 0; - for(i = 0; i < reclen; ++i) { - if (read(fd, &buffer, 2) != 2 || sscanf(buffer, "%2x", &c) != 1) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* add the byte to the checksum */ - checksum += c; - - switch(type) { - case 0: - if (record != NULL) { - record[i] = c; - } else { - return PARSER_ERR_INVALID_FILE; - } - break; - - case 2: - case 4: - base = (base << 8) | c; - break; - } - } - - /* read, scan, and verify the checksum */ - if ( - read(fd, &buffer, 2 ) != 2 || - sscanf(buffer, "%2x", &c) != 1 || - (uint8_t)(checksum + c) != 0x00 - ) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - switch(type) { - /* EOF */ - case 1: - close(fd); - return PARSER_ERR_OK; - - /* address record */ - case 2: base = base << 4; - case 4: base = be_u32(base); - /* Reset last_address since our base changed */ - last_address = 0; - - if (st->base == 0) { - st->base = base; - break; - } - - /* we cant cope with files out of order */ - if (base < st->base) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* if there is a gap, enlarge and fill with zeros */ - unsigned int len = base - st->base; - if (len > st->data_len) { - st->data = realloc(st->data, len); - memset(&st->data[st->data_len], 0, len - st->data_len); - st->data_len = len; - } - break; - } - } - - close(fd); - return PARSER_ERR_OK; - } -} - -parser_err_t hex_close(void *storage) { - hex_t *st = storage; - if (st) free(st->data); - free(st); - return PARSER_ERR_OK; -} - -unsigned int hex_size(void *storage) { - hex_t *st = storage; - return st->data_len; -} - -parser_err_t hex_read(void *storage, void *data, unsigned int *len) { - hex_t *st = storage; - unsigned int left = st->data_len - st->offset; - unsigned int get = left > *len ? *len : left; - - memcpy(data, &st->data[st->offset], get); - st->offset += get; - - *len = get; - return PARSER_ERR_OK; -} - -parser_err_t hex_write(void *storage, void *data, unsigned int len) { - return PARSER_ERR_RDONLY; -} - -parser_t PARSER_HEX = { - "Intel HEX", - hex_init, - hex_open, - hex_close, - hex_size, - hex_read, - hex_write -}; - diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/hex.h b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/hex.h deleted file mode 100755 index 02413c9c9..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/hex.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _PARSER_HEX_H -#define _PARSER_HEX_H - -#include "parser.h" - -extern parser_t PARSER_HEX; -#endif diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/parser.h b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/parser.h deleted file mode 100755 index c2fae3cf8..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/parsers/parser.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_PARSER -#define _H_PARSER - -enum parser_err { - PARSER_ERR_OK, - PARSER_ERR_SYSTEM, - PARSER_ERR_INVALID_FILE, - PARSER_ERR_WRONLY, - PARSER_ERR_RDONLY -}; -typedef enum parser_err parser_err_t; - -struct parser { - const char *name; - void* (*init )(); /* initialise the parser */ - parser_err_t (*open )(void *storage, const char *filename, const char write); /* open the file for read|write */ - parser_err_t (*close)(void *storage); /* close and free the parser */ - unsigned int (*size )(void *storage); /* get the total data size */ - parser_err_t (*read )(void *storage, void *data, unsigned int *len); /* read a block of data */ - parser_err_t (*write)(void *storage, void *data, unsigned int len); /* write a block of data */ -}; -typedef struct parser parser_t; - -static inline const char* parser_errstr(parser_err_t err) { - switch(err) { - case PARSER_ERR_OK : return "OK"; - case PARSER_ERR_SYSTEM : return "System Error"; - case PARSER_ERR_INVALID_FILE: return "Invalid File"; - case PARSER_ERR_WRONLY : return "Parser can only write"; - case PARSER_ERR_RDONLY : return "Parser can only read"; - default: - return "Unknown Error"; - } -} - -#endif diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/port.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/port.c deleted file mode 100755 index 08e58cc34..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/port.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include "serial.h" -#include "port.h" - - -extern struct port_interface port_serial; -extern struct port_interface port_i2c; - -static struct port_interface *ports[] = { - &port_serial, - &port_i2c, - NULL, -}; - - -port_err_t port_open(struct port_options *ops, struct port_interface **outport) -{ - int ret; - static struct port_interface **port; - - for (port = ports; *port; port++) { - ret = (*port)->open(*port, ops); - if (ret == PORT_ERR_NODEV) - continue; - if (ret == PORT_ERR_OK) - break; - fprintf(stderr, "Error probing interface \"%s\"\n", - (*port)->name); - } - if (*port == NULL) { - fprintf(stderr, "Cannot handle device \"%s\"\n", - ops->device); - return PORT_ERR_UNKNOWN; - } - - *outport = *port; - return PORT_ERR_OK; -} diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/port.h b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/port.h deleted file mode 100755 index 290f03496..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/port.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_PORT -#define _H_PORT - -typedef enum { - PORT_ERR_OK = 0, - PORT_ERR_NODEV, /* No such device */ - PORT_ERR_TIMEDOUT, /* Operation timed out */ - PORT_ERR_UNKNOWN, -} port_err_t; - -/* flags */ -#define PORT_BYTE (1 << 0) /* byte (not frame) oriented */ -#define PORT_GVR_ETX (1 << 1) /* cmd GVR returns protection status */ -#define PORT_CMD_INIT (1 << 2) /* use INIT cmd to autodetect speed */ -#define PORT_RETRY (1 << 3) /* allowed read() retry after timeout */ -#define PORT_STRETCH_W (1 << 4) /* warning for no-stretching commands */ - -/* all options and flags used to open and configure an interface */ -struct port_options { - const char *device; - serial_baud_t baudRate; - const char *serial_mode; - int bus_addr; - int rx_frame_max; - int tx_frame_max; -}; - -/* - * Specify the length of reply for command GET - * This is helpful for frame-oriented protocols, e.g. i2c, to avoid time - * consuming try-fail-timeout-retry operation. - * On byte-oriented protocols, i.e. UART, this information would be skipped - * after read the first byte, so not needed. - */ -struct varlen_cmd { - uint8_t version; - uint8_t length; -}; - -struct port_interface { - const char *name; - unsigned flags; - port_err_t (*open)(struct port_interface *port, struct port_options *ops); - port_err_t (*close)(struct port_interface *port); - port_err_t (*read)(struct port_interface *port, void *buf, size_t nbyte); - port_err_t (*write)(struct port_interface *port, void *buf, size_t nbyte); - port_err_t (*gpio)(struct port_interface *port, serial_gpio_t n, int level); - const char *(*get_cfg_str)(struct port_interface *port); - struct varlen_cmd *cmd_get_reply; - void *private; -}; - -port_err_t port_open(struct port_options *ops, struct port_interface **outport); - -#endif diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/protocol.txt b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/protocol.txt deleted file mode 100755 index 039109908..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/protocol.txt +++ /dev/null @@ -1,19 +0,0 @@ -The communication protocol used by ST bootloader is documented in following ST -application notes, depending on communication port. - -In current version of stm32flash are supported only UART and I2C ports. - -* AN3154: CAN protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/CD00264321.pdf - -* AN3155: USART protocol used in the STM32(TM) bootloader - http://www.st.com/web/en/resource/technical/document/application_note/CD00264342.pdf - -* AN4221: I2C protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/DM00072315.pdf - -* AN4286: SPI protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/DM00081379.pdf - -Boot mode selection for STM32 is documented in ST application note AN2606, available in ST website: - http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial.h b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial.h deleted file mode 100755 index 227ba163b..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _SERIAL_H -#define _SERIAL_H - -typedef struct serial serial_t; - -typedef enum { - SERIAL_PARITY_NONE, - SERIAL_PARITY_EVEN, - SERIAL_PARITY_ODD, - - SERIAL_PARITY_INVALID -} serial_parity_t; - -typedef enum { - SERIAL_BITS_5, - SERIAL_BITS_6, - SERIAL_BITS_7, - SERIAL_BITS_8, - - SERIAL_BITS_INVALID -} serial_bits_t; - -typedef enum { - SERIAL_BAUD_1200, - SERIAL_BAUD_1800, - SERIAL_BAUD_2400, - SERIAL_BAUD_4800, - SERIAL_BAUD_9600, - SERIAL_BAUD_19200, - SERIAL_BAUD_38400, - SERIAL_BAUD_57600, - SERIAL_BAUD_115200, - SERIAL_BAUD_128000, - SERIAL_BAUD_230400, - SERIAL_BAUD_256000, - SERIAL_BAUD_460800, - SERIAL_BAUD_500000, - SERIAL_BAUD_576000, - SERIAL_BAUD_921600, - SERIAL_BAUD_1000000, - SERIAL_BAUD_1500000, - SERIAL_BAUD_2000000, - - SERIAL_BAUD_INVALID -} serial_baud_t; - -typedef enum { - SERIAL_STOPBIT_1, - SERIAL_STOPBIT_2, - - SERIAL_STOPBIT_INVALID -} serial_stopbit_t; - -typedef enum { - GPIO_RTS = 1, - GPIO_DTR, - GPIO_BRK, -} serial_gpio_t; - -/* common helper functions */ -serial_baud_t serial_get_baud(const unsigned int baud); -unsigned int serial_get_baud_int(const serial_baud_t baud); -serial_bits_t serial_get_bits(const char *mode); -unsigned int serial_get_bits_int(const serial_bits_t bits); -serial_parity_t serial_get_parity(const char *mode); -char serial_get_parity_str(const serial_parity_t parity); -serial_stopbit_t serial_get_stopbit(const char *mode); -unsigned int serial_get_stopbit_int(const serial_stopbit_t stopbit); - -#endif diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_common.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_common.c deleted file mode 100755 index 43e48e1ac..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_common.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "serial.h" - -serial_baud_t serial_get_baud(const unsigned int baud) { - switch(baud) { - case 1200: return SERIAL_BAUD_1200 ; - case 1800: return SERIAL_BAUD_1800 ; - case 2400: return SERIAL_BAUD_2400 ; - case 4800: return SERIAL_BAUD_4800 ; - case 9600: return SERIAL_BAUD_9600 ; - case 19200: return SERIAL_BAUD_19200 ; - case 38400: return SERIAL_BAUD_38400 ; - case 57600: return SERIAL_BAUD_57600 ; - case 115200: return SERIAL_BAUD_115200; - case 128000: return SERIAL_BAUD_128000; - case 230400: return SERIAL_BAUD_230400; - case 256000: return SERIAL_BAUD_256000; - case 460800: return SERIAL_BAUD_460800; - case 500000: return SERIAL_BAUD_500000; - case 576000: return SERIAL_BAUD_576000; - case 921600: return SERIAL_BAUD_921600; - case 1000000: return SERIAL_BAUD_1000000; - case 1500000: return SERIAL_BAUD_1500000; - case 2000000: return SERIAL_BAUD_2000000; - - default: - return SERIAL_BAUD_INVALID; - } -} - -unsigned int serial_get_baud_int(const serial_baud_t baud) { - switch(baud) { - case SERIAL_BAUD_1200 : return 1200 ; - case SERIAL_BAUD_1800 : return 1800 ; - case SERIAL_BAUD_2400 : return 2400 ; - case SERIAL_BAUD_4800 : return 4800 ; - case SERIAL_BAUD_9600 : return 9600 ; - case SERIAL_BAUD_19200 : return 19200 ; - case SERIAL_BAUD_38400 : return 38400 ; - case SERIAL_BAUD_57600 : return 57600 ; - case SERIAL_BAUD_115200: return 115200; - case SERIAL_BAUD_128000: return 128000; - case SERIAL_BAUD_230400: return 230400; - case SERIAL_BAUD_256000: return 256000; - case SERIAL_BAUD_460800: return 460800; - case SERIAL_BAUD_500000: return 500000; - case SERIAL_BAUD_576000: return 576000; - case SERIAL_BAUD_921600: return 921600; - case SERIAL_BAUD_1000000: return 1000000; - case SERIAL_BAUD_1500000: return 1500000; - case SERIAL_BAUD_2000000: return 2000000; - - case SERIAL_BAUD_INVALID: - default: - return 0; - } -} - -serial_bits_t serial_get_bits(const char *mode) { - if (!mode) - return SERIAL_BITS_INVALID; - switch(mode[0]) { - case '5': return SERIAL_BITS_5; - case '6': return SERIAL_BITS_6; - case '7': return SERIAL_BITS_7; - case '8': return SERIAL_BITS_8; - - default: - return SERIAL_BITS_INVALID; - } -} - -unsigned int serial_get_bits_int(const serial_bits_t bits) { - switch(bits) { - case SERIAL_BITS_5: return 5; - case SERIAL_BITS_6: return 6; - case SERIAL_BITS_7: return 7; - case SERIAL_BITS_8: return 8; - - default: - return 0; - } -} - -serial_parity_t serial_get_parity(const char *mode) { - if (!mode || !mode[0]) - return SERIAL_PARITY_INVALID; - switch(mode[1]) { - case 'N': - case 'n': - return SERIAL_PARITY_NONE; - case 'E': - case 'e': - return SERIAL_PARITY_EVEN; - case 'O': - case 'o': - return SERIAL_PARITY_ODD; - - default: - return SERIAL_PARITY_INVALID; - } -} - -char serial_get_parity_str(const serial_parity_t parity) { - switch(parity) { - case SERIAL_PARITY_NONE: return 'N'; - case SERIAL_PARITY_EVEN: return 'E'; - case SERIAL_PARITY_ODD : return 'O'; - - default: - return ' '; - } -} - -serial_stopbit_t serial_get_stopbit(const char *mode) { - if (!mode || !mode[0] || !mode[1]) - return SERIAL_STOPBIT_INVALID; - switch(mode[2]) { - case '1': return SERIAL_STOPBIT_1; - case '2': return SERIAL_STOPBIT_2; - - default: - return SERIAL_STOPBIT_INVALID; - } -} - -unsigned int serial_get_stopbit_int(const serial_stopbit_t stopbit) { - switch(stopbit) { - case SERIAL_STOPBIT_1: return 1; - case SERIAL_STOPBIT_2: return 2; - - default: - return 0; - } -} - diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_platform.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_platform.c deleted file mode 100755 index 98e256921..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_platform.c +++ /dev/null @@ -1,5 +0,0 @@ -#if defined(__WIN32__) || defined(__CYGWIN__) -# include "serial_w32.c" -#else -# include "serial_posix.c" -#endif diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_posix.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_posix.c deleted file mode 100755 index 284b35b20..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_posix.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - -struct serial { - int fd; - struct termios oldtio; - struct termios newtio; - char setup_str[11]; -}; - -static serial_t *serial_open(const char *device) -{ - serial_t *h = calloc(sizeof(serial_t), 1); - - h->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); - if (h->fd < 0) { - free(h); - return NULL; - } - fcntl(h->fd, F_SETFL, 0); - - tcgetattr(h->fd, &h->oldtio); - tcgetattr(h->fd, &h->newtio); - - return h; -} - -static void serial_flush(const serial_t *h) -{ - tcflush(h->fd, TCIFLUSH); -} - -static void serial_close(serial_t *h) -{ - serial_flush(h); - tcsetattr(h->fd, TCSANOW, &h->oldtio); - close(h->fd); - free(h); -} - -static port_err_t serial_setup(serial_t *h, const serial_baud_t baud, - const serial_bits_t bits, - const serial_parity_t parity, - const serial_stopbit_t stopbit) -{ - speed_t port_baud; - tcflag_t port_bits; - tcflag_t port_parity; - tcflag_t port_stop; - struct termios settings; - - switch (baud) { - case SERIAL_BAUD_1200: port_baud = B1200; break; - case SERIAL_BAUD_1800: port_baud = B1800; break; - case SERIAL_BAUD_2400: port_baud = B2400; break; - case SERIAL_BAUD_4800: port_baud = B4800; break; - case SERIAL_BAUD_9600: port_baud = B9600; break; - case SERIAL_BAUD_19200: port_baud = B19200; break; - case SERIAL_BAUD_38400: port_baud = B38400; break; - case SERIAL_BAUD_57600: port_baud = B57600; break; - case SERIAL_BAUD_115200: port_baud = B115200; break; - case SERIAL_BAUD_230400: port_baud = B230400; break; -#ifdef B460800 - case SERIAL_BAUD_460800: port_baud = B460800; break; -#endif /* B460800 */ -#ifdef B921600 - case SERIAL_BAUD_921600: port_baud = B921600; break; -#endif /* B921600 */ -#ifdef B500000 - case SERIAL_BAUD_500000: port_baud = B500000; break; -#endif /* B500000 */ -#ifdef B576000 - case SERIAL_BAUD_576000: port_baud = B576000; break; -#endif /* B576000 */ -#ifdef B1000000 - case SERIAL_BAUD_1000000: port_baud = B1000000; break; -#endif /* B1000000 */ -#ifdef B1500000 - case SERIAL_BAUD_1500000: port_baud = B1500000; break; -#endif /* B1500000 */ -#ifdef B2000000 - case SERIAL_BAUD_2000000: port_baud = B2000000; break; -#endif /* B2000000 */ - - case SERIAL_BAUD_INVALID: - default: - return PORT_ERR_UNKNOWN; - } - - switch (bits) { - case SERIAL_BITS_5: port_bits = CS5; break; - case SERIAL_BITS_6: port_bits = CS6; break; - case SERIAL_BITS_7: port_bits = CS7; break; - case SERIAL_BITS_8: port_bits = CS8; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (parity) { - case SERIAL_PARITY_NONE: port_parity = 0; break; - case SERIAL_PARITY_EVEN: port_parity = PARENB; break; - case SERIAL_PARITY_ODD: port_parity = PARENB | PARODD; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (stopbit) { - case SERIAL_STOPBIT_1: port_stop = 0; break; - case SERIAL_STOPBIT_2: port_stop = CSTOPB; break; - - default: - return PORT_ERR_UNKNOWN; - } - - /* reset the settings */ -#ifndef __sun /* Used by GNU and BSD. Ignore __SVR4 in test. */ - cfmakeraw(&h->newtio); -#else /* __sun */ - h->newtio.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR - | IGNCR | ICRNL | IXON); - if (port_parity) - h->newtio.c_iflag |= INPCK; - - h->newtio.c_oflag &= ~OPOST; - h->newtio.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); - h->newtio.c_cflag &= ~(CSIZE | PARENB); - h->newtio.c_cflag |= CS8; -#endif /* __sun */ -#ifdef __QNXNTO__ - h->newtio.c_cflag &= ~(CSIZE | IHFLOW | OHFLOW); -#else - h->newtio.c_cflag &= ~(CSIZE | CRTSCTS); -#endif - h->newtio.c_cflag &= ~(CSIZE | CRTSCTS); - h->newtio.c_iflag &= ~(IXON | IXOFF | IXANY | IGNPAR); - h->newtio.c_lflag &= ~(ECHOK | ECHOCTL | ECHOKE); - h->newtio.c_oflag &= ~(OPOST | ONLCR); - - /* setup the new settings */ - cfsetispeed(&h->newtio, port_baud); - cfsetospeed(&h->newtio, port_baud); - h->newtio.c_cflag |= - port_parity | - port_bits | - port_stop | - CLOCAL | - CREAD; - - h->newtio.c_cc[VMIN] = 0; - h->newtio.c_cc[VTIME] = 5; /* in units of 0.1 s */ - - /* set the settings */ - serial_flush(h); - if (tcsetattr(h->fd, TCSANOW, &h->newtio) != 0) - return PORT_ERR_UNKNOWN; - -/* this check fails on CDC-ACM devices, bits 16 and 17 of cflag differ! - * it has been disabled below for now -jcw, 2015-11-09 - if (settings.c_cflag != h->newtio.c_cflag) - fprintf(stderr, "c_cflag mismatch %lx\n", - settings.c_cflag ^ h->newtio.c_cflag); - */ - - /* confirm they were set */ - tcgetattr(h->fd, &settings); - if (settings.c_iflag != h->newtio.c_iflag || - settings.c_oflag != h->newtio.c_oflag || - //settings.c_cflag != h->newtio.c_cflag || - settings.c_lflag != h->newtio.c_lflag) - return PORT_ERR_UNKNOWN; - - snprintf(h->setup_str, sizeof(h->setup_str), "%u %d%c%d", - serial_get_baud_int(baud), - serial_get_bits_int(bits), - serial_get_parity_str(parity), - serial_get_stopbit_int(stopbit)); - return PORT_ERR_OK; -} - -/* - * Roger clark. - * This function is no longer used. But has just been commented out in case it needs - * to be reinstated in the future - -static int startswith(const char *haystack, const char *needle) { - return strncmp(haystack, needle, strlen(needle)) == 0; -} -*/ - -static int is_tty(const char *path) { - char resolved[PATH_MAX]; - - if(!realpath(path, resolved)) return 0; - - - /* - * Roger Clark - * Commented out this check, because on OSX some devices are /dev/cu - * and some users use symbolic links to devices, hence the name may not even start - * with /dev - - if(startswith(resolved, "/dev/tty")) return 1; - - return 0; - */ - - return 1; -} - -static port_err_t serial_posix_open(struct port_interface *port, - struct port_options *ops) -{ - serial_t *h; - - /* 1. check device name match */ - if (!is_tty(ops->device)) - return PORT_ERR_NODEV; - - /* 2. check options */ - if (ops->baudRate == SERIAL_BAUD_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_bits(ops->serial_mode) == SERIAL_BITS_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_parity(ops->serial_mode) == SERIAL_PARITY_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_stopbit(ops->serial_mode) == SERIAL_STOPBIT_INVALID) - return PORT_ERR_UNKNOWN; - - /* 3. open it */ - h = serial_open(ops->device); - if (h == NULL) - return PORT_ERR_UNKNOWN; - - /* 4. set options */ - if (serial_setup(h, ops->baudRate, - serial_get_bits(ops->serial_mode), - serial_get_parity(ops->serial_mode), - serial_get_stopbit(ops->serial_mode) - ) != PORT_ERR_OK) { - serial_close(h); - return PORT_ERR_UNKNOWN; - } - - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t serial_posix_close(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - serial_close(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t serial_posix_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - ssize_t r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - r = read(h->fd, pos, nbyte); - if (r == 0) - return PORT_ERR_TIMEDOUT; - if (r < 0) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_posix_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - ssize_t r; - const uint8_t *pos = (const uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - r = write(h->fd, pos, nbyte); - if (r < 1) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_posix_gpio(struct port_interface *port, - serial_gpio_t n, int level) -{ - serial_t *h; - int bit, lines; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - switch (n) { - case GPIO_RTS: - bit = TIOCM_RTS; - break; - - case GPIO_DTR: - bit = TIOCM_DTR; - break; - - case GPIO_BRK: - if (level == 0) - return PORT_ERR_OK; - if (tcsendbreak(h->fd, 1)) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; - - default: - return PORT_ERR_UNKNOWN; - } - - /* handle RTS/DTR */ - if (ioctl(h->fd, TIOCMGET, &lines)) - return PORT_ERR_UNKNOWN; - lines = level ? lines | bit : lines & ~bit; - if (ioctl(h->fd, TIOCMSET, &lines)) - return PORT_ERR_UNKNOWN; - - return PORT_ERR_OK; -} - -static const char *serial_posix_get_cfg_str(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - return h ? h->setup_str : "INVALID"; -} - -struct port_interface port_serial = { - .name = "serial_posix", - .flags = PORT_BYTE | PORT_GVR_ETX | PORT_CMD_INIT | PORT_RETRY, - .open = serial_posix_open, - .close = serial_posix_close, - .read = serial_posix_read, - .write = serial_posix_write, - .gpio = serial_posix_gpio, - .get_cfg_str = serial_posix_get_cfg_str, -}; diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_w32.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_w32.c deleted file mode 100755 index 56772c0a0..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/serial_w32.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2010 Gareth McMullin - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - -struct serial { - HANDLE fd; - DCB oldtio; - DCB newtio; - char setup_str[11]; -}; - -static serial_t *serial_open(const char *device) -{ - serial_t *h = calloc(sizeof(serial_t), 1); - char *devName; - - /* timeout in ms */ - COMMTIMEOUTS timeouts = {MAXDWORD, MAXDWORD, 500, 0, 0}; - - /* Fix the device name if required */ - if (strlen(device) > 4 && device[0] != '\\') { - devName = calloc(1, strlen(device) + 5); - sprintf(devName, "\\\\.\\%s", device); - } else { - devName = (char *)device; - } - - /* Create file handle for port */ - h->fd = CreateFile(devName, GENERIC_READ | GENERIC_WRITE, - 0, /* Exclusive access */ - NULL, /* No security */ - OPEN_EXISTING, - 0, /* No overlap */ - NULL); - - if (devName != device) - free(devName); - - if (h->fd == INVALID_HANDLE_VALUE) { - if (GetLastError() == ERROR_FILE_NOT_FOUND) - fprintf(stderr, "File not found: %s\n", device); - return NULL; - } - - SetupComm(h->fd, 4096, 4096); /* Set input and output buffer size */ - - SetCommTimeouts(h->fd, &timeouts); - - SetCommMask(h->fd, EV_ERR); /* Notify us of error events */ - - GetCommState(h->fd, &h->oldtio); /* Retrieve port parameters */ - GetCommState(h->fd, &h->newtio); /* Retrieve port parameters */ - - /* PurgeComm(h->fd, PURGE_RXABORT | PURGE_TXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR); */ - - return h; -} - -static void serial_flush(const serial_t *h) -{ - /* We shouldn't need to flush in non-overlapping (blocking) mode */ - /* tcflush(h->fd, TCIFLUSH); */ -} - -static void serial_close(serial_t *h) -{ - serial_flush(h); - SetCommState(h->fd, &h->oldtio); - CloseHandle(h->fd); - free(h); -} - -static port_err_t serial_setup(serial_t *h, - const serial_baud_t baud, - const serial_bits_t bits, - const serial_parity_t parity, - const serial_stopbit_t stopbit) -{ - switch (baud) { - case SERIAL_BAUD_1200: h->newtio.BaudRate = CBR_1200; break; - /* case SERIAL_BAUD_1800: h->newtio.BaudRate = CBR_1800; break; */ - case SERIAL_BAUD_2400: h->newtio.BaudRate = CBR_2400; break; - case SERIAL_BAUD_4800: h->newtio.BaudRate = CBR_4800; break; - case SERIAL_BAUD_9600: h->newtio.BaudRate = CBR_9600; break; - case SERIAL_BAUD_19200: h->newtio.BaudRate = CBR_19200; break; - case SERIAL_BAUD_38400: h->newtio.BaudRate = CBR_38400; break; - case SERIAL_BAUD_57600: h->newtio.BaudRate = CBR_57600; break; - case SERIAL_BAUD_115200: h->newtio.BaudRate = CBR_115200; break; - case SERIAL_BAUD_128000: h->newtio.BaudRate = CBR_128000; break; - case SERIAL_BAUD_256000: h->newtio.BaudRate = CBR_256000; break; - /* These are not defined in WinBase.h and might work or not */ - case SERIAL_BAUD_230400: h->newtio.BaudRate = 230400; break; - case SERIAL_BAUD_460800: h->newtio.BaudRate = 460800; break; - case SERIAL_BAUD_500000: h->newtio.BaudRate = 500000; break; - case SERIAL_BAUD_576000: h->newtio.BaudRate = 576000; break; - case SERIAL_BAUD_921600: h->newtio.BaudRate = 921600; break; - case SERIAL_BAUD_1000000: h->newtio.BaudRate = 1000000; break; - case SERIAL_BAUD_1500000: h->newtio.BaudRate = 1500000; break; - case SERIAL_BAUD_2000000: h->newtio.BaudRate = 2000000; break; - case SERIAL_BAUD_INVALID: - - default: - return PORT_ERR_UNKNOWN; - } - - switch (bits) { - case SERIAL_BITS_5: h->newtio.ByteSize = 5; break; - case SERIAL_BITS_6: h->newtio.ByteSize = 6; break; - case SERIAL_BITS_7: h->newtio.ByteSize = 7; break; - case SERIAL_BITS_8: h->newtio.ByteSize = 8; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (parity) { - case SERIAL_PARITY_NONE: h->newtio.Parity = NOPARITY; break; - case SERIAL_PARITY_EVEN: h->newtio.Parity = EVENPARITY; break; - case SERIAL_PARITY_ODD: h->newtio.Parity = ODDPARITY; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (stopbit) { - case SERIAL_STOPBIT_1: h->newtio.StopBits = ONESTOPBIT; break; - case SERIAL_STOPBIT_2: h->newtio.StopBits = TWOSTOPBITS; break; - - default: - return PORT_ERR_UNKNOWN; - } - - /* reset the settings */ - h->newtio.fOutxCtsFlow = FALSE; - h->newtio.fOutxDsrFlow = FALSE; - h->newtio.fOutX = FALSE; - h->newtio.fInX = FALSE; - h->newtio.fNull = 0; - h->newtio.fAbortOnError = 0; - - /* set the settings */ - serial_flush(h); - if (!SetCommState(h->fd, &h->newtio)) - return PORT_ERR_UNKNOWN; - - snprintf(h->setup_str, sizeof(h->setup_str), "%u %d%c%d", - serial_get_baud_int(baud), - serial_get_bits_int(bits), - serial_get_parity_str(parity), - serial_get_stopbit_int(stopbit) - ); - return PORT_ERR_OK; -} - -static port_err_t serial_w32_open(struct port_interface *port, - struct port_options *ops) -{ - serial_t *h; - - /* 1. check device name match */ - if (!((strlen(ops->device) == 4 || strlen(ops->device) == 5) - && !strncmp(ops->device, "COM", 3) && isdigit(ops->device[3])) - && !(!strncmp(ops->device, "\\\\.\\COM", strlen("\\\\.\\COM")) - && isdigit(ops->device[strlen("\\\\.\\COM")]))) - return PORT_ERR_NODEV; - - /* 2. check options */ - if (ops->baudRate == SERIAL_BAUD_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_bits(ops->serial_mode) == SERIAL_BITS_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_parity(ops->serial_mode) == SERIAL_PARITY_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_stopbit(ops->serial_mode) == SERIAL_STOPBIT_INVALID) - return PORT_ERR_UNKNOWN; - - /* 3. open it */ - h = serial_open(ops->device); - if (h == NULL) - return PORT_ERR_UNKNOWN; - - /* 4. set options */ - if (serial_setup(h, ops->baudRate, - serial_get_bits(ops->serial_mode), - serial_get_parity(ops->serial_mode), - serial_get_stopbit(ops->serial_mode) - ) != PORT_ERR_OK) { - serial_close(h); - return PORT_ERR_UNKNOWN; - } - - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t serial_w32_close(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - serial_close(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t serial_w32_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - DWORD r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - ReadFile(h->fd, pos, nbyte, &r, NULL); - if (r == 0) - return PORT_ERR_TIMEDOUT; - if (r < 0) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_w32_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - DWORD r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - if (!WriteFile(h->fd, pos, nbyte, &r, NULL)) - return PORT_ERR_UNKNOWN; - if (r < 1) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_w32_gpio(struct port_interface *port, - serial_gpio_t n, int level) -{ - serial_t *h; - int bit; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - switch (n) { - case GPIO_RTS: - bit = level ? SETRTS : CLRRTS; - break; - - case GPIO_DTR: - bit = level ? SETDTR : CLRDTR; - break; - - case GPIO_BRK: - if (level == 0) - return PORT_ERR_OK; - if (EscapeCommFunction(h->fd, SETBREAK) == 0) - return PORT_ERR_UNKNOWN; - usleep(500000); - if (EscapeCommFunction(h->fd, CLRBREAK) == 0) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; - - default: - return PORT_ERR_UNKNOWN; - } - - /* handle RTS/DTR */ - if (EscapeCommFunction(h->fd, bit) == 0) - return PORT_ERR_UNKNOWN; - - return PORT_ERR_OK; -} - -static const char *serial_w32_get_cfg_str(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - return h ? h->setup_str : "INVALID"; -} - -struct port_interface port_serial = { - .name = "serial_w32", - .flags = PORT_BYTE | PORT_GVR_ETX | PORT_CMD_INIT | PORT_RETRY, - .open = serial_w32_open, - .close = serial_w32_close, - .read = serial_w32_read, - .write = serial_w32_write, - .gpio = serial_w32_gpio, - .get_cfg_str = serial_w32_get_cfg_str, -}; diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/stm32.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/stm32.c deleted file mode 100755 index 74047d244..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/stm32.c +++ /dev/null @@ -1,1048 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright 2010 Geoffrey McRae - Copyright 2012-2014 Tormod Volden - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include - -#include "stm32.h" -#include "port.h" -#include "utils.h" - -#define STM32_ACK 0x79 -#define STM32_NACK 0x1F -#define STM32_BUSY 0x76 - -#define STM32_CMD_INIT 0x7F -#define STM32_CMD_GET 0x00 /* get the version and command supported */ -#define STM32_CMD_GVR 0x01 /* get version and read protection status */ -#define STM32_CMD_GID 0x02 /* get ID */ -#define STM32_CMD_RM 0x11 /* read memory */ -#define STM32_CMD_GO 0x21 /* go */ -#define STM32_CMD_WM 0x31 /* write memory */ -#define STM32_CMD_WM_NS 0x32 /* no-stretch write memory */ -#define STM32_CMD_ER 0x43 /* erase */ -#define STM32_CMD_EE 0x44 /* extended erase */ -#define STM32_CMD_EE_NS 0x45 /* extended erase no-stretch */ -#define STM32_CMD_WP 0x63 /* write protect */ -#define STM32_CMD_WP_NS 0x64 /* write protect no-stretch */ -#define STM32_CMD_UW 0x73 /* write unprotect */ -#define STM32_CMD_UW_NS 0x74 /* write unprotect no-stretch */ -#define STM32_CMD_RP 0x82 /* readout protect */ -#define STM32_CMD_RP_NS 0x83 /* readout protect no-stretch */ -#define STM32_CMD_UR 0x92 /* readout unprotect */ -#define STM32_CMD_UR_NS 0x93 /* readout unprotect no-stretch */ -#define STM32_CMD_CRC 0xA1 /* compute CRC */ -#define STM32_CMD_ERR 0xFF /* not a valid command */ - -#define STM32_RESYNC_TIMEOUT 35 /* seconds */ -#define STM32_MASSERASE_TIMEOUT 35 /* seconds */ -#define STM32_SECTERASE_TIMEOUT 5 /* seconds */ -#define STM32_BLKWRITE_TIMEOUT 1 /* seconds */ -#define STM32_WUNPROT_TIMEOUT 1 /* seconds */ -#define STM32_WPROT_TIMEOUT 1 /* seconds */ -#define STM32_RPROT_TIMEOUT 1 /* seconds */ - -#define STM32_CMD_GET_LENGTH 17 /* bytes in the reply */ - -struct stm32_cmd { - uint8_t get; - uint8_t gvr; - uint8_t gid; - uint8_t rm; - uint8_t go; - uint8_t wm; - uint8_t er; /* this may be extended erase */ - uint8_t wp; - uint8_t uw; - uint8_t rp; - uint8_t ur; - uint8_t crc; -}; - -/* Reset code for ARMv7-M (Cortex-M3) and ARMv6-M (Cortex-M0) - * see ARMv7-M or ARMv6-M Architecture Reference Manual (table B3-8) - * or "The definitive guide to the ARM Cortex-M3", section 14.4. - */ -static const uint8_t stm_reset_code[] = { - 0x01, 0x49, // ldr r1, [pc, #4] ; () - 0x02, 0x4A, // ldr r2, [pc, #8] ; () - 0x0A, 0x60, // str r2, [r1, #0] - 0xfe, 0xe7, // endless: b endless - 0x0c, 0xed, 0x00, 0xe0, // .word 0xe000ed0c = NVIC AIRCR register address - 0x04, 0x00, 0xfa, 0x05 // .word 0x05fa0004 = VECTKEY | SYSRESETREQ -}; - -static const uint32_t stm_reset_code_length = sizeof(stm_reset_code); - -extern const stm32_dev_t devices[]; - -static void stm32_warn_stretching(const char *f) -{ - fprintf(stderr, "Attention !!!\n"); - fprintf(stderr, "\tThis %s error could be caused by your I2C\n", f); - fprintf(stderr, "\tcontroller not accepting \"clock stretching\"\n"); - fprintf(stderr, "\tas required by bootloader.\n"); - fprintf(stderr, "\tCheck \"I2C.txt\" in stm32flash source code.\n"); -} - -static stm32_err_t stm32_get_ack_timeout(const stm32_t *stm, time_t timeout) -{ - struct port_interface *port = stm->port; - uint8_t byte; - port_err_t p_err; - time_t t0, t1; - - if (!(port->flags & PORT_RETRY)) - timeout = 0; - - if (timeout) - time(&t0); - - do { - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_TIMEDOUT && timeout) { - time(&t1); - if (t1 < t0 + timeout) - continue; - } - - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to read ACK byte\n"); - return STM32_ERR_UNKNOWN; - } - - if (byte == STM32_ACK) - return STM32_ERR_OK; - if (byte == STM32_NACK) - return STM32_ERR_NACK; - if (byte != STM32_BUSY) { - fprintf(stderr, "Got byte 0x%02x instead of ACK\n", - byte); - return STM32_ERR_UNKNOWN; - } - } while (1); -} - -static stm32_err_t stm32_get_ack(const stm32_t *stm) -{ - return stm32_get_ack_timeout(stm, 0); -} - -static stm32_err_t stm32_send_command_timeout(const stm32_t *stm, - const uint8_t cmd, - time_t timeout) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - port_err_t p_err; - uint8_t buf[2]; - - buf[0] = cmd; - buf[1] = cmd ^ 0xFF; - p_err = port->write(port, buf, 2); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send command\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, timeout); - if (s_err == STM32_ERR_OK) - return STM32_ERR_OK; - if (s_err == STM32_ERR_NACK) - fprintf(stderr, "Got NACK from device on command 0x%02x\n", cmd); - else - fprintf(stderr, "Unexpected reply from device on command 0x%02x\n", cmd); - return STM32_ERR_UNKNOWN; -} - -static stm32_err_t stm32_send_command(const stm32_t *stm, const uint8_t cmd) -{ - return stm32_send_command_timeout(stm, cmd, 0); -} - -/* if we have lost sync, send a wrong command and expect a NACK */ -static stm32_err_t stm32_resync(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - uint8_t buf[2], ack; - time_t t0, t1; - - time(&t0); - t1 = t0; - - buf[0] = STM32_CMD_ERR; - buf[1] = STM32_CMD_ERR ^ 0xFF; - while (t1 < t0 + STM32_RESYNC_TIMEOUT) { - p_err = port->write(port, buf, 2); - if (p_err != PORT_ERR_OK) { - usleep(500000); - time(&t1); - continue; - } - p_err = port->read(port, &ack, 1); - if (p_err != PORT_ERR_OK) { - time(&t1); - continue; - } - if (ack == STM32_NACK) - return STM32_ERR_OK; - time(&t1); - } - return STM32_ERR_UNKNOWN; -} - -/* - * some command receive reply frame with variable length, and length is - * embedded in reply frame itself. - * We can guess the length, but if we guess wrong the protocol gets out - * of sync. - * Use resync for frame oriented interfaces (e.g. I2C) and byte-by-byte - * read for byte oriented interfaces (e.g. UART). - * - * to run safely, data buffer should be allocated for 256+1 bytes - * - * len is value of the first byte in the frame. - */ -static stm32_err_t stm32_guess_len_cmd(const stm32_t *stm, uint8_t cmd, - uint8_t *data, unsigned int len) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - if (port->flags & PORT_BYTE) { - /* interface is UART-like */ - p_err = port->read(port, data, 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - len = data[0]; - p_err = port->read(port, data + 1, len + 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; - } - - p_err = port->read(port, data, len + 2); - if (p_err == PORT_ERR_OK && len == data[0]) - return STM32_ERR_OK; - if (p_err != PORT_ERR_OK) { - /* restart with only one byte */ - if (stm32_resync(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - p_err = port->read(port, data, 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - } - - fprintf(stderr, "Re sync (len = %d)\n", data[0]); - if (stm32_resync(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - len = data[0]; - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - p_err = port->read(port, data, len + 2); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; -} - -/* - * Some interface, e.g. UART, requires a specific init sequence to let STM32 - * autodetect the interface speed. - * The sequence is only required one time after reset. - * stm32flash has command line flag "-c" to prevent sending the init sequence - * in case it was already sent before. - * User can easily forget adding "-c". In this case the bootloader would - * interpret the init sequence as part of a command message, then waiting for - * the rest of the message blocking the interface. - * This function sends the init sequence and, in case of timeout, recovers - * the interface. - */ -static stm32_err_t stm32_send_init_seq(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - uint8_t byte, cmd = STM32_CMD_INIT; - - p_err = port->write(port, &cmd, 1); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send init to device\n"); - return STM32_ERR_UNKNOWN; - } - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_OK && byte == STM32_ACK) - return STM32_ERR_OK; - if (p_err == PORT_ERR_OK && byte == STM32_NACK) { - /* We could get error later, but let's continue, for now. */ - fprintf(stderr, - "Warning: the interface was not closed properly.\n"); - return STM32_ERR_OK; - } - if (p_err != PORT_ERR_TIMEDOUT) { - fprintf(stderr, "Failed to init device.\n"); - return STM32_ERR_UNKNOWN; - } - - /* - * Check if previous STM32_CMD_INIT was taken as first byte - * of a command. Send a new byte, we should get back a NACK. - */ - p_err = port->write(port, &cmd, 1); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send init to device\n"); - return STM32_ERR_UNKNOWN; - } - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_OK && byte == STM32_NACK) - return STM32_ERR_OK; - fprintf(stderr, "Failed to init device.\n"); - return STM32_ERR_UNKNOWN; -} - -/* find newer command by higher code */ -#define newer(prev, a) (((prev) == STM32_CMD_ERR) \ - ? (a) \ - : (((prev) > (a)) ? (prev) : (a))) - -stm32_t *stm32_init(struct port_interface *port, const char init) -{ - uint8_t len, val, buf[257]; - stm32_t *stm; - int i, new_cmds; - - stm = calloc(sizeof(stm32_t), 1); - stm->cmd = malloc(sizeof(stm32_cmd_t)); - memset(stm->cmd, STM32_CMD_ERR, sizeof(stm32_cmd_t)); - stm->port = port; - - if ((port->flags & PORT_CMD_INIT) && init) - if (stm32_send_init_seq(stm) != STM32_ERR_OK) - return NULL; - - /* get the version and read protection status */ - if (stm32_send_command(stm, STM32_CMD_GVR) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - /* From AN, only UART bootloader returns 3 bytes */ - len = (port->flags & PORT_GVR_ETX) ? 3 : 1; - if (port->read(port, buf, len) != PORT_ERR_OK) - return NULL; - stm->version = buf[0]; - stm->option1 = (port->flags & PORT_GVR_ETX) ? buf[1] : 0; - stm->option2 = (port->flags & PORT_GVR_ETX) ? buf[2] : 0; - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - /* get the bootloader information */ - len = STM32_CMD_GET_LENGTH; - if (port->cmd_get_reply) - for (i = 0; port->cmd_get_reply[i].length; i++) - if (stm->version == port->cmd_get_reply[i].version) { - len = port->cmd_get_reply[i].length; - break; - } - if (stm32_guess_len_cmd(stm, STM32_CMD_GET, buf, len) != STM32_ERR_OK) - return NULL; - len = buf[0] + 1; - stm->bl_version = buf[1]; - new_cmds = 0; - for (i = 1; i < len; i++) { - val = buf[i + 1]; - switch (val) { - case STM32_CMD_GET: - stm->cmd->get = val; break; - case STM32_CMD_GVR: - stm->cmd->gvr = val; break; - case STM32_CMD_GID: - stm->cmd->gid = val; break; - case STM32_CMD_RM: - stm->cmd->rm = val; break; - case STM32_CMD_GO: - stm->cmd->go = val; break; - case STM32_CMD_WM: - case STM32_CMD_WM_NS: - stm->cmd->wm = newer(stm->cmd->wm, val); - break; - case STM32_CMD_ER: - case STM32_CMD_EE: - case STM32_CMD_EE_NS: - stm->cmd->er = newer(stm->cmd->er, val); - break; - case STM32_CMD_WP: - case STM32_CMD_WP_NS: - stm->cmd->wp = newer(stm->cmd->wp, val); - break; - case STM32_CMD_UW: - case STM32_CMD_UW_NS: - stm->cmd->uw = newer(stm->cmd->uw, val); - break; - case STM32_CMD_RP: - case STM32_CMD_RP_NS: - stm->cmd->rp = newer(stm->cmd->rp, val); - break; - case STM32_CMD_UR: - case STM32_CMD_UR_NS: - stm->cmd->ur = newer(stm->cmd->ur, val); - break; - case STM32_CMD_CRC: - stm->cmd->crc = newer(stm->cmd->crc, val); - break; - default: - if (new_cmds++ == 0) - fprintf(stderr, - "GET returns unknown commands (0x%2x", - val); - else - fprintf(stderr, ", 0x%2x", val); - } - } - if (new_cmds) - fprintf(stderr, ")\n"); - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - if (stm->cmd->get == STM32_CMD_ERR - || stm->cmd->gvr == STM32_CMD_ERR - || stm->cmd->gid == STM32_CMD_ERR) { - fprintf(stderr, "Error: bootloader did not returned correct information from GET command\n"); - return NULL; - } - - /* get the device ID */ - if (stm32_guess_len_cmd(stm, stm->cmd->gid, buf, 1) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - len = buf[0] + 1; - if (len < 2) { - stm32_close(stm); - fprintf(stderr, "Only %d bytes sent in the PID, unknown/unsupported device\n", len); - return NULL; - } - stm->pid = (buf[1] << 8) | buf[2]; - if (len > 2) { - fprintf(stderr, "This bootloader returns %d extra bytes in PID:", len); - for (i = 2; i <= len ; i++) - fprintf(stderr, " %02x", buf[i]); - fprintf(stderr, "\n"); - } - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - stm->dev = devices; - while (stm->dev->id != 0x00 && stm->dev->id != stm->pid) - ++stm->dev; - - if (!stm->dev->id) { - fprintf(stderr, "Unknown/unsupported device (Device ID: 0x%03x)\n", stm->pid); - stm32_close(stm); - return NULL; - } - - return stm; -} - -void stm32_close(stm32_t *stm) -{ - if (stm) - free(stm->cmd); - free(stm); -} - -stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address, - uint8_t data[], unsigned int len) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (!len) - return STM32_ERR_OK; - - if (len > 256) { - fprintf(stderr, "Error: READ length limit at 256 bytes\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->rm == STM32_CMD_ERR) { - fprintf(stderr, "Error: READ command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->rm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_send_command(stm, len - 1) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (port->read(port, data, len) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - return STM32_ERR_OK; -} - -stm32_err_t stm32_write_memory(const stm32_t *stm, uint32_t address, - const uint8_t data[], unsigned int len) -{ - struct port_interface *port = stm->port; - uint8_t cs, buf[256 + 2]; - unsigned int i, aligned_len; - stm32_err_t s_err; - - if (!len) - return STM32_ERR_OK; - - if (len > 256) { - fprintf(stderr, "Error: READ length limit at 256 bytes\n"); - return STM32_ERR_UNKNOWN; - } - - /* must be 32bit aligned */ - if (address & 0x3 || len & 0x3) { - fprintf(stderr, "Error: WRITE address and length must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->wm == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - /* send the address and checksum */ - if (stm32_send_command(stm, stm->cmd->wm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - aligned_len = (len + 3) & ~3; - cs = aligned_len - 1; - buf[0] = aligned_len - 1; - for (i = 0; i < len; i++) { - cs ^= data[i]; - buf[i + 1] = data[i]; - } - /* padding data */ - for (i = len; i < aligned_len; i++) { - cs ^= 0xFF; - buf[i + 1] = 0xFF; - } - buf[aligned_len + 1] = cs; - if (port->write(port, buf, aligned_len + 2) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_BLKWRITE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->wm != STM32_CMD_WM_NS) - stm32_warn_stretching("write"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_wunprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->uw == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE UNPROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->uw) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_WUNPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to WRITE UNPROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->uw != STM32_CMD_UW_NS) - stm32_warn_stretching("WRITE UNPROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_wprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->wp == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE PROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->wp) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_WPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to WRITE PROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->wp != STM32_CMD_WP_NS) - stm32_warn_stretching("WRITE PROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_runprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->ur == STM32_CMD_ERR) { - fprintf(stderr, "Error: READOUT UNPROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->ur) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to READOUT UNPROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->ur != STM32_CMD_UR_NS) - stm32_warn_stretching("READOUT UNPROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_readprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->rp == STM32_CMD_ERR) { - fprintf(stderr, "Error: READOUT PROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->rp) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_RPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to READOUT PROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->rp != STM32_CMD_RP_NS) - stm32_warn_stretching("READOUT PROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_erase_memory(const stm32_t *stm, uint8_t spage, uint8_t pages) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - port_err_t p_err; - - if (!pages) - return STM32_ERR_OK; - - if (stm->cmd->er == STM32_CMD_ERR) { - fprintf(stderr, "Error: ERASE command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->er) != STM32_ERR_OK) { - fprintf(stderr, "Can't initiate chip erase!\n"); - return STM32_ERR_UNKNOWN; - } - - /* The erase command reported by the bootloader is either 0x43, 0x44 or 0x45 */ - /* 0x44 is Extended Erase, a 2 byte based protocol and needs to be handled differently. */ - /* 0x45 is clock no-stretching version of Extended Erase for I2C port. */ - if (stm->cmd->er != STM32_CMD_ER) { - /* Not all chips using Extended Erase support mass erase */ - /* Currently known as not supporting mass erase is the Ultra Low Power STM32L15xx range */ - /* So if someone has not overridden the default, but uses one of these chips, take it out of */ - /* mass erase mode, so it will be done page by page. This maximum might not be correct either! */ - if (stm->pid == 0x416 && pages == 0xFF) - pages = 0xF8; /* works for the STM32L152RB with 128Kb flash */ - - if (pages == 0xFF) { - uint8_t buf[3]; - - /* 0xFFFF the magic number for mass erase */ - buf[0] = 0xFF; - buf[1] = 0xFF; - buf[2] = 0x00; /* checksum */ - if (port->write(port, buf, 3) != PORT_ERR_OK) { - fprintf(stderr, "Mass erase error.\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Mass erase failed. Try specifying the number of pages to be erased.\n"); - if (port->flags & PORT_STRETCH_W - && stm->cmd->er != STM32_CMD_EE_NS) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } - - uint16_t pg_num; - uint8_t pg_byte; - uint8_t cs = 0; - uint8_t *buf; - int i = 0; - - buf = malloc(2 + 2 * pages + 1); - if (!buf) - return STM32_ERR_UNKNOWN; - - /* Number of pages to be erased - 1, two bytes, MSB first */ - pg_byte = (pages - 1) >> 8; - buf[i++] = pg_byte; - cs ^= pg_byte; - pg_byte = (pages - 1) & 0xFF; - buf[i++] = pg_byte; - cs ^= pg_byte; - - for (pg_num = spage; pg_num < spage + pages; pg_num++) { - pg_byte = pg_num >> 8; - cs ^= pg_byte; - buf[i++] = pg_byte; - pg_byte = pg_num & 0xFF; - cs ^= pg_byte; - buf[i++] = pg_byte; - } - buf[i++] = cs; - p_err = port->write(port, buf, i); - free(buf); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Page-by-page erase error.\n"); - return STM32_ERR_UNKNOWN; - } - - s_err = stm32_get_ack_timeout(stm, pages * STM32_SECTERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Page-by-page erase failed. Check the maximum pages your device supports.\n"); - if (port->flags & PORT_STRETCH_W - && stm->cmd->er != STM32_CMD_EE_NS) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - - return STM32_ERR_OK; - } - - /* And now the regular erase (0x43) for all other chips */ - if (pages == 0xFF) { - s_err = stm32_send_command_timeout(stm, 0xFF, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } else { - uint8_t cs = 0; - uint8_t pg_num; - uint8_t *buf; - int i = 0; - - buf = malloc(1 + pages + 1); - if (!buf) - return STM32_ERR_UNKNOWN; - - buf[i++] = pages - 1; - cs ^= (pages-1); - for (pg_num = spage; pg_num < (pages + spage); pg_num++) { - buf[i++] = pg_num; - cs ^= pg_num; - } - buf[i++] = cs; - p_err = port->write(port, buf, i); - free(buf); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Erase failed.\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } -} - -static stm32_err_t stm32_run_raw_code(const stm32_t *stm, - uint32_t target_address, - const uint8_t *code, uint32_t code_size) -{ - uint32_t stack_le = le_u32(0x20002000); - uint32_t code_address_le = le_u32(target_address + 8); - uint32_t length = code_size + 8; - uint8_t *mem, *pos; - uint32_t address, w; - - /* Must be 32-bit aligned */ - if (target_address & 0x3) { - fprintf(stderr, "Error: code address must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - mem = malloc(length); - if (!mem) - return STM32_ERR_UNKNOWN; - - memcpy(mem, &stack_le, sizeof(uint32_t)); - memcpy(mem + 4, &code_address_le, sizeof(uint32_t)); - memcpy(mem + 8, code, code_size); - - pos = mem; - address = target_address; - while (length > 0) { - w = length > 256 ? 256 : length; - if (stm32_write_memory(stm, address, pos, w) != STM32_ERR_OK) { - free(mem); - return STM32_ERR_UNKNOWN; - } - - address += w; - pos += w; - length -= w; - } - - free(mem); - return stm32_go(stm, target_address); -} - -stm32_err_t stm32_go(const stm32_t *stm, uint32_t address) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (stm->cmd->go == STM32_CMD_ERR) { - fprintf(stderr, "Error: GO command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->go) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; -} - -stm32_err_t stm32_reset_device(const stm32_t *stm) -{ - uint32_t target_address = stm->dev->ram_start; - - return stm32_run_raw_code(stm, target_address, stm_reset_code, stm_reset_code_length); -} - -stm32_err_t stm32_crc_memory(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (address & 0x3 || length & 0x3) { - fprintf(stderr, "Start and end addresses must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->crc == STM32_CMD_ERR) { - fprintf(stderr, "Error: CRC command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->crc) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = length >> 24; - buf[1] = (length >> 16) & 0xFF; - buf[2] = (length >> 8) & 0xFF; - buf[3] = length & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (port->read(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (buf[4] != (buf[0] ^ buf[1] ^ buf[2] ^ buf[3])) - return STM32_ERR_UNKNOWN; - - *crc = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; - return STM32_ERR_OK; -} - -/* - * CRC computed by STM32 is similar to the standard crc32_be() - * implemented, for example, in Linux kernel in ./lib/crc32.c - * But STM32 computes it on units of 32 bits word and swaps the - * bytes of the word before the computation. - * Due to byte swap, I cannot use any CRC available in existing - * libraries, so here is a simple not optimized implementation. - */ -#define CRCPOLY_BE 0x04c11db7 -#define CRC_MSBMASK 0x80000000 -#define CRC_INIT_VALUE 0xFFFFFFFF -uint32_t stm32_sw_crc(uint32_t crc, uint8_t *buf, unsigned int len) -{ - int i; - uint32_t data; - - if (len & 0x3) { - fprintf(stderr, "Buffer length must be multiple of 4 bytes\n"); - return 0; - } - - while (len) { - data = *buf++; - data |= *buf++ << 8; - data |= *buf++ << 16; - data |= *buf++ << 24; - len -= 4; - - crc ^= data; - - for (i = 0; i < 32; i++) - if (crc & CRC_MSBMASK) - crc = (crc << 1) ^ CRCPOLY_BE; - else - crc = (crc << 1); - } - return crc; -} - -stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc) -{ - uint8_t buf[256]; - uint32_t start, total_len, len, current_crc; - - if (address & 0x3 || length & 0x3) { - fprintf(stderr, "Start and end addresses must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->crc != STM32_CMD_ERR) - return stm32_crc_memory(stm, address, length, crc); - - start = address; - total_len = length; - current_crc = CRC_INIT_VALUE; - while (length) { - len = length > 256 ? 256 : length; - if (stm32_read_memory(stm, address, buf, len) != STM32_ERR_OK) { - fprintf(stderr, - "Failed to read memory at address 0x%08x, target write-protected?\n", - address); - return STM32_ERR_UNKNOWN; - } - current_crc = stm32_sw_crc(current_crc, buf, len); - length -= len; - address += len; - - fprintf(stderr, - "\rCRC address 0x%08x (%.2f%%) ", - address, - (100.0f / (float)total_len) * (float)(address - start) - ); - fflush(stderr); - } - fprintf(stderr, "Done.\n"); - *crc = current_crc; - return STM32_ERR_OK; -} diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/stm32.h b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/stm32.h deleted file mode 100755 index 1688fcb4b..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/stm32.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _STM32_H -#define _STM32_H - -#include -#include "serial.h" - -#define STM32_MAX_RX_FRAME 256 /* cmd read memory */ -#define STM32_MAX_TX_FRAME (1 + 256 + 1) /* cmd write memory */ - -typedef enum { - STM32_ERR_OK = 0, - STM32_ERR_UNKNOWN, /* Generic error */ - STM32_ERR_NACK, - STM32_ERR_NO_CMD, /* Command not available in bootloader */ -} stm32_err_t; - -typedef struct stm32 stm32_t; -typedef struct stm32_cmd stm32_cmd_t; -typedef struct stm32_dev stm32_dev_t; - -struct stm32 { - const serial_t *serial; - struct port_interface *port; - uint8_t bl_version; - uint8_t version; - uint8_t option1, option2; - uint16_t pid; - stm32_cmd_t *cmd; - const stm32_dev_t *dev; -}; - -struct stm32_dev { - uint16_t id; - const char *name; - uint32_t ram_start, ram_end; - uint32_t fl_start, fl_end; - uint16_t fl_pps; // pages per sector - uint16_t fl_ps; // page size - uint32_t opt_start, opt_end; - uint32_t mem_start, mem_end; -}; - -stm32_t *stm32_init(struct port_interface *port, const char init); -void stm32_close(stm32_t *stm); -stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address, - uint8_t data[], unsigned int len); -stm32_err_t stm32_write_memory(const stm32_t *stm, uint32_t address, - const uint8_t data[], unsigned int len); -stm32_err_t stm32_wunprot_memory(const stm32_t *stm); -stm32_err_t stm32_wprot_memory(const stm32_t *stm); -stm32_err_t stm32_erase_memory(const stm32_t *stm, uint8_t spage, - uint8_t pages); -stm32_err_t stm32_go(const stm32_t *stm, uint32_t address); -stm32_err_t stm32_reset_device(const stm32_t *stm); -stm32_err_t stm32_readprot_memory(const stm32_t *stm); -stm32_err_t stm32_runprot_memory(const stm32_t *stm); -stm32_err_t stm32_crc_memory(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc); -stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc); -uint32_t stm32_sw_crc(uint32_t crc, uint8_t *buf, unsigned int len); - -#endif - diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/stm32flash.1 b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/stm32flash.1 deleted file mode 100755 index d37292f6a..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/stm32flash.1 +++ /dev/null @@ -1,407 +0,0 @@ -.TH STM32FLASH 1 "2013\-11\-03" STM32FLASH "User command" -.SH NAME -stm32flash \- flashing utility for STM32 and STM32W through UART or I2C -.SH SYNOPSIS -.B stm32flash -.RB [ \-cfhjkouvCR ] -.RB [ \-a -.IR bus_address ] -.RB [ \-b -.IR baud_rate ] -.RB [ \-m -.IR serial_mode ] -.RB [ \-r -.IR filename ] -.RB [ \-w -.IR filename ] -.RB [ \-e -.IR num ] -.RB [ \-n -.IR count ] -.RB [ \-g -.IR address ] -.RB [ \-s -.IR start_page ] -.RB [ \-S -.IR address [: length ]] -.RB [ \-F -.IR RX_length [: TX_length ]] -.RB [ \-i -.IR GPIO_string ] -.RI [ tty_device -.R | -.IR i2c_device ] - -.SH DESCRIPTION -.B stm32flash -reads or writes the flash memory of STM32 and STM32W. - -It requires the STM32[W] to embed a bootloader compliant with ST -application note AN3155. -.B stm32flash -uses the serial port -.I tty_device -to interact with the bootloader of STM32[W]. - -.SH OPTIONS -.TP -.BI "\-a" " bus_address" -Specify address on bus for -.IR i2c_device . -This option is mandatory for I2C interface. - -.TP -.BI "\-b" " baud_rate" -Specify baud rate speed of -.IR tty_device . -Please notice that the ST bootloader can automatically detect the baud rate, -as explaned in chapter 2 of AN3155. -This option could be required together with option -.B "\-c" -or if following interaction with bootloader is expected. -Default is -.IR 57600 . - -.TP -.BI "\-m" " mode" -Specify the format of UART data. -.I mode -is a three characters long string where each character specifies, in -this strict order, character size, parity and stop bits. -The only values currenly used are -.I 8e1 -for standard STM32 bootloader and -.I 8n1 -for standard STM32W bootloader. -Default is -.IR 8e1 . - -.TP -.BI "\-r" " filename" -Specify to read the STM32[W] flash and write its content in -.I filename -in raw binary format (see below -.BR "FORMAT CONVERSION" ). - -.TP -.BI "\-w" " filename" -Specify to write the STM32[W] flash with the content of -.IR filename . -File format can be either raw binary or intel hex (see below -.BR "FORMAT CONVERSION" ). -The file format is automatically detected. -To by\-pass format detection and force binary mode (e.g. to -write an intel hex content in STM32[W] flash), use -.B \-f -option. - -.TP -.B \-u -Specify to disable write\-protection from STM32[W] flash. -The STM32[W] will be reset after this operation. - -.TP -.B \-j -Enable the flash read\-protection. - -.TP -.B \-k -Disable the flash read\-protection. - -.TP -.B \-o -Erase only. - -.TP -.BI "\-e" " num" -Specify to erase only -.I num -pages before writing the flash. Default is to erase the whole flash. With -.B \-e 0 -the flash would not be erased. - -.TP -.B \-v -Specify to verify flash content after write operation. - -.TP -.BI "\-n" " count" -Specify to retry failed writes up to -.I count -times. Default is 10 times. - -.TP -.BI "\-g" " address" -Specify address to start execution from (0 = flash start). - -.TP -.BI "\-s" " start_page" -Specify flash page offset (0 = flash start). - -.TP -.BI "\-S" " address" "[:" "length" "]" -Specify start address and optionally length for read/write/erase/crc operations. - -.TP -.BI "\-F" " RX_length" "[:" "TX_length" "]" -Specify the maximum frame size for the current interface. -Due to STM32 bootloader protocol, host will never handle frames bigger than -256 byte in RX or 258 byte in TX. -Due to current code, lowest limit in RX is 20 byte (to read a complete reply -of command GET). Minimum limit in TX is 5 byte, required by protocol. - -.TP -.B \-f -Force binary parser while reading file with -.BR "\-w" "." - -.TP -.B \-h -Show help. - -.TP -.B \-c -Specify to resume the existing UART connection and don't send initial -INIT sequence to detect baud rate. Baud rate must be kept the same as the -existing connection. This is useful if the reset fails. - -.TP -.BI "\-i" " GPIO_string" -Specify the GPIO sequences on the host to force STM32[W] to enter and -exit bootloader mode. GPIO can either be real GPIO connected from host to -STM32[W] beside the UART connection, or UART's modem signals used as -GPIO. (See below -.B BOOTLOADER GPIO SEQUENCE -for the format of -.I GPIO_string -and further explanation). - -.TP -.B \-C -Specify to compute CRC on memory content. -By default the CRC is computed on the whole flash content. -Use -.B "\-S" -to provide different memory address range. - -.TP -.B \-R -Specify to reset the device at exit. -This option is ignored if either -.BR "\-g" "," -.BR "\-j" "," -.B "\-k" -or -.B "\-u" -is also specified. - -.SH BOOTLOADER GPIO SEQUENCE -This feature is currently available on Linux host only. - -As explained in ST application note AN2606, after reset the STM32 will -execute either the application program in user flash or the bootloader, -depending on the level applied at specific pins of STM32 during reset. - -STM32 bootloader is automatically activated by configuring the pins -BOOT0="high" and BOOT1="low" and then by applying a reset. -Application program in user flash is activated by configuring the pin -BOOT0="low" (the level on BOOT1 is ignored) and then by applying a reset. - -When GPIO from host computer are connected to either configuration and -reset pins of STM32, -.B stm32flash -can control the host GPIO to reset STM32 and to force execution of -bootloader or execution of application program. - -The sequence of GPIO values to entry to and exit from bootloader mode is -provided with command line option -.B "\-i" -.IR "GPIO_string" . - -.PD 0 -The format of -.IR "GPIO_string" " is:" -.RS -GPIO_string = [entry sequence][:[exit sequence]] -.P -sequence = [\-]n[,sequence] -.RE -.P -In the above sequences, negative numbers correspond to GPIO at "low" level; -numbers without sign correspond to GPIO at "high" level. -The value "n" can either be the GPIO number on the host system or the -string "rts", "dtr" or "brk". The strings "rts" and "dtr" drive the -corresponding UART's modem lines RTS and DTR as GPIO. -The string "brk" forces the UART to send a BREAK sequence on TX line; -after BREAK the UART is returned in normal "non\-break" mode. -Note: the string "\-brk" has no effect and is ignored. -.PD - -.PD 0 -As example, let's suppose the following connection between host and STM32: -.IP \(bu 2 -host GPIO_3 connected to reset pin of STM32; -.IP \(bu 2 -host GPIO_4 connected to STM32 pin BOOT0; -.IP \(bu 2 -host GPIO_5 connected to STM32 pin BOOT1. -.PD -.P - -In this case, the sequence to enter in bootloader mode is: first put -GPIO_4="high" and GPIO_5="low"; then send reset pulse by GPIO_3="low" -followed by GPIO_3="high". -The corresponding string for -.I GPIO_string -is "4,\-5,\-3,3". - -To exit from bootloade and run the application program, the sequence is: -put GPIO_4="low"; then send reset pulse. -The corresponding string for -.I GPIO_string -is "\-4,\-3,3". - -The complete command line flag is "\-i 4,\-5,\-3,3:\-4,\-3,3". - -STM32W uses pad PA5 to select boot mode; if during reset PA5 is "low" then -STM32W will enter in bootloader mode; if PA5 is "high" it will execute the -program in flash. - -As example, supposing GPIO_3 connected to PA5 and GPIO_2 to STM32W's reset. -The command: -.PD 0 -.RS -stm32flash \-i \-3,\-2,2:3,\-2,2 /dev/ttyS0 -.RE -provides: -.IP \(bu 2 -entry sequence: GPIO_3=low, GPIO_2=low, GPIO_2=high -.IP \(bu 2 -exit sequence: GPIO_3=high, GPIO_2=low, GPIO_2=high -.PD - -.SH EXAMPLES -Get device information: -.RS -.PD 0 -.P -stm32flash /dev/ttyS0 -.PD -.RE - -Write with verify and then start execution: -.RS -.PD 0 -.P -stm32flash \-w filename \-v \-g 0x0 /dev/ttyS0 -.PD -.RE - -Read flash to file: -.RS -.PD 0 -.P -stm32flash \-r filename /dev/ttyS0 -.PD -.RE - -Start execution: -.RS -.PD 0 -.P -stm32flash \-g 0x0 /dev/ttyS0 -.PD -.RE - -Specify: -.PD 0 -.IP \(bu 2 -entry sequence: RTS=low, DTR=low, DTR=high -.IP \(bu 2 -exit sequence: RTS=high, DTR=low, DTR=high -.P -.RS -stm32flash \-i \-rts,\-dtr,dtr:rts,\-dtr,dtr /dev/ttyS0 -.PD -.RE - -.SH FORMAT CONVERSION -Flash images provided by ST or created with ST tools are often in file -format Motorola S\-Record. -Conversion between raw binary, intel hex and Motorola S\-Record can be -done through software package SRecord. - -.SH AUTHORS -The original software package -.B stm32flash -is written by -.I Geoffrey McRae -and is since 2012 maintained by -.IR "Tormod Volden " . - -Man page and extension to STM32W and I2C are written by -.IR "Antonio Borneo " . - -Please report any bugs at the project homepage -http://stm32flash.googlecode.com . - -.SH SEE ALSO -.BR "srec_cat" "(1)," " srec_intel" "(5)," " srec_motorola" "(5)." - -The communication protocol used by ST bootloader is documented in -following ST application notes, depending on communication port. -The current version of -.B stm32flash -only supports -.I UART -and -.I I2C -ports. -.PD 0 -.P -.IP \(bu 2 -AN3154: CAN protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/CD00264321.pdf -.RE - -.P -.IP \(bu 2 -AN3155: USART protocol used in the STM32(TM) bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/CD00264342.pdf -.RE - -.P -.IP \(bu 2 -AN4221: I2C protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/DM00072315.pdf -.RE - -.P -.IP \(bu 2 -AN4286: SPI protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/DM00081379.pdf -.RE - -.PD - - -Boot mode selection for STM32 is documented in ST application note -AN2606, available from the ST website: -.PD 0 -.P -http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf -.PD - -.SH LICENSE -.B stm32flash -is distributed under GNU GENERAL PUBLIC LICENSE Version 2. -Copy of the license is available within the source code in the file -.IR "gpl\-2.0.txt" . diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/utils.c b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/utils.c deleted file mode 100755 index 271bb3ed7..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/utils.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include "utils.h" - -/* detect CPU endian */ -char cpu_le() { - const uint32_t cpu_le_test = 0x12345678; - return ((const unsigned char*)&cpu_le_test)[0] == 0x78; -} - -uint32_t be_u32(const uint32_t v) { - if (cpu_le()) - return ((v & 0xFF000000) >> 24) | - ((v & 0x00FF0000) >> 8) | - ((v & 0x0000FF00) << 8) | - ((v & 0x000000FF) << 24); - return v; -} - -uint32_t le_u32(const uint32_t v) { - if (!cpu_le()) - return ((v & 0xFF000000) >> 24) | - ((v & 0x00FF0000) >> 8) | - ((v & 0x0000FF00) << 8) | - ((v & 0x000000FF) << 24); - return v; -} diff --git a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/utils.h b/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/utils.h deleted file mode 100755 index a8d37d2d5..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/stm32flash_serial/src/utils.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_UTILS -#define _H_UTILS - -#include - -char cpu_le(); -uint32_t be_u32(const uint32_t v); -uint32_t le_u32(const uint32_t v); - -#endif diff --git a/arduino/opencr_arduino/tools/linux64/src/upload-reset/upload-reset.c b/arduino/opencr_arduino/tools/linux64/src/upload-reset/upload-reset.c deleted file mode 100755 index 1d03bff51..000000000 --- a/arduino/opencr_arduino/tools/linux64/src/upload-reset/upload-reset.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (C) 2015 Roger Clark - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * - * Utility to send the reset sequence on RTS and DTR and chars - * which resets the libmaple and causes the bootloader to be run - * - * - * - * Terminal control code by Heiko Noordhof (see copyright below) - */ - - - -/* Copyright (C) 2003 Heiko Noordhof - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Function prototypes (belong in a seperate header file) */ -int openserial(char *devicename); -void closeserial(void); -int setDTR(unsigned short level); -int setRTS(unsigned short level); - - -/* Two globals for use by this module only */ -static int fd; -static struct termios oldterminfo; - - -void closeserial(void) -{ - tcsetattr(fd, TCSANOW, &oldterminfo); - close(fd); -} - - -int openserial(char *devicename) -{ - struct termios attr; - - if ((fd = open(devicename, O_RDWR)) == -1) return 0; /* Error */ - atexit(closeserial); - - if (tcgetattr(fd, &oldterminfo) == -1) return 0; /* Error */ - attr = oldterminfo; - attr.c_cflag |= CRTSCTS | CLOCAL; - attr.c_oflag = 0; - if (tcflush(fd, TCIOFLUSH) == -1) return 0; /* Error */ - if (tcsetattr(fd, TCSANOW, &attr) == -1) return 0; /* Error */ - - /* Set the lines to a known state, and */ - /* finally return non-zero is successful. */ - return setRTS(0) && setDTR(0); -} - - -/* For the two functions below: - * level=0 to set line to LOW - * level=1 to set line to HIGH - */ - -int setRTS(unsigned short level) -{ - int status; - - if (ioctl(fd, TIOCMGET, &status) == -1) { - perror("setRTS(): TIOCMGET"); - return 0; - } - if (level) status |= TIOCM_RTS; - else status &= ~TIOCM_RTS; - if (ioctl(fd, TIOCMSET, &status) == -1) { - perror("setRTS(): TIOCMSET"); - return 0; - } - return 1; -} - - -int setDTR(unsigned short level) -{ - int status; - - if (ioctl(fd, TIOCMGET, &status) == -1) { - perror("setDTR(): TIOCMGET"); - return 0; - } - if (level) status |= TIOCM_DTR; - else status &= ~TIOCM_DTR; - if (ioctl(fd, TIOCMSET, &status) == -1) { - perror("setDTR: TIOCMSET"); - return 0; - } - return 1; -} - -/* This portion of code was written by Roger Clark - * It was informed by various other pieces of code written by Leaflabs to reset their - * Maple and Maple mini boards - */ - -main(int argc, char *argv[]) -{ - - if (argc<2 || argc >3) - { - printf("Usage upload-reset \n\r"); - return; - } - - if (openserial(argv[1])) - { - // Send magic sequence of DTR and RTS followed by the magic word "1EAF" - setRTS(false); - setDTR(false); - setDTR(true); - - usleep(50000L); - - setDTR(false); - setRTS(true); - setDTR(true); - - usleep(50000L); - - setDTR(false); - - usleep(50000L); - - write(fd,"1EAF",4); - - closeserial(); - if (argc==3) - { - usleep(atol(argv[2])*1000L); - } - } - else - { - printf("Failed to open serial device.\n\r"); - } -} diff --git a/arduino/opencr_arduino/tools/linux64/stlink/st-flash b/arduino/opencr_arduino/tools/linux64/stlink/st-flash deleted file mode 100755 index 9a0ac6536..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/stlink/st-flash and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/stlink/st-info b/arduino/opencr_arduino/tools/linux64/stlink/st-info deleted file mode 100755 index 3a5e5e80e..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/stlink/st-info and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/stlink/st-term b/arduino/opencr_arduino/tools/linux64/stlink/st-term deleted file mode 100755 index 8bdc1a612..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/stlink/st-term and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/stlink/st-util b/arduino/opencr_arduino/tools/linux64/stlink/st-util deleted file mode 100755 index 014919f10..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/stlink/st-util and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/stlink_upload b/arduino/opencr_arduino/tools/linux64/stlink_upload deleted file mode 100755 index 24e528d5b..000000000 --- a/arduino/opencr_arduino/tools/linux64/stlink_upload +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# Check for leaf device. -function leaf_status() -{ - -this_leaf_status=$(lsusb |grep "1eaf" | awk '{ print $NF}') -# Find the mode of the leaf bootloader -case $this_leaf_status in - "1eaf:0003") - echo "dfu" - ;; - "1eaf:0004") - echo "ttyACMx" - ;; - *) - #echo "$this_leaf_status" - echo "unknown" - ;; -esac -} - -# You will need the usb-reset code, see https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Using-a-generic-stm32-board-on-linux-with-Maple-bootloader -# -USBRESET=$(which usb-reset) || USBRESET="./usb-reset" - -# Check to see if a maple compatible board is attached -LEAF_STATUS=$(leaf_status) -echo "USB Status [$LEAF_STATUS]" - -$(dirname $0)/stlink/st-flash write "$4" 0x8000000 - -sleep 4 -# Reset the usb device to bring up the tty rather than DFU -"$USBRESET" "/dev/bus/usb/$(lsusb |grep "1eaf" |awk '{print $2,$4}'|sed 's/\://g'|sed 's/ /\//g')" >/dev/null 2>&1 -# Check to see if a maple compatible board is attached -LEAF_STATUS=$(leaf_status) -echo "USB Status [$LEAF_STATUS]" -# Check to see if the tty came up -TTY_DEV=$(find /dev -cmin -2 |grep ttyAC) -echo -e "Waiting for tty device $TTY_DEV \n" -sleep 20 -echo -e "$TTY_DEV should now be available.\n" -exit 0 - diff --git a/arduino/opencr_arduino/tools/linux64/stm32flash/stm32flash b/arduino/opencr_arduino/tools/linux64/stm32flash/stm32flash deleted file mode 100755 index 7e067aee0..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/stm32flash/stm32flash and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/upload-reset b/arduino/opencr_arduino/tools/linux64/upload-reset deleted file mode 100755 index 26985b857..000000000 Binary files a/arduino/opencr_arduino/tools/linux64/upload-reset and /dev/null differ diff --git a/arduino/opencr_arduino/tools/linux64/upload_router b/arduino/opencr_arduino/tools/linux64/upload_router deleted file mode 100755 index b74244d29..000000000 --- a/arduino/opencr_arduino/tools/linux64/upload_router +++ /dev/null @@ -1,112 +0,0 @@ -#!/bin/bash -# Translates the windows Arduino IDE upload call - something like.. -# -# upload_router ttyUSB0 1 1EAF:0003 /tmp/build9114565021046468906.tmp/STM32_Blink.cpp maple_dfu 0 -# -# to the linux dfu-util equivalent of the form... -# -# dfu-util -D ./STM32_Blink.cpp.bin -d 1eaf:0003 --intf 0 --alt 1 -# -# - -function leaf_status() -{ - -this_leaf_status=$(lsusb |grep "1eaf" | awk '{ print $NF}') -# Find the mode of the leaf bootloader -case $this_leaf_status in - "1eaf:0003") - echo "dfu" - ;; - "1eaf:0004") - echo "ttyACMx" - ;; - *) - #echo "$this_leaf_status" - echo "unknown" - ;; -esac -} - - -DEVICE="$3" -# Lowercase the 1eaf device name, since in Windows land everybody shouts. -DEVICE=${DEVICE,,} - -BINFILE="$4.bin" -INTERFACE="$6" -ALT_INTERFACE="$2" - -# You will need the usb-reset code, see https://github.com/rogerclarkmelbourne/Arduino_STM32/wiki/Using-a-generic-stm32-board-on-linux-with-Maple-bootloader -# -USBRESET=$(which usb-reset) || USBRESET="./usb-reset" - -# Check to see if a maple compatible board is attached -LEAF_STATUS=$(leaf_status) - -# Borard not found, or no boot loader on board. -if [[ $(leaf_status) = "unknown" ]] -then - echo "STM32 Maple Bootloader compatible board not found." - sleep 5 - exit 1 -fi - -# We got this far, so we need to get the board in bootloader mode. -# After the timeout period, the board goes back in to serial mode, we need it in dfu mode, which happens for the first few seconds at power on -# so we ask the user to unplug and re-plug the board. -echo -e "\n\rSTM32 Maple board is in $LEAF_STATUS mode." - -echo "Please unplug and replug the USB cable to the Maple device." -sleep 2 -# On unplugging the board will be "unknown" -while [[ $(leaf_status) != "unknown" ]] -do - echo -n "." - sleep 1 -done -# On re-plugging the board will be "dfu" -while [[ $(leaf_status) != "dfu" ]] -do - echo -n "." - sleep 1 -done - -echo -e "\n\rProgramming STM32 device with dfu-util" -until dfu-util -D "$BINFILE" -d "$DEVICE" --intf "$INTERFACE" --alt "$ALT_INTERFACE" 2>&1 -do - echo -n "." - sleep 1 -done - -echo -e "\n\rUnplug and replug the USB cable to the STM32 board again please...." -while [[ $(leaf_status) != "unknown" ]] -do - echo -n "." - sleep 1 -done - -echo -e "\n\rReconnecting" -while [[ $(leaf_status) = "unknown" ]] -do - echo -n "." - sleep 1 -done - -echo -e "\n\rWaiting for bootloader to exit." -for i in {1..6} -do - echo -n "." - sleep 1 -done - -"$USBRESET" "/dev/bus/usb/$(lsusb |grep "1eaf" |awk '{print $2,$4}'|sed 's/\://g'|sed 's/ /\//g')" >/dev/null 2>&1 - -while [[ $(leaf_status) = "unknown" ]] -do - echo -n "." - sleep 1 -done -THIS_TTY=$(find /dev/ttyACM* -cmin -2) -echo -e "\n\rSTM32 Maple board serial port re-created..." -echo -e "\n\rSerial port is $THIS_TTY Please allow 15 seconds before attempting to read from serial port." diff --git a/arduino/opencr_arduino/tools/macosx/maple_upload b/arduino/opencr_arduino/tools/macosx/maple_upload deleted file mode 100755 index 8d15eff8f..000000000 --- a/arduino/opencr_arduino/tools/macosx/maple_upload +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash - -set -e - -if [ $# -lt 4 ]; then - echo "Usage: $0 $# " >&2 - exit 1 -fi -dummy_port=$1; altID=$2; usbID=$3; binfile=$4;dummy_port_fullpath="/dev/$1" - - -# Get the directory where the script is running. -DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) - - -# ----------------- Old code to reset the USB - which doesn't seem to work -------- -# -#if we can find the Serial device try resetting it and then sleeping for 1 sec while the board reboots -#if [ -e $dummy_port_fullpath ]; then -# echo "resetting " $dummy_port_fullpath -# stty -f $dummy_port_fullpath 1200 -# sleep 1 -## stty -f $dummy_port_fullpath 1200 -## sleep 1 -#fi -# ------------------ End of old code ----------------- - -# ----------------- IMPORTANT ----------------- -# The 2nd parameter to upload-reset is the delay after resetting before it exits -# This value is in milliseonds -# You may need to tune this to your system -# 750ms to 1500ms seems to work on my Mac - -${DIR}/upload-reset ${dummy_port_fullpath} 750 - -if [ $# -eq 5 ]; then - dfuse_addr="--dfuse-address $5" -else - dfuse_addr="" -fi - -#DFU_UTIL=/usr/local/bin/dfu-util -DFU_UTIL=${DIR}/dfu-util/dfu-util -if [ ! -x ${DFU_UTIL} ]; then - DFU_UTIL=/opt/local/bin/dfu-util -fi - -if [ ! -x ${DFU_UTIL} ]; then - echo "$0: error: cannot find ${DFU_UTIL}" >&2 - exit 2 -fi - -${DFU_UTIL} -d ${usbID} -a ${altID} -D ${binfile} -R ${dfuse_addr} -R diff --git a/arduino/opencr_arduino/tools/macosx/serial_upload b/arduino/opencr_arduino/tools/macosx/serial_upload deleted file mode 100755 index 05d17c6e5..000000000 --- a/arduino/opencr_arduino/tools/macosx/serial_upload +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -$(dirname $0)/stm32flash/stm32flash -g 0x8000000 -b 230400 -w "$4" /dev/"$1" diff --git a/arduino/opencr_arduino/tools/macosx/src/build_dfu-util.sh b/arduino/opencr_arduino/tools/macosx/src/build_dfu-util.sh deleted file mode 100755 index 3563f576c..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/build_dfu-util.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -sudo apt-get build-dep dfu-util -sudo apt-get install build-essentials -sudo apt-get install libusb-1.0-0-dev -sudo apt-get install autoconf automake autotools-dev - -cd dfu-util -./autogen.sh -./configure -make -cp src/dfu-util ../../linux/dfu-util -cp src/dfu-suffix ../../linux/dfu-util -cp src/dfu-prefix ../../linux/dfu-util - diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/AUTHORS b/arduino/opencr_arduino/tools/macosx/src/dfu-util/AUTHORS deleted file mode 100755 index 1b36c739c..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/AUTHORS +++ /dev/null @@ -1,30 +0,0 @@ -Authors ordered by first contribution. - -Harald Welte -Werner Almesberger -Michael Lauer -Jim Huang -Stefan Schmidt -Daniel Willmann -Mike Frysinger -Uwe Hermann -C. Scott Ananian -Bernard Blackham -Holger Freyther -Marc Singer -James Perkins -Tommi Keisala -Pascal Schweizer -Bradley Scott -Uwe Bonnes -Andrey Smirnov -Jussi Timperi -Hans Petter Selasky -Bo Shen -Henrique de Almeida Mendonca -Bernd Krumboeck -Dennis Meier -Veli-Pekka Peltola -Dave Hylands -Michael Grzeschik -Paul Fertser diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/COPYING b/arduino/opencr_arduino/tools/macosx/src/dfu-util/COPYING deleted file mode 100755 index d60c31a97..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/ChangeLog b/arduino/opencr_arduino/tools/macosx/src/dfu-util/ChangeLog deleted file mode 100755 index 37f1addba..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/ChangeLog +++ /dev/null @@ -1,93 +0,0 @@ -0.8: - o New, separate dfu-prefix tool (Uwe Bonnes) - o Allow filtering on serial number (Uwe Bonnes) - o Improved VID/PID/serial filtering (Bradley Scott) - o Support reading firmware from stdin (Tormod Volden) - o Warn if missing DFU suffix (Tormod Volden) - o Improved progress bar (Hans Petter Selasky) - o Fix dfuse leave option (Uwe Bonnes) - o Major code rework (Hans Petter Selasky) - o MS Visual Studio build support (Henrique Mendonca) - o dfuse-pack.py tool for .dfu files (Antonio Galeo) - o Many other fixes from many people - -2014-09-13: Tormod Volden - -0.7: - o Support for TI Stellaris devices (Tommi Keisala) - o Fix libusb detection on MacOSX (Marc Singer) - o Fix libusb detection on FreeBSD (Tormod Volden) - o Improved DfuSe support (Tormod Volden) - o Support all special commands (leave, unprotect, mass-erase) - o Arbitrary upload lengths - o "force" option for various possible (dangerous) overrides - -2012-10-07: Tormod Volden - -0.6: - o Add detach mode (Stefan Schmidt) - o Check return value on all libusb calls (Tormod Volden) - o Fix segmentation fault with -s option (Tormod Volden) - o Add DFU suffix manipulation tool (Stefan Schmidt) - o Port to Windows: (Tormod Volden, some parts based on work from Satz - Klauer) - o Port file handling to stdio streams - o Sleep() macros - o C99 types - o Pack structs - o Detect DfuSe device correctly on big-endian architectures (Tormod - Volden) - o Add dfuse progress indication on download (Tormod Volden) - o Cleanup: gcc pedantic, gcc extension, ... (Tormod Volden) - o Rely on page size from functional descriptor. Please report if you get - an error about it. (Tormod Volden) - o Add quirk for Maple since it reports wrong DFU version (Tormod Volden) - -2012-04-22: Stefan Schmidt - -0.5: - o DfuSe extension support for ST devices (Tormod Volden) - o Add initial support for bitWillDetach flag from DFU 1.1 (Tormod - Volden) - o Internal cleanup and some manual page fixes (Tormod Volden) - -2011-11-02: Stefan Schmidt - -0.4: - o Rework to use libusb-1.0 (Stefan Schmidt) - o DFU suffix support (Tormod Volden, Stefan Schmidt) - o Sspeed up DFU downloads directly into memory (Bernard Blackham) - o More flexible -d vid:pid parsing (Tormod Volden) - o Many bug fixes and cleanups - -2011-07-20: Stefan Schmidt - -0.3: - o quirks: Add OpenOCD to the poll timeout quirk table. - -2010-12-22: Stefan Schmidt - -0.2: - o Fix some typos on the website and the README (Antonio Ospite, Uwe - Hermann) - o Remove build rule for a static binary. We can use autotools for this. - (Mike Frysinger) - o Fix infinite loop in download error path (C. Scott Ananian) - o Break out to show the 'finished' in upload (C. Scott Ananian) - o Add GPLv2+ headers (Harald Welte) - o Remove dead code (commands.[ch]) remnescent of dfu-programmer (Harald - Welte) - o Simple quirk system with Openmoko quirk for missing bwPollTimeout (Tormod Volden) - o New default (1024) and clamping of transfer size (Tormod Volden) - o Verify sending of completion packet (Tormod Volden) - o Look for DFU functional descriptor among all descriptors (Tormod - Volden) - o Print out in which direction we are transferring data - o Abort in upload if the file already exists - -2010-11-17 Stefan Schmidt - -0.1: - Initial release - -2010-05-23 Stefan Schmidt diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/DEVICES.txt b/arduino/opencr_arduino/tools/macosx/src/dfu-util/DEVICES.txt deleted file mode 100755 index bdd9f1f2e..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/DEVICES.txt +++ /dev/null @@ -1,20 +0,0 @@ -List of supported software and hardware products: - -Software user (bootloader, etc) -------------------------------- -- Sam7DFU: http://www.openpcd.org/Sam7dfu -- U-boot: DFU patches -- Barebox: http://www.barebox.org/ -- Leaflabs: http://code.google.com/p/leaflabs/ -- Blackmagic DFU - -Products using DFU ------------------- -- OpenPCD (sam7dfu) -- Openmoko Neo 1973 and Freerunner (u-boot with DFU patches) -- Leaflabs Maple -- ATUSB from Qi Hardware -- STM32F105/7, STM32F2/F3/F4 in System Bootloader -- Blackmagic debug probe -- NXP LPC31xx/LPC43XX, e.g. LPC-Link and LPC-Link2, need binaries - with LPC prefix and encoding (LPC-Link) diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/Makefile.am b/arduino/opencr_arduino/tools/macosx/src/dfu-util/Makefile.am deleted file mode 100755 index 641dda58a..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = src doc - -EXTRA_DIST = autogen.sh TODO DEVICES.txt dfuse-pack.py diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/README b/arduino/opencr_arduino/tools/macosx/src/dfu-util/README deleted file mode 100755 index 0f8f2621a..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/README +++ /dev/null @@ -1,20 +0,0 @@ -Dfu-util - Device Firmware Upgrade Utilities - -Dfu-util is the host side implementation of the DFU 1.0 [1] and DFU 1.1 [2] -specification of the USB forum. - -DFU is intended to download and upload firmware to devices connected over -USB. It ranges from small devices like micro-controller boards up to mobile -phones. With dfu-util you are able to download firmware to your device or -upload firmware from it. - -dfu-util has been tested with Openmoko Neo1973 and Freerunner and many -other devices. - -[1] DFU 1.0 spec: http://www.usb.org/developers/devclass_docs/usbdfu10.pdf -[2] DFU 1.1 spec: http://www.usb.org/developers/devclass_docs/DFU_1.1.pdf - -The official website is: - - http://dfu-util.gnumonks.org/ - diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/TODO b/arduino/opencr_arduino/tools/macosx/src/dfu-util/TODO deleted file mode 100755 index 900c30c29..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/TODO +++ /dev/null @@ -1,14 +0,0 @@ -DfuSe: -- Do erase and write in two separate passes when downloading -- Skip "Set Address" command when downloading contiguous blocks -- Implement "Get Commands" command - -Devices: -- Research iPhone/iPod/iPad support - Heavily modified dfu-util fork here: - https://github.com/planetbeing/xpwn/tree/master/dfu-util -- Test against Niftylights - -Non-Code: -- Logo -- Re-License as LGPL for usage as library? diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/autogen.sh b/arduino/opencr_arduino/tools/macosx/src/dfu-util/autogen.sh deleted file mode 100755 index e67aed39a..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/autogen.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -autoreconf -v -i diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/configure.ac b/arduino/opencr_arduino/tools/macosx/src/dfu-util/configure.ac deleted file mode 100755 index 86221143f..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/configure.ac +++ /dev/null @@ -1,41 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59) -AC_INIT([dfu-util],[0.8],[dfu-util@lists.gnumonks.org],,[http://dfu-util.gnumonks.org]) -AC_CONFIG_AUX_DIR(m4) -AM_INIT_AUTOMAKE([foreign]) -AC_CONFIG_HEADERS([config.h]) - -# Test for new silent rules and enable only if they are available -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -# Checks for programs. -AC_PROG_CC - -# Checks for libraries. -# On FreeBSD the libusb-1.0 is called libusb and resides in system location -AC_CHECK_LIB([usb], [libusb_init],, [native_libusb=no],) -AS_IF([test x$native_libusb = xno], [ - PKG_CHECK_MODULES([USB], [libusb-1.0 >= 1.0.0],, - AC_MSG_ERROR([*** Required libusb-1.0 >= 1.0.0 not installed ***])) -]) -AC_CHECK_LIB([usbpath],[usb_path2devnum],,,-lusb) - -LIBS="$LIBS $USB_LIBS" -CFLAGS="$CFLAGS $USB_CFLAGS" - -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([usbpath.h windows.h sysexits.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_TYPE_SIZE_T - -# Checks for library functions. -AC_FUNC_MEMCMP -AC_CHECK_FUNCS([ftruncate getpagesize nanosleep err]) - -AC_CONFIG_FILES(Makefile src/Makefile doc/Makefile) -AC_OUTPUT diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/README b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/README deleted file mode 100755 index 00d3d1a96..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/README +++ /dev/null @@ -1,77 +0,0 @@ -Device: -------- -qi-hardware-atusb: -- Qi Hardware ben-wpan -- DFU implementation: - http://projects.qi-hardware.com/index.php/p/ben-wpan/source/tree/master/atusb/fw/usb -- Tester: Stefan Schmidt - -openpcd: -- OpenPCD RFID reader -- DFU implementation: SAM7DFU - http://www.openpcd.org/Sam7dfu, git://git.gnumonks.org/openpcd.git -- Tester: Stefan Schmidt - -simtrace: -- Sysmocom SimTrace -- DFU implementation: SAM7DFU - http://www.openpcd.org/Sam7dfu, git://git.gnumonks.org/openpcd.git -- Tester: Stefan Schmidt - -openmoko-freerunner: -- Openmoko Freerunner -- DFU implementation: Old U-Boot - http://git.openmoko.org/?p=u-boot.git;a=shortlog;h=refs/heads/mokopatches -- Tester: Stefan Schmidt - -openmoko-neo1973: -- Openmoko Neo1073 -- DFU implementation: Old U-Boot - http://git.openmoko.org/?p=u-boot.git;a=shortlog;h=refs/heads/mokopatches -- Tester: Stefan Schmidt - -tdk-bluetooth: -- TDK Corp. Bluetooth Adapter -- DFU implementation: closed soure -- Only upload has been tested -- Tester: Stefan Schmidt - -stm32f107: -- STM32 microcontrollers with built-in (ROM) DFU loader -- DFU implementation: Closed source but probably similar to the one - in their USB device libraries. Some relevant application notes: - http://www.st.com -> AN3156 and AN2606 -- Tested by Uwe Bonnes - -stm32f4discovery: -- STM32 microcontroller board with built-in (ROM) DFU loader -- DFU implementation: Closed source, probably similar to stm32f107. -- Tested by Joe Rothweiler - -dso-nano: -- DSO Nano pocket oscilloscope -- DFU implementation: Based on ST Microelectronics USB FS Library 1.0 - http://dsonano.googlecode.com/files/DS0201_OpenSource.rar -- Tester: Tormod Volden - -opc-20: -- Custom devices based on STM32F1xx -- DFU implementation: ST Microelectronics USB FS Device Library 3.1.0 - http://www.st.com -> um0424.zip -- Tester: Tormod Volden - -lpc-link, lpclink2: -- NXP LPCXpresso debug adapters -- Proprietary DFU implementation, uses special download files with - LPC prefix and encoding of the target firmware code -- Tested by Uwe Bonnes - -Adding the lsusb output and a download log of your device here helps -us to avoid regressions for hardware we cannot test while working on -the code. To extract the lsusb output use this command: -sudo lsusb -v -d $USBID > $DEVICE.lsusb -Prepare a description snippet as above, and send it to us. A log -(copy-paste of the command window) of a firmware download is also -nice, please use the double verbose option -v -v and include the -command line in the log file. - diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/dsonano.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/dsonano.lsusb deleted file mode 100755 index 140a7bc6c..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/dsonano.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 002 Device 004: ID 0483:df11 SGS Thomson Microelectronics -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 - bcdDevice 1.1a - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 DFU - iSerial 3 001 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 64mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 4 @Internal Flash /0x08000000/12*001Ka,116*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 5 @SPI Flash : M25P64/0x00000000/64*064Kg,64*064Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1.1a -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink.log b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink.log deleted file mode 100755 index 7de4dd3e6..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink.log +++ /dev/null @@ -1,59 +0,0 @@ -(The on-board LPC3154 has some encryption key set and LPCXpressoWIN.enc -is encrypted.) - -$ lsusb | grep NXP -Bus 003 Device 011: ID 0471:df55 Philips (or NXP) LPCXpresso LPC-Link - -$ dfu-util -v -v -v -R -D /opt/lpc/lpcxpresso/bin/LPCXpressoWIN.enc - -dfu-util 0.7 - -Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. -Copyright 2010-2012 Tormod Volden and Stefan Schmidt -This program is Free Software and has ABSOLUTELY NO WARRANTY -Please report bugs to dfu-util@lists.gnumonks.org - -dfu-util: Invalid DFU suffix signature -dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! -Deducing device DFU version from functional descriptor length -Opening DFU capable USB device... -ID 0471:df55 -Run-time device DFU version 0100 -Claiming USB DFU Runtime Interface... -Determining device status: -state = dfuIDLE, status = 0 -dfu-util: WARNING: Runtime device already in DFU state ?!? -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: -state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 0100 -Device returned transfer size 2048 -Copying data from PC to DFU device -Download [ ] 0% 0 bytes -Download [= ] 6% 2048 bytes -Download [=== ] 13% 4096 bytes -Download [==== ] 19% 6144 bytes -Download [====== ] 26% 8192 bytes -Download [======== ] 32% 10240 bytes -Download [========= ] 39% 12288 bytes -Download [=========== ] 45% 14336 bytes -Download [============= ] 52% 16384 bytes -Download [============== ] 59% 18432 bytes -Download [================ ] 65% 20480 bytes -Download [================== ] 72% 22528 bytes -Download [=================== ] 78% 24576 bytes -Download [===================== ] 85% 26624 bytes -Download [====================== ] 91% 28672 bytes -Download [======================== ] 98% 29192 bytes -Download [=========================] 100% 29192 bytes -Download done. -Sent a total of 29192 bytes -state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present -Done! -dfu-util: can't detach -Resetting USB to switch back to runtime mode - -$ lsusb | grep NXP -Bus 003 Device 012: ID 1fc9:0009 NXP Semiconductors diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink.lsusb deleted file mode 100755 index 867b2a2c5..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink.lsusb +++ /dev/null @@ -1,58 +0,0 @@ - -Bus 003 Device 008: ID 0471:df55 Philips (or NXP) LPCXpresso LPC-Link -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0471 Philips (or NXP) - idProduct 0xdf55 LPCXpresso LPC-Link - bcdDevice 0.01 - iManufacturer 0 - iProduct 0 - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 25 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 7 - bDescriptorType 33 - bmAttributes 1 - Will Not Detach - Manifestation Intolerant - Upload Unsupported - Download Supported - wDetachTimeout 65535 milliseconds - wTransferSize 2048 bytes -Device Qualifier (for other device speed): - bLength 10 - bDescriptorType 6 - bcdUSB 2.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - bNumConfigurations 1 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink2.log b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink2.log deleted file mode 100755 index 4681eff7d..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink2.log +++ /dev/null @@ -1,59 +0,0 @@ -$ lsusb | grep NXP -Bus 003 Device 013: ID 1fc9:000c NXP Semiconductors - -$ dfu-util -D ~/devel/dfu-util/firmware.bin.qthdr - -dfu-util 0.7 - -Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. -Copyright 2010-2012 Tormod Volden and Stefan Schmidt -This program is Free Software and has ABSOLUTELY NO WARRANTY -Please report bugs to dfu-util@lists.gnumonks.org - -dfu-util: Invalid DFU suffix signature -dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! -Possible unencryptes NXP LPC DFU prefix with the following properties -Payload length: 39 kiByte -Opening DFU capable USB device... -ID 1fc9:000c -Run-time device DFU version 0100 -Claiming USB DFU Runtime Interface... -Determining device status: -state = dfuIDLE, status = 0 -dfu-util: WARNING: Runtime device already in DFU state ?!? -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: -state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 0100 -Device returned transfer size 2048 -Copying data from PC to DFU device -Download [ ] 0% 0 bytes -Download [= ] 4% 2048 bytes -Download [== ] 9% 4096 bytes -Download [=== ] 14% 6144 bytes -Download [==== ] 19% 8192 bytes -Download [====== ] 24% 10240 bytes -Download [======= ] 28% 12288 bytes -Download [======== ] 33% 14336 bytes -Download [========= ] 38% 16384 bytes -Download [========== ] 43% 18432 bytes -Download [============ ] 48% 20480 bytes -Download [============= ] 53% 22528 bytes -Download [============== ] 57% 24576 bytes -Download [=============== ] 62% 26624 bytes -Download [================ ] 67% 28672 bytes -Download [================== ] 72% 30720 bytes -Download [=================== ] 77% 32768 bytes -Download [==================== ] 82% 34816 bytes -Download [===================== ] 86% 36864 bytes -Download [====================== ] 91% 38912 bytes -Download [======================== ] 96% 40356 bytes -Download [=========================] 100% 40356 bytes -Download done. -Sent a total of 40356 bytes -dfu-util: unable to read DFU status - -$ lsusb | grep NXP -Bus 003 Device 014: ID 1fc9:0018 NXP Semiconductors diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink2.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink2.lsusb deleted file mode 100755 index b833fca77..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/lpclink2.lsusb +++ /dev/null @@ -1,203 +0,0 @@ - -Bus 003 Device 007: ID 0c72:000c PEAK System PCAN-USB -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x0c72 PEAK System - idProduct 0x000c PCAN-USB - bcdDevice 1c.ff - iManufacturer 0 - iProduct 3 VER1:PEAK -VER2:02.8.01 -DAT :06.05.2004 -TIME:09:35:37 - ... - iSerial 0 - bNumConfigurations 3 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 2 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 394mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 3 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/opc-20.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/opc-20.lsusb deleted file mode 100755 index 580df90e5..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/opc-20.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 004: ID 0483:df11 SGS Thomson Microelectronics -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 - bcdDevice 2.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 DFU - iSerial 3 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/12*001Ka,116*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @SPI Flash : M25P64/0x00000000/128*64Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1a.01 -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb deleted file mode 100755 index 4c0abfb06..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb +++ /dev/null @@ -1,109 +0,0 @@ -Bus 003 Device 017: ID 1d50:5119 OpenMoko, Inc. GTA01/GTA02 U-Boot Bootloader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x5119 GTA01/GTA02 U-Boot Bootloader - bcdDevice 0.00 - iManufacturer 1 OpenMoko, Inc - iProduct 2 Neo1973 Bootloader U-Boot 1.3.2-moko12 - iSerial 3 0000000 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 81 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 7 USB Device Firmware Upgrade - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 8 RAM 0x32000000 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 9 u-boot - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 10 u-boot_env - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 3 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 11 kernel - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 4 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 12 splash - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 5 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 13 factory - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 6 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 14 rootfs - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 -Device Status: 0x0a00 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openmoko-freerunner.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openmoko-freerunner.lsusb deleted file mode 100755 index 835708dd8..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openmoko-freerunner.lsusb +++ /dev/null @@ -1,179 +0,0 @@ -Bus 005 Device 033: ID 1d50:5119 OpenMoko, Inc. GTA01/GTA02 U-Boot Bootloader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.10 - bDeviceClass 2 Communications - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x5119 GTA01/GTA02 U-Boot Bootloader - bcdDevice 0.00 - iManufacturer 1 OpenMoko, Inc - iProduct 2 Neo1973 Bootloader U-Boot 1.3.2-moko12 - iSerial 3 0000000 - bNumConfigurations 2 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 85 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 4 TTY via USB - bmAttributes 0x80 - (Bus Powered) - MaxPower 500mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 Control Interface - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 Bulk Data Interface - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 7 USB Device Firmware Upgrade - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 67 - bNumInterfaces 2 - bConfigurationValue 2 - iConfiguration 4 TTY via USB - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 Control Interface - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 Bulk Data Interface - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 -Device Status: 0x9a00 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openmoko-neo1973.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openmoko-neo1973.lsusb deleted file mode 100755 index 07789506a..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openmoko-neo1973.lsusb +++ /dev/null @@ -1,182 +0,0 @@ - -Bus 006 Device 020: ID 1457:5119 First International Computer, Inc. OpenMoko Neo1973 u-boot cdc_acm serial port -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.10 - bDeviceClass 2 Communications - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1457 First International Computer, Inc. - idProduct 0x5119 OpenMoko Neo1973 u-boot cdc_acm serial port - bcdDevice 0.00 - iManufacturer 1 - iProduct 2 - iSerial 3 - bNumConfigurations 2 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 85 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 4 - bmAttributes 0x80 - (Bus Powered) - MaxPower 500mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 7 - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 67 - bNumInterfaces 2 - bConfigurationValue 2 - iConfiguration 4 - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 -Device Status: 0x0006 - (Bus Powered) - Remote Wakeup Enabled - Test Mode diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openpcd.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openpcd.lsusb deleted file mode 100755 index f6255a943..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/openpcd.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 006 Device 016: ID 16c0:076b VOTI OpenPCD 13.56MHz RFID Reader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 8 - idVendor 0x16c0 VOTI - idProduct 0x076b OpenPCD 13.56MHz RFID Reader - bcdDevice 0.00 - iManufacturer 1 - iProduct 2 OpenPCD RFID Simulator - DFU Mode - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 0 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 3 - Will Not Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 256 bytes - bcdDFUVersion 1.00 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/qi-hardware-atusb.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/qi-hardware-atusb.lsusb deleted file mode 100755 index bfc1701e1..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/qi-hardware-atusb.lsusb +++ /dev/null @@ -1,59 +0,0 @@ - -Bus 006 Device 013: ID 20b7:1540 Qi Hardware ben-wpan, AT86RF230-based -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 255 Vendor Specific Class - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x20b7 Qi Hardware - idProduct 0x1540 ben-wpan, AT86RF230-based - bcdDevice 0.01 - iManufacturer 0 - iProduct 0 - iSerial 1 4630333438371508231a - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 34 - bNumInterfaces 2 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 40mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 255 Vendor Specific Class - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 0 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 0 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/simtrace.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/simtrace.lsusb deleted file mode 100755 index 578ddf0e1..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/simtrace.lsusb +++ /dev/null @@ -1,70 +0,0 @@ - -Bus 006 Device 017: ID 16c0:0762 VOTI -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 8 - idVendor 0x16c0 VOTI - idProduct 0x0762 - bcdDevice 0.00 - iManufacturer 1 sysmocom - systems for mobile communications GmbH - iProduct 2 SimTrace SIM Sniffer - DFU Mode - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 45 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 3 SimTrace DFU Configuration - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 SimTrace DFU Interface - Application Partition - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 SimTrace DFU Interface - Bootloader Partition - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 6 SimTrace DFU Interface - RAM - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 3 - Will Not Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 256 bytes - bcdDFUVersion 1.00 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/sparkcore.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/sparkcore.lsusb deleted file mode 100755 index b6029ffa5..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/sparkcore.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 008: ID 1d50:607f OpenMoko, Inc. -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x607f - bcdDevice 2.00 - iManufacturer 1 Spark Devices - iProduct 2 CORE DFU - iSerial 3 8D80527B5055 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/20*001Ka,108*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @SPI Flash : SST25x/0x00000000/512*04Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1.1a -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f107.bin-download b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f107.bin-download deleted file mode 100755 index 45b714f83..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f107.bin-download +++ /dev/null @@ -1,48 +0,0 @@ -> src/dfu-util --intf 0 --alt 0 -v -v -v -s 0x8000000 -D test3 -dfu-util 0.4 - -(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. -(C) 2010-2011 Tormod Volden (DfuSe support) -This program is Free Software and has ABSOLUTELY NO WARRANTY - -dfu-util does currently only support DFU version 1.0 - -Opening DFU USB device... ID 0483:df11 -Run-time device DFU version 011a -Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/128*002Kg" -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 011a -Device returned transfer size 2048 -No valid DFU suffix signature -Warning: File has no DFU suffix -DfuSe interface name: "Internal Flash " -Memory segment at 0x08000000 128 x 2048 = 262144 (rew) -Uploading to address = 0x08000000, size = 16384 -Erasing page size 2048 at address 0x08000000, page starting at 0x08000000 - Download from image offset 00000000 to memory 08000000-080007ff, size 2048 - Setting address pointer to 0x08000000 -Erasing page size 2048 at address 0x08000800, page starting at 0x08000800 - Download from image offset 00000800 to memory 08000800-08000fff, size 2048 - Setting address pointer to 0x08000800 -Erasing page size 2048 at address 0x08001000, page starting at 0x08001000 - Download from image offset 00001000 to memory 08001000-080017ff, size 2048 - Setting address pointer to 0x08001000 -Erasing page size 2048 at address 0x08001800, page starting at 0x08001800 - Download from image offset 00001800 to memory 08001800-08001fff, size 2048 - Setting address pointer to 0x08001800 -Erasing page size 2048 at address 0x08002000, page starting at 0x08002000 - Download from image offset 00002000 to memory 08002000-080027ff, size 2048 - Setting address pointer to 0x08002000 -Erasing page size 2048 at address 0x08002800, page starting at 0x08002800 - Download from image offset 00002800 to memory 08002800-08002fff, size 2048 - Setting address pointer to 0x08002800 -Erasing page size 2048 at address 0x08003000, page starting at 0x08003000 - Download from image offset 00003000 to memory 08003000-080037ff, size 2048 - Setting address pointer to 0x08003000 -Erasing page size 2048 at address 0x08003800, page starting at 0x08003800 - Download from image offset 00003800 to memory 08003800-08003fff, size 2048 - Setting address pointer to 0x08003800 - diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f107.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f107.lsusb deleted file mode 100755 index 14b45cda0..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f107.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 028: ID 0483:df11 SGS Thomson Microelectronics STM Device in DFU Mode -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 STM Device in DFU Mode - bcdDevice 20.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 0x418 DFU Bootloader - iSerial 3 STM32 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/128*002Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @Option Bytes /0x1FFFF800/01*016 g - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 2048 bytes - bcdDFUVersion 1.1a -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f4discovery.bin-download b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f4discovery.bin-download deleted file mode 100755 index 96e172216..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f4discovery.bin-download +++ /dev/null @@ -1,36 +0,0 @@ -dfu-util --device 0483:df11 --alt 0 \ - --dfuse-address 0x08000000 \ - -v -v -v \ - --download arm/iotoggle.bin -No valid DFU suffix signature -Warning: File has no DFU suffix -dfu-util 0.5 - -(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. -(C) 2010-2011 Tormod Volden (DfuSe support) -This program is Free Software and has ABSOLUTELY NO WARRANTY - -dfu-util does currently only support DFU version 1.0 - -Filter on vendor = 0x0483 product = 0xdf11 -Opening DFU capable USB device... ID 0483:df11 -Run-time device DFU version 011a -Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg" -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: state = dfuERROR, status = 10 -dfuERROR, clearing status -Determining device status: state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 011a -Device returned transfer size 2048 -DfuSe interface name: "Internal Flash " -Memory segment at 0x08000000 4 x 16384 = 65536 (rew) -Memory segment at 0x08010000 1 x 65536 = 65536 (rew) -Memory segment at 0x08020000 7 x 131072 = 917504 (rew) -Uploading to address = 0x08000000, size = 2308 -Erasing page size 16384 at address 0x08000000, page starting at 0x08000000 - Download from image offset 00000000 to memory 08000000-080007ff, size 2048 - Setting address pointer to 0x08000000 - Download from image offset 00000800 to memory 08000800-08000903, size 260 - Setting address pointer to 0x08000800 diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f4discovery.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f4discovery.lsusb deleted file mode 100755 index 0b870de91..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/stm32f4discovery.lsusb +++ /dev/null @@ -1,80 +0,0 @@ - -Bus 001 Device 010: ID 0483:df11 SGS Thomson Microelectronics STM Device in DFU Mode -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 STM Device in DFU Mode - bcdDevice 21.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 BOOTLOADER - iSerial 3 315A28A0B956 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 54 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @Option Bytes /0x1FFFC000/01*016 g - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 6 @OTP Memory /0x1FFF7800/01*512 g,01*016 g - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 3 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 7 @Device Feature/0xFFFF0000/01*004 g - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 2048 bytes - bcdDFUVersion 1.1a -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/tdk-bluetooth.lsusb b/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/tdk-bluetooth.lsusb deleted file mode 100755 index c0cfaceb6..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/device-logs/tdk-bluetooth.lsusb +++ /dev/null @@ -1,269 +0,0 @@ - -Bus 006 Device 014: ID 04bf:0320 TDK Corp. Bluetooth Adapter -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 224 Wireless - bDeviceSubClass 1 Radio Frequency - bDeviceProtocol 1 Bluetooth - bMaxPacketSize0 64 - idVendor 0x04bf TDK Corp. - idProduct 0x0320 Bluetooth Adapter - bcdDevice 26.52 - iManufacturer 1 Ezurio - iProduct 2 Turbo Bluetooth Adapter - iSerial 3 008098D4FFBD - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 193 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 64mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 3 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0000 1x 0 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0000 1x 0 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 1 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0009 1x 9 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0009 1x 9 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 2 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0011 1x 17 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0011 1x 17 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 3 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0019 1x 25 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0019 1x 25 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 4 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0021 1x 33 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0021 1x 33 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 5 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0031 1x 49 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0031 1x 49 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 7 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 5000 milliseconds - wTransferSize 1023 bytes -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/dfuse-pack.py b/arduino/opencr_arduino/tools/macosx/src/dfu-util/dfuse-pack.py deleted file mode 100755 index 875cc5c6e..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/dfuse-pack.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/python - -# Written by Antonio Galea - 2010/11/18 -# Distributed under Gnu LGPL 3.0 -# see http://www.gnu.org/licenses/lgpl-3.0.txt - -import sys,struct,zlib,os -from optparse import OptionParser - -DEFAULT_DEVICE="0x0483:0xdf11" - -def named(tuple,names): - return dict(zip(names.split(),tuple)) -def consume(fmt,data,names): - n = struct.calcsize(fmt) - return named(struct.unpack(fmt,data[:n]),names),data[n:] -def cstring(string): - return string.split('\0',1)[0] -def compute_crc(data): - return 0xFFFFFFFF & -zlib.crc32(data) -1 - -def parse(file,dump_images=False): - print 'File: "%s"' % file - data = open(file,'rb').read() - crc = compute_crc(data[:-4]) - prefix, data = consume('<5sBIB',data,'signature version size targets') - print '%(signature)s v%(version)d, image size: %(size)d, targets: %(targets)d' % prefix - for t in range(prefix['targets']): - tprefix, data = consume('<6sBI255s2I',data,'signature altsetting named name size elements') - tprefix['num'] = t - if tprefix['named']: - tprefix['name'] = cstring(tprefix['name']) - else: - tprefix['name'] = '' - print '%(signature)s %(num)d, alt setting: %(altsetting)s, name: "%(name)s", size: %(size)d, elements: %(elements)d' % tprefix - tsize = tprefix['size'] - target, data = data[:tsize], data[tsize:] - for e in range(tprefix['elements']): - eprefix, target = consume('<2I',target,'address size') - eprefix['num'] = e - print ' %(num)d, address: 0x%(address)08x, size: %(size)d' % eprefix - esize = eprefix['size'] - image, target = target[:esize], target[esize:] - if dump_images: - out = '%s.target%d.image%d.bin' % (file,t,e) - open(out,'wb').write(image) - print ' DUMPED IMAGE TO "%s"' % out - if len(target): - print "target %d: PARSE ERROR" % t - suffix = named(struct.unpack('<4H3sBI',data[:16]),'device product vendor dfu ufd len crc') - print 'usb: %(vendor)04x:%(product)04x, device: 0x%(device)04x, dfu: 0x%(dfu)04x, %(ufd)s, %(len)d, 0x%(crc)08x' % suffix - if crc != suffix['crc']: - print "CRC ERROR: computed crc32 is 0x%08x" % crc - data = data[16:] - if data: - print "PARSE ERROR" - -def build(file,targets,device=DEFAULT_DEVICE): - data = '' - for t,target in enumerate(targets): - tdata = '' - for image in target: - tdata += struct.pack('<2I',image['address'],len(image['data']))+image['data'] - tdata = struct.pack('<6sBI255s2I','Target',0,1,'ST...',len(tdata),len(target)) + tdata - data += tdata - data = struct.pack('<5sBIB','DfuSe',1,len(data)+11,len(targets)) + data - v,d=map(lambda x: int(x,0) & 0xFFFF, device.split(':',1)) - data += struct.pack('<4H3sB',0,d,v,0x011a,'UFD',16) - crc = compute_crc(data) - data += struct.pack(' and -Harald Welte . Over time, nearly complete -support of DFU 1.0, DFU 1.1 and DfuSe ("1.1a") has been added. -.SH LICENCE -.B dfu-util -is covered by the GNU General Public License (GPL), version 2 or later. -.SH COPYRIGHT -This manual page was originally written by Uwe Hermann , -and is now part of the dfu-util project. diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/README_msvc.txt b/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/README_msvc.txt deleted file mode 100755 index 6e68ec6ff..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/README_msvc.txt +++ /dev/null @@ -1,10 +0,0 @@ -# (C) Roger Meier -# (C) Pascal Schweizer -# msvc folder is GPL-2.0+, LGPL-2.1+, BSD-3-Clause or MIT license(SPDX) - -Building dfu-util native on Windows with Visual Studio - -3rd party dependencies: -- libusbx ( git clone https://github.com/libusbx/libusbx.git ) - - getopt (part of libusbx: libusbx/examples/getopt) - diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/dfu-suffix_2010.vcxproj b/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/dfu-suffix_2010.vcxproj deleted file mode 100755 index 0c316c2e5..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/dfu-suffix_2010.vcxproj +++ /dev/null @@ -1,100 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA} - dfusuffix - dfu-suffix - - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\dll;$(LibraryPath) - $(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib - $(ExecutablePath) - - - $(ExecutablePath) - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\dll;$(LibraryPath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - Level3 - Disabled - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebug - - - true - - - - - Level3 - MaxSpeed - true - true - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - - - true - true - true - - - - - - - - - - - - - {a2169bc8-cf99-40bf-83f3-b0e38f7067bd} - - - {349ee8f9-7d25-4909-aaf5-ff3fade72187} - - - - - - \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/dfu-util_2010.sln b/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/dfu-util_2010.sln deleted file mode 100755 index ef797239b..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/dfu-util_2010.sln +++ /dev/null @@ -1,54 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dfu-util", "dfu-util_2010.vcxproj", "{0E071A60-7EF2-4427-BAA8-9143CACB5BCB}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C4F8746D-B27E-4806-95E5-2052174E923B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dfu-suffix", "dfu-suffix_2010.vcxproj", "{8F7600A2-3B37-4956-B39B-A1D43EF29EDA}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt_2010", "..\..\libusbx\msvc\getopt_2010.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "..\..\libusbx\msvc\libusb_static_2010.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|Win32.ActiveCfg = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|Win32.Build.0 = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|x64.ActiveCfg = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|Win32.ActiveCfg = Release|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|Win32.Build.0 = Release|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|x64.ActiveCfg = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|Win32.ActiveCfg = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|Win32.Build.0 = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|x64.ActiveCfg = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|Win32.ActiveCfg = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|Win32.Build.0 = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|x64.ActiveCfg = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.ActiveCfg = Debug|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.Build.0 = Debug|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.ActiveCfg = Debug|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.Build.0 = Debug|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.ActiveCfg = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.Build.0 = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.ActiveCfg = Release|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.Build.0 = Release|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/dfu-util_2010.vcxproj b/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/dfu-util_2010.vcxproj deleted file mode 100755 index 17a8bee1b..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/msvc/dfu-util_2010.vcxproj +++ /dev/null @@ -1,120 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB} - dfuutil - dfu-util - - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\getopt\$(Configuration);$(LibraryPath) - $(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib - $(ExecutablePath) - - - $(ExecutablePath) - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\getopt\$(Configuration);$(LibraryPath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - Level3 - Disabled - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebug - - - true - - - - - - - - - Level3 - MaxSpeed - true - true - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - - - true - true - true - - - copy $(SolutionDir)..\$(Platform)\$(Configuration)\dll\libusb-1.0.dll $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - - - - - - - - - - - - - - - - - - - - - - - {a2169bc8-cf99-40bf-83f3-b0e38f7067bd} - - - {349ee8f9-7d25-4909-aaf5-ff3fade72187} - - - - - - \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/Makefile.am b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/Makefile.am deleted file mode 100755 index 70179c411..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -AM_CFLAGS = -Wall -Wextra - -bin_PROGRAMS = dfu-util dfu-suffix dfu-prefix -dfu_util_SOURCES = main.c \ - portable.h \ - dfu_load.c \ - dfu_load.h \ - dfu_util.c \ - dfu_util.h \ - dfuse.c \ - dfuse.h \ - dfuse_mem.c \ - dfuse_mem.h \ - dfu.c \ - dfu.h \ - usb_dfu.h \ - dfu_file.c \ - dfu_file.h \ - quirks.c \ - quirks.h - -dfu_suffix_SOURCES = suffix.c \ - dfu_file.h \ - dfu_file.c - -dfu_prefix_SOURCES = prefix.c \ - dfu_file.h \ - dfu_file.c diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu.c b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu.c deleted file mode 100755 index 14d7673d1..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Low-level DFU communication routines, originally taken from - * $Id: dfu.c,v 1.3 2006/06/20 06:28:04 schmidtw Exp $ - * (part of dfu-programmer). - * - * Copyright 2005-2006 Weston Schmidt - * Copyright 2011-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include - -#include - -#include "portable.h" -#include "dfu.h" -#include "quirks.h" - -static int dfu_timeout = 5000; /* 5 seconds - default */ - -/* - * DFU_DETACH Request (DFU Spec 1.0, Section 5.1) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * timeout - the timeout in ms the USB device should wait for a pending - * USB reset before giving up and terminating the operation - * - * returns 0 or < 0 on error - */ -int dfu_detach( libusb_device_handle *device, - const unsigned short interface, - const unsigned short timeout ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DETACH, - /* wValue */ timeout, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -/* - * DFU_DNLOAD Request (DFU Spec 1.0, Section 6.1.1) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the total number of bytes to transfer to the USB - * device - must be less than wTransferSize - * data - the data to transfer - * - * returns the number of bytes written or < 0 on error - */ -int dfu_download( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ) -{ - int status; - - status = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DNLOAD, - /* wValue */ transaction, - /* wIndex */ interface, - /* Data */ data, - /* wLength */ length, - dfu_timeout ); - return status; -} - - -/* - * DFU_UPLOAD Request (DFU Spec 1.0, Section 6.2) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the maximum number of bytes to receive from the USB - * device - must be less than wTransferSize - * data - the buffer to put the received data in - * - * returns the number of bytes received or < 0 on error - */ -int dfu_upload( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ) -{ - int status; - - status = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_UPLOAD, - /* wValue */ transaction, - /* wIndex */ interface, - /* Data */ data, - /* wLength */ length, - dfu_timeout ); - return status; -} - - -/* - * DFU_GETSTATUS Request (DFU Spec 1.0, Section 6.1.2) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * status - the data structure to be populated with the results - * - * return the number of bytes read in or < 0 on an error - */ -int dfu_get_status( struct dfu_if *dif, struct dfu_status *status ) -{ - unsigned char buffer[6]; - int result; - - /* Initialize the status data structure */ - status->bStatus = DFU_STATUS_ERROR_UNKNOWN; - status->bwPollTimeout = 0; - status->bState = STATE_DFU_ERROR; - status->iString = 0; - - result = libusb_control_transfer( dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_GETSTATUS, - /* wValue */ 0, - /* wIndex */ dif->interface, - /* Data */ buffer, - /* wLength */ 6, - dfu_timeout ); - - if( 6 == result ) { - status->bStatus = buffer[0]; - if (dif->quirks & QUIRK_POLLTIMEOUT) - status->bwPollTimeout = DEFAULT_POLLTIMEOUT; - else - status->bwPollTimeout = ((0xff & buffer[3]) << 16) | - ((0xff & buffer[2]) << 8) | - (0xff & buffer[1]); - status->bState = buffer[4]; - status->iString = buffer[5]; - } - - return result; -} - - -/* - * DFU_CLRSTATUS Request (DFU Spec 1.0, Section 6.1.3) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * - * return 0 or < 0 on an error - */ -int dfu_clear_status( libusb_device_handle *device, - const unsigned short interface ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT| LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_CLRSTATUS, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -/* - * DFU_GETSTATE Request (DFU Spec 1.0, Section 6.1.5) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the maximum number of bytes to receive from the USB - * device - must be less than wTransferSize - * data - the buffer to put the received data in - * - * returns the state or < 0 on error - */ -int dfu_get_state( libusb_device_handle *device, - const unsigned short interface ) -{ - int result; - unsigned char buffer[1]; - - result = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_GETSTATE, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ buffer, - /* wLength */ 1, - dfu_timeout ); - - /* Return the error if there is one. */ - if (result < 1) - return -1; - - /* Return the state. */ - return buffer[0]; -} - - -/* - * DFU_ABORT Request (DFU Spec 1.0, Section 6.1.4) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * - * returns 0 or < 0 on an error - */ -int dfu_abort( libusb_device_handle *device, - const unsigned short interface ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_ABORT, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -const char* dfu_state_to_string( int state ) -{ - const char *message; - - switch (state) { - case STATE_APP_IDLE: - message = "appIDLE"; - break; - case STATE_APP_DETACH: - message = "appDETACH"; - break; - case STATE_DFU_IDLE: - message = "dfuIDLE"; - break; - case STATE_DFU_DOWNLOAD_SYNC: - message = "dfuDNLOAD-SYNC"; - break; - case STATE_DFU_DOWNLOAD_BUSY: - message = "dfuDNBUSY"; - break; - case STATE_DFU_DOWNLOAD_IDLE: - message = "dfuDNLOAD-IDLE"; - break; - case STATE_DFU_MANIFEST_SYNC: - message = "dfuMANIFEST-SYNC"; - break; - case STATE_DFU_MANIFEST: - message = "dfuMANIFEST"; - break; - case STATE_DFU_MANIFEST_WAIT_RESET: - message = "dfuMANIFEST-WAIT-RESET"; - break; - case STATE_DFU_UPLOAD_IDLE: - message = "dfuUPLOAD-IDLE"; - break; - case STATE_DFU_ERROR: - message = "dfuERROR"; - break; - default: - message = NULL; - break; - } - - return message; -} - -/* Chapter 6.1.2 */ -static const char *dfu_status_names[] = { - /* DFU_STATUS_OK */ - "No error condition is present", - /* DFU_STATUS_errTARGET */ - "File is not targeted for use by this device", - /* DFU_STATUS_errFILE */ - "File is for this device but fails some vendor-specific test", - /* DFU_STATUS_errWRITE */ - "Device is unable to write memory", - /* DFU_STATUS_errERASE */ - "Memory erase function failed", - /* DFU_STATUS_errCHECK_ERASED */ - "Memory erase check failed", - /* DFU_STATUS_errPROG */ - "Program memory function failed", - /* DFU_STATUS_errVERIFY */ - "Programmed memory failed verification", - /* DFU_STATUS_errADDRESS */ - "Cannot program memory due to received address that is out of range", - /* DFU_STATUS_errNOTDONE */ - "Received DFU_DNLOAD with wLength = 0, but device does not think that it has all data yet", - /* DFU_STATUS_errFIRMWARE */ - "Device's firmware is corrupt. It cannot return to run-time (non-DFU) operations", - /* DFU_STATUS_errVENDOR */ - "iString indicates a vendor specific error", - /* DFU_STATUS_errUSBR */ - "Device detected unexpected USB reset signalling", - /* DFU_STATUS_errPOR */ - "Device detected unexpected power on reset", - /* DFU_STATUS_errUNKNOWN */ - "Something went wrong, but the device does not know what it was", - /* DFU_STATUS_errSTALLEDPKT */ - "Device stalled an unexpected request" -}; - - -const char *dfu_status_to_string(int status) -{ - if (status > DFU_STATUS_errSTALLEDPKT) - return "INVALID"; - return dfu_status_names[status]; -} - -int dfu_abort_to_idle(struct dfu_if *dif) -{ - int ret; - struct dfu_status dst; - - ret = dfu_abort(dif->dev_handle, dif->interface); - if (ret < 0) { - errx(EX_IOERR, "Error sending dfu abort request"); - exit(1); - } - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during abort get_status"); - exit(1); - } - if (dst.bState != DFU_STATE_dfuIDLE) { - errx(EX_IOERR, "Failed to enter idle state on abort"); - exit(1); - } - milli_sleep(dst.bwPollTimeout); - return ret; -} diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu.h b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu.h deleted file mode 100755 index 8e3caeb7b..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * dfu-programmer - * - * $Id: dfu.h,v 1.2 2005/09/25 01:27:42 schmidtw Exp $ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFU_H -#define DFU_H - -#include -#include "usb_dfu.h" - -/* DFU states */ -#define STATE_APP_IDLE 0x00 -#define STATE_APP_DETACH 0x01 -#define STATE_DFU_IDLE 0x02 -#define STATE_DFU_DOWNLOAD_SYNC 0x03 -#define STATE_DFU_DOWNLOAD_BUSY 0x04 -#define STATE_DFU_DOWNLOAD_IDLE 0x05 -#define STATE_DFU_MANIFEST_SYNC 0x06 -#define STATE_DFU_MANIFEST 0x07 -#define STATE_DFU_MANIFEST_WAIT_RESET 0x08 -#define STATE_DFU_UPLOAD_IDLE 0x09 -#define STATE_DFU_ERROR 0x0a - - -/* DFU status */ -#define DFU_STATUS_OK 0x00 -#define DFU_STATUS_ERROR_TARGET 0x01 -#define DFU_STATUS_ERROR_FILE 0x02 -#define DFU_STATUS_ERROR_WRITE 0x03 -#define DFU_STATUS_ERROR_ERASE 0x04 -#define DFU_STATUS_ERROR_CHECK_ERASED 0x05 -#define DFU_STATUS_ERROR_PROG 0x06 -#define DFU_STATUS_ERROR_VERIFY 0x07 -#define DFU_STATUS_ERROR_ADDRESS 0x08 -#define DFU_STATUS_ERROR_NOTDONE 0x09 -#define DFU_STATUS_ERROR_FIRMWARE 0x0a -#define DFU_STATUS_ERROR_VENDOR 0x0b -#define DFU_STATUS_ERROR_USBR 0x0c -#define DFU_STATUS_ERROR_POR 0x0d -#define DFU_STATUS_ERROR_UNKNOWN 0x0e -#define DFU_STATUS_ERROR_STALLEDPKT 0x0f - -/* DFU commands */ -#define DFU_DETACH 0 -#define DFU_DNLOAD 1 -#define DFU_UPLOAD 2 -#define DFU_GETSTATUS 3 -#define DFU_CLRSTATUS 4 -#define DFU_GETSTATE 5 -#define DFU_ABORT 6 - -/* DFU interface */ -#define DFU_IFF_DFU 0x0001 /* DFU Mode, (not Runtime) */ - -/* This is based off of DFU_GETSTATUS - * - * 1 unsigned byte bStatus - * 3 unsigned byte bwPollTimeout - * 1 unsigned byte bState - * 1 unsigned byte iString -*/ - -struct dfu_status { - unsigned char bStatus; - unsigned int bwPollTimeout; - unsigned char bState; - unsigned char iString; -}; - -struct dfu_if { - struct usb_dfu_func_descriptor func_dfu; - uint16_t quirks; - uint16_t busnum; - uint16_t devnum; - uint16_t vendor; - uint16_t product; - uint16_t bcdDevice; - uint8_t configuration; - uint8_t interface; - uint8_t altsetting; - uint8_t flags; - uint8_t bMaxPacketSize0; - char *alt_name; - char *serial_name; - libusb_device *dev; - libusb_device_handle *dev_handle; - struct dfu_if *next; -}; - -int dfu_detach( libusb_device_handle *device, - const unsigned short interface, - const unsigned short timeout ); -int dfu_download( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ); -int dfu_upload( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ); -int dfu_get_status( struct dfu_if *dif, - struct dfu_status *status ); -int dfu_clear_status( libusb_device_handle *device, - const unsigned short interface ); -int dfu_get_state( libusb_device_handle *device, - const unsigned short interface ); -int dfu_abort( libusb_device_handle *device, - const unsigned short interface ); -int dfu_abort_to_idle( struct dfu_if *dif); - -const char *dfu_state_to_string( int state ); - -const char *dfu_status_to_string( int status ); - -#endif /* DFU_H */ diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_file.c b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_file.c deleted file mode 100755 index 7c897d4f6..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_file.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Load or store DFU files including suffix and prefix - * - * Copyright 2014 Tormod Volden - * Copyright 2012 Stefan Schmidt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -#define DFU_SUFFIX_LENGTH 16 -#define LMDFU_PREFIX_LENGTH 8 -#define LPCDFU_PREFIX_LENGTH 16 -#define PROGRESS_BAR_WIDTH 25 -#define STDIN_CHUNK_SIZE 65536 - -static const unsigned long crc32_table[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}; - -static uint32_t crc32_byte(uint32_t accum, uint8_t delta) -{ - return crc32_table[(accum ^ delta) & 0xff] ^ (accum >> 8); -} - -static int probe_prefix(struct dfu_file *file) -{ - uint8_t *prefix = file->firmware; - - if (file->size.total < LMDFU_PREFIX_LENGTH) - return 1; - if ((prefix[0] == 0x01) && (prefix[1] == 0x00)) { - file->prefix_type = LMDFU_PREFIX; - file->size.prefix = LMDFU_PREFIX_LENGTH; - file->lmdfu_address = 1024 * ((prefix[3] << 8) | prefix[2]); - } - else if (((prefix[0] & 0x3f) == 0x1a) && ((prefix[1] & 0x3f)== 0x3f)) { - file->prefix_type = LPCDFU_UNENCRYPTED_PREFIX; - file->size.prefix = LPCDFU_PREFIX_LENGTH; - } - - if (file->size.prefix + file->size.suffix > file->size.total) - return 1; - return 0; -} - -void dfu_progress_bar(const char *desc, unsigned long long curr, - unsigned long long max) -{ - static char buf[PROGRESS_BAR_WIDTH + 1]; - static unsigned long long last_progress = -1; - static time_t last_time; - time_t curr_time = time(NULL); - unsigned long long progress; - unsigned long long x; - - /* check for not known maximum */ - if (max < curr) - max = curr + 1; - /* make none out of none give zero */ - if (max == 0 && curr == 0) - max = 1; - - /* compute completion */ - progress = (PROGRESS_BAR_WIDTH * curr) / max; - if (progress > PROGRESS_BAR_WIDTH) - progress = PROGRESS_BAR_WIDTH; - if (progress == last_progress && - curr_time == last_time) - return; - last_progress = progress; - last_time = curr_time; - - for (x = 0; x != PROGRESS_BAR_WIDTH; x++) { - if (x < progress) - buf[x] = '='; - else - buf[x] = ' '; - } - buf[x] = 0; - - printf("\r%s\t[%s] %3lld%% %12lld bytes", desc, buf, - (100ULL * curr) / max, curr); - - if (progress == PROGRESS_BAR_WIDTH) - printf("\n%s done.\n", desc); -} - -void *dfu_malloc(size_t size) -{ - void *ptr = malloc(size); - if (ptr == NULL) - errx(EX_SOFTWARE, "Cannot allocate memory of size %d bytes", (int)size); - return (ptr); -} - -uint32_t dfu_file_write_crc(int f, uint32_t crc, const void *buf, int size) -{ - int x; - - /* compute CRC */ - for (x = 0; x != size; x++) - crc = crc32_byte(crc, ((uint8_t *)buf)[x]); - - /* write data */ - if (write(f, buf, size) != size) - err(EX_IOERR, "Could not write %d bytes to file %d", size, f); - - return (crc); -} - -void dfu_load_file(struct dfu_file *file, enum suffix_req check_suffix, enum prefix_req check_prefix) -{ - off_t offset; - int f; - int i; - int res; - - file->size.prefix = 0; - file->size.suffix = 0; - - /* default values, if no valid suffix is found */ - file->bcdDFU = 0; - file->idVendor = 0xffff; /* wildcard value */ - file->idProduct = 0xffff; /* wildcard value */ - file->bcdDevice = 0xffff; /* wildcard value */ - - /* default values, if no valid prefix is found */ - file->lmdfu_address = 0; - - free(file->firmware); - - if (!strcmp(file->name, "-")) { - int read_bytes; - -#ifdef WIN32 - _setmode( _fileno( stdin ), _O_BINARY ); -#endif - file->firmware = (uint8_t*) dfu_malloc(STDIN_CHUNK_SIZE); - read_bytes = fread(file->firmware, 1, STDIN_CHUNK_SIZE, stdin); - file->size.total = read_bytes; - while (read_bytes == STDIN_CHUNK_SIZE) { - file->firmware = (uint8_t*) realloc(file->firmware, file->size.total + STDIN_CHUNK_SIZE); - if (!file->firmware) - err(EX_IOERR, "Could not allocate firmware buffer"); - read_bytes = fread(file->firmware + file->size.total, 1, STDIN_CHUNK_SIZE, stdin); - file->size.total += read_bytes; - } - if (verbose) - printf("Read %i bytes from stdin\n", file->size.total); - /* Never require suffix when reading from stdin */ - check_suffix = MAYBE_SUFFIX; - } else { - f = open(file->name, O_RDONLY | O_BINARY); - if (f < 0) - err(EX_IOERR, "Could not open file %s for reading", file->name); - - offset = lseek(f, 0, SEEK_END); - - if ((int)offset < 0 || (int)offset != offset) - err(EX_IOERR, "File size is too big"); - - if (lseek(f, 0, SEEK_SET) != 0) - err(EX_IOERR, "Could not seek to beginning"); - - file->size.total = offset; - file->firmware = dfu_malloc(file->size.total); - - if (read(f, file->firmware, file->size.total) != file->size.total) { - err(EX_IOERR, "Could not read %d bytes from %s", - file->size.total, file->name); - } - close(f); - } - - /* Check for possible DFU file suffix by trying to parse one */ - { - uint32_t crc = 0xffffffff; - const uint8_t *dfusuffix; - int missing_suffix = 0; - const char *reason; - - if (file->size.total < DFU_SUFFIX_LENGTH) { - reason = "File too short for DFU suffix"; - missing_suffix = 1; - goto checked; - } - - dfusuffix = file->firmware + file->size.total - - DFU_SUFFIX_LENGTH; - - for (i = 0; i < file->size.total - 4; i++) - crc = crc32_byte(crc, file->firmware[i]); - - if (dfusuffix[10] != 'D' || - dfusuffix[9] != 'F' || - dfusuffix[8] != 'U') { - reason = "Invalid DFU suffix signature"; - missing_suffix = 1; - goto checked; - } - - file->dwCRC = (dfusuffix[15] << 24) + - (dfusuffix[14] << 16) + - (dfusuffix[13] << 8) + - dfusuffix[12]; - - if (file->dwCRC != crc) { - reason = "DFU suffix CRC does not match"; - missing_suffix = 1; - goto checked; - } - - /* At this point we believe we have a DFU suffix - so we require further checks to succeed */ - - file->bcdDFU = (dfusuffix[7] << 8) + dfusuffix[6]; - - if (verbose) - printf("DFU suffix version %x\n", file->bcdDFU); - - file->size.suffix = dfusuffix[11]; - - if (file->size.suffix < DFU_SUFFIX_LENGTH) { - errx(EX_IOERR, "Unsupported DFU suffix length %d", - file->size.suffix); - } - - if (file->size.suffix > file->size.total) { - errx(EX_IOERR, "Invalid DFU suffix length %d", - file->size.suffix); - } - - file->idVendor = (dfusuffix[5] << 8) + dfusuffix[4]; - file->idProduct = (dfusuffix[3] << 8) + dfusuffix[2]; - file->bcdDevice = (dfusuffix[1] << 8) + dfusuffix[0]; - -checked: - if (missing_suffix) { - if (check_suffix == NEEDS_SUFFIX) { - warnx("%s", reason); - errx(EX_IOERR, "Valid DFU suffix needed"); - } else if (check_suffix == MAYBE_SUFFIX) { - warnx("%s", reason); - warnx("A valid DFU suffix will be required in " - "a future dfu-util release!!!"); - } - } else { - if (check_suffix == NO_SUFFIX) { - errx(EX_SOFTWARE, "Please remove existing DFU suffix before adding a new one.\n"); - } - } - } - res = probe_prefix(file); - if ((res || file->size.prefix == 0) && check_prefix == NEEDS_PREFIX) - errx(EX_IOERR, "Valid DFU prefix needed"); - if (file->size.prefix && check_prefix == NO_PREFIX) - errx(EX_IOERR, "A prefix already exists, please delete it first"); - if (file->size.prefix && verbose) { - uint8_t *data = file->firmware; - if (file->prefix_type == LMDFU_PREFIX) - printf("Possible TI Stellaris DFU prefix with " - "the following properties\n" - "Address: 0x%08x\n" - "Payload length: %d\n", - file->lmdfu_address, - data[4] | (data[5] << 8) | - (data[6] << 16) | (data[7] << 14)); - else if (file->prefix_type == LPCDFU_UNENCRYPTED_PREFIX) - printf("Possible unencrypted NXP LPC DFU prefix with " - "the following properties\n" - "Payload length: %d kiByte\n", - data[2] >>1 | (data[3] << 7) ); - else - errx(EX_IOERR, "Unknown DFU prefix type"); - } -} - -void dfu_store_file(struct dfu_file *file, int write_suffix, int write_prefix) -{ - uint32_t crc = 0xffffffff; - int f; - - f = open(file->name, O_WRONLY | O_BINARY | O_TRUNC | O_CREAT, 0666); - if (f < 0) - err(EX_IOERR, "Could not open file %s for writing", file->name); - - /* write prefix, if any */ - if (write_prefix) { - if (file->prefix_type == LMDFU_PREFIX) { - uint8_t lmdfu_prefix[LMDFU_PREFIX_LENGTH]; - uint32_t addr = file->lmdfu_address / 1024; - - /* lmdfu_dfu_prefix payload length excludes prefix and suffix */ - uint32_t len = file->size.total - - file->size.prefix - file->size.suffix; - - lmdfu_prefix[0] = 0x01; /* STELLARIS_DFU_PROG */ - lmdfu_prefix[1] = 0x00; /* Reserved */ - lmdfu_prefix[2] = (uint8_t)(addr & 0xff); - lmdfu_prefix[3] = (uint8_t)(addr >> 8); - lmdfu_prefix[4] = (uint8_t)(len & 0xff); - lmdfu_prefix[5] = (uint8_t)(len >> 8) & 0xff; - lmdfu_prefix[6] = (uint8_t)(len >> 16) & 0xff; - lmdfu_prefix[7] = (uint8_t)(len >> 24); - - crc = dfu_file_write_crc(f, crc, lmdfu_prefix, LMDFU_PREFIX_LENGTH); - } - if (file->prefix_type == LPCDFU_UNENCRYPTED_PREFIX) { - uint8_t lpcdfu_prefix[LPCDFU_PREFIX_LENGTH] = {0}; - int i; - - /* Payload is firmware and prefix rounded to 512 bytes */ - uint32_t len = (file->size.total - file->size.suffix + 511) /512; - - lpcdfu_prefix[0] = 0x1a; /* Unencypted*/ - lpcdfu_prefix[1] = 0x3f; /* Reserved */ - lpcdfu_prefix[2] = (uint8_t)(len & 0xff); - lpcdfu_prefix[3] = (uint8_t)((len >> 8) & 0xff); - for (i = 12; i < LPCDFU_PREFIX_LENGTH; i++) - lpcdfu_prefix[i] = 0xff; - - crc = dfu_file_write_crc(f, crc, lpcdfu_prefix, LPCDFU_PREFIX_LENGTH); - } - } - /* write firmware binary */ - crc = dfu_file_write_crc(f, crc, file->firmware + file->size.prefix, - file->size.total - file->size.prefix - file->size.suffix); - - /* write suffix, if any */ - if (write_suffix) { - uint8_t dfusuffix[DFU_SUFFIX_LENGTH]; - - dfusuffix[0] = file->bcdDevice & 0xff; - dfusuffix[1] = file->bcdDevice >> 8; - dfusuffix[2] = file->idProduct & 0xff; - dfusuffix[3] = file->idProduct >> 8; - dfusuffix[4] = file->idVendor & 0xff; - dfusuffix[5] = file->idVendor >> 8; - dfusuffix[6] = file->bcdDFU & 0xff; - dfusuffix[7] = file->bcdDFU >> 8; - dfusuffix[8] = 'U'; - dfusuffix[9] = 'F'; - dfusuffix[10] = 'D'; - dfusuffix[11] = DFU_SUFFIX_LENGTH; - - crc = dfu_file_write_crc(f, crc, dfusuffix, - DFU_SUFFIX_LENGTH - 4); - - dfusuffix[12] = crc; - dfusuffix[13] = crc >> 8; - dfusuffix[14] = crc >> 16; - dfusuffix[15] = crc >> 24; - - crc = dfu_file_write_crc(f, crc, dfusuffix + 12, 4); - } - close(f); -} - -void show_suffix_and_prefix(struct dfu_file *file) -{ - if (file->size.prefix == LMDFU_PREFIX_LENGTH) { - printf("The file %s contains a TI Stellaris DFU prefix with the following properties:\n", file->name); - printf("Address:\t0x%08x\n", file->lmdfu_address); - } else if (file->size.prefix == LPCDFU_PREFIX_LENGTH) { - uint8_t * prefix = file->firmware; - printf("The file %s contains a NXP unencrypted LPC DFU prefix with the following properties:\n", file->name); - printf("Size:\t%5d kiB\n", prefix[2]>>1|prefix[3]<<7); - } else if (file->size.prefix != 0) { - printf("The file %s contains an unknown prefix\n", file->name); - } - if (file->size.suffix > 0) { - printf("The file %s contains a DFU suffix with the following properties:\n", file->name); - printf("BCD device:\t0x%04X\n", file->bcdDevice); - printf("Product ID:\t0x%04X\n",file->idProduct); - printf("Vendor ID:\t0x%04X\n", file->idVendor); - printf("BCD DFU:\t0x%04X\n", file->bcdDFU); - printf("Length:\t\t%i\n", file->size.suffix); - printf("CRC:\t\t0x%08X\n", file->dwCRC); - } -} diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_file.h b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_file.h deleted file mode 100755 index abebd44f4..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_file.h +++ /dev/null @@ -1,60 +0,0 @@ - -#ifndef DFU_FILE_H -#define DFU_FILE_H - -#include - -struct dfu_file { - /* File name */ - const char *name; - /* Pointer to file loaded into memory */ - uint8_t *firmware; - /* Different sizes */ - struct { - int total; - int prefix; - int suffix; - } size; - /* From prefix fields */ - uint32_t lmdfu_address; - /* From prefix fields */ - uint32_t prefix_type; - - /* From DFU suffix fields */ - uint32_t dwCRC; - uint16_t bcdDFU; - uint16_t idVendor; - uint16_t idProduct; - uint16_t bcdDevice; -}; - -enum suffix_req { - NO_SUFFIX, - NEEDS_SUFFIX, - MAYBE_SUFFIX -}; - -enum prefix_req { - NO_PREFIX, - NEEDS_PREFIX, - MAYBE_PREFIX -}; - -enum prefix_type { - ZERO_PREFIX, - LMDFU_PREFIX, - LPCDFU_UNENCRYPTED_PREFIX -}; - -extern int verbose; - -void dfu_load_file(struct dfu_file *file, enum suffix_req check_suffix, enum prefix_req check_prefix); -void dfu_store_file(struct dfu_file *file, int write_suffix, int write_prefix); - -void dfu_progress_bar(const char *desc, unsigned long long curr, - unsigned long long max); -void *dfu_malloc(size_t size); -uint32_t dfu_file_write_crc(int f, uint32_t crc, const void *buf, int size); -void show_suffix_and_prefix(struct dfu_file *file); - -#endif /* DFU_FILE_H */ diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_load.c b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_load.c deleted file mode 100755 index 64f7009df..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_load.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * DFU transfer routines - * - * This is supposed to be a general DFU implementation, as specified in the - * USB DFU 1.0 and 1.1 specification. - * - * The code was originally intended to interface with a USB device running the - * "sam7dfu" firmware (see http://www.openpcd.org/) on an AT91SAM7 processor. - * - * Copyright 2007-2008 Harald Welte - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "quirks.h" - -int dfuload_do_upload(struct dfu_if *dif, int xfer_size, - int expected_size, int fd) -{ - int total_bytes = 0; - unsigned short transaction = 0; - unsigned char *buf; - int ret; - - buf = dfu_malloc(xfer_size); - - printf("Copying data from DFU device to PC\n"); - dfu_progress_bar("Upload", 0, 1); - - while (1) { - int rc; - rc = dfu_upload(dif->dev_handle, dif->interface, - xfer_size, transaction++, buf); - if (rc < 0) { - warnx("Error during upload"); - ret = rc; - goto out_free; - } - - dfu_file_write_crc(fd, 0, buf, rc); - total_bytes += rc; - - if (total_bytes < 0) - errx(EX_SOFTWARE, "Received too many bytes (wraparound)"); - - if (rc < xfer_size) { - /* last block, return */ - ret = total_bytes; - break; - } - dfu_progress_bar("Upload", total_bytes, expected_size); - } - ret = 0; - -out_free: - dfu_progress_bar("Upload", total_bytes, total_bytes); - if (total_bytes == 0) - printf("\nFailed.\n"); - free(buf); - if (verbose) - printf("Received a total of %i bytes\n", total_bytes); - if (expected_size != 0 && total_bytes != expected_size) - errx(EX_SOFTWARE, "Unexpected number of bytes uploaded from device"); - return ret; -} - -int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file) -{ - int bytes_sent; - int expected_size; - unsigned char *buf; - unsigned short transaction = 0; - struct dfu_status dst; - int ret; - - printf("Copying data from PC to DFU device\n"); - - buf = file->firmware; - expected_size = file->size.total - file->size.suffix; - bytes_sent = 0; - - dfu_progress_bar("Download", 0, 1); - while (bytes_sent < expected_size) { - int bytes_left; - int chunk_size; - - bytes_left = expected_size - bytes_sent; - if (bytes_left < xfer_size) - chunk_size = bytes_left; - else - chunk_size = xfer_size; - - ret = dfu_download(dif->dev_handle, dif->interface, - chunk_size, transaction++, chunk_size ? buf : NULL); - if (ret < 0) { - warnx("Error during download"); - goto out; - } - bytes_sent += chunk_size; - buf += chunk_size; - - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during download get_status"); - goto out; - } - - if (dst.bState == DFU_STATE_dfuDNLOAD_IDLE || - dst.bState == DFU_STATE_dfuERROR) - break; - - /* Wait while device executes flashing */ - milli_sleep(dst.bwPollTimeout); - - } while (1); - if (dst.bStatus != DFU_STATUS_OK) { - printf(" failed!\n"); - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - ret = -1; - goto out; - } - dfu_progress_bar("Download", bytes_sent, bytes_sent + bytes_left); - } - - /* send one zero sized download request to signalize end */ - ret = dfu_download(dif->dev_handle, dif->interface, - 0, transaction, NULL); - if (ret < 0) { - errx(EX_IOERR, "Error sending completion packet"); - goto out; - } - - dfu_progress_bar("Download", bytes_sent, bytes_sent); - - if (verbose) - printf("Sent a total of %i bytes\n", bytes_sent); - -get_status: - /* Transition to MANIFEST_SYNC state */ - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - warnx("unable to read DFU status after completion"); - goto out; - } - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - - milli_sleep(dst.bwPollTimeout); - - /* FIXME: deal correctly with ManifestationTolerant=0 / WillDetach bits */ - switch (dst.bState) { - case DFU_STATE_dfuMANIFEST_SYNC: - case DFU_STATE_dfuMANIFEST: - /* some devices (e.g. TAS1020b) need some time before we - * can obtain the status */ - milli_sleep(1000); - goto get_status; - break; - case DFU_STATE_dfuIDLE: - break; - } - printf("Done!\n"); - -out: - return bytes_sent; -} diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_load.h b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_load.h deleted file mode 100755 index be23e9b4f..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_load.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef DFU_LOAD_H -#define DFU_LOAD_H - -int dfuload_do_upload(struct dfu_if *dif, int xfer_size, int expected_size, int fd); -int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file); - -#endif /* DFU_LOAD_H */ diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_util.c b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_util.c deleted file mode 100755 index b94c7ccd3..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_util.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Functions for detecting DFU USB entities - * - * Written by Harald Welte - * Copyright 2007-2008 by OpenMoko, Inc. - * Copyright 2013 Hans Petter Selasky - * - * Based on existing code of dfu-programmer-0.4 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "dfu_util.h" -#include "dfuse.h" -#include "quirks.h" - -#ifdef HAVE_USBPATH_H -#include -#endif - -/* - * Look for a descriptor in a concatenated descriptor list. Will - * return upon the first match of the given descriptor type. Returns length of - * found descriptor, limited to res_size - */ -static int find_descriptor(const uint8_t *desc_list, int list_len, - uint8_t desc_type, void *res_buf, int res_size) -{ - int p = 0; - - if (list_len < 2) - return (-1); - - while (p + 1 < list_len) { - int desclen; - - desclen = (int) desc_list[p]; - if (desclen == 0) { - warnx("Invalid descriptor list"); - return -1; - } - if (desc_list[p + 1] == desc_type) { - if (desclen > res_size) - desclen = res_size; - if (p + desclen > list_len) - desclen = list_len - p; - memcpy(res_buf, &desc_list[p], desclen); - return desclen; - } - p += (int) desc_list[p]; - } - return -1; -} - -static void probe_configuration(libusb_device *dev, struct libusb_device_descriptor *desc) -{ - struct usb_dfu_func_descriptor func_dfu; - libusb_device_handle *devh; - struct dfu_if *pdfu; - struct libusb_config_descriptor *cfg; - const struct libusb_interface_descriptor *intf; - const struct libusb_interface *uif; - char alt_name[MAX_DESC_STR_LEN + 1]; - char serial_name[MAX_DESC_STR_LEN + 1]; - int cfg_idx; - int intf_idx; - int alt_idx; - int ret; - int has_dfu; - - for (cfg_idx = 0; cfg_idx != desc->bNumConfigurations; cfg_idx++) { - memset(&func_dfu, 0, sizeof(func_dfu)); - has_dfu = 0; - - ret = libusb_get_config_descriptor(dev, cfg_idx, &cfg); - if (ret != 0) - return; - if (match_config_index > -1 && match_config_index != cfg->bConfigurationValue) { - libusb_free_config_descriptor(cfg); - continue; - } - - /* - * In some cases, noticably FreeBSD if uid != 0, - * the configuration descriptors are empty - */ - if (!cfg) - return; - - ret = find_descriptor(cfg->extra, cfg->extra_length, - USB_DT_DFU, &func_dfu, sizeof(func_dfu)); - if (ret > -1) - goto found_dfu; - - for (intf_idx = 0; intf_idx < cfg->bNumInterfaces; - intf_idx++) { - uif = &cfg->interface[intf_idx]; - if (!uif) - break; - - for (alt_idx = 0; alt_idx < cfg->interface[intf_idx].num_altsetting; - alt_idx++) { - intf = &uif->altsetting[alt_idx]; - - ret = find_descriptor(intf->extra, intf->extra_length, USB_DT_DFU, - &func_dfu, sizeof(func_dfu)); - if (ret > -1) - goto found_dfu; - - if (intf->bInterfaceClass != 0xfe || - intf->bInterfaceSubClass != 1) - continue; - - has_dfu = 1; - } - } - if (has_dfu) { - /* - * Finally try to retrieve it requesting the - * device directly This is not supported on - * all devices for non-standard types - */ - if (libusb_open(dev, &devh) == 0) { - ret = libusb_get_descriptor(devh, USB_DT_DFU, 0, - (void *)&func_dfu, sizeof(func_dfu)); - libusb_close(devh); - if (ret > -1) - goto found_dfu; - } - warnx("Device has DFU interface, " - "but has no DFU functional descriptor"); - - /* fake version 1.0 */ - func_dfu.bLength = 7; - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - goto found_dfu; - } - libusb_free_config_descriptor(cfg); - continue; - -found_dfu: - if (func_dfu.bLength == 7) { - printf("Deducing device DFU version from functional descriptor " - "length\n"); - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - } else if (func_dfu.bLength < 9) { - printf("Error obtaining DFU functional descriptor\n"); - printf("Please report this as a bug!\n"); - printf("Warning: Assuming DFU version 1.0\n"); - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - printf("Warning: Transfer size can not be detected\n"); - func_dfu.wTransferSize = 0; - } - - for (intf_idx = 0; intf_idx < cfg->bNumInterfaces; - intf_idx++) { - if (match_iface_index > -1 && match_iface_index != intf_idx) - continue; - - uif = &cfg->interface[intf_idx]; - if (!uif) - break; - - for (alt_idx = 0; - alt_idx < uif->num_altsetting; alt_idx++) { - int dfu_mode; - - intf = &uif->altsetting[alt_idx]; - - if (intf->bInterfaceClass != 0xfe || - intf->bInterfaceSubClass != 1) - continue; - - dfu_mode = (intf->bInterfaceProtocol == 2); - /* e.g. DSO Nano has bInterfaceProtocol 0 instead of 2 */ - if (func_dfu.bcdDFUVersion == 0x011a && intf->bInterfaceProtocol == 0) - dfu_mode = 1; - - if (dfu_mode && - match_iface_alt_index > -1 && match_iface_alt_index != alt_idx) - continue; - - if (dfu_mode) { - if ((match_vendor_dfu >= 0 && match_vendor_dfu != desc->idVendor) || - (match_product_dfu >= 0 && match_product_dfu != desc->idProduct)) { - continue; - } - } else { - if ((match_vendor >= 0 && match_vendor != desc->idVendor) || - (match_product >= 0 && match_product != desc->idProduct)) { - continue; - } - } - - if (libusb_open(dev, &devh)) { - warnx("Cannot open DFU device %04x:%04x", desc->idVendor, desc->idProduct); - break; - } - if (intf->iInterface != 0) - ret = libusb_get_string_descriptor_ascii(devh, - intf->iInterface, (void *)alt_name, MAX_DESC_STR_LEN); - else - ret = -1; - if (ret < 1) - strcpy(alt_name, "UNKNOWN"); - if (desc->iSerialNumber != 0) - ret = libusb_get_string_descriptor_ascii(devh, - desc->iSerialNumber, (void *)serial_name, MAX_DESC_STR_LEN); - else - ret = -1; - if (ret < 1) - strcpy(serial_name, "UNKNOWN"); - libusb_close(devh); - - if (dfu_mode && - match_iface_alt_name != NULL && strcmp(alt_name, match_iface_alt_name)) - continue; - - if (dfu_mode) { - if (match_serial_dfu != NULL && strcmp(match_serial_dfu, serial_name)) - continue; - } else { - if (match_serial != NULL && strcmp(match_serial, serial_name)) - continue; - } - - pdfu = dfu_malloc(sizeof(*pdfu)); - - memset(pdfu, 0, sizeof(*pdfu)); - - pdfu->func_dfu = func_dfu; - pdfu->dev = libusb_ref_device(dev); - pdfu->quirks = get_quirks(desc->idVendor, - desc->idProduct, desc->bcdDevice); - pdfu->vendor = desc->idVendor; - pdfu->product = desc->idProduct; - pdfu->bcdDevice = desc->bcdDevice; - pdfu->configuration = cfg->bConfigurationValue; - pdfu->interface = intf->bInterfaceNumber; - pdfu->altsetting = intf->bAlternateSetting; - pdfu->devnum = libusb_get_device_address(dev); - pdfu->busnum = libusb_get_bus_number(dev); - pdfu->alt_name = strdup(alt_name); - if (pdfu->alt_name == NULL) - errx(EX_SOFTWARE, "Out of memory"); - pdfu->serial_name = strdup(serial_name); - if (pdfu->serial_name == NULL) - errx(EX_SOFTWARE, "Out of memory"); - if (dfu_mode) - pdfu->flags |= DFU_IFF_DFU; - if (pdfu->quirks & QUIRK_FORCE_DFU11) { - pdfu->func_dfu.bcdDFUVersion = - libusb_cpu_to_le16(0x0110); - } - pdfu->bMaxPacketSize0 = desc->bMaxPacketSize0; - - /* queue into list */ - pdfu->next = dfu_root; - dfu_root = pdfu; - } - } - libusb_free_config_descriptor(cfg); - } -} - -void probe_devices(libusb_context *ctx) -{ - libusb_device **list; - ssize_t num_devs; - ssize_t i; - - num_devs = libusb_get_device_list(ctx, &list); - for (i = 0; i < num_devs; ++i) { - struct libusb_device_descriptor desc; - struct libusb_device *dev = list[i]; - - if (match_bus > -1 && match_bus != libusb_get_bus_number(dev)) - continue; - if (match_device > -1 && match_device != libusb_get_device_address(dev)) - continue; - if (libusb_get_device_descriptor(dev, &desc)) - continue; - probe_configuration(dev, &desc); - } - libusb_free_device_list(list, 0); -} - -void disconnect_devices(void) -{ - struct dfu_if *pdfu; - struct dfu_if *prev = NULL; - - for (pdfu = dfu_root; pdfu != NULL; pdfu = pdfu->next) { - free(prev); - libusb_unref_device(pdfu->dev); - free(pdfu->alt_name); - free(pdfu->serial_name); - prev = pdfu; - } - free(prev); - dfu_root = NULL; -} - -void print_dfu_if(struct dfu_if *dfu_if) -{ - printf("Found %s: [%04x:%04x] ver=%04x, devnum=%u, cfg=%u, intf=%u, " - "alt=%u, name=\"%s\", serial=\"%s\"\n", - dfu_if->flags & DFU_IFF_DFU ? "DFU" : "Runtime", - dfu_if->vendor, dfu_if->product, - dfu_if->bcdDevice, dfu_if->devnum, - dfu_if->configuration, dfu_if->interface, - dfu_if->altsetting, dfu_if->alt_name, - dfu_if->serial_name); -} - -/* Walk the device tree and print out DFU devices */ -void list_dfu_interfaces(void) -{ - struct dfu_if *pdfu; - - for (pdfu = dfu_root; pdfu != NULL; pdfu = pdfu->next) - print_dfu_if(pdfu); -} diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_util.h b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_util.h deleted file mode 100755 index fc0c19dca..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfu_util.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef DFU_UTIL_H -#define DFU_UTIL_H - -/* USB string descriptor should contain max 126 UTF-16 characters - * but 253 would even accomodate any UTF-8 encoding */ -#define MAX_DESC_STR_LEN 253 - -enum mode { - MODE_NONE, - MODE_VERSION, - MODE_LIST, - MODE_DETACH, - MODE_UPLOAD, - MODE_DOWNLOAD -}; - -extern struct dfu_if *dfu_root; -extern int match_bus; -extern int match_device; -extern int match_vendor; -extern int match_product; -extern int match_vendor_dfu; -extern int match_product_dfu; -extern int match_config_index; -extern int match_iface_index; -extern int match_iface_alt_index; -extern const char *match_iface_alt_name; -extern const char *match_serial; -extern const char *match_serial_dfu; - -void probe_devices(libusb_context *); -void disconnect_devices(void); -void print_dfu_if(struct dfu_if *); -void list_dfu_interfaces(void); - -#endif /* DFU_UTIL_H */ diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse.c b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse.c deleted file mode 100755 index fce29fed6..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse.c +++ /dev/null @@ -1,652 +0,0 @@ -/* - * DfuSe specific functions - * - * This implements the ST Microsystems DFU extensions (DfuSe) - * as per the DfuSe 1.1a specification (ST documents AN3156, AN2606) - * The DfuSe file format is described in ST document UM0391. - * - * Copyright 2010-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfuse.h" -#include "dfuse_mem.h" - -#define DFU_TIMEOUT 5000 - -extern int verbose; -static unsigned int last_erased_page = 1; /* non-aligned value, won't match */ -static struct memsegment *mem_layout; -static unsigned int dfuse_address = 0; -static unsigned int dfuse_length = 0; -static int dfuse_force = 0; -static int dfuse_leave = 0; -static int dfuse_unprotect = 0; -static int dfuse_mass_erase = 0; - -unsigned int quad2uint(unsigned char *p) -{ - return (*p + (*(p + 1) << 8) + (*(p + 2) << 16) + (*(p + 3) << 24)); -} - -void dfuse_parse_options(const char *options) -{ - char *end; - const char *endword; - unsigned int number; - - /* address, possibly empty, must be first */ - if (*options != ':') { - endword = strchr(options, ':'); - if (!endword) - endword = options + strlen(options); /* GNU strchrnul */ - - number = strtoul(options, &end, 0); - if (end == endword) { - dfuse_address = number; - } else { - errx(EX_IOERR, "Invalid dfuse address: %s", options); - } - options = endword; - } - - while (*options) { - if (*options == ':') { - options++; - continue; - } - endword = strchr(options, ':'); - if (!endword) - endword = options + strlen(options); - - if (!strncmp(options, "force", endword - options)) { - dfuse_force++; - options += 5; - continue; - } - if (!strncmp(options, "leave", endword - options)) { - dfuse_leave = 1; - options += 5; - continue; - } - if (!strncmp(options, "unprotect", endword - options)) { - dfuse_unprotect = 1; - options += 9; - continue; - } - if (!strncmp(options, "mass-erase", endword - options)) { - dfuse_mass_erase = 1; - options += 10; - continue; - } - - /* any valid number is interpreted as upload length */ - number = strtoul(options, &end, 0); - if (end == endword) { - dfuse_length = number; - } else { - errx(EX_IOERR, "Invalid dfuse modifier: %s", options); - } - options = endword; - } -} - -/* DFU_UPLOAD request for DfuSe 1.1a */ -int dfuse_upload(struct dfu_if *dif, const unsigned short length, - unsigned char *data, unsigned short transaction) -{ - int status; - - status = libusb_control_transfer(dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | - LIBUSB_REQUEST_TYPE_CLASS | - LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_UPLOAD, - /* wValue */ transaction, - /* wIndex */ dif->interface, - /* Data */ data, - /* wLength */ length, - DFU_TIMEOUT); - if (status < 0) { - errx(EX_IOERR, "%s: libusb_control_msg returned %d", - __FUNCTION__, status); - } - return status; -} - -/* DFU_DNLOAD request for DfuSe 1.1a */ -int dfuse_download(struct dfu_if *dif, const unsigned short length, - unsigned char *data, unsigned short transaction) -{ - int status; - - status = libusb_control_transfer(dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | - LIBUSB_REQUEST_TYPE_CLASS | - LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DNLOAD, - /* wValue */ transaction, - /* wIndex */ dif->interface, - /* Data */ data, - /* wLength */ length, - DFU_TIMEOUT); - if (status < 0) { - errx(EX_IOERR, "%s: libusb_control_transfer returned %d", - __FUNCTION__, status); - } - return status; -} - -/* DfuSe only commands */ -/* Leaves the device in dfuDNLOAD-IDLE state */ -int dfuse_special_command(struct dfu_if *dif, unsigned int address, - enum dfuse_command command) -{ - const char* dfuse_command_name[] = { "SET_ADDRESS" , "ERASE_PAGE", - "MASS_ERASE", "READ_UNPROTECT"}; - unsigned char buf[5]; - int length; - int ret; - struct dfu_status dst; - int firstpoll = 1; - - if (command == ERASE_PAGE) { - struct memsegment *segment; - int page_size; - - segment = find_segment(mem_layout, address); - if (!segment || !(segment->memtype & DFUSE_ERASABLE)) { - errx(EX_IOERR, "Page at 0x%08x can not be erased", - address); - } - page_size = segment->pagesize; - if (verbose > 1) - printf("Erasing page size %i at address 0x%08x, page " - "starting at 0x%08x\n", page_size, address, - address & ~(page_size - 1)); - buf[0] = 0x41; /* Erase command */ - length = 5; - last_erased_page = address & ~(page_size - 1); - } else if (command == SET_ADDRESS) { - if (verbose > 2) - printf(" Setting address pointer to 0x%08x\n", - address); - buf[0] = 0x21; /* Set Address Pointer command */ - length = 5; - } else if (command == MASS_ERASE) { - buf[0] = 0x41; /* Mass erase command when length = 1 */ - length = 1; - } else if (command == READ_UNPROTECT) { - buf[0] = 0x92; - length = 1; - } else { - errx(EX_IOERR, "Non-supported special command %d", command); - } - buf[1] = address & 0xff; - buf[2] = (address >> 8) & 0xff; - buf[3] = (address >> 16) & 0xff; - buf[4] = (address >> 24) & 0xff; - - ret = dfuse_download(dif, length, buf, 0); - if (ret < 0) { - errx(EX_IOERR, "Error during special command \"%s\" download", - dfuse_command_name[command]); - } - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during special command \"%s\" get_status", - dfuse_command_name[command]); - } - if (firstpoll) { - firstpoll = 0; - if (dst.bState != DFU_STATE_dfuDNBUSY) { - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - errx(EX_IOERR, "Wrong state after command \"%s\" download", - dfuse_command_name[command]); - } - } - /* wait while command is executed */ - if (verbose) - printf(" Poll timeout %i ms\n", dst.bwPollTimeout); - milli_sleep(dst.bwPollTimeout); - if (command == READ_UNPROTECT) - return ret; - } while (dst.bState == DFU_STATE_dfuDNBUSY); - - if (dst.bStatus != DFU_STATUS_OK) { - errx(EX_IOERR, "%s not correctly executed", - dfuse_command_name[command]); - } - return ret; -} - -int dfuse_dnload_chunk(struct dfu_if *dif, unsigned char *data, int size, - int transaction) -{ - int bytes_sent; - struct dfu_status dst; - int ret; - - ret = dfuse_download(dif, size, size ? data : NULL, transaction); - if (ret < 0) { - errx(EX_IOERR, "Error during download"); - return ret; - } - bytes_sent = ret; - - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during download get_status"); - return ret; - } - milli_sleep(dst.bwPollTimeout); - } while (dst.bState != DFU_STATE_dfuDNLOAD_IDLE && - dst.bState != DFU_STATE_dfuERROR && - dst.bState != DFU_STATE_dfuMANIFEST); - - if (dst.bState == DFU_STATE_dfuMANIFEST) - printf("Transitioning to dfuMANIFEST state\n"); - - if (dst.bStatus != DFU_STATUS_OK) { - printf(" failed!\n"); - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - return -1; - } - return bytes_sent; -} - -int dfuse_do_upload(struct dfu_if *dif, int xfer_size, int fd, - const char *dfuse_options) -{ - int total_bytes = 0; - int upload_limit = 0; - unsigned char *buf; - int transaction; - int ret; - - buf = dfu_malloc(xfer_size); - - if (dfuse_options) - dfuse_parse_options(dfuse_options); - if (dfuse_length) - upload_limit = dfuse_length; - if (dfuse_address) { - struct memsegment *segment; - - mem_layout = parse_memory_layout((char *)dif->alt_name); - if (!mem_layout) - errx(EX_IOERR, "Failed to parse memory layout"); - - segment = find_segment(mem_layout, dfuse_address); - if (!dfuse_force && - (!segment || !(segment->memtype & DFUSE_READABLE))) - errx(EX_IOERR, "Page at 0x%08x is not readable", - dfuse_address); - - if (!upload_limit) { - upload_limit = segment->end - dfuse_address + 1; - printf("Limiting upload to end of memory segment, " - "%i bytes\n", upload_limit); - } - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfu_abort_to_idle(dif); - } else { - /* Boot loader decides the start address, unknown to us */ - /* Use a short length to lower risk of running out of bounds */ - if (!upload_limit) - upload_limit = 0x4000; - printf("Limiting default upload to %i bytes\n", upload_limit); - } - - dfu_progress_bar("Upload", 0, 1); - - transaction = 2; - while (1) { - int rc; - - /* last chunk can be smaller than original xfer_size */ - if (upload_limit - total_bytes < xfer_size) - xfer_size = upload_limit - total_bytes; - rc = dfuse_upload(dif, xfer_size, buf, transaction++); - if (rc < 0) { - ret = rc; - goto out_free; - } - - dfu_file_write_crc(fd, 0, buf, rc); - total_bytes += rc; - - if (total_bytes < 0) - errx(EX_SOFTWARE, "Received too many bytes"); - - if (rc < xfer_size || total_bytes >= upload_limit) { - /* last block, return successfully */ - ret = total_bytes; - break; - } - dfu_progress_bar("Upload", total_bytes, upload_limit); - } - - dfu_progress_bar("Upload", total_bytes, total_bytes); - - dfu_abort_to_idle(dif); - if (dfuse_leave) { - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfuse_dnload_chunk(dif, NULL, 0, 2); /* Zero-size */ - } - - out_free: - free(buf); - - return ret; -} - -/* Writes an element of any size to the device, taking care of page erases */ -/* returns 0 on success, otherwise -EINVAL */ -int dfuse_dnload_element(struct dfu_if *dif, unsigned int dwElementAddress, - unsigned int dwElementSize, unsigned char *data, - int xfer_size) -{ - int p; - int ret; - struct memsegment *segment; - - /* Check at least that we can write to the last address */ - segment = - find_segment(mem_layout, dwElementAddress + dwElementSize - 1); - if (!segment || !(segment->memtype & DFUSE_WRITEABLE)) { - errx(EX_IOERR, "Last page at 0x%08x is not writeable", - dwElementAddress + dwElementSize - 1); - } - - dfu_progress_bar("Download", 0, 1); - - for (p = 0; p < (int)dwElementSize; p += xfer_size) { - int page_size; - unsigned int erase_address; - unsigned int address = dwElementAddress + p; - int chunk_size = xfer_size; - - segment = find_segment(mem_layout, address); - if (!segment || !(segment->memtype & DFUSE_WRITEABLE)) { - errx(EX_IOERR, "Page at 0x%08x is not writeable", - address); - } - page_size = segment->pagesize; - - /* check if this is the last chunk */ - if (p + chunk_size > (int)dwElementSize) - chunk_size = dwElementSize - p; - - /* Erase only for flash memory downloads */ - if ((segment->memtype & DFUSE_ERASABLE) && !dfuse_mass_erase) { - /* erase all involved pages */ - for (erase_address = address; - erase_address < address + chunk_size; - erase_address += page_size) - if ((erase_address & ~(page_size - 1)) != - last_erased_page) - dfuse_special_command(dif, - erase_address, - ERASE_PAGE); - - if (((address + chunk_size - 1) & ~(page_size - 1)) != - last_erased_page) { - if (verbose > 2) - printf(" Chunk extends into next page," - " erase it as well\n"); - dfuse_special_command(dif, - address + chunk_size - 1, - ERASE_PAGE); - } - } - - if (verbose) { - printf(" Download from image offset " - "%08x to memory %08x-%08x, size %i\n", - p, address, address + chunk_size - 1, - chunk_size); - } else { - dfu_progress_bar("Download", p, dwElementSize); - } - - dfuse_special_command(dif, address, SET_ADDRESS); - - /* transaction = 2 for no address offset */ - ret = dfuse_dnload_chunk(dif, data + p, chunk_size, 2); - if (ret != chunk_size) { - errx(EX_IOERR, "Failed to write whole chunk: " - "%i of %i bytes", ret, chunk_size); - return -EINVAL; - } - } - if (!verbose) - dfu_progress_bar("Download", dwElementSize, dwElementSize); - return 0; -} - -static void -dfuse_memcpy(unsigned char *dst, unsigned char **src, int *rem, int size) -{ - if (size > *rem) { - errx(EX_IOERR, "Corrupt DfuSe file: " - "Cannot read %d bytes from %d bytes", size, *rem); - } - if (dst != NULL) - memcpy(dst, *src, size); - (*src) += size; - (*rem) -= size; -} - -/* Download raw binary file to DfuSe device */ -int dfuse_do_bin_dnload(struct dfu_if *dif, int xfer_size, - struct dfu_file *file, unsigned int start_address) -{ - unsigned int dwElementAddress; - unsigned int dwElementSize; - unsigned char *data; - int ret; - - dwElementAddress = start_address; - dwElementSize = file->size.total - - file->size.suffix - file->size.prefix; - - printf("Downloading to address = 0x%08x, size = %i\n", - dwElementAddress, dwElementSize); - - data = file->firmware + file->size.prefix; - - ret = dfuse_dnload_element(dif, dwElementAddress, dwElementSize, data, - xfer_size); - if (ret != 0) - goto out_free; - - printf("File downloaded successfully\n"); - ret = dwElementSize; - - out_free: - return ret; -} - -/* Parse a DfuSe file and download contents to device */ -int dfuse_do_dfuse_dnload(struct dfu_if *dif, int xfer_size, - struct dfu_file *file) -{ - uint8_t dfuprefix[11]; - uint8_t targetprefix[274]; - uint8_t elementheader[8]; - int image; - int element; - int bTargets; - int bAlternateSetting; - int dwNbElements; - unsigned int dwElementAddress; - unsigned int dwElementSize; - uint8_t *data; - int ret; - int rem; - int bFirstAddressSaved = 0; - - rem = file->size.total - file->size.prefix - file->size.suffix; - data = file->firmware + file->size.prefix; - - /* Must be larger than a minimal DfuSe header and suffix */ - if (rem < (int)(sizeof(dfuprefix) + - sizeof(targetprefix) + sizeof(elementheader))) { - errx(EX_SOFTWARE, "File too small for a DfuSe file"); - } - - dfuse_memcpy(dfuprefix, &data, &rem, sizeof(dfuprefix)); - - if (strncmp((char *)dfuprefix, "DfuSe", 5)) { - errx(EX_IOERR, "No valid DfuSe signature"); - return -EINVAL; - } - if (dfuprefix[5] != 0x01) { - errx(EX_IOERR, "DFU format revision %i not supported", - dfuprefix[5]); - return -EINVAL; - } - bTargets = dfuprefix[10]; - printf("file contains %i DFU images\n", bTargets); - - for (image = 1; image <= bTargets; image++) { - printf("parsing DFU image %i\n", image); - dfuse_memcpy(targetprefix, &data, &rem, sizeof(targetprefix)); - if (strncmp((char *)targetprefix, "Target", 6)) { - errx(EX_IOERR, "No valid target signature"); - return -EINVAL; - } - bAlternateSetting = targetprefix[6]; - dwNbElements = quad2uint((unsigned char *)targetprefix + 270); - printf("image for alternate setting %i, ", bAlternateSetting); - printf("(%i elements, ", dwNbElements); - printf("total size = %i)\n", - quad2uint((unsigned char *)targetprefix + 266)); - if (bAlternateSetting != dif->altsetting) - printf("Warning: Image does not match current alternate" - " setting.\n" - "Please rerun with the correct -a option setting" - " to download this image!\n"); - for (element = 1; element <= dwNbElements; element++) { - printf("parsing element %i, ", element); - dfuse_memcpy(elementheader, &data, &rem, sizeof(elementheader)); - dwElementAddress = - quad2uint((unsigned char *)elementheader); - dwElementSize = - quad2uint((unsigned char *)elementheader + 4); - printf("address = 0x%08x, ", dwElementAddress); - printf("size = %i\n", dwElementSize); - - if (!bFirstAddressSaved) { - bFirstAddressSaved = 1; - dfuse_address = dwElementAddress; - } - /* sanity check */ - if ((int)dwElementSize > rem) - errx(EX_SOFTWARE, "File too small for element size"); - - if (bAlternateSetting == dif->altsetting) { - ret = dfuse_dnload_element(dif, dwElementAddress, - dwElementSize, data, xfer_size); - } else { - ret = 0; - } - - /* advance read pointer */ - dfuse_memcpy(NULL, &data, &rem, dwElementSize); - - if (ret != 0) - return ret; - } - } - - if (rem != 0) - warnx("%d bytes leftover", rem); - - printf("done parsing DfuSe file\n"); - - return 0; -} - -int dfuse_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file, - const char *dfuse_options) -{ - int ret; - - if (dfuse_options) - dfuse_parse_options(dfuse_options); - mem_layout = parse_memory_layout((char *)dif->alt_name); - if (!mem_layout) { - errx(EX_IOERR, "Failed to parse memory layout"); - } - if (dfuse_unprotect) { - if (!dfuse_force) { - errx(EX_IOERR, "The read unprotect command " - "will erase the flash memory" - "and can only be used with force\n"); - } - dfuse_special_command(dif, 0, READ_UNPROTECT); - printf("Device disconnects, erases flash and resets now\n"); - exit(0); - } - if (dfuse_mass_erase) { - if (!dfuse_force) { - errx(EX_IOERR, "The mass erase command " - "can only be used with force"); - } - printf("Performing mass erase, this can take a moment\n"); - dfuse_special_command(dif, 0, MASS_ERASE); - } - if (dfuse_address) { - if (file->bcdDFU == 0x11a) { - errx(EX_IOERR, "This is a DfuSe file, not " - "meant for raw download"); - } - ret = dfuse_do_bin_dnload(dif, xfer_size, file, dfuse_address); - } else { - if (file->bcdDFU != 0x11a) { - warnx("Only DfuSe file version 1.1a is supported"); - errx(EX_IOERR, "(for raw binary download, use the " - "--dfuse-address option)"); - } - ret = dfuse_do_dfuse_dnload(dif, xfer_size, file); - } - free_segment_list(mem_layout); - - dfu_abort_to_idle(dif); - - if (dfuse_leave) { - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfuse_dnload_chunk(dif, NULL, 0, 2); /* Zero-size */ - } - return ret; -} diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse.h b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse.h deleted file mode 100755 index ed1108cfc..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse.h +++ /dev/null @@ -1,35 +0,0 @@ -/* This implements the ST Microsystems DFU extensions (DfuSe) - * as per the DfuSe 1.1a specification (Document UM0391) - * - * (C) 2010-2012 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFUSE_H -#define DFUSE_H - -#include "dfu.h" - -enum dfuse_command { SET_ADDRESS, ERASE_PAGE, MASS_ERASE, READ_UNPROTECT }; - -int dfuse_special_command(struct dfu_if *dif, unsigned int address, - enum dfuse_command command); -int dfuse_do_upload(struct dfu_if *dif, int xfer_size, int fd, - const char *dfuse_options); -int dfuse_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file, - const char *dfuse_options); - -#endif /* DFUSE_H */ diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse_mem.c b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse_mem.c deleted file mode 100755 index a91aacf5f..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse_mem.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Helper functions for reading the memory map of a device - * following the ST DfuSe 1.1a specification. - * - * Copyright 2011-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" -#include "dfuse_mem.h" - -int add_segment(struct memsegment **segment_list, struct memsegment segment) -{ - struct memsegment *new_element; - - new_element = dfu_malloc(sizeof(struct memsegment)); - *new_element = segment; - new_element->next = NULL; - - if (*segment_list == NULL) - /* list can be empty on first call */ - *segment_list = new_element; - else { - struct memsegment *next_element; - - /* find last element in list */ - next_element = *segment_list; - while (next_element->next != NULL) - next_element = next_element->next; - next_element->next = new_element; - } - return 0; -} - -struct memsegment *find_segment(struct memsegment *segment_list, - unsigned int address) -{ - while (segment_list != NULL) { - if (segment_list->start <= address && - segment_list->end >= address) - return segment_list; - segment_list = segment_list->next; - } - return NULL; -} - -void free_segment_list(struct memsegment *segment_list) -{ - struct memsegment *next_element; - - while (segment_list->next != NULL) { - next_element = segment_list->next; - free(segment_list); - segment_list = next_element; - } - free(segment_list); -} - -/* Parse memory map from interface descriptor string - * encoded as per ST document UM0424 section 4.3.2. - */ -struct memsegment *parse_memory_layout(char *intf_desc) -{ - - char multiplier, memtype; - unsigned int address; - int sectors, size; - char *name, *typestring; - int ret; - int count = 0; - char separator; - int scanned; - struct memsegment *segment_list = NULL; - struct memsegment segment; - - name = dfu_malloc(strlen(intf_desc)); - - ret = sscanf(intf_desc, "@%[^/]%n", name, &scanned); - if (ret < 1) { - free(name); - warnx("Could not read name, sscanf returned %d", ret); - return NULL; - } - printf("DfuSe interface name: \"%s\"\n", name); - - intf_desc += scanned; - typestring = dfu_malloc(strlen(intf_desc)); - - while (ret = sscanf(intf_desc, "/0x%x/%n", &address, &scanned), - ret > 0) { - - intf_desc += scanned; - while (ret = sscanf(intf_desc, "%d*%d%c%[^,/]%n", - §ors, &size, &multiplier, typestring, - &scanned), ret > 2) { - intf_desc += scanned; - - count++; - memtype = 0; - if (ret == 4) { - if (strlen(typestring) == 1 - && typestring[0] != '/') - memtype = typestring[0]; - else { - warnx("Parsing type identifier '%s' " - "failed for segment %i", - typestring, count); - continue; - } - } - - /* Quirk for STM32F4 devices */ - if (strcmp(name, "Device Feature") == 0) - memtype = 'e'; - - switch (multiplier) { - case 'B': - break; - case 'K': - size *= 1024; - break; - case 'M': - size *= 1024 * 1024; - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - if (!memtype) { - warnx("Non-valid multiplier '%c', " - "interpreted as type " - "identifier instead", - multiplier); - memtype = multiplier; - break; - } - /* fallthrough if memtype was already set */ - default: - warnx("Non-valid multiplier '%c', " - "assuming bytes", multiplier); - } - - if (!memtype) { - warnx("No valid type for segment %d\n", count); - continue; - } - - segment.start = address; - segment.end = address + sectors * size - 1; - segment.pagesize = size; - segment.memtype = memtype & 7; - add_segment(&segment_list, segment); - - if (verbose) - printf("Memory segment at 0x%08x %3d x %4d = " - "%5d (%s%s%s)\n", - address, sectors, size, sectors * size, - memtype & DFUSE_READABLE ? "r" : "", - memtype & DFUSE_ERASABLE ? "e" : "", - memtype & DFUSE_WRITEABLE ? "w" : ""); - - address += sectors * size; - - separator = *intf_desc; - if (separator == ',') - intf_desc += 1; - else - break; - } /* while per segment */ - - } /* while per address */ - free(name); - free(typestring); - - return segment_list; -} diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse_mem.h b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse_mem.h deleted file mode 100755 index 0181f0c16..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/dfuse_mem.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Helper functions for reading the memory map in a device - * following the ST DfuSe 1.1a specification. - * - * (C) 2011 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFUSE_MEM_H -#define DFUSE_MEM_H - -#define DFUSE_READABLE 1 -#define DFUSE_ERASABLE 2 -#define DFUSE_WRITEABLE 4 - -struct memsegment { - unsigned int start; - unsigned int end; - int pagesize; - int memtype; - struct memsegment *next; -}; - -int add_segment(struct memsegment **list, struct memsegment new_element); - -struct memsegment *find_segment(struct memsegment *list, unsigned int address); - -void free_segment_list(struct memsegment *list); - -struct memsegment *parse_memory_layout(char *intf_desc_str); - -#endif /* DFUSE_MEM_H */ diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/main.c b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/main.c deleted file mode 100755 index acaed2f08..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/main.c +++ /dev/null @@ -1,699 +0,0 @@ -/* - * dfu-util - * - * Copyright 2007-2008 by OpenMoko, Inc. - * Copyright 2013-2014 Hans Petter Selasky - * - * Written by Harald Welte - * - * Based on existing code of dfu-programmer-0.4 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "dfu_util.h" -#include "dfuse.h" -#include "quirks.h" - -#ifdef HAVE_USBPATH_H -#include -#endif - -int verbose = 0; - -struct dfu_if *dfu_root = NULL; - -int match_bus = -1; -int match_device = -1; -int match_vendor = -1; -int match_product = -1; -int match_vendor_dfu = -1; -int match_product_dfu = -1; -int match_config_index = -1; -int match_iface_index = -1; -int match_iface_alt_index = -1; -const char *match_iface_alt_name = NULL; -const char *match_serial = NULL; -const char *match_serial_dfu = NULL; - -static int parse_match_value(const char *str, int default_value) -{ - char *remainder; - int value; - - if (str == NULL) { - value = default_value; - } else if (*str == '*') { - value = -1; /* Match anything */ - } else if (*str == '-') { - value = 0x10000; /* Impossible vendor/product ID */ - } else { - value = strtoul(str, &remainder, 16); - if (remainder == str) { - value = default_value; - } - } - return value; -} - -static void parse_vendprod(const char *str) -{ - const char *comma; - const char *colon; - - /* Default to match any DFU device in runtime or DFU mode */ - match_vendor = -1; - match_product = -1; - match_vendor_dfu = -1; - match_product_dfu = -1; - - comma = strchr(str, ','); - if (comma == str) { - /* DFU mode vendor/product being specified without any runtime - * vendor/product specification, so don't match any runtime device */ - match_vendor = match_product = 0x10000; - } else { - colon = strchr(str, ':'); - if (colon != NULL) { - ++colon; - if ((comma != NULL) && (colon > comma)) { - colon = NULL; - } - } - match_vendor = parse_match_value(str, match_vendor); - match_product = parse_match_value(colon, match_product); - if (comma != NULL) { - /* Both runtime and DFU mode vendor/product specifications are - * available, so default DFU mode match components to the given - * runtime match components */ - match_vendor_dfu = match_vendor; - match_product_dfu = match_product; - } - } - if (comma != NULL) { - ++comma; - colon = strchr(comma, ':'); - if (colon != NULL) { - ++colon; - } - match_vendor_dfu = parse_match_value(comma, match_vendor_dfu); - match_product_dfu = parse_match_value(colon, match_product_dfu); - } -} - -static void parse_serial(char *str) -{ - char *comma; - - match_serial = str; - comma = strchr(str, ','); - if (comma == NULL) { - match_serial_dfu = match_serial; - } else { - *comma++ = 0; - match_serial_dfu = comma; - } - if (*match_serial == 0) match_serial = NULL; - if (*match_serial_dfu == 0) match_serial_dfu = NULL; -} - -#ifdef HAVE_USBPATH_H - -static int resolve_device_path(char *path) -{ - int res; - - res = usb_path2devnum(path); - if (res < 0) - return -EINVAL; - if (!res) - return 0; - - match_bus = atoi(path); - match_device = res; - - return 0; -} - -#else /* HAVE_USBPATH_H */ - -static int resolve_device_path(char *path) -{ - (void)path; /* Eliminate unused variable warning */ - errx(EX_SOFTWARE, "USB device paths are not supported by this dfu-util.\n"); -} - -#endif /* !HAVE_USBPATH_H */ - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-util [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -v --verbose\t\t\tPrint verbose debug statements\n" - " -l --list\t\t\tList currently attached DFU capable devices\n"); - fprintf(stderr, " -e --detach\t\t\tDetach currently attached DFU capable devices\n" - " -E --detach-delay seconds\tTime to wait before reopening a device after detach\n" - " -d --device :[,:]\n" - "\t\t\t\tSpecify Vendor/Product ID(s) of DFU device\n" - " -p --path \tSpecify path to DFU device\n" - " -c --cfg \t\tSpecify the Configuration of DFU device\n" - " -i --intf \t\tSpecify the DFU Interface number\n" - " -S --serial [,]\n" - "\t\t\t\tSpecify Serial String of DFU device\n" - " -a --alt \t\tSpecify the Altsetting of the DFU Interface\n" - "\t\t\t\tby name or by number\n"); - fprintf(stderr, " -t --transfer-size \tSpecify the number of bytes per USB Transfer\n" - " -U --upload \t\tRead firmware from device into \n" - " -Z --upload-size \tSpecify the expected upload size in bytes\n" - " -D --download \t\tWrite firmware from into device\n" - " -R --reset\t\t\tIssue USB Reset signalling once we're finished\n" - " -s --dfuse-address

\tST DfuSe mode, specify target address for\n" - "\t\t\t\traw file download or upload. Not applicable for\n" - "\t\t\t\tDfuSe file (.dfu) downloads\n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf(PACKAGE_STRING "\n\n"); - printf("Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.\n" - "Copyright 2010-2014 Tormod Volden and Stefan Schmidt\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to " PACKAGE_BUGREPORT "\n\n"); -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "verbose", 0, 0, 'v' }, - { "list", 0, 0, 'l' }, - { "detach", 0, 0, 'e' }, - { "detach-delay", 1, 0, 'E' }, - { "device", 1, 0, 'd' }, - { "path", 1, 0, 'p' }, - { "configuration", 1, 0, 'c' }, - { "cfg", 1, 0, 'c' }, - { "interface", 1, 0, 'i' }, - { "intf", 1, 0, 'i' }, - { "altsetting", 1, 0, 'a' }, - { "alt", 1, 0, 'a' }, - { "serial", 1, 0, 'S' }, - { "transfer-size", 1, 0, 't' }, - { "upload", 1, 0, 'U' }, - { "upload-size", 1, 0, 'Z' }, - { "download", 1, 0, 'D' }, - { "reset", 0, 0, 'R' }, - { "dfuse-address", 1, 0, 's' }, - { 0, 0, 0, 0 } -}; - -int main(int argc, char **argv) -{ - int expected_size = 0; - unsigned int transfer_size = 0; - enum mode mode = MODE_NONE; - struct dfu_status status; - libusb_context *ctx; - struct dfu_file file; - char *end; - int final_reset = 0; - int ret; - int dfuse_device = 0; - int fd; - const char *dfuse_options = NULL; - int detach_delay = 5; - uint16_t runtime_vendor; - uint16_t runtime_product; - - memset(&file, 0, sizeof(file)); - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVvleE:d:p:c:i:a:S:t:U:D:Rs:Z:", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - mode = MODE_VERSION; - break; - case 'v': - verbose++; - break; - case 'l': - mode = MODE_LIST; - break; - case 'e': - mode = MODE_DETACH; - match_iface_alt_index = 0; - match_iface_index = 0; - break; - case 'E': - detach_delay = atoi(optarg); - break; - case 'd': - parse_vendprod(optarg); - break; - case 'p': - /* Parse device path */ - ret = resolve_device_path(optarg); - if (ret < 0) - errx(EX_SOFTWARE, "Unable to parse '%s'", optarg); - if (!ret) - errx(EX_SOFTWARE, "Cannot find '%s'", optarg); - break; - case 'c': - /* Configuration */ - match_config_index = atoi(optarg); - break; - case 'i': - /* Interface */ - match_iface_index = atoi(optarg); - break; - case 'a': - /* Interface Alternate Setting */ - match_iface_alt_index = strtoul(optarg, &end, 0); - if (*end) { - match_iface_alt_name = optarg; - match_iface_alt_index = -1; - } - break; - case 'S': - parse_serial(optarg); - break; - case 't': - transfer_size = atoi(optarg); - break; - case 'U': - mode = MODE_UPLOAD; - file.name = optarg; - break; - case 'Z': - expected_size = atoi(optarg); - break; - case 'D': - mode = MODE_DOWNLOAD; - file.name = optarg; - break; - case 'R': - final_reset = 1; - break; - case 's': - dfuse_options = optarg; - break; - default: - help(); - break; - } - } - - print_version(); - if (mode == MODE_VERSION) { - exit(0); - } - - if (mode == MODE_NONE) { - fprintf(stderr, "You need to specify one of -D or -U\n"); - help(); - } - - if (match_config_index == 0) { - /* Handle "-c 0" (unconfigured device) as don't care */ - match_config_index = -1; - } - - if (mode == MODE_DOWNLOAD) { - dfu_load_file(&file, MAYBE_SUFFIX, MAYBE_PREFIX); - /* If the user didn't specify product and/or vendor IDs to match, - * use any IDs from the file suffix for device matching */ - if (match_vendor < 0 && file.idVendor != 0xffff) { - match_vendor = file.idVendor; - printf("Match vendor ID from file: %04x\n", match_vendor); - } - if (match_product < 0 && file.idProduct != 0xffff) { - match_product = file.idProduct; - printf("Match product ID from file: %04x\n", match_product); - } - } - - ret = libusb_init(&ctx); - if (ret) - errx(EX_IOERR, "unable to initialize libusb: %i", ret); - - if (verbose > 2) { - libusb_set_debug(ctx, 255); - } - - probe_devices(ctx); - - if (mode == MODE_LIST) { - list_dfu_interfaces(); - exit(0); - } - - if (dfu_root == NULL) { - errx(EX_IOERR, "No DFU capable USB device available"); - } else if (dfu_root->next != NULL) { - /* We cannot safely support more than one DFU capable device - * with same vendor/product ID, since during DFU we need to do - * a USB bus reset, after which the target device will get a - * new address */ - errx(EX_IOERR, "More than one DFU capable USB device found! " - "Try `--list' and specify the serial number " - "or disconnect all but one device\n"); - } - - /* We have exactly one device. Its libusb_device is now in dfu_root->dev */ - - printf("Opening DFU capable USB device...\n"); - ret = libusb_open(dfu_root->dev, &dfu_root->dev_handle); - if (ret || !dfu_root->dev_handle) - errx(EX_IOERR, "Cannot open device"); - - printf("ID %04x:%04x\n", dfu_root->vendor, dfu_root->product); - - printf("Run-time device DFU version %04x\n", - libusb_le16_to_cpu(dfu_root->func_dfu.bcdDFUVersion)); - - /* Transition from run-Time mode to DFU mode */ - if (!(dfu_root->flags & DFU_IFF_DFU)) { - int err; - /* In the 'first round' during runtime mode, there can only be one - * DFU Interface descriptor according to the DFU Spec. */ - - /* FIXME: check if the selected device really has only one */ - - runtime_vendor = dfu_root->vendor; - runtime_product = dfu_root->product; - - printf("Claiming USB DFU Runtime Interface...\n"); - if (libusb_claim_interface(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "Cannot claim interface %d", - dfu_root->interface); - } - - if (libusb_set_interface_alt_setting(dfu_root->dev_handle, dfu_root->interface, 0) < 0) { - errx(EX_IOERR, "Cannot set alt interface zero"); - } - - printf("Determining device status: "); - - err = dfu_get_status(dfu_root, &status); - if (err == LIBUSB_ERROR_PIPE) { - printf("Device does not implement get_status, assuming appIDLE\n"); - status.bStatus = DFU_STATUS_OK; - status.bwPollTimeout = 0; - status.bState = DFU_STATE_appIDLE; - status.iString = 0; - } else if (err < 0) { - errx(EX_IOERR, "error get_status"); - } else { - printf("state = %s, status = %d\n", - dfu_state_to_string(status.bState), status.bStatus); - } - milli_sleep(status.bwPollTimeout); - - switch (status.bState) { - case DFU_STATE_appIDLE: - case DFU_STATE_appDETACH: - printf("Device really in Runtime Mode, send DFU " - "detach request...\n"); - if (dfu_detach(dfu_root->dev_handle, - dfu_root->interface, 1000) < 0) { - warnx("error detaching"); - } - if (dfu_root->func_dfu.bmAttributes & USB_DFU_WILL_DETACH) { - printf("Device will detach and reattach...\n"); - } else { - printf("Resetting USB...\n"); - ret = libusb_reset_device(dfu_root->dev_handle); - if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) - errx(EX_IOERR, "error resetting " - "after detach"); - } - break; - case DFU_STATE_dfuERROR: - printf("dfuERROR, clearing status\n"); - if (dfu_clear_status(dfu_root->dev_handle, - dfu_root->interface) < 0) { - errx(EX_IOERR, "error clear_status"); - } - /* fall through */ - default: - warnx("WARNING: Runtime device already in DFU state ?!?"); - libusb_release_interface(dfu_root->dev_handle, - dfu_root->interface); - goto dfustate; - } - libusb_release_interface(dfu_root->dev_handle, - dfu_root->interface); - libusb_close(dfu_root->dev_handle); - dfu_root->dev_handle = NULL; - - if (mode == MODE_DETACH) { - libusb_exit(ctx); - exit(0); - } - - /* keeping handles open might prevent re-enumeration */ - disconnect_devices(); - - milli_sleep(detach_delay * 1000); - - /* Change match vendor and product to impossible values to force - * only DFU mode matches in the following probe */ - match_vendor = match_product = 0x10000; - - probe_devices(ctx); - - if (dfu_root == NULL) { - errx(EX_IOERR, "Lost device after RESET?"); - } else if (dfu_root->next != NULL) { - errx(EX_IOERR, "More than one DFU capable USB device found! " - "Try `--list' and specify the serial number " - "or disconnect all but one device"); - } - - /* Check for DFU mode device */ - if (!(dfu_root->flags | DFU_IFF_DFU)) - errx(EX_SOFTWARE, "Device is not in DFU mode"); - - printf("Opening DFU USB Device...\n"); - ret = libusb_open(dfu_root->dev, &dfu_root->dev_handle); - if (ret || !dfu_root->dev_handle) { - errx(EX_IOERR, "Cannot open device"); - } - } else { - /* we're already in DFU mode, so we can skip the detach/reset - * procedure */ - /* If a match vendor/product was specified, use that as the runtime - * vendor/product, otherwise use the DFU mode vendor/product */ - runtime_vendor = match_vendor < 0 ? dfu_root->vendor : match_vendor; - runtime_product = match_product < 0 ? dfu_root->product : match_product; - } - -dfustate: -#if 0 - printf("Setting Configuration %u...\n", dfu_root->configuration); - if (libusb_set_configuration(dfu_root->dev_handle, dfu_root->configuration) < 0) { - errx(EX_IOERR, "Cannot set configuration"); - } -#endif - printf("Claiming USB DFU Interface...\n"); - if (libusb_claim_interface(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "Cannot claim interface"); - } - - printf("Setting Alternate Setting #%d ...\n", dfu_root->altsetting); - if (libusb_set_interface_alt_setting(dfu_root->dev_handle, dfu_root->interface, dfu_root->altsetting) < 0) { - errx(EX_IOERR, "Cannot set alternate interface"); - } - -status_again: - printf("Determining device status: "); - if (dfu_get_status(dfu_root, &status ) < 0) { - errx(EX_IOERR, "error get_status"); - } - printf("state = %s, status = %d\n", - dfu_state_to_string(status.bState), status.bStatus); - - milli_sleep(status.bwPollTimeout); - - switch (status.bState) { - case DFU_STATE_appIDLE: - case DFU_STATE_appDETACH: - errx(EX_IOERR, "Device still in Runtime Mode!"); - break; - case DFU_STATE_dfuERROR: - printf("dfuERROR, clearing status\n"); - if (dfu_clear_status(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "error clear_status"); - } - goto status_again; - break; - case DFU_STATE_dfuDNLOAD_IDLE: - case DFU_STATE_dfuUPLOAD_IDLE: - printf("aborting previous incomplete transfer\n"); - if (dfu_abort(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "can't send DFU_ABORT"); - } - goto status_again; - break; - case DFU_STATE_dfuIDLE: - printf("dfuIDLE, continuing\n"); - break; - default: - break; - } - - if (DFU_STATUS_OK != status.bStatus ) { - printf("WARNING: DFU Status: '%s'\n", - dfu_status_to_string(status.bStatus)); - /* Clear our status & try again. */ - if (dfu_clear_status(dfu_root->dev_handle, dfu_root->interface) < 0) - errx(EX_IOERR, "USB communication error"); - if (dfu_get_status(dfu_root, &status) < 0) - errx(EX_IOERR, "USB communication error"); - if (DFU_STATUS_OK != status.bStatus) - errx(EX_SOFTWARE, "Status is not OK: %d", status.bStatus); - - milli_sleep(status.bwPollTimeout); - } - - printf("DFU mode device DFU version %04x\n", - libusb_le16_to_cpu(dfu_root->func_dfu.bcdDFUVersion)); - - if (dfu_root->func_dfu.bcdDFUVersion == libusb_cpu_to_le16(0x11a)) - dfuse_device = 1; - - /* If not overridden by the user */ - if (!transfer_size) { - transfer_size = libusb_le16_to_cpu( - dfu_root->func_dfu.wTransferSize); - if (transfer_size) { - printf("Device returned transfer size %i\n", - transfer_size); - } else { - errx(EX_IOERR, "Transfer size must be specified"); - } - } - -#ifdef HAVE_GETPAGESIZE -/* autotools lie when cross-compiling for Windows using mingw32/64 */ -#ifndef __MINGW32__ - /* limitation of Linux usbdevio */ - if ((int)transfer_size > getpagesize()) { - transfer_size = getpagesize(); - printf("Limited transfer size to %i\n", transfer_size); - } -#endif /* __MINGW32__ */ -#endif /* HAVE_GETPAGESIZE */ - - if (transfer_size < dfu_root->bMaxPacketSize0) { - transfer_size = dfu_root->bMaxPacketSize0; - printf("Adjusted transfer size to %i\n", transfer_size); - } - - switch (mode) { - case MODE_UPLOAD: - /* open for "exclusive" writing */ - fd = open(file.name, O_WRONLY | O_BINARY | O_CREAT | O_EXCL | O_TRUNC, 0666); - if (fd < 0) - err(EX_IOERR, "Cannot open file %s for writing", file.name); - - if (dfuse_device || dfuse_options) { - if (dfuse_do_upload(dfu_root, transfer_size, fd, - dfuse_options) < 0) - exit(1); - } else { - if (dfuload_do_upload(dfu_root, transfer_size, - expected_size, fd) < 0) { - exit(1); - } - } - close(fd); - break; - - case MODE_DOWNLOAD: - if (((file.idVendor != 0xffff && file.idVendor != runtime_vendor) || - (file.idProduct != 0xffff && file.idProduct != runtime_product)) && - ((file.idVendor != 0xffff && file.idVendor != dfu_root->vendor) || - (file.idProduct != 0xffff && file.idProduct != dfu_root->product))) { - errx(EX_IOERR, "Error: File ID %04x:%04x does " - "not match device (%04x:%04x or %04x:%04x)", - file.idVendor, file.idProduct, - runtime_vendor, runtime_product, - dfu_root->vendor, dfu_root->product); - } - if (dfuse_device || dfuse_options || file.bcdDFU == 0x11a) { - if (dfuse_do_dnload(dfu_root, transfer_size, &file, - dfuse_options) < 0) - exit(1); - } else { - if (dfuload_do_dnload(dfu_root, transfer_size, &file) < 0) - exit(1); - } - break; - case MODE_DETACH: - if (dfu_detach(dfu_root->dev_handle, dfu_root->interface, 1000) < 0) { - warnx("can't detach"); - } - break; - default: - errx(EX_IOERR, "Unsupported mode: %u", mode); - break; - } - - if (final_reset) { - if (dfu_detach(dfu_root->dev_handle, dfu_root->interface, 1000) < 0) { - /* Even if detach failed, just carry on to leave the - device in a known state */ - warnx("can't detach"); - } - printf("Resetting USB to switch back to runtime mode\n"); - ret = libusb_reset_device(dfu_root->dev_handle); - if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) { - errx(EX_IOERR, "error resetting after download"); - } - } - - libusb_close(dfu_root->dev_handle); - dfu_root->dev_handle = NULL; - libusb_exit(ctx); - - return (0); -} diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/portable.h b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/portable.h deleted file mode 100755 index cf8d5df38..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/portable.h +++ /dev/null @@ -1,72 +0,0 @@ - -#ifndef PORTABLE_H -#define PORTABLE_H - -#ifdef HAVE_CONFIG_H -# include "config.h" -#else -# define PACKAGE "dfu-util" -# define PACKAGE_VERSION "0.8-msvc" -# define PACKAGE_STRING "dfu-util 0.8-msvc" -# define PACKAGE_BUGREPORT "dfu-util@lists.gnumonks.org" -#endif /* HAVE_CONFIG_H */ - -#ifdef HAVE_FTRUNCATE -# include -#else -# include -#endif /* HAVE_FTRUNCATE */ - -#ifdef HAVE_NANOSLEEP -# include -# define milli_sleep(msec) do {\ - if (msec) {\ - struct timespec nanosleepDelay = { (msec) / 1000, ((msec) % 1000) * 1000000 };\ - nanosleep(&nanosleepDelay, NULL);\ - } } while (0) -#elif defined HAVE_WINDOWS_H -# define milli_sleep(msec) do {\ - if (msec) {\ - Sleep(msec);\ - } } while (0) -#else -# error "Can't get no sleep! Please report" -#endif /* HAVE_NANOSLEEP */ - -#ifdef HAVE_ERR -# include -#else -# include -# include -# define warnx(...) do {\ - fprintf(stderr, __VA_ARGS__);\ - fprintf(stderr, "\n"); } while (0) -# define errx(eval, ...) do {\ - warnx(__VA_ARGS__);\ - exit(eval); } while (0) -# define warn(...) do {\ - fprintf(stderr, "%s: ", strerror(errno));\ - warnx(__VA_ARGS__); } while (0) -# define err(eval, ...) do {\ - warn(__VA_ARGS__);\ - exit(eval); } while (0) -#endif /* HAVE_ERR */ - -#ifdef HAVE_SYSEXITS_H -# include -#else -# define EX_OK 0 /* successful termination */ -# define EX_USAGE 64 /* command line usage error */ -# define EX_SOFTWARE 70 /* internal software error */ -# define EX_IOERR 74 /* input/output error */ -#endif /* HAVE_SYSEXITS_H */ - -#ifndef O_BINARY -# define O_BINARY 0 -#endif - -#ifndef off_t -# define off_t long int -#endif - -#endif /* PORTABLE_H */ diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/prefix.c b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/prefix.c deleted file mode 100755 index be8e3faf3..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/prefix.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * dfu-prefix - * - * Copyright 2011-2012 Stefan Schmidt - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Uwe Bonnes - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -enum mode { - MODE_NONE, - MODE_ADD, - MODE_DEL, - MODE_CHECK -}; - -int verbose; - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-prefix [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -c --check \t\tCheck DFU prefix of \n" - " -D --delete \t\tDelete DFU prefix from \n" - " -a --add \t\tAdd DFU prefix to \n" - "In combination with -a:\n" - ); - fprintf(stderr, " -s --stellaris-address
Add TI Stellaris address prefix to \n" - "In combination with -D or -c:\n" - " -T --stellaris\t\tAct on TI Stellaris address prefix of \n" - "In combination with -a or -D or -c:\n" - " -L --lpc-prefix\t\tUse NXP LPC DFU prefix format\n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf("dfu-prefix (%s) %s\n\n", PACKAGE, PACKAGE_VERSION); - printf("Copyright 2011-2012 Stefan Schmidt, 2014 Uwe Bonnes\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to %s\n\n", PACKAGE_BUGREPORT); - -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "check", 1, 0, 'c' }, - { "add", 1, 0, 'a' }, - { "delete", 1, 0, 'D' }, - { "stellaris-address", 1, 0, 's' }, - { "stellaris", 0, 0, 'T' }, - { "LPC", 0, 0, 'L' }, -}; -int main(int argc, char **argv) -{ - struct dfu_file file; - enum mode mode = MODE_NONE; - enum prefix_type type = ZERO_PREFIX; - uint32_t lmdfu_flash_address = 0; - char *end; - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - print_version(); - - memset(&file, 0, sizeof(file)); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVc:a:D:p:v:d:s:TL", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - exit(0); - break; - case 'D': - file.name = optarg; - mode = MODE_DEL; - break; - case 'c': - file.name = optarg; - mode = MODE_CHECK; - break; - case 'a': - file.name = optarg; - mode = MODE_ADD; - break; - case 's': - lmdfu_flash_address = strtoul(optarg, &end, 0); - if (*end) { - errx(EX_IOERR, "Invalid lmdfu " - "address: %s", optarg); - } - /* fall-through */ - case 'T': - type = LMDFU_PREFIX; - break; - case 'L': - type = LPCDFU_UNENCRYPTED_PREFIX; - break; - default: - help(); - break; - } - } - - if (!file.name) { - fprintf(stderr, "You need to specify a filename\n"); - help(); - } - - switch(mode) { - case MODE_ADD: - if (type == ZERO_PREFIX) - errx(EX_IOERR, "Prefix type must be specified"); - dfu_load_file(&file, MAYBE_SUFFIX, NO_PREFIX); - file.lmdfu_address = lmdfu_flash_address; - file.prefix_type = type; - printf("Adding prefix to file\n"); - dfu_store_file(&file, file.size.suffix != 0, 1); - break; - - case MODE_CHECK: - dfu_load_file(&file, MAYBE_SUFFIX, MAYBE_PREFIX); - show_suffix_and_prefix(&file); - if (type > ZERO_PREFIX && file.prefix_type != type) - errx(EX_IOERR, "No prefix of requested type"); - break; - - case MODE_DEL: - dfu_load_file(&file, MAYBE_SUFFIX, NEEDS_PREFIX); - if (type > ZERO_PREFIX && file.prefix_type != type) - errx(EX_IOERR, "No prefix of requested type"); - printf("Removing prefix from file\n"); - /* if there was a suffix, rewrite it */ - dfu_store_file(&file, file.size.suffix != 0, 0); - break; - - default: - help(); - break; - } - return (0); -} diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/quirks.c b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/quirks.c deleted file mode 100755 index de394a615..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/quirks.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Simple quirk system for dfu-util - * - * Copyright 2010-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include "quirks.h" - -uint16_t get_quirks(uint16_t vendor, uint16_t product, uint16_t bcdDevice) -{ - uint16_t quirks = 0; - - /* Device returns bogus bwPollTimeout values */ - if ((vendor == VENDOR_OPENMOKO || vendor == VENDOR_FIC) && - product >= PRODUCT_FREERUNNER_FIRST && - product <= PRODUCT_FREERUNNER_LAST) - quirks |= QUIRK_POLLTIMEOUT; - - if (vendor == VENDOR_VOTI && - product == PRODUCT_OPENPCD) - quirks |= QUIRK_POLLTIMEOUT; - - /* Reports wrong DFU version in DFU descriptor */ - if (vendor == VENDOR_LEAFLABS && - product == PRODUCT_MAPLE3 && - bcdDevice == 0x0200) - quirks |= QUIRK_FORCE_DFU11; - - /* old devices(bcdDevice == 0) return bogus bwPollTimeout values */ - if (vendor == VENDOR_SIEMENS && - (product == PRODUCT_PXM40 || product == PRODUCT_PXM50) && - bcdDevice == 0) - quirks |= QUIRK_POLLTIMEOUT; - - /* M-Audio Transit returns bogus bwPollTimeout values */ - if (vendor == VENDOR_MIDIMAN && - product == PRODUCT_TRANSIT) - quirks |= QUIRK_POLLTIMEOUT; - - return (quirks); -} diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/quirks.h b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/quirks.h deleted file mode 100755 index 0e4b3ec58..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/quirks.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef DFU_QUIRKS_H -#define DFU_QUIRKS_H - -#define VENDOR_OPENMOKO 0x1d50 /* Openmoko Freerunner / GTA02 */ -#define VENDOR_FIC 0x1457 /* Openmoko Freerunner / GTA02 */ -#define VENDOR_VOTI 0x16c0 /* OpenPCD Reader */ -#define VENDOR_LEAFLABS 0x1eaf /* Maple */ -#define VENDOR_SIEMENS 0x0908 /* Siemens AG */ -#define VENDOR_MIDIMAN 0x0763 /* Midiman */ - -#define PRODUCT_FREERUNNER_FIRST 0x5117 -#define PRODUCT_FREERUNNER_LAST 0x5126 -#define PRODUCT_OPENPCD 0x076b -#define PRODUCT_MAPLE3 0x0003 /* rev 3 and 5 */ -#define PRODUCT_PXM40 0x02c4 /* Siemens AG, PXM 40 */ -#define PRODUCT_PXM50 0x02c5 /* Siemens AG, PXM 50 */ -#define PRODUCT_TRANSIT 0x2806 /* M-Audio Transit (Midiman) */ - -#define QUIRK_POLLTIMEOUT (1<<0) -#define QUIRK_FORCE_DFU11 (1<<1) - -/* Fallback value, works for OpenMoko */ -#define DEFAULT_POLLTIMEOUT 5 - -uint16_t get_quirks(uint16_t vendor, uint16_t product, uint16_t bcdDevice); - -#endif /* DFU_QUIRKS_H */ diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/suffix.c b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/suffix.c deleted file mode 100755 index 0df248f51..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/suffix.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * dfu-suffix - * - * Copyright 2011-2012 Stefan Schmidt - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -enum mode { - MODE_NONE, - MODE_ADD, - MODE_DEL, - MODE_CHECK -}; - -int verbose; - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-suffix [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -c --check \t\tCheck DFU suffix of \n" - " -a --add \t\tAdd DFU suffix to \n" - " -D --delete \t\tDelete DFU suffix from \n" - " -p --pid \t\tAdd product ID into DFU suffix in \n" - " -v --vid \t\tAdd vendor ID into DFU suffix in \n" - " -d --did \t\tAdd device ID into DFU suffix in \n" - " -S --spec \t\tAdd DFU specification ID into DFU suffix in \n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf("dfu-suffix (%s) %s\n\n", PACKAGE, PACKAGE_VERSION); - printf("Copyright 2011-2012 Stefan Schmidt, 2013-2014 Tormod Volden\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to %s\n\n", PACKAGE_BUGREPORT); - -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "check", 1, 0, 'c' }, - { "add", 1, 0, 'a' }, - { "delete", 1, 0, 'D' }, - { "pid", 1, 0, 'p' }, - { "vid", 1, 0, 'v' }, - { "did", 1, 0, 'd' }, - { "spec", 1, 0, 'S' }, -}; - -int main(int argc, char **argv) -{ - struct dfu_file file; - int pid, vid, did, spec; - enum mode mode = MODE_NONE; - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - print_version(); - - pid = vid = did = 0xffff; - spec = 0x0100; /* Default to bcdDFU version 1.0 */ - memset(&file, 0, sizeof(file)); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVc:a:D:p:v:d:S:s:T", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - exit(0); - break; - case 'D': - file.name = optarg; - mode = MODE_DEL; - break; - case 'p': - pid = strtol(optarg, NULL, 16); - break; - case 'v': - vid = strtol(optarg, NULL, 16); - break; - case 'd': - did = strtol(optarg, NULL, 16); - break; - case 'S': - spec = strtol(optarg, NULL, 16); - break; - case 'c': - file.name = optarg; - mode = MODE_CHECK; - break; - case 'a': - file.name = optarg; - mode = MODE_ADD; - break; - default: - help(); - break; - } - } - - if (!file.name) { - fprintf(stderr, "You need to specify a filename\n"); - help(); - } - - if (spec != 0x0100 && spec != 0x011a) { - fprintf(stderr, "Only DFU specification 0x0100 and 0x011a supported\n"); - help(); - } - - switch(mode) { - case MODE_ADD: - dfu_load_file(&file, NO_SUFFIX, MAYBE_PREFIX); - file.idVendor = vid; - file.idProduct = pid; - file.bcdDevice = did; - file.bcdDFU = spec; - /* always write suffix, rewrite prefix if there was one */ - dfu_store_file(&file, 1, file.size.prefix != 0); - printf("Suffix successfully added to file\n"); - break; - - case MODE_CHECK: - dfu_load_file(&file, NEEDS_SUFFIX, MAYBE_PREFIX); - show_suffix_and_prefix(&file); - break; - - case MODE_DEL: - dfu_load_file(&file, NEEDS_SUFFIX, MAYBE_PREFIX); - dfu_store_file(&file, 0, file.size.prefix != 0); - if (file.size.suffix) /* had a suffix */ - printf("Suffix successfully removed from file\n"); - break; - - default: - help(); - break; - } - return (0); -} diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/usb_dfu.h b/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/usb_dfu.h deleted file mode 100755 index 660bedcbf..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/src/usb_dfu.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef USB_DFU_H -#define USB_DFU_H -/* USB Device Firmware Update Implementation for OpenPCD - * (C) 2006 by Harald Welte - * - * Protocol definitions for USB DFU - * - * This ought to be compliant to the USB DFU Spec 1.0 as available from - * http://www.usb.org/developers/devclass_docs/usbdfu10.pdf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define USB_DT_DFU 0x21 - -#ifdef _MSC_VER -# pragma pack(push) -# pragma pack(1) -#endif /* _MSC_VER */ -struct usb_dfu_func_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bmAttributes; -#define USB_DFU_CAN_DOWNLOAD (1 << 0) -#define USB_DFU_CAN_UPLOAD (1 << 1) -#define USB_DFU_MANIFEST_TOL (1 << 2) -#define USB_DFU_WILL_DETACH (1 << 3) - uint16_t wDetachTimeOut; - uint16_t wTransferSize; - uint16_t bcdDFUVersion; -#ifdef _MSC_VER -}; -# pragma pack(pop) -#elif defined __GNUC__ -} __attribute__ ((packed)); -#else - #warning "No way to pack struct on this compiler? This will break!" -#endif /* _MSC_VER */ - -#define USB_DT_DFU_SIZE 9 - -#define USB_TYPE_DFU (LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE) - -/* DFU class-specific requests (Section 3, DFU Rev 1.1) */ -#define USB_REQ_DFU_DETACH 0x00 -#define USB_REQ_DFU_DNLOAD 0x01 -#define USB_REQ_DFU_UPLOAD 0x02 -#define USB_REQ_DFU_GETSTATUS 0x03 -#define USB_REQ_DFU_CLRSTATUS 0x04 -#define USB_REQ_DFU_GETSTATE 0x05 -#define USB_REQ_DFU_ABORT 0x06 - -/* DFU_GETSTATUS bStatus values (Section 6.1.2, DFU Rev 1.1) */ -#define DFU_STATUS_OK 0x00 -#define DFU_STATUS_errTARGET 0x01 -#define DFU_STATUS_errFILE 0x02 -#define DFU_STATUS_errWRITE 0x03 -#define DFU_STATUS_errERASE 0x04 -#define DFU_STATUS_errCHECK_ERASED 0x05 -#define DFU_STATUS_errPROG 0x06 -#define DFU_STATUS_errVERIFY 0x07 -#define DFU_STATUS_errADDRESS 0x08 -#define DFU_STATUS_errNOTDONE 0x09 -#define DFU_STATUS_errFIRMWARE 0x0a -#define DFU_STATUS_errVENDOR 0x0b -#define DFU_STATUS_errUSBR 0x0c -#define DFU_STATUS_errPOR 0x0d -#define DFU_STATUS_errUNKNOWN 0x0e -#define DFU_STATUS_errSTALLEDPKT 0x0f - -enum dfu_state { - DFU_STATE_appIDLE = 0, - DFU_STATE_appDETACH = 1, - DFU_STATE_dfuIDLE = 2, - DFU_STATE_dfuDNLOAD_SYNC = 3, - DFU_STATE_dfuDNBUSY = 4, - DFU_STATE_dfuDNLOAD_IDLE = 5, - DFU_STATE_dfuMANIFEST_SYNC = 6, - DFU_STATE_dfuMANIFEST = 7, - DFU_STATE_dfuMANIFEST_WAIT_RST = 8, - DFU_STATE_dfuUPLOAD_IDLE = 9, - DFU_STATE_dfuERROR = 10 -}; - -#endif /* USB_DFU_H */ diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/build.html b/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/build.html deleted file mode 100755 index f3036e40c..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/build.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - Building dfu-util from source - - - - - - - - - -
-

How to build dfu-util from source

- -

Prerequisites for building from git

-

Mac OS X

-

-First install MacPorts (and if you are on 10.6 or older, the Java Developer Package) and then run: -

-
-	sudo port install libusb-devel git-core
-
- -

FreeBSD

-
-	sudo pkg_add -r git pkgconf
-
- -

Ubuntu and Debian and derivatives

-
-	sudo apt-get build-dep dfu-util
-	sudo apt-get install libusb-1.0-0-dev
-
- -

Get the source code and build it

-

-The first time you will have to clone the git repository: -

-
-	git clone git://gitorious.org/dfu-util/dfu-util.git
-	cd dfu-util
-
-

-If you later want to update to latest git version, just run this: -

-
-	make maintainer-clean
-	git pull
-
-

-To build the source: -

-
-	./autogen.sh
-	./configure  # on most systems
-	make
-
- -

-If you are building on Mac OS X, replace the ./configure command with: -

-
-	./configure --libdir=/opt/local/lib --includedir=/opt/local/include  # on MacOSX only
-
- -

-Your dfu-util binary will be inside the src folder. Use it from there, or install it to /usr/local/bin by running "sudo make install". -

- -

Cross-building for Windows

- -

-Windows binaries can be built in a MinGW -environment, on a Windows computer or cross-hosted in another OS. -To build it on a Debian or Ubuntu host, first install build dependencies: -

-
-	sudo apt-get build-dep libusb-1.0-0 dfu-util
-	sudo apt-get install mingw32
-
- -

-The below example builds dfu-util 0.8 and libusb 1.0.19 from unpacked release -tarballs. If you instead build from git, you will have to run "./autogen.sh" -before running the "./configure" steps. -

- -
-mkdir -p build
-cd libusb-1.0.19
-PKG_CONFIG_PATH=$PWD/../build/lib/pkgconfig ./configure \
-    --host=i586-mingw32msvc --prefix=$PWD/../build
-# WINVER workaround needed for 1.0.19 only
-make CFLAGS="-DWINVER=0x0501"
-make install
-cd ..
-
-cd dfu-util-0.8
-PKG_CONFIG_PATH=$PWD/../build/lib/pkgconfig ./configure \
-    --host=i586-mingw32msvc --prefix=$PWD/../build
-make
-make install
-cd ..
-
-The build files will now be in build/bin. -

- -

Building on Windows using MinGW

-This assumes using release tarballs or having run ./autogen.sh on -the git sources. -
-cd libusb-1.0.19
-./configure --prefix=$HOME
-# WINVER workaround needed for 1.0.19 only
-# MKDIR_P setting should not really be needed...
-make CFLAGS="-DWINVER=0x0501" MKDIR_P="mkdir -p"
-make install
-cd ..
-
-cd dfu-util-0.8
-./configure USB_CFLAGS="-I$HOME/include/libusb-1.0" \
-            USB_LIBS="-L $HOME/lib -lusb-1.0" PKG_CONFIG=true
-make
-make install
-cd ..
-
-To link libusb statically into dfu-util.exe use instead of "make": -
-make LDFLAGS=-static
-
-The built executables (and DLL) will now be under $HOME/bin. - -

-[Back to dfu-util main page] -

- -
- - diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/dfu-util.1.html b/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/dfu-util.1.html deleted file mode 100755 index 62ca40b5d..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/dfu-util.1.html +++ /dev/null @@ -1,411 +0,0 @@ - - -Man page of DFU-UTIL - - -

DFU-UTIL(1)

- -  -

NAME

- -dfu-util - Device firmware update (DFU) USB programmer -  -

SYNOPSIS

- - -
-
-dfu-util - --l - -[-v] - -[-d - -vid:pid[,vid:pid]] - -[-p - -path] - -[-c - -configuration] - -[-i - -interface] - -[-a - -alt-intf] - -[-S - -serial[,serial]] - - -
-dfu-util - -[-v] - -[-d - -vid:pid[,vid:pid]] - -[-p - -path] - -[-c - -configuration] - -[-i - -interface] - -[-a - -alt-intf] - -[-S - -serial[,serial]] - -[-t - -size] - -[-Z - -size] - -[-s - -address] - -[-R] - -[-D|-U - -file] - - -
-dfu-util - -[-hV] - -
-  -

DESCRIPTION

- -dfu-util - -is a program that implements the host (computer) side of the USB DFU -(Universal Serial Bus Device Firmware Upgrade) protocol. -

-dfu-util communicates with devices that implement the device side of the -USB DFU protocol, and is often used to upgrade the firmware of such -devices. -  -

OPTIONS

- -
-
-l, --list - -
-List the currently attached DFU capable USB devices. -
-d, --device [Run-Time VENDOR]:[Run-Time PRODUCT][,[DFU Mode VENDOR]:[DFU Mode PRODUCT]] - -
-
-Specify run-time and/or DFU mode vendor and/or product IDs of the DFU device -to work with. VENDOR and PRODUCT are hexadecimal numbers (no prefix -needed), "*" (match any), or "-" (match nothing). By default, any DFU capable -device in either run-time or DFU mode will be considered. -

-If you only have one standards-compliant DFU device attached to your computer, -this parameter is optional. However, as soon as you have multiple DFU devices -connected, dfu-util will detect this and abort, asking you to specify which -device to use. -

-If only run-time IDs are specified (e.g. "--device 1457:51ab"), then in -addition to the specified run-time IDs, any DFU mode devices will also be -considered. This is beneficial to allow a DFU capable device to be found -again after a switch to DFU mode, since the vendor and/or product ID of a -device usually changes in DFU mode. -

-If only DFU mode IDs are specified (e.g. "--device ,951:26"), then all -run-time devices will be ignored, making it easy to target a specific device in -DFU mode. -

-If both run-time and DFU mode IDs are specified (e.g. "--device -1457:51ab,:2bc"), then unspecified DFU mode components will use the run-time -value specified. -

-Examples: -

-
--device 1457:51ab,951:26 - -
-
- -Work with a device in run-time mode with -vendor ID 0x1457 and product ID 0x51ab, or in DFU mode with vendor ID 0x0951 -and product ID 0x0026 -

-

--device 1457:51ab,:2bc - -
-
- -Work with a device in run-time mode with vendor ID 0x1457 and product ID -0x51ab, or in DFU mode with vendor ID 0x1457 and product ID 0x02bc -

-

--device 1457:51ab - -
-
- -Work with a device in run-time mode with vendor ID 0x1457 and product ID -0x51ab, or in DFU mode with any vendor and product ID -

-

--device ,951:26 - -
-
- -Work with a device in DFU mode with vendor ID 0x0951 and product ID 0x0026 -

-

--device *,- - -
-
- -Work with any device in run-time mode, and ignore any device in DFU mode -

-

--device , - -
-
- -Ignore any device in run-time mode, and Work with any device in DFU mode -
-
- -
-p, --path BUS-PORT. ... .PORT - -
-Specify the path to the DFU device. -
-c, --cfg CONFIG-NR - -
-Specify the configuration of the DFU device. Note that this is only used for matching, the configuration is not set by dfu-util. -
-i, --intf INTF-NR - -
-Specify the DFU interface number. -
-a, --alt ALT - -
-Specify the altsetting of the DFU interface by name or by number. -
-S, --serial [Run-Time SERIAL][,[DFU Mode SERIAL]] - -
-Specify the run-time and DFU mode serial numbers used to further restrict -device matches. If multiple, identical DFU devices are simultaneously -connected to a system then vendor and product ID will be insufficient for -targeting a single device. In this situation, it may be possible to use this -parameter to specify a serial number which also must match. -

-If only a single serial number is specified, then the same serial number is -used in both run-time and DFU mode. An empty serial number will match any -serial number in the corresponding mode. -

-t, --transfer-size SIZE - -
-Specify the number of bytes per USB transfer. The optimal value is -usually determined automatically so this option is rarely useful. If -you need to use this option for a device, please report it as a bug. -
-Z, --upload-size SIZE - -
-Specify the expected upload size, in bytes. -
-U, --upload FILE - -
-Read firmware from device into -FILE. - -
-D, --download FILE - -
-Write firmware from -FILE - -into device. -
-R, --reset - -
-Issue USB reset signalling after upload or download has finished. -
-s, --dfuse-address address - -
-Specify target address for raw binary download/upload on DfuSe devices. Do -not - -use this for downloading DfuSe (.dfu) files. Modifiers can be added -to the address, separated by a colon, to perform special DfuSE commands such -as "leave" DFU mode, "unprotect" and "mass-erase" flash memory. -
-v, --verbose - -
-Print more information about dfu-util's operation. A second --v - -will turn on verbose logging of USB requests. Repeat this option to further -increase verbosity. -
-h, --help - -
-Show a help text and exit. -
-V, --version - -
-Show version information and exit. -
-  -

EXAMPLES

- -  -

Using dfu-util in the OpenMoko project

- -(with the Neo1973 hardware) -

- -Flashing the rootfs: -
- - $ dfu-util -a rootfs -R -D /path/to/openmoko-devel-image.jffs2 - -

- -Flashing the kernel: -
- - $ dfu-util -a kernel -R -D /path/to/uImage - -

- -Flashing the bootloader: -
- - $ dfu-util -a u-boot -R -D /path/to/u-boot.bin - -

- -Copying a kernel into RAM: -
- - $ dfu-util -a 0 -R -D /path/to/uImage - -

-Once this has finished, the kernel will be available at the default load -address of 0x32000000 in Neo1973 RAM. -Note: - -You cannot transfer more than 2MB of data into RAM using this method. -

-  -

Using dfu-util with a DfuSe device

- -

- -Flashing a -.dfu - -(special DfuSe format) file to the device: -
- - $ dfu-util -a 0 -D /path/to/dfuse-image.dfu - -

- -Reading out 1 KB of flash starting at address 0x8000000: -
- - $ dfu-util -a 0 -s 0x08000000:1024 -U newfile.bin - -

- -Flashing a binary file to address 0x8004000 of device memory and -ask the device to leave DFU mode: -
- - $ dfu-util -a 0 -s 0x08004000:leave -D /path/to/image.bin - - -  -

BUGS

- -Please report any bugs to the dfu-util mailing list at -dfu-util@lists.gnumonks.org. - -Please use the ---verbose option (repeated as necessary) to provide more - -information in your bug report. -  -

SEE ALSO

- -The dfu-util home page is -http://dfu-util.gnumonks.org - -  -

HISTORY

- -dfu-util was originally written for the OpenMoko project by -Weston Schmidt <weston_schmidt@yahoo.com> and -Harald Welte <hwelte@hmw-consulting.de>. Over time, nearly complete -support of DFU 1.0, DFU 1.1 and DfuSe ("1.1a") has been added. -  -

LICENCE

- -dfu-util - -is covered by the GNU General Public License (GPL), version 2 or later. -  -

COPYRIGHT

- -This manual page was originally written by Uwe Hermann <uwe@hermann-uwe.de>, -and is now part of the dfu-util project. -

- -


- 

Index

-
-
NAME
-
SYNOPSIS
-
DESCRIPTION
-
OPTIONS
-
EXAMPLES
-
-
Using dfu-util in the OpenMoko project
-
Using dfu-util with a DfuSe device
-
-
BUGS
-
SEE ALSO
-
HISTORY
-
LICENCE
-
COPYRIGHT
-
-
-This document was created by man2html, -using the doc/dfu-util.1 manual page from dfu-util 0.8.
-Time: 14:40:57 GMT, September 13, 2014 - - diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/dfuse.html b/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/dfuse.html deleted file mode 100755 index 35e4ffa9f..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/dfuse.html +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - DfuSe and dfu-util - - - - - - - - - -
-

Using dfu-util with DfuSe devices

-

DfuSe

-

- DfuSe (DFU with ST Microsystems extensions) is a protocol based on - DFU 1.1. However, in expanding the functionality of the DFU protocol, - ST Microsystems broke all compatibility with the DFU 1.1 standard. - DfuSe devices report the DFU version as "1.1a". -

-

- DfuSe can be used to download firmware and other data - from a host computer to a conforming device (or upload in the - opposite direction) over USB similar to standard DFU. -

-

- The main difference from standard DFU is that the target address in - the device (flash) memory is specified by the host, so that a - download can be performed to parts of the device memory. The host - program is also responsible for erasing flash pages before they - are written to. -

-

.dfu files

-

- A special file format is defined by ST Microsystems to carry firmware - for DfuSe devices. The file contains target information such as address - and alternate interface information in addition to the binary data. - Several blocks of binary data can be combined in one .dfu file. -

-

Alternate interfaces

-

- Different memory locations of the device may have different - characteristics that the host program (dfu-util) has to take - into considerations, such as flash memory page size, read-only - versus read-write segments, the need to erase, and so on. - These parameters are reported by the device in the string - descriptors meant for describing the USB interfaces. - The host program decodes these strings to build a memory map of - the device. Different memory units or address spaces are listed - in separate alternate interface settings that must be selected - according to the memory unit to access. -

-

- Note that dfu-util leaves it to the user to select alternate - interface. When parsing a .dfu file it will skip file segments - not matching the selected alternate interface. Also, some - DfuSe device firmware implementations ignore the setting of - alternate interface and deduct the memory unit from the - address, since they have no address space overlap. -

-

DfuSe special commands

-

- DfuSe special commands are used by the host program during normal - downloads or uploads, such as SET_ADDRESS and ERASE_PAGE. Also - the normal DFU_DNLOAD and DFU_UPLOAD commands have special - implementations in DfuSe. - Many DfuSe devices also support commands to leave DFU mode, - read unprotect the flash memory or mass erase the flash memory. - dfu-util (from version 0.7) - supports adding "leave", "unprotect", or "mass-erase" - to the -s option argument to send such requests in combination - with a download request. These modifiers are separated with a colon. -

-

- Some DfuSe devices have their DfuSe bootloader running from flash - memory. Erasing the whole flash memory would therefore destroy - the DfuSe bootloader itself and practically brick the device - for most users. Any use of modifiers such as "unprotect" - and "mass-erase" therefore needs to be combined with the "force" - modifer. This is not included in the examples, to not encourage - ignorant users to copy and paste such instructions and shoot - themselves in the foot. -

-

- Devices based on for instance STM32F103 all run the bootloader - from flash, since there is no USB bootloader in ROM. -

-

- For instance STM32F107, STM32F2xx and STM32F4xx devices have a - DfuSe bootloader in ROM, so the flash can be erased while - keeping the device available for USB DFU transfers as long - as the device designers use this built-in bootloader and have - not implemented another DfuSe bootloader in flash that the user is - dependent upon. -

-

- Well-written bootloaders running from flash will report their - own memory region as read-only and not eraseable, but this does - not prevent dfu-util from sending a "unprotect" or "mass-erase" - request which overrides this, if the user insists. -

-

Example usage

-

- Flashing a .dfu (special DfuSe format) file to the device: -

-
-         $ dfu-util -a 0 -D /path/to/dfuse-image.dfu
-	
-

- Reading out 1 KB of flash starting at address 0x8000000: -

-
-         $ dfu-util -a 0 -s 0x08000000:1024 -U newfile.bin
-	
-

- Flashing a binary file to address 0x8004000 of device memory and ask - the device to leave DFU mode: -

-
-         $ dfu-util -a 0 -s 0x08004000:leave -D /path/to/image.bin
-	
-

- [Back to dfu-util main page] -

- -
- - diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/index.html b/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/index.html deleted file mode 100755 index 108ddaf66..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/index.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - dfu-util Homepage - - - - - - - - - -
-

dfu-util - Device Firmware Upgrade Utilities

-

Description

-

- dfu-util is a host side implementation of the DFU 1.0 and DFU 1.1 specifications of the USB forum. - - DFU is intended to download and upload firmware to/from devices connected - over USB. It ranges from small devices like micro-controller boards - to mobile phones. Using dfu-util you can download firmware to your - DFU-enabled device or upload firmware from it. dfu-util has been - tested with the Openmoko Neo1973 and Freerunner and many other devices. -

-

- See the manual page for examples of use. -

-

Supported Devices

- -

Releases

-

- Releases of the dfu-util software can be found in the - releases folder. - The current release is 0.8. -

-

- We offer binaries for Microsoft Windows and some other platforms. - dfu-util uses libusb 1.0 to access your device, so - on Windows you have to register the device with the WinUSB driver - (alternatively libusb-win32 or libusbK), please see the libusbx wiki - for more details. -

-

- Mac OS X users can also get dfu-util from Homebrew with "brew install dfu-util" or from MacPorts. -

-

- Most Linux distributions ship dfu-util in binary packages for those - who do not want to compile dfu-util from source. - On Debian, Ubuntu, Fedora and Gentoo you can install it through the - normal software package tools. For other distributions -(namely OpenSuSe, Mandriva, and CentOS) Holger Freyther was kind enough to -provide binary packages through the Open Build Service. -

-

Development

-

- Development happens in a GIT repository. Browse it via the web -interface or clone it with: -

-
-	git clone git://gitorious.org/dfu-util/dfu-util.git
-	
-

- See our build instructions for how to - build the source on different platforms. -

-

License

-

- This software is licensed under the GPL version 2. -

-

Contact

-

- If you have questions about the development or use of dfu-util please - send an e-mail to our dedicated -mailing list for dfu-util. -

-

People

-

- dfu-util was originally written by - Harald Welte partially based on code from - dfu-programmer 0.4 and is currently maintained by Stefan Schmidt and - Tormod Volden. -

- -
- - diff --git a/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/simple.css b/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/simple.css deleted file mode 100755 index 98100bc5c..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/dfu-util/www/simple.css +++ /dev/null @@ -1,56 +0,0 @@ -body { - margin: 10px; - font-size: 0.82em; - background-color: #EEE; -} - -h1 { - clear: both; - padding: 0 0 12px 0; - margin: 0; - font-size: 2em; - font-weight: bold; -} - -h2 { - clear: both; - margin: 0; - font-size: 1.5em; - font-weight: normal; -} - -h3 { - clear: both; - margin: 15px 0 0 0; - font-size: 1.0em; - font-weight: bold; -} - -p { - line-height: 20px; - padding: 8px 0 8px 0; - margin: 0; - font-size: 1.1em; -} - -pre { - white-space: pre-wrap; - background-color: #CCC; - padding: 3px; -} - -a:hover { - background-color: #DDD; -} - -#middlebox { - width: 600px; - margin: 0px auto; - text-align: left; -} - -#footer { - height: 100px; - padding: 28px 3px 0 0; - margin: 20px 0 20px 0; -} diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/README.md b/arduino/opencr_arduino/tools/macosx/src/maple_loader/README.md deleted file mode 100755 index c6c937950..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/README.md +++ /dev/null @@ -1,5 +0,0 @@ -These files build the maple_loader.jar file used on Windows to reset the Sketch via USB Serial, so that the bootloader will run in dfu upload mode, ready for a new sketch to be uploaded - -The files were written by @bobC (github) and have been slightly modified by me (Roger Clark), so that dfu-util no longer attempts to reset the board after upload. -This change to dfu-util's reset command line argument, was required because dfu-util was showing errors on some Windows systems, because the bootloader had reset its self after upload, -before dfu-util had chance to tell it to reset. \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build.xml b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build.xml deleted file mode 100755 index 80bdd6fdb..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project maple_loader. - - - diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/built-jar.properties b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/built-jar.properties deleted file mode 100755 index 10752d534..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/built-jar.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Mon, 20 Jul 2015 11:21:26 +1000 - - -C\:\\Users\\rclark\\Desktop\\maple-asp-master\\installer\\maple_loader= diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/CliTemplate/CliMain.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/CliTemplate/CliMain.class deleted file mode 100755 index 37ee63000..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/CliTemplate/CliMain.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/CliTemplate/DFUUploader.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/CliTemplate/DFUUploader.class deleted file mode 100755 index 77087b052..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/CliTemplate/DFUUploader.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/CliTemplate/ExecCommand.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/CliTemplate/ExecCommand.class deleted file mode 100755 index ad95f7984..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/CliTemplate/ExecCommand.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/Base.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/Base.class deleted file mode 100755 index 4aa0bde02..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/Base.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/Preferences.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/Preferences.class deleted file mode 100755 index 89cf01004..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/Preferences.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/Serial.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/Serial.class deleted file mode 100755 index cceccdd27..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/Serial.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/SerialException.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/SerialException.class deleted file mode 100755 index 71048dd3a..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/SerialException.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class deleted file mode 100755 index 37250e770..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class deleted file mode 100755 index e22c8d499..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/debug/RunnerException.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/debug/RunnerException.class deleted file mode 100755 index 710f79650..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/debug/RunnerException.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class b/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class deleted file mode 100755 index 27eca6262..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/dist/README.TXT b/arduino/opencr_arduino/tools/macosx/src/maple_loader/dist/README.TXT deleted file mode 100755 index 255b89c68..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/dist/README.TXT +++ /dev/null @@ -1,32 +0,0 @@ -======================== -BUILD OUTPUT DESCRIPTION -======================== - -When you build an Java application project that has a main class, the IDE -automatically copies all of the JAR -files on the projects classpath to your projects dist/lib folder. The IDE -also adds each of the JAR files to the Class-Path element in the application -JAR files manifest file (MANIFEST.MF). - -To run the project from the command line, go to the dist folder and -type the following: - -java -jar "maple_loader.jar" - -To distribute this project, zip up the dist folder (including the lib folder) -and distribute the ZIP file. - -Notes: - -* If two JAR files on the project classpath have the same name, only the first -JAR file is copied to the lib folder. -* Only JAR files are copied to the lib folder. -If the classpath contains other types of files or folders, these files (folders) -are not copied. -* If a library on the projects classpath also has a Class-Path element -specified in the manifest,the content of the Class-Path element has to be on -the projects runtime path. -* To set a main class in a standard Java project, right-click the project node -in the Projects window and choose Properties. Then click Run and enter the -class name in the Main Class field. Alternatively, you can manually type the -class name in the manifest Main-Class element. diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/dist/lib/jssc.jar b/arduino/opencr_arduino/tools/macosx/src/maple_loader/dist/lib/jssc.jar deleted file mode 100755 index eb74f154a..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/dist/lib/jssc.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/dist/maple_loader.jar b/arduino/opencr_arduino/tools/macosx/src/maple_loader/dist/maple_loader.jar deleted file mode 100755 index e1f9965c1..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/dist/maple_loader.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/jars/jssc.jar b/arduino/opencr_arduino/tools/macosx/src/maple_loader/jars/jssc.jar deleted file mode 100755 index eb74f154a..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/src/maple_loader/jars/jssc.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/manifest.mf b/arduino/opencr_arduino/tools/macosx/src/maple_loader/manifest.mf deleted file mode 100755 index 328e8e5bc..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/build-impl.xml b/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/build-impl.xml deleted file mode 100755 index a66f34964..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/build-impl.xml +++ /dev/null @@ -1,1413 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/genfiles.properties b/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/genfiles.properties deleted file mode 100755 index c13672132..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=2e6a03ba -build.xml.script.CRC32=4676ee6b -build.xml.stylesheet.CRC32=8064a381@1.75.2.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=2e6a03ba -nbproject/build-impl.xml.script.CRC32=392b3f79 -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/private/config.properties b/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/private/config.properties deleted file mode 100755 index e69de29bb..000000000 diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/private/private.properties b/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/private/private.properties deleted file mode 100755 index e5c9f10c4..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/private/private.properties +++ /dev/null @@ -1,6 +0,0 @@ -compile.on.save=true -do.depend=false -do.jar=true -javac.debug=true -javadoc.preview=true -user.properties.file=C:\\Users\\rclark\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/private/private.xml b/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/private/private.xml deleted file mode 100755 index a1bbd60c9..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/private/private.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - file:/C:/Users/rclark/Desktop/maple-asp-master/installer/maple_loader/src/CliTemplate/CliMain.java - file:/C:/Users/rclark/Desktop/maple-asp-master/installer/maple_loader/src/CliTemplate/DFUUploader.java - - - diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/project.properties b/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/project.properties deleted file mode 100755 index 7f48d719f..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/project.properties +++ /dev/null @@ -1,79 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=maple_loader -application.vendor=bob -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/maple_loader.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.jssc.jar=dist/lib/jssc.jar -file.reference.jssc.jar-1=jars/jssc.jar -includes=** -jar.compress=false -javac.classpath=\ - ${file.reference.jssc.jar}:\ - ${file.reference.jssc.jar-1} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.7 -javac.target=1.7 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=CliTemplate.CliMain -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/project.xml b/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/project.xml deleted file mode 100755 index 92218a925..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/nbproject/project.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - maple_loader - - - - - - - - - diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/CliTemplate/CliMain.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/CliTemplate/CliMain.java deleted file mode 100755 index c7dc9f098..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/CliTemplate/CliMain.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package CliTemplate; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import processing.app.Preferences; - -//import processing.app.I18n; -import processing.app.helpers.ProcessUtils; - -/** - * - * @author cousinr - */ -public class CliMain { - - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - - String comPort = args[0]; // - String altIf = args[1]; // - String usbID = args[2]; // "1EAF:0003"; - String binFile = args[3]; // bin file - - System.out.println("maple_loader v0.1"); - - Preferences.set ("serial.port",comPort); - Preferences.set ("serial.parity","N"); - Preferences.setInteger ("serial.databits", 8); - Preferences.setInteger ("serial.debug_rate",9600); - Preferences.setInteger ("serial.stopbits",1); - - Preferences.setInteger ("programDelay",1200); - - Preferences.set ("upload.usbID", usbID); - Preferences.set ("upload.altID", altIf); - Preferences.setBoolean ("upload.auto_reset", true); - Preferences.setBoolean ("upload.verbose", false); - - // - DFUUploader dfuUploader = new DFUUploader(); - try { - //dfuUploader.uploadViaDFU(binFile); - dfuUploader.uploadViaDFU(binFile); - } catch (Exception e) - { - System.err.print (MessageFormat.format("an error occurred! {0}\n", e.getMessage())); - } - } -} diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/CliTemplate/DFUUploader.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/CliTemplate/DFUUploader.java deleted file mode 100755 index 3dee0b4b7..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/CliTemplate/DFUUploader.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - DFUUploader - uploader implementation using DFU - - Copyright (c) 2010 - Andrew Meyer - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - -package CliTemplate; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import processing.app.Preferences; -import processing.app.Serial; -import processing.app.debug.MessageConsumer; -import processing.app.debug.MessageSiphon; -import processing.app.debug.RunnerException; - -/** - * - * @author bob - */ -public class DFUUploader implements MessageConsumer { - - boolean firstErrorFound; - boolean secondErrorFound; - // part of the PdeMessageConsumer interface - boolean notFoundError; - boolean verbose; - RunnerException exception; - - static final String SUPER_BADNESS = - "Compiler error!"; - - public boolean uploadUsingPreferences(String binPath, boolean verbose) - throws RunnerException { - - this.verbose = verbose; - - return uploadViaDFU(binPath); - } - - // works with old and new versions of dfu-util - private boolean found_device (String dfuData, String usbID) - { - return dfuData.contains(("Found DFU: [0x"+usbID.substring(0,4)).toUpperCase()) || - dfuData.contains(("Found DFU: ["+usbID.substring(0,4)).toUpperCase()); - } - - public boolean uploadViaDFU (String binPath) - throws RunnerException { - - this.verbose = Preferences.getBoolean ("upload.verbose"); - - /* todo, check for size overruns! */ - String fileType="bin"; - - if (fileType.equals("bin")) { - String usbID = Preferences.get("upload.usbID"); - if (usbID == null) { - /* fall back on default */ - /* this isnt great because is default Avrdude or dfu-util? */ - usbID = Preferences.get("upload.usbID"); - } - - /* if auto-reset, then emit the reset pulse on dtr/rts */ - if (Preferences.get("upload.auto_reset") != null) { - if (Preferences.get("upload.auto_reset").toLowerCase().equals("true")) { - System.out.println("Resetting to bootloader via DTR pulse"); - emitResetPulse(); - } - } else { - System.out.println("Resetting to bootloader via DTR pulse"); - emitResetPulse(); - } - - String dfuList = new String(); - List commandCheck = new ArrayList(); - commandCheck.add("dfu-util"); - commandCheck.add("-l"); - long startChecking = System.currentTimeMillis(); - System.out.println("Searching for DFU device [" + usbID + "]..."); - do { - try { - Thread.sleep(100); - } catch (InterruptedException e) {} - dfuList = executeCheckCommand(commandCheck); - //System.out.println(dfuList); - } - while ( !found_device (dfuList.toUpperCase(), usbID) && (System.currentTimeMillis() - startChecking < 7000)); - - if ( !found_device (dfuList.toUpperCase(), usbID) ) - { - System.out.println(dfuList); - System.err.println("Couldn't find the DFU device: [" + usbID + "]"); - return false; - } - System.out.println("Found it!"); - - /* todo, add handle to let user choose altIf at upload time! */ - String altIf = Preferences.get("upload.altID"); - - List commandDownloader = new ArrayList(); - commandDownloader.add("dfu-util"); - commandDownloader.add("-a "+altIf); - commandDownloader.add("-R"); - commandDownloader.add("-d "+usbID); - commandDownloader.add("-D"+ binPath); //"./thisbin.bin"); - - return executeUploadCommand(commandDownloader); - } - - System.err.println("Only .bin files are supported at this time"); - return false; - } - - /* we need to ensure both RTS and DTR are low to start, - then pulse DTR on its own. This is the reset signal - maple responds to - */ - private void emitResetPulse() throws RunnerException { - - /* wait a while for the device to reboot */ - int programDelay = Preferences.getInteger("programDelay"); - - try { - Serial serialPort = new Serial(); - - // try to toggle DTR/RTS (old scheme) - serialPort.setRTS(false); - serialPort.setDTR(false); - serialPort.setDTR(true); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.setDTR(false); - - // try magic number - serialPort.setRTS(true); - serialPort.setDTR(true); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.setDTR(false); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.write("1EAF"); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.dispose(); - - } catch(Exception e) { - System.err.println("Reset via USB Serial Failed! Did you select the right serial port?\nAssuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...\n"); - } - } - - protected String executeCheckCommand(Collection commandDownloader) - throws RunnerException - { - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - notFoundError = false; - int result=0; // pre-initialized to quiet a bogus warning from jikes - - String userdir = System.getProperty("user.dir") + File.separator; - String returnStr = new String(); - - try { - String[] commandArray = new String[commandDownloader.size()]; - commandDownloader.toArray(commandArray); - - String armBasePath; - - //armBasePath = new String(Base.getHardwarePath() + "/tools/arm/bin/"); - armBasePath = ""; - - commandArray[0] = armBasePath + commandArray[0]; - - if (verbose || Preferences.getBoolean("upload.verbose")) { - for(int i = 0; i < commandArray.length; i++) { - System.out.print(commandArray[i] + " "); - } - System.out.println(); - } - - Process process = Runtime.getRuntime().exec(commandArray); - BufferedReader stdInput = new BufferedReader(new - InputStreamReader(process.getInputStream())); - BufferedReader stdError = new BufferedReader(new - InputStreamReader(process.getErrorStream())); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - // - boolean busy = true; - while (busy) { - try { - result = process.waitFor(); - busy = false; - } catch (InterruptedException intExc) { - } - } - - String s; - while ((s = stdInput.readLine()) != null) { - returnStr += s + "\n"; - } - - process.destroy(); - - if(exception!=null) { - exception.hideStackTrace(); - throw exception; - } - if(result!=0) return "Error!"; - } catch (Exception e) { - e.printStackTrace(); - } - //System.out.println("result2 is "+result); - // if the result isn't a known, expected value it means that something - // is fairly wrong, one possibility is that jikes has crashed. - // - if (exception != null) throw exception; - - if ((result != 0) && (result != 1 )) { - exception = new RunnerException(SUPER_BADNESS); - } - - return returnStr; // ? true : false; - - } - - // Need to overload this from Uploader to use the system-wide dfu-util - protected boolean executeUploadCommand(Collection commandDownloader) - throws RunnerException - { - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - notFoundError = false; - int result=0; // pre-initialized to quiet a bogus warning from jikes - - String userdir = System.getProperty("user.dir") + File.separator; - - try { - String[] commandArray = new String[commandDownloader.size()]; - commandDownloader.toArray(commandArray); - - String armBasePath; - - //armBasePath = new String(Base.getHardwarePath() + "/tools/arm/bin/"); - armBasePath = ""; - - commandArray[0] = armBasePath + commandArray[0]; - - if (verbose || Preferences.getBoolean("upload.verbose")) { - for(int i = 0; i < commandArray.length; i++) { - System.out.print(commandArray[i] + " "); - } - System.out.println(); - } - - Process process = Runtime.getRuntime().exec(commandArray); - new MessageSiphon(process.getInputStream(), this); - new MessageSiphon(process.getErrorStream(), this); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - // - boolean compiling = true; - while (compiling) { - try { - result = process.waitFor(); - compiling = false; - } catch (InterruptedException intExc) { - } - } - if(exception!=null) { - exception.hideStackTrace(); - throw exception; - } - if(result!=0) - return false; - } catch (Exception e) { - e.printStackTrace(); - } - //System.out.println("result2 is "+result); - // if the result isn't a known, expected value it means that something - // is fairly wrong, one possibility is that jikes has crashed. - // - if (exception != null) throw exception; - - if ((result != 0) && (result != 1 )) { - exception = new RunnerException(SUPER_BADNESS); - //editor.error(exception); - //PdeBase.openURL(BUGS_URL); - //throw new PdeException(SUPER_BADNESS); - } - - return (result == 0); // ? true : false; - - } - - // deal with messages from dfu-util... - public void message(String s) { - - if(s.indexOf("dfu-util - (C) ") != -1) { return; } - if(s.indexOf("This program is Free Software and has ABSOLUTELY NO WARRANTY") != -1) { return; } - - if(s.indexOf("No DFU capable USB device found") != -1) { - System.err.print(s); - exception = new RunnerException("Problem uploading via dfu-util: No Maple found"); - return; - } - - if(s.indexOf("Operation not perimitted") != -1) { - System.err.print(s); - exception = new RunnerException("Problem uploading via dfu-util: Insufficient privilages"); - return; - } - - // else just print everything... - System.out.print(s); - } - -} diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/CliTemplate/ExecCommand.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/CliTemplate/ExecCommand.java deleted file mode 100755 index 3d6c106b7..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/CliTemplate/ExecCommand.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package CliTemplate; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; - -import processing.app.debug.MessageConsumer; -import processing.app.debug.MessageSiphon; -import processing.app.debug.RunnerException; -import processing.app.helpers.ProcessUtils; - -/** - * - * @author cousinr - */ -public class ExecCommand implements MessageConsumer { - - private boolean verbose = true; - private boolean firstErrorFound; - private boolean secondErrorFound; - private RunnerException exception; - - /** - * Either succeeds or throws a RunnerException fit for public consumption. - * - * @param command - * @throws RunnerException - */ - public void execAsynchronously(String[] command) throws RunnerException { - - // eliminate any empty array entries - List stringList = new ArrayList<>(); - for (String string : command) { - string = string.trim(); - if (string.length() != 0) - stringList.add(string); - } - command = stringList.toArray(new String[stringList.size()]); - if (command.length == 0) - return; - int result = 0; - - if (verbose) { - for (String c : command) - System.out.print(c + " "); - System.out.println(); - } - - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - - Process process; - try { - process = ProcessUtils.exec(command); - } catch (IOException e) { - RunnerException re = new RunnerException(e.getMessage()); - re.hideStackTrace(); - throw re; - } - - MessageSiphon in = new MessageSiphon(process.getInputStream(), this); - MessageSiphon err = new MessageSiphon(process.getErrorStream(), this); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - boolean compiling = true; - while (compiling) { - try { - in.join(); - err.join(); - result = process.waitFor(); - //System.out.println("result is " + result); - compiling = false; - } catch (InterruptedException ignored) { } - } - - // an error was queued up by message(), barf this back to compile(), - // which will barf it back to Editor. if you're having trouble - // discerning the imagery, consider how cows regurgitate their food - // to digest it, and the fact that they have five stomaches. - // - //System.out.println("throwing up " + exception); - if (exception != null) - throw exception; - - if (result > 1) { - // a failure in the tool (e.g. unable to locate a sub-executable) - System.err.println(MessageFormat.format("{0} returned {1}", command[0], result)); - } - - if (result != 0) { - RunnerException re = new RunnerException(MessageFormat.format("exit code: {0}", result)); - re.hideStackTrace(); - throw re; - } - } - - /** - * Part of the MessageConsumer interface, this is called - * whenever a piece (usually a line) of error message is spewed - * out from the compiler. The errors are parsed for their contents - * and line number, which is then reported back to Editor. - * @param s - */ - @Override - public void message(String s) { - int i; - - - System.err.print(s); - } - -} diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/Base.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/Base.java deleted file mode 100755 index c3a174dcb..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/Base.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-10 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - - -/** - * The base class for the main processing application. - * Primary role of this class is for platform identification and - * general interaction with the system (launching URLs, loading - * files and images, etc) that comes from that. - */ -public class Base { - - /** - * returns true if running on windows. - */ - static public boolean isWindows() { - //return PApplet.platform == PConstants.WINDOWS; - return System.getProperty("os.name").indexOf("Windows") != -1; - } - - - /** - * true if running on linux. - */ - static public boolean isLinux() { - //return PApplet.platform == PConstants.LINUX; - return System.getProperty("os.name").indexOf("Linux") != -1; - } - - - -} diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/Preferences.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/Preferences.java deleted file mode 100755 index 6368e38af..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/Preferences.java +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-09 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - -import java.io.*; -import java.util.*; - - -/** - * Storage class for user preferences and environment settings. - *

- * This class no longer uses the Properties class, since - * properties files are iso8859-1, which is highly likely to - * be a problem when trying to save sketch folders and locations. - *

- * The GUI portion in here is really ugly, as it uses exact layout. This was - * done in frustration one evening (and pre-Swing), but that's long since past, - * and it should all be moved to a proper swing layout like BoxLayout. - *

- * This is very poorly put together, that the preferences panel and the actual - * preferences i/o is part of the same code. But there hasn't yet been a - * compelling reason to bother with the separation aside from concern about - * being lectured by strangers who feel that it doesn't look like what they - * learned in CS class. - *

- * Would also be possible to change this to use the Java Preferences API. - * Some useful articles - * here and - * here. - * However, haven't implemented this yet for lack of time, but more - * importantly, because it would entail writing to the registry (on Windows), - * or an obscure file location (on Mac OS X) and make it far more difficult to - * find the preferences to tweak them by hand (no! stay out of regedit!) - * or to reset the preferences by simply deleting the preferences.txt file. - */ -public class Preferences { - - // what to call the feller - - static final String PREFS_FILE = "preferences.txt"; - - - // prompt text stuff - - static final String PROMPT_YES = "Yes"; - static final String PROMPT_NO = "No"; - static final String PROMPT_CANCEL = "Cancel"; - static final String PROMPT_OK = "OK"; - static final String PROMPT_BROWSE = "Browse"; - - /** - * Standardized width for buttons. Mac OS X 10.3 wants 70 as its default, - * Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper. - */ - static public int BUTTON_WIDTH = 80; - - /** - * Standardized button height. Mac OS X 10.3 (Java 1.4) wants 29, - * presumably because it now includes the blue border, where it didn't - * in Java 1.3. Windows XP only wants 23 (not sure what default Linux - * would be). Because of the disparity, on Mac OS X, it will be set - * inside a static block. - */ - static public int BUTTON_HEIGHT = 24; - - // value for the size bars, buttons, etc - - static final int GRID_SIZE = 33; - - - // indents and spacing standards. these probably need to be modified - // per platform as well, since macosx is so huge, windows is smaller, - // and linux is all over the map - - static final int GUI_BIG = 13; - static final int GUI_BETWEEN = 10; - static final int GUI_SMALL = 6; - - - - // data model - - static Hashtable table = new Hashtable();; - static File preferencesFile; - - - static protected void init(String commandLinePrefs) { - - - } - - - public Preferences() { - - } - - // ................................................................. - - // ................................................................. - - // ................................................................. - - // ................................................................. - - - - static public String get(String attribute) { - return (String) table.get(attribute); - } - - static public void set(String attribute, String value) { - table.put(attribute, value); - } - - - static public boolean getBoolean(String attribute) { - String value = get(attribute); - return (new Boolean(value)).booleanValue(); - } - - - static public void setBoolean(String attribute, boolean value) { - set(attribute, value ? "true" : "false"); - } - - - static public int getInteger(String attribute) { - return Integer.parseInt(get(attribute)); - } - - - static public void setInteger(String key, int value) { - set(key, String.valueOf(value)); - } - -} diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/Serial.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/Serial.java deleted file mode 100755 index 04566a738..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/Serial.java +++ /dev/null @@ -1,527 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - PSerial - class for serial port goodness - Part of the Processing project - http://processing.org - - Copyright (c) 2004 Ben Fry & Casey Reas - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA -*/ - -package processing.app; -//import processing.core.*; - - -import java.io.*; -import java.text.MessageFormat; -import java.util.*; -import jssc.SerialPort; -import jssc.SerialPortEvent; -import jssc.SerialPortEventListener; -import jssc.SerialPortException; -import jssc.SerialPortList; -import processing.app.debug.MessageConsumer; - - -public class Serial implements SerialPortEventListener { - - //PApplet parent; - - // properties can be passed in for default values - // otherwise defaults to 9600 N81 - - // these could be made static, which might be a solution - // for the classloading problem.. because if code ran again, - // the static class would have an object that could be closed - - SerialPort port; - - int rate; - int parity; - int databits; - int stopbits; - boolean monitor = false; - - // read buffer and streams - - InputStream input; - OutputStream output; - - byte buffer[] = new byte[32768]; - int bufferIndex; - int bufferLast; - - MessageConsumer consumer; - - public Serial(boolean monitor) throws SerialException { - this(Preferences.get("serial.port"), - Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - this.monitor = monitor; - } - - public Serial() throws SerialException { - this(Preferences.get("serial.port"), - Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(int irate) throws SerialException { - this(Preferences.get("serial.port"), irate, - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname, int irate) throws SerialException { - this(iname, irate, Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname) throws SerialException { - this(iname, Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname, int irate, - char iparity, int idatabits, float istopbits) - throws SerialException { - //if (port != null) port.close(); - //this.parent = parent; - //parent.attach(this); - - this.rate = irate; - - parity = SerialPort.PARITY_NONE; - if (iparity == 'E') parity = SerialPort.PARITY_EVEN; - if (iparity == 'O') parity = SerialPort.PARITY_ODD; - - this.databits = idatabits; - - stopbits = SerialPort.STOPBITS_1; - if (istopbits == 1.5f) stopbits = SerialPort.STOPBITS_1_5; - if (istopbits == 2) stopbits = SerialPort.STOPBITS_2; - - try { - port = new SerialPort(iname); - port.openPort(); - port.setParams(rate, databits, stopbits, parity, true, true); - port.addEventListener(this); - } catch (Exception e) { - throw new SerialException(MessageFormat.format("Error opening serial port ''{0}''.", iname), e); - } - - if (port == null) { - throw new SerialException("Serial port '" + iname + "' not found. Did you select the right one from the Tools > Serial Port menu?"); - } - } - - - public void setup() { - //parent.registerCall(this, DISPOSE); - } - - public void dispose() throws IOException { - if (port != null) { - try { - if (port.isOpened()) { - port.closePort(); // close the port - } - } catch (SerialPortException e) { - throw new IOException(e); - } finally { - port = null; - } - } - } - - public void addListener(MessageConsumer consumer) { - this.consumer = consumer; - } - - public synchronized void serialEvent(SerialPortEvent serialEvent) { - if (serialEvent.isRXCHAR()) { - try { - byte[] buf = port.readBytes(serialEvent.getEventValue()); - if (buf.length > 0) { - if (bufferLast == buffer.length) { - byte temp[] = new byte[bufferLast << 1]; - System.arraycopy(buffer, 0, temp, 0, bufferLast); - buffer = temp; - } - if (monitor) { - System.out.print(new String(buf)); - } - if (this.consumer != null) { - this.consumer.message(new String(buf)); - } - } - } catch (SerialPortException e) { - errorMessage("serialEvent", e); - } - } - } - - - /** - * Returns the number of bytes that have been read from serial - * and are waiting to be dealt with by the user. - */ - public synchronized int available() { - return (bufferLast - bufferIndex); - } - - - /** - * Ignore all the bytes read so far and empty the buffer. - */ - public synchronized void clear() { - bufferLast = 0; - bufferIndex = 0; - } - - - /** - * Returns a number between 0 and 255 for the next byte that's - * waiting in the buffer. - * Returns -1 if there was no byte (although the user should - * first check available() to see if things are ready to avoid this) - */ - public synchronized int read() { - if (bufferIndex == bufferLast) return -1; - - int outgoing = buffer[bufferIndex++] & 0xff; - if (bufferIndex == bufferLast) { // rewind - bufferIndex = 0; - bufferLast = 0; - } - return outgoing; - } - - - /** - * Returns the next byte in the buffer as a char. - * Returns -1, or 0xffff, if nothing is there. - */ - public synchronized char readChar() { - if (bufferIndex == bufferLast) return (char)(-1); - return (char) read(); - } - - - /** - * Return a byte array of anything that's in the serial buffer. - * Not particularly memory/speed efficient, because it creates - * a byte array on each read, but it's easier to use than - * readBytes(byte b[]) (see below). - */ - public synchronized byte[] readBytes() { - if (bufferIndex == bufferLast) return null; - - int length = bufferLast - bufferIndex; - byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex = 0; // rewind - bufferLast = 0; - return outgoing; - } - - - /** - * Grab whatever is in the serial buffer, and stuff it into a - * byte buffer passed in by the user. This is more memory/time - * efficient than readBytes() returning a byte[] array. - *

- * Returns an int for how many bytes were read. If more bytes - * are available than can fit into the byte array, only those - * that will fit are read. - */ - public synchronized int readBytes(byte outgoing[]) { - if (bufferIndex == bufferLast) return 0; - - int length = bufferLast - bufferIndex; - if (length > outgoing.length) length = outgoing.length; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex += length; - if (bufferIndex == bufferLast) { - bufferIndex = 0; // rewind - bufferLast = 0; - } - return length; - } - - - /** - * Reads from the serial port into a buffer of bytes up to and - * including a particular character. If the character isn't in - * the serial buffer, then 'null' is returned. - */ - public synchronized byte[] readBytesUntil(int interesting) { - if (bufferIndex == bufferLast) return null; - byte what = (byte)interesting; - - int found = -1; - for (int k = bufferIndex; k < bufferLast; k++) { - if (buffer[k] == what) { - found = k; - break; - } - } - if (found == -1) return null; - - int length = found - bufferIndex + 1; - byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex = 0; // rewind - bufferLast = 0; - return outgoing; - } - - - /** - * Reads from the serial port into a buffer of bytes until a - * particular character. If the character isn't in the serial - * buffer, then 'null' is returned. - *

- * If outgoing[] is not big enough, then -1 is returned, - * and an error message is printed on the console. - * If nothing is in the buffer, zero is returned. - * If 'interesting' byte is not in the buffer, then 0 is returned. - */ - public synchronized int readBytesUntil(int interesting, byte outgoing[]) { - if (bufferIndex == bufferLast) return 0; - byte what = (byte)interesting; - - int found = -1; - for (int k = bufferIndex; k < bufferLast; k++) { - if (buffer[k] == what) { - found = k; - break; - } - } - if (found == -1) return 0; - - int length = found - bufferIndex + 1; - if (length > outgoing.length) { - System.err.println("readBytesUntil() byte buffer is" + - " too small for the " + length + - " bytes up to and including char " + interesting); - return -1; - } - //byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex += length; - if (bufferIndex == bufferLast) { - bufferIndex = 0; // rewind - bufferLast = 0; - } - return length; - } - - - /** - * Return whatever has been read from the serial port so far - * as a String. It assumes that the incoming characters are ASCII. - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public synchronized String readString() { - if (bufferIndex == bufferLast) return null; - return new String(readBytes()); - } - - - /** - * Combination of readBytesUntil and readString. See caveats in - * each function. Returns null if it still hasn't found what - * you're looking for. - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public synchronized String readStringUntil(int interesting) { - byte b[] = readBytesUntil(interesting); - if (b == null) return null; - return new String(b); - } - - - /** - * This will handle both ints, bytes and chars transparently. - */ - public void write(int what) { // will also cover char - try { - port.writeInt(what & 0xff); - } catch (SerialPortException e) { - errorMessage("write", e); - } - } - - - public void write(byte bytes[]) { - try { - port.writeBytes(bytes); - } catch (SerialPortException e) { - errorMessage("write", e); - } - } - - - /** - * Write a String to the output. Note that this doesn't account - * for Unicode (two bytes per char), nor will it send UTF8 - * characters.. It assumes that you mean to send a byte buffer - * (most often the case for networking and serial i/o) and - * will only use the bottom 8 bits of each char in the string. - * (Meaning that internally it uses String.getBytes) - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public void write(String what) { - write(what.getBytes()); - } - - public void setDTR(boolean state) { - try { - port.setDTR(state); - } catch (SerialPortException e) { - errorMessage("setDTR", e); - } - } - - public void setRTS(boolean state) { - try { - port.setRTS(state); - } catch (SerialPortException e) { - errorMessage("setRTS", e); - } - } - - static public List list() { - return Arrays.asList(SerialPortList.getPortNames()); - } - - - /** - * General error reporting, all corraled here just in case - * I think of something slightly more intelligent to do. - */ - static public void errorMessage(String where, Throwable e) { - System.err.println("Error inside Serial." + where + "()"); - e.printStackTrace(); - } -} - - - /* - class SerialMenuListener implements ItemListener { - //public SerialMenuListener() { } - - public void itemStateChanged(ItemEvent e) { - int count = serialMenu.getItemCount(); - for (int i = 0; i < count; i++) { - ((CheckboxMenuItem)serialMenu.getItem(i)).setState(false); - } - CheckboxMenuItem item = (CheckboxMenuItem)e.getSource(); - item.setState(true); - String name = item.getLabel(); - //System.out.println(item.getLabel()); - PdeBase.properties.put("serial.port", name); - //System.out.println("set to " + get("serial.port")); - } - } - */ - - - /* - protected Vector buildPortList() { - // get list of names for serial ports - // have the default port checked (if present) - Vector list = new Vector(); - - //SerialMenuListener listener = new SerialMenuListener(); - boolean problem = false; - - // if this is failing, it may be because - // lib/javax.comm.properties is missing. - // java is weird about how it searches for java.comm.properties - // so it tends to be very fragile. i.e. quotes in the CLASSPATH - // environment variable will hose things. - try { - //System.out.println("building port list"); - Enumeration portList = CommPortIdentifier.getPortIdentifiers(); - while (portList.hasMoreElements()) { - CommPortIdentifier portId = - (CommPortIdentifier) portList.nextElement(); - //System.out.println(portId); - - if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { - //if (portId.getName().equals(port)) { - String name = portId.getName(); - //CheckboxMenuItem mi = - //new CheckboxMenuItem(name, name.equals(defaultName)); - - //mi.addItemListener(listener); - //serialMenu.add(mi); - list.addElement(name); - } - } - } catch (UnsatisfiedLinkError e) { - e.printStackTrace(); - problem = true; - - } catch (Exception e) { - System.out.println("exception building serial menu"); - e.printStackTrace(); - } - - //if (serialMenu.getItemCount() == 0) { - //System.out.println("dimming serial menu"); - //serialMenu.setEnabled(false); - //} - - // only warn them if this is the first time - if (problem && PdeBase.firstTime) { - JOptionPane.showMessageDialog(this, //frame, - "Serial port support not installed.\n" + - "Check the readme for instructions\n" + - "if you need to use the serial port. ", - "Serial Port Warning", - JOptionPane.WARNING_MESSAGE); - } - return list; - } - */ - - - diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/SerialException.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/SerialException.java deleted file mode 100755 index 525c24078..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/SerialException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Copyright (c) 2007 David A. Mellis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - -public class SerialException extends Exception { - public SerialException() { - super(); - } - - public SerialException(String message) { - super(message); - } - - public SerialException(String message, Throwable cause) { - super(message, cause); - } - - public SerialException(Throwable cause) { - super(cause); - } -} diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/debug/MessageConsumer.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/debug/MessageConsumer.java deleted file mode 100755 index 5e2042943..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/debug/MessageConsumer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-06 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - - -/** - * Interface for dealing with parser/compiler output. - *

- * Different instances of MessageStream need to do different things with - * messages. In particular, a stream instance used for parsing output from - * the compiler compiler has to interpret its messages differently than one - * parsing output from the runtime. - *

- * Classes which consume messages and do something with them - * should implement this interface. - */ -public interface MessageConsumer { - - public void message(String s); - -} diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/debug/MessageSiphon.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/debug/MessageSiphon.java deleted file mode 100755 index 26901c3f4..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/debug/MessageSiphon.java +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-06 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.SocketException; - -/** - * Slurps up messages from compiler. - */ -public class MessageSiphon implements Runnable { - - private final BufferedReader streamReader; - private final MessageConsumer consumer; - - private Thread thread; - private boolean canRun; - - public MessageSiphon(InputStream stream, MessageConsumer consumer) { - this.streamReader = new BufferedReader(new InputStreamReader(stream)); - this.consumer = consumer; - this.canRun = true; - - thread = new Thread(this); - // don't set priority too low, otherwise exceptions won't - // bubble up in time (i.e. compile errors have a weird delay) - //thread.setPriority(Thread.MIN_PRIORITY); - thread.setPriority(Thread.MAX_PRIORITY - 1); - thread.start(); - } - - - public void run() { - try { - // process data until we hit EOF; this will happily block - // (effectively sleeping the thread) until new data comes in. - // when the program is finally done, null will come through. - // - String currentLine; - while (canRun && (currentLine = streamReader.readLine()) != null) { - // \n is added again because readLine() strips it out - //EditorConsole.systemOut.println("messaging in"); - consumer.message(currentLine + "\n"); - //EditorConsole.systemOut.println("messaging out"); - } - //EditorConsole.systemOut.println("messaging thread done"); - } catch (NullPointerException npe) { - // Fairly common exception during shutdown - } catch (SocketException e) { - // socket has been close while we were wainting for data. nothing to see here, move along - } catch (Exception e) { - // On Linux and sometimes on Mac OS X, a "bad file descriptor" - // message comes up when closing an applet that's run externally. - // That message just gets supressed here.. - String mess = e.getMessage(); - if ((mess != null) && - (mess.indexOf("Bad file descriptor") != -1)) { - //if (e.getMessage().indexOf("Bad file descriptor") == -1) { - //System.err.println("MessageSiphon err " + e); - //e.printStackTrace(); - } else { - e.printStackTrace(); - } - } finally { - thread = null; - } - } - - // Wait until the MessageSiphon thread is complete. - public void join() throws java.lang.InterruptedException { - // Grab a temp copy in case another thread nulls the "thread" - // member variable - Thread t = thread; - if (t != null) t.join(); - } - - public void stop() { - this.canRun = false; - } - -} diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/debug/RunnerException.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/debug/RunnerException.java deleted file mode 100755 index 0a67d1e80..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/debug/RunnerException.java +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-08 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - - -/** - * An exception with a line number attached that occurs - * during either compile time or run time. - */ -@SuppressWarnings("serial") -public class RunnerException extends Exception { - protected String message; - protected int codeIndex; - protected int codeLine; - protected int codeColumn; - protected boolean showStackTrace; - - - public RunnerException(String message) { - this(message, true); - } - - public RunnerException(String message, boolean showStackTrace) { - this(message, -1, -1, -1, showStackTrace); - } - - public RunnerException(String message, int file, int line) { - this(message, file, line, -1, true); - } - - - public RunnerException(String message, int file, int line, int column) { - this(message, file, line, column, true); - } - - - public RunnerException(String message, int file, int line, int column, - boolean showStackTrace) { - this.message = message; - this.codeIndex = file; - this.codeLine = line; - this.codeColumn = column; - this.showStackTrace = showStackTrace; - } - - - public RunnerException(Exception e) { - super(e); - this.showStackTrace = true; - } - - /** - * Override getMessage() in Throwable, so that I can set - * the message text outside the constructor. - */ - public String getMessage() { - return message; - } - - - public void setMessage(String message) { - this.message = message; - } - - - public int getCodeIndex() { - return codeIndex; - } - - - public void setCodeIndex(int index) { - codeIndex = index; - } - - - public boolean hasCodeIndex() { - return codeIndex != -1; - } - - - public int getCodeLine() { - return codeLine; - } - - - public void setCodeLine(int line) { - this.codeLine = line; - } - - - public boolean hasCodeLine() { - return codeLine != -1; - } - - - public void setCodeColumn(int column) { - this.codeColumn = column; - } - - - public int getCodeColumn() { - return codeColumn; - } - - - public void showStackTrace() { - showStackTrace = true; - } - - - public void hideStackTrace() { - showStackTrace = false; - } - - - /** - * Nix the java.lang crap out of an exception message - * because it scares the children. - *

- * This function must be static to be used with super() - * in each of the constructors above. - */ - /* - static public final String massage(String msg) { - if (msg.indexOf("java.lang.") == 0) { - //int dot = msg.lastIndexOf('.'); - msg = msg.substring("java.lang.".length()); - } - return msg; - //return (dot == -1) ? msg : msg.substring(dot+1); - } - */ - - - public void printStackTrace() { - if (showStackTrace) { - super.printStackTrace(); - } - } -} diff --git a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/helpers/ProcessUtils.java b/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/helpers/ProcessUtils.java deleted file mode 100755 index c023f5810..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/maple_loader/src/processing/app/helpers/ProcessUtils.java +++ /dev/null @@ -1,32 +0,0 @@ -package processing.app.helpers; - -//import processing.app.Base; - -import java.io.IOException; -import java.util.Map; - -import processing.app.Base; - -public class ProcessUtils { - - public static Process exec(String[] command) throws IOException { - // No problems on linux and mac - if (!Base.isWindows()) { - return Runtime.getRuntime().exec(command); - } - - // Brutal hack to workaround windows command line parsing. - // http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly - // http://msdn.microsoft.com/en-us/library/a1y7w461.aspx - // http://bugs.sun.com/view_bug.do?bug_id=6468220 - // http://bugs.sun.com/view_bug.do?bug_id=6518827 - String[] cmdLine = new String[command.length]; - for (int i = 0; i < command.length; i++) - cmdLine[i] = command[i].replace("\"", "\\\""); - - ProcessBuilder pb = new ProcessBuilder(cmdLine); - Map env = pb.environment(); - env.put("CYGWIN", "nodosfilewarning"); - return pb.start(); - } -} diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/AUTHORS b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/AUTHORS deleted file mode 100755 index d096f2205..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/AUTHORS +++ /dev/null @@ -1,19 +0,0 @@ -Authors ordered by first contribution. - -Geoffrey McRae -Bret Olmsted -Tormod Volden -Jakob Malm -Reuben Dowle -Matthias Kubisch -Paul Fertser -Daniel Strnad -Jérémie Rapin -Christian Pointner -Mats Erik Andersson -Alexey Borovik -Antonio Borneo -Armin van der Togt -Brian Silverman -Georg Hofmann -Luis Rodrigues diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/Android.mk b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/Android.mk deleted file mode 100755 index 7be3d0018..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/Android.mk +++ /dev/null @@ -1,20 +0,0 @@ -TOP_LOCAL_PATH := $(call my-dir) - -include $(call all-named-subdir-makefiles, parsers) - -LOCAL_PATH := $(TOP_LOCAL_PATH) - -include $(CLEAR_VARS) -LOCAL_MODULE := stm32flash -LOCAL_SRC_FILES := \ - dev_table.c \ - i2c.c \ - init.c \ - main.c \ - port.c \ - serial_common.c \ - serial_platform.c \ - stm32.c \ - utils.c -LOCAL_STATIC_LIBRARIES := libparsers -include $(BUILD_EXECUTABLE) diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/HOWTO b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/HOWTO deleted file mode 100755 index d8f32eb04..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/HOWTO +++ /dev/null @@ -1,35 +0,0 @@ -Add new interfaces: -===================================================================== -Current version 0.4 supports the following interfaces: -- UART Windows (either "COMn" and "\\.\COMn"); -- UART posix/Linux (e.g. "/dev/ttyUSB0"); -- I2C Linux through standard driver "i2c-dev" (e.g. "/dev/i2c-n"). - -Starting from version 0.4, the back-end of stm32flash is modular and -ready to be expanded to support new interfaces. -I'm planning adding SPI on Linux through standard driver "spidev". -You are invited to contribute with more interfaces. - -To add a new interface you need to add a new file, populate the struct -port_interface (check at the end of files i2c.c, serial_posix.c and -serial_w32.c) and provide the relative functions to operate on the -interface: open/close, read/write, get_cfg_str and the optional gpio. -The include the new drive in Makefile and register the new struct -port_interface in file port.c in struct port_interface *ports[]. - -There are several USB-I2C adapter in the market, each providing its -own libraries to communicate with the I2C bus. -Could be interesting to provide as back-end a bridge between stm32flash -and such libraries (I have no plan on this item). - - -Add new STM32 devices: -===================================================================== -Add a new line in file dev_table.c, in table devices[]. -The fields of the table are listed in stm32.h, struct stm32_dev. - - -Cross compile on Linux host for Windows target with MinGW: -===================================================================== -I'm using a 64 bit Arch Linux machines, and I usually run: - make CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/I2C.txt b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/I2C.txt deleted file mode 100755 index 4c05ff62d..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/I2C.txt +++ /dev/null @@ -1,94 +0,0 @@ -About I2C back-end communication in stm32flash -========================================================================== - -Starting from version v0.4, beside the serial communication port, -stm32flash adds support for I2C port to talk with STM32 bootloader. - -The current I2C back-end supports only the API provided by Linux kernel -driver "i2c-dev", so only I2C controllers with Linux kernel driver can be -used. -In Linux source code, most of the drivers for I2C and SMBUS controllers -are in - ./drivers/i2c/busses/ -Only I2C is supported by STM32 bootloader, so check the section below -about SMBUS. -No I2C support for Windows is available in stm32flash v0.4. - -Thanks to the new modular back-end, stm32flash can be easily extended to -support new back-ends and API. Check HOWTO file in stm32flash source code -for details. - -In the market there are several USB-to-I2C dongles; most of them are not -supported by kernel drivers. Manufacturer provide proprietary userspace -libraries using not standardized API. -These API and dongles could be supported in feature versions. - -There are currently 3 versions of STM32 bootloader for I2C communications: -- v1.0 using I2C clock stretching synchronization between host and STM32; -- v1.1 superset of v1.0, adds non stretching commands; -- v1.2 superset of v1.1, adds CRC command and compatibility with i2cdetect. -Details in ST application note AN2606. -All the bootloaders above are tested and working with stm32flash. - - -SMBUS controllers -========================================================================== - -Almost 50% of the drivers in Linux source code folder - ./drivers/i2c/busses/ -are for controllers that "only" support SMBUS protocol. They can NOT -operate with STM32 bootloader. -To identify if your controller supports I2C, use command: - i2cdetect -F n -where "n" is the number of the I2C interface (e.g. n=3 for "/dev/i2c-3"). -Controllers that supports I2C will report - I2C yes -Controller that support both I2C and SMBUS are ok. - -If you are interested on details about SMBUS protocol, you can download -the current specs from - http://smbus.org/specs/smbus20.pdf -and you can read the files in Linux source code - ./Documentation/i2c/i2c-protocol - ./Documentation/i2c/smbus-protocol - - -About bootloader v1.0 -========================================================================== - -Version v1.0 can have issues with some I2C controllers due to use of clock -stretching during commands that require long operations, like flash erase -and programming. - -Clock stretching is a technique to synchronize host and I2C device. When -I2C device wants to force a delay in the communication, it push "low" the -I2C clock; the I2C controller detects it and waits until I2C clock returns -"high". -Most I2C controllers set a "timeout" for clock stretching, ranging from -few milli-seconds to seconds depending on specific HW or SW driver. - -It is possible that the timeout in your I2C controller is smaller than the -delay required for flash erase or programming. In this case the I2C -controller will timeout and report error to stm32flash. -There is no possibility for stm32flash to retry, so it can only signal the -error and exit. - -To by-pass the issue with bootloader v1.0 you can modify the kernel driver -of your I2C controller. Not an easy job, since every controller has its own -way to handle the timeout. - -In my case I'm using the I2C controller integrated in the VGA port of my -laptop HP EliteBook 8460p. I built the 0.25$ VGA-to-I2C adapter reported in - http://www.paintyourdragon.com/?p=43 -To change the timeout of the I2C controller I had to modify the kernel file - drivers/gpu/drm/radeon/radeon_i2c.c -line 969 -- i2c->bit.timeout = usecs_to_jiffies(2200); /* from VESA */ -+ i2c->bit.timeout = msecs_to_jiffies(5000); /* 5s for STM32 */ -and recompile it. -Then - $> modprobe i2c-dev - $> chmod 666 /dev/i2c-7 - #> stm32flash -a 0x39 /dev/i2c-7 - -2014-09-16 Antonio Borneo diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/Makefile b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/Makefile deleted file mode 100755 index 0328d5588..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -PREFIX = /usr/local -CFLAGS += -Wall -g - -INSTALL = install - -OBJS = dev_table.o \ - i2c.o \ - init.o \ - main.o \ - port.o \ - serial_common.o \ - serial_platform.o \ - stm32.o \ - utils.o - -LIBOBJS = parsers/parsers.a - -all: stm32flash - -serial_platform.o: serial_posix.c serial_w32.c - -parsers/parsers.a: - cd parsers && $(MAKE) parsers.a - -stm32flash: $(OBJS) $(LIBOBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBOBJS) - -clean: - rm -f $(OBJS) stm32flash - cd parsers && $(MAKE) $@ - -install: all - $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin - $(INSTALL) -m 755 stm32flash $(DESTDIR)$(PREFIX)/bin - $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/man/man1 - $(INSTALL) -m 644 stm32flash.1 $(DESTDIR)$(PREFIX)/share/man/man1 - -.PHONY: all clean install diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/TODO b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/TODO deleted file mode 100755 index 41df614ff..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/TODO +++ /dev/null @@ -1,7 +0,0 @@ - -stm32: -- Add support for variable page size - -AUTHORS: -- Add contributors from Geoffrey's commits - diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/dev_table.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/dev_table.c deleted file mode 100755 index 399cd9d08..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/dev_table.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "stm32.h" - -/* - * Device table, corresponds to the "Bootloader device-dependant parameters" - * table in ST document AN2606. - * Note that the option bytes upper range is inclusive! - */ -const stm32_dev_t devices[] = { - /* F0 */ - {0x440, "STM32F051xx" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 4, 1024, 0x1FFFF800, 0x1FFFF80B, 0x1FFFEC00, 0x1FFFF800}, - {0x444, "STM32F030/F031" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 4, 1024, 0x1FFFF800, 0x1FFFF80B, 0x1FFFEC00, 0x1FFFF800}, - {0x445, "STM32F042xx" , 0x20001800, 0x20001800, 0x08000000, 0x08008000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC400, 0x1FFFF800}, - {0x448, "STM32F072xx" , 0x20001800, 0x20004000, 0x08000000, 0x08020000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC800, 0x1FFFF800}, - /* F1 */ - {0x412, "Low-density" , 0x20000200, 0x20002800, 0x08000000, 0x08008000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x410, "Medium-density" , 0x20000200, 0x20005000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x414, "High-density" , 0x20000200, 0x20010000, 0x08000000, 0x08080000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x420, "Medium-density VL" , 0x20000200, 0x20002000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x428, "High-density VL" , 0x20000200, 0x20008000, 0x08000000, 0x08080000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x418, "Connectivity line" , 0x20001000, 0x20010000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFB000, 0x1FFFF800}, - {0x430, "XL-density" , 0x20000800, 0x20018000, 0x08000000, 0x08100000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFE000, 0x1FFFF800}, - /* Note that F2 and F4 devices have sectors of different page sizes - and only the first sectors (of one page size) are included here */ - /* F2 */ - {0x411, "STM32F2xx" , 0x20002000, 0x20020000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77DF}, - /* F3 */ - {0x432, "STM32F373/8" , 0x20001400, 0x20008000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x422, "F302xB/303xB/358" , 0x20001400, 0x20010000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x439, "STM32F302x4(6/8)" , 0x20001800, 0x20004000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x438, "F303x4/334/328" , 0x20001800, 0x20003000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - /* F4 */ - {0x413, "STM32F40/1" , 0x20002000, 0x20020000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77DF}, - /* 0x419 is also used for STM32F429/39 but with other bootloader ID... */ - {0x419, "STM32F427/37" , 0x20002000, 0x20030000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - {0x423, "STM32F401xB(C)" , 0x20003000, 0x20010000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - {0x433, "STM32F401xD(E)" , 0x20003000, 0x20018000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - /* L0 */ - {0x417, "L05xxx/06xxx" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 32, 128, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - /* L1 */ - {0x416, "L1xxx6(8/B)" , 0x20000800, 0x20004000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - {0x429, "L1xxx6(8/B)A" , 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - {0x427, "L1xxxC" , 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF02000}, - {0x436, "L1xxxD" , 0x20001000, 0x2000C000, 0x08000000, 0x08060000, 16, 256, 0x1ff80000, 0x1ff8000F, 0x1FF00000, 0x1FF02000}, - {0x437, "L1xxxE" , 0x20001000, 0x20014000, 0x08000000, 0x08060000, 16, 256, 0x1ff80000, 0x1ff8000F, 0x1FF00000, 0x1FF02000}, - /* These are not (yet) in AN2606: */ - {0x641, "Medium_Density PL" , 0x20000200, 0x00005000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x9a8, "STM32W-128K" , 0x20000200, 0x20002000, 0x08000000, 0x08020000, 1, 1024, 0, 0, 0, 0}, - {0x9b0, "STM32W-256K" , 0x20000200, 0x20004000, 0x08000000, 0x08040000, 1, 2048, 0, 0, 0, 0}, - {0x0} -}; diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/gpl-2.0.txt b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/gpl-2.0.txt deleted file mode 100755 index d159169d1..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/gpl-2.0.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/i2c.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/i2c.c deleted file mode 100755 index 10e6bb15a..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/i2c.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - - -#if !defined(__linux__) - -static port_err_t i2c_open(struct port_interface *port, - struct port_options *ops) -{ - return PORT_ERR_NODEV; -} - -struct port_interface port_i2c = { - .name = "i2c", - .open = i2c_open, -}; - -#else - -#ifdef __ANDROID__ -#define I2C_SLAVE 0x0703 /* Use this slave address */ -#define I2C_FUNCS 0x0705 /* Get the adapter functionality mask */ -/* To determine what functionality is present */ -#define I2C_FUNC_I2C 0x00000001 -#else -#include -#include -#endif - -#include - -struct i2c_priv { - int fd; - int addr; -}; - -static port_err_t i2c_open(struct port_interface *port, - struct port_options *ops) -{ - struct i2c_priv *h; - int fd, addr, ret; - unsigned long funcs; - - /* 1. check device name match */ - if (strncmp(ops->device, "/dev/i2c-", strlen("/dev/i2c-"))) - return PORT_ERR_NODEV; - - /* 2. check options */ - addr = ops->bus_addr; - if (addr < 0x03 || addr > 0x77) { - fprintf(stderr, "I2C address out of range [0x03-0x77]\n"); - return PORT_ERR_UNKNOWN; - } - - /* 3. open it */ - h = calloc(sizeof(*h), 1); - if (h == NULL) { - fprintf(stderr, "End of memory\n"); - return PORT_ERR_UNKNOWN; - } - fd = open(ops->device, O_RDWR); - if (fd < 0) { - fprintf(stderr, "Unable to open special file \"%s\"\n", - ops->device); - free(h); - return PORT_ERR_UNKNOWN; - } - - /* 3.5. Check capabilities */ - ret = ioctl(fd, I2C_FUNCS, &funcs); - if (ret < 0) { - fprintf(stderr, "I2C ioctl(funcs) error %d\n", errno); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - if ((funcs & I2C_FUNC_I2C) == 0) { - fprintf(stderr, "Error: controller is not I2C, only SMBUS.\n"); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - - /* 4. set options */ - ret = ioctl(fd, I2C_SLAVE, addr); - if (ret < 0) { - fprintf(stderr, "I2C ioctl(slave) error %d\n", errno); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - - h->fd = fd; - h->addr = addr; - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t i2c_close(struct port_interface *port) -{ - struct i2c_priv *h; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - close(h->fd); - free(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t i2c_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - struct i2c_priv *h; - int ret; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - ret = read(h->fd, buf, nbyte); - if (ret != nbyte) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; -} - -static port_err_t i2c_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - struct i2c_priv *h; - int ret; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - ret = write(h->fd, buf, nbyte); - if (ret != nbyte) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; -} - -static port_err_t i2c_gpio(struct port_interface *port, serial_gpio_t n, - int level) -{ - return PORT_ERR_OK; -} - -static const char *i2c_get_cfg_str(struct port_interface *port) -{ - struct i2c_priv *h; - static char str[11]; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return "INVALID"; - snprintf(str, sizeof(str), "addr 0x%2x", h->addr); - return str; -} - -static struct varlen_cmd i2c_cmd_get_reply[] = { - {0x10, 11}, - {0x11, 17}, - {0x12, 18}, - { /* sentinel */ } -}; - -struct port_interface port_i2c = { - .name = "i2c", - .flags = PORT_STRETCH_W, - .open = i2c_open, - .close = i2c_close, - .read = i2c_read, - .write = i2c_write, - .gpio = i2c_gpio, - .cmd_get_reply = i2c_cmd_get_reply, - .get_cfg_str = i2c_get_cfg_str, -}; - -#endif diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/init.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/init.c deleted file mode 100755 index 77a571bd8..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/init.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include "init.h" -#include "serial.h" -#include "stm32.h" -#include "port.h" - -struct gpio_list { - struct gpio_list *next; - int gpio; -}; - - -static int write_to(const char *filename, const char *value) -{ - int fd, ret; - - fd = open(filename, O_WRONLY); - if (fd < 0) { - fprintf(stderr, "Cannot open file \"%s\"\n", filename); - return 0; - } - ret = write(fd, value, strlen(value)); - if (ret < 0) { - fprintf(stderr, "Error writing in file \"%s\"\n", filename); - close(fd); - return 0; - } - close(fd); - return 1; -} - -#if !defined(__linux__) -static int drive_gpio(int n, int level, struct gpio_list **gpio_to_release) -{ - fprintf(stderr, "GPIO control only available in Linux\n"); - return 0; -} -#else -static int drive_gpio(int n, int level, struct gpio_list **gpio_to_release) -{ - char num[16]; /* sized to carry MAX_INT */ - char file[48]; /* sized to carry longest filename */ - struct stat buf; - struct gpio_list *new; - int ret; - - sprintf(file, "/sys/class/gpio/gpio%d/direction", n); - ret = stat(file, &buf); - if (ret) { - /* file miss, GPIO not exported yet */ - sprintf(num, "%d", n); - ret = write_to("/sys/class/gpio/export", num); - if (!ret) - return 0; - ret = stat(file, &buf); - if (ret) { - fprintf(stderr, "GPIO %d not available\n", n); - return 0; - } - new = (struct gpio_list *)malloc(sizeof(struct gpio_list)); - if (new == NULL) { - fprintf(stderr, "Out of memory\n"); - return 0; - } - new->gpio = n; - new->next = *gpio_to_release; - *gpio_to_release = new; - } - - return write_to(file, level ? "high" : "low"); -} -#endif - -static int release_gpio(int n) -{ - char num[16]; /* sized to carry MAX_INT */ - - sprintf(num, "%d", n); - return write_to("/sys/class/gpio/unexport", num); -} - -static int gpio_sequence(struct port_interface *port, const char *s, size_t l) -{ - struct gpio_list *gpio_to_release = NULL, *to_free; - int ret, level, gpio; - - ret = 1; - while (ret == 1 && *s && l > 0) { - if (*s == '-') { - level = 0; - s++; - l--; - } else - level = 1; - - if (isdigit(*s)) { - gpio = atoi(s); - while (isdigit(*s)) { - s++; - l--; - } - } else if (!strncmp(s, "rts", 3)) { - gpio = -GPIO_RTS; - s += 3; - l -= 3; - } else if (!strncmp(s, "dtr", 3)) { - gpio = -GPIO_DTR; - s += 3; - l -= 3; - } else if (!strncmp(s, "brk", 3)) { - gpio = -GPIO_BRK; - s += 3; - l -= 3; - } else { - fprintf(stderr, "Character \'%c\' is not a digit\n", *s); - ret = 0; - break; - } - - if (*s && (l > 0)) { - if (*s == ',') { - s++; - l--; - } else { - fprintf(stderr, "Character \'%c\' is not a separator\n", *s); - ret = 0; - break; - } - } - if (gpio < 0) - ret = (port->gpio(port, -gpio, level) == PORT_ERR_OK); - else - ret = drive_gpio(gpio, level, &gpio_to_release); - usleep(100000); - } - - while (gpio_to_release) { - release_gpio(gpio_to_release->gpio); - to_free = gpio_to_release; - gpio_to_release = gpio_to_release->next; - free(to_free); - } - usleep(500000); - return ret; -} - -static int gpio_bl_entry(struct port_interface *port, const char *seq) -{ - char *s; - - if (seq == NULL || seq[0] == ':') - return 1; - - s = strchr(seq, ':'); - if (s == NULL) - return gpio_sequence(port, seq, strlen(seq)); - - return gpio_sequence(port, seq, s - seq); -} - -static int gpio_bl_exit(struct port_interface *port, const char *seq) -{ - char *s; - - if (seq == NULL) - return 1; - - s = strchr(seq, ':'); - if (s == NULL || s[1] == '\0') - return 1; - - return gpio_sequence(port, s + 1, strlen(s + 1)); -} - -int init_bl_entry(struct port_interface *port, const char *seq) -{ - if (seq) - return gpio_bl_entry(port, seq); - - return 1; -} - -int init_bl_exit(stm32_t *stm, struct port_interface *port, const char *seq) -{ - if (seq) - return gpio_bl_exit(port, seq); - - if (stm32_reset_device(stm) != STM32_ERR_OK) - return 0; - return 1; -} diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/init.h b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/init.h deleted file mode 100755 index 6075b519b..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/init.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _INIT_H -#define _INIT_H - -#include "stm32.h" -#include "port.h" - -int init_bl_entry(struct port_interface *port, const char *seq); -int init_bl_exit(stm32_t *stm, struct port_interface *port, const char *seq); - -#endif diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/main.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/main.c deleted file mode 100755 index f081d6131..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/main.c +++ /dev/null @@ -1,774 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright 2010 Geoffrey McRae - Copyright 2011 Steve Markgraf - Copyright 2012 Tormod Volden - Copyright 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "init.h" -#include "utils.h" -#include "serial.h" -#include "stm32.h" -#include "parsers/parser.h" -#include "port.h" - -#include "parsers/binary.h" -#include "parsers/hex.h" - -#define VERSION "Arduino_STM32_0.9" - -/* device globals */ -stm32_t *stm = NULL; - -void *p_st = NULL; -parser_t *parser = NULL; - -/* settings */ -struct port_options port_opts = { - .device = NULL, - .baudRate = SERIAL_BAUD_57600, - .serial_mode = "8e1", - .bus_addr = 0, - .rx_frame_max = STM32_MAX_RX_FRAME, - .tx_frame_max = STM32_MAX_TX_FRAME, -}; -int rd = 0; -int wr = 0; -int wu = 0; -int rp = 0; -int ur = 0; -int eraseOnly = 0; -int crc = 0; -int npages = 0; -int spage = 0; -int no_erase = 0; -char verify = 0; -int retry = 10; -char exec_flag = 0; -uint32_t execute = 0; -char init_flag = 1; -char force_binary = 0; -char reset_flag = 0; -char *filename; -char *gpio_seq = NULL; -uint32_t start_addr = 0; -uint32_t readwrite_len = 0; - -/* functions */ -int parse_options(int argc, char *argv[]); -void show_help(char *name); - -static int is_addr_in_ram(uint32_t addr) -{ - return addr >= stm->dev->ram_start && addr < stm->dev->ram_end; -} - -static int is_addr_in_flash(uint32_t addr) -{ - return addr >= stm->dev->fl_start && addr < stm->dev->fl_end; -} - -static int flash_addr_to_page_floor(uint32_t addr) -{ - if (!is_addr_in_flash(addr)) - return 0; - - return (addr - stm->dev->fl_start) / stm->dev->fl_ps; -} - -static int flash_addr_to_page_ceil(uint32_t addr) -{ - if (!(addr >= stm->dev->fl_start && addr <= stm->dev->fl_end)) - return 0; - - return (addr + stm->dev->fl_ps - 1 - stm->dev->fl_start) - / stm->dev->fl_ps; -} - -static uint32_t flash_page_to_addr(int page) -{ - return stm->dev->fl_start + page * stm->dev->fl_ps; -} - -int main(int argc, char* argv[]) { - struct port_interface *port = NULL; - int ret = 1; - stm32_err_t s_err; - parser_err_t perr; - FILE *diag = stdout; - - fprintf(diag, "stm32flash " VERSION "\n\n"); - fprintf(diag, "http://github.com/rogerclarkmelbourne/arduino_stm32\n\n"); - if (parse_options(argc, argv) != 0) - goto close; - - if (rd && filename[0] == '-') { - diag = stderr; - } - - if (wr) { - /* first try hex */ - if (!force_binary) { - parser = &PARSER_HEX; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - } - - if (force_binary || (perr = parser->open(p_st, filename, 0)) != PARSER_ERR_OK) { - if (force_binary || perr == PARSER_ERR_INVALID_FILE) { - if (!force_binary) { - parser->close(p_st); - p_st = NULL; - } - - /* now try binary */ - parser = &PARSER_BINARY; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - perr = parser->open(p_st, filename, 0); - } - - /* if still have an error, fail */ - if (perr != PARSER_ERR_OK) { - fprintf(stderr, "%s ERROR: %s\n", parser->name, parser_errstr(perr)); - if (perr == PARSER_ERR_SYSTEM) perror(filename); - goto close; - } - } - - fprintf(diag, "Using Parser : %s\n", parser->name); - } else { - parser = &PARSER_BINARY; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - } - - if (port_open(&port_opts, &port) != PORT_ERR_OK) { - fprintf(stderr, "Failed to open port: %s\n", port_opts.device); - goto close; - } - - fprintf(diag, "Interface %s: %s\n", port->name, port->get_cfg_str(port)); - if (init_flag && init_bl_entry(port, gpio_seq) == 0) - goto close; - stm = stm32_init(port, init_flag); - if (!stm) - goto close; - - fprintf(diag, "Version : 0x%02x\n", stm->bl_version); - if (port->flags & PORT_GVR_ETX) { - fprintf(diag, "Option 1 : 0x%02x\n", stm->option1); - fprintf(diag, "Option 2 : 0x%02x\n", stm->option2); - } - fprintf(diag, "Device ID : 0x%04x (%s)\n", stm->pid, stm->dev->name); - fprintf(diag, "- RAM : %dKiB (%db reserved by bootloader)\n", (stm->dev->ram_end - 0x20000000) / 1024, stm->dev->ram_start - 0x20000000); - fprintf(diag, "- Flash : %dKiB (sector size: %dx%d)\n", (stm->dev->fl_end - stm->dev->fl_start ) / 1024, stm->dev->fl_pps, stm->dev->fl_ps); - fprintf(diag, "- Option RAM : %db\n", stm->dev->opt_end - stm->dev->opt_start + 1); - fprintf(diag, "- System RAM : %dKiB\n", (stm->dev->mem_end - stm->dev->mem_start) / 1024); - - uint8_t buffer[256]; - uint32_t addr, start, end; - unsigned int len; - int failed = 0; - int first_page, num_pages; - - /* - * Cleanup addresses: - * - * Starting from options - * start_addr, readwrite_len, spage, npages - * and using device memory size, compute - * start, end, first_page, num_pages - */ - if (start_addr || readwrite_len) { - start = start_addr; - - if (is_addr_in_flash(start)) - end = stm->dev->fl_end; - else { - no_erase = 1; - if (is_addr_in_ram(start)) - end = stm->dev->ram_end; - else - end = start + sizeof(uint32_t); - } - - if (readwrite_len && (end > start + readwrite_len)) - end = start + readwrite_len; - - first_page = flash_addr_to_page_floor(start); - if (!first_page && end == stm->dev->fl_end) - num_pages = 0xff; /* mass erase */ - else - num_pages = flash_addr_to_page_ceil(end) - first_page; - } else if (!spage && !npages) { - start = stm->dev->fl_start; - end = stm->dev->fl_end; - first_page = 0; - num_pages = 0xff; /* mass erase */ - } else { - first_page = spage; - start = flash_page_to_addr(first_page); - if (start > stm->dev->fl_end) { - fprintf(stderr, "Address range exceeds flash size.\n"); - goto close; - } - - if (npages) { - num_pages = npages; - end = flash_page_to_addr(first_page + num_pages); - if (end > stm->dev->fl_end) - end = stm->dev->fl_end; - } else { - end = stm->dev->fl_end; - num_pages = flash_addr_to_page_ceil(end) - first_page; - } - - if (!first_page && end == stm->dev->fl_end) - num_pages = 0xff; /* mass erase */ - } - - if (rd) { - unsigned int max_len = port_opts.rx_frame_max; - - fprintf(diag, "Memory read\n"); - - perr = parser->open(p_st, filename, 1); - if (perr != PARSER_ERR_OK) { - fprintf(stderr, "%s ERROR: %s\n", parser->name, parser_errstr(perr)); - if (perr == PARSER_ERR_SYSTEM) - perror(filename); - goto close; - } - - fflush(diag); - addr = start; - while(addr < end) { - uint32_t left = end - addr; - len = max_len > left ? left : max_len; - s_err = stm32_read_memory(stm, addr, buffer, len); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read memory at address 0x%08x, target write-protected?\n", addr); - goto close; - } - if (parser->write(p_st, buffer, len) != PARSER_ERR_OK) - { - fprintf(stderr, "Failed to write data to file\n"); - goto close; - } - addr += len; - - fprintf(diag, - "\rRead address 0x%08x (%.2f%%) ", - addr, - (100.0f / (float)(end - start)) * (float)(addr - start) - ); - fflush(diag); - } - fprintf(diag, "Done.\n"); - ret = 0; - goto close; - } else if (rp) { - fprintf(stdout, "Read-Protecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_readprot_memory(stm); - fprintf(stdout, "Done.\n"); - } else if (ur) { - fprintf(stdout, "Read-UnProtecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_runprot_memory(stm); - fprintf(stdout, "Done.\n"); - } else if (eraseOnly) { - ret = 0; - fprintf(stdout, "Erasing flash\n"); - - if (num_pages != 0xff && - (start != flash_page_to_addr(first_page) - || end != flash_page_to_addr(first_page + num_pages))) { - fprintf(stderr, "Specified start & length are invalid (must be page aligned)\n"); - ret = 1; - goto close; - } - - s_err = stm32_erase_memory(stm, first_page, num_pages); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to erase memory\n"); - ret = 1; - goto close; - } - } else if (wu) { - fprintf(diag, "Write-unprotecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_wunprot_memory(stm); - fprintf(diag, "Done.\n"); - - } else if (wr) { - fprintf(diag, "Write to memory\n"); - - off_t offset = 0; - ssize_t r; - unsigned int size; - unsigned int max_wlen, max_rlen; - - max_wlen = port_opts.tx_frame_max - 2; /* skip len and crc */ - max_wlen &= ~3; /* 32 bit aligned */ - - max_rlen = port_opts.rx_frame_max; - max_rlen = max_rlen < max_wlen ? max_rlen : max_wlen; - - /* Assume data from stdin is whole device */ - if (filename[0] == '-' && filename[1] == '\0') - size = end - start; - else - size = parser->size(p_st); - - // TODO: It is possible to write to non-page boundaries, by reading out flash - // from partial pages and combining with the input data - // if ((start % stm->dev->fl_ps) != 0 || (end % stm->dev->fl_ps) != 0) { - // fprintf(stderr, "Specified start & length are invalid (must be page aligned)\n"); - // goto close; - // } - - // TODO: If writes are not page aligned, we should probably read out existing flash - // contents first, so it can be preserved and combined with new data - if (!no_erase && num_pages) { - fprintf(diag, "Erasing memory\n"); - s_err = stm32_erase_memory(stm, first_page, num_pages); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to erase memory\n"); - goto close; - } - } - - fflush(diag); - addr = start; - while(addr < end && offset < size) { - uint32_t left = end - addr; - len = max_wlen > left ? left : max_wlen; - len = len > size - offset ? size - offset : len; - - if (parser->read(p_st, buffer, &len) != PARSER_ERR_OK) - goto close; - - if (len == 0) { - if (filename[0] == '-') { - break; - } else { - fprintf(stderr, "Failed to read input file\n"); - goto close; - } - } - - again: - s_err = stm32_write_memory(stm, addr, buffer, len); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to write memory at address 0x%08x\n", addr); - goto close; - } - - if (verify) { - uint8_t compare[len]; - unsigned int offset, rlen; - - offset = 0; - while (offset < len) { - rlen = len - offset; - rlen = rlen < max_rlen ? rlen : max_rlen; - s_err = stm32_read_memory(stm, addr + offset, compare + offset, rlen); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read memory at address 0x%08x\n", addr + offset); - goto close; - } - offset += rlen; - } - - for(r = 0; r < len; ++r) - if (buffer[r] != compare[r]) { - if (failed == retry) { - fprintf(stderr, "Failed to verify at address 0x%08x, expected 0x%02x and found 0x%02x\n", - (uint32_t)(addr + r), - buffer [r], - compare[r] - ); - goto close; - } - ++failed; - goto again; - } - - failed = 0; - } - - addr += len; - offset += len; - - fprintf(diag, - "\rWrote %saddress 0x%08x (%.2f%%) ", - verify ? "and verified " : "", - addr, - (100.0f / size) * offset - ); - fflush(diag); - - } - - fprintf(diag, "Done.\n"); - ret = 0; - goto close; - } else if (crc) { - uint32_t crc_val = 0; - - fprintf(diag, "CRC computation\n"); - - s_err = stm32_crc_wrapper(stm, start, end - start, &crc_val); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read CRC\n"); - goto close; - } - fprintf(diag, "CRC(0x%08x-0x%08x) = 0x%08x\n", start, end, - crc_val); - ret = 0; - goto close; - } else - ret = 0; - -close: - if (stm && exec_flag && ret == 0) { - if (execute == 0) - execute = stm->dev->fl_start; - - fprintf(diag, "\nStarting execution at address 0x%08x... ", execute); - fflush(diag); - if (stm32_go(stm, execute) == STM32_ERR_OK) { - reset_flag = 0; - fprintf(diag, "done.\n"); - } else - fprintf(diag, "failed.\n"); - } - - if (stm && reset_flag) { - fprintf(diag, "\nResetting device... "); - fflush(diag); - if (init_bl_exit(stm, port, gpio_seq)) - fprintf(diag, "done.\n"); - else fprintf(diag, "failed.\n"); - } - - if (p_st ) parser->close(p_st); - if (stm ) stm32_close (stm); - if (port) - port->close(port); - - fprintf(diag, "\n"); - return ret; -} - -int parse_options(int argc, char *argv[]) -{ - int c; - char *pLen; - - while ((c = getopt(argc, argv, "a:b:m:r:w:e:vn:g:jkfcChuos:S:F:i:R")) != -1) { - switch(c) { - case 'a': - port_opts.bus_addr = strtoul(optarg, NULL, 0); - break; - - case 'b': - port_opts.baudRate = serial_get_baud(strtoul(optarg, NULL, 0)); - if (port_opts.baudRate == SERIAL_BAUD_INVALID) { - serial_baud_t baudrate; - fprintf(stderr, "Invalid baud rate, valid options are:\n"); - for (baudrate = SERIAL_BAUD_1200; baudrate != SERIAL_BAUD_INVALID; ++baudrate) - fprintf(stderr, " %d\n", serial_get_baud_int(baudrate)); - return 1; - } - break; - - case 'm': - if (strlen(optarg) != 3 - || serial_get_bits(optarg) == SERIAL_BITS_INVALID - || serial_get_parity(optarg) == SERIAL_PARITY_INVALID - || serial_get_stopbit(optarg) == SERIAL_STOPBIT_INVALID) { - fprintf(stderr, "Invalid serial mode\n"); - return 1; - } - port_opts.serial_mode = optarg; - break; - - case 'r': - case 'w': - rd = rd || c == 'r'; - wr = wr || c == 'w'; - if (rd && wr) { - fprintf(stderr, "ERROR: Invalid options, can't read & write at the same time\n"); - return 1; - } - filename = optarg; - if (filename[0] == '-') { - force_binary = 1; - } - break; - case 'e': - if (readwrite_len || start_addr) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } - npages = strtoul(optarg, NULL, 0); - if (npages > 0xFF || npages < 0) { - fprintf(stderr, "ERROR: You need to specify a page count between 0 and 255"); - return 1; - } - if (!npages) - no_erase = 1; - break; - case 'u': - wu = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't write unprotect and read/write at the same time\n"); - return 1; - } - break; - - case 'j': - rp = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't read protect and read/write at the same time\n"); - return 1; - } - break; - - case 'k': - ur = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't read unprotect and read/write at the same time\n"); - return 1; - } - break; - - case 'o': - eraseOnly = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't erase-only and read/write at the same time\n"); - return 1; - } - break; - - case 'v': - verify = 1; - break; - - case 'n': - retry = strtoul(optarg, NULL, 0); - break; - - case 'g': - exec_flag = 1; - execute = strtoul(optarg, NULL, 0); - if (execute % 4 != 0) { - fprintf(stderr, "ERROR: Execution address must be word-aligned\n"); - return 1; - } - break; - case 's': - if (readwrite_len || start_addr) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } - spage = strtoul(optarg, NULL, 0); - break; - case 'S': - if (spage || npages) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } else { - start_addr = strtoul(optarg, &pLen, 0); - if (*pLen == ':') { - pLen++; - readwrite_len = strtoul(pLen, NULL, 0); - if (readwrite_len == 0) { - fprintf(stderr, "ERROR: Invalid options, can't specify zero length\n"); - return 1; - } - } - } - break; - case 'F': - port_opts.rx_frame_max = strtoul(optarg, &pLen, 0); - if (*pLen == ':') { - pLen++; - port_opts.tx_frame_max = strtoul(pLen, NULL, 0); - } - if (port_opts.rx_frame_max < 0 - || port_opts.tx_frame_max < 0) { - fprintf(stderr, "ERROR: Invalid negative value for option -F\n"); - return 1; - } - if (port_opts.rx_frame_max == 0) - port_opts.rx_frame_max = STM32_MAX_RX_FRAME; - if (port_opts.tx_frame_max == 0) - port_opts.tx_frame_max = STM32_MAX_TX_FRAME; - if (port_opts.rx_frame_max < 20 - || port_opts.tx_frame_max < 5) { - fprintf(stderr, "ERROR: current code cannot work with small frames.\n"); - fprintf(stderr, "min(RX) = 20, min(TX) = 5\n"); - return 1; - } - if (port_opts.rx_frame_max > STM32_MAX_RX_FRAME) { - fprintf(stderr, "WARNING: Ignore RX length in option -F\n"); - port_opts.rx_frame_max = STM32_MAX_RX_FRAME; - } - if (port_opts.tx_frame_max > STM32_MAX_TX_FRAME) { - fprintf(stderr, "WARNING: Ignore TX length in option -F\n"); - port_opts.tx_frame_max = STM32_MAX_TX_FRAME; - } - break; - case 'f': - force_binary = 1; - break; - - case 'c': - init_flag = 0; - break; - - case 'h': - show_help(argv[0]); - exit(0); - - case 'i': - gpio_seq = optarg; - break; - - case 'R': - reset_flag = 1; - break; - - case 'C': - crc = 1; - break; - } - } - - for (c = optind; c < argc; ++c) { - if (port_opts.device) { - fprintf(stderr, "ERROR: Invalid parameter specified\n"); - show_help(argv[0]); - return 1; - } - port_opts.device = argv[c]; - } - - if (port_opts.device == NULL) { - fprintf(stderr, "ERROR: Device not specified\n"); - show_help(argv[0]); - return 1; - } - - if (!wr && verify) { - fprintf(stderr, "ERROR: Invalid usage, -v is only valid when writing\n"); - show_help(argv[0]); - return 1; - } - - return 0; -} - -void show_help(char *name) { - fprintf(stderr, - "Usage: %s [-bvngfhc] [-[rw] filename] [tty_device | i2c_device]\n" - " -a bus_address Bus address (e.g. for I2C port)\n" - " -b rate Baud rate (default 57600)\n" - " -m mode Serial port mode (default 8e1)\n" - " -r filename Read flash to file (or - stdout)\n" - " -w filename Write flash from file (or - stdout)\n" - " -C Compute CRC of flash content\n" - " -u Disable the flash write-protection\n" - " -j Enable the flash read-protection\n" - " -k Disable the flash read-protection\n" - " -o Erase only\n" - " -e n Only erase n pages before writing the flash\n" - " -v Verify writes\n" - " -n count Retry failed writes up to count times (default 10)\n" - " -g address Start execution at specified address (0 = flash start)\n" - " -S address[:length] Specify start address and optionally length for\n" - " read/write/erase operations\n" - " -F RX_length[:TX_length] Specify the max length of RX and TX frame\n" - " -s start_page Flash at specified page (0 = flash start)\n" - " -f Force binary parser\n" - " -h Show this help\n" - " -c Resume the connection (don't send initial INIT)\n" - " *Baud rate must be kept the same as the first init*\n" - " This is useful if the reset fails\n" - " -i GPIO_string GPIO sequence to enter/exit bootloader mode\n" - " GPIO_string=[entry_seq][:[exit_seq]]\n" - " sequence=[-]n[,sequence]\n" - " -R Reset device at exit.\n" - "\n" - "Examples:\n" - " Get device information:\n" - " %s /dev/ttyS0\n" - " or:\n" - " %s /dev/i2c-0\n" - "\n" - " Write with verify and then start execution:\n" - " %s -w filename -v -g 0x0 /dev/ttyS0\n" - "\n" - " Read flash to file:\n" - " %s -r filename /dev/ttyS0\n" - "\n" - " Read 100 bytes of flash from 0x1000 to stdout:\n" - " %s -r - -S 0x1000:100 /dev/ttyS0\n" - "\n" - " Start execution:\n" - " %s -g 0x0 /dev/ttyS0\n" - "\n" - " GPIO sequence:\n" - " - entry sequence: GPIO_3=low, GPIO_2=low, GPIO_2=high\n" - " - exit sequence: GPIO_3=high, GPIO_2=low, GPIO_2=high\n" - " %s -i -3,-2,2:3,-2,2 /dev/ttyS0\n", - name, - name, - name, - name, - name, - name, - name, - name - ); -} - diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/Android.mk b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/Android.mk deleted file mode 100755 index afec18cd5..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := libparsers -LOCAL_SRC_FILES := binary.c hex.c -include $(BUILD_STATIC_LIBRARY) diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/Makefile b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/Makefile deleted file mode 100755 index bb7df1e02..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -CFLAGS += -Wall -g - -all: parsers.a - -parsers.a: binary.o hex.o - $(AR) rc $@ binary.o hex.o - -clean: - rm -f *.o parsers.a - -.PHONY: all clean diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/binary.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/binary.c deleted file mode 100755 index f491952bb..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/binary.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include - -#include "binary.h" - -typedef struct { - int fd; - char write; - struct stat stat; -} binary_t; - -void* binary_init() { - return calloc(sizeof(binary_t), 1); -} - -parser_err_t binary_open(void *storage, const char *filename, const char write) { - binary_t *st = storage; - if (write) { - if (filename[0] == '-') - st->fd = 1; - else - st->fd = open( - filename, -#ifndef __WIN32__ - O_WRONLY | O_CREAT | O_TRUNC, -#else - O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, -#endif -#ifndef __WIN32__ - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#else - 0 -#endif - ); - st->stat.st_size = 0; - } else { - if (filename[0] == '-') { - st->fd = 0; - } else { - if (stat(filename, &st->stat) != 0) - return PARSER_ERR_INVALID_FILE; - st->fd = open(filename, -#ifndef __WIN32__ - O_RDONLY -#else - O_RDONLY | O_BINARY -#endif - ); - } - } - - st->write = write; - return st->fd == -1 ? PARSER_ERR_SYSTEM : PARSER_ERR_OK; -} - -parser_err_t binary_close(void *storage) { - binary_t *st = storage; - - if (st->fd) close(st->fd); - free(st); - return PARSER_ERR_OK; -} - -unsigned int binary_size(void *storage) { - binary_t *st = storage; - return st->stat.st_size; -} - -parser_err_t binary_read(void *storage, void *data, unsigned int *len) { - binary_t *st = storage; - unsigned int left = *len; - if (st->write) return PARSER_ERR_WRONLY; - - ssize_t r; - while(left > 0) { - r = read(st->fd, data, left); - /* If there is no data to read at all, return OK, but with zero read */ - if (r == 0 && left == *len) { - *len = 0; - return PARSER_ERR_OK; - } - if (r <= 0) return PARSER_ERR_SYSTEM; - left -= r; - data += r; - } - - *len = *len - left; - return PARSER_ERR_OK; -} - -parser_err_t binary_write(void *storage, void *data, unsigned int len) { - binary_t *st = storage; - if (!st->write) return PARSER_ERR_RDONLY; - - ssize_t r; - while(len > 0) { - r = write(st->fd, data, len); - if (r < 1) return PARSER_ERR_SYSTEM; - st->stat.st_size += r; - - len -= r; - data += r; - } - - return PARSER_ERR_OK; -} - -parser_t PARSER_BINARY = { - "Raw BINARY", - binary_init, - binary_open, - binary_close, - binary_size, - binary_read, - binary_write -}; - diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/binary.h b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/binary.h deleted file mode 100755 index d989acfa0..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/binary.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _PARSER_BINARY_H -#define _PARSER_BINARY_H - -#include "parser.h" - -extern parser_t PARSER_BINARY; -#endif diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/hex.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/hex.c deleted file mode 100755 index 3baf85623..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/hex.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include - -#include "hex.h" -#include "../utils.h" - -typedef struct { - size_t data_len, offset; - uint8_t *data; - uint8_t base; -} hex_t; - -void* hex_init() { - return calloc(sizeof(hex_t), 1); -} - -parser_err_t hex_open(void *storage, const char *filename, const char write) { - hex_t *st = storage; - if (write) { - return PARSER_ERR_RDONLY; - } else { - char mark; - int i, fd; - uint8_t checksum; - unsigned int c; - uint32_t base = 0; - unsigned int last_address = 0x0; - - fd = open(filename, O_RDONLY); - if (fd < 0) - return PARSER_ERR_SYSTEM; - - /* read in the file */ - - while(read(fd, &mark, 1) != 0) { - if (mark == '\n' || mark == '\r') continue; - if (mark != ':') - return PARSER_ERR_INVALID_FILE; - - char buffer[9]; - unsigned int reclen, address, type; - uint8_t *record = NULL; - - /* get the reclen, address, and type */ - buffer[8] = 0; - if (read(fd, &buffer, 8) != 8) return PARSER_ERR_INVALID_FILE; - if (sscanf(buffer, "%2x%4x%2x", &reclen, &address, &type) != 3) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* setup the checksum */ - checksum = - reclen + - ((address & 0xFF00) >> 8) + - ((address & 0x00FF) >> 0) + - type; - - switch(type) { - /* data record */ - case 0: - c = address - last_address; - st->data = realloc(st->data, st->data_len + c + reclen); - - /* if there is a gap, set it to 0xff and increment the length */ - if (c > 0) { - memset(&st->data[st->data_len], 0xff, c); - st->data_len += c; - } - - last_address = address + reclen; - record = &st->data[st->data_len]; - st->data_len += reclen; - break; - - /* extended segment address record */ - case 2: - base = 0; - break; - - /* extended linear address record */ - case 4: - base = address; - break; - } - - buffer[2] = 0; - for(i = 0; i < reclen; ++i) { - if (read(fd, &buffer, 2) != 2 || sscanf(buffer, "%2x", &c) != 1) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* add the byte to the checksum */ - checksum += c; - - switch(type) { - case 0: - if (record != NULL) { - record[i] = c; - } else { - return PARSER_ERR_INVALID_FILE; - } - break; - - case 2: - case 4: - base = (base << 8) | c; - break; - } - } - - /* read, scan, and verify the checksum */ - if ( - read(fd, &buffer, 2 ) != 2 || - sscanf(buffer, "%2x", &c) != 1 || - (uint8_t)(checksum + c) != 0x00 - ) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - switch(type) { - /* EOF */ - case 1: - close(fd); - return PARSER_ERR_OK; - - /* address record */ - case 2: base = base << 4; - case 4: base = be_u32(base); - /* Reset last_address since our base changed */ - last_address = 0; - - if (st->base == 0) { - st->base = base; - break; - } - - /* we cant cope with files out of order */ - if (base < st->base) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* if there is a gap, enlarge and fill with zeros */ - unsigned int len = base - st->base; - if (len > st->data_len) { - st->data = realloc(st->data, len); - memset(&st->data[st->data_len], 0, len - st->data_len); - st->data_len = len; - } - break; - } - } - - close(fd); - return PARSER_ERR_OK; - } -} - -parser_err_t hex_close(void *storage) { - hex_t *st = storage; - if (st) free(st->data); - free(st); - return PARSER_ERR_OK; -} - -unsigned int hex_size(void *storage) { - hex_t *st = storage; - return st->data_len; -} - -parser_err_t hex_read(void *storage, void *data, unsigned int *len) { - hex_t *st = storage; - unsigned int left = st->data_len - st->offset; - unsigned int get = left > *len ? *len : left; - - memcpy(data, &st->data[st->offset], get); - st->offset += get; - - *len = get; - return PARSER_ERR_OK; -} - -parser_err_t hex_write(void *storage, void *data, unsigned int len) { - return PARSER_ERR_RDONLY; -} - -parser_t PARSER_HEX = { - "Intel HEX", - hex_init, - hex_open, - hex_close, - hex_size, - hex_read, - hex_write -}; - diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/hex.h b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/hex.h deleted file mode 100755 index 02413c9c9..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/hex.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _PARSER_HEX_H -#define _PARSER_HEX_H - -#include "parser.h" - -extern parser_t PARSER_HEX; -#endif diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/parser.h b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/parser.h deleted file mode 100755 index c2fae3cf8..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/parsers/parser.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_PARSER -#define _H_PARSER - -enum parser_err { - PARSER_ERR_OK, - PARSER_ERR_SYSTEM, - PARSER_ERR_INVALID_FILE, - PARSER_ERR_WRONLY, - PARSER_ERR_RDONLY -}; -typedef enum parser_err parser_err_t; - -struct parser { - const char *name; - void* (*init )(); /* initialise the parser */ - parser_err_t (*open )(void *storage, const char *filename, const char write); /* open the file for read|write */ - parser_err_t (*close)(void *storage); /* close and free the parser */ - unsigned int (*size )(void *storage); /* get the total data size */ - parser_err_t (*read )(void *storage, void *data, unsigned int *len); /* read a block of data */ - parser_err_t (*write)(void *storage, void *data, unsigned int len); /* write a block of data */ -}; -typedef struct parser parser_t; - -static inline const char* parser_errstr(parser_err_t err) { - switch(err) { - case PARSER_ERR_OK : return "OK"; - case PARSER_ERR_SYSTEM : return "System Error"; - case PARSER_ERR_INVALID_FILE: return "Invalid File"; - case PARSER_ERR_WRONLY : return "Parser can only write"; - case PARSER_ERR_RDONLY : return "Parser can only read"; - default: - return "Unknown Error"; - } -} - -#endif diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/port.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/port.c deleted file mode 100755 index 08e58cc34..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/port.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include "serial.h" -#include "port.h" - - -extern struct port_interface port_serial; -extern struct port_interface port_i2c; - -static struct port_interface *ports[] = { - &port_serial, - &port_i2c, - NULL, -}; - - -port_err_t port_open(struct port_options *ops, struct port_interface **outport) -{ - int ret; - static struct port_interface **port; - - for (port = ports; *port; port++) { - ret = (*port)->open(*port, ops); - if (ret == PORT_ERR_NODEV) - continue; - if (ret == PORT_ERR_OK) - break; - fprintf(stderr, "Error probing interface \"%s\"\n", - (*port)->name); - } - if (*port == NULL) { - fprintf(stderr, "Cannot handle device \"%s\"\n", - ops->device); - return PORT_ERR_UNKNOWN; - } - - *outport = *port; - return PORT_ERR_OK; -} diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/port.h b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/port.h deleted file mode 100755 index 290f03496..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/port.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_PORT -#define _H_PORT - -typedef enum { - PORT_ERR_OK = 0, - PORT_ERR_NODEV, /* No such device */ - PORT_ERR_TIMEDOUT, /* Operation timed out */ - PORT_ERR_UNKNOWN, -} port_err_t; - -/* flags */ -#define PORT_BYTE (1 << 0) /* byte (not frame) oriented */ -#define PORT_GVR_ETX (1 << 1) /* cmd GVR returns protection status */ -#define PORT_CMD_INIT (1 << 2) /* use INIT cmd to autodetect speed */ -#define PORT_RETRY (1 << 3) /* allowed read() retry after timeout */ -#define PORT_STRETCH_W (1 << 4) /* warning for no-stretching commands */ - -/* all options and flags used to open and configure an interface */ -struct port_options { - const char *device; - serial_baud_t baudRate; - const char *serial_mode; - int bus_addr; - int rx_frame_max; - int tx_frame_max; -}; - -/* - * Specify the length of reply for command GET - * This is helpful for frame-oriented protocols, e.g. i2c, to avoid time - * consuming try-fail-timeout-retry operation. - * On byte-oriented protocols, i.e. UART, this information would be skipped - * after read the first byte, so not needed. - */ -struct varlen_cmd { - uint8_t version; - uint8_t length; -}; - -struct port_interface { - const char *name; - unsigned flags; - port_err_t (*open)(struct port_interface *port, struct port_options *ops); - port_err_t (*close)(struct port_interface *port); - port_err_t (*read)(struct port_interface *port, void *buf, size_t nbyte); - port_err_t (*write)(struct port_interface *port, void *buf, size_t nbyte); - port_err_t (*gpio)(struct port_interface *port, serial_gpio_t n, int level); - const char *(*get_cfg_str)(struct port_interface *port); - struct varlen_cmd *cmd_get_reply; - void *private; -}; - -port_err_t port_open(struct port_options *ops, struct port_interface **outport); - -#endif diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/protocol.txt b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/protocol.txt deleted file mode 100755 index 039109908..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/protocol.txt +++ /dev/null @@ -1,19 +0,0 @@ -The communication protocol used by ST bootloader is documented in following ST -application notes, depending on communication port. - -In current version of stm32flash are supported only UART and I2C ports. - -* AN3154: CAN protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/CD00264321.pdf - -* AN3155: USART protocol used in the STM32(TM) bootloader - http://www.st.com/web/en/resource/technical/document/application_note/CD00264342.pdf - -* AN4221: I2C protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/DM00072315.pdf - -* AN4286: SPI protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/DM00081379.pdf - -Boot mode selection for STM32 is documented in ST application note AN2606, available in ST website: - http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial.h b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial.h deleted file mode 100755 index 227ba163b..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _SERIAL_H -#define _SERIAL_H - -typedef struct serial serial_t; - -typedef enum { - SERIAL_PARITY_NONE, - SERIAL_PARITY_EVEN, - SERIAL_PARITY_ODD, - - SERIAL_PARITY_INVALID -} serial_parity_t; - -typedef enum { - SERIAL_BITS_5, - SERIAL_BITS_6, - SERIAL_BITS_7, - SERIAL_BITS_8, - - SERIAL_BITS_INVALID -} serial_bits_t; - -typedef enum { - SERIAL_BAUD_1200, - SERIAL_BAUD_1800, - SERIAL_BAUD_2400, - SERIAL_BAUD_4800, - SERIAL_BAUD_9600, - SERIAL_BAUD_19200, - SERIAL_BAUD_38400, - SERIAL_BAUD_57600, - SERIAL_BAUD_115200, - SERIAL_BAUD_128000, - SERIAL_BAUD_230400, - SERIAL_BAUD_256000, - SERIAL_BAUD_460800, - SERIAL_BAUD_500000, - SERIAL_BAUD_576000, - SERIAL_BAUD_921600, - SERIAL_BAUD_1000000, - SERIAL_BAUD_1500000, - SERIAL_BAUD_2000000, - - SERIAL_BAUD_INVALID -} serial_baud_t; - -typedef enum { - SERIAL_STOPBIT_1, - SERIAL_STOPBIT_2, - - SERIAL_STOPBIT_INVALID -} serial_stopbit_t; - -typedef enum { - GPIO_RTS = 1, - GPIO_DTR, - GPIO_BRK, -} serial_gpio_t; - -/* common helper functions */ -serial_baud_t serial_get_baud(const unsigned int baud); -unsigned int serial_get_baud_int(const serial_baud_t baud); -serial_bits_t serial_get_bits(const char *mode); -unsigned int serial_get_bits_int(const serial_bits_t bits); -serial_parity_t serial_get_parity(const char *mode); -char serial_get_parity_str(const serial_parity_t parity); -serial_stopbit_t serial_get_stopbit(const char *mode); -unsigned int serial_get_stopbit_int(const serial_stopbit_t stopbit); - -#endif diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_common.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_common.c deleted file mode 100755 index 43e48e1ac..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_common.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "serial.h" - -serial_baud_t serial_get_baud(const unsigned int baud) { - switch(baud) { - case 1200: return SERIAL_BAUD_1200 ; - case 1800: return SERIAL_BAUD_1800 ; - case 2400: return SERIAL_BAUD_2400 ; - case 4800: return SERIAL_BAUD_4800 ; - case 9600: return SERIAL_BAUD_9600 ; - case 19200: return SERIAL_BAUD_19200 ; - case 38400: return SERIAL_BAUD_38400 ; - case 57600: return SERIAL_BAUD_57600 ; - case 115200: return SERIAL_BAUD_115200; - case 128000: return SERIAL_BAUD_128000; - case 230400: return SERIAL_BAUD_230400; - case 256000: return SERIAL_BAUD_256000; - case 460800: return SERIAL_BAUD_460800; - case 500000: return SERIAL_BAUD_500000; - case 576000: return SERIAL_BAUD_576000; - case 921600: return SERIAL_BAUD_921600; - case 1000000: return SERIAL_BAUD_1000000; - case 1500000: return SERIAL_BAUD_1500000; - case 2000000: return SERIAL_BAUD_2000000; - - default: - return SERIAL_BAUD_INVALID; - } -} - -unsigned int serial_get_baud_int(const serial_baud_t baud) { - switch(baud) { - case SERIAL_BAUD_1200 : return 1200 ; - case SERIAL_BAUD_1800 : return 1800 ; - case SERIAL_BAUD_2400 : return 2400 ; - case SERIAL_BAUD_4800 : return 4800 ; - case SERIAL_BAUD_9600 : return 9600 ; - case SERIAL_BAUD_19200 : return 19200 ; - case SERIAL_BAUD_38400 : return 38400 ; - case SERIAL_BAUD_57600 : return 57600 ; - case SERIAL_BAUD_115200: return 115200; - case SERIAL_BAUD_128000: return 128000; - case SERIAL_BAUD_230400: return 230400; - case SERIAL_BAUD_256000: return 256000; - case SERIAL_BAUD_460800: return 460800; - case SERIAL_BAUD_500000: return 500000; - case SERIAL_BAUD_576000: return 576000; - case SERIAL_BAUD_921600: return 921600; - case SERIAL_BAUD_1000000: return 1000000; - case SERIAL_BAUD_1500000: return 1500000; - case SERIAL_BAUD_2000000: return 2000000; - - case SERIAL_BAUD_INVALID: - default: - return 0; - } -} - -serial_bits_t serial_get_bits(const char *mode) { - if (!mode) - return SERIAL_BITS_INVALID; - switch(mode[0]) { - case '5': return SERIAL_BITS_5; - case '6': return SERIAL_BITS_6; - case '7': return SERIAL_BITS_7; - case '8': return SERIAL_BITS_8; - - default: - return SERIAL_BITS_INVALID; - } -} - -unsigned int serial_get_bits_int(const serial_bits_t bits) { - switch(bits) { - case SERIAL_BITS_5: return 5; - case SERIAL_BITS_6: return 6; - case SERIAL_BITS_7: return 7; - case SERIAL_BITS_8: return 8; - - default: - return 0; - } -} - -serial_parity_t serial_get_parity(const char *mode) { - if (!mode || !mode[0]) - return SERIAL_PARITY_INVALID; - switch(mode[1]) { - case 'N': - case 'n': - return SERIAL_PARITY_NONE; - case 'E': - case 'e': - return SERIAL_PARITY_EVEN; - case 'O': - case 'o': - return SERIAL_PARITY_ODD; - - default: - return SERIAL_PARITY_INVALID; - } -} - -char serial_get_parity_str(const serial_parity_t parity) { - switch(parity) { - case SERIAL_PARITY_NONE: return 'N'; - case SERIAL_PARITY_EVEN: return 'E'; - case SERIAL_PARITY_ODD : return 'O'; - - default: - return ' '; - } -} - -serial_stopbit_t serial_get_stopbit(const char *mode) { - if (!mode || !mode[0] || !mode[1]) - return SERIAL_STOPBIT_INVALID; - switch(mode[2]) { - case '1': return SERIAL_STOPBIT_1; - case '2': return SERIAL_STOPBIT_2; - - default: - return SERIAL_STOPBIT_INVALID; - } -} - -unsigned int serial_get_stopbit_int(const serial_stopbit_t stopbit) { - switch(stopbit) { - case SERIAL_STOPBIT_1: return 1; - case SERIAL_STOPBIT_2: return 2; - - default: - return 0; - } -} - diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_platform.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_platform.c deleted file mode 100755 index 98e256921..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_platform.c +++ /dev/null @@ -1,5 +0,0 @@ -#if defined(__WIN32__) || defined(__CYGWIN__) -# include "serial_w32.c" -#else -# include "serial_posix.c" -#endif diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_posix.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_posix.c deleted file mode 100755 index 284b35b20..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_posix.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - -struct serial { - int fd; - struct termios oldtio; - struct termios newtio; - char setup_str[11]; -}; - -static serial_t *serial_open(const char *device) -{ - serial_t *h = calloc(sizeof(serial_t), 1); - - h->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); - if (h->fd < 0) { - free(h); - return NULL; - } - fcntl(h->fd, F_SETFL, 0); - - tcgetattr(h->fd, &h->oldtio); - tcgetattr(h->fd, &h->newtio); - - return h; -} - -static void serial_flush(const serial_t *h) -{ - tcflush(h->fd, TCIFLUSH); -} - -static void serial_close(serial_t *h) -{ - serial_flush(h); - tcsetattr(h->fd, TCSANOW, &h->oldtio); - close(h->fd); - free(h); -} - -static port_err_t serial_setup(serial_t *h, const serial_baud_t baud, - const serial_bits_t bits, - const serial_parity_t parity, - const serial_stopbit_t stopbit) -{ - speed_t port_baud; - tcflag_t port_bits; - tcflag_t port_parity; - tcflag_t port_stop; - struct termios settings; - - switch (baud) { - case SERIAL_BAUD_1200: port_baud = B1200; break; - case SERIAL_BAUD_1800: port_baud = B1800; break; - case SERIAL_BAUD_2400: port_baud = B2400; break; - case SERIAL_BAUD_4800: port_baud = B4800; break; - case SERIAL_BAUD_9600: port_baud = B9600; break; - case SERIAL_BAUD_19200: port_baud = B19200; break; - case SERIAL_BAUD_38400: port_baud = B38400; break; - case SERIAL_BAUD_57600: port_baud = B57600; break; - case SERIAL_BAUD_115200: port_baud = B115200; break; - case SERIAL_BAUD_230400: port_baud = B230400; break; -#ifdef B460800 - case SERIAL_BAUD_460800: port_baud = B460800; break; -#endif /* B460800 */ -#ifdef B921600 - case SERIAL_BAUD_921600: port_baud = B921600; break; -#endif /* B921600 */ -#ifdef B500000 - case SERIAL_BAUD_500000: port_baud = B500000; break; -#endif /* B500000 */ -#ifdef B576000 - case SERIAL_BAUD_576000: port_baud = B576000; break; -#endif /* B576000 */ -#ifdef B1000000 - case SERIAL_BAUD_1000000: port_baud = B1000000; break; -#endif /* B1000000 */ -#ifdef B1500000 - case SERIAL_BAUD_1500000: port_baud = B1500000; break; -#endif /* B1500000 */ -#ifdef B2000000 - case SERIAL_BAUD_2000000: port_baud = B2000000; break; -#endif /* B2000000 */ - - case SERIAL_BAUD_INVALID: - default: - return PORT_ERR_UNKNOWN; - } - - switch (bits) { - case SERIAL_BITS_5: port_bits = CS5; break; - case SERIAL_BITS_6: port_bits = CS6; break; - case SERIAL_BITS_7: port_bits = CS7; break; - case SERIAL_BITS_8: port_bits = CS8; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (parity) { - case SERIAL_PARITY_NONE: port_parity = 0; break; - case SERIAL_PARITY_EVEN: port_parity = PARENB; break; - case SERIAL_PARITY_ODD: port_parity = PARENB | PARODD; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (stopbit) { - case SERIAL_STOPBIT_1: port_stop = 0; break; - case SERIAL_STOPBIT_2: port_stop = CSTOPB; break; - - default: - return PORT_ERR_UNKNOWN; - } - - /* reset the settings */ -#ifndef __sun /* Used by GNU and BSD. Ignore __SVR4 in test. */ - cfmakeraw(&h->newtio); -#else /* __sun */ - h->newtio.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR - | IGNCR | ICRNL | IXON); - if (port_parity) - h->newtio.c_iflag |= INPCK; - - h->newtio.c_oflag &= ~OPOST; - h->newtio.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); - h->newtio.c_cflag &= ~(CSIZE | PARENB); - h->newtio.c_cflag |= CS8; -#endif /* __sun */ -#ifdef __QNXNTO__ - h->newtio.c_cflag &= ~(CSIZE | IHFLOW | OHFLOW); -#else - h->newtio.c_cflag &= ~(CSIZE | CRTSCTS); -#endif - h->newtio.c_cflag &= ~(CSIZE | CRTSCTS); - h->newtio.c_iflag &= ~(IXON | IXOFF | IXANY | IGNPAR); - h->newtio.c_lflag &= ~(ECHOK | ECHOCTL | ECHOKE); - h->newtio.c_oflag &= ~(OPOST | ONLCR); - - /* setup the new settings */ - cfsetispeed(&h->newtio, port_baud); - cfsetospeed(&h->newtio, port_baud); - h->newtio.c_cflag |= - port_parity | - port_bits | - port_stop | - CLOCAL | - CREAD; - - h->newtio.c_cc[VMIN] = 0; - h->newtio.c_cc[VTIME] = 5; /* in units of 0.1 s */ - - /* set the settings */ - serial_flush(h); - if (tcsetattr(h->fd, TCSANOW, &h->newtio) != 0) - return PORT_ERR_UNKNOWN; - -/* this check fails on CDC-ACM devices, bits 16 and 17 of cflag differ! - * it has been disabled below for now -jcw, 2015-11-09 - if (settings.c_cflag != h->newtio.c_cflag) - fprintf(stderr, "c_cflag mismatch %lx\n", - settings.c_cflag ^ h->newtio.c_cflag); - */ - - /* confirm they were set */ - tcgetattr(h->fd, &settings); - if (settings.c_iflag != h->newtio.c_iflag || - settings.c_oflag != h->newtio.c_oflag || - //settings.c_cflag != h->newtio.c_cflag || - settings.c_lflag != h->newtio.c_lflag) - return PORT_ERR_UNKNOWN; - - snprintf(h->setup_str, sizeof(h->setup_str), "%u %d%c%d", - serial_get_baud_int(baud), - serial_get_bits_int(bits), - serial_get_parity_str(parity), - serial_get_stopbit_int(stopbit)); - return PORT_ERR_OK; -} - -/* - * Roger clark. - * This function is no longer used. But has just been commented out in case it needs - * to be reinstated in the future - -static int startswith(const char *haystack, const char *needle) { - return strncmp(haystack, needle, strlen(needle)) == 0; -} -*/ - -static int is_tty(const char *path) { - char resolved[PATH_MAX]; - - if(!realpath(path, resolved)) return 0; - - - /* - * Roger Clark - * Commented out this check, because on OSX some devices are /dev/cu - * and some users use symbolic links to devices, hence the name may not even start - * with /dev - - if(startswith(resolved, "/dev/tty")) return 1; - - return 0; - */ - - return 1; -} - -static port_err_t serial_posix_open(struct port_interface *port, - struct port_options *ops) -{ - serial_t *h; - - /* 1. check device name match */ - if (!is_tty(ops->device)) - return PORT_ERR_NODEV; - - /* 2. check options */ - if (ops->baudRate == SERIAL_BAUD_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_bits(ops->serial_mode) == SERIAL_BITS_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_parity(ops->serial_mode) == SERIAL_PARITY_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_stopbit(ops->serial_mode) == SERIAL_STOPBIT_INVALID) - return PORT_ERR_UNKNOWN; - - /* 3. open it */ - h = serial_open(ops->device); - if (h == NULL) - return PORT_ERR_UNKNOWN; - - /* 4. set options */ - if (serial_setup(h, ops->baudRate, - serial_get_bits(ops->serial_mode), - serial_get_parity(ops->serial_mode), - serial_get_stopbit(ops->serial_mode) - ) != PORT_ERR_OK) { - serial_close(h); - return PORT_ERR_UNKNOWN; - } - - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t serial_posix_close(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - serial_close(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t serial_posix_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - ssize_t r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - r = read(h->fd, pos, nbyte); - if (r == 0) - return PORT_ERR_TIMEDOUT; - if (r < 0) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_posix_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - ssize_t r; - const uint8_t *pos = (const uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - r = write(h->fd, pos, nbyte); - if (r < 1) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_posix_gpio(struct port_interface *port, - serial_gpio_t n, int level) -{ - serial_t *h; - int bit, lines; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - switch (n) { - case GPIO_RTS: - bit = TIOCM_RTS; - break; - - case GPIO_DTR: - bit = TIOCM_DTR; - break; - - case GPIO_BRK: - if (level == 0) - return PORT_ERR_OK; - if (tcsendbreak(h->fd, 1)) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; - - default: - return PORT_ERR_UNKNOWN; - } - - /* handle RTS/DTR */ - if (ioctl(h->fd, TIOCMGET, &lines)) - return PORT_ERR_UNKNOWN; - lines = level ? lines | bit : lines & ~bit; - if (ioctl(h->fd, TIOCMSET, &lines)) - return PORT_ERR_UNKNOWN; - - return PORT_ERR_OK; -} - -static const char *serial_posix_get_cfg_str(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - return h ? h->setup_str : "INVALID"; -} - -struct port_interface port_serial = { - .name = "serial_posix", - .flags = PORT_BYTE | PORT_GVR_ETX | PORT_CMD_INIT | PORT_RETRY, - .open = serial_posix_open, - .close = serial_posix_close, - .read = serial_posix_read, - .write = serial_posix_write, - .gpio = serial_posix_gpio, - .get_cfg_str = serial_posix_get_cfg_str, -}; diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_w32.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_w32.c deleted file mode 100755 index 56772c0a0..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/serial_w32.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2010 Gareth McMullin - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - -struct serial { - HANDLE fd; - DCB oldtio; - DCB newtio; - char setup_str[11]; -}; - -static serial_t *serial_open(const char *device) -{ - serial_t *h = calloc(sizeof(serial_t), 1); - char *devName; - - /* timeout in ms */ - COMMTIMEOUTS timeouts = {MAXDWORD, MAXDWORD, 500, 0, 0}; - - /* Fix the device name if required */ - if (strlen(device) > 4 && device[0] != '\\') { - devName = calloc(1, strlen(device) + 5); - sprintf(devName, "\\\\.\\%s", device); - } else { - devName = (char *)device; - } - - /* Create file handle for port */ - h->fd = CreateFile(devName, GENERIC_READ | GENERIC_WRITE, - 0, /* Exclusive access */ - NULL, /* No security */ - OPEN_EXISTING, - 0, /* No overlap */ - NULL); - - if (devName != device) - free(devName); - - if (h->fd == INVALID_HANDLE_VALUE) { - if (GetLastError() == ERROR_FILE_NOT_FOUND) - fprintf(stderr, "File not found: %s\n", device); - return NULL; - } - - SetupComm(h->fd, 4096, 4096); /* Set input and output buffer size */ - - SetCommTimeouts(h->fd, &timeouts); - - SetCommMask(h->fd, EV_ERR); /* Notify us of error events */ - - GetCommState(h->fd, &h->oldtio); /* Retrieve port parameters */ - GetCommState(h->fd, &h->newtio); /* Retrieve port parameters */ - - /* PurgeComm(h->fd, PURGE_RXABORT | PURGE_TXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR); */ - - return h; -} - -static void serial_flush(const serial_t *h) -{ - /* We shouldn't need to flush in non-overlapping (blocking) mode */ - /* tcflush(h->fd, TCIFLUSH); */ -} - -static void serial_close(serial_t *h) -{ - serial_flush(h); - SetCommState(h->fd, &h->oldtio); - CloseHandle(h->fd); - free(h); -} - -static port_err_t serial_setup(serial_t *h, - const serial_baud_t baud, - const serial_bits_t bits, - const serial_parity_t parity, - const serial_stopbit_t stopbit) -{ - switch (baud) { - case SERIAL_BAUD_1200: h->newtio.BaudRate = CBR_1200; break; - /* case SERIAL_BAUD_1800: h->newtio.BaudRate = CBR_1800; break; */ - case SERIAL_BAUD_2400: h->newtio.BaudRate = CBR_2400; break; - case SERIAL_BAUD_4800: h->newtio.BaudRate = CBR_4800; break; - case SERIAL_BAUD_9600: h->newtio.BaudRate = CBR_9600; break; - case SERIAL_BAUD_19200: h->newtio.BaudRate = CBR_19200; break; - case SERIAL_BAUD_38400: h->newtio.BaudRate = CBR_38400; break; - case SERIAL_BAUD_57600: h->newtio.BaudRate = CBR_57600; break; - case SERIAL_BAUD_115200: h->newtio.BaudRate = CBR_115200; break; - case SERIAL_BAUD_128000: h->newtio.BaudRate = CBR_128000; break; - case SERIAL_BAUD_256000: h->newtio.BaudRate = CBR_256000; break; - /* These are not defined in WinBase.h and might work or not */ - case SERIAL_BAUD_230400: h->newtio.BaudRate = 230400; break; - case SERIAL_BAUD_460800: h->newtio.BaudRate = 460800; break; - case SERIAL_BAUD_500000: h->newtio.BaudRate = 500000; break; - case SERIAL_BAUD_576000: h->newtio.BaudRate = 576000; break; - case SERIAL_BAUD_921600: h->newtio.BaudRate = 921600; break; - case SERIAL_BAUD_1000000: h->newtio.BaudRate = 1000000; break; - case SERIAL_BAUD_1500000: h->newtio.BaudRate = 1500000; break; - case SERIAL_BAUD_2000000: h->newtio.BaudRate = 2000000; break; - case SERIAL_BAUD_INVALID: - - default: - return PORT_ERR_UNKNOWN; - } - - switch (bits) { - case SERIAL_BITS_5: h->newtio.ByteSize = 5; break; - case SERIAL_BITS_6: h->newtio.ByteSize = 6; break; - case SERIAL_BITS_7: h->newtio.ByteSize = 7; break; - case SERIAL_BITS_8: h->newtio.ByteSize = 8; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (parity) { - case SERIAL_PARITY_NONE: h->newtio.Parity = NOPARITY; break; - case SERIAL_PARITY_EVEN: h->newtio.Parity = EVENPARITY; break; - case SERIAL_PARITY_ODD: h->newtio.Parity = ODDPARITY; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (stopbit) { - case SERIAL_STOPBIT_1: h->newtio.StopBits = ONESTOPBIT; break; - case SERIAL_STOPBIT_2: h->newtio.StopBits = TWOSTOPBITS; break; - - default: - return PORT_ERR_UNKNOWN; - } - - /* reset the settings */ - h->newtio.fOutxCtsFlow = FALSE; - h->newtio.fOutxDsrFlow = FALSE; - h->newtio.fOutX = FALSE; - h->newtio.fInX = FALSE; - h->newtio.fNull = 0; - h->newtio.fAbortOnError = 0; - - /* set the settings */ - serial_flush(h); - if (!SetCommState(h->fd, &h->newtio)) - return PORT_ERR_UNKNOWN; - - snprintf(h->setup_str, sizeof(h->setup_str), "%u %d%c%d", - serial_get_baud_int(baud), - serial_get_bits_int(bits), - serial_get_parity_str(parity), - serial_get_stopbit_int(stopbit) - ); - return PORT_ERR_OK; -} - -static port_err_t serial_w32_open(struct port_interface *port, - struct port_options *ops) -{ - serial_t *h; - - /* 1. check device name match */ - if (!((strlen(ops->device) == 4 || strlen(ops->device) == 5) - && !strncmp(ops->device, "COM", 3) && isdigit(ops->device[3])) - && !(!strncmp(ops->device, "\\\\.\\COM", strlen("\\\\.\\COM")) - && isdigit(ops->device[strlen("\\\\.\\COM")]))) - return PORT_ERR_NODEV; - - /* 2. check options */ - if (ops->baudRate == SERIAL_BAUD_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_bits(ops->serial_mode) == SERIAL_BITS_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_parity(ops->serial_mode) == SERIAL_PARITY_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_stopbit(ops->serial_mode) == SERIAL_STOPBIT_INVALID) - return PORT_ERR_UNKNOWN; - - /* 3. open it */ - h = serial_open(ops->device); - if (h == NULL) - return PORT_ERR_UNKNOWN; - - /* 4. set options */ - if (serial_setup(h, ops->baudRate, - serial_get_bits(ops->serial_mode), - serial_get_parity(ops->serial_mode), - serial_get_stopbit(ops->serial_mode) - ) != PORT_ERR_OK) { - serial_close(h); - return PORT_ERR_UNKNOWN; - } - - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t serial_w32_close(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - serial_close(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t serial_w32_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - DWORD r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - ReadFile(h->fd, pos, nbyte, &r, NULL); - if (r == 0) - return PORT_ERR_TIMEDOUT; - if (r < 0) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_w32_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - DWORD r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - if (!WriteFile(h->fd, pos, nbyte, &r, NULL)) - return PORT_ERR_UNKNOWN; - if (r < 1) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_w32_gpio(struct port_interface *port, - serial_gpio_t n, int level) -{ - serial_t *h; - int bit; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - switch (n) { - case GPIO_RTS: - bit = level ? SETRTS : CLRRTS; - break; - - case GPIO_DTR: - bit = level ? SETDTR : CLRDTR; - break; - - case GPIO_BRK: - if (level == 0) - return PORT_ERR_OK; - if (EscapeCommFunction(h->fd, SETBREAK) == 0) - return PORT_ERR_UNKNOWN; - usleep(500000); - if (EscapeCommFunction(h->fd, CLRBREAK) == 0) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; - - default: - return PORT_ERR_UNKNOWN; - } - - /* handle RTS/DTR */ - if (EscapeCommFunction(h->fd, bit) == 0) - return PORT_ERR_UNKNOWN; - - return PORT_ERR_OK; -} - -static const char *serial_w32_get_cfg_str(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - return h ? h->setup_str : "INVALID"; -} - -struct port_interface port_serial = { - .name = "serial_w32", - .flags = PORT_BYTE | PORT_GVR_ETX | PORT_CMD_INIT | PORT_RETRY, - .open = serial_w32_open, - .close = serial_w32_close, - .read = serial_w32_read, - .write = serial_w32_write, - .gpio = serial_w32_gpio, - .get_cfg_str = serial_w32_get_cfg_str, -}; diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/stm32.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/stm32.c deleted file mode 100755 index 74047d244..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/stm32.c +++ /dev/null @@ -1,1048 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright 2010 Geoffrey McRae - Copyright 2012-2014 Tormod Volden - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include - -#include "stm32.h" -#include "port.h" -#include "utils.h" - -#define STM32_ACK 0x79 -#define STM32_NACK 0x1F -#define STM32_BUSY 0x76 - -#define STM32_CMD_INIT 0x7F -#define STM32_CMD_GET 0x00 /* get the version and command supported */ -#define STM32_CMD_GVR 0x01 /* get version and read protection status */ -#define STM32_CMD_GID 0x02 /* get ID */ -#define STM32_CMD_RM 0x11 /* read memory */ -#define STM32_CMD_GO 0x21 /* go */ -#define STM32_CMD_WM 0x31 /* write memory */ -#define STM32_CMD_WM_NS 0x32 /* no-stretch write memory */ -#define STM32_CMD_ER 0x43 /* erase */ -#define STM32_CMD_EE 0x44 /* extended erase */ -#define STM32_CMD_EE_NS 0x45 /* extended erase no-stretch */ -#define STM32_CMD_WP 0x63 /* write protect */ -#define STM32_CMD_WP_NS 0x64 /* write protect no-stretch */ -#define STM32_CMD_UW 0x73 /* write unprotect */ -#define STM32_CMD_UW_NS 0x74 /* write unprotect no-stretch */ -#define STM32_CMD_RP 0x82 /* readout protect */ -#define STM32_CMD_RP_NS 0x83 /* readout protect no-stretch */ -#define STM32_CMD_UR 0x92 /* readout unprotect */ -#define STM32_CMD_UR_NS 0x93 /* readout unprotect no-stretch */ -#define STM32_CMD_CRC 0xA1 /* compute CRC */ -#define STM32_CMD_ERR 0xFF /* not a valid command */ - -#define STM32_RESYNC_TIMEOUT 35 /* seconds */ -#define STM32_MASSERASE_TIMEOUT 35 /* seconds */ -#define STM32_SECTERASE_TIMEOUT 5 /* seconds */ -#define STM32_BLKWRITE_TIMEOUT 1 /* seconds */ -#define STM32_WUNPROT_TIMEOUT 1 /* seconds */ -#define STM32_WPROT_TIMEOUT 1 /* seconds */ -#define STM32_RPROT_TIMEOUT 1 /* seconds */ - -#define STM32_CMD_GET_LENGTH 17 /* bytes in the reply */ - -struct stm32_cmd { - uint8_t get; - uint8_t gvr; - uint8_t gid; - uint8_t rm; - uint8_t go; - uint8_t wm; - uint8_t er; /* this may be extended erase */ - uint8_t wp; - uint8_t uw; - uint8_t rp; - uint8_t ur; - uint8_t crc; -}; - -/* Reset code for ARMv7-M (Cortex-M3) and ARMv6-M (Cortex-M0) - * see ARMv7-M or ARMv6-M Architecture Reference Manual (table B3-8) - * or "The definitive guide to the ARM Cortex-M3", section 14.4. - */ -static const uint8_t stm_reset_code[] = { - 0x01, 0x49, // ldr r1, [pc, #4] ; () - 0x02, 0x4A, // ldr r2, [pc, #8] ; () - 0x0A, 0x60, // str r2, [r1, #0] - 0xfe, 0xe7, // endless: b endless - 0x0c, 0xed, 0x00, 0xe0, // .word 0xe000ed0c = NVIC AIRCR register address - 0x04, 0x00, 0xfa, 0x05 // .word 0x05fa0004 = VECTKEY | SYSRESETREQ -}; - -static const uint32_t stm_reset_code_length = sizeof(stm_reset_code); - -extern const stm32_dev_t devices[]; - -static void stm32_warn_stretching(const char *f) -{ - fprintf(stderr, "Attention !!!\n"); - fprintf(stderr, "\tThis %s error could be caused by your I2C\n", f); - fprintf(stderr, "\tcontroller not accepting \"clock stretching\"\n"); - fprintf(stderr, "\tas required by bootloader.\n"); - fprintf(stderr, "\tCheck \"I2C.txt\" in stm32flash source code.\n"); -} - -static stm32_err_t stm32_get_ack_timeout(const stm32_t *stm, time_t timeout) -{ - struct port_interface *port = stm->port; - uint8_t byte; - port_err_t p_err; - time_t t0, t1; - - if (!(port->flags & PORT_RETRY)) - timeout = 0; - - if (timeout) - time(&t0); - - do { - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_TIMEDOUT && timeout) { - time(&t1); - if (t1 < t0 + timeout) - continue; - } - - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to read ACK byte\n"); - return STM32_ERR_UNKNOWN; - } - - if (byte == STM32_ACK) - return STM32_ERR_OK; - if (byte == STM32_NACK) - return STM32_ERR_NACK; - if (byte != STM32_BUSY) { - fprintf(stderr, "Got byte 0x%02x instead of ACK\n", - byte); - return STM32_ERR_UNKNOWN; - } - } while (1); -} - -static stm32_err_t stm32_get_ack(const stm32_t *stm) -{ - return stm32_get_ack_timeout(stm, 0); -} - -static stm32_err_t stm32_send_command_timeout(const stm32_t *stm, - const uint8_t cmd, - time_t timeout) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - port_err_t p_err; - uint8_t buf[2]; - - buf[0] = cmd; - buf[1] = cmd ^ 0xFF; - p_err = port->write(port, buf, 2); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send command\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, timeout); - if (s_err == STM32_ERR_OK) - return STM32_ERR_OK; - if (s_err == STM32_ERR_NACK) - fprintf(stderr, "Got NACK from device on command 0x%02x\n", cmd); - else - fprintf(stderr, "Unexpected reply from device on command 0x%02x\n", cmd); - return STM32_ERR_UNKNOWN; -} - -static stm32_err_t stm32_send_command(const stm32_t *stm, const uint8_t cmd) -{ - return stm32_send_command_timeout(stm, cmd, 0); -} - -/* if we have lost sync, send a wrong command and expect a NACK */ -static stm32_err_t stm32_resync(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - uint8_t buf[2], ack; - time_t t0, t1; - - time(&t0); - t1 = t0; - - buf[0] = STM32_CMD_ERR; - buf[1] = STM32_CMD_ERR ^ 0xFF; - while (t1 < t0 + STM32_RESYNC_TIMEOUT) { - p_err = port->write(port, buf, 2); - if (p_err != PORT_ERR_OK) { - usleep(500000); - time(&t1); - continue; - } - p_err = port->read(port, &ack, 1); - if (p_err != PORT_ERR_OK) { - time(&t1); - continue; - } - if (ack == STM32_NACK) - return STM32_ERR_OK; - time(&t1); - } - return STM32_ERR_UNKNOWN; -} - -/* - * some command receive reply frame with variable length, and length is - * embedded in reply frame itself. - * We can guess the length, but if we guess wrong the protocol gets out - * of sync. - * Use resync for frame oriented interfaces (e.g. I2C) and byte-by-byte - * read for byte oriented interfaces (e.g. UART). - * - * to run safely, data buffer should be allocated for 256+1 bytes - * - * len is value of the first byte in the frame. - */ -static stm32_err_t stm32_guess_len_cmd(const stm32_t *stm, uint8_t cmd, - uint8_t *data, unsigned int len) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - if (port->flags & PORT_BYTE) { - /* interface is UART-like */ - p_err = port->read(port, data, 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - len = data[0]; - p_err = port->read(port, data + 1, len + 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; - } - - p_err = port->read(port, data, len + 2); - if (p_err == PORT_ERR_OK && len == data[0]) - return STM32_ERR_OK; - if (p_err != PORT_ERR_OK) { - /* restart with only one byte */ - if (stm32_resync(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - p_err = port->read(port, data, 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - } - - fprintf(stderr, "Re sync (len = %d)\n", data[0]); - if (stm32_resync(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - len = data[0]; - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - p_err = port->read(port, data, len + 2); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; -} - -/* - * Some interface, e.g. UART, requires a specific init sequence to let STM32 - * autodetect the interface speed. - * The sequence is only required one time after reset. - * stm32flash has command line flag "-c" to prevent sending the init sequence - * in case it was already sent before. - * User can easily forget adding "-c". In this case the bootloader would - * interpret the init sequence as part of a command message, then waiting for - * the rest of the message blocking the interface. - * This function sends the init sequence and, in case of timeout, recovers - * the interface. - */ -static stm32_err_t stm32_send_init_seq(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - uint8_t byte, cmd = STM32_CMD_INIT; - - p_err = port->write(port, &cmd, 1); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send init to device\n"); - return STM32_ERR_UNKNOWN; - } - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_OK && byte == STM32_ACK) - return STM32_ERR_OK; - if (p_err == PORT_ERR_OK && byte == STM32_NACK) { - /* We could get error later, but let's continue, for now. */ - fprintf(stderr, - "Warning: the interface was not closed properly.\n"); - return STM32_ERR_OK; - } - if (p_err != PORT_ERR_TIMEDOUT) { - fprintf(stderr, "Failed to init device.\n"); - return STM32_ERR_UNKNOWN; - } - - /* - * Check if previous STM32_CMD_INIT was taken as first byte - * of a command. Send a new byte, we should get back a NACK. - */ - p_err = port->write(port, &cmd, 1); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send init to device\n"); - return STM32_ERR_UNKNOWN; - } - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_OK && byte == STM32_NACK) - return STM32_ERR_OK; - fprintf(stderr, "Failed to init device.\n"); - return STM32_ERR_UNKNOWN; -} - -/* find newer command by higher code */ -#define newer(prev, a) (((prev) == STM32_CMD_ERR) \ - ? (a) \ - : (((prev) > (a)) ? (prev) : (a))) - -stm32_t *stm32_init(struct port_interface *port, const char init) -{ - uint8_t len, val, buf[257]; - stm32_t *stm; - int i, new_cmds; - - stm = calloc(sizeof(stm32_t), 1); - stm->cmd = malloc(sizeof(stm32_cmd_t)); - memset(stm->cmd, STM32_CMD_ERR, sizeof(stm32_cmd_t)); - stm->port = port; - - if ((port->flags & PORT_CMD_INIT) && init) - if (stm32_send_init_seq(stm) != STM32_ERR_OK) - return NULL; - - /* get the version and read protection status */ - if (stm32_send_command(stm, STM32_CMD_GVR) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - /* From AN, only UART bootloader returns 3 bytes */ - len = (port->flags & PORT_GVR_ETX) ? 3 : 1; - if (port->read(port, buf, len) != PORT_ERR_OK) - return NULL; - stm->version = buf[0]; - stm->option1 = (port->flags & PORT_GVR_ETX) ? buf[1] : 0; - stm->option2 = (port->flags & PORT_GVR_ETX) ? buf[2] : 0; - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - /* get the bootloader information */ - len = STM32_CMD_GET_LENGTH; - if (port->cmd_get_reply) - for (i = 0; port->cmd_get_reply[i].length; i++) - if (stm->version == port->cmd_get_reply[i].version) { - len = port->cmd_get_reply[i].length; - break; - } - if (stm32_guess_len_cmd(stm, STM32_CMD_GET, buf, len) != STM32_ERR_OK) - return NULL; - len = buf[0] + 1; - stm->bl_version = buf[1]; - new_cmds = 0; - for (i = 1; i < len; i++) { - val = buf[i + 1]; - switch (val) { - case STM32_CMD_GET: - stm->cmd->get = val; break; - case STM32_CMD_GVR: - stm->cmd->gvr = val; break; - case STM32_CMD_GID: - stm->cmd->gid = val; break; - case STM32_CMD_RM: - stm->cmd->rm = val; break; - case STM32_CMD_GO: - stm->cmd->go = val; break; - case STM32_CMD_WM: - case STM32_CMD_WM_NS: - stm->cmd->wm = newer(stm->cmd->wm, val); - break; - case STM32_CMD_ER: - case STM32_CMD_EE: - case STM32_CMD_EE_NS: - stm->cmd->er = newer(stm->cmd->er, val); - break; - case STM32_CMD_WP: - case STM32_CMD_WP_NS: - stm->cmd->wp = newer(stm->cmd->wp, val); - break; - case STM32_CMD_UW: - case STM32_CMD_UW_NS: - stm->cmd->uw = newer(stm->cmd->uw, val); - break; - case STM32_CMD_RP: - case STM32_CMD_RP_NS: - stm->cmd->rp = newer(stm->cmd->rp, val); - break; - case STM32_CMD_UR: - case STM32_CMD_UR_NS: - stm->cmd->ur = newer(stm->cmd->ur, val); - break; - case STM32_CMD_CRC: - stm->cmd->crc = newer(stm->cmd->crc, val); - break; - default: - if (new_cmds++ == 0) - fprintf(stderr, - "GET returns unknown commands (0x%2x", - val); - else - fprintf(stderr, ", 0x%2x", val); - } - } - if (new_cmds) - fprintf(stderr, ")\n"); - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - if (stm->cmd->get == STM32_CMD_ERR - || stm->cmd->gvr == STM32_CMD_ERR - || stm->cmd->gid == STM32_CMD_ERR) { - fprintf(stderr, "Error: bootloader did not returned correct information from GET command\n"); - return NULL; - } - - /* get the device ID */ - if (stm32_guess_len_cmd(stm, stm->cmd->gid, buf, 1) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - len = buf[0] + 1; - if (len < 2) { - stm32_close(stm); - fprintf(stderr, "Only %d bytes sent in the PID, unknown/unsupported device\n", len); - return NULL; - } - stm->pid = (buf[1] << 8) | buf[2]; - if (len > 2) { - fprintf(stderr, "This bootloader returns %d extra bytes in PID:", len); - for (i = 2; i <= len ; i++) - fprintf(stderr, " %02x", buf[i]); - fprintf(stderr, "\n"); - } - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - stm->dev = devices; - while (stm->dev->id != 0x00 && stm->dev->id != stm->pid) - ++stm->dev; - - if (!stm->dev->id) { - fprintf(stderr, "Unknown/unsupported device (Device ID: 0x%03x)\n", stm->pid); - stm32_close(stm); - return NULL; - } - - return stm; -} - -void stm32_close(stm32_t *stm) -{ - if (stm) - free(stm->cmd); - free(stm); -} - -stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address, - uint8_t data[], unsigned int len) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (!len) - return STM32_ERR_OK; - - if (len > 256) { - fprintf(stderr, "Error: READ length limit at 256 bytes\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->rm == STM32_CMD_ERR) { - fprintf(stderr, "Error: READ command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->rm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_send_command(stm, len - 1) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (port->read(port, data, len) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - return STM32_ERR_OK; -} - -stm32_err_t stm32_write_memory(const stm32_t *stm, uint32_t address, - const uint8_t data[], unsigned int len) -{ - struct port_interface *port = stm->port; - uint8_t cs, buf[256 + 2]; - unsigned int i, aligned_len; - stm32_err_t s_err; - - if (!len) - return STM32_ERR_OK; - - if (len > 256) { - fprintf(stderr, "Error: READ length limit at 256 bytes\n"); - return STM32_ERR_UNKNOWN; - } - - /* must be 32bit aligned */ - if (address & 0x3 || len & 0x3) { - fprintf(stderr, "Error: WRITE address and length must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->wm == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - /* send the address and checksum */ - if (stm32_send_command(stm, stm->cmd->wm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - aligned_len = (len + 3) & ~3; - cs = aligned_len - 1; - buf[0] = aligned_len - 1; - for (i = 0; i < len; i++) { - cs ^= data[i]; - buf[i + 1] = data[i]; - } - /* padding data */ - for (i = len; i < aligned_len; i++) { - cs ^= 0xFF; - buf[i + 1] = 0xFF; - } - buf[aligned_len + 1] = cs; - if (port->write(port, buf, aligned_len + 2) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_BLKWRITE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->wm != STM32_CMD_WM_NS) - stm32_warn_stretching("write"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_wunprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->uw == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE UNPROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->uw) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_WUNPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to WRITE UNPROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->uw != STM32_CMD_UW_NS) - stm32_warn_stretching("WRITE UNPROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_wprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->wp == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE PROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->wp) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_WPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to WRITE PROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->wp != STM32_CMD_WP_NS) - stm32_warn_stretching("WRITE PROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_runprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->ur == STM32_CMD_ERR) { - fprintf(stderr, "Error: READOUT UNPROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->ur) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to READOUT UNPROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->ur != STM32_CMD_UR_NS) - stm32_warn_stretching("READOUT UNPROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_readprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->rp == STM32_CMD_ERR) { - fprintf(stderr, "Error: READOUT PROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->rp) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_RPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to READOUT PROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->rp != STM32_CMD_RP_NS) - stm32_warn_stretching("READOUT PROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_erase_memory(const stm32_t *stm, uint8_t spage, uint8_t pages) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - port_err_t p_err; - - if (!pages) - return STM32_ERR_OK; - - if (stm->cmd->er == STM32_CMD_ERR) { - fprintf(stderr, "Error: ERASE command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->er) != STM32_ERR_OK) { - fprintf(stderr, "Can't initiate chip erase!\n"); - return STM32_ERR_UNKNOWN; - } - - /* The erase command reported by the bootloader is either 0x43, 0x44 or 0x45 */ - /* 0x44 is Extended Erase, a 2 byte based protocol and needs to be handled differently. */ - /* 0x45 is clock no-stretching version of Extended Erase for I2C port. */ - if (stm->cmd->er != STM32_CMD_ER) { - /* Not all chips using Extended Erase support mass erase */ - /* Currently known as not supporting mass erase is the Ultra Low Power STM32L15xx range */ - /* So if someone has not overridden the default, but uses one of these chips, take it out of */ - /* mass erase mode, so it will be done page by page. This maximum might not be correct either! */ - if (stm->pid == 0x416 && pages == 0xFF) - pages = 0xF8; /* works for the STM32L152RB with 128Kb flash */ - - if (pages == 0xFF) { - uint8_t buf[3]; - - /* 0xFFFF the magic number for mass erase */ - buf[0] = 0xFF; - buf[1] = 0xFF; - buf[2] = 0x00; /* checksum */ - if (port->write(port, buf, 3) != PORT_ERR_OK) { - fprintf(stderr, "Mass erase error.\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Mass erase failed. Try specifying the number of pages to be erased.\n"); - if (port->flags & PORT_STRETCH_W - && stm->cmd->er != STM32_CMD_EE_NS) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } - - uint16_t pg_num; - uint8_t pg_byte; - uint8_t cs = 0; - uint8_t *buf; - int i = 0; - - buf = malloc(2 + 2 * pages + 1); - if (!buf) - return STM32_ERR_UNKNOWN; - - /* Number of pages to be erased - 1, two bytes, MSB first */ - pg_byte = (pages - 1) >> 8; - buf[i++] = pg_byte; - cs ^= pg_byte; - pg_byte = (pages - 1) & 0xFF; - buf[i++] = pg_byte; - cs ^= pg_byte; - - for (pg_num = spage; pg_num < spage + pages; pg_num++) { - pg_byte = pg_num >> 8; - cs ^= pg_byte; - buf[i++] = pg_byte; - pg_byte = pg_num & 0xFF; - cs ^= pg_byte; - buf[i++] = pg_byte; - } - buf[i++] = cs; - p_err = port->write(port, buf, i); - free(buf); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Page-by-page erase error.\n"); - return STM32_ERR_UNKNOWN; - } - - s_err = stm32_get_ack_timeout(stm, pages * STM32_SECTERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Page-by-page erase failed. Check the maximum pages your device supports.\n"); - if (port->flags & PORT_STRETCH_W - && stm->cmd->er != STM32_CMD_EE_NS) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - - return STM32_ERR_OK; - } - - /* And now the regular erase (0x43) for all other chips */ - if (pages == 0xFF) { - s_err = stm32_send_command_timeout(stm, 0xFF, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } else { - uint8_t cs = 0; - uint8_t pg_num; - uint8_t *buf; - int i = 0; - - buf = malloc(1 + pages + 1); - if (!buf) - return STM32_ERR_UNKNOWN; - - buf[i++] = pages - 1; - cs ^= (pages-1); - for (pg_num = spage; pg_num < (pages + spage); pg_num++) { - buf[i++] = pg_num; - cs ^= pg_num; - } - buf[i++] = cs; - p_err = port->write(port, buf, i); - free(buf); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Erase failed.\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } -} - -static stm32_err_t stm32_run_raw_code(const stm32_t *stm, - uint32_t target_address, - const uint8_t *code, uint32_t code_size) -{ - uint32_t stack_le = le_u32(0x20002000); - uint32_t code_address_le = le_u32(target_address + 8); - uint32_t length = code_size + 8; - uint8_t *mem, *pos; - uint32_t address, w; - - /* Must be 32-bit aligned */ - if (target_address & 0x3) { - fprintf(stderr, "Error: code address must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - mem = malloc(length); - if (!mem) - return STM32_ERR_UNKNOWN; - - memcpy(mem, &stack_le, sizeof(uint32_t)); - memcpy(mem + 4, &code_address_le, sizeof(uint32_t)); - memcpy(mem + 8, code, code_size); - - pos = mem; - address = target_address; - while (length > 0) { - w = length > 256 ? 256 : length; - if (stm32_write_memory(stm, address, pos, w) != STM32_ERR_OK) { - free(mem); - return STM32_ERR_UNKNOWN; - } - - address += w; - pos += w; - length -= w; - } - - free(mem); - return stm32_go(stm, target_address); -} - -stm32_err_t stm32_go(const stm32_t *stm, uint32_t address) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (stm->cmd->go == STM32_CMD_ERR) { - fprintf(stderr, "Error: GO command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->go) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; -} - -stm32_err_t stm32_reset_device(const stm32_t *stm) -{ - uint32_t target_address = stm->dev->ram_start; - - return stm32_run_raw_code(stm, target_address, stm_reset_code, stm_reset_code_length); -} - -stm32_err_t stm32_crc_memory(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (address & 0x3 || length & 0x3) { - fprintf(stderr, "Start and end addresses must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->crc == STM32_CMD_ERR) { - fprintf(stderr, "Error: CRC command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->crc) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = length >> 24; - buf[1] = (length >> 16) & 0xFF; - buf[2] = (length >> 8) & 0xFF; - buf[3] = length & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (port->read(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (buf[4] != (buf[0] ^ buf[1] ^ buf[2] ^ buf[3])) - return STM32_ERR_UNKNOWN; - - *crc = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; - return STM32_ERR_OK; -} - -/* - * CRC computed by STM32 is similar to the standard crc32_be() - * implemented, for example, in Linux kernel in ./lib/crc32.c - * But STM32 computes it on units of 32 bits word and swaps the - * bytes of the word before the computation. - * Due to byte swap, I cannot use any CRC available in existing - * libraries, so here is a simple not optimized implementation. - */ -#define CRCPOLY_BE 0x04c11db7 -#define CRC_MSBMASK 0x80000000 -#define CRC_INIT_VALUE 0xFFFFFFFF -uint32_t stm32_sw_crc(uint32_t crc, uint8_t *buf, unsigned int len) -{ - int i; - uint32_t data; - - if (len & 0x3) { - fprintf(stderr, "Buffer length must be multiple of 4 bytes\n"); - return 0; - } - - while (len) { - data = *buf++; - data |= *buf++ << 8; - data |= *buf++ << 16; - data |= *buf++ << 24; - len -= 4; - - crc ^= data; - - for (i = 0; i < 32; i++) - if (crc & CRC_MSBMASK) - crc = (crc << 1) ^ CRCPOLY_BE; - else - crc = (crc << 1); - } - return crc; -} - -stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc) -{ - uint8_t buf[256]; - uint32_t start, total_len, len, current_crc; - - if (address & 0x3 || length & 0x3) { - fprintf(stderr, "Start and end addresses must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->crc != STM32_CMD_ERR) - return stm32_crc_memory(stm, address, length, crc); - - start = address; - total_len = length; - current_crc = CRC_INIT_VALUE; - while (length) { - len = length > 256 ? 256 : length; - if (stm32_read_memory(stm, address, buf, len) != STM32_ERR_OK) { - fprintf(stderr, - "Failed to read memory at address 0x%08x, target write-protected?\n", - address); - return STM32_ERR_UNKNOWN; - } - current_crc = stm32_sw_crc(current_crc, buf, len); - length -= len; - address += len; - - fprintf(stderr, - "\rCRC address 0x%08x (%.2f%%) ", - address, - (100.0f / (float)total_len) * (float)(address - start) - ); - fflush(stderr); - } - fprintf(stderr, "Done.\n"); - *crc = current_crc; - return STM32_ERR_OK; -} diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/stm32.h b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/stm32.h deleted file mode 100755 index 1688fcb4b..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/stm32.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _STM32_H -#define _STM32_H - -#include -#include "serial.h" - -#define STM32_MAX_RX_FRAME 256 /* cmd read memory */ -#define STM32_MAX_TX_FRAME (1 + 256 + 1) /* cmd write memory */ - -typedef enum { - STM32_ERR_OK = 0, - STM32_ERR_UNKNOWN, /* Generic error */ - STM32_ERR_NACK, - STM32_ERR_NO_CMD, /* Command not available in bootloader */ -} stm32_err_t; - -typedef struct stm32 stm32_t; -typedef struct stm32_cmd stm32_cmd_t; -typedef struct stm32_dev stm32_dev_t; - -struct stm32 { - const serial_t *serial; - struct port_interface *port; - uint8_t bl_version; - uint8_t version; - uint8_t option1, option2; - uint16_t pid; - stm32_cmd_t *cmd; - const stm32_dev_t *dev; -}; - -struct stm32_dev { - uint16_t id; - const char *name; - uint32_t ram_start, ram_end; - uint32_t fl_start, fl_end; - uint16_t fl_pps; // pages per sector - uint16_t fl_ps; // page size - uint32_t opt_start, opt_end; - uint32_t mem_start, mem_end; -}; - -stm32_t *stm32_init(struct port_interface *port, const char init); -void stm32_close(stm32_t *stm); -stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address, - uint8_t data[], unsigned int len); -stm32_err_t stm32_write_memory(const stm32_t *stm, uint32_t address, - const uint8_t data[], unsigned int len); -stm32_err_t stm32_wunprot_memory(const stm32_t *stm); -stm32_err_t stm32_wprot_memory(const stm32_t *stm); -stm32_err_t stm32_erase_memory(const stm32_t *stm, uint8_t spage, - uint8_t pages); -stm32_err_t stm32_go(const stm32_t *stm, uint32_t address); -stm32_err_t stm32_reset_device(const stm32_t *stm); -stm32_err_t stm32_readprot_memory(const stm32_t *stm); -stm32_err_t stm32_runprot_memory(const stm32_t *stm); -stm32_err_t stm32_crc_memory(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc); -stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc); -uint32_t stm32_sw_crc(uint32_t crc, uint8_t *buf, unsigned int len); - -#endif - diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/stm32flash.1 b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/stm32flash.1 deleted file mode 100755 index d37292f6a..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/stm32flash.1 +++ /dev/null @@ -1,407 +0,0 @@ -.TH STM32FLASH 1 "2013\-11\-03" STM32FLASH "User command" -.SH NAME -stm32flash \- flashing utility for STM32 and STM32W through UART or I2C -.SH SYNOPSIS -.B stm32flash -.RB [ \-cfhjkouvCR ] -.RB [ \-a -.IR bus_address ] -.RB [ \-b -.IR baud_rate ] -.RB [ \-m -.IR serial_mode ] -.RB [ \-r -.IR filename ] -.RB [ \-w -.IR filename ] -.RB [ \-e -.IR num ] -.RB [ \-n -.IR count ] -.RB [ \-g -.IR address ] -.RB [ \-s -.IR start_page ] -.RB [ \-S -.IR address [: length ]] -.RB [ \-F -.IR RX_length [: TX_length ]] -.RB [ \-i -.IR GPIO_string ] -.RI [ tty_device -.R | -.IR i2c_device ] - -.SH DESCRIPTION -.B stm32flash -reads or writes the flash memory of STM32 and STM32W. - -It requires the STM32[W] to embed a bootloader compliant with ST -application note AN3155. -.B stm32flash -uses the serial port -.I tty_device -to interact with the bootloader of STM32[W]. - -.SH OPTIONS -.TP -.BI "\-a" " bus_address" -Specify address on bus for -.IR i2c_device . -This option is mandatory for I2C interface. - -.TP -.BI "\-b" " baud_rate" -Specify baud rate speed of -.IR tty_device . -Please notice that the ST bootloader can automatically detect the baud rate, -as explaned in chapter 2 of AN3155. -This option could be required together with option -.B "\-c" -or if following interaction with bootloader is expected. -Default is -.IR 57600 . - -.TP -.BI "\-m" " mode" -Specify the format of UART data. -.I mode -is a three characters long string where each character specifies, in -this strict order, character size, parity and stop bits. -The only values currenly used are -.I 8e1 -for standard STM32 bootloader and -.I 8n1 -for standard STM32W bootloader. -Default is -.IR 8e1 . - -.TP -.BI "\-r" " filename" -Specify to read the STM32[W] flash and write its content in -.I filename -in raw binary format (see below -.BR "FORMAT CONVERSION" ). - -.TP -.BI "\-w" " filename" -Specify to write the STM32[W] flash with the content of -.IR filename . -File format can be either raw binary or intel hex (see below -.BR "FORMAT CONVERSION" ). -The file format is automatically detected. -To by\-pass format detection and force binary mode (e.g. to -write an intel hex content in STM32[W] flash), use -.B \-f -option. - -.TP -.B \-u -Specify to disable write\-protection from STM32[W] flash. -The STM32[W] will be reset after this operation. - -.TP -.B \-j -Enable the flash read\-protection. - -.TP -.B \-k -Disable the flash read\-protection. - -.TP -.B \-o -Erase only. - -.TP -.BI "\-e" " num" -Specify to erase only -.I num -pages before writing the flash. Default is to erase the whole flash. With -.B \-e 0 -the flash would not be erased. - -.TP -.B \-v -Specify to verify flash content after write operation. - -.TP -.BI "\-n" " count" -Specify to retry failed writes up to -.I count -times. Default is 10 times. - -.TP -.BI "\-g" " address" -Specify address to start execution from (0 = flash start). - -.TP -.BI "\-s" " start_page" -Specify flash page offset (0 = flash start). - -.TP -.BI "\-S" " address" "[:" "length" "]" -Specify start address and optionally length for read/write/erase/crc operations. - -.TP -.BI "\-F" " RX_length" "[:" "TX_length" "]" -Specify the maximum frame size for the current interface. -Due to STM32 bootloader protocol, host will never handle frames bigger than -256 byte in RX or 258 byte in TX. -Due to current code, lowest limit in RX is 20 byte (to read a complete reply -of command GET). Minimum limit in TX is 5 byte, required by protocol. - -.TP -.B \-f -Force binary parser while reading file with -.BR "\-w" "." - -.TP -.B \-h -Show help. - -.TP -.B \-c -Specify to resume the existing UART connection and don't send initial -INIT sequence to detect baud rate. Baud rate must be kept the same as the -existing connection. This is useful if the reset fails. - -.TP -.BI "\-i" " GPIO_string" -Specify the GPIO sequences on the host to force STM32[W] to enter and -exit bootloader mode. GPIO can either be real GPIO connected from host to -STM32[W] beside the UART connection, or UART's modem signals used as -GPIO. (See below -.B BOOTLOADER GPIO SEQUENCE -for the format of -.I GPIO_string -and further explanation). - -.TP -.B \-C -Specify to compute CRC on memory content. -By default the CRC is computed on the whole flash content. -Use -.B "\-S" -to provide different memory address range. - -.TP -.B \-R -Specify to reset the device at exit. -This option is ignored if either -.BR "\-g" "," -.BR "\-j" "," -.B "\-k" -or -.B "\-u" -is also specified. - -.SH BOOTLOADER GPIO SEQUENCE -This feature is currently available on Linux host only. - -As explained in ST application note AN2606, after reset the STM32 will -execute either the application program in user flash or the bootloader, -depending on the level applied at specific pins of STM32 during reset. - -STM32 bootloader is automatically activated by configuring the pins -BOOT0="high" and BOOT1="low" and then by applying a reset. -Application program in user flash is activated by configuring the pin -BOOT0="low" (the level on BOOT1 is ignored) and then by applying a reset. - -When GPIO from host computer are connected to either configuration and -reset pins of STM32, -.B stm32flash -can control the host GPIO to reset STM32 and to force execution of -bootloader or execution of application program. - -The sequence of GPIO values to entry to and exit from bootloader mode is -provided with command line option -.B "\-i" -.IR "GPIO_string" . - -.PD 0 -The format of -.IR "GPIO_string" " is:" -.RS -GPIO_string = [entry sequence][:[exit sequence]] -.P -sequence = [\-]n[,sequence] -.RE -.P -In the above sequences, negative numbers correspond to GPIO at "low" level; -numbers without sign correspond to GPIO at "high" level. -The value "n" can either be the GPIO number on the host system or the -string "rts", "dtr" or "brk". The strings "rts" and "dtr" drive the -corresponding UART's modem lines RTS and DTR as GPIO. -The string "brk" forces the UART to send a BREAK sequence on TX line; -after BREAK the UART is returned in normal "non\-break" mode. -Note: the string "\-brk" has no effect and is ignored. -.PD - -.PD 0 -As example, let's suppose the following connection between host and STM32: -.IP \(bu 2 -host GPIO_3 connected to reset pin of STM32; -.IP \(bu 2 -host GPIO_4 connected to STM32 pin BOOT0; -.IP \(bu 2 -host GPIO_5 connected to STM32 pin BOOT1. -.PD -.P - -In this case, the sequence to enter in bootloader mode is: first put -GPIO_4="high" and GPIO_5="low"; then send reset pulse by GPIO_3="low" -followed by GPIO_3="high". -The corresponding string for -.I GPIO_string -is "4,\-5,\-3,3". - -To exit from bootloade and run the application program, the sequence is: -put GPIO_4="low"; then send reset pulse. -The corresponding string for -.I GPIO_string -is "\-4,\-3,3". - -The complete command line flag is "\-i 4,\-5,\-3,3:\-4,\-3,3". - -STM32W uses pad PA5 to select boot mode; if during reset PA5 is "low" then -STM32W will enter in bootloader mode; if PA5 is "high" it will execute the -program in flash. - -As example, supposing GPIO_3 connected to PA5 and GPIO_2 to STM32W's reset. -The command: -.PD 0 -.RS -stm32flash \-i \-3,\-2,2:3,\-2,2 /dev/ttyS0 -.RE -provides: -.IP \(bu 2 -entry sequence: GPIO_3=low, GPIO_2=low, GPIO_2=high -.IP \(bu 2 -exit sequence: GPIO_3=high, GPIO_2=low, GPIO_2=high -.PD - -.SH EXAMPLES -Get device information: -.RS -.PD 0 -.P -stm32flash /dev/ttyS0 -.PD -.RE - -Write with verify and then start execution: -.RS -.PD 0 -.P -stm32flash \-w filename \-v \-g 0x0 /dev/ttyS0 -.PD -.RE - -Read flash to file: -.RS -.PD 0 -.P -stm32flash \-r filename /dev/ttyS0 -.PD -.RE - -Start execution: -.RS -.PD 0 -.P -stm32flash \-g 0x0 /dev/ttyS0 -.PD -.RE - -Specify: -.PD 0 -.IP \(bu 2 -entry sequence: RTS=low, DTR=low, DTR=high -.IP \(bu 2 -exit sequence: RTS=high, DTR=low, DTR=high -.P -.RS -stm32flash \-i \-rts,\-dtr,dtr:rts,\-dtr,dtr /dev/ttyS0 -.PD -.RE - -.SH FORMAT CONVERSION -Flash images provided by ST or created with ST tools are often in file -format Motorola S\-Record. -Conversion between raw binary, intel hex and Motorola S\-Record can be -done through software package SRecord. - -.SH AUTHORS -The original software package -.B stm32flash -is written by -.I Geoffrey McRae -and is since 2012 maintained by -.IR "Tormod Volden " . - -Man page and extension to STM32W and I2C are written by -.IR "Antonio Borneo " . - -Please report any bugs at the project homepage -http://stm32flash.googlecode.com . - -.SH SEE ALSO -.BR "srec_cat" "(1)," " srec_intel" "(5)," " srec_motorola" "(5)." - -The communication protocol used by ST bootloader is documented in -following ST application notes, depending on communication port. -The current version of -.B stm32flash -only supports -.I UART -and -.I I2C -ports. -.PD 0 -.P -.IP \(bu 2 -AN3154: CAN protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/CD00264321.pdf -.RE - -.P -.IP \(bu 2 -AN3155: USART protocol used in the STM32(TM) bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/CD00264342.pdf -.RE - -.P -.IP \(bu 2 -AN4221: I2C protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/DM00072315.pdf -.RE - -.P -.IP \(bu 2 -AN4286: SPI protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/DM00081379.pdf -.RE - -.PD - - -Boot mode selection for STM32 is documented in ST application note -AN2606, available from the ST website: -.PD 0 -.P -http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf -.PD - -.SH LICENSE -.B stm32flash -is distributed under GNU GENERAL PUBLIC LICENSE Version 2. -Copy of the license is available within the source code in the file -.IR "gpl\-2.0.txt" . diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/utils.c b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/utils.c deleted file mode 100755 index 271bb3ed7..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/utils.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include "utils.h" - -/* detect CPU endian */ -char cpu_le() { - const uint32_t cpu_le_test = 0x12345678; - return ((const unsigned char*)&cpu_le_test)[0] == 0x78; -} - -uint32_t be_u32(const uint32_t v) { - if (cpu_le()) - return ((v & 0xFF000000) >> 24) | - ((v & 0x00FF0000) >> 8) | - ((v & 0x0000FF00) << 8) | - ((v & 0x000000FF) << 24); - return v; -} - -uint32_t le_u32(const uint32_t v) { - if (!cpu_le()) - return ((v & 0xFF000000) >> 24) | - ((v & 0x00FF0000) >> 8) | - ((v & 0x0000FF00) << 8) | - ((v & 0x000000FF) << 24); - return v; -} diff --git a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/utils.h b/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/utils.h deleted file mode 100755 index a8d37d2d5..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/stm32flash_serial/src/utils.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_UTILS -#define _H_UTILS - -#include - -char cpu_le(); -uint32_t be_u32(const uint32_t v); -uint32_t le_u32(const uint32_t v); - -#endif diff --git a/arduino/opencr_arduino/tools/macosx/src/upload-reset/upload-reset.c b/arduino/opencr_arduino/tools/macosx/src/upload-reset/upload-reset.c deleted file mode 100755 index 1d03bff51..000000000 --- a/arduino/opencr_arduino/tools/macosx/src/upload-reset/upload-reset.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (C) 2015 Roger Clark - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * - * Utility to send the reset sequence on RTS and DTR and chars - * which resets the libmaple and causes the bootloader to be run - * - * - * - * Terminal control code by Heiko Noordhof (see copyright below) - */ - - - -/* Copyright (C) 2003 Heiko Noordhof - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Function prototypes (belong in a seperate header file) */ -int openserial(char *devicename); -void closeserial(void); -int setDTR(unsigned short level); -int setRTS(unsigned short level); - - -/* Two globals for use by this module only */ -static int fd; -static struct termios oldterminfo; - - -void closeserial(void) -{ - tcsetattr(fd, TCSANOW, &oldterminfo); - close(fd); -} - - -int openserial(char *devicename) -{ - struct termios attr; - - if ((fd = open(devicename, O_RDWR)) == -1) return 0; /* Error */ - atexit(closeserial); - - if (tcgetattr(fd, &oldterminfo) == -1) return 0; /* Error */ - attr = oldterminfo; - attr.c_cflag |= CRTSCTS | CLOCAL; - attr.c_oflag = 0; - if (tcflush(fd, TCIOFLUSH) == -1) return 0; /* Error */ - if (tcsetattr(fd, TCSANOW, &attr) == -1) return 0; /* Error */ - - /* Set the lines to a known state, and */ - /* finally return non-zero is successful. */ - return setRTS(0) && setDTR(0); -} - - -/* For the two functions below: - * level=0 to set line to LOW - * level=1 to set line to HIGH - */ - -int setRTS(unsigned short level) -{ - int status; - - if (ioctl(fd, TIOCMGET, &status) == -1) { - perror("setRTS(): TIOCMGET"); - return 0; - } - if (level) status |= TIOCM_RTS; - else status &= ~TIOCM_RTS; - if (ioctl(fd, TIOCMSET, &status) == -1) { - perror("setRTS(): TIOCMSET"); - return 0; - } - return 1; -} - - -int setDTR(unsigned short level) -{ - int status; - - if (ioctl(fd, TIOCMGET, &status) == -1) { - perror("setDTR(): TIOCMGET"); - return 0; - } - if (level) status |= TIOCM_DTR; - else status &= ~TIOCM_DTR; - if (ioctl(fd, TIOCMSET, &status) == -1) { - perror("setDTR: TIOCMSET"); - return 0; - } - return 1; -} - -/* This portion of code was written by Roger Clark - * It was informed by various other pieces of code written by Leaflabs to reset their - * Maple and Maple mini boards - */ - -main(int argc, char *argv[]) -{ - - if (argc<2 || argc >3) - { - printf("Usage upload-reset \n\r"); - return; - } - - if (openserial(argv[1])) - { - // Send magic sequence of DTR and RTS followed by the magic word "1EAF" - setRTS(false); - setDTR(false); - setDTR(true); - - usleep(50000L); - - setDTR(false); - setRTS(true); - setDTR(true); - - usleep(50000L); - - setDTR(false); - - usleep(50000L); - - write(fd,"1EAF",4); - - closeserial(); - if (argc==3) - { - usleep(atol(argv[2])*1000L); - } - } - else - { - printf("Failed to open serial device.\n\r"); - } -} diff --git a/arduino/opencr_arduino/tools/macosx/stlink/st-flash b/arduino/opencr_arduino/tools/macosx/stlink/st-flash deleted file mode 100755 index 6480b3f38..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/stlink/st-flash and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/stlink/st-info b/arduino/opencr_arduino/tools/macosx/stlink/st-info deleted file mode 100755 index 4e0ac3053..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/stlink/st-info and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/stlink/st-term b/arduino/opencr_arduino/tools/macosx/stlink/st-term deleted file mode 100755 index 9690069cf..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/stlink/st-term and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/stlink/st-util b/arduino/opencr_arduino/tools/macosx/stlink/st-util deleted file mode 100755 index f37b666b7..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/stlink/st-util and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/stlink_upload b/arduino/opencr_arduino/tools/macosx/stlink_upload deleted file mode 100755 index 7c107c79f..000000000 --- a/arduino/opencr_arduino/tools/macosx/stlink_upload +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -$(dirname $0)/stlink/st-flash write "$4" 0x8000000 diff --git a/arduino/opencr_arduino/tools/macosx/stm32flash/stm32flash b/arduino/opencr_arduino/tools/macosx/stm32flash/stm32flash deleted file mode 100755 index dc8d42241..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/stm32flash/stm32flash and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/upload-reset b/arduino/opencr_arduino/tools/macosx/upload-reset deleted file mode 100755 index 29290310b..000000000 Binary files a/arduino/opencr_arduino/tools/macosx/upload-reset and /dev/null differ diff --git a/arduino/opencr_arduino/tools/macosx/upload_router b/arduino/opencr_arduino/tools/macosx/upload_router deleted file mode 100755 index 5743986ba..000000000 --- a/arduino/opencr_arduino/tools/macosx/upload_router +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -set -e - -if [ $# -lt 4 ]; then - echo "Usage: $0 $# " >&2 - exit 1 -fi -dummy_port=$1; altID=$2; usbID=$3; binfile=$4 - -DFU_UTIL=/usr/local/bin/dfu-util -if [ ! -x ${DFU_UTIL} ]; then - DFU_UTIL=/opt/local/bin/dfu-util -fi - -if [ ! -x ${DFU_UTIL} ]; then - echo "$0: error: cannot find ${DFU_UTIL}" >&2 - exit 2 -fi - -${DFU_UTIL} -d ${usbID} -a ${altID} -D ${binfile} diff --git a/arduino/opencr_arduino/tools/win/bmp_upload.bat b/arduino/opencr_arduino/tools/win/bmp_upload.bat deleted file mode 100755 index 47cb445b4..000000000 --- a/arduino/opencr_arduino/tools/win/bmp_upload.bat +++ /dev/null @@ -1,11 +0,0 @@ -rem: @echo off -rem: Note %~dp0 get path of this batch file -rem: Need to change drive if My Documents is on a drive other than C: -set driverLetter=%~dp0 -set driverLetter=%driverLetter:~0,2% -%driverLetter% -cd %~dp0 -rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name -set str=%4 -set str=%str:/=\% -%1arm-none-eabi-gdb.exe -b %2 -ex "set debug remote 0" -ex "set target-async off" -ex "set remotetimeout 60" -ex "set confirm off" -ex "set height 0" -ex %3 -ex "monitor swdp_scan" -ex "attach 1" -ex "x/wx 0x8000004" -ex "monitor erase_mass" -ex "echo 0x8000004 expect 0xffffffff after erase\n" -ex "x/wx 0x8000004" -ex "file %str%" -ex "load" -ex "x/i *0x8000004" -ex "kill" -ex "tbreak main" -ex "run" -ex "detach" -ex "echo \n\n\n%6 uploaded!\n" -ex "quit" diff --git a/arduino/opencr_arduino/tools/win/lib/jssc.jar b/arduino/opencr_arduino/tools/win/lib/jssc.jar deleted file mode 100755 index d2b5c070a..000000000 Binary files a/arduino/opencr_arduino/tools/win/lib/jssc.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/maple_loader.jar b/arduino/opencr_arduino/tools/win/maple_loader.jar deleted file mode 100755 index e64676cef..000000000 Binary files a/arduino/opencr_arduino/tools/win/maple_loader.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/maple_upload.bat b/arduino/opencr_arduino/tools/win/maple_upload.bat deleted file mode 100755 index 678969c56..000000000 --- a/arduino/opencr_arduino/tools/win/maple_upload.bat +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -rem: Note %~dp0 get path of this batch file -rem: Need to change drive if My Documents is on a drive other than C: -set driverLetter=%~dp0 -set driverLetter=%driverLetter:~0,2% -%driverLetter% -cd %~dp0 -java -jar maple_loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9 diff --git a/arduino/opencr_arduino/tools/win/serial_upload.bat b/arduino/opencr_arduino/tools/win/serial_upload.bat deleted file mode 100755 index d733be745..000000000 --- a/arduino/opencr_arduino/tools/win/serial_upload.bat +++ /dev/null @@ -1,23 +0,0 @@ -@echo off -rem: Note %~dp0 get path of this batch file -rem: Need to change drive if My Documents is on a drive other than C: -set driverLetter=%~dp0 -set driverLetter=%driverLetter:~0,2% -%driverLetter% -cd %~dp0 -rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name -set str=%4 -set str=%str:/=\% -stm32flash -g 0x8000000 -b 230400 -w %str% %1 -rem: C:\Python27\python.exe stm32loader.py -e -w -p %1 -g -b 115200 %str% - -rem: ------------- use STM's own uploader -rem: ---- Need to remove the COM bit from the comm port as the STM prog just wants the number -set commport=%1 -set commportnum=%commport:COM=% -rem: --- The maple board may nee the -i setting to be -i STM32_Med-density_128K or STM32_Med-density_64K -rem: ---- 64 bit version -rem: "%ProgramFiles(x86)%\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe" -c --pn %commportnum% --br 230400 -i STM32_High-density_256K -e --all -d --fn %str% --a 0x8000000 -r --a 0x8000000 - -rem: -- 32 bit version -rem: "%ProgramFiles%\STMicroelectronics\Software\Flash Loader Demonstrator\STMFlashLoader.exe" -c --pn %commportnum% --br 230400 -i STM32_Med-density_64K -e --all -d --fn %str% --a 0x8000000 -r --a 0x8000000 diff --git a/arduino/opencr_arduino/tools/win/src/build_dfu-util.sh b/arduino/opencr_arduino/tools/win/src/build_dfu-util.sh deleted file mode 100755 index 3563f576c..000000000 --- a/arduino/opencr_arduino/tools/win/src/build_dfu-util.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -sudo apt-get build-dep dfu-util -sudo apt-get install build-essentials -sudo apt-get install libusb-1.0-0-dev -sudo apt-get install autoconf automake autotools-dev - -cd dfu-util -./autogen.sh -./configure -make -cp src/dfu-util ../../linux/dfu-util -cp src/dfu-suffix ../../linux/dfu-util -cp src/dfu-prefix ../../linux/dfu-util - diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/AUTHORS b/arduino/opencr_arduino/tools/win/src/dfu-util/AUTHORS deleted file mode 100755 index 1b36c739c..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/AUTHORS +++ /dev/null @@ -1,30 +0,0 @@ -Authors ordered by first contribution. - -Harald Welte -Werner Almesberger -Michael Lauer -Jim Huang -Stefan Schmidt -Daniel Willmann -Mike Frysinger -Uwe Hermann -C. Scott Ananian -Bernard Blackham -Holger Freyther -Marc Singer -James Perkins -Tommi Keisala -Pascal Schweizer -Bradley Scott -Uwe Bonnes -Andrey Smirnov -Jussi Timperi -Hans Petter Selasky -Bo Shen -Henrique de Almeida Mendonca -Bernd Krumboeck -Dennis Meier -Veli-Pekka Peltola -Dave Hylands -Michael Grzeschik -Paul Fertser diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/COPYING b/arduino/opencr_arduino/tools/win/src/dfu-util/COPYING deleted file mode 100755 index d60c31a97..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/COPYING +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/ChangeLog b/arduino/opencr_arduino/tools/win/src/dfu-util/ChangeLog deleted file mode 100755 index 37f1addba..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/ChangeLog +++ /dev/null @@ -1,93 +0,0 @@ -0.8: - o New, separate dfu-prefix tool (Uwe Bonnes) - o Allow filtering on serial number (Uwe Bonnes) - o Improved VID/PID/serial filtering (Bradley Scott) - o Support reading firmware from stdin (Tormod Volden) - o Warn if missing DFU suffix (Tormod Volden) - o Improved progress bar (Hans Petter Selasky) - o Fix dfuse leave option (Uwe Bonnes) - o Major code rework (Hans Petter Selasky) - o MS Visual Studio build support (Henrique Mendonca) - o dfuse-pack.py tool for .dfu files (Antonio Galeo) - o Many other fixes from many people - -2014-09-13: Tormod Volden - -0.7: - o Support for TI Stellaris devices (Tommi Keisala) - o Fix libusb detection on MacOSX (Marc Singer) - o Fix libusb detection on FreeBSD (Tormod Volden) - o Improved DfuSe support (Tormod Volden) - o Support all special commands (leave, unprotect, mass-erase) - o Arbitrary upload lengths - o "force" option for various possible (dangerous) overrides - -2012-10-07: Tormod Volden - -0.6: - o Add detach mode (Stefan Schmidt) - o Check return value on all libusb calls (Tormod Volden) - o Fix segmentation fault with -s option (Tormod Volden) - o Add DFU suffix manipulation tool (Stefan Schmidt) - o Port to Windows: (Tormod Volden, some parts based on work from Satz - Klauer) - o Port file handling to stdio streams - o Sleep() macros - o C99 types - o Pack structs - o Detect DfuSe device correctly on big-endian architectures (Tormod - Volden) - o Add dfuse progress indication on download (Tormod Volden) - o Cleanup: gcc pedantic, gcc extension, ... (Tormod Volden) - o Rely on page size from functional descriptor. Please report if you get - an error about it. (Tormod Volden) - o Add quirk for Maple since it reports wrong DFU version (Tormod Volden) - -2012-04-22: Stefan Schmidt - -0.5: - o DfuSe extension support for ST devices (Tormod Volden) - o Add initial support for bitWillDetach flag from DFU 1.1 (Tormod - Volden) - o Internal cleanup and some manual page fixes (Tormod Volden) - -2011-11-02: Stefan Schmidt - -0.4: - o Rework to use libusb-1.0 (Stefan Schmidt) - o DFU suffix support (Tormod Volden, Stefan Schmidt) - o Sspeed up DFU downloads directly into memory (Bernard Blackham) - o More flexible -d vid:pid parsing (Tormod Volden) - o Many bug fixes and cleanups - -2011-07-20: Stefan Schmidt - -0.3: - o quirks: Add OpenOCD to the poll timeout quirk table. - -2010-12-22: Stefan Schmidt - -0.2: - o Fix some typos on the website and the README (Antonio Ospite, Uwe - Hermann) - o Remove build rule for a static binary. We can use autotools for this. - (Mike Frysinger) - o Fix infinite loop in download error path (C. Scott Ananian) - o Break out to show the 'finished' in upload (C. Scott Ananian) - o Add GPLv2+ headers (Harald Welte) - o Remove dead code (commands.[ch]) remnescent of dfu-programmer (Harald - Welte) - o Simple quirk system with Openmoko quirk for missing bwPollTimeout (Tormod Volden) - o New default (1024) and clamping of transfer size (Tormod Volden) - o Verify sending of completion packet (Tormod Volden) - o Look for DFU functional descriptor among all descriptors (Tormod - Volden) - o Print out in which direction we are transferring data - o Abort in upload if the file already exists - -2010-11-17 Stefan Schmidt - -0.1: - Initial release - -2010-05-23 Stefan Schmidt diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/DEVICES.txt b/arduino/opencr_arduino/tools/win/src/dfu-util/DEVICES.txt deleted file mode 100755 index bdd9f1f2e..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/DEVICES.txt +++ /dev/null @@ -1,20 +0,0 @@ -List of supported software and hardware products: - -Software user (bootloader, etc) -------------------------------- -- Sam7DFU: http://www.openpcd.org/Sam7dfu -- U-boot: DFU patches -- Barebox: http://www.barebox.org/ -- Leaflabs: http://code.google.com/p/leaflabs/ -- Blackmagic DFU - -Products using DFU ------------------- -- OpenPCD (sam7dfu) -- Openmoko Neo 1973 and Freerunner (u-boot with DFU patches) -- Leaflabs Maple -- ATUSB from Qi Hardware -- STM32F105/7, STM32F2/F3/F4 in System Bootloader -- Blackmagic debug probe -- NXP LPC31xx/LPC43XX, e.g. LPC-Link and LPC-Link2, need binaries - with LPC prefix and encoding (LPC-Link) diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/Makefile.am b/arduino/opencr_arduino/tools/win/src/dfu-util/Makefile.am deleted file mode 100755 index 641dda58a..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/Makefile.am +++ /dev/null @@ -1,3 +0,0 @@ -SUBDIRS = src doc - -EXTRA_DIST = autogen.sh TODO DEVICES.txt dfuse-pack.py diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/README b/arduino/opencr_arduino/tools/win/src/dfu-util/README deleted file mode 100755 index 0f8f2621a..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/README +++ /dev/null @@ -1,20 +0,0 @@ -Dfu-util - Device Firmware Upgrade Utilities - -Dfu-util is the host side implementation of the DFU 1.0 [1] and DFU 1.1 [2] -specification of the USB forum. - -DFU is intended to download and upload firmware to devices connected over -USB. It ranges from small devices like micro-controller boards up to mobile -phones. With dfu-util you are able to download firmware to your device or -upload firmware from it. - -dfu-util has been tested with Openmoko Neo1973 and Freerunner and many -other devices. - -[1] DFU 1.0 spec: http://www.usb.org/developers/devclass_docs/usbdfu10.pdf -[2] DFU 1.1 spec: http://www.usb.org/developers/devclass_docs/DFU_1.1.pdf - -The official website is: - - http://dfu-util.gnumonks.org/ - diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/TODO b/arduino/opencr_arduino/tools/win/src/dfu-util/TODO deleted file mode 100755 index 900c30c29..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/TODO +++ /dev/null @@ -1,14 +0,0 @@ -DfuSe: -- Do erase and write in two separate passes when downloading -- Skip "Set Address" command when downloading contiguous blocks -- Implement "Get Commands" command - -Devices: -- Research iPhone/iPod/iPad support - Heavily modified dfu-util fork here: - https://github.com/planetbeing/xpwn/tree/master/dfu-util -- Test against Niftylights - -Non-Code: -- Logo -- Re-License as LGPL for usage as library? diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/autogen.sh b/arduino/opencr_arduino/tools/win/src/dfu-util/autogen.sh deleted file mode 100755 index e67aed39a..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/autogen.sh +++ /dev/null @@ -1,2 +0,0 @@ -#! /bin/sh -autoreconf -v -i diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/configure.ac b/arduino/opencr_arduino/tools/win/src/dfu-util/configure.ac deleted file mode 100755 index 86221143f..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/configure.ac +++ /dev/null @@ -1,41 +0,0 @@ -# -*- Autoconf -*- -# Process this file with autoconf to produce a configure script. - -AC_PREREQ(2.59) -AC_INIT([dfu-util],[0.8],[dfu-util@lists.gnumonks.org],,[http://dfu-util.gnumonks.org]) -AC_CONFIG_AUX_DIR(m4) -AM_INIT_AUTOMAKE([foreign]) -AC_CONFIG_HEADERS([config.h]) - -# Test for new silent rules and enable only if they are available -m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) - -# Checks for programs. -AC_PROG_CC - -# Checks for libraries. -# On FreeBSD the libusb-1.0 is called libusb and resides in system location -AC_CHECK_LIB([usb], [libusb_init],, [native_libusb=no],) -AS_IF([test x$native_libusb = xno], [ - PKG_CHECK_MODULES([USB], [libusb-1.0 >= 1.0.0],, - AC_MSG_ERROR([*** Required libusb-1.0 >= 1.0.0 not installed ***])) -]) -AC_CHECK_LIB([usbpath],[usb_path2devnum],,,-lusb) - -LIBS="$LIBS $USB_LIBS" -CFLAGS="$CFLAGS $USB_CFLAGS" - -# Checks for header files. -AC_HEADER_STDC -AC_CHECK_HEADERS([usbpath.h windows.h sysexits.h]) - -# Checks for typedefs, structures, and compiler characteristics. -AC_C_CONST -AC_TYPE_SIZE_T - -# Checks for library functions. -AC_FUNC_MEMCMP -AC_CHECK_FUNCS([ftruncate getpagesize nanosleep err]) - -AC_CONFIG_FILES(Makefile src/Makefile doc/Makefile) -AC_OUTPUT diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/README b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/README deleted file mode 100755 index 00d3d1a96..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/README +++ /dev/null @@ -1,77 +0,0 @@ -Device: -------- -qi-hardware-atusb: -- Qi Hardware ben-wpan -- DFU implementation: - http://projects.qi-hardware.com/index.php/p/ben-wpan/source/tree/master/atusb/fw/usb -- Tester: Stefan Schmidt - -openpcd: -- OpenPCD RFID reader -- DFU implementation: SAM7DFU - http://www.openpcd.org/Sam7dfu, git://git.gnumonks.org/openpcd.git -- Tester: Stefan Schmidt - -simtrace: -- Sysmocom SimTrace -- DFU implementation: SAM7DFU - http://www.openpcd.org/Sam7dfu, git://git.gnumonks.org/openpcd.git -- Tester: Stefan Schmidt - -openmoko-freerunner: -- Openmoko Freerunner -- DFU implementation: Old U-Boot - http://git.openmoko.org/?p=u-boot.git;a=shortlog;h=refs/heads/mokopatches -- Tester: Stefan Schmidt - -openmoko-neo1973: -- Openmoko Neo1073 -- DFU implementation: Old U-Boot - http://git.openmoko.org/?p=u-boot.git;a=shortlog;h=refs/heads/mokopatches -- Tester: Stefan Schmidt - -tdk-bluetooth: -- TDK Corp. Bluetooth Adapter -- DFU implementation: closed soure -- Only upload has been tested -- Tester: Stefan Schmidt - -stm32f107: -- STM32 microcontrollers with built-in (ROM) DFU loader -- DFU implementation: Closed source but probably similar to the one - in their USB device libraries. Some relevant application notes: - http://www.st.com -> AN3156 and AN2606 -- Tested by Uwe Bonnes - -stm32f4discovery: -- STM32 microcontroller board with built-in (ROM) DFU loader -- DFU implementation: Closed source, probably similar to stm32f107. -- Tested by Joe Rothweiler - -dso-nano: -- DSO Nano pocket oscilloscope -- DFU implementation: Based on ST Microelectronics USB FS Library 1.0 - http://dsonano.googlecode.com/files/DS0201_OpenSource.rar -- Tester: Tormod Volden - -opc-20: -- Custom devices based on STM32F1xx -- DFU implementation: ST Microelectronics USB FS Device Library 3.1.0 - http://www.st.com -> um0424.zip -- Tester: Tormod Volden - -lpc-link, lpclink2: -- NXP LPCXpresso debug adapters -- Proprietary DFU implementation, uses special download files with - LPC prefix and encoding of the target firmware code -- Tested by Uwe Bonnes - -Adding the lsusb output and a download log of your device here helps -us to avoid regressions for hardware we cannot test while working on -the code. To extract the lsusb output use this command: -sudo lsusb -v -d $USBID > $DEVICE.lsusb -Prepare a description snippet as above, and send it to us. A log -(copy-paste of the command window) of a firmware download is also -nice, please use the double verbose option -v -v and include the -command line in the log file. - diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/dsonano.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/dsonano.lsusb deleted file mode 100755 index 140a7bc6c..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/dsonano.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 002 Device 004: ID 0483:df11 SGS Thomson Microelectronics -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 - bcdDevice 1.1a - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 DFU - iSerial 3 001 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 64mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 4 @Internal Flash /0x08000000/12*001Ka,116*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 5 @SPI Flash : M25P64/0x00000000/64*064Kg,64*064Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1.1a -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink.log b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink.log deleted file mode 100755 index 7de4dd3e6..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink.log +++ /dev/null @@ -1,59 +0,0 @@ -(The on-board LPC3154 has some encryption key set and LPCXpressoWIN.enc -is encrypted.) - -$ lsusb | grep NXP -Bus 003 Device 011: ID 0471:df55 Philips (or NXP) LPCXpresso LPC-Link - -$ dfu-util -v -v -v -R -D /opt/lpc/lpcxpresso/bin/LPCXpressoWIN.enc - -dfu-util 0.7 - -Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. -Copyright 2010-2012 Tormod Volden and Stefan Schmidt -This program is Free Software and has ABSOLUTELY NO WARRANTY -Please report bugs to dfu-util@lists.gnumonks.org - -dfu-util: Invalid DFU suffix signature -dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! -Deducing device DFU version from functional descriptor length -Opening DFU capable USB device... -ID 0471:df55 -Run-time device DFU version 0100 -Claiming USB DFU Runtime Interface... -Determining device status: -state = dfuIDLE, status = 0 -dfu-util: WARNING: Runtime device already in DFU state ?!? -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: -state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 0100 -Device returned transfer size 2048 -Copying data from PC to DFU device -Download [ ] 0% 0 bytes -Download [= ] 6% 2048 bytes -Download [=== ] 13% 4096 bytes -Download [==== ] 19% 6144 bytes -Download [====== ] 26% 8192 bytes -Download [======== ] 32% 10240 bytes -Download [========= ] 39% 12288 bytes -Download [=========== ] 45% 14336 bytes -Download [============= ] 52% 16384 bytes -Download [============== ] 59% 18432 bytes -Download [================ ] 65% 20480 bytes -Download [================== ] 72% 22528 bytes -Download [=================== ] 78% 24576 bytes -Download [===================== ] 85% 26624 bytes -Download [====================== ] 91% 28672 bytes -Download [======================== ] 98% 29192 bytes -Download [=========================] 100% 29192 bytes -Download done. -Sent a total of 29192 bytes -state(8) = dfuMANIFEST-WAIT-RESET, status(0) = No error condition is present -Done! -dfu-util: can't detach -Resetting USB to switch back to runtime mode - -$ lsusb | grep NXP -Bus 003 Device 012: ID 1fc9:0009 NXP Semiconductors diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink.lsusb deleted file mode 100755 index 867b2a2c5..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink.lsusb +++ /dev/null @@ -1,58 +0,0 @@ - -Bus 003 Device 008: ID 0471:df55 Philips (or NXP) LPCXpresso LPC-Link -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0471 Philips (or NXP) - idProduct 0xdf55 LPCXpresso LPC-Link - bcdDevice 0.01 - iManufacturer 0 - iProduct 0 - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 25 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 7 - bDescriptorType 33 - bmAttributes 1 - Will Not Detach - Manifestation Intolerant - Upload Unsupported - Download Supported - wDetachTimeout 65535 milliseconds - wTransferSize 2048 bytes -Device Qualifier (for other device speed): - bLength 10 - bDescriptorType 6 - bcdUSB 2.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - bNumConfigurations 1 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink2.log b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink2.log deleted file mode 100755 index 4681eff7d..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink2.log +++ /dev/null @@ -1,59 +0,0 @@ -$ lsusb | grep NXP -Bus 003 Device 013: ID 1fc9:000c NXP Semiconductors - -$ dfu-util -D ~/devel/dfu-util/firmware.bin.qthdr - -dfu-util 0.7 - -Copyright 2005-2008 Weston Schmidt, Harald Welte and OpenMoko Inc. -Copyright 2010-2012 Tormod Volden and Stefan Schmidt -This program is Free Software and has ABSOLUTELY NO WARRANTY -Please report bugs to dfu-util@lists.gnumonks.org - -dfu-util: Invalid DFU suffix signature -dfu-util: A valid DFU suffix will be required in a future dfu-util release!!! -Possible unencryptes NXP LPC DFU prefix with the following properties -Payload length: 39 kiByte -Opening DFU capable USB device... -ID 1fc9:000c -Run-time device DFU version 0100 -Claiming USB DFU Runtime Interface... -Determining device status: -state = dfuIDLE, status = 0 -dfu-util: WARNING: Runtime device already in DFU state ?!? -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: -state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 0100 -Device returned transfer size 2048 -Copying data from PC to DFU device -Download [ ] 0% 0 bytes -Download [= ] 4% 2048 bytes -Download [== ] 9% 4096 bytes -Download [=== ] 14% 6144 bytes -Download [==== ] 19% 8192 bytes -Download [====== ] 24% 10240 bytes -Download [======= ] 28% 12288 bytes -Download [======== ] 33% 14336 bytes -Download [========= ] 38% 16384 bytes -Download [========== ] 43% 18432 bytes -Download [============ ] 48% 20480 bytes -Download [============= ] 53% 22528 bytes -Download [============== ] 57% 24576 bytes -Download [=============== ] 62% 26624 bytes -Download [================ ] 67% 28672 bytes -Download [================== ] 72% 30720 bytes -Download [=================== ] 77% 32768 bytes -Download [==================== ] 82% 34816 bytes -Download [===================== ] 86% 36864 bytes -Download [====================== ] 91% 38912 bytes -Download [======================== ] 96% 40356 bytes -Download [=========================] 100% 40356 bytes -Download done. -Sent a total of 40356 bytes -dfu-util: unable to read DFU status - -$ lsusb | grep NXP -Bus 003 Device 014: ID 1fc9:0018 NXP Semiconductors diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink2.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink2.lsusb deleted file mode 100755 index b833fca77..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/lpclink2.lsusb +++ /dev/null @@ -1,203 +0,0 @@ - -Bus 003 Device 007: ID 0c72:000c PEAK System PCAN-USB -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x0c72 PEAK System - idProduct 0x000c PCAN-USB - bcdDevice 1c.ff - iManufacturer 0 - iProduct 3 VER1:PEAK -VER2:02.8.01 -DAT :06.05.2004 -TIME:09:35:37 - ... - iSerial 0 - bNumConfigurations 3 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 2 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 394mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 20 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 46 - bNumInterfaces 1 - bConfigurationValue 3 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 4 - bInterfaceClass 0 (Defined at Interface level) - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x01 EP 1 OUT - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/opc-20.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/opc-20.lsusb deleted file mode 100755 index 580df90e5..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/opc-20.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 004: ID 0483:df11 SGS Thomson Microelectronics -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 - bcdDevice 2.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 DFU - iSerial 3 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/12*001Ka,116*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @SPI Flash : M25P64/0x00000000/128*64Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1a.01 -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb deleted file mode 100755 index 4c0abfb06..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openmoko-freerunner-dfumode.lsusb +++ /dev/null @@ -1,109 +0,0 @@ -Bus 003 Device 017: ID 1d50:5119 OpenMoko, Inc. GTA01/GTA02 U-Boot Bootloader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x5119 GTA01/GTA02 U-Boot Bootloader - bcdDevice 0.00 - iManufacturer 1 OpenMoko, Inc - iProduct 2 Neo1973 Bootloader U-Boot 1.3.2-moko12 - iSerial 3 0000000 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 81 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 7 USB Device Firmware Upgrade - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 8 RAM 0x32000000 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 9 u-boot - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 10 u-boot_env - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 3 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 11 kernel - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 4 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 12 splash - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 5 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 13 factory - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 6 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 14 rootfs - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 -Device Status: 0x0a00 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openmoko-freerunner.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openmoko-freerunner.lsusb deleted file mode 100755 index 835708dd8..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openmoko-freerunner.lsusb +++ /dev/null @@ -1,179 +0,0 @@ -Bus 005 Device 033: ID 1d50:5119 OpenMoko, Inc. GTA01/GTA02 U-Boot Bootloader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.10 - bDeviceClass 2 Communications - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x5119 GTA01/GTA02 U-Boot Bootloader - bcdDevice 0.00 - iManufacturer 1 OpenMoko, Inc - iProduct 2 Neo1973 Bootloader U-Boot 1.3.2-moko12 - iSerial 3 0000000 - bNumConfigurations 2 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 85 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 4 TTY via USB - bmAttributes 0x80 - (Bus Powered) - MaxPower 500mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 Control Interface - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 Bulk Data Interface - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 7 USB Device Firmware Upgrade - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 67 - bNumInterfaces 2 - bConfigurationValue 2 - iConfiguration 4 TTY via USB - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 Control Interface - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 Bulk Data Interface - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 -Device Status: 0x9a00 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openmoko-neo1973.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openmoko-neo1973.lsusb deleted file mode 100755 index 07789506a..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openmoko-neo1973.lsusb +++ /dev/null @@ -1,182 +0,0 @@ - -Bus 006 Device 020: ID 1457:5119 First International Computer, Inc. OpenMoko Neo1973 u-boot cdc_acm serial port -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.10 - bDeviceClass 2 Communications - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 16 - idVendor 0x1457 First International Computer, Inc. - idProduct 0x5119 OpenMoko Neo1973 u-boot cdc_acm serial port - bcdDevice 0.00 - iManufacturer 1 - iProduct 2 - iSerial 3 - bNumConfigurations 2 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 85 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 4 - bmAttributes 0x80 - (Bus Powered) - MaxPower 500mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 7 - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 4096 bytes - bcdDFUVersion 1.00 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 67 - bNumInterfaces 2 - bConfigurationValue 2 - iConfiguration 4 - bmAttributes 0x80 - (Bus Powered) - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 2 Communications - bInterfaceSubClass 2 Abstract (modem) - bInterfaceProtocol 1 AT-commands (v.25ter) - iInterface 6 - CDC Header: - bcdCDC 0.6e - CDC Call Management: - bmCapabilities 0x00 - bDataInterface 1 - CDC ACM: - bmCapabilities 0x00 - CDC Union: - bMasterInterface 0 - bSlaveInterface 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 10 CDC Data - bInterfaceSubClass 0 Unused - bInterfaceProtocol 0 - iInterface 5 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 255 -Device Status: 0x0006 - (Bus Powered) - Remote Wakeup Enabled - Test Mode diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openpcd.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openpcd.lsusb deleted file mode 100755 index f6255a943..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/openpcd.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 006 Device 016: ID 16c0:076b VOTI OpenPCD 13.56MHz RFID Reader -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 8 - idVendor 0x16c0 VOTI - idProduct 0x076b OpenPCD 13.56MHz RFID Reader - bcdDevice 0.00 - iManufacturer 1 - iProduct 2 OpenPCD RFID Simulator - DFU Mode - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 0 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 3 - Will Not Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 256 bytes - bcdDFUVersion 1.00 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/qi-hardware-atusb.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/qi-hardware-atusb.lsusb deleted file mode 100755 index bfc1701e1..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/qi-hardware-atusb.lsusb +++ /dev/null @@ -1,59 +0,0 @@ - -Bus 006 Device 013: ID 20b7:1540 Qi Hardware ben-wpan, AT86RF230-based -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 255 Vendor Specific Class - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x20b7 Qi Hardware - idProduct 0x1540 ben-wpan, AT86RF230-based - bcdDevice 0.01 - iManufacturer 0 - iProduct 0 - iSerial 1 4630333438371508231a - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 34 - bNumInterfaces 2 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 40mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 1 - bInterfaceClass 255 Vendor Specific Class - bInterfaceSubClass 0 - bInterfaceProtocol 0 - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 0 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 1 - iInterface 0 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/simtrace.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/simtrace.lsusb deleted file mode 100755 index 578ddf0e1..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/simtrace.lsusb +++ /dev/null @@ -1,70 +0,0 @@ - -Bus 006 Device 017: ID 16c0:0762 VOTI -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 8 - idVendor 0x16c0 VOTI - idProduct 0x0762 - bcdDevice 0.00 - iManufacturer 1 sysmocom - systems for mobile communications GmbH - iProduct 2 SimTrace SIM Sniffer - DFU Mode - iSerial 0 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 45 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 3 SimTrace DFU Configuration - bmAttributes 0x80 - (Bus Powered) - MaxPower 200mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 SimTrace DFU Interface - Application Partition - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 SimTrace DFU Interface - Bootloader Partition - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 6 SimTrace DFU Interface - RAM - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 3 - Will Not Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 65280 milliseconds - wTransferSize 256 bytes - bcdDFUVersion 1.00 -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/sparkcore.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/sparkcore.lsusb deleted file mode 100755 index b6029ffa5..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/sparkcore.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 008: ID 1d50:607f OpenMoko, Inc. -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x1d50 OpenMoko, Inc. - idProduct 0x607f - bcdDevice 2.00 - iManufacturer 1 Spark Devices - iProduct 2 CORE DFU - iSerial 3 8D80527B5055 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/20*001Ka,108*001Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @SPI Flash : SST25x/0x00000000/512*04Kg - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 1024 bytes - bcdDFUVersion 1.1a -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f107.bin-download b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f107.bin-download deleted file mode 100755 index 45b714f83..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f107.bin-download +++ /dev/null @@ -1,48 +0,0 @@ -> src/dfu-util --intf 0 --alt 0 -v -v -v -s 0x8000000 -D test3 -dfu-util 0.4 - -(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. -(C) 2010-2011 Tormod Volden (DfuSe support) -This program is Free Software and has ABSOLUTELY NO WARRANTY - -dfu-util does currently only support DFU version 1.0 - -Opening DFU USB device... ID 0483:df11 -Run-time device DFU version 011a -Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/128*002Kg" -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 011a -Device returned transfer size 2048 -No valid DFU suffix signature -Warning: File has no DFU suffix -DfuSe interface name: "Internal Flash " -Memory segment at 0x08000000 128 x 2048 = 262144 (rew) -Uploading to address = 0x08000000, size = 16384 -Erasing page size 2048 at address 0x08000000, page starting at 0x08000000 - Download from image offset 00000000 to memory 08000000-080007ff, size 2048 - Setting address pointer to 0x08000000 -Erasing page size 2048 at address 0x08000800, page starting at 0x08000800 - Download from image offset 00000800 to memory 08000800-08000fff, size 2048 - Setting address pointer to 0x08000800 -Erasing page size 2048 at address 0x08001000, page starting at 0x08001000 - Download from image offset 00001000 to memory 08001000-080017ff, size 2048 - Setting address pointer to 0x08001000 -Erasing page size 2048 at address 0x08001800, page starting at 0x08001800 - Download from image offset 00001800 to memory 08001800-08001fff, size 2048 - Setting address pointer to 0x08001800 -Erasing page size 2048 at address 0x08002000, page starting at 0x08002000 - Download from image offset 00002000 to memory 08002000-080027ff, size 2048 - Setting address pointer to 0x08002000 -Erasing page size 2048 at address 0x08002800, page starting at 0x08002800 - Download from image offset 00002800 to memory 08002800-08002fff, size 2048 - Setting address pointer to 0x08002800 -Erasing page size 2048 at address 0x08003000, page starting at 0x08003000 - Download from image offset 00003000 to memory 08003000-080037ff, size 2048 - Setting address pointer to 0x08003000 -Erasing page size 2048 at address 0x08003800, page starting at 0x08003800 - Download from image offset 00003800 to memory 08003800-08003fff, size 2048 - Setting address pointer to 0x08003800 - diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f107.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f107.lsusb deleted file mode 100755 index 14b45cda0..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f107.lsusb +++ /dev/null @@ -1,60 +0,0 @@ - -Bus 001 Device 028: ID 0483:df11 SGS Thomson Microelectronics STM Device in DFU Mode -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 STM Device in DFU Mode - bcdDevice 20.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 0x418 DFU Bootloader - iSerial 3 STM32 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 36 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/128*002Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @Option Bytes /0x1FFFF800/01*016 g - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 2048 bytes - bcdDFUVersion 1.1a -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f4discovery.bin-download b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f4discovery.bin-download deleted file mode 100755 index 96e172216..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f4discovery.bin-download +++ /dev/null @@ -1,36 +0,0 @@ -dfu-util --device 0483:df11 --alt 0 \ - --dfuse-address 0x08000000 \ - -v -v -v \ - --download arm/iotoggle.bin -No valid DFU suffix signature -Warning: File has no DFU suffix -dfu-util 0.5 - -(C) 2005-2008 by Weston Schmidt, Harald Welte and OpenMoko Inc. -(C) 2010-2011 Tormod Volden (DfuSe support) -This program is Free Software and has ABSOLUTELY NO WARRANTY - -dfu-util does currently only support DFU version 1.0 - -Filter on vendor = 0x0483 product = 0xdf11 -Opening DFU capable USB device... ID 0483:df11 -Run-time device DFU version 011a -Found DFU: [0483:df11] devnum=0, cfg=1, intf=0, alt=0, name="@Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg" -Claiming USB DFU Interface... -Setting Alternate Setting #0 ... -Determining device status: state = dfuERROR, status = 10 -dfuERROR, clearing status -Determining device status: state = dfuIDLE, status = 0 -dfuIDLE, continuing -DFU mode device DFU version 011a -Device returned transfer size 2048 -DfuSe interface name: "Internal Flash " -Memory segment at 0x08000000 4 x 16384 = 65536 (rew) -Memory segment at 0x08010000 1 x 65536 = 65536 (rew) -Memory segment at 0x08020000 7 x 131072 = 917504 (rew) -Uploading to address = 0x08000000, size = 2308 -Erasing page size 16384 at address 0x08000000, page starting at 0x08000000 - Download from image offset 00000000 to memory 08000000-080007ff, size 2048 - Setting address pointer to 0x08000000 - Download from image offset 00000800 to memory 08000800-08000903, size 260 - Setting address pointer to 0x08000800 diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f4discovery.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f4discovery.lsusb deleted file mode 100755 index 0b870de91..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/stm32f4discovery.lsusb +++ /dev/null @@ -1,80 +0,0 @@ - -Bus 001 Device 010: ID 0483:df11 SGS Thomson Microelectronics STM Device in DFU Mode -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 1.00 - bDeviceClass 0 (Defined at Interface level) - bDeviceSubClass 0 - bDeviceProtocol 0 - bMaxPacketSize0 64 - idVendor 0x0483 SGS Thomson Microelectronics - idProduct 0xdf11 STM Device in DFU Mode - bcdDevice 21.00 - iManufacturer 1 STMicroelectronics - iProduct 2 STM32 BOOTLOADER - iSerial 3 315A28A0B956 - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 54 - bNumInterfaces 1 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0xc0 - Self Powered - MaxPower 100mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 4 @Internal Flash /0x08000000/04*016Kg,01*064Kg,07*128Kg - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 1 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 5 @Option Bytes /0x1FFFC000/01*016 g - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 2 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 6 @OTP Memory /0x1FFF7800/01*512 g,01*016 g - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 3 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 2 - iInterface 7 @Device Feature/0xFFFF0000/01*004 g - Device Firmware Upgrade Interface Descriptor: - bLength 9 - bDescriptorType 33 - bmAttributes 11 - Will Detach - Manifestation Intolerant - Upload Supported - Download Supported - wDetachTimeout 255 milliseconds - wTransferSize 2048 bytes - bcdDFUVersion 1.1a -Device Status: 0x0001 - Self Powered diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/tdk-bluetooth.lsusb b/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/tdk-bluetooth.lsusb deleted file mode 100755 index c0cfaceb6..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/device-logs/tdk-bluetooth.lsusb +++ /dev/null @@ -1,269 +0,0 @@ - -Bus 006 Device 014: ID 04bf:0320 TDK Corp. Bluetooth Adapter -Device Descriptor: - bLength 18 - bDescriptorType 1 - bcdUSB 2.00 - bDeviceClass 224 Wireless - bDeviceSubClass 1 Radio Frequency - bDeviceProtocol 1 Bluetooth - bMaxPacketSize0 64 - idVendor 0x04bf TDK Corp. - idProduct 0x0320 Bluetooth Adapter - bcdDevice 26.52 - iManufacturer 1 Ezurio - iProduct 2 Turbo Bluetooth Adapter - iSerial 3 008098D4FFBD - bNumConfigurations 1 - Configuration Descriptor: - bLength 9 - bDescriptorType 2 - wTotalLength 193 - bNumInterfaces 3 - bConfigurationValue 1 - iConfiguration 0 - bmAttributes 0x80 - (Bus Powered) - MaxPower 64mA - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 0 - bAlternateSetting 0 - bNumEndpoints 3 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x81 EP 1 IN - bmAttributes 3 - Transfer Type Interrupt - Synch Type None - Usage Type Data - wMaxPacketSize 0x0010 1x 16 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x02 EP 2 OUT - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x82 EP 2 IN - bmAttributes 2 - Transfer Type Bulk - Synch Type None - Usage Type Data - wMaxPacketSize 0x0040 1x 64 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 0 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0000 1x 0 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0000 1x 0 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 1 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0009 1x 9 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0009 1x 9 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 2 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0011 1x 17 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0011 1x 17 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 3 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0019 1x 25 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0019 1x 25 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 4 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0021 1x 33 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0021 1x 33 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 1 - bAlternateSetting 5 - bNumEndpoints 2 - bInterfaceClass 224 Wireless - bInterfaceSubClass 1 Radio Frequency - bInterfaceProtocol 1 Bluetooth - iInterface 0 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x03 EP 3 OUT - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0031 1x 49 bytes - bInterval 1 - Endpoint Descriptor: - bLength 7 - bDescriptorType 5 - bEndpointAddress 0x83 EP 3 IN - bmAttributes 1 - Transfer Type Isochronous - Synch Type None - Usage Type Data - wMaxPacketSize 0x0031 1x 49 bytes - bInterval 1 - Interface Descriptor: - bLength 9 - bDescriptorType 4 - bInterfaceNumber 2 - bAlternateSetting 0 - bNumEndpoints 0 - bInterfaceClass 254 Application Specific Interface - bInterfaceSubClass 1 Device Firmware Update - bInterfaceProtocol 0 - iInterface 0 - Device Firmware Upgrade Interface Descriptor: - bLength 7 - bDescriptorType 33 - bmAttributes 7 - Will Not Detach - Manifestation Tolerant - Upload Supported - Download Supported - wDetachTimeout 5000 milliseconds - wTransferSize 1023 bytes -Device Status: 0x0000 - (Bus Powered) diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/dfuse-pack.py b/arduino/opencr_arduino/tools/win/src/dfu-util/dfuse-pack.py deleted file mode 100755 index 875cc5c6e..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/dfuse-pack.py +++ /dev/null @@ -1,121 +0,0 @@ -#!/usr/bin/python - -# Written by Antonio Galea - 2010/11/18 -# Distributed under Gnu LGPL 3.0 -# see http://www.gnu.org/licenses/lgpl-3.0.txt - -import sys,struct,zlib,os -from optparse import OptionParser - -DEFAULT_DEVICE="0x0483:0xdf11" - -def named(tuple,names): - return dict(zip(names.split(),tuple)) -def consume(fmt,data,names): - n = struct.calcsize(fmt) - return named(struct.unpack(fmt,data[:n]),names),data[n:] -def cstring(string): - return string.split('\0',1)[0] -def compute_crc(data): - return 0xFFFFFFFF & -zlib.crc32(data) -1 - -def parse(file,dump_images=False): - print 'File: "%s"' % file - data = open(file,'rb').read() - crc = compute_crc(data[:-4]) - prefix, data = consume('<5sBIB',data,'signature version size targets') - print '%(signature)s v%(version)d, image size: %(size)d, targets: %(targets)d' % prefix - for t in range(prefix['targets']): - tprefix, data = consume('<6sBI255s2I',data,'signature altsetting named name size elements') - tprefix['num'] = t - if tprefix['named']: - tprefix['name'] = cstring(tprefix['name']) - else: - tprefix['name'] = '' - print '%(signature)s %(num)d, alt setting: %(altsetting)s, name: "%(name)s", size: %(size)d, elements: %(elements)d' % tprefix - tsize = tprefix['size'] - target, data = data[:tsize], data[tsize:] - for e in range(tprefix['elements']): - eprefix, target = consume('<2I',target,'address size') - eprefix['num'] = e - print ' %(num)d, address: 0x%(address)08x, size: %(size)d' % eprefix - esize = eprefix['size'] - image, target = target[:esize], target[esize:] - if dump_images: - out = '%s.target%d.image%d.bin' % (file,t,e) - open(out,'wb').write(image) - print ' DUMPED IMAGE TO "%s"' % out - if len(target): - print "target %d: PARSE ERROR" % t - suffix = named(struct.unpack('<4H3sBI',data[:16]),'device product vendor dfu ufd len crc') - print 'usb: %(vendor)04x:%(product)04x, device: 0x%(device)04x, dfu: 0x%(dfu)04x, %(ufd)s, %(len)d, 0x%(crc)08x' % suffix - if crc != suffix['crc']: - print "CRC ERROR: computed crc32 is 0x%08x" % crc - data = data[16:] - if data: - print "PARSE ERROR" - -def build(file,targets,device=DEFAULT_DEVICE): - data = '' - for t,target in enumerate(targets): - tdata = '' - for image in target: - tdata += struct.pack('<2I',image['address'],len(image['data']))+image['data'] - tdata = struct.pack('<6sBI255s2I','Target',0,1,'ST...',len(tdata),len(target)) + tdata - data += tdata - data = struct.pack('<5sBIB','DfuSe',1,len(data)+11,len(targets)) + data - v,d=map(lambda x: int(x,0) & 0xFFFF, device.split(':',1)) - data += struct.pack('<4H3sB',0,d,v,0x011a,'UFD',16) - crc = compute_crc(data) - data += struct.pack(' and -Harald Welte . Over time, nearly complete -support of DFU 1.0, DFU 1.1 and DfuSe ("1.1a") has been added. -.SH LICENCE -.B dfu-util -is covered by the GNU General Public License (GPL), version 2 or later. -.SH COPYRIGHT -This manual page was originally written by Uwe Hermann , -and is now part of the dfu-util project. diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/README_msvc.txt b/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/README_msvc.txt deleted file mode 100755 index 6e68ec6ff..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/README_msvc.txt +++ /dev/null @@ -1,10 +0,0 @@ -# (C) Roger Meier -# (C) Pascal Schweizer -# msvc folder is GPL-2.0+, LGPL-2.1+, BSD-3-Clause or MIT license(SPDX) - -Building dfu-util native on Windows with Visual Studio - -3rd party dependencies: -- libusbx ( git clone https://github.com/libusbx/libusbx.git ) - - getopt (part of libusbx: libusbx/examples/getopt) - diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/dfu-suffix_2010.vcxproj b/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/dfu-suffix_2010.vcxproj deleted file mode 100755 index 0c316c2e5..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/dfu-suffix_2010.vcxproj +++ /dev/null @@ -1,100 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA} - dfusuffix - dfu-suffix - - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\dll;$(LibraryPath) - $(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib - $(ExecutablePath) - - - $(ExecutablePath) - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\dll;$(LibraryPath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - Level3 - Disabled - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebug - - - true - - - - - Level3 - MaxSpeed - true - true - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - - - true - true - true - - - - - - - - - - - - - {a2169bc8-cf99-40bf-83f3-b0e38f7067bd} - - - {349ee8f9-7d25-4909-aaf5-ff3fade72187} - - - - - - \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/dfu-util_2010.sln b/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/dfu-util_2010.sln deleted file mode 100755 index ef797239b..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/dfu-util_2010.sln +++ /dev/null @@ -1,54 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dfu-util", "dfu-util_2010.vcxproj", "{0E071A60-7EF2-4427-BAA8-9143CACB5BCB}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C4F8746D-B27E-4806-95E5-2052174E923B}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "dfu-suffix", "dfu-suffix_2010.vcxproj", "{8F7600A2-3B37-4956-B39B-A1D43EF29EDA}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "getopt_2010", "..\..\libusbx\msvc\getopt_2010.vcxproj", "{AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libusb-1.0 (static)", "..\..\libusbx\msvc\libusb_static_2010.vcxproj", "{349EE8F9-7D25-4909-AAF5-FF3FADE72187}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Debug|x64 = Debug|x64 - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|Win32.ActiveCfg = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|Win32.Build.0 = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Debug|x64.ActiveCfg = Debug|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|Win32.ActiveCfg = Release|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|Win32.Build.0 = Release|Win32 - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB}.Release|x64.ActiveCfg = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|Win32.ActiveCfg = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|Win32.Build.0 = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Debug|x64.ActiveCfg = Debug|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|Win32.ActiveCfg = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|Win32.Build.0 = Release|Win32 - {8F7600A2-3B37-4956-B39B-A1D43EF29EDA}.Release|x64.ActiveCfg = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.ActiveCfg = Debug|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|Win32.Build.0 = Debug|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.ActiveCfg = Debug|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Debug|x64.Build.0 = Debug|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.ActiveCfg = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|Win32.Build.0 = Release|Win32 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.ActiveCfg = Release|x64 - {AE83E1B4-CE06-47EE-B7A3-C3A1D7C2D71E}.Release|x64.Build.0 = Release|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.ActiveCfg = Debug|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|Win32.Build.0 = Debug|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.ActiveCfg = Debug|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Debug|x64.Build.0 = Debug|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.ActiveCfg = Release|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|Win32.Build.0 = Release|Win32 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.ActiveCfg = Release|x64 - {349EE8F9-7D25-4909-AAF5-FF3FADE72187}.Release|x64.Build.0 = Release|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/dfu-util_2010.vcxproj b/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/dfu-util_2010.vcxproj deleted file mode 100755 index 17a8bee1b..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/msvc/dfu-util_2010.vcxproj +++ /dev/null @@ -1,120 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {0E071A60-7EF2-4427-BAA8-9143CACB5BCB} - dfuutil - dfu-util - - - - Application - true - MultiByte - - - Application - false - true - MultiByte - - - - - - - - - - - - - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\getopt\$(Configuration);$(LibraryPath) - $(VCInstallDir)atlmfc\lib;$(VCInstallDir)lib - $(ExecutablePath) - - - $(ExecutablePath) - $(SolutionDir)..\..\libusbx\examples\getopt;$(SolutionDir)..\..\libusbx\libusb;$(IncludePath) - $(SolutionDir)..\$(Platform)\getopt\$(Configuration);$(LibraryPath) - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - Level3 - Disabled - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreadedDebug - - - true - - - - - - - - - Level3 - MaxSpeed - true - true - HAVE_WINDOWS_H;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) - MultiThreaded - - - true - true - true - - - copy $(SolutionDir)..\$(Platform)\$(Configuration)\dll\libusb-1.0.dll $(SolutionDir)..\$(Platform)\$(ProjectName)\$(Configuration)\ - - - - - - - - - - - - - - - - - - - - - - - - - - {a2169bc8-cf99-40bf-83f3-b0e38f7067bd} - - - {349ee8f9-7d25-4909-aaf5-ff3fade72187} - - - - - - \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/Makefile.am b/arduino/opencr_arduino/tools/win/src/dfu-util/src/Makefile.am deleted file mode 100755 index 70179c411..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -AM_CFLAGS = -Wall -Wextra - -bin_PROGRAMS = dfu-util dfu-suffix dfu-prefix -dfu_util_SOURCES = main.c \ - portable.h \ - dfu_load.c \ - dfu_load.h \ - dfu_util.c \ - dfu_util.h \ - dfuse.c \ - dfuse.h \ - dfuse_mem.c \ - dfuse_mem.h \ - dfu.c \ - dfu.h \ - usb_dfu.h \ - dfu_file.c \ - dfu_file.h \ - quirks.c \ - quirks.h - -dfu_suffix_SOURCES = suffix.c \ - dfu_file.h \ - dfu_file.c - -dfu_prefix_SOURCES = prefix.c \ - dfu_file.h \ - dfu_file.c diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu.c b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu.c deleted file mode 100755 index 14d7673d1..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu.c +++ /dev/null @@ -1,357 +0,0 @@ -/* - * Low-level DFU communication routines, originally taken from - * $Id: dfu.c,v 1.3 2006/06/20 06:28:04 schmidtw Exp $ - * (part of dfu-programmer). - * - * Copyright 2005-2006 Weston Schmidt - * Copyright 2011-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include - -#include - -#include "portable.h" -#include "dfu.h" -#include "quirks.h" - -static int dfu_timeout = 5000; /* 5 seconds - default */ - -/* - * DFU_DETACH Request (DFU Spec 1.0, Section 5.1) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * timeout - the timeout in ms the USB device should wait for a pending - * USB reset before giving up and terminating the operation - * - * returns 0 or < 0 on error - */ -int dfu_detach( libusb_device_handle *device, - const unsigned short interface, - const unsigned short timeout ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DETACH, - /* wValue */ timeout, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -/* - * DFU_DNLOAD Request (DFU Spec 1.0, Section 6.1.1) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the total number of bytes to transfer to the USB - * device - must be less than wTransferSize - * data - the data to transfer - * - * returns the number of bytes written or < 0 on error - */ -int dfu_download( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ) -{ - int status; - - status = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DNLOAD, - /* wValue */ transaction, - /* wIndex */ interface, - /* Data */ data, - /* wLength */ length, - dfu_timeout ); - return status; -} - - -/* - * DFU_UPLOAD Request (DFU Spec 1.0, Section 6.2) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the maximum number of bytes to receive from the USB - * device - must be less than wTransferSize - * data - the buffer to put the received data in - * - * returns the number of bytes received or < 0 on error - */ -int dfu_upload( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ) -{ - int status; - - status = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_UPLOAD, - /* wValue */ transaction, - /* wIndex */ interface, - /* Data */ data, - /* wLength */ length, - dfu_timeout ); - return status; -} - - -/* - * DFU_GETSTATUS Request (DFU Spec 1.0, Section 6.1.2) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * status - the data structure to be populated with the results - * - * return the number of bytes read in or < 0 on an error - */ -int dfu_get_status( struct dfu_if *dif, struct dfu_status *status ) -{ - unsigned char buffer[6]; - int result; - - /* Initialize the status data structure */ - status->bStatus = DFU_STATUS_ERROR_UNKNOWN; - status->bwPollTimeout = 0; - status->bState = STATE_DFU_ERROR; - status->iString = 0; - - result = libusb_control_transfer( dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_GETSTATUS, - /* wValue */ 0, - /* wIndex */ dif->interface, - /* Data */ buffer, - /* wLength */ 6, - dfu_timeout ); - - if( 6 == result ) { - status->bStatus = buffer[0]; - if (dif->quirks & QUIRK_POLLTIMEOUT) - status->bwPollTimeout = DEFAULT_POLLTIMEOUT; - else - status->bwPollTimeout = ((0xff & buffer[3]) << 16) | - ((0xff & buffer[2]) << 8) | - (0xff & buffer[1]); - status->bState = buffer[4]; - status->iString = buffer[5]; - } - - return result; -} - - -/* - * DFU_CLRSTATUS Request (DFU Spec 1.0, Section 6.1.3) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * - * return 0 or < 0 on an error - */ -int dfu_clear_status( libusb_device_handle *device, - const unsigned short interface ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT| LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_CLRSTATUS, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -/* - * DFU_GETSTATE Request (DFU Spec 1.0, Section 6.1.5) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * length - the maximum number of bytes to receive from the USB - * device - must be less than wTransferSize - * data - the buffer to put the received data in - * - * returns the state or < 0 on error - */ -int dfu_get_state( libusb_device_handle *device, - const unsigned short interface ) -{ - int result; - unsigned char buffer[1]; - - result = libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_GETSTATE, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ buffer, - /* wLength */ 1, - dfu_timeout ); - - /* Return the error if there is one. */ - if (result < 1) - return -1; - - /* Return the state. */ - return buffer[0]; -} - - -/* - * DFU_ABORT Request (DFU Spec 1.0, Section 6.1.4) - * - * device - the usb_dev_handle to communicate with - * interface - the interface to communicate with - * - * returns 0 or < 0 on an error - */ -int dfu_abort( libusb_device_handle *device, - const unsigned short interface ) -{ - return libusb_control_transfer( device, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_ABORT, - /* wValue */ 0, - /* wIndex */ interface, - /* Data */ NULL, - /* wLength */ 0, - dfu_timeout ); -} - - -const char* dfu_state_to_string( int state ) -{ - const char *message; - - switch (state) { - case STATE_APP_IDLE: - message = "appIDLE"; - break; - case STATE_APP_DETACH: - message = "appDETACH"; - break; - case STATE_DFU_IDLE: - message = "dfuIDLE"; - break; - case STATE_DFU_DOWNLOAD_SYNC: - message = "dfuDNLOAD-SYNC"; - break; - case STATE_DFU_DOWNLOAD_BUSY: - message = "dfuDNBUSY"; - break; - case STATE_DFU_DOWNLOAD_IDLE: - message = "dfuDNLOAD-IDLE"; - break; - case STATE_DFU_MANIFEST_SYNC: - message = "dfuMANIFEST-SYNC"; - break; - case STATE_DFU_MANIFEST: - message = "dfuMANIFEST"; - break; - case STATE_DFU_MANIFEST_WAIT_RESET: - message = "dfuMANIFEST-WAIT-RESET"; - break; - case STATE_DFU_UPLOAD_IDLE: - message = "dfuUPLOAD-IDLE"; - break; - case STATE_DFU_ERROR: - message = "dfuERROR"; - break; - default: - message = NULL; - break; - } - - return message; -} - -/* Chapter 6.1.2 */ -static const char *dfu_status_names[] = { - /* DFU_STATUS_OK */ - "No error condition is present", - /* DFU_STATUS_errTARGET */ - "File is not targeted for use by this device", - /* DFU_STATUS_errFILE */ - "File is for this device but fails some vendor-specific test", - /* DFU_STATUS_errWRITE */ - "Device is unable to write memory", - /* DFU_STATUS_errERASE */ - "Memory erase function failed", - /* DFU_STATUS_errCHECK_ERASED */ - "Memory erase check failed", - /* DFU_STATUS_errPROG */ - "Program memory function failed", - /* DFU_STATUS_errVERIFY */ - "Programmed memory failed verification", - /* DFU_STATUS_errADDRESS */ - "Cannot program memory due to received address that is out of range", - /* DFU_STATUS_errNOTDONE */ - "Received DFU_DNLOAD with wLength = 0, but device does not think that it has all data yet", - /* DFU_STATUS_errFIRMWARE */ - "Device's firmware is corrupt. It cannot return to run-time (non-DFU) operations", - /* DFU_STATUS_errVENDOR */ - "iString indicates a vendor specific error", - /* DFU_STATUS_errUSBR */ - "Device detected unexpected USB reset signalling", - /* DFU_STATUS_errPOR */ - "Device detected unexpected power on reset", - /* DFU_STATUS_errUNKNOWN */ - "Something went wrong, but the device does not know what it was", - /* DFU_STATUS_errSTALLEDPKT */ - "Device stalled an unexpected request" -}; - - -const char *dfu_status_to_string(int status) -{ - if (status > DFU_STATUS_errSTALLEDPKT) - return "INVALID"; - return dfu_status_names[status]; -} - -int dfu_abort_to_idle(struct dfu_if *dif) -{ - int ret; - struct dfu_status dst; - - ret = dfu_abort(dif->dev_handle, dif->interface); - if (ret < 0) { - errx(EX_IOERR, "Error sending dfu abort request"); - exit(1); - } - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during abort get_status"); - exit(1); - } - if (dst.bState != DFU_STATE_dfuIDLE) { - errx(EX_IOERR, "Failed to enter idle state on abort"); - exit(1); - } - milli_sleep(dst.bwPollTimeout); - return ret; -} diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu.h b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu.h deleted file mode 100755 index 8e3caeb7b..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * dfu-programmer - * - * $Id: dfu.h,v 1.2 2005/09/25 01:27:42 schmidtw Exp $ - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFU_H -#define DFU_H - -#include -#include "usb_dfu.h" - -/* DFU states */ -#define STATE_APP_IDLE 0x00 -#define STATE_APP_DETACH 0x01 -#define STATE_DFU_IDLE 0x02 -#define STATE_DFU_DOWNLOAD_SYNC 0x03 -#define STATE_DFU_DOWNLOAD_BUSY 0x04 -#define STATE_DFU_DOWNLOAD_IDLE 0x05 -#define STATE_DFU_MANIFEST_SYNC 0x06 -#define STATE_DFU_MANIFEST 0x07 -#define STATE_DFU_MANIFEST_WAIT_RESET 0x08 -#define STATE_DFU_UPLOAD_IDLE 0x09 -#define STATE_DFU_ERROR 0x0a - - -/* DFU status */ -#define DFU_STATUS_OK 0x00 -#define DFU_STATUS_ERROR_TARGET 0x01 -#define DFU_STATUS_ERROR_FILE 0x02 -#define DFU_STATUS_ERROR_WRITE 0x03 -#define DFU_STATUS_ERROR_ERASE 0x04 -#define DFU_STATUS_ERROR_CHECK_ERASED 0x05 -#define DFU_STATUS_ERROR_PROG 0x06 -#define DFU_STATUS_ERROR_VERIFY 0x07 -#define DFU_STATUS_ERROR_ADDRESS 0x08 -#define DFU_STATUS_ERROR_NOTDONE 0x09 -#define DFU_STATUS_ERROR_FIRMWARE 0x0a -#define DFU_STATUS_ERROR_VENDOR 0x0b -#define DFU_STATUS_ERROR_USBR 0x0c -#define DFU_STATUS_ERROR_POR 0x0d -#define DFU_STATUS_ERROR_UNKNOWN 0x0e -#define DFU_STATUS_ERROR_STALLEDPKT 0x0f - -/* DFU commands */ -#define DFU_DETACH 0 -#define DFU_DNLOAD 1 -#define DFU_UPLOAD 2 -#define DFU_GETSTATUS 3 -#define DFU_CLRSTATUS 4 -#define DFU_GETSTATE 5 -#define DFU_ABORT 6 - -/* DFU interface */ -#define DFU_IFF_DFU 0x0001 /* DFU Mode, (not Runtime) */ - -/* This is based off of DFU_GETSTATUS - * - * 1 unsigned byte bStatus - * 3 unsigned byte bwPollTimeout - * 1 unsigned byte bState - * 1 unsigned byte iString -*/ - -struct dfu_status { - unsigned char bStatus; - unsigned int bwPollTimeout; - unsigned char bState; - unsigned char iString; -}; - -struct dfu_if { - struct usb_dfu_func_descriptor func_dfu; - uint16_t quirks; - uint16_t busnum; - uint16_t devnum; - uint16_t vendor; - uint16_t product; - uint16_t bcdDevice; - uint8_t configuration; - uint8_t interface; - uint8_t altsetting; - uint8_t flags; - uint8_t bMaxPacketSize0; - char *alt_name; - char *serial_name; - libusb_device *dev; - libusb_device_handle *dev_handle; - struct dfu_if *next; -}; - -int dfu_detach( libusb_device_handle *device, - const unsigned short interface, - const unsigned short timeout ); -int dfu_download( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ); -int dfu_upload( libusb_device_handle *device, - const unsigned short interface, - const unsigned short length, - const unsigned short transaction, - unsigned char* data ); -int dfu_get_status( struct dfu_if *dif, - struct dfu_status *status ); -int dfu_clear_status( libusb_device_handle *device, - const unsigned short interface ); -int dfu_get_state( libusb_device_handle *device, - const unsigned short interface ); -int dfu_abort( libusb_device_handle *device, - const unsigned short interface ); -int dfu_abort_to_idle( struct dfu_if *dif); - -const char *dfu_state_to_string( int state ); - -const char *dfu_status_to_string( int status ); - -#endif /* DFU_H */ diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_file.c b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_file.c deleted file mode 100755 index 7c897d4f6..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_file.c +++ /dev/null @@ -1,444 +0,0 @@ -/* - * Load or store DFU files including suffix and prefix - * - * Copyright 2014 Tormod Volden - * Copyright 2012 Stefan Schmidt - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -#define DFU_SUFFIX_LENGTH 16 -#define LMDFU_PREFIX_LENGTH 8 -#define LPCDFU_PREFIX_LENGTH 16 -#define PROGRESS_BAR_WIDTH 25 -#define STDIN_CHUNK_SIZE 65536 - -static const unsigned long crc32_table[] = { - 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, - 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, - 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, - 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, - 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, - 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, - 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, - 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, - 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, - 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, - 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106, - 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433, - 0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, - 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, - 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, - 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, - 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, - 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, - 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, - 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, - 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, - 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a, - 0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, - 0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, - 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, - 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, - 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, - 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, - 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, - 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, - 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, - 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, - 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f, - 0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, - 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242, - 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, - 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, - 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, - 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, - 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, - 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, - 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, - 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d}; - -static uint32_t crc32_byte(uint32_t accum, uint8_t delta) -{ - return crc32_table[(accum ^ delta) & 0xff] ^ (accum >> 8); -} - -static int probe_prefix(struct dfu_file *file) -{ - uint8_t *prefix = file->firmware; - - if (file->size.total < LMDFU_PREFIX_LENGTH) - return 1; - if ((prefix[0] == 0x01) && (prefix[1] == 0x00)) { - file->prefix_type = LMDFU_PREFIX; - file->size.prefix = LMDFU_PREFIX_LENGTH; - file->lmdfu_address = 1024 * ((prefix[3] << 8) | prefix[2]); - } - else if (((prefix[0] & 0x3f) == 0x1a) && ((prefix[1] & 0x3f)== 0x3f)) { - file->prefix_type = LPCDFU_UNENCRYPTED_PREFIX; - file->size.prefix = LPCDFU_PREFIX_LENGTH; - } - - if (file->size.prefix + file->size.suffix > file->size.total) - return 1; - return 0; -} - -void dfu_progress_bar(const char *desc, unsigned long long curr, - unsigned long long max) -{ - static char buf[PROGRESS_BAR_WIDTH + 1]; - static unsigned long long last_progress = -1; - static time_t last_time; - time_t curr_time = time(NULL); - unsigned long long progress; - unsigned long long x; - - /* check for not known maximum */ - if (max < curr) - max = curr + 1; - /* make none out of none give zero */ - if (max == 0 && curr == 0) - max = 1; - - /* compute completion */ - progress = (PROGRESS_BAR_WIDTH * curr) / max; - if (progress > PROGRESS_BAR_WIDTH) - progress = PROGRESS_BAR_WIDTH; - if (progress == last_progress && - curr_time == last_time) - return; - last_progress = progress; - last_time = curr_time; - - for (x = 0; x != PROGRESS_BAR_WIDTH; x++) { - if (x < progress) - buf[x] = '='; - else - buf[x] = ' '; - } - buf[x] = 0; - - printf("\r%s\t[%s] %3lld%% %12lld bytes", desc, buf, - (100ULL * curr) / max, curr); - - if (progress == PROGRESS_BAR_WIDTH) - printf("\n%s done.\n", desc); -} - -void *dfu_malloc(size_t size) -{ - void *ptr = malloc(size); - if (ptr == NULL) - errx(EX_SOFTWARE, "Cannot allocate memory of size %d bytes", (int)size); - return (ptr); -} - -uint32_t dfu_file_write_crc(int f, uint32_t crc, const void *buf, int size) -{ - int x; - - /* compute CRC */ - for (x = 0; x != size; x++) - crc = crc32_byte(crc, ((uint8_t *)buf)[x]); - - /* write data */ - if (write(f, buf, size) != size) - err(EX_IOERR, "Could not write %d bytes to file %d", size, f); - - return (crc); -} - -void dfu_load_file(struct dfu_file *file, enum suffix_req check_suffix, enum prefix_req check_prefix) -{ - off_t offset; - int f; - int i; - int res; - - file->size.prefix = 0; - file->size.suffix = 0; - - /* default values, if no valid suffix is found */ - file->bcdDFU = 0; - file->idVendor = 0xffff; /* wildcard value */ - file->idProduct = 0xffff; /* wildcard value */ - file->bcdDevice = 0xffff; /* wildcard value */ - - /* default values, if no valid prefix is found */ - file->lmdfu_address = 0; - - free(file->firmware); - - if (!strcmp(file->name, "-")) { - int read_bytes; - -#ifdef WIN32 - _setmode( _fileno( stdin ), _O_BINARY ); -#endif - file->firmware = (uint8_t*) dfu_malloc(STDIN_CHUNK_SIZE); - read_bytes = fread(file->firmware, 1, STDIN_CHUNK_SIZE, stdin); - file->size.total = read_bytes; - while (read_bytes == STDIN_CHUNK_SIZE) { - file->firmware = (uint8_t*) realloc(file->firmware, file->size.total + STDIN_CHUNK_SIZE); - if (!file->firmware) - err(EX_IOERR, "Could not allocate firmware buffer"); - read_bytes = fread(file->firmware + file->size.total, 1, STDIN_CHUNK_SIZE, stdin); - file->size.total += read_bytes; - } - if (verbose) - printf("Read %i bytes from stdin\n", file->size.total); - /* Never require suffix when reading from stdin */ - check_suffix = MAYBE_SUFFIX; - } else { - f = open(file->name, O_RDONLY | O_BINARY); - if (f < 0) - err(EX_IOERR, "Could not open file %s for reading", file->name); - - offset = lseek(f, 0, SEEK_END); - - if ((int)offset < 0 || (int)offset != offset) - err(EX_IOERR, "File size is too big"); - - if (lseek(f, 0, SEEK_SET) != 0) - err(EX_IOERR, "Could not seek to beginning"); - - file->size.total = offset; - file->firmware = dfu_malloc(file->size.total); - - if (read(f, file->firmware, file->size.total) != file->size.total) { - err(EX_IOERR, "Could not read %d bytes from %s", - file->size.total, file->name); - } - close(f); - } - - /* Check for possible DFU file suffix by trying to parse one */ - { - uint32_t crc = 0xffffffff; - const uint8_t *dfusuffix; - int missing_suffix = 0; - const char *reason; - - if (file->size.total < DFU_SUFFIX_LENGTH) { - reason = "File too short for DFU suffix"; - missing_suffix = 1; - goto checked; - } - - dfusuffix = file->firmware + file->size.total - - DFU_SUFFIX_LENGTH; - - for (i = 0; i < file->size.total - 4; i++) - crc = crc32_byte(crc, file->firmware[i]); - - if (dfusuffix[10] != 'D' || - dfusuffix[9] != 'F' || - dfusuffix[8] != 'U') { - reason = "Invalid DFU suffix signature"; - missing_suffix = 1; - goto checked; - } - - file->dwCRC = (dfusuffix[15] << 24) + - (dfusuffix[14] << 16) + - (dfusuffix[13] << 8) + - dfusuffix[12]; - - if (file->dwCRC != crc) { - reason = "DFU suffix CRC does not match"; - missing_suffix = 1; - goto checked; - } - - /* At this point we believe we have a DFU suffix - so we require further checks to succeed */ - - file->bcdDFU = (dfusuffix[7] << 8) + dfusuffix[6]; - - if (verbose) - printf("DFU suffix version %x\n", file->bcdDFU); - - file->size.suffix = dfusuffix[11]; - - if (file->size.suffix < DFU_SUFFIX_LENGTH) { - errx(EX_IOERR, "Unsupported DFU suffix length %d", - file->size.suffix); - } - - if (file->size.suffix > file->size.total) { - errx(EX_IOERR, "Invalid DFU suffix length %d", - file->size.suffix); - } - - file->idVendor = (dfusuffix[5] << 8) + dfusuffix[4]; - file->idProduct = (dfusuffix[3] << 8) + dfusuffix[2]; - file->bcdDevice = (dfusuffix[1] << 8) + dfusuffix[0]; - -checked: - if (missing_suffix) { - if (check_suffix == NEEDS_SUFFIX) { - warnx("%s", reason); - errx(EX_IOERR, "Valid DFU suffix needed"); - } else if (check_suffix == MAYBE_SUFFIX) { - warnx("%s", reason); - warnx("A valid DFU suffix will be required in " - "a future dfu-util release!!!"); - } - } else { - if (check_suffix == NO_SUFFIX) { - errx(EX_SOFTWARE, "Please remove existing DFU suffix before adding a new one.\n"); - } - } - } - res = probe_prefix(file); - if ((res || file->size.prefix == 0) && check_prefix == NEEDS_PREFIX) - errx(EX_IOERR, "Valid DFU prefix needed"); - if (file->size.prefix && check_prefix == NO_PREFIX) - errx(EX_IOERR, "A prefix already exists, please delete it first"); - if (file->size.prefix && verbose) { - uint8_t *data = file->firmware; - if (file->prefix_type == LMDFU_PREFIX) - printf("Possible TI Stellaris DFU prefix with " - "the following properties\n" - "Address: 0x%08x\n" - "Payload length: %d\n", - file->lmdfu_address, - data[4] | (data[5] << 8) | - (data[6] << 16) | (data[7] << 14)); - else if (file->prefix_type == LPCDFU_UNENCRYPTED_PREFIX) - printf("Possible unencrypted NXP LPC DFU prefix with " - "the following properties\n" - "Payload length: %d kiByte\n", - data[2] >>1 | (data[3] << 7) ); - else - errx(EX_IOERR, "Unknown DFU prefix type"); - } -} - -void dfu_store_file(struct dfu_file *file, int write_suffix, int write_prefix) -{ - uint32_t crc = 0xffffffff; - int f; - - f = open(file->name, O_WRONLY | O_BINARY | O_TRUNC | O_CREAT, 0666); - if (f < 0) - err(EX_IOERR, "Could not open file %s for writing", file->name); - - /* write prefix, if any */ - if (write_prefix) { - if (file->prefix_type == LMDFU_PREFIX) { - uint8_t lmdfu_prefix[LMDFU_PREFIX_LENGTH]; - uint32_t addr = file->lmdfu_address / 1024; - - /* lmdfu_dfu_prefix payload length excludes prefix and suffix */ - uint32_t len = file->size.total - - file->size.prefix - file->size.suffix; - - lmdfu_prefix[0] = 0x01; /* STELLARIS_DFU_PROG */ - lmdfu_prefix[1] = 0x00; /* Reserved */ - lmdfu_prefix[2] = (uint8_t)(addr & 0xff); - lmdfu_prefix[3] = (uint8_t)(addr >> 8); - lmdfu_prefix[4] = (uint8_t)(len & 0xff); - lmdfu_prefix[5] = (uint8_t)(len >> 8) & 0xff; - lmdfu_prefix[6] = (uint8_t)(len >> 16) & 0xff; - lmdfu_prefix[7] = (uint8_t)(len >> 24); - - crc = dfu_file_write_crc(f, crc, lmdfu_prefix, LMDFU_PREFIX_LENGTH); - } - if (file->prefix_type == LPCDFU_UNENCRYPTED_PREFIX) { - uint8_t lpcdfu_prefix[LPCDFU_PREFIX_LENGTH] = {0}; - int i; - - /* Payload is firmware and prefix rounded to 512 bytes */ - uint32_t len = (file->size.total - file->size.suffix + 511) /512; - - lpcdfu_prefix[0] = 0x1a; /* Unencypted*/ - lpcdfu_prefix[1] = 0x3f; /* Reserved */ - lpcdfu_prefix[2] = (uint8_t)(len & 0xff); - lpcdfu_prefix[3] = (uint8_t)((len >> 8) & 0xff); - for (i = 12; i < LPCDFU_PREFIX_LENGTH; i++) - lpcdfu_prefix[i] = 0xff; - - crc = dfu_file_write_crc(f, crc, lpcdfu_prefix, LPCDFU_PREFIX_LENGTH); - } - } - /* write firmware binary */ - crc = dfu_file_write_crc(f, crc, file->firmware + file->size.prefix, - file->size.total - file->size.prefix - file->size.suffix); - - /* write suffix, if any */ - if (write_suffix) { - uint8_t dfusuffix[DFU_SUFFIX_LENGTH]; - - dfusuffix[0] = file->bcdDevice & 0xff; - dfusuffix[1] = file->bcdDevice >> 8; - dfusuffix[2] = file->idProduct & 0xff; - dfusuffix[3] = file->idProduct >> 8; - dfusuffix[4] = file->idVendor & 0xff; - dfusuffix[5] = file->idVendor >> 8; - dfusuffix[6] = file->bcdDFU & 0xff; - dfusuffix[7] = file->bcdDFU >> 8; - dfusuffix[8] = 'U'; - dfusuffix[9] = 'F'; - dfusuffix[10] = 'D'; - dfusuffix[11] = DFU_SUFFIX_LENGTH; - - crc = dfu_file_write_crc(f, crc, dfusuffix, - DFU_SUFFIX_LENGTH - 4); - - dfusuffix[12] = crc; - dfusuffix[13] = crc >> 8; - dfusuffix[14] = crc >> 16; - dfusuffix[15] = crc >> 24; - - crc = dfu_file_write_crc(f, crc, dfusuffix + 12, 4); - } - close(f); -} - -void show_suffix_and_prefix(struct dfu_file *file) -{ - if (file->size.prefix == LMDFU_PREFIX_LENGTH) { - printf("The file %s contains a TI Stellaris DFU prefix with the following properties:\n", file->name); - printf("Address:\t0x%08x\n", file->lmdfu_address); - } else if (file->size.prefix == LPCDFU_PREFIX_LENGTH) { - uint8_t * prefix = file->firmware; - printf("The file %s contains a NXP unencrypted LPC DFU prefix with the following properties:\n", file->name); - printf("Size:\t%5d kiB\n", prefix[2]>>1|prefix[3]<<7); - } else if (file->size.prefix != 0) { - printf("The file %s contains an unknown prefix\n", file->name); - } - if (file->size.suffix > 0) { - printf("The file %s contains a DFU suffix with the following properties:\n", file->name); - printf("BCD device:\t0x%04X\n", file->bcdDevice); - printf("Product ID:\t0x%04X\n",file->idProduct); - printf("Vendor ID:\t0x%04X\n", file->idVendor); - printf("BCD DFU:\t0x%04X\n", file->bcdDFU); - printf("Length:\t\t%i\n", file->size.suffix); - printf("CRC:\t\t0x%08X\n", file->dwCRC); - } -} diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_file.h b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_file.h deleted file mode 100755 index abebd44f4..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_file.h +++ /dev/null @@ -1,60 +0,0 @@ - -#ifndef DFU_FILE_H -#define DFU_FILE_H - -#include - -struct dfu_file { - /* File name */ - const char *name; - /* Pointer to file loaded into memory */ - uint8_t *firmware; - /* Different sizes */ - struct { - int total; - int prefix; - int suffix; - } size; - /* From prefix fields */ - uint32_t lmdfu_address; - /* From prefix fields */ - uint32_t prefix_type; - - /* From DFU suffix fields */ - uint32_t dwCRC; - uint16_t bcdDFU; - uint16_t idVendor; - uint16_t idProduct; - uint16_t bcdDevice; -}; - -enum suffix_req { - NO_SUFFIX, - NEEDS_SUFFIX, - MAYBE_SUFFIX -}; - -enum prefix_req { - NO_PREFIX, - NEEDS_PREFIX, - MAYBE_PREFIX -}; - -enum prefix_type { - ZERO_PREFIX, - LMDFU_PREFIX, - LPCDFU_UNENCRYPTED_PREFIX -}; - -extern int verbose; - -void dfu_load_file(struct dfu_file *file, enum suffix_req check_suffix, enum prefix_req check_prefix); -void dfu_store_file(struct dfu_file *file, int write_suffix, int write_prefix); - -void dfu_progress_bar(const char *desc, unsigned long long curr, - unsigned long long max); -void *dfu_malloc(size_t size); -uint32_t dfu_file_write_crc(int f, uint32_t crc, const void *buf, int size); -void show_suffix_and_prefix(struct dfu_file *file); - -#endif /* DFU_FILE_H */ diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_load.c b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_load.c deleted file mode 100755 index 64f7009df..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_load.c +++ /dev/null @@ -1,196 +0,0 @@ -/* - * DFU transfer routines - * - * This is supposed to be a general DFU implementation, as specified in the - * USB DFU 1.0 and 1.1 specification. - * - * The code was originally intended to interface with a USB device running the - * "sam7dfu" firmware (see http://www.openpcd.org/) on an AT91SAM7 processor. - * - * Copyright 2007-2008 Harald Welte - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "quirks.h" - -int dfuload_do_upload(struct dfu_if *dif, int xfer_size, - int expected_size, int fd) -{ - int total_bytes = 0; - unsigned short transaction = 0; - unsigned char *buf; - int ret; - - buf = dfu_malloc(xfer_size); - - printf("Copying data from DFU device to PC\n"); - dfu_progress_bar("Upload", 0, 1); - - while (1) { - int rc; - rc = dfu_upload(dif->dev_handle, dif->interface, - xfer_size, transaction++, buf); - if (rc < 0) { - warnx("Error during upload"); - ret = rc; - goto out_free; - } - - dfu_file_write_crc(fd, 0, buf, rc); - total_bytes += rc; - - if (total_bytes < 0) - errx(EX_SOFTWARE, "Received too many bytes (wraparound)"); - - if (rc < xfer_size) { - /* last block, return */ - ret = total_bytes; - break; - } - dfu_progress_bar("Upload", total_bytes, expected_size); - } - ret = 0; - -out_free: - dfu_progress_bar("Upload", total_bytes, total_bytes); - if (total_bytes == 0) - printf("\nFailed.\n"); - free(buf); - if (verbose) - printf("Received a total of %i bytes\n", total_bytes); - if (expected_size != 0 && total_bytes != expected_size) - errx(EX_SOFTWARE, "Unexpected number of bytes uploaded from device"); - return ret; -} - -int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file) -{ - int bytes_sent; - int expected_size; - unsigned char *buf; - unsigned short transaction = 0; - struct dfu_status dst; - int ret; - - printf("Copying data from PC to DFU device\n"); - - buf = file->firmware; - expected_size = file->size.total - file->size.suffix; - bytes_sent = 0; - - dfu_progress_bar("Download", 0, 1); - while (bytes_sent < expected_size) { - int bytes_left; - int chunk_size; - - bytes_left = expected_size - bytes_sent; - if (bytes_left < xfer_size) - chunk_size = bytes_left; - else - chunk_size = xfer_size; - - ret = dfu_download(dif->dev_handle, dif->interface, - chunk_size, transaction++, chunk_size ? buf : NULL); - if (ret < 0) { - warnx("Error during download"); - goto out; - } - bytes_sent += chunk_size; - buf += chunk_size; - - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during download get_status"); - goto out; - } - - if (dst.bState == DFU_STATE_dfuDNLOAD_IDLE || - dst.bState == DFU_STATE_dfuERROR) - break; - - /* Wait while device executes flashing */ - milli_sleep(dst.bwPollTimeout); - - } while (1); - if (dst.bStatus != DFU_STATUS_OK) { - printf(" failed!\n"); - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - ret = -1; - goto out; - } - dfu_progress_bar("Download", bytes_sent, bytes_sent + bytes_left); - } - - /* send one zero sized download request to signalize end */ - ret = dfu_download(dif->dev_handle, dif->interface, - 0, transaction, NULL); - if (ret < 0) { - errx(EX_IOERR, "Error sending completion packet"); - goto out; - } - - dfu_progress_bar("Download", bytes_sent, bytes_sent); - - if (verbose) - printf("Sent a total of %i bytes\n", bytes_sent); - -get_status: - /* Transition to MANIFEST_SYNC state */ - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - warnx("unable to read DFU status after completion"); - goto out; - } - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - - milli_sleep(dst.bwPollTimeout); - - /* FIXME: deal correctly with ManifestationTolerant=0 / WillDetach bits */ - switch (dst.bState) { - case DFU_STATE_dfuMANIFEST_SYNC: - case DFU_STATE_dfuMANIFEST: - /* some devices (e.g. TAS1020b) need some time before we - * can obtain the status */ - milli_sleep(1000); - goto get_status; - break; - case DFU_STATE_dfuIDLE: - break; - } - printf("Done!\n"); - -out: - return bytes_sent; -} diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_load.h b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_load.h deleted file mode 100755 index be23e9b4f..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_load.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef DFU_LOAD_H -#define DFU_LOAD_H - -int dfuload_do_upload(struct dfu_if *dif, int xfer_size, int expected_size, int fd); -int dfuload_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file); - -#endif /* DFU_LOAD_H */ diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_util.c b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_util.c deleted file mode 100755 index b94c7ccd3..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_util.c +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Functions for detecting DFU USB entities - * - * Written by Harald Welte - * Copyright 2007-2008 by OpenMoko, Inc. - * Copyright 2013 Hans Petter Selasky - * - * Based on existing code of dfu-programmer-0.4 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "dfu_util.h" -#include "dfuse.h" -#include "quirks.h" - -#ifdef HAVE_USBPATH_H -#include -#endif - -/* - * Look for a descriptor in a concatenated descriptor list. Will - * return upon the first match of the given descriptor type. Returns length of - * found descriptor, limited to res_size - */ -static int find_descriptor(const uint8_t *desc_list, int list_len, - uint8_t desc_type, void *res_buf, int res_size) -{ - int p = 0; - - if (list_len < 2) - return (-1); - - while (p + 1 < list_len) { - int desclen; - - desclen = (int) desc_list[p]; - if (desclen == 0) { - warnx("Invalid descriptor list"); - return -1; - } - if (desc_list[p + 1] == desc_type) { - if (desclen > res_size) - desclen = res_size; - if (p + desclen > list_len) - desclen = list_len - p; - memcpy(res_buf, &desc_list[p], desclen); - return desclen; - } - p += (int) desc_list[p]; - } - return -1; -} - -static void probe_configuration(libusb_device *dev, struct libusb_device_descriptor *desc) -{ - struct usb_dfu_func_descriptor func_dfu; - libusb_device_handle *devh; - struct dfu_if *pdfu; - struct libusb_config_descriptor *cfg; - const struct libusb_interface_descriptor *intf; - const struct libusb_interface *uif; - char alt_name[MAX_DESC_STR_LEN + 1]; - char serial_name[MAX_DESC_STR_LEN + 1]; - int cfg_idx; - int intf_idx; - int alt_idx; - int ret; - int has_dfu; - - for (cfg_idx = 0; cfg_idx != desc->bNumConfigurations; cfg_idx++) { - memset(&func_dfu, 0, sizeof(func_dfu)); - has_dfu = 0; - - ret = libusb_get_config_descriptor(dev, cfg_idx, &cfg); - if (ret != 0) - return; - if (match_config_index > -1 && match_config_index != cfg->bConfigurationValue) { - libusb_free_config_descriptor(cfg); - continue; - } - - /* - * In some cases, noticably FreeBSD if uid != 0, - * the configuration descriptors are empty - */ - if (!cfg) - return; - - ret = find_descriptor(cfg->extra, cfg->extra_length, - USB_DT_DFU, &func_dfu, sizeof(func_dfu)); - if (ret > -1) - goto found_dfu; - - for (intf_idx = 0; intf_idx < cfg->bNumInterfaces; - intf_idx++) { - uif = &cfg->interface[intf_idx]; - if (!uif) - break; - - for (alt_idx = 0; alt_idx < cfg->interface[intf_idx].num_altsetting; - alt_idx++) { - intf = &uif->altsetting[alt_idx]; - - ret = find_descriptor(intf->extra, intf->extra_length, USB_DT_DFU, - &func_dfu, sizeof(func_dfu)); - if (ret > -1) - goto found_dfu; - - if (intf->bInterfaceClass != 0xfe || - intf->bInterfaceSubClass != 1) - continue; - - has_dfu = 1; - } - } - if (has_dfu) { - /* - * Finally try to retrieve it requesting the - * device directly This is not supported on - * all devices for non-standard types - */ - if (libusb_open(dev, &devh) == 0) { - ret = libusb_get_descriptor(devh, USB_DT_DFU, 0, - (void *)&func_dfu, sizeof(func_dfu)); - libusb_close(devh); - if (ret > -1) - goto found_dfu; - } - warnx("Device has DFU interface, " - "but has no DFU functional descriptor"); - - /* fake version 1.0 */ - func_dfu.bLength = 7; - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - goto found_dfu; - } - libusb_free_config_descriptor(cfg); - continue; - -found_dfu: - if (func_dfu.bLength == 7) { - printf("Deducing device DFU version from functional descriptor " - "length\n"); - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - } else if (func_dfu.bLength < 9) { - printf("Error obtaining DFU functional descriptor\n"); - printf("Please report this as a bug!\n"); - printf("Warning: Assuming DFU version 1.0\n"); - func_dfu.bcdDFUVersion = libusb_cpu_to_le16(0x0100); - printf("Warning: Transfer size can not be detected\n"); - func_dfu.wTransferSize = 0; - } - - for (intf_idx = 0; intf_idx < cfg->bNumInterfaces; - intf_idx++) { - if (match_iface_index > -1 && match_iface_index != intf_idx) - continue; - - uif = &cfg->interface[intf_idx]; - if (!uif) - break; - - for (alt_idx = 0; - alt_idx < uif->num_altsetting; alt_idx++) { - int dfu_mode; - - intf = &uif->altsetting[alt_idx]; - - if (intf->bInterfaceClass != 0xfe || - intf->bInterfaceSubClass != 1) - continue; - - dfu_mode = (intf->bInterfaceProtocol == 2); - /* e.g. DSO Nano has bInterfaceProtocol 0 instead of 2 */ - if (func_dfu.bcdDFUVersion == 0x011a && intf->bInterfaceProtocol == 0) - dfu_mode = 1; - - if (dfu_mode && - match_iface_alt_index > -1 && match_iface_alt_index != alt_idx) - continue; - - if (dfu_mode) { - if ((match_vendor_dfu >= 0 && match_vendor_dfu != desc->idVendor) || - (match_product_dfu >= 0 && match_product_dfu != desc->idProduct)) { - continue; - } - } else { - if ((match_vendor >= 0 && match_vendor != desc->idVendor) || - (match_product >= 0 && match_product != desc->idProduct)) { - continue; - } - } - - if (libusb_open(dev, &devh)) { - warnx("Cannot open DFU device %04x:%04x", desc->idVendor, desc->idProduct); - break; - } - if (intf->iInterface != 0) - ret = libusb_get_string_descriptor_ascii(devh, - intf->iInterface, (void *)alt_name, MAX_DESC_STR_LEN); - else - ret = -1; - if (ret < 1) - strcpy(alt_name, "UNKNOWN"); - if (desc->iSerialNumber != 0) - ret = libusb_get_string_descriptor_ascii(devh, - desc->iSerialNumber, (void *)serial_name, MAX_DESC_STR_LEN); - else - ret = -1; - if (ret < 1) - strcpy(serial_name, "UNKNOWN"); - libusb_close(devh); - - if (dfu_mode && - match_iface_alt_name != NULL && strcmp(alt_name, match_iface_alt_name)) - continue; - - if (dfu_mode) { - if (match_serial_dfu != NULL && strcmp(match_serial_dfu, serial_name)) - continue; - } else { - if (match_serial != NULL && strcmp(match_serial, serial_name)) - continue; - } - - pdfu = dfu_malloc(sizeof(*pdfu)); - - memset(pdfu, 0, sizeof(*pdfu)); - - pdfu->func_dfu = func_dfu; - pdfu->dev = libusb_ref_device(dev); - pdfu->quirks = get_quirks(desc->idVendor, - desc->idProduct, desc->bcdDevice); - pdfu->vendor = desc->idVendor; - pdfu->product = desc->idProduct; - pdfu->bcdDevice = desc->bcdDevice; - pdfu->configuration = cfg->bConfigurationValue; - pdfu->interface = intf->bInterfaceNumber; - pdfu->altsetting = intf->bAlternateSetting; - pdfu->devnum = libusb_get_device_address(dev); - pdfu->busnum = libusb_get_bus_number(dev); - pdfu->alt_name = strdup(alt_name); - if (pdfu->alt_name == NULL) - errx(EX_SOFTWARE, "Out of memory"); - pdfu->serial_name = strdup(serial_name); - if (pdfu->serial_name == NULL) - errx(EX_SOFTWARE, "Out of memory"); - if (dfu_mode) - pdfu->flags |= DFU_IFF_DFU; - if (pdfu->quirks & QUIRK_FORCE_DFU11) { - pdfu->func_dfu.bcdDFUVersion = - libusb_cpu_to_le16(0x0110); - } - pdfu->bMaxPacketSize0 = desc->bMaxPacketSize0; - - /* queue into list */ - pdfu->next = dfu_root; - dfu_root = pdfu; - } - } - libusb_free_config_descriptor(cfg); - } -} - -void probe_devices(libusb_context *ctx) -{ - libusb_device **list; - ssize_t num_devs; - ssize_t i; - - num_devs = libusb_get_device_list(ctx, &list); - for (i = 0; i < num_devs; ++i) { - struct libusb_device_descriptor desc; - struct libusb_device *dev = list[i]; - - if (match_bus > -1 && match_bus != libusb_get_bus_number(dev)) - continue; - if (match_device > -1 && match_device != libusb_get_device_address(dev)) - continue; - if (libusb_get_device_descriptor(dev, &desc)) - continue; - probe_configuration(dev, &desc); - } - libusb_free_device_list(list, 0); -} - -void disconnect_devices(void) -{ - struct dfu_if *pdfu; - struct dfu_if *prev = NULL; - - for (pdfu = dfu_root; pdfu != NULL; pdfu = pdfu->next) { - free(prev); - libusb_unref_device(pdfu->dev); - free(pdfu->alt_name); - free(pdfu->serial_name); - prev = pdfu; - } - free(prev); - dfu_root = NULL; -} - -void print_dfu_if(struct dfu_if *dfu_if) -{ - printf("Found %s: [%04x:%04x] ver=%04x, devnum=%u, cfg=%u, intf=%u, " - "alt=%u, name=\"%s\", serial=\"%s\"\n", - dfu_if->flags & DFU_IFF_DFU ? "DFU" : "Runtime", - dfu_if->vendor, dfu_if->product, - dfu_if->bcdDevice, dfu_if->devnum, - dfu_if->configuration, dfu_if->interface, - dfu_if->altsetting, dfu_if->alt_name, - dfu_if->serial_name); -} - -/* Walk the device tree and print out DFU devices */ -void list_dfu_interfaces(void) -{ - struct dfu_if *pdfu; - - for (pdfu = dfu_root; pdfu != NULL; pdfu = pdfu->next) - print_dfu_if(pdfu); -} diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_util.h b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_util.h deleted file mode 100755 index fc0c19dca..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfu_util.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef DFU_UTIL_H -#define DFU_UTIL_H - -/* USB string descriptor should contain max 126 UTF-16 characters - * but 253 would even accomodate any UTF-8 encoding */ -#define MAX_DESC_STR_LEN 253 - -enum mode { - MODE_NONE, - MODE_VERSION, - MODE_LIST, - MODE_DETACH, - MODE_UPLOAD, - MODE_DOWNLOAD -}; - -extern struct dfu_if *dfu_root; -extern int match_bus; -extern int match_device; -extern int match_vendor; -extern int match_product; -extern int match_vendor_dfu; -extern int match_product_dfu; -extern int match_config_index; -extern int match_iface_index; -extern int match_iface_alt_index; -extern const char *match_iface_alt_name; -extern const char *match_serial; -extern const char *match_serial_dfu; - -void probe_devices(libusb_context *); -void disconnect_devices(void); -void print_dfu_if(struct dfu_if *); -void list_dfu_interfaces(void); - -#endif /* DFU_UTIL_H */ diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse.c b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse.c deleted file mode 100755 index fce29fed6..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse.c +++ /dev/null @@ -1,652 +0,0 @@ -/* - * DfuSe specific functions - * - * This implements the ST Microsystems DFU extensions (DfuSe) - * as per the DfuSe 1.1a specification (ST documents AN3156, AN2606) - * The DfuSe file format is described in ST document UM0391. - * - * Copyright 2010-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfuse.h" -#include "dfuse_mem.h" - -#define DFU_TIMEOUT 5000 - -extern int verbose; -static unsigned int last_erased_page = 1; /* non-aligned value, won't match */ -static struct memsegment *mem_layout; -static unsigned int dfuse_address = 0; -static unsigned int dfuse_length = 0; -static int dfuse_force = 0; -static int dfuse_leave = 0; -static int dfuse_unprotect = 0; -static int dfuse_mass_erase = 0; - -unsigned int quad2uint(unsigned char *p) -{ - return (*p + (*(p + 1) << 8) + (*(p + 2) << 16) + (*(p + 3) << 24)); -} - -void dfuse_parse_options(const char *options) -{ - char *end; - const char *endword; - unsigned int number; - - /* address, possibly empty, must be first */ - if (*options != ':') { - endword = strchr(options, ':'); - if (!endword) - endword = options + strlen(options); /* GNU strchrnul */ - - number = strtoul(options, &end, 0); - if (end == endword) { - dfuse_address = number; - } else { - errx(EX_IOERR, "Invalid dfuse address: %s", options); - } - options = endword; - } - - while (*options) { - if (*options == ':') { - options++; - continue; - } - endword = strchr(options, ':'); - if (!endword) - endword = options + strlen(options); - - if (!strncmp(options, "force", endword - options)) { - dfuse_force++; - options += 5; - continue; - } - if (!strncmp(options, "leave", endword - options)) { - dfuse_leave = 1; - options += 5; - continue; - } - if (!strncmp(options, "unprotect", endword - options)) { - dfuse_unprotect = 1; - options += 9; - continue; - } - if (!strncmp(options, "mass-erase", endword - options)) { - dfuse_mass_erase = 1; - options += 10; - continue; - } - - /* any valid number is interpreted as upload length */ - number = strtoul(options, &end, 0); - if (end == endword) { - dfuse_length = number; - } else { - errx(EX_IOERR, "Invalid dfuse modifier: %s", options); - } - options = endword; - } -} - -/* DFU_UPLOAD request for DfuSe 1.1a */ -int dfuse_upload(struct dfu_if *dif, const unsigned short length, - unsigned char *data, unsigned short transaction) -{ - int status; - - status = libusb_control_transfer(dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_IN | - LIBUSB_REQUEST_TYPE_CLASS | - LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_UPLOAD, - /* wValue */ transaction, - /* wIndex */ dif->interface, - /* Data */ data, - /* wLength */ length, - DFU_TIMEOUT); - if (status < 0) { - errx(EX_IOERR, "%s: libusb_control_msg returned %d", - __FUNCTION__, status); - } - return status; -} - -/* DFU_DNLOAD request for DfuSe 1.1a */ -int dfuse_download(struct dfu_if *dif, const unsigned short length, - unsigned char *data, unsigned short transaction) -{ - int status; - - status = libusb_control_transfer(dif->dev_handle, - /* bmRequestType */ LIBUSB_ENDPOINT_OUT | - LIBUSB_REQUEST_TYPE_CLASS | - LIBUSB_RECIPIENT_INTERFACE, - /* bRequest */ DFU_DNLOAD, - /* wValue */ transaction, - /* wIndex */ dif->interface, - /* Data */ data, - /* wLength */ length, - DFU_TIMEOUT); - if (status < 0) { - errx(EX_IOERR, "%s: libusb_control_transfer returned %d", - __FUNCTION__, status); - } - return status; -} - -/* DfuSe only commands */ -/* Leaves the device in dfuDNLOAD-IDLE state */ -int dfuse_special_command(struct dfu_if *dif, unsigned int address, - enum dfuse_command command) -{ - const char* dfuse_command_name[] = { "SET_ADDRESS" , "ERASE_PAGE", - "MASS_ERASE", "READ_UNPROTECT"}; - unsigned char buf[5]; - int length; - int ret; - struct dfu_status dst; - int firstpoll = 1; - - if (command == ERASE_PAGE) { - struct memsegment *segment; - int page_size; - - segment = find_segment(mem_layout, address); - if (!segment || !(segment->memtype & DFUSE_ERASABLE)) { - errx(EX_IOERR, "Page at 0x%08x can not be erased", - address); - } - page_size = segment->pagesize; - if (verbose > 1) - printf("Erasing page size %i at address 0x%08x, page " - "starting at 0x%08x\n", page_size, address, - address & ~(page_size - 1)); - buf[0] = 0x41; /* Erase command */ - length = 5; - last_erased_page = address & ~(page_size - 1); - } else if (command == SET_ADDRESS) { - if (verbose > 2) - printf(" Setting address pointer to 0x%08x\n", - address); - buf[0] = 0x21; /* Set Address Pointer command */ - length = 5; - } else if (command == MASS_ERASE) { - buf[0] = 0x41; /* Mass erase command when length = 1 */ - length = 1; - } else if (command == READ_UNPROTECT) { - buf[0] = 0x92; - length = 1; - } else { - errx(EX_IOERR, "Non-supported special command %d", command); - } - buf[1] = address & 0xff; - buf[2] = (address >> 8) & 0xff; - buf[3] = (address >> 16) & 0xff; - buf[4] = (address >> 24) & 0xff; - - ret = dfuse_download(dif, length, buf, 0); - if (ret < 0) { - errx(EX_IOERR, "Error during special command \"%s\" download", - dfuse_command_name[command]); - } - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during special command \"%s\" get_status", - dfuse_command_name[command]); - } - if (firstpoll) { - firstpoll = 0; - if (dst.bState != DFU_STATE_dfuDNBUSY) { - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - errx(EX_IOERR, "Wrong state after command \"%s\" download", - dfuse_command_name[command]); - } - } - /* wait while command is executed */ - if (verbose) - printf(" Poll timeout %i ms\n", dst.bwPollTimeout); - milli_sleep(dst.bwPollTimeout); - if (command == READ_UNPROTECT) - return ret; - } while (dst.bState == DFU_STATE_dfuDNBUSY); - - if (dst.bStatus != DFU_STATUS_OK) { - errx(EX_IOERR, "%s not correctly executed", - dfuse_command_name[command]); - } - return ret; -} - -int dfuse_dnload_chunk(struct dfu_if *dif, unsigned char *data, int size, - int transaction) -{ - int bytes_sent; - struct dfu_status dst; - int ret; - - ret = dfuse_download(dif, size, size ? data : NULL, transaction); - if (ret < 0) { - errx(EX_IOERR, "Error during download"); - return ret; - } - bytes_sent = ret; - - do { - ret = dfu_get_status(dif, &dst); - if (ret < 0) { - errx(EX_IOERR, "Error during download get_status"); - return ret; - } - milli_sleep(dst.bwPollTimeout); - } while (dst.bState != DFU_STATE_dfuDNLOAD_IDLE && - dst.bState != DFU_STATE_dfuERROR && - dst.bState != DFU_STATE_dfuMANIFEST); - - if (dst.bState == DFU_STATE_dfuMANIFEST) - printf("Transitioning to dfuMANIFEST state\n"); - - if (dst.bStatus != DFU_STATUS_OK) { - printf(" failed!\n"); - printf("state(%u) = %s, status(%u) = %s\n", dst.bState, - dfu_state_to_string(dst.bState), dst.bStatus, - dfu_status_to_string(dst.bStatus)); - return -1; - } - return bytes_sent; -} - -int dfuse_do_upload(struct dfu_if *dif, int xfer_size, int fd, - const char *dfuse_options) -{ - int total_bytes = 0; - int upload_limit = 0; - unsigned char *buf; - int transaction; - int ret; - - buf = dfu_malloc(xfer_size); - - if (dfuse_options) - dfuse_parse_options(dfuse_options); - if (dfuse_length) - upload_limit = dfuse_length; - if (dfuse_address) { - struct memsegment *segment; - - mem_layout = parse_memory_layout((char *)dif->alt_name); - if (!mem_layout) - errx(EX_IOERR, "Failed to parse memory layout"); - - segment = find_segment(mem_layout, dfuse_address); - if (!dfuse_force && - (!segment || !(segment->memtype & DFUSE_READABLE))) - errx(EX_IOERR, "Page at 0x%08x is not readable", - dfuse_address); - - if (!upload_limit) { - upload_limit = segment->end - dfuse_address + 1; - printf("Limiting upload to end of memory segment, " - "%i bytes\n", upload_limit); - } - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfu_abort_to_idle(dif); - } else { - /* Boot loader decides the start address, unknown to us */ - /* Use a short length to lower risk of running out of bounds */ - if (!upload_limit) - upload_limit = 0x4000; - printf("Limiting default upload to %i bytes\n", upload_limit); - } - - dfu_progress_bar("Upload", 0, 1); - - transaction = 2; - while (1) { - int rc; - - /* last chunk can be smaller than original xfer_size */ - if (upload_limit - total_bytes < xfer_size) - xfer_size = upload_limit - total_bytes; - rc = dfuse_upload(dif, xfer_size, buf, transaction++); - if (rc < 0) { - ret = rc; - goto out_free; - } - - dfu_file_write_crc(fd, 0, buf, rc); - total_bytes += rc; - - if (total_bytes < 0) - errx(EX_SOFTWARE, "Received too many bytes"); - - if (rc < xfer_size || total_bytes >= upload_limit) { - /* last block, return successfully */ - ret = total_bytes; - break; - } - dfu_progress_bar("Upload", total_bytes, upload_limit); - } - - dfu_progress_bar("Upload", total_bytes, total_bytes); - - dfu_abort_to_idle(dif); - if (dfuse_leave) { - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfuse_dnload_chunk(dif, NULL, 0, 2); /* Zero-size */ - } - - out_free: - free(buf); - - return ret; -} - -/* Writes an element of any size to the device, taking care of page erases */ -/* returns 0 on success, otherwise -EINVAL */ -int dfuse_dnload_element(struct dfu_if *dif, unsigned int dwElementAddress, - unsigned int dwElementSize, unsigned char *data, - int xfer_size) -{ - int p; - int ret; - struct memsegment *segment; - - /* Check at least that we can write to the last address */ - segment = - find_segment(mem_layout, dwElementAddress + dwElementSize - 1); - if (!segment || !(segment->memtype & DFUSE_WRITEABLE)) { - errx(EX_IOERR, "Last page at 0x%08x is not writeable", - dwElementAddress + dwElementSize - 1); - } - - dfu_progress_bar("Download", 0, 1); - - for (p = 0; p < (int)dwElementSize; p += xfer_size) { - int page_size; - unsigned int erase_address; - unsigned int address = dwElementAddress + p; - int chunk_size = xfer_size; - - segment = find_segment(mem_layout, address); - if (!segment || !(segment->memtype & DFUSE_WRITEABLE)) { - errx(EX_IOERR, "Page at 0x%08x is not writeable", - address); - } - page_size = segment->pagesize; - - /* check if this is the last chunk */ - if (p + chunk_size > (int)dwElementSize) - chunk_size = dwElementSize - p; - - /* Erase only for flash memory downloads */ - if ((segment->memtype & DFUSE_ERASABLE) && !dfuse_mass_erase) { - /* erase all involved pages */ - for (erase_address = address; - erase_address < address + chunk_size; - erase_address += page_size) - if ((erase_address & ~(page_size - 1)) != - last_erased_page) - dfuse_special_command(dif, - erase_address, - ERASE_PAGE); - - if (((address + chunk_size - 1) & ~(page_size - 1)) != - last_erased_page) { - if (verbose > 2) - printf(" Chunk extends into next page," - " erase it as well\n"); - dfuse_special_command(dif, - address + chunk_size - 1, - ERASE_PAGE); - } - } - - if (verbose) { - printf(" Download from image offset " - "%08x to memory %08x-%08x, size %i\n", - p, address, address + chunk_size - 1, - chunk_size); - } else { - dfu_progress_bar("Download", p, dwElementSize); - } - - dfuse_special_command(dif, address, SET_ADDRESS); - - /* transaction = 2 for no address offset */ - ret = dfuse_dnload_chunk(dif, data + p, chunk_size, 2); - if (ret != chunk_size) { - errx(EX_IOERR, "Failed to write whole chunk: " - "%i of %i bytes", ret, chunk_size); - return -EINVAL; - } - } - if (!verbose) - dfu_progress_bar("Download", dwElementSize, dwElementSize); - return 0; -} - -static void -dfuse_memcpy(unsigned char *dst, unsigned char **src, int *rem, int size) -{ - if (size > *rem) { - errx(EX_IOERR, "Corrupt DfuSe file: " - "Cannot read %d bytes from %d bytes", size, *rem); - } - if (dst != NULL) - memcpy(dst, *src, size); - (*src) += size; - (*rem) -= size; -} - -/* Download raw binary file to DfuSe device */ -int dfuse_do_bin_dnload(struct dfu_if *dif, int xfer_size, - struct dfu_file *file, unsigned int start_address) -{ - unsigned int dwElementAddress; - unsigned int dwElementSize; - unsigned char *data; - int ret; - - dwElementAddress = start_address; - dwElementSize = file->size.total - - file->size.suffix - file->size.prefix; - - printf("Downloading to address = 0x%08x, size = %i\n", - dwElementAddress, dwElementSize); - - data = file->firmware + file->size.prefix; - - ret = dfuse_dnload_element(dif, dwElementAddress, dwElementSize, data, - xfer_size); - if (ret != 0) - goto out_free; - - printf("File downloaded successfully\n"); - ret = dwElementSize; - - out_free: - return ret; -} - -/* Parse a DfuSe file and download contents to device */ -int dfuse_do_dfuse_dnload(struct dfu_if *dif, int xfer_size, - struct dfu_file *file) -{ - uint8_t dfuprefix[11]; - uint8_t targetprefix[274]; - uint8_t elementheader[8]; - int image; - int element; - int bTargets; - int bAlternateSetting; - int dwNbElements; - unsigned int dwElementAddress; - unsigned int dwElementSize; - uint8_t *data; - int ret; - int rem; - int bFirstAddressSaved = 0; - - rem = file->size.total - file->size.prefix - file->size.suffix; - data = file->firmware + file->size.prefix; - - /* Must be larger than a minimal DfuSe header and suffix */ - if (rem < (int)(sizeof(dfuprefix) + - sizeof(targetprefix) + sizeof(elementheader))) { - errx(EX_SOFTWARE, "File too small for a DfuSe file"); - } - - dfuse_memcpy(dfuprefix, &data, &rem, sizeof(dfuprefix)); - - if (strncmp((char *)dfuprefix, "DfuSe", 5)) { - errx(EX_IOERR, "No valid DfuSe signature"); - return -EINVAL; - } - if (dfuprefix[5] != 0x01) { - errx(EX_IOERR, "DFU format revision %i not supported", - dfuprefix[5]); - return -EINVAL; - } - bTargets = dfuprefix[10]; - printf("file contains %i DFU images\n", bTargets); - - for (image = 1; image <= bTargets; image++) { - printf("parsing DFU image %i\n", image); - dfuse_memcpy(targetprefix, &data, &rem, sizeof(targetprefix)); - if (strncmp((char *)targetprefix, "Target", 6)) { - errx(EX_IOERR, "No valid target signature"); - return -EINVAL; - } - bAlternateSetting = targetprefix[6]; - dwNbElements = quad2uint((unsigned char *)targetprefix + 270); - printf("image for alternate setting %i, ", bAlternateSetting); - printf("(%i elements, ", dwNbElements); - printf("total size = %i)\n", - quad2uint((unsigned char *)targetprefix + 266)); - if (bAlternateSetting != dif->altsetting) - printf("Warning: Image does not match current alternate" - " setting.\n" - "Please rerun with the correct -a option setting" - " to download this image!\n"); - for (element = 1; element <= dwNbElements; element++) { - printf("parsing element %i, ", element); - dfuse_memcpy(elementheader, &data, &rem, sizeof(elementheader)); - dwElementAddress = - quad2uint((unsigned char *)elementheader); - dwElementSize = - quad2uint((unsigned char *)elementheader + 4); - printf("address = 0x%08x, ", dwElementAddress); - printf("size = %i\n", dwElementSize); - - if (!bFirstAddressSaved) { - bFirstAddressSaved = 1; - dfuse_address = dwElementAddress; - } - /* sanity check */ - if ((int)dwElementSize > rem) - errx(EX_SOFTWARE, "File too small for element size"); - - if (bAlternateSetting == dif->altsetting) { - ret = dfuse_dnload_element(dif, dwElementAddress, - dwElementSize, data, xfer_size); - } else { - ret = 0; - } - - /* advance read pointer */ - dfuse_memcpy(NULL, &data, &rem, dwElementSize); - - if (ret != 0) - return ret; - } - } - - if (rem != 0) - warnx("%d bytes leftover", rem); - - printf("done parsing DfuSe file\n"); - - return 0; -} - -int dfuse_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file, - const char *dfuse_options) -{ - int ret; - - if (dfuse_options) - dfuse_parse_options(dfuse_options); - mem_layout = parse_memory_layout((char *)dif->alt_name); - if (!mem_layout) { - errx(EX_IOERR, "Failed to parse memory layout"); - } - if (dfuse_unprotect) { - if (!dfuse_force) { - errx(EX_IOERR, "The read unprotect command " - "will erase the flash memory" - "and can only be used with force\n"); - } - dfuse_special_command(dif, 0, READ_UNPROTECT); - printf("Device disconnects, erases flash and resets now\n"); - exit(0); - } - if (dfuse_mass_erase) { - if (!dfuse_force) { - errx(EX_IOERR, "The mass erase command " - "can only be used with force"); - } - printf("Performing mass erase, this can take a moment\n"); - dfuse_special_command(dif, 0, MASS_ERASE); - } - if (dfuse_address) { - if (file->bcdDFU == 0x11a) { - errx(EX_IOERR, "This is a DfuSe file, not " - "meant for raw download"); - } - ret = dfuse_do_bin_dnload(dif, xfer_size, file, dfuse_address); - } else { - if (file->bcdDFU != 0x11a) { - warnx("Only DfuSe file version 1.1a is supported"); - errx(EX_IOERR, "(for raw binary download, use the " - "--dfuse-address option)"); - } - ret = dfuse_do_dfuse_dnload(dif, xfer_size, file); - } - free_segment_list(mem_layout); - - dfu_abort_to_idle(dif); - - if (dfuse_leave) { - dfuse_special_command(dif, dfuse_address, SET_ADDRESS); - dfuse_dnload_chunk(dif, NULL, 0, 2); /* Zero-size */ - } - return ret; -} diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse.h b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse.h deleted file mode 100755 index ed1108cfc..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse.h +++ /dev/null @@ -1,35 +0,0 @@ -/* This implements the ST Microsystems DFU extensions (DfuSe) - * as per the DfuSe 1.1a specification (Document UM0391) - * - * (C) 2010-2012 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFUSE_H -#define DFUSE_H - -#include "dfu.h" - -enum dfuse_command { SET_ADDRESS, ERASE_PAGE, MASS_ERASE, READ_UNPROTECT }; - -int dfuse_special_command(struct dfu_if *dif, unsigned int address, - enum dfuse_command command); -int dfuse_do_upload(struct dfu_if *dif, int xfer_size, int fd, - const char *dfuse_options); -int dfuse_do_dnload(struct dfu_if *dif, int xfer_size, struct dfu_file *file, - const char *dfuse_options); - -#endif /* DFUSE_H */ diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse_mem.c b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse_mem.c deleted file mode 100755 index a91aacf5f..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse_mem.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - * Helper functions for reading the memory map of a device - * following the ST DfuSe 1.1a specification. - * - * Copyright 2011-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" -#include "dfuse_mem.h" - -int add_segment(struct memsegment **segment_list, struct memsegment segment) -{ - struct memsegment *new_element; - - new_element = dfu_malloc(sizeof(struct memsegment)); - *new_element = segment; - new_element->next = NULL; - - if (*segment_list == NULL) - /* list can be empty on first call */ - *segment_list = new_element; - else { - struct memsegment *next_element; - - /* find last element in list */ - next_element = *segment_list; - while (next_element->next != NULL) - next_element = next_element->next; - next_element->next = new_element; - } - return 0; -} - -struct memsegment *find_segment(struct memsegment *segment_list, - unsigned int address) -{ - while (segment_list != NULL) { - if (segment_list->start <= address && - segment_list->end >= address) - return segment_list; - segment_list = segment_list->next; - } - return NULL; -} - -void free_segment_list(struct memsegment *segment_list) -{ - struct memsegment *next_element; - - while (segment_list->next != NULL) { - next_element = segment_list->next; - free(segment_list); - segment_list = next_element; - } - free(segment_list); -} - -/* Parse memory map from interface descriptor string - * encoded as per ST document UM0424 section 4.3.2. - */ -struct memsegment *parse_memory_layout(char *intf_desc) -{ - - char multiplier, memtype; - unsigned int address; - int sectors, size; - char *name, *typestring; - int ret; - int count = 0; - char separator; - int scanned; - struct memsegment *segment_list = NULL; - struct memsegment segment; - - name = dfu_malloc(strlen(intf_desc)); - - ret = sscanf(intf_desc, "@%[^/]%n", name, &scanned); - if (ret < 1) { - free(name); - warnx("Could not read name, sscanf returned %d", ret); - return NULL; - } - printf("DfuSe interface name: \"%s\"\n", name); - - intf_desc += scanned; - typestring = dfu_malloc(strlen(intf_desc)); - - while (ret = sscanf(intf_desc, "/0x%x/%n", &address, &scanned), - ret > 0) { - - intf_desc += scanned; - while (ret = sscanf(intf_desc, "%d*%d%c%[^,/]%n", - §ors, &size, &multiplier, typestring, - &scanned), ret > 2) { - intf_desc += scanned; - - count++; - memtype = 0; - if (ret == 4) { - if (strlen(typestring) == 1 - && typestring[0] != '/') - memtype = typestring[0]; - else { - warnx("Parsing type identifier '%s' " - "failed for segment %i", - typestring, count); - continue; - } - } - - /* Quirk for STM32F4 devices */ - if (strcmp(name, "Device Feature") == 0) - memtype = 'e'; - - switch (multiplier) { - case 'B': - break; - case 'K': - size *= 1024; - break; - case 'M': - size *= 1024 * 1024; - break; - case 'a': - case 'b': - case 'c': - case 'd': - case 'e': - case 'f': - case 'g': - if (!memtype) { - warnx("Non-valid multiplier '%c', " - "interpreted as type " - "identifier instead", - multiplier); - memtype = multiplier; - break; - } - /* fallthrough if memtype was already set */ - default: - warnx("Non-valid multiplier '%c', " - "assuming bytes", multiplier); - } - - if (!memtype) { - warnx("No valid type for segment %d\n", count); - continue; - } - - segment.start = address; - segment.end = address + sectors * size - 1; - segment.pagesize = size; - segment.memtype = memtype & 7; - add_segment(&segment_list, segment); - - if (verbose) - printf("Memory segment at 0x%08x %3d x %4d = " - "%5d (%s%s%s)\n", - address, sectors, size, sectors * size, - memtype & DFUSE_READABLE ? "r" : "", - memtype & DFUSE_ERASABLE ? "e" : "", - memtype & DFUSE_WRITEABLE ? "w" : ""); - - address += sectors * size; - - separator = *intf_desc; - if (separator == ',') - intf_desc += 1; - else - break; - } /* while per segment */ - - } /* while per address */ - free(name); - free(typestring); - - return segment_list; -} diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse_mem.h b/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse_mem.h deleted file mode 100755 index 0181f0c16..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/dfuse_mem.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Helper functions for reading the memory map in a device - * following the ST DfuSe 1.1a specification. - * - * (C) 2011 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DFUSE_MEM_H -#define DFUSE_MEM_H - -#define DFUSE_READABLE 1 -#define DFUSE_ERASABLE 2 -#define DFUSE_WRITEABLE 4 - -struct memsegment { - unsigned int start; - unsigned int end; - int pagesize; - int memtype; - struct memsegment *next; -}; - -int add_segment(struct memsegment **list, struct memsegment new_element); - -struct memsegment *find_segment(struct memsegment *list, unsigned int address); - -void free_segment_list(struct memsegment *list); - -struct memsegment *parse_memory_layout(char *intf_desc_str); - -#endif /* DFUSE_MEM_H */ diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/main.c b/arduino/opencr_arduino/tools/win/src/dfu-util/src/main.c deleted file mode 100755 index acaed2f08..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/main.c +++ /dev/null @@ -1,699 +0,0 @@ -/* - * dfu-util - * - * Copyright 2007-2008 by OpenMoko, Inc. - * Copyright 2013-2014 Hans Petter Selasky - * - * Written by Harald Welte - * - * Based on existing code of dfu-programmer-0.4 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu.h" -#include "usb_dfu.h" -#include "dfu_file.h" -#include "dfu_load.h" -#include "dfu_util.h" -#include "dfuse.h" -#include "quirks.h" - -#ifdef HAVE_USBPATH_H -#include -#endif - -int verbose = 0; - -struct dfu_if *dfu_root = NULL; - -int match_bus = -1; -int match_device = -1; -int match_vendor = -1; -int match_product = -1; -int match_vendor_dfu = -1; -int match_product_dfu = -1; -int match_config_index = -1; -int match_iface_index = -1; -int match_iface_alt_index = -1; -const char *match_iface_alt_name = NULL; -const char *match_serial = NULL; -const char *match_serial_dfu = NULL; - -static int parse_match_value(const char *str, int default_value) -{ - char *remainder; - int value; - - if (str == NULL) { - value = default_value; - } else if (*str == '*') { - value = -1; /* Match anything */ - } else if (*str == '-') { - value = 0x10000; /* Impossible vendor/product ID */ - } else { - value = strtoul(str, &remainder, 16); - if (remainder == str) { - value = default_value; - } - } - return value; -} - -static void parse_vendprod(const char *str) -{ - const char *comma; - const char *colon; - - /* Default to match any DFU device in runtime or DFU mode */ - match_vendor = -1; - match_product = -1; - match_vendor_dfu = -1; - match_product_dfu = -1; - - comma = strchr(str, ','); - if (comma == str) { - /* DFU mode vendor/product being specified without any runtime - * vendor/product specification, so don't match any runtime device */ - match_vendor = match_product = 0x10000; - } else { - colon = strchr(str, ':'); - if (colon != NULL) { - ++colon; - if ((comma != NULL) && (colon > comma)) { - colon = NULL; - } - } - match_vendor = parse_match_value(str, match_vendor); - match_product = parse_match_value(colon, match_product); - if (comma != NULL) { - /* Both runtime and DFU mode vendor/product specifications are - * available, so default DFU mode match components to the given - * runtime match components */ - match_vendor_dfu = match_vendor; - match_product_dfu = match_product; - } - } - if (comma != NULL) { - ++comma; - colon = strchr(comma, ':'); - if (colon != NULL) { - ++colon; - } - match_vendor_dfu = parse_match_value(comma, match_vendor_dfu); - match_product_dfu = parse_match_value(colon, match_product_dfu); - } -} - -static void parse_serial(char *str) -{ - char *comma; - - match_serial = str; - comma = strchr(str, ','); - if (comma == NULL) { - match_serial_dfu = match_serial; - } else { - *comma++ = 0; - match_serial_dfu = comma; - } - if (*match_serial == 0) match_serial = NULL; - if (*match_serial_dfu == 0) match_serial_dfu = NULL; -} - -#ifdef HAVE_USBPATH_H - -static int resolve_device_path(char *path) -{ - int res; - - res = usb_path2devnum(path); - if (res < 0) - return -EINVAL; - if (!res) - return 0; - - match_bus = atoi(path); - match_device = res; - - return 0; -} - -#else /* HAVE_USBPATH_H */ - -static int resolve_device_path(char *path) -{ - (void)path; /* Eliminate unused variable warning */ - errx(EX_SOFTWARE, "USB device paths are not supported by this dfu-util.\n"); -} - -#endif /* !HAVE_USBPATH_H */ - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-util [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -v --verbose\t\t\tPrint verbose debug statements\n" - " -l --list\t\t\tList currently attached DFU capable devices\n"); - fprintf(stderr, " -e --detach\t\t\tDetach currently attached DFU capable devices\n" - " -E --detach-delay seconds\tTime to wait before reopening a device after detach\n" - " -d --device :[,:]\n" - "\t\t\t\tSpecify Vendor/Product ID(s) of DFU device\n" - " -p --path \tSpecify path to DFU device\n" - " -c --cfg \t\tSpecify the Configuration of DFU device\n" - " -i --intf \t\tSpecify the DFU Interface number\n" - " -S --serial [,]\n" - "\t\t\t\tSpecify Serial String of DFU device\n" - " -a --alt \t\tSpecify the Altsetting of the DFU Interface\n" - "\t\t\t\tby name or by number\n"); - fprintf(stderr, " -t --transfer-size \tSpecify the number of bytes per USB Transfer\n" - " -U --upload \t\tRead firmware from device into \n" - " -Z --upload-size \tSpecify the expected upload size in bytes\n" - " -D --download \t\tWrite firmware from into device\n" - " -R --reset\t\t\tIssue USB Reset signalling once we're finished\n" - " -s --dfuse-address

\tST DfuSe mode, specify target address for\n" - "\t\t\t\traw file download or upload. Not applicable for\n" - "\t\t\t\tDfuSe file (.dfu) downloads\n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf(PACKAGE_STRING "\n\n"); - printf("Copyright 2005-2009 Weston Schmidt, Harald Welte and OpenMoko Inc.\n" - "Copyright 2010-2014 Tormod Volden and Stefan Schmidt\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to " PACKAGE_BUGREPORT "\n\n"); -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "verbose", 0, 0, 'v' }, - { "list", 0, 0, 'l' }, - { "detach", 0, 0, 'e' }, - { "detach-delay", 1, 0, 'E' }, - { "device", 1, 0, 'd' }, - { "path", 1, 0, 'p' }, - { "configuration", 1, 0, 'c' }, - { "cfg", 1, 0, 'c' }, - { "interface", 1, 0, 'i' }, - { "intf", 1, 0, 'i' }, - { "altsetting", 1, 0, 'a' }, - { "alt", 1, 0, 'a' }, - { "serial", 1, 0, 'S' }, - { "transfer-size", 1, 0, 't' }, - { "upload", 1, 0, 'U' }, - { "upload-size", 1, 0, 'Z' }, - { "download", 1, 0, 'D' }, - { "reset", 0, 0, 'R' }, - { "dfuse-address", 1, 0, 's' }, - { 0, 0, 0, 0 } -}; - -int main(int argc, char **argv) -{ - int expected_size = 0; - unsigned int transfer_size = 0; - enum mode mode = MODE_NONE; - struct dfu_status status; - libusb_context *ctx; - struct dfu_file file; - char *end; - int final_reset = 0; - int ret; - int dfuse_device = 0; - int fd; - const char *dfuse_options = NULL; - int detach_delay = 5; - uint16_t runtime_vendor; - uint16_t runtime_product; - - memset(&file, 0, sizeof(file)); - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVvleE:d:p:c:i:a:S:t:U:D:Rs:Z:", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - mode = MODE_VERSION; - break; - case 'v': - verbose++; - break; - case 'l': - mode = MODE_LIST; - break; - case 'e': - mode = MODE_DETACH; - match_iface_alt_index = 0; - match_iface_index = 0; - break; - case 'E': - detach_delay = atoi(optarg); - break; - case 'd': - parse_vendprod(optarg); - break; - case 'p': - /* Parse device path */ - ret = resolve_device_path(optarg); - if (ret < 0) - errx(EX_SOFTWARE, "Unable to parse '%s'", optarg); - if (!ret) - errx(EX_SOFTWARE, "Cannot find '%s'", optarg); - break; - case 'c': - /* Configuration */ - match_config_index = atoi(optarg); - break; - case 'i': - /* Interface */ - match_iface_index = atoi(optarg); - break; - case 'a': - /* Interface Alternate Setting */ - match_iface_alt_index = strtoul(optarg, &end, 0); - if (*end) { - match_iface_alt_name = optarg; - match_iface_alt_index = -1; - } - break; - case 'S': - parse_serial(optarg); - break; - case 't': - transfer_size = atoi(optarg); - break; - case 'U': - mode = MODE_UPLOAD; - file.name = optarg; - break; - case 'Z': - expected_size = atoi(optarg); - break; - case 'D': - mode = MODE_DOWNLOAD; - file.name = optarg; - break; - case 'R': - final_reset = 1; - break; - case 's': - dfuse_options = optarg; - break; - default: - help(); - break; - } - } - - print_version(); - if (mode == MODE_VERSION) { - exit(0); - } - - if (mode == MODE_NONE) { - fprintf(stderr, "You need to specify one of -D or -U\n"); - help(); - } - - if (match_config_index == 0) { - /* Handle "-c 0" (unconfigured device) as don't care */ - match_config_index = -1; - } - - if (mode == MODE_DOWNLOAD) { - dfu_load_file(&file, MAYBE_SUFFIX, MAYBE_PREFIX); - /* If the user didn't specify product and/or vendor IDs to match, - * use any IDs from the file suffix for device matching */ - if (match_vendor < 0 && file.idVendor != 0xffff) { - match_vendor = file.idVendor; - printf("Match vendor ID from file: %04x\n", match_vendor); - } - if (match_product < 0 && file.idProduct != 0xffff) { - match_product = file.idProduct; - printf("Match product ID from file: %04x\n", match_product); - } - } - - ret = libusb_init(&ctx); - if (ret) - errx(EX_IOERR, "unable to initialize libusb: %i", ret); - - if (verbose > 2) { - libusb_set_debug(ctx, 255); - } - - probe_devices(ctx); - - if (mode == MODE_LIST) { - list_dfu_interfaces(); - exit(0); - } - - if (dfu_root == NULL) { - errx(EX_IOERR, "No DFU capable USB device available"); - } else if (dfu_root->next != NULL) { - /* We cannot safely support more than one DFU capable device - * with same vendor/product ID, since during DFU we need to do - * a USB bus reset, after which the target device will get a - * new address */ - errx(EX_IOERR, "More than one DFU capable USB device found! " - "Try `--list' and specify the serial number " - "or disconnect all but one device\n"); - } - - /* We have exactly one device. Its libusb_device is now in dfu_root->dev */ - - printf("Opening DFU capable USB device...\n"); - ret = libusb_open(dfu_root->dev, &dfu_root->dev_handle); - if (ret || !dfu_root->dev_handle) - errx(EX_IOERR, "Cannot open device"); - - printf("ID %04x:%04x\n", dfu_root->vendor, dfu_root->product); - - printf("Run-time device DFU version %04x\n", - libusb_le16_to_cpu(dfu_root->func_dfu.bcdDFUVersion)); - - /* Transition from run-Time mode to DFU mode */ - if (!(dfu_root->flags & DFU_IFF_DFU)) { - int err; - /* In the 'first round' during runtime mode, there can only be one - * DFU Interface descriptor according to the DFU Spec. */ - - /* FIXME: check if the selected device really has only one */ - - runtime_vendor = dfu_root->vendor; - runtime_product = dfu_root->product; - - printf("Claiming USB DFU Runtime Interface...\n"); - if (libusb_claim_interface(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "Cannot claim interface %d", - dfu_root->interface); - } - - if (libusb_set_interface_alt_setting(dfu_root->dev_handle, dfu_root->interface, 0) < 0) { - errx(EX_IOERR, "Cannot set alt interface zero"); - } - - printf("Determining device status: "); - - err = dfu_get_status(dfu_root, &status); - if (err == LIBUSB_ERROR_PIPE) { - printf("Device does not implement get_status, assuming appIDLE\n"); - status.bStatus = DFU_STATUS_OK; - status.bwPollTimeout = 0; - status.bState = DFU_STATE_appIDLE; - status.iString = 0; - } else if (err < 0) { - errx(EX_IOERR, "error get_status"); - } else { - printf("state = %s, status = %d\n", - dfu_state_to_string(status.bState), status.bStatus); - } - milli_sleep(status.bwPollTimeout); - - switch (status.bState) { - case DFU_STATE_appIDLE: - case DFU_STATE_appDETACH: - printf("Device really in Runtime Mode, send DFU " - "detach request...\n"); - if (dfu_detach(dfu_root->dev_handle, - dfu_root->interface, 1000) < 0) { - warnx("error detaching"); - } - if (dfu_root->func_dfu.bmAttributes & USB_DFU_WILL_DETACH) { - printf("Device will detach and reattach...\n"); - } else { - printf("Resetting USB...\n"); - ret = libusb_reset_device(dfu_root->dev_handle); - if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) - errx(EX_IOERR, "error resetting " - "after detach"); - } - break; - case DFU_STATE_dfuERROR: - printf("dfuERROR, clearing status\n"); - if (dfu_clear_status(dfu_root->dev_handle, - dfu_root->interface) < 0) { - errx(EX_IOERR, "error clear_status"); - } - /* fall through */ - default: - warnx("WARNING: Runtime device already in DFU state ?!?"); - libusb_release_interface(dfu_root->dev_handle, - dfu_root->interface); - goto dfustate; - } - libusb_release_interface(dfu_root->dev_handle, - dfu_root->interface); - libusb_close(dfu_root->dev_handle); - dfu_root->dev_handle = NULL; - - if (mode == MODE_DETACH) { - libusb_exit(ctx); - exit(0); - } - - /* keeping handles open might prevent re-enumeration */ - disconnect_devices(); - - milli_sleep(detach_delay * 1000); - - /* Change match vendor and product to impossible values to force - * only DFU mode matches in the following probe */ - match_vendor = match_product = 0x10000; - - probe_devices(ctx); - - if (dfu_root == NULL) { - errx(EX_IOERR, "Lost device after RESET?"); - } else if (dfu_root->next != NULL) { - errx(EX_IOERR, "More than one DFU capable USB device found! " - "Try `--list' and specify the serial number " - "or disconnect all but one device"); - } - - /* Check for DFU mode device */ - if (!(dfu_root->flags | DFU_IFF_DFU)) - errx(EX_SOFTWARE, "Device is not in DFU mode"); - - printf("Opening DFU USB Device...\n"); - ret = libusb_open(dfu_root->dev, &dfu_root->dev_handle); - if (ret || !dfu_root->dev_handle) { - errx(EX_IOERR, "Cannot open device"); - } - } else { - /* we're already in DFU mode, so we can skip the detach/reset - * procedure */ - /* If a match vendor/product was specified, use that as the runtime - * vendor/product, otherwise use the DFU mode vendor/product */ - runtime_vendor = match_vendor < 0 ? dfu_root->vendor : match_vendor; - runtime_product = match_product < 0 ? dfu_root->product : match_product; - } - -dfustate: -#if 0 - printf("Setting Configuration %u...\n", dfu_root->configuration); - if (libusb_set_configuration(dfu_root->dev_handle, dfu_root->configuration) < 0) { - errx(EX_IOERR, "Cannot set configuration"); - } -#endif - printf("Claiming USB DFU Interface...\n"); - if (libusb_claim_interface(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "Cannot claim interface"); - } - - printf("Setting Alternate Setting #%d ...\n", dfu_root->altsetting); - if (libusb_set_interface_alt_setting(dfu_root->dev_handle, dfu_root->interface, dfu_root->altsetting) < 0) { - errx(EX_IOERR, "Cannot set alternate interface"); - } - -status_again: - printf("Determining device status: "); - if (dfu_get_status(dfu_root, &status ) < 0) { - errx(EX_IOERR, "error get_status"); - } - printf("state = %s, status = %d\n", - dfu_state_to_string(status.bState), status.bStatus); - - milli_sleep(status.bwPollTimeout); - - switch (status.bState) { - case DFU_STATE_appIDLE: - case DFU_STATE_appDETACH: - errx(EX_IOERR, "Device still in Runtime Mode!"); - break; - case DFU_STATE_dfuERROR: - printf("dfuERROR, clearing status\n"); - if (dfu_clear_status(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "error clear_status"); - } - goto status_again; - break; - case DFU_STATE_dfuDNLOAD_IDLE: - case DFU_STATE_dfuUPLOAD_IDLE: - printf("aborting previous incomplete transfer\n"); - if (dfu_abort(dfu_root->dev_handle, dfu_root->interface) < 0) { - errx(EX_IOERR, "can't send DFU_ABORT"); - } - goto status_again; - break; - case DFU_STATE_dfuIDLE: - printf("dfuIDLE, continuing\n"); - break; - default: - break; - } - - if (DFU_STATUS_OK != status.bStatus ) { - printf("WARNING: DFU Status: '%s'\n", - dfu_status_to_string(status.bStatus)); - /* Clear our status & try again. */ - if (dfu_clear_status(dfu_root->dev_handle, dfu_root->interface) < 0) - errx(EX_IOERR, "USB communication error"); - if (dfu_get_status(dfu_root, &status) < 0) - errx(EX_IOERR, "USB communication error"); - if (DFU_STATUS_OK != status.bStatus) - errx(EX_SOFTWARE, "Status is not OK: %d", status.bStatus); - - milli_sleep(status.bwPollTimeout); - } - - printf("DFU mode device DFU version %04x\n", - libusb_le16_to_cpu(dfu_root->func_dfu.bcdDFUVersion)); - - if (dfu_root->func_dfu.bcdDFUVersion == libusb_cpu_to_le16(0x11a)) - dfuse_device = 1; - - /* If not overridden by the user */ - if (!transfer_size) { - transfer_size = libusb_le16_to_cpu( - dfu_root->func_dfu.wTransferSize); - if (transfer_size) { - printf("Device returned transfer size %i\n", - transfer_size); - } else { - errx(EX_IOERR, "Transfer size must be specified"); - } - } - -#ifdef HAVE_GETPAGESIZE -/* autotools lie when cross-compiling for Windows using mingw32/64 */ -#ifndef __MINGW32__ - /* limitation of Linux usbdevio */ - if ((int)transfer_size > getpagesize()) { - transfer_size = getpagesize(); - printf("Limited transfer size to %i\n", transfer_size); - } -#endif /* __MINGW32__ */ -#endif /* HAVE_GETPAGESIZE */ - - if (transfer_size < dfu_root->bMaxPacketSize0) { - transfer_size = dfu_root->bMaxPacketSize0; - printf("Adjusted transfer size to %i\n", transfer_size); - } - - switch (mode) { - case MODE_UPLOAD: - /* open for "exclusive" writing */ - fd = open(file.name, O_WRONLY | O_BINARY | O_CREAT | O_EXCL | O_TRUNC, 0666); - if (fd < 0) - err(EX_IOERR, "Cannot open file %s for writing", file.name); - - if (dfuse_device || dfuse_options) { - if (dfuse_do_upload(dfu_root, transfer_size, fd, - dfuse_options) < 0) - exit(1); - } else { - if (dfuload_do_upload(dfu_root, transfer_size, - expected_size, fd) < 0) { - exit(1); - } - } - close(fd); - break; - - case MODE_DOWNLOAD: - if (((file.idVendor != 0xffff && file.idVendor != runtime_vendor) || - (file.idProduct != 0xffff && file.idProduct != runtime_product)) && - ((file.idVendor != 0xffff && file.idVendor != dfu_root->vendor) || - (file.idProduct != 0xffff && file.idProduct != dfu_root->product))) { - errx(EX_IOERR, "Error: File ID %04x:%04x does " - "not match device (%04x:%04x or %04x:%04x)", - file.idVendor, file.idProduct, - runtime_vendor, runtime_product, - dfu_root->vendor, dfu_root->product); - } - if (dfuse_device || dfuse_options || file.bcdDFU == 0x11a) { - if (dfuse_do_dnload(dfu_root, transfer_size, &file, - dfuse_options) < 0) - exit(1); - } else { - if (dfuload_do_dnload(dfu_root, transfer_size, &file) < 0) - exit(1); - } - break; - case MODE_DETACH: - if (dfu_detach(dfu_root->dev_handle, dfu_root->interface, 1000) < 0) { - warnx("can't detach"); - } - break; - default: - errx(EX_IOERR, "Unsupported mode: %u", mode); - break; - } - - if (final_reset) { - if (dfu_detach(dfu_root->dev_handle, dfu_root->interface, 1000) < 0) { - /* Even if detach failed, just carry on to leave the - device in a known state */ - warnx("can't detach"); - } - printf("Resetting USB to switch back to runtime mode\n"); - ret = libusb_reset_device(dfu_root->dev_handle); - if (ret < 0 && ret != LIBUSB_ERROR_NOT_FOUND) { - errx(EX_IOERR, "error resetting after download"); - } - } - - libusb_close(dfu_root->dev_handle); - dfu_root->dev_handle = NULL; - libusb_exit(ctx); - - return (0); -} diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/portable.h b/arduino/opencr_arduino/tools/win/src/dfu-util/src/portable.h deleted file mode 100755 index cf8d5df38..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/portable.h +++ /dev/null @@ -1,72 +0,0 @@ - -#ifndef PORTABLE_H -#define PORTABLE_H - -#ifdef HAVE_CONFIG_H -# include "config.h" -#else -# define PACKAGE "dfu-util" -# define PACKAGE_VERSION "0.8-msvc" -# define PACKAGE_STRING "dfu-util 0.8-msvc" -# define PACKAGE_BUGREPORT "dfu-util@lists.gnumonks.org" -#endif /* HAVE_CONFIG_H */ - -#ifdef HAVE_FTRUNCATE -# include -#else -# include -#endif /* HAVE_FTRUNCATE */ - -#ifdef HAVE_NANOSLEEP -# include -# define milli_sleep(msec) do {\ - if (msec) {\ - struct timespec nanosleepDelay = { (msec) / 1000, ((msec) % 1000) * 1000000 };\ - nanosleep(&nanosleepDelay, NULL);\ - } } while (0) -#elif defined HAVE_WINDOWS_H -# define milli_sleep(msec) do {\ - if (msec) {\ - Sleep(msec);\ - } } while (0) -#else -# error "Can't get no sleep! Please report" -#endif /* HAVE_NANOSLEEP */ - -#ifdef HAVE_ERR -# include -#else -# include -# include -# define warnx(...) do {\ - fprintf(stderr, __VA_ARGS__);\ - fprintf(stderr, "\n"); } while (0) -# define errx(eval, ...) do {\ - warnx(__VA_ARGS__);\ - exit(eval); } while (0) -# define warn(...) do {\ - fprintf(stderr, "%s: ", strerror(errno));\ - warnx(__VA_ARGS__); } while (0) -# define err(eval, ...) do {\ - warn(__VA_ARGS__);\ - exit(eval); } while (0) -#endif /* HAVE_ERR */ - -#ifdef HAVE_SYSEXITS_H -# include -#else -# define EX_OK 0 /* successful termination */ -# define EX_USAGE 64 /* command line usage error */ -# define EX_SOFTWARE 70 /* internal software error */ -# define EX_IOERR 74 /* input/output error */ -#endif /* HAVE_SYSEXITS_H */ - -#ifndef O_BINARY -# define O_BINARY 0 -#endif - -#ifndef off_t -# define off_t long int -#endif - -#endif /* PORTABLE_H */ diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/prefix.c b/arduino/opencr_arduino/tools/win/src/dfu-util/src/prefix.c deleted file mode 100755 index be8e3faf3..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/prefix.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * dfu-prefix - * - * Copyright 2011-2012 Stefan Schmidt - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Uwe Bonnes - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -enum mode { - MODE_NONE, - MODE_ADD, - MODE_DEL, - MODE_CHECK -}; - -int verbose; - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-prefix [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -c --check \t\tCheck DFU prefix of \n" - " -D --delete \t\tDelete DFU prefix from \n" - " -a --add \t\tAdd DFU prefix to \n" - "In combination with -a:\n" - ); - fprintf(stderr, " -s --stellaris-address
Add TI Stellaris address prefix to \n" - "In combination with -D or -c:\n" - " -T --stellaris\t\tAct on TI Stellaris address prefix of \n" - "In combination with -a or -D or -c:\n" - " -L --lpc-prefix\t\tUse NXP LPC DFU prefix format\n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf("dfu-prefix (%s) %s\n\n", PACKAGE, PACKAGE_VERSION); - printf("Copyright 2011-2012 Stefan Schmidt, 2014 Uwe Bonnes\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to %s\n\n", PACKAGE_BUGREPORT); - -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "check", 1, 0, 'c' }, - { "add", 1, 0, 'a' }, - { "delete", 1, 0, 'D' }, - { "stellaris-address", 1, 0, 's' }, - { "stellaris", 0, 0, 'T' }, - { "LPC", 0, 0, 'L' }, -}; -int main(int argc, char **argv) -{ - struct dfu_file file; - enum mode mode = MODE_NONE; - enum prefix_type type = ZERO_PREFIX; - uint32_t lmdfu_flash_address = 0; - char *end; - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - print_version(); - - memset(&file, 0, sizeof(file)); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVc:a:D:p:v:d:s:TL", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - exit(0); - break; - case 'D': - file.name = optarg; - mode = MODE_DEL; - break; - case 'c': - file.name = optarg; - mode = MODE_CHECK; - break; - case 'a': - file.name = optarg; - mode = MODE_ADD; - break; - case 's': - lmdfu_flash_address = strtoul(optarg, &end, 0); - if (*end) { - errx(EX_IOERR, "Invalid lmdfu " - "address: %s", optarg); - } - /* fall-through */ - case 'T': - type = LMDFU_PREFIX; - break; - case 'L': - type = LPCDFU_UNENCRYPTED_PREFIX; - break; - default: - help(); - break; - } - } - - if (!file.name) { - fprintf(stderr, "You need to specify a filename\n"); - help(); - } - - switch(mode) { - case MODE_ADD: - if (type == ZERO_PREFIX) - errx(EX_IOERR, "Prefix type must be specified"); - dfu_load_file(&file, MAYBE_SUFFIX, NO_PREFIX); - file.lmdfu_address = lmdfu_flash_address; - file.prefix_type = type; - printf("Adding prefix to file\n"); - dfu_store_file(&file, file.size.suffix != 0, 1); - break; - - case MODE_CHECK: - dfu_load_file(&file, MAYBE_SUFFIX, MAYBE_PREFIX); - show_suffix_and_prefix(&file); - if (type > ZERO_PREFIX && file.prefix_type != type) - errx(EX_IOERR, "No prefix of requested type"); - break; - - case MODE_DEL: - dfu_load_file(&file, MAYBE_SUFFIX, NEEDS_PREFIX); - if (type > ZERO_PREFIX && file.prefix_type != type) - errx(EX_IOERR, "No prefix of requested type"); - printf("Removing prefix from file\n"); - /* if there was a suffix, rewrite it */ - dfu_store_file(&file, file.size.suffix != 0, 0); - break; - - default: - help(); - break; - } - return (0); -} diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/quirks.c b/arduino/opencr_arduino/tools/win/src/dfu-util/src/quirks.c deleted file mode 100755 index de394a615..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/quirks.c +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Simple quirk system for dfu-util - * - * Copyright 2010-2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include "quirks.h" - -uint16_t get_quirks(uint16_t vendor, uint16_t product, uint16_t bcdDevice) -{ - uint16_t quirks = 0; - - /* Device returns bogus bwPollTimeout values */ - if ((vendor == VENDOR_OPENMOKO || vendor == VENDOR_FIC) && - product >= PRODUCT_FREERUNNER_FIRST && - product <= PRODUCT_FREERUNNER_LAST) - quirks |= QUIRK_POLLTIMEOUT; - - if (vendor == VENDOR_VOTI && - product == PRODUCT_OPENPCD) - quirks |= QUIRK_POLLTIMEOUT; - - /* Reports wrong DFU version in DFU descriptor */ - if (vendor == VENDOR_LEAFLABS && - product == PRODUCT_MAPLE3 && - bcdDevice == 0x0200) - quirks |= QUIRK_FORCE_DFU11; - - /* old devices(bcdDevice == 0) return bogus bwPollTimeout values */ - if (vendor == VENDOR_SIEMENS && - (product == PRODUCT_PXM40 || product == PRODUCT_PXM50) && - bcdDevice == 0) - quirks |= QUIRK_POLLTIMEOUT; - - /* M-Audio Transit returns bogus bwPollTimeout values */ - if (vendor == VENDOR_MIDIMAN && - product == PRODUCT_TRANSIT) - quirks |= QUIRK_POLLTIMEOUT; - - return (quirks); -} diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/quirks.h b/arduino/opencr_arduino/tools/win/src/dfu-util/src/quirks.h deleted file mode 100755 index 0e4b3ec58..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/quirks.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef DFU_QUIRKS_H -#define DFU_QUIRKS_H - -#define VENDOR_OPENMOKO 0x1d50 /* Openmoko Freerunner / GTA02 */ -#define VENDOR_FIC 0x1457 /* Openmoko Freerunner / GTA02 */ -#define VENDOR_VOTI 0x16c0 /* OpenPCD Reader */ -#define VENDOR_LEAFLABS 0x1eaf /* Maple */ -#define VENDOR_SIEMENS 0x0908 /* Siemens AG */ -#define VENDOR_MIDIMAN 0x0763 /* Midiman */ - -#define PRODUCT_FREERUNNER_FIRST 0x5117 -#define PRODUCT_FREERUNNER_LAST 0x5126 -#define PRODUCT_OPENPCD 0x076b -#define PRODUCT_MAPLE3 0x0003 /* rev 3 and 5 */ -#define PRODUCT_PXM40 0x02c4 /* Siemens AG, PXM 40 */ -#define PRODUCT_PXM50 0x02c5 /* Siemens AG, PXM 50 */ -#define PRODUCT_TRANSIT 0x2806 /* M-Audio Transit (Midiman) */ - -#define QUIRK_POLLTIMEOUT (1<<0) -#define QUIRK_FORCE_DFU11 (1<<1) - -/* Fallback value, works for OpenMoko */ -#define DEFAULT_POLLTIMEOUT 5 - -uint16_t get_quirks(uint16_t vendor, uint16_t product, uint16_t bcdDevice); - -#endif /* DFU_QUIRKS_H */ diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/suffix.c b/arduino/opencr_arduino/tools/win/src/dfu-util/src/suffix.c deleted file mode 100755 index 0df248f51..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/suffix.c +++ /dev/null @@ -1,176 +0,0 @@ -/* - * dfu-suffix - * - * Copyright 2011-2012 Stefan Schmidt - * Copyright 2013 Hans Petter Selasky - * Copyright 2014 Tormod Volden - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include -#include -#include -#include -#include - -#include "portable.h" -#include "dfu_file.h" - -enum mode { - MODE_NONE, - MODE_ADD, - MODE_DEL, - MODE_CHECK -}; - -int verbose; - -static void help(void) -{ - fprintf(stderr, "Usage: dfu-suffix [options] ...\n" - " -h --help\t\t\tPrint this help message\n" - " -V --version\t\t\tPrint the version number\n" - " -c --check \t\tCheck DFU suffix of \n" - " -a --add \t\tAdd DFU suffix to \n" - " -D --delete \t\tDelete DFU suffix from \n" - " -p --pid \t\tAdd product ID into DFU suffix in \n" - " -v --vid \t\tAdd vendor ID into DFU suffix in \n" - " -d --did \t\tAdd device ID into DFU suffix in \n" - " -S --spec \t\tAdd DFU specification ID into DFU suffix in \n" - ); - exit(EX_USAGE); -} - -static void print_version(void) -{ - printf("dfu-suffix (%s) %s\n\n", PACKAGE, PACKAGE_VERSION); - printf("Copyright 2011-2012 Stefan Schmidt, 2013-2014 Tormod Volden\n" - "This program is Free Software and has ABSOLUTELY NO WARRANTY\n" - "Please report bugs to %s\n\n", PACKAGE_BUGREPORT); - -} - -static struct option opts[] = { - { "help", 0, 0, 'h' }, - { "version", 0, 0, 'V' }, - { "check", 1, 0, 'c' }, - { "add", 1, 0, 'a' }, - { "delete", 1, 0, 'D' }, - { "pid", 1, 0, 'p' }, - { "vid", 1, 0, 'v' }, - { "did", 1, 0, 'd' }, - { "spec", 1, 0, 'S' }, -}; - -int main(int argc, char **argv) -{ - struct dfu_file file; - int pid, vid, did, spec; - enum mode mode = MODE_NONE; - - /* make sure all prints are flushed */ - setvbuf(stdout, NULL, _IONBF, 0); - - print_version(); - - pid = vid = did = 0xffff; - spec = 0x0100; /* Default to bcdDFU version 1.0 */ - memset(&file, 0, sizeof(file)); - - while (1) { - int c, option_index = 0; - c = getopt_long(argc, argv, "hVc:a:D:p:v:d:S:s:T", opts, - &option_index); - if (c == -1) - break; - - switch (c) { - case 'h': - help(); - break; - case 'V': - exit(0); - break; - case 'D': - file.name = optarg; - mode = MODE_DEL; - break; - case 'p': - pid = strtol(optarg, NULL, 16); - break; - case 'v': - vid = strtol(optarg, NULL, 16); - break; - case 'd': - did = strtol(optarg, NULL, 16); - break; - case 'S': - spec = strtol(optarg, NULL, 16); - break; - case 'c': - file.name = optarg; - mode = MODE_CHECK; - break; - case 'a': - file.name = optarg; - mode = MODE_ADD; - break; - default: - help(); - break; - } - } - - if (!file.name) { - fprintf(stderr, "You need to specify a filename\n"); - help(); - } - - if (spec != 0x0100 && spec != 0x011a) { - fprintf(stderr, "Only DFU specification 0x0100 and 0x011a supported\n"); - help(); - } - - switch(mode) { - case MODE_ADD: - dfu_load_file(&file, NO_SUFFIX, MAYBE_PREFIX); - file.idVendor = vid; - file.idProduct = pid; - file.bcdDevice = did; - file.bcdDFU = spec; - /* always write suffix, rewrite prefix if there was one */ - dfu_store_file(&file, 1, file.size.prefix != 0); - printf("Suffix successfully added to file\n"); - break; - - case MODE_CHECK: - dfu_load_file(&file, NEEDS_SUFFIX, MAYBE_PREFIX); - show_suffix_and_prefix(&file); - break; - - case MODE_DEL: - dfu_load_file(&file, NEEDS_SUFFIX, MAYBE_PREFIX); - dfu_store_file(&file, 0, file.size.prefix != 0); - if (file.size.suffix) /* had a suffix */ - printf("Suffix successfully removed from file\n"); - break; - - default: - help(); - break; - } - return (0); -} diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/src/usb_dfu.h b/arduino/opencr_arduino/tools/win/src/dfu-util/src/usb_dfu.h deleted file mode 100755 index 660bedcbf..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/src/usb_dfu.h +++ /dev/null @@ -1,99 +0,0 @@ -#ifndef USB_DFU_H -#define USB_DFU_H -/* USB Device Firmware Update Implementation for OpenPCD - * (C) 2006 by Harald Welte - * - * Protocol definitions for USB DFU - * - * This ought to be compliant to the USB DFU Spec 1.0 as available from - * http://www.usb.org/developers/devclass_docs/usbdfu10.pdf - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include - -#define USB_DT_DFU 0x21 - -#ifdef _MSC_VER -# pragma pack(push) -# pragma pack(1) -#endif /* _MSC_VER */ -struct usb_dfu_func_descriptor { - uint8_t bLength; - uint8_t bDescriptorType; - uint8_t bmAttributes; -#define USB_DFU_CAN_DOWNLOAD (1 << 0) -#define USB_DFU_CAN_UPLOAD (1 << 1) -#define USB_DFU_MANIFEST_TOL (1 << 2) -#define USB_DFU_WILL_DETACH (1 << 3) - uint16_t wDetachTimeOut; - uint16_t wTransferSize; - uint16_t bcdDFUVersion; -#ifdef _MSC_VER -}; -# pragma pack(pop) -#elif defined __GNUC__ -} __attribute__ ((packed)); -#else - #warning "No way to pack struct on this compiler? This will break!" -#endif /* _MSC_VER */ - -#define USB_DT_DFU_SIZE 9 - -#define USB_TYPE_DFU (LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE) - -/* DFU class-specific requests (Section 3, DFU Rev 1.1) */ -#define USB_REQ_DFU_DETACH 0x00 -#define USB_REQ_DFU_DNLOAD 0x01 -#define USB_REQ_DFU_UPLOAD 0x02 -#define USB_REQ_DFU_GETSTATUS 0x03 -#define USB_REQ_DFU_CLRSTATUS 0x04 -#define USB_REQ_DFU_GETSTATE 0x05 -#define USB_REQ_DFU_ABORT 0x06 - -/* DFU_GETSTATUS bStatus values (Section 6.1.2, DFU Rev 1.1) */ -#define DFU_STATUS_OK 0x00 -#define DFU_STATUS_errTARGET 0x01 -#define DFU_STATUS_errFILE 0x02 -#define DFU_STATUS_errWRITE 0x03 -#define DFU_STATUS_errERASE 0x04 -#define DFU_STATUS_errCHECK_ERASED 0x05 -#define DFU_STATUS_errPROG 0x06 -#define DFU_STATUS_errVERIFY 0x07 -#define DFU_STATUS_errADDRESS 0x08 -#define DFU_STATUS_errNOTDONE 0x09 -#define DFU_STATUS_errFIRMWARE 0x0a -#define DFU_STATUS_errVENDOR 0x0b -#define DFU_STATUS_errUSBR 0x0c -#define DFU_STATUS_errPOR 0x0d -#define DFU_STATUS_errUNKNOWN 0x0e -#define DFU_STATUS_errSTALLEDPKT 0x0f - -enum dfu_state { - DFU_STATE_appIDLE = 0, - DFU_STATE_appDETACH = 1, - DFU_STATE_dfuIDLE = 2, - DFU_STATE_dfuDNLOAD_SYNC = 3, - DFU_STATE_dfuDNBUSY = 4, - DFU_STATE_dfuDNLOAD_IDLE = 5, - DFU_STATE_dfuMANIFEST_SYNC = 6, - DFU_STATE_dfuMANIFEST = 7, - DFU_STATE_dfuMANIFEST_WAIT_RST = 8, - DFU_STATE_dfuUPLOAD_IDLE = 9, - DFU_STATE_dfuERROR = 10 -}; - -#endif /* USB_DFU_H */ diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/www/build.html b/arduino/opencr_arduino/tools/win/src/dfu-util/www/build.html deleted file mode 100755 index f3036e40c..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/www/build.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - Building dfu-util from source - - - - - - - - - -
-

How to build dfu-util from source

- -

Prerequisites for building from git

-

Mac OS X

-

-First install MacPorts (and if you are on 10.6 or older, the Java Developer Package) and then run: -

-
-	sudo port install libusb-devel git-core
-
- -

FreeBSD

-
-	sudo pkg_add -r git pkgconf
-
- -

Ubuntu and Debian and derivatives

-
-	sudo apt-get build-dep dfu-util
-	sudo apt-get install libusb-1.0-0-dev
-
- -

Get the source code and build it

-

-The first time you will have to clone the git repository: -

-
-	git clone git://gitorious.org/dfu-util/dfu-util.git
-	cd dfu-util
-
-

-If you later want to update to latest git version, just run this: -

-
-	make maintainer-clean
-	git pull
-
-

-To build the source: -

-
-	./autogen.sh
-	./configure  # on most systems
-	make
-
- -

-If you are building on Mac OS X, replace the ./configure command with: -

-
-	./configure --libdir=/opt/local/lib --includedir=/opt/local/include  # on MacOSX only
-
- -

-Your dfu-util binary will be inside the src folder. Use it from there, or install it to /usr/local/bin by running "sudo make install". -

- -

Cross-building for Windows

- -

-Windows binaries can be built in a MinGW -environment, on a Windows computer or cross-hosted in another OS. -To build it on a Debian or Ubuntu host, first install build dependencies: -

-
-	sudo apt-get build-dep libusb-1.0-0 dfu-util
-	sudo apt-get install mingw32
-
- -

-The below example builds dfu-util 0.8 and libusb 1.0.19 from unpacked release -tarballs. If you instead build from git, you will have to run "./autogen.sh" -before running the "./configure" steps. -

- -
-mkdir -p build
-cd libusb-1.0.19
-PKG_CONFIG_PATH=$PWD/../build/lib/pkgconfig ./configure \
-    --host=i586-mingw32msvc --prefix=$PWD/../build
-# WINVER workaround needed for 1.0.19 only
-make CFLAGS="-DWINVER=0x0501"
-make install
-cd ..
-
-cd dfu-util-0.8
-PKG_CONFIG_PATH=$PWD/../build/lib/pkgconfig ./configure \
-    --host=i586-mingw32msvc --prefix=$PWD/../build
-make
-make install
-cd ..
-
-The build files will now be in build/bin. -

- -

Building on Windows using MinGW

-This assumes using release tarballs or having run ./autogen.sh on -the git sources. -
-cd libusb-1.0.19
-./configure --prefix=$HOME
-# WINVER workaround needed for 1.0.19 only
-# MKDIR_P setting should not really be needed...
-make CFLAGS="-DWINVER=0x0501" MKDIR_P="mkdir -p"
-make install
-cd ..
-
-cd dfu-util-0.8
-./configure USB_CFLAGS="-I$HOME/include/libusb-1.0" \
-            USB_LIBS="-L $HOME/lib -lusb-1.0" PKG_CONFIG=true
-make
-make install
-cd ..
-
-To link libusb statically into dfu-util.exe use instead of "make": -
-make LDFLAGS=-static
-
-The built executables (and DLL) will now be under $HOME/bin. - -

-[Back to dfu-util main page] -

- -
- - diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/www/dfu-util.1.html b/arduino/opencr_arduino/tools/win/src/dfu-util/www/dfu-util.1.html deleted file mode 100755 index 62ca40b5d..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/www/dfu-util.1.html +++ /dev/null @@ -1,411 +0,0 @@ - - -Man page of DFU-UTIL - - -

DFU-UTIL(1)

- -  -

NAME

- -dfu-util - Device firmware update (DFU) USB programmer -  -

SYNOPSIS

- - -
-
-dfu-util - --l - -[-v] - -[-d - -vid:pid[,vid:pid]] - -[-p - -path] - -[-c - -configuration] - -[-i - -interface] - -[-a - -alt-intf] - -[-S - -serial[,serial]] - - -
-dfu-util - -[-v] - -[-d - -vid:pid[,vid:pid]] - -[-p - -path] - -[-c - -configuration] - -[-i - -interface] - -[-a - -alt-intf] - -[-S - -serial[,serial]] - -[-t - -size] - -[-Z - -size] - -[-s - -address] - -[-R] - -[-D|-U - -file] - - -
-dfu-util - -[-hV] - -
-  -

DESCRIPTION

- -dfu-util - -is a program that implements the host (computer) side of the USB DFU -(Universal Serial Bus Device Firmware Upgrade) protocol. -

-dfu-util communicates with devices that implement the device side of the -USB DFU protocol, and is often used to upgrade the firmware of such -devices. -  -

OPTIONS

- -
-
-l, --list - -
-List the currently attached DFU capable USB devices. -
-d, --device [Run-Time VENDOR]:[Run-Time PRODUCT][,[DFU Mode VENDOR]:[DFU Mode PRODUCT]] - -
-
-Specify run-time and/or DFU mode vendor and/or product IDs of the DFU device -to work with. VENDOR and PRODUCT are hexadecimal numbers (no prefix -needed), "*" (match any), or "-" (match nothing). By default, any DFU capable -device in either run-time or DFU mode will be considered. -

-If you only have one standards-compliant DFU device attached to your computer, -this parameter is optional. However, as soon as you have multiple DFU devices -connected, dfu-util will detect this and abort, asking you to specify which -device to use. -

-If only run-time IDs are specified (e.g. "--device 1457:51ab"), then in -addition to the specified run-time IDs, any DFU mode devices will also be -considered. This is beneficial to allow a DFU capable device to be found -again after a switch to DFU mode, since the vendor and/or product ID of a -device usually changes in DFU mode. -

-If only DFU mode IDs are specified (e.g. "--device ,951:26"), then all -run-time devices will be ignored, making it easy to target a specific device in -DFU mode. -

-If both run-time and DFU mode IDs are specified (e.g. "--device -1457:51ab,:2bc"), then unspecified DFU mode components will use the run-time -value specified. -

-Examples: -

-
--device 1457:51ab,951:26 - -
-
- -Work with a device in run-time mode with -vendor ID 0x1457 and product ID 0x51ab, or in DFU mode with vendor ID 0x0951 -and product ID 0x0026 -

-

--device 1457:51ab,:2bc - -
-
- -Work with a device in run-time mode with vendor ID 0x1457 and product ID -0x51ab, or in DFU mode with vendor ID 0x1457 and product ID 0x02bc -

-

--device 1457:51ab - -
-
- -Work with a device in run-time mode with vendor ID 0x1457 and product ID -0x51ab, or in DFU mode with any vendor and product ID -

-

--device ,951:26 - -
-
- -Work with a device in DFU mode with vendor ID 0x0951 and product ID 0x0026 -

-

--device *,- - -
-
- -Work with any device in run-time mode, and ignore any device in DFU mode -

-

--device , - -
-
- -Ignore any device in run-time mode, and Work with any device in DFU mode -
-
- -
-p, --path BUS-PORT. ... .PORT - -
-Specify the path to the DFU device. -
-c, --cfg CONFIG-NR - -
-Specify the configuration of the DFU device. Note that this is only used for matching, the configuration is not set by dfu-util. -
-i, --intf INTF-NR - -
-Specify the DFU interface number. -
-a, --alt ALT - -
-Specify the altsetting of the DFU interface by name or by number. -
-S, --serial [Run-Time SERIAL][,[DFU Mode SERIAL]] - -
-Specify the run-time and DFU mode serial numbers used to further restrict -device matches. If multiple, identical DFU devices are simultaneously -connected to a system then vendor and product ID will be insufficient for -targeting a single device. In this situation, it may be possible to use this -parameter to specify a serial number which also must match. -

-If only a single serial number is specified, then the same serial number is -used in both run-time and DFU mode. An empty serial number will match any -serial number in the corresponding mode. -

-t, --transfer-size SIZE - -
-Specify the number of bytes per USB transfer. The optimal value is -usually determined automatically so this option is rarely useful. If -you need to use this option for a device, please report it as a bug. -
-Z, --upload-size SIZE - -
-Specify the expected upload size, in bytes. -
-U, --upload FILE - -
-Read firmware from device into -FILE. - -
-D, --download FILE - -
-Write firmware from -FILE - -into device. -
-R, --reset - -
-Issue USB reset signalling after upload or download has finished. -
-s, --dfuse-address address - -
-Specify target address for raw binary download/upload on DfuSe devices. Do -not - -use this for downloading DfuSe (.dfu) files. Modifiers can be added -to the address, separated by a colon, to perform special DfuSE commands such -as "leave" DFU mode, "unprotect" and "mass-erase" flash memory. -
-v, --verbose - -
-Print more information about dfu-util's operation. A second --v - -will turn on verbose logging of USB requests. Repeat this option to further -increase verbosity. -
-h, --help - -
-Show a help text and exit. -
-V, --version - -
-Show version information and exit. -
-  -

EXAMPLES

- -  -

Using dfu-util in the OpenMoko project

- -(with the Neo1973 hardware) -

- -Flashing the rootfs: -
- - $ dfu-util -a rootfs -R -D /path/to/openmoko-devel-image.jffs2 - -

- -Flashing the kernel: -
- - $ dfu-util -a kernel -R -D /path/to/uImage - -

- -Flashing the bootloader: -
- - $ dfu-util -a u-boot -R -D /path/to/u-boot.bin - -

- -Copying a kernel into RAM: -
- - $ dfu-util -a 0 -R -D /path/to/uImage - -

-Once this has finished, the kernel will be available at the default load -address of 0x32000000 in Neo1973 RAM. -Note: - -You cannot transfer more than 2MB of data into RAM using this method. -

-  -

Using dfu-util with a DfuSe device

- -

- -Flashing a -.dfu - -(special DfuSe format) file to the device: -
- - $ dfu-util -a 0 -D /path/to/dfuse-image.dfu - -

- -Reading out 1 KB of flash starting at address 0x8000000: -
- - $ dfu-util -a 0 -s 0x08000000:1024 -U newfile.bin - -

- -Flashing a binary file to address 0x8004000 of device memory and -ask the device to leave DFU mode: -
- - $ dfu-util -a 0 -s 0x08004000:leave -D /path/to/image.bin - - -  -

BUGS

- -Please report any bugs to the dfu-util mailing list at -dfu-util@lists.gnumonks.org. - -Please use the ---verbose option (repeated as necessary) to provide more - -information in your bug report. -  -

SEE ALSO

- -The dfu-util home page is -http://dfu-util.gnumonks.org - -  -

HISTORY

- -dfu-util was originally written for the OpenMoko project by -Weston Schmidt <weston_schmidt@yahoo.com> and -Harald Welte <hwelte@hmw-consulting.de>. Over time, nearly complete -support of DFU 1.0, DFU 1.1 and DfuSe ("1.1a") has been added. -  -

LICENCE

- -dfu-util - -is covered by the GNU General Public License (GPL), version 2 or later. -  -

COPYRIGHT

- -This manual page was originally written by Uwe Hermann <uwe@hermann-uwe.de>, -and is now part of the dfu-util project. -

- -


- 

Index

-
-
NAME
-
SYNOPSIS
-
DESCRIPTION
-
OPTIONS
-
EXAMPLES
-
-
Using dfu-util in the OpenMoko project
-
Using dfu-util with a DfuSe device
-
-
BUGS
-
SEE ALSO
-
HISTORY
-
LICENCE
-
COPYRIGHT
-
-
-This document was created by man2html, -using the doc/dfu-util.1 manual page from dfu-util 0.8.
-Time: 14:40:57 GMT, September 13, 2014 - - diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/www/dfuse.html b/arduino/opencr_arduino/tools/win/src/dfu-util/www/dfuse.html deleted file mode 100755 index 35e4ffa9f..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/www/dfuse.html +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - DfuSe and dfu-util - - - - - - - - - -
-

Using dfu-util with DfuSe devices

-

DfuSe

-

- DfuSe (DFU with ST Microsystems extensions) is a protocol based on - DFU 1.1. However, in expanding the functionality of the DFU protocol, - ST Microsystems broke all compatibility with the DFU 1.1 standard. - DfuSe devices report the DFU version as "1.1a". -

-

- DfuSe can be used to download firmware and other data - from a host computer to a conforming device (or upload in the - opposite direction) over USB similar to standard DFU. -

-

- The main difference from standard DFU is that the target address in - the device (flash) memory is specified by the host, so that a - download can be performed to parts of the device memory. The host - program is also responsible for erasing flash pages before they - are written to. -

-

.dfu files

-

- A special file format is defined by ST Microsystems to carry firmware - for DfuSe devices. The file contains target information such as address - and alternate interface information in addition to the binary data. - Several blocks of binary data can be combined in one .dfu file. -

-

Alternate interfaces

-

- Different memory locations of the device may have different - characteristics that the host program (dfu-util) has to take - into considerations, such as flash memory page size, read-only - versus read-write segments, the need to erase, and so on. - These parameters are reported by the device in the string - descriptors meant for describing the USB interfaces. - The host program decodes these strings to build a memory map of - the device. Different memory units or address spaces are listed - in separate alternate interface settings that must be selected - according to the memory unit to access. -

-

- Note that dfu-util leaves it to the user to select alternate - interface. When parsing a .dfu file it will skip file segments - not matching the selected alternate interface. Also, some - DfuSe device firmware implementations ignore the setting of - alternate interface and deduct the memory unit from the - address, since they have no address space overlap. -

-

DfuSe special commands

-

- DfuSe special commands are used by the host program during normal - downloads or uploads, such as SET_ADDRESS and ERASE_PAGE. Also - the normal DFU_DNLOAD and DFU_UPLOAD commands have special - implementations in DfuSe. - Many DfuSe devices also support commands to leave DFU mode, - read unprotect the flash memory or mass erase the flash memory. - dfu-util (from version 0.7) - supports adding "leave", "unprotect", or "mass-erase" - to the -s option argument to send such requests in combination - with a download request. These modifiers are separated with a colon. -

-

- Some DfuSe devices have their DfuSe bootloader running from flash - memory. Erasing the whole flash memory would therefore destroy - the DfuSe bootloader itself and practically brick the device - for most users. Any use of modifiers such as "unprotect" - and "mass-erase" therefore needs to be combined with the "force" - modifer. This is not included in the examples, to not encourage - ignorant users to copy and paste such instructions and shoot - themselves in the foot. -

-

- Devices based on for instance STM32F103 all run the bootloader - from flash, since there is no USB bootloader in ROM. -

-

- For instance STM32F107, STM32F2xx and STM32F4xx devices have a - DfuSe bootloader in ROM, so the flash can be erased while - keeping the device available for USB DFU transfers as long - as the device designers use this built-in bootloader and have - not implemented another DfuSe bootloader in flash that the user is - dependent upon. -

-

- Well-written bootloaders running from flash will report their - own memory region as read-only and not eraseable, but this does - not prevent dfu-util from sending a "unprotect" or "mass-erase" - request which overrides this, if the user insists. -

-

Example usage

-

- Flashing a .dfu (special DfuSe format) file to the device: -

-
-         $ dfu-util -a 0 -D /path/to/dfuse-image.dfu
-	
-

- Reading out 1 KB of flash starting at address 0x8000000: -

-
-         $ dfu-util -a 0 -s 0x08000000:1024 -U newfile.bin
-	
-

- Flashing a binary file to address 0x8004000 of device memory and ask - the device to leave DFU mode: -

-
-         $ dfu-util -a 0 -s 0x08004000:leave -D /path/to/image.bin
-	
-

- [Back to dfu-util main page] -

- -
- - diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/www/index.html b/arduino/opencr_arduino/tools/win/src/dfu-util/www/index.html deleted file mode 100755 index 108ddaf66..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/www/index.html +++ /dev/null @@ -1,119 +0,0 @@ - - - - - - dfu-util Homepage - - - - - - - - - -
-

dfu-util - Device Firmware Upgrade Utilities

-

Description

-

- dfu-util is a host side implementation of the DFU 1.0 and DFU 1.1 specifications of the USB forum. - - DFU is intended to download and upload firmware to/from devices connected - over USB. It ranges from small devices like micro-controller boards - to mobile phones. Using dfu-util you can download firmware to your - DFU-enabled device or upload firmware from it. dfu-util has been - tested with the Openmoko Neo1973 and Freerunner and many other devices. -

-

- See the manual page for examples of use. -

-

Supported Devices

- -

Releases

-

- Releases of the dfu-util software can be found in the - releases folder. - The current release is 0.8. -

-

- We offer binaries for Microsoft Windows and some other platforms. - dfu-util uses libusb 1.0 to access your device, so - on Windows you have to register the device with the WinUSB driver - (alternatively libusb-win32 or libusbK), please see the libusbx wiki - for more details. -

-

- Mac OS X users can also get dfu-util from Homebrew with "brew install dfu-util" or from MacPorts. -

-

- Most Linux distributions ship dfu-util in binary packages for those - who do not want to compile dfu-util from source. - On Debian, Ubuntu, Fedora and Gentoo you can install it through the - normal software package tools. For other distributions -(namely OpenSuSe, Mandriva, and CentOS) Holger Freyther was kind enough to -provide binary packages through the Open Build Service. -

-

Development

-

- Development happens in a GIT repository. Browse it via the web -interface or clone it with: -

-
-	git clone git://gitorious.org/dfu-util/dfu-util.git
-	
-

- See our build instructions for how to - build the source on different platforms. -

-

License

-

- This software is licensed under the GPL version 2. -

-

Contact

-

- If you have questions about the development or use of dfu-util please - send an e-mail to our dedicated -mailing list for dfu-util. -

-

People

-

- dfu-util was originally written by - Harald Welte partially based on code from - dfu-programmer 0.4 and is currently maintained by Stefan Schmidt and - Tormod Volden. -

- -
- - diff --git a/arduino/opencr_arduino/tools/win/src/dfu-util/www/simple.css b/arduino/opencr_arduino/tools/win/src/dfu-util/www/simple.css deleted file mode 100755 index 98100bc5c..000000000 --- a/arduino/opencr_arduino/tools/win/src/dfu-util/www/simple.css +++ /dev/null @@ -1,56 +0,0 @@ -body { - margin: 10px; - font-size: 0.82em; - background-color: #EEE; -} - -h1 { - clear: both; - padding: 0 0 12px 0; - margin: 0; - font-size: 2em; - font-weight: bold; -} - -h2 { - clear: both; - margin: 0; - font-size: 1.5em; - font-weight: normal; -} - -h3 { - clear: both; - margin: 15px 0 0 0; - font-size: 1.0em; - font-weight: bold; -} - -p { - line-height: 20px; - padding: 8px 0 8px 0; - margin: 0; - font-size: 1.1em; -} - -pre { - white-space: pre-wrap; - background-color: #CCC; - padding: 3px; -} - -a:hover { - background-color: #DDD; -} - -#middlebox { - width: 600px; - margin: 0px auto; - text-align: left; -} - -#footer { - height: 100px; - padding: 28px 3px 0 0; - margin: 20px 0 20px 0; -} diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/README.md b/arduino/opencr_arduino/tools/win/src/maple_loader/README.md deleted file mode 100755 index c6c937950..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/README.md +++ /dev/null @@ -1,5 +0,0 @@ -These files build the maple_loader.jar file used on Windows to reset the Sketch via USB Serial, so that the bootloader will run in dfu upload mode, ready for a new sketch to be uploaded - -The files were written by @bobC (github) and have been slightly modified by me (Roger Clark), so that dfu-util no longer attempts to reset the board after upload. -This change to dfu-util's reset command line argument, was required because dfu-util was showing errors on some Windows systems, because the bootloader had reset its self after upload, -before dfu-util had chance to tell it to reset. \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build.xml b/arduino/opencr_arduino/tools/win/src/maple_loader/build.xml deleted file mode 100755 index 80bdd6fdb..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/build.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - Builds, tests, and runs the project maple_loader. - - - diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/built-jar.properties b/arduino/opencr_arduino/tools/win/src/maple_loader/build/built-jar.properties deleted file mode 100755 index 10752d534..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/build/built-jar.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Mon, 20 Jul 2015 11:21:26 +1000 - - -C\:\\Users\\rclark\\Desktop\\maple-asp-master\\installer\\maple_loader= diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/CliTemplate/CliMain.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/CliTemplate/CliMain.class deleted file mode 100755 index 37ee63000..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/CliTemplate/CliMain.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/CliTemplate/DFUUploader.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/CliTemplate/DFUUploader.class deleted file mode 100755 index 77087b052..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/CliTemplate/DFUUploader.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/CliTemplate/ExecCommand.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/CliTemplate/ExecCommand.class deleted file mode 100755 index ad95f7984..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/CliTemplate/ExecCommand.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/Base.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/Base.class deleted file mode 100755 index 4aa0bde02..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/Base.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/Preferences.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/Preferences.class deleted file mode 100755 index 89cf01004..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/Preferences.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/Serial.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/Serial.class deleted file mode 100755 index cceccdd27..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/Serial.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/SerialException.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/SerialException.class deleted file mode 100755 index 71048dd3a..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/SerialException.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class deleted file mode 100755 index 37250e770..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/debug/MessageConsumer.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class deleted file mode 100755 index e22c8d499..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/debug/MessageSiphon.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/debug/RunnerException.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/debug/RunnerException.class deleted file mode 100755 index 710f79650..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/debug/RunnerException.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class b/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class deleted file mode 100755 index 27eca6262..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/build/classes/processing/app/helpers/ProcessUtils.class and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/dist/README.TXT b/arduino/opencr_arduino/tools/win/src/maple_loader/dist/README.TXT deleted file mode 100755 index 255b89c68..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/dist/README.TXT +++ /dev/null @@ -1,32 +0,0 @@ -======================== -BUILD OUTPUT DESCRIPTION -======================== - -When you build an Java application project that has a main class, the IDE -automatically copies all of the JAR -files on the projects classpath to your projects dist/lib folder. The IDE -also adds each of the JAR files to the Class-Path element in the application -JAR files manifest file (MANIFEST.MF). - -To run the project from the command line, go to the dist folder and -type the following: - -java -jar "maple_loader.jar" - -To distribute this project, zip up the dist folder (including the lib folder) -and distribute the ZIP file. - -Notes: - -* If two JAR files on the project classpath have the same name, only the first -JAR file is copied to the lib folder. -* Only JAR files are copied to the lib folder. -If the classpath contains other types of files or folders, these files (folders) -are not copied. -* If a library on the projects classpath also has a Class-Path element -specified in the manifest,the content of the Class-Path element has to be on -the projects runtime path. -* To set a main class in a standard Java project, right-click the project node -in the Projects window and choose Properties. Then click Run and enter the -class name in the Main Class field. Alternatively, you can manually type the -class name in the manifest Main-Class element. diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/dist/lib/jssc.jar b/arduino/opencr_arduino/tools/win/src/maple_loader/dist/lib/jssc.jar deleted file mode 100755 index eb74f154a..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/dist/lib/jssc.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/dist/maple_loader.jar b/arduino/opencr_arduino/tools/win/src/maple_loader/dist/maple_loader.jar deleted file mode 100755 index e1f9965c1..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/dist/maple_loader.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/jars/jssc.jar b/arduino/opencr_arduino/tools/win/src/maple_loader/jars/jssc.jar deleted file mode 100755 index eb74f154a..000000000 Binary files a/arduino/opencr_arduino/tools/win/src/maple_loader/jars/jssc.jar and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/manifest.mf b/arduino/opencr_arduino/tools/win/src/maple_loader/manifest.mf deleted file mode 100755 index 328e8e5bc..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/manifest.mf +++ /dev/null @@ -1,3 +0,0 @@ -Manifest-Version: 1.0 -X-COMMENT: Main-Class will be added automatically by build - diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/build-impl.xml b/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/build-impl.xml deleted file mode 100755 index a66f34964..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/build-impl.xml +++ /dev/null @@ -1,1413 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set src.dir - Must set test.src.dir - Must set build.dir - Must set dist.dir - Must set build.classes.dir - Must set dist.javadoc.dir - Must set build.test.classes.dir - Must set build.test.results.dir - Must set build.classes.excludes - Must set dist.jar - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No tests executed. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must set JVM to use for profiling in profiler.info.jvm - Must set profiler agent JVM arguments in profiler.info.jvmargs.agent - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - To run this application from the command line without Ant, try: - - java -jar "${dist.jar.resolved}" - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - Must select one file in the IDE or set run.class - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set debug.class - - - - - Must select one file in the IDE or set debug.class - - - - - Must set fix.includes - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - Must select one file in the IDE or set profile.class - This target only works when run from inside the NetBeans IDE. - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - This target only works when run from inside the NetBeans IDE. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select one file in the IDE or set run.class - - - - - - Must select some files in the IDE or set test.includes - - - - - Must select one file in the IDE or set run.class - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Must select some files in the IDE or set javac.includes - - - - - - - - - - - - - - - - - - - - Some tests failed; see details above. - - - - - - - - - Must select some files in the IDE or set test.includes - - - - Some tests failed; see details above. - - - - Must select some files in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - Some tests failed; see details above. - - - - - Must select one file in the IDE or set test.class - - - - Must select one file in the IDE or set test.class - Must select some method in the IDE or set test.method - - - - - - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - Must select one file in the IDE or set applet.url - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/genfiles.properties b/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/genfiles.properties deleted file mode 100755 index c13672132..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/genfiles.properties +++ /dev/null @@ -1,8 +0,0 @@ -build.xml.data.CRC32=2e6a03ba -build.xml.script.CRC32=4676ee6b -build.xml.stylesheet.CRC32=8064a381@1.75.2.48 -# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. -# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. -nbproject/build-impl.xml.data.CRC32=2e6a03ba -nbproject/build-impl.xml.script.CRC32=392b3f79 -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/private/config.properties b/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/private/config.properties deleted file mode 100755 index e69de29bb..000000000 diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/private/private.properties b/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/private/private.properties deleted file mode 100755 index e5c9f10c4..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/private/private.properties +++ /dev/null @@ -1,6 +0,0 @@ -compile.on.save=true -do.depend=false -do.jar=true -javac.debug=true -javadoc.preview=true -user.properties.file=C:\\Users\\rclark\\AppData\\Roaming\\NetBeans\\8.0.2\\build.properties diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/private/private.xml b/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/private/private.xml deleted file mode 100755 index a1bbd60c9..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/private/private.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - file:/C:/Users/rclark/Desktop/maple-asp-master/installer/maple_loader/src/CliTemplate/CliMain.java - file:/C:/Users/rclark/Desktop/maple-asp-master/installer/maple_loader/src/CliTemplate/DFUUploader.java - - - diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/project.properties b/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/project.properties deleted file mode 100755 index 7f48d719f..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/project.properties +++ /dev/null @@ -1,79 +0,0 @@ -annotation.processing.enabled=true -annotation.processing.enabled.in.editor=false -annotation.processing.processors.list= -annotation.processing.run.all.processors=true -annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output -application.title=maple_loader -application.vendor=bob -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -build.generated.dir=${build.dir}/generated -build.generated.sources.dir=${build.dir}/generated-sources -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -# Uncomment to specify the preferred debugger connection transport: -#debug.transport=dt_socket -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# Files in build.classes.dir which should be excluded from distribution jar -dist.archive.excludes= -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/maple_loader.jar -dist.javadoc.dir=${dist.dir}/javadoc -endorsed.classpath= -excludes= -file.reference.jssc.jar=dist/lib/jssc.jar -file.reference.jssc.jar-1=jars/jssc.jar -includes=** -jar.compress=false -javac.classpath=\ - ${file.reference.jssc.jar}:\ - ${file.reference.jssc.jar-1} -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.processorpath=\ - ${javac.classpath} -javac.source=1.7 -javac.target=1.7 -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -javac.test.processorpath=\ - ${javac.test.classpath} -javadoc.additionalparam= -javadoc.author=false -javadoc.encoding=${source.encoding} -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle= -main.class=CliTemplate.CliMain -manifest.file=manifest.mf -meta.inf.dir=${src.dir}/META-INF -mkdist.disabled=false -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project. -# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. -# To set system properties for unit tests define test-sys-prop.name=value: -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -source.encoding=UTF-8 -src.dir=src -test.src.dir=test diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/project.xml b/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/project.xml deleted file mode 100755 index 92218a925..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/nbproject/project.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - org.netbeans.modules.java.j2seproject - - - maple_loader - - - - - - - - - diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/CliTemplate/CliMain.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/CliTemplate/CliMain.java deleted file mode 100755 index c7dc9f098..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/CliTemplate/CliMain.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package CliTemplate; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import processing.app.Preferences; - -//import processing.app.I18n; -import processing.app.helpers.ProcessUtils; - -/** - * - * @author cousinr - */ -public class CliMain { - - - /** - * @param args the command line arguments - */ - public static void main(String[] args) { - - String comPort = args[0]; // - String altIf = args[1]; // - String usbID = args[2]; // "1EAF:0003"; - String binFile = args[3]; // bin file - - System.out.println("maple_loader v0.1"); - - Preferences.set ("serial.port",comPort); - Preferences.set ("serial.parity","N"); - Preferences.setInteger ("serial.databits", 8); - Preferences.setInteger ("serial.debug_rate",9600); - Preferences.setInteger ("serial.stopbits",1); - - Preferences.setInteger ("programDelay",1200); - - Preferences.set ("upload.usbID", usbID); - Preferences.set ("upload.altID", altIf); - Preferences.setBoolean ("upload.auto_reset", true); - Preferences.setBoolean ("upload.verbose", false); - - // - DFUUploader dfuUploader = new DFUUploader(); - try { - //dfuUploader.uploadViaDFU(binFile); - dfuUploader.uploadViaDFU(binFile); - } catch (Exception e) - { - System.err.print (MessageFormat.format("an error occurred! {0}\n", e.getMessage())); - } - } -} diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/CliTemplate/DFUUploader.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/CliTemplate/DFUUploader.java deleted file mode 100755 index 3dee0b4b7..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/CliTemplate/DFUUploader.java +++ /dev/null @@ -1,345 +0,0 @@ -/* - DFUUploader - uploader implementation using DFU - - Copyright (c) 2010 - Andrew Meyer - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*/ - -package CliTemplate; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStreamReader; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import processing.app.Preferences; -import processing.app.Serial; -import processing.app.debug.MessageConsumer; -import processing.app.debug.MessageSiphon; -import processing.app.debug.RunnerException; - -/** - * - * @author bob - */ -public class DFUUploader implements MessageConsumer { - - boolean firstErrorFound; - boolean secondErrorFound; - // part of the PdeMessageConsumer interface - boolean notFoundError; - boolean verbose; - RunnerException exception; - - static final String SUPER_BADNESS = - "Compiler error!"; - - public boolean uploadUsingPreferences(String binPath, boolean verbose) - throws RunnerException { - - this.verbose = verbose; - - return uploadViaDFU(binPath); - } - - // works with old and new versions of dfu-util - private boolean found_device (String dfuData, String usbID) - { - return dfuData.contains(("Found DFU: [0x"+usbID.substring(0,4)).toUpperCase()) || - dfuData.contains(("Found DFU: ["+usbID.substring(0,4)).toUpperCase()); - } - - public boolean uploadViaDFU (String binPath) - throws RunnerException { - - this.verbose = Preferences.getBoolean ("upload.verbose"); - - /* todo, check for size overruns! */ - String fileType="bin"; - - if (fileType.equals("bin")) { - String usbID = Preferences.get("upload.usbID"); - if (usbID == null) { - /* fall back on default */ - /* this isnt great because is default Avrdude or dfu-util? */ - usbID = Preferences.get("upload.usbID"); - } - - /* if auto-reset, then emit the reset pulse on dtr/rts */ - if (Preferences.get("upload.auto_reset") != null) { - if (Preferences.get("upload.auto_reset").toLowerCase().equals("true")) { - System.out.println("Resetting to bootloader via DTR pulse"); - emitResetPulse(); - } - } else { - System.out.println("Resetting to bootloader via DTR pulse"); - emitResetPulse(); - } - - String dfuList = new String(); - List commandCheck = new ArrayList(); - commandCheck.add("dfu-util"); - commandCheck.add("-l"); - long startChecking = System.currentTimeMillis(); - System.out.println("Searching for DFU device [" + usbID + "]..."); - do { - try { - Thread.sleep(100); - } catch (InterruptedException e) {} - dfuList = executeCheckCommand(commandCheck); - //System.out.println(dfuList); - } - while ( !found_device (dfuList.toUpperCase(), usbID) && (System.currentTimeMillis() - startChecking < 7000)); - - if ( !found_device (dfuList.toUpperCase(), usbID) ) - { - System.out.println(dfuList); - System.err.println("Couldn't find the DFU device: [" + usbID + "]"); - return false; - } - System.out.println("Found it!"); - - /* todo, add handle to let user choose altIf at upload time! */ - String altIf = Preferences.get("upload.altID"); - - List commandDownloader = new ArrayList(); - commandDownloader.add("dfu-util"); - commandDownloader.add("-a "+altIf); - commandDownloader.add("-R"); - commandDownloader.add("-d "+usbID); - commandDownloader.add("-D"+ binPath); //"./thisbin.bin"); - - return executeUploadCommand(commandDownloader); - } - - System.err.println("Only .bin files are supported at this time"); - return false; - } - - /* we need to ensure both RTS and DTR are low to start, - then pulse DTR on its own. This is the reset signal - maple responds to - */ - private void emitResetPulse() throws RunnerException { - - /* wait a while for the device to reboot */ - int programDelay = Preferences.getInteger("programDelay"); - - try { - Serial serialPort = new Serial(); - - // try to toggle DTR/RTS (old scheme) - serialPort.setRTS(false); - serialPort.setDTR(false); - serialPort.setDTR(true); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.setDTR(false); - - // try magic number - serialPort.setRTS(true); - serialPort.setDTR(true); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.setDTR(false); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.write("1EAF"); - try { - Thread.sleep(50); - } catch (InterruptedException e) {} - serialPort.dispose(); - - } catch(Exception e) { - System.err.println("Reset via USB Serial Failed! Did you select the right serial port?\nAssuming the board is in perpetual bootloader mode and continuing to attempt dfu programming...\n"); - } - } - - protected String executeCheckCommand(Collection commandDownloader) - throws RunnerException - { - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - notFoundError = false; - int result=0; // pre-initialized to quiet a bogus warning from jikes - - String userdir = System.getProperty("user.dir") + File.separator; - String returnStr = new String(); - - try { - String[] commandArray = new String[commandDownloader.size()]; - commandDownloader.toArray(commandArray); - - String armBasePath; - - //armBasePath = new String(Base.getHardwarePath() + "/tools/arm/bin/"); - armBasePath = ""; - - commandArray[0] = armBasePath + commandArray[0]; - - if (verbose || Preferences.getBoolean("upload.verbose")) { - for(int i = 0; i < commandArray.length; i++) { - System.out.print(commandArray[i] + " "); - } - System.out.println(); - } - - Process process = Runtime.getRuntime().exec(commandArray); - BufferedReader stdInput = new BufferedReader(new - InputStreamReader(process.getInputStream())); - BufferedReader stdError = new BufferedReader(new - InputStreamReader(process.getErrorStream())); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - // - boolean busy = true; - while (busy) { - try { - result = process.waitFor(); - busy = false; - } catch (InterruptedException intExc) { - } - } - - String s; - while ((s = stdInput.readLine()) != null) { - returnStr += s + "\n"; - } - - process.destroy(); - - if(exception!=null) { - exception.hideStackTrace(); - throw exception; - } - if(result!=0) return "Error!"; - } catch (Exception e) { - e.printStackTrace(); - } - //System.out.println("result2 is "+result); - // if the result isn't a known, expected value it means that something - // is fairly wrong, one possibility is that jikes has crashed. - // - if (exception != null) throw exception; - - if ((result != 0) && (result != 1 )) { - exception = new RunnerException(SUPER_BADNESS); - } - - return returnStr; // ? true : false; - - } - - // Need to overload this from Uploader to use the system-wide dfu-util - protected boolean executeUploadCommand(Collection commandDownloader) - throws RunnerException - { - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - notFoundError = false; - int result=0; // pre-initialized to quiet a bogus warning from jikes - - String userdir = System.getProperty("user.dir") + File.separator; - - try { - String[] commandArray = new String[commandDownloader.size()]; - commandDownloader.toArray(commandArray); - - String armBasePath; - - //armBasePath = new String(Base.getHardwarePath() + "/tools/arm/bin/"); - armBasePath = ""; - - commandArray[0] = armBasePath + commandArray[0]; - - if (verbose || Preferences.getBoolean("upload.verbose")) { - for(int i = 0; i < commandArray.length; i++) { - System.out.print(commandArray[i] + " "); - } - System.out.println(); - } - - Process process = Runtime.getRuntime().exec(commandArray); - new MessageSiphon(process.getInputStream(), this); - new MessageSiphon(process.getErrorStream(), this); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - // - boolean compiling = true; - while (compiling) { - try { - result = process.waitFor(); - compiling = false; - } catch (InterruptedException intExc) { - } - } - if(exception!=null) { - exception.hideStackTrace(); - throw exception; - } - if(result!=0) - return false; - } catch (Exception e) { - e.printStackTrace(); - } - //System.out.println("result2 is "+result); - // if the result isn't a known, expected value it means that something - // is fairly wrong, one possibility is that jikes has crashed. - // - if (exception != null) throw exception; - - if ((result != 0) && (result != 1 )) { - exception = new RunnerException(SUPER_BADNESS); - //editor.error(exception); - //PdeBase.openURL(BUGS_URL); - //throw new PdeException(SUPER_BADNESS); - } - - return (result == 0); // ? true : false; - - } - - // deal with messages from dfu-util... - public void message(String s) { - - if(s.indexOf("dfu-util - (C) ") != -1) { return; } - if(s.indexOf("This program is Free Software and has ABSOLUTELY NO WARRANTY") != -1) { return; } - - if(s.indexOf("No DFU capable USB device found") != -1) { - System.err.print(s); - exception = new RunnerException("Problem uploading via dfu-util: No Maple found"); - return; - } - - if(s.indexOf("Operation not perimitted") != -1) { - System.err.print(s); - exception = new RunnerException("Problem uploading via dfu-util: Insufficient privilages"); - return; - } - - // else just print everything... - System.out.print(s); - } - -} diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/CliTemplate/ExecCommand.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/CliTemplate/ExecCommand.java deleted file mode 100755 index 3d6c106b7..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/CliTemplate/ExecCommand.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ -package CliTemplate; - -import java.io.IOException; -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.List; - -import processing.app.debug.MessageConsumer; -import processing.app.debug.MessageSiphon; -import processing.app.debug.RunnerException; -import processing.app.helpers.ProcessUtils; - -/** - * - * @author cousinr - */ -public class ExecCommand implements MessageConsumer { - - private boolean verbose = true; - private boolean firstErrorFound; - private boolean secondErrorFound; - private RunnerException exception; - - /** - * Either succeeds or throws a RunnerException fit for public consumption. - * - * @param command - * @throws RunnerException - */ - public void execAsynchronously(String[] command) throws RunnerException { - - // eliminate any empty array entries - List stringList = new ArrayList<>(); - for (String string : command) { - string = string.trim(); - if (string.length() != 0) - stringList.add(string); - } - command = stringList.toArray(new String[stringList.size()]); - if (command.length == 0) - return; - int result = 0; - - if (verbose) { - for (String c : command) - System.out.print(c + " "); - System.out.println(); - } - - firstErrorFound = false; // haven't found any errors yet - secondErrorFound = false; - - Process process; - try { - process = ProcessUtils.exec(command); - } catch (IOException e) { - RunnerException re = new RunnerException(e.getMessage()); - re.hideStackTrace(); - throw re; - } - - MessageSiphon in = new MessageSiphon(process.getInputStream(), this); - MessageSiphon err = new MessageSiphon(process.getErrorStream(), this); - - // wait for the process to finish. if interrupted - // before waitFor returns, continue waiting - boolean compiling = true; - while (compiling) { - try { - in.join(); - err.join(); - result = process.waitFor(); - //System.out.println("result is " + result); - compiling = false; - } catch (InterruptedException ignored) { } - } - - // an error was queued up by message(), barf this back to compile(), - // which will barf it back to Editor. if you're having trouble - // discerning the imagery, consider how cows regurgitate their food - // to digest it, and the fact that they have five stomaches. - // - //System.out.println("throwing up " + exception); - if (exception != null) - throw exception; - - if (result > 1) { - // a failure in the tool (e.g. unable to locate a sub-executable) - System.err.println(MessageFormat.format("{0} returned {1}", command[0], result)); - } - - if (result != 0) { - RunnerException re = new RunnerException(MessageFormat.format("exit code: {0}", result)); - re.hideStackTrace(); - throw re; - } - } - - /** - * Part of the MessageConsumer interface, this is called - * whenever a piece (usually a line) of error message is spewed - * out from the compiler. The errors are parsed for their contents - * and line number, which is then reported back to Editor. - * @param s - */ - @Override - public void message(String s) { - int i; - - - System.err.print(s); - } - -} diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/Base.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/Base.java deleted file mode 100755 index c3a174dcb..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/Base.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-10 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License version 2 - as published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - - -/** - * The base class for the main processing application. - * Primary role of this class is for platform identification and - * general interaction with the system (launching URLs, loading - * files and images, etc) that comes from that. - */ -public class Base { - - /** - * returns true if running on windows. - */ - static public boolean isWindows() { - //return PApplet.platform == PConstants.WINDOWS; - return System.getProperty("os.name").indexOf("Windows") != -1; - } - - - /** - * true if running on linux. - */ - static public boolean isLinux() { - //return PApplet.platform == PConstants.LINUX; - return System.getProperty("os.name").indexOf("Linux") != -1; - } - - - -} diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/Preferences.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/Preferences.java deleted file mode 100755 index 6368e38af..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/Preferences.java +++ /dev/null @@ -1,157 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-09 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - -import java.io.*; -import java.util.*; - - -/** - * Storage class for user preferences and environment settings. - *

- * This class no longer uses the Properties class, since - * properties files are iso8859-1, which is highly likely to - * be a problem when trying to save sketch folders and locations. - *

- * The GUI portion in here is really ugly, as it uses exact layout. This was - * done in frustration one evening (and pre-Swing), but that's long since past, - * and it should all be moved to a proper swing layout like BoxLayout. - *

- * This is very poorly put together, that the preferences panel and the actual - * preferences i/o is part of the same code. But there hasn't yet been a - * compelling reason to bother with the separation aside from concern about - * being lectured by strangers who feel that it doesn't look like what they - * learned in CS class. - *

- * Would also be possible to change this to use the Java Preferences API. - * Some useful articles - * here and - * here. - * However, haven't implemented this yet for lack of time, but more - * importantly, because it would entail writing to the registry (on Windows), - * or an obscure file location (on Mac OS X) and make it far more difficult to - * find the preferences to tweak them by hand (no! stay out of regedit!) - * or to reset the preferences by simply deleting the preferences.txt file. - */ -public class Preferences { - - // what to call the feller - - static final String PREFS_FILE = "preferences.txt"; - - - // prompt text stuff - - static final String PROMPT_YES = "Yes"; - static final String PROMPT_NO = "No"; - static final String PROMPT_CANCEL = "Cancel"; - static final String PROMPT_OK = "OK"; - static final String PROMPT_BROWSE = "Browse"; - - /** - * Standardized width for buttons. Mac OS X 10.3 wants 70 as its default, - * Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper. - */ - static public int BUTTON_WIDTH = 80; - - /** - * Standardized button height. Mac OS X 10.3 (Java 1.4) wants 29, - * presumably because it now includes the blue border, where it didn't - * in Java 1.3. Windows XP only wants 23 (not sure what default Linux - * would be). Because of the disparity, on Mac OS X, it will be set - * inside a static block. - */ - static public int BUTTON_HEIGHT = 24; - - // value for the size bars, buttons, etc - - static final int GRID_SIZE = 33; - - - // indents and spacing standards. these probably need to be modified - // per platform as well, since macosx is so huge, windows is smaller, - // and linux is all over the map - - static final int GUI_BIG = 13; - static final int GUI_BETWEEN = 10; - static final int GUI_SMALL = 6; - - - - // data model - - static Hashtable table = new Hashtable();; - static File preferencesFile; - - - static protected void init(String commandLinePrefs) { - - - } - - - public Preferences() { - - } - - // ................................................................. - - // ................................................................. - - // ................................................................. - - // ................................................................. - - - - static public String get(String attribute) { - return (String) table.get(attribute); - } - - static public void set(String attribute, String value) { - table.put(attribute, value); - } - - - static public boolean getBoolean(String attribute) { - String value = get(attribute); - return (new Boolean(value)).booleanValue(); - } - - - static public void setBoolean(String attribute, boolean value) { - set(attribute, value ? "true" : "false"); - } - - - static public int getInteger(String attribute) { - return Integer.parseInt(get(attribute)); - } - - - static public void setInteger(String key, int value) { - set(key, String.valueOf(value)); - } - -} diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/Serial.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/Serial.java deleted file mode 100755 index 04566a738..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/Serial.java +++ /dev/null @@ -1,527 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - PSerial - class for serial port goodness - Part of the Processing project - http://processing.org - - Copyright (c) 2004 Ben Fry & Casey Reas - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General - Public License along with this library; if not, write to the - Free Software Foundation, Inc., 59 Temple Place, Suite 330, - Boston, MA 02111-1307 USA -*/ - -package processing.app; -//import processing.core.*; - - -import java.io.*; -import java.text.MessageFormat; -import java.util.*; -import jssc.SerialPort; -import jssc.SerialPortEvent; -import jssc.SerialPortEventListener; -import jssc.SerialPortException; -import jssc.SerialPortList; -import processing.app.debug.MessageConsumer; - - -public class Serial implements SerialPortEventListener { - - //PApplet parent; - - // properties can be passed in for default values - // otherwise defaults to 9600 N81 - - // these could be made static, which might be a solution - // for the classloading problem.. because if code ran again, - // the static class would have an object that could be closed - - SerialPort port; - - int rate; - int parity; - int databits; - int stopbits; - boolean monitor = false; - - // read buffer and streams - - InputStream input; - OutputStream output; - - byte buffer[] = new byte[32768]; - int bufferIndex; - int bufferLast; - - MessageConsumer consumer; - - public Serial(boolean monitor) throws SerialException { - this(Preferences.get("serial.port"), - Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - this.monitor = monitor; - } - - public Serial() throws SerialException { - this(Preferences.get("serial.port"), - Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(int irate) throws SerialException { - this(Preferences.get("serial.port"), irate, - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname, int irate) throws SerialException { - this(iname, irate, Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname) throws SerialException { - this(iname, Preferences.getInteger("serial.debug_rate"), - Preferences.get("serial.parity").charAt(0), - Preferences.getInteger("serial.databits"), - new Float(Preferences.get("serial.stopbits")).floatValue()); - } - - public Serial(String iname, int irate, - char iparity, int idatabits, float istopbits) - throws SerialException { - //if (port != null) port.close(); - //this.parent = parent; - //parent.attach(this); - - this.rate = irate; - - parity = SerialPort.PARITY_NONE; - if (iparity == 'E') parity = SerialPort.PARITY_EVEN; - if (iparity == 'O') parity = SerialPort.PARITY_ODD; - - this.databits = idatabits; - - stopbits = SerialPort.STOPBITS_1; - if (istopbits == 1.5f) stopbits = SerialPort.STOPBITS_1_5; - if (istopbits == 2) stopbits = SerialPort.STOPBITS_2; - - try { - port = new SerialPort(iname); - port.openPort(); - port.setParams(rate, databits, stopbits, parity, true, true); - port.addEventListener(this); - } catch (Exception e) { - throw new SerialException(MessageFormat.format("Error opening serial port ''{0}''.", iname), e); - } - - if (port == null) { - throw new SerialException("Serial port '" + iname + "' not found. Did you select the right one from the Tools > Serial Port menu?"); - } - } - - - public void setup() { - //parent.registerCall(this, DISPOSE); - } - - public void dispose() throws IOException { - if (port != null) { - try { - if (port.isOpened()) { - port.closePort(); // close the port - } - } catch (SerialPortException e) { - throw new IOException(e); - } finally { - port = null; - } - } - } - - public void addListener(MessageConsumer consumer) { - this.consumer = consumer; - } - - public synchronized void serialEvent(SerialPortEvent serialEvent) { - if (serialEvent.isRXCHAR()) { - try { - byte[] buf = port.readBytes(serialEvent.getEventValue()); - if (buf.length > 0) { - if (bufferLast == buffer.length) { - byte temp[] = new byte[bufferLast << 1]; - System.arraycopy(buffer, 0, temp, 0, bufferLast); - buffer = temp; - } - if (monitor) { - System.out.print(new String(buf)); - } - if (this.consumer != null) { - this.consumer.message(new String(buf)); - } - } - } catch (SerialPortException e) { - errorMessage("serialEvent", e); - } - } - } - - - /** - * Returns the number of bytes that have been read from serial - * and are waiting to be dealt with by the user. - */ - public synchronized int available() { - return (bufferLast - bufferIndex); - } - - - /** - * Ignore all the bytes read so far and empty the buffer. - */ - public synchronized void clear() { - bufferLast = 0; - bufferIndex = 0; - } - - - /** - * Returns a number between 0 and 255 for the next byte that's - * waiting in the buffer. - * Returns -1 if there was no byte (although the user should - * first check available() to see if things are ready to avoid this) - */ - public synchronized int read() { - if (bufferIndex == bufferLast) return -1; - - int outgoing = buffer[bufferIndex++] & 0xff; - if (bufferIndex == bufferLast) { // rewind - bufferIndex = 0; - bufferLast = 0; - } - return outgoing; - } - - - /** - * Returns the next byte in the buffer as a char. - * Returns -1, or 0xffff, if nothing is there. - */ - public synchronized char readChar() { - if (bufferIndex == bufferLast) return (char)(-1); - return (char) read(); - } - - - /** - * Return a byte array of anything that's in the serial buffer. - * Not particularly memory/speed efficient, because it creates - * a byte array on each read, but it's easier to use than - * readBytes(byte b[]) (see below). - */ - public synchronized byte[] readBytes() { - if (bufferIndex == bufferLast) return null; - - int length = bufferLast - bufferIndex; - byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex = 0; // rewind - bufferLast = 0; - return outgoing; - } - - - /** - * Grab whatever is in the serial buffer, and stuff it into a - * byte buffer passed in by the user. This is more memory/time - * efficient than readBytes() returning a byte[] array. - *

- * Returns an int for how many bytes were read. If more bytes - * are available than can fit into the byte array, only those - * that will fit are read. - */ - public synchronized int readBytes(byte outgoing[]) { - if (bufferIndex == bufferLast) return 0; - - int length = bufferLast - bufferIndex; - if (length > outgoing.length) length = outgoing.length; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex += length; - if (bufferIndex == bufferLast) { - bufferIndex = 0; // rewind - bufferLast = 0; - } - return length; - } - - - /** - * Reads from the serial port into a buffer of bytes up to and - * including a particular character. If the character isn't in - * the serial buffer, then 'null' is returned. - */ - public synchronized byte[] readBytesUntil(int interesting) { - if (bufferIndex == bufferLast) return null; - byte what = (byte)interesting; - - int found = -1; - for (int k = bufferIndex; k < bufferLast; k++) { - if (buffer[k] == what) { - found = k; - break; - } - } - if (found == -1) return null; - - int length = found - bufferIndex + 1; - byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex = 0; // rewind - bufferLast = 0; - return outgoing; - } - - - /** - * Reads from the serial port into a buffer of bytes until a - * particular character. If the character isn't in the serial - * buffer, then 'null' is returned. - *

- * If outgoing[] is not big enough, then -1 is returned, - * and an error message is printed on the console. - * If nothing is in the buffer, zero is returned. - * If 'interesting' byte is not in the buffer, then 0 is returned. - */ - public synchronized int readBytesUntil(int interesting, byte outgoing[]) { - if (bufferIndex == bufferLast) return 0; - byte what = (byte)interesting; - - int found = -1; - for (int k = bufferIndex; k < bufferLast; k++) { - if (buffer[k] == what) { - found = k; - break; - } - } - if (found == -1) return 0; - - int length = found - bufferIndex + 1; - if (length > outgoing.length) { - System.err.println("readBytesUntil() byte buffer is" + - " too small for the " + length + - " bytes up to and including char " + interesting); - return -1; - } - //byte outgoing[] = new byte[length]; - System.arraycopy(buffer, bufferIndex, outgoing, 0, length); - - bufferIndex += length; - if (bufferIndex == bufferLast) { - bufferIndex = 0; // rewind - bufferLast = 0; - } - return length; - } - - - /** - * Return whatever has been read from the serial port so far - * as a String. It assumes that the incoming characters are ASCII. - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public synchronized String readString() { - if (bufferIndex == bufferLast) return null; - return new String(readBytes()); - } - - - /** - * Combination of readBytesUntil and readString. See caveats in - * each function. Returns null if it still hasn't found what - * you're looking for. - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public synchronized String readStringUntil(int interesting) { - byte b[] = readBytesUntil(interesting); - if (b == null) return null; - return new String(b); - } - - - /** - * This will handle both ints, bytes and chars transparently. - */ - public void write(int what) { // will also cover char - try { - port.writeInt(what & 0xff); - } catch (SerialPortException e) { - errorMessage("write", e); - } - } - - - public void write(byte bytes[]) { - try { - port.writeBytes(bytes); - } catch (SerialPortException e) { - errorMessage("write", e); - } - } - - - /** - * Write a String to the output. Note that this doesn't account - * for Unicode (two bytes per char), nor will it send UTF8 - * characters.. It assumes that you mean to send a byte buffer - * (most often the case for networking and serial i/o) and - * will only use the bottom 8 bits of each char in the string. - * (Meaning that internally it uses String.getBytes) - *

- * If you want to move Unicode data, you can first convert the - * String to a byte stream in the representation of your choice - * (i.e. UTF8 or two-byte Unicode data), and send it as a byte array. - */ - public void write(String what) { - write(what.getBytes()); - } - - public void setDTR(boolean state) { - try { - port.setDTR(state); - } catch (SerialPortException e) { - errorMessage("setDTR", e); - } - } - - public void setRTS(boolean state) { - try { - port.setRTS(state); - } catch (SerialPortException e) { - errorMessage("setRTS", e); - } - } - - static public List list() { - return Arrays.asList(SerialPortList.getPortNames()); - } - - - /** - * General error reporting, all corraled here just in case - * I think of something slightly more intelligent to do. - */ - static public void errorMessage(String where, Throwable e) { - System.err.println("Error inside Serial." + where + "()"); - e.printStackTrace(); - } -} - - - /* - class SerialMenuListener implements ItemListener { - //public SerialMenuListener() { } - - public void itemStateChanged(ItemEvent e) { - int count = serialMenu.getItemCount(); - for (int i = 0; i < count; i++) { - ((CheckboxMenuItem)serialMenu.getItem(i)).setState(false); - } - CheckboxMenuItem item = (CheckboxMenuItem)e.getSource(); - item.setState(true); - String name = item.getLabel(); - //System.out.println(item.getLabel()); - PdeBase.properties.put("serial.port", name); - //System.out.println("set to " + get("serial.port")); - } - } - */ - - - /* - protected Vector buildPortList() { - // get list of names for serial ports - // have the default port checked (if present) - Vector list = new Vector(); - - //SerialMenuListener listener = new SerialMenuListener(); - boolean problem = false; - - // if this is failing, it may be because - // lib/javax.comm.properties is missing. - // java is weird about how it searches for java.comm.properties - // so it tends to be very fragile. i.e. quotes in the CLASSPATH - // environment variable will hose things. - try { - //System.out.println("building port list"); - Enumeration portList = CommPortIdentifier.getPortIdentifiers(); - while (portList.hasMoreElements()) { - CommPortIdentifier portId = - (CommPortIdentifier) portList.nextElement(); - //System.out.println(portId); - - if (portId.getPortType() == CommPortIdentifier.PORT_SERIAL) { - //if (portId.getName().equals(port)) { - String name = portId.getName(); - //CheckboxMenuItem mi = - //new CheckboxMenuItem(name, name.equals(defaultName)); - - //mi.addItemListener(listener); - //serialMenu.add(mi); - list.addElement(name); - } - } - } catch (UnsatisfiedLinkError e) { - e.printStackTrace(); - problem = true; - - } catch (Exception e) { - System.out.println("exception building serial menu"); - e.printStackTrace(); - } - - //if (serialMenu.getItemCount() == 0) { - //System.out.println("dimming serial menu"); - //serialMenu.setEnabled(false); - //} - - // only warn them if this is the first time - if (problem && PdeBase.firstTime) { - JOptionPane.showMessageDialog(this, //frame, - "Serial port support not installed.\n" + - "Check the readme for instructions\n" + - "if you need to use the serial port. ", - "Serial Port Warning", - JOptionPane.WARNING_MESSAGE); - } - return list; - } - */ - - - diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/SerialException.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/SerialException.java deleted file mode 100755 index 525c24078..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/SerialException.java +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- mode: jde; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Copyright (c) 2007 David A. Mellis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app; - -public class SerialException extends Exception { - public SerialException() { - super(); - } - - public SerialException(String message) { - super(message); - } - - public SerialException(String message, Throwable cause) { - super(message, cause); - } - - public SerialException(Throwable cause) { - super(cause); - } -} diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/debug/MessageConsumer.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/debug/MessageConsumer.java deleted file mode 100755 index 5e2042943..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/debug/MessageConsumer.java +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-06 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - - -/** - * Interface for dealing with parser/compiler output. - *

- * Different instances of MessageStream need to do different things with - * messages. In particular, a stream instance used for parsing output from - * the compiler compiler has to interpret its messages differently than one - * parsing output from the runtime. - *

- * Classes which consume messages and do something with them - * should implement this interface. - */ -public interface MessageConsumer { - - public void message(String s); - -} diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/debug/MessageSiphon.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/debug/MessageSiphon.java deleted file mode 100755 index 26901c3f4..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/debug/MessageSiphon.java +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-06 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.SocketException; - -/** - * Slurps up messages from compiler. - */ -public class MessageSiphon implements Runnable { - - private final BufferedReader streamReader; - private final MessageConsumer consumer; - - private Thread thread; - private boolean canRun; - - public MessageSiphon(InputStream stream, MessageConsumer consumer) { - this.streamReader = new BufferedReader(new InputStreamReader(stream)); - this.consumer = consumer; - this.canRun = true; - - thread = new Thread(this); - // don't set priority too low, otherwise exceptions won't - // bubble up in time (i.e. compile errors have a weird delay) - //thread.setPriority(Thread.MIN_PRIORITY); - thread.setPriority(Thread.MAX_PRIORITY - 1); - thread.start(); - } - - - public void run() { - try { - // process data until we hit EOF; this will happily block - // (effectively sleeping the thread) until new data comes in. - // when the program is finally done, null will come through. - // - String currentLine; - while (canRun && (currentLine = streamReader.readLine()) != null) { - // \n is added again because readLine() strips it out - //EditorConsole.systemOut.println("messaging in"); - consumer.message(currentLine + "\n"); - //EditorConsole.systemOut.println("messaging out"); - } - //EditorConsole.systemOut.println("messaging thread done"); - } catch (NullPointerException npe) { - // Fairly common exception during shutdown - } catch (SocketException e) { - // socket has been close while we were wainting for data. nothing to see here, move along - } catch (Exception e) { - // On Linux and sometimes on Mac OS X, a "bad file descriptor" - // message comes up when closing an applet that's run externally. - // That message just gets supressed here.. - String mess = e.getMessage(); - if ((mess != null) && - (mess.indexOf("Bad file descriptor") != -1)) { - //if (e.getMessage().indexOf("Bad file descriptor") == -1) { - //System.err.println("MessageSiphon err " + e); - //e.printStackTrace(); - } else { - e.printStackTrace(); - } - } finally { - thread = null; - } - } - - // Wait until the MessageSiphon thread is complete. - public void join() throws java.lang.InterruptedException { - // Grab a temp copy in case another thread nulls the "thread" - // member variable - Thread t = thread; - if (t != null) t.join(); - } - - public void stop() { - this.canRun = false; - } - -} diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/debug/RunnerException.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/debug/RunnerException.java deleted file mode 100755 index 0a67d1e80..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/debug/RunnerException.java +++ /dev/null @@ -1,161 +0,0 @@ -/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */ - -/* - Part of the Processing project - http://processing.org - - Copyright (c) 2004-08 Ben Fry and Casey Reas - Copyright (c) 2001-04 Massachusetts Institute of Technology - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -*/ - -package processing.app.debug; - - -/** - * An exception with a line number attached that occurs - * during either compile time or run time. - */ -@SuppressWarnings("serial") -public class RunnerException extends Exception { - protected String message; - protected int codeIndex; - protected int codeLine; - protected int codeColumn; - protected boolean showStackTrace; - - - public RunnerException(String message) { - this(message, true); - } - - public RunnerException(String message, boolean showStackTrace) { - this(message, -1, -1, -1, showStackTrace); - } - - public RunnerException(String message, int file, int line) { - this(message, file, line, -1, true); - } - - - public RunnerException(String message, int file, int line, int column) { - this(message, file, line, column, true); - } - - - public RunnerException(String message, int file, int line, int column, - boolean showStackTrace) { - this.message = message; - this.codeIndex = file; - this.codeLine = line; - this.codeColumn = column; - this.showStackTrace = showStackTrace; - } - - - public RunnerException(Exception e) { - super(e); - this.showStackTrace = true; - } - - /** - * Override getMessage() in Throwable, so that I can set - * the message text outside the constructor. - */ - public String getMessage() { - return message; - } - - - public void setMessage(String message) { - this.message = message; - } - - - public int getCodeIndex() { - return codeIndex; - } - - - public void setCodeIndex(int index) { - codeIndex = index; - } - - - public boolean hasCodeIndex() { - return codeIndex != -1; - } - - - public int getCodeLine() { - return codeLine; - } - - - public void setCodeLine(int line) { - this.codeLine = line; - } - - - public boolean hasCodeLine() { - return codeLine != -1; - } - - - public void setCodeColumn(int column) { - this.codeColumn = column; - } - - - public int getCodeColumn() { - return codeColumn; - } - - - public void showStackTrace() { - showStackTrace = true; - } - - - public void hideStackTrace() { - showStackTrace = false; - } - - - /** - * Nix the java.lang crap out of an exception message - * because it scares the children. - *

- * This function must be static to be used with super() - * in each of the constructors above. - */ - /* - static public final String massage(String msg) { - if (msg.indexOf("java.lang.") == 0) { - //int dot = msg.lastIndexOf('.'); - msg = msg.substring("java.lang.".length()); - } - return msg; - //return (dot == -1) ? msg : msg.substring(dot+1); - } - */ - - - public void printStackTrace() { - if (showStackTrace) { - super.printStackTrace(); - } - } -} diff --git a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/helpers/ProcessUtils.java b/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/helpers/ProcessUtils.java deleted file mode 100755 index c023f5810..000000000 --- a/arduino/opencr_arduino/tools/win/src/maple_loader/src/processing/app/helpers/ProcessUtils.java +++ /dev/null @@ -1,32 +0,0 @@ -package processing.app.helpers; - -//import processing.app.Base; - -import java.io.IOException; -import java.util.Map; - -import processing.app.Base; - -public class ProcessUtils { - - public static Process exec(String[] command) throws IOException { - // No problems on linux and mac - if (!Base.isWindows()) { - return Runtime.getRuntime().exec(command); - } - - // Brutal hack to workaround windows command line parsing. - // http://stackoverflow.com/questions/5969724/java-runtime-exec-fails-to-escape-characters-properly - // http://msdn.microsoft.com/en-us/library/a1y7w461.aspx - // http://bugs.sun.com/view_bug.do?bug_id=6468220 - // http://bugs.sun.com/view_bug.do?bug_id=6518827 - String[] cmdLine = new String[command.length]; - for (int i = 0; i < command.length; i++) - cmdLine[i] = command[i].replace("\"", "\\\""); - - ProcessBuilder pb = new ProcessBuilder(cmdLine); - Map env = pb.environment(); - env.put("CYGWIN", "nodosfilewarning"); - return pb.start(); - } -} diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/AUTHORS b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/AUTHORS deleted file mode 100755 index d096f2205..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/AUTHORS +++ /dev/null @@ -1,19 +0,0 @@ -Authors ordered by first contribution. - -Geoffrey McRae -Bret Olmsted -Tormod Volden -Jakob Malm -Reuben Dowle -Matthias Kubisch -Paul Fertser -Daniel Strnad -Jérémie Rapin -Christian Pointner -Mats Erik Andersson -Alexey Borovik -Antonio Borneo -Armin van der Togt -Brian Silverman -Georg Hofmann -Luis Rodrigues diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/Android.mk b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/Android.mk deleted file mode 100755 index 7be3d0018..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/Android.mk +++ /dev/null @@ -1,20 +0,0 @@ -TOP_LOCAL_PATH := $(call my-dir) - -include $(call all-named-subdir-makefiles, parsers) - -LOCAL_PATH := $(TOP_LOCAL_PATH) - -include $(CLEAR_VARS) -LOCAL_MODULE := stm32flash -LOCAL_SRC_FILES := \ - dev_table.c \ - i2c.c \ - init.c \ - main.c \ - port.c \ - serial_common.c \ - serial_platform.c \ - stm32.c \ - utils.c -LOCAL_STATIC_LIBRARIES := libparsers -include $(BUILD_EXECUTABLE) diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/HOWTO b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/HOWTO deleted file mode 100755 index d8f32eb04..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/HOWTO +++ /dev/null @@ -1,35 +0,0 @@ -Add new interfaces: -===================================================================== -Current version 0.4 supports the following interfaces: -- UART Windows (either "COMn" and "\\.\COMn"); -- UART posix/Linux (e.g. "/dev/ttyUSB0"); -- I2C Linux through standard driver "i2c-dev" (e.g. "/dev/i2c-n"). - -Starting from version 0.4, the back-end of stm32flash is modular and -ready to be expanded to support new interfaces. -I'm planning adding SPI on Linux through standard driver "spidev". -You are invited to contribute with more interfaces. - -To add a new interface you need to add a new file, populate the struct -port_interface (check at the end of files i2c.c, serial_posix.c and -serial_w32.c) and provide the relative functions to operate on the -interface: open/close, read/write, get_cfg_str and the optional gpio. -The include the new drive in Makefile and register the new struct -port_interface in file port.c in struct port_interface *ports[]. - -There are several USB-I2C adapter in the market, each providing its -own libraries to communicate with the I2C bus. -Could be interesting to provide as back-end a bridge between stm32flash -and such libraries (I have no plan on this item). - - -Add new STM32 devices: -===================================================================== -Add a new line in file dev_table.c, in table devices[]. -The fields of the table are listed in stm32.h, struct stm32_dev. - - -Cross compile on Linux host for Windows target with MinGW: -===================================================================== -I'm using a 64 bit Arch Linux machines, and I usually run: - make CC=x86_64-w64-mingw32-gcc AR=x86_64-w64-mingw32-ar diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/I2C.txt b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/I2C.txt deleted file mode 100755 index 4c05ff62d..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/I2C.txt +++ /dev/null @@ -1,94 +0,0 @@ -About I2C back-end communication in stm32flash -========================================================================== - -Starting from version v0.4, beside the serial communication port, -stm32flash adds support for I2C port to talk with STM32 bootloader. - -The current I2C back-end supports only the API provided by Linux kernel -driver "i2c-dev", so only I2C controllers with Linux kernel driver can be -used. -In Linux source code, most of the drivers for I2C and SMBUS controllers -are in - ./drivers/i2c/busses/ -Only I2C is supported by STM32 bootloader, so check the section below -about SMBUS. -No I2C support for Windows is available in stm32flash v0.4. - -Thanks to the new modular back-end, stm32flash can be easily extended to -support new back-ends and API. Check HOWTO file in stm32flash source code -for details. - -In the market there are several USB-to-I2C dongles; most of them are not -supported by kernel drivers. Manufacturer provide proprietary userspace -libraries using not standardized API. -These API and dongles could be supported in feature versions. - -There are currently 3 versions of STM32 bootloader for I2C communications: -- v1.0 using I2C clock stretching synchronization between host and STM32; -- v1.1 superset of v1.0, adds non stretching commands; -- v1.2 superset of v1.1, adds CRC command and compatibility with i2cdetect. -Details in ST application note AN2606. -All the bootloaders above are tested and working with stm32flash. - - -SMBUS controllers -========================================================================== - -Almost 50% of the drivers in Linux source code folder - ./drivers/i2c/busses/ -are for controllers that "only" support SMBUS protocol. They can NOT -operate with STM32 bootloader. -To identify if your controller supports I2C, use command: - i2cdetect -F n -where "n" is the number of the I2C interface (e.g. n=3 for "/dev/i2c-3"). -Controllers that supports I2C will report - I2C yes -Controller that support both I2C and SMBUS are ok. - -If you are interested on details about SMBUS protocol, you can download -the current specs from - http://smbus.org/specs/smbus20.pdf -and you can read the files in Linux source code - ./Documentation/i2c/i2c-protocol - ./Documentation/i2c/smbus-protocol - - -About bootloader v1.0 -========================================================================== - -Version v1.0 can have issues with some I2C controllers due to use of clock -stretching during commands that require long operations, like flash erase -and programming. - -Clock stretching is a technique to synchronize host and I2C device. When -I2C device wants to force a delay in the communication, it push "low" the -I2C clock; the I2C controller detects it and waits until I2C clock returns -"high". -Most I2C controllers set a "timeout" for clock stretching, ranging from -few milli-seconds to seconds depending on specific HW or SW driver. - -It is possible that the timeout in your I2C controller is smaller than the -delay required for flash erase or programming. In this case the I2C -controller will timeout and report error to stm32flash. -There is no possibility for stm32flash to retry, so it can only signal the -error and exit. - -To by-pass the issue with bootloader v1.0 you can modify the kernel driver -of your I2C controller. Not an easy job, since every controller has its own -way to handle the timeout. - -In my case I'm using the I2C controller integrated in the VGA port of my -laptop HP EliteBook 8460p. I built the 0.25$ VGA-to-I2C adapter reported in - http://www.paintyourdragon.com/?p=43 -To change the timeout of the I2C controller I had to modify the kernel file - drivers/gpu/drm/radeon/radeon_i2c.c -line 969 -- i2c->bit.timeout = usecs_to_jiffies(2200); /* from VESA */ -+ i2c->bit.timeout = msecs_to_jiffies(5000); /* 5s for STM32 */ -and recompile it. -Then - $> modprobe i2c-dev - $> chmod 666 /dev/i2c-7 - #> stm32flash -a 0x39 /dev/i2c-7 - -2014-09-16 Antonio Borneo diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/Makefile b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/Makefile deleted file mode 100755 index 0328d5588..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/Makefile +++ /dev/null @@ -1,38 +0,0 @@ -PREFIX = /usr/local -CFLAGS += -Wall -g - -INSTALL = install - -OBJS = dev_table.o \ - i2c.o \ - init.o \ - main.o \ - port.o \ - serial_common.o \ - serial_platform.o \ - stm32.o \ - utils.o - -LIBOBJS = parsers/parsers.a - -all: stm32flash - -serial_platform.o: serial_posix.c serial_w32.c - -parsers/parsers.a: - cd parsers && $(MAKE) parsers.a - -stm32flash: $(OBJS) $(LIBOBJS) - $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBOBJS) - -clean: - rm -f $(OBJS) stm32flash - cd parsers && $(MAKE) $@ - -install: all - $(INSTALL) -d $(DESTDIR)$(PREFIX)/bin - $(INSTALL) -m 755 stm32flash $(DESTDIR)$(PREFIX)/bin - $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/man/man1 - $(INSTALL) -m 644 stm32flash.1 $(DESTDIR)$(PREFIX)/share/man/man1 - -.PHONY: all clean install diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/TODO b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/TODO deleted file mode 100755 index 41df614ff..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/TODO +++ /dev/null @@ -1,7 +0,0 @@ - -stm32: -- Add support for variable page size - -AUTHORS: -- Add contributors from Geoffrey's commits - diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/dev_table.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/dev_table.c deleted file mode 100755 index 399cd9d08..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/dev_table.c +++ /dev/null @@ -1,70 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "stm32.h" - -/* - * Device table, corresponds to the "Bootloader device-dependant parameters" - * table in ST document AN2606. - * Note that the option bytes upper range is inclusive! - */ -const stm32_dev_t devices[] = { - /* F0 */ - {0x440, "STM32F051xx" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 4, 1024, 0x1FFFF800, 0x1FFFF80B, 0x1FFFEC00, 0x1FFFF800}, - {0x444, "STM32F030/F031" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 4, 1024, 0x1FFFF800, 0x1FFFF80B, 0x1FFFEC00, 0x1FFFF800}, - {0x445, "STM32F042xx" , 0x20001800, 0x20001800, 0x08000000, 0x08008000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC400, 0x1FFFF800}, - {0x448, "STM32F072xx" , 0x20001800, 0x20004000, 0x08000000, 0x08020000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFC800, 0x1FFFF800}, - /* F1 */ - {0x412, "Low-density" , 0x20000200, 0x20002800, 0x08000000, 0x08008000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x410, "Medium-density" , 0x20000200, 0x20005000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x414, "High-density" , 0x20000200, 0x20010000, 0x08000000, 0x08080000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x420, "Medium-density VL" , 0x20000200, 0x20002000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x428, "High-density VL" , 0x20000200, 0x20008000, 0x08000000, 0x08080000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x418, "Connectivity line" , 0x20001000, 0x20010000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFB000, 0x1FFFF800}, - {0x430, "XL-density" , 0x20000800, 0x20018000, 0x08000000, 0x08100000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFE000, 0x1FFFF800}, - /* Note that F2 and F4 devices have sectors of different page sizes - and only the first sectors (of one page size) are included here */ - /* F2 */ - {0x411, "STM32F2xx" , 0x20002000, 0x20020000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77DF}, - /* F3 */ - {0x432, "STM32F373/8" , 0x20001400, 0x20008000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x422, "F302xB/303xB/358" , 0x20001400, 0x20010000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x439, "STM32F302x4(6/8)" , 0x20001800, 0x20004000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - {0x438, "F303x4/334/328" , 0x20001800, 0x20003000, 0x08000000, 0x08040000, 2, 2048, 0x1FFFF800, 0x1FFFF80F, 0x1FFFD800, 0x1FFFF800}, - /* F4 */ - {0x413, "STM32F40/1" , 0x20002000, 0x20020000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77DF}, - /* 0x419 is also used for STM32F429/39 but with other bootloader ID... */ - {0x419, "STM32F427/37" , 0x20002000, 0x20030000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - {0x423, "STM32F401xB(C)" , 0x20003000, 0x20010000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - {0x433, "STM32F401xD(E)" , 0x20003000, 0x20018000, 0x08000000, 0x08100000, 4, 16384, 0x1FFFC000, 0x1FFFC00F, 0x1FFF0000, 0x1FFF77FF}, - /* L0 */ - {0x417, "L05xxx/06xxx" , 0x20001000, 0x20002000, 0x08000000, 0x08010000, 32, 128, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - /* L1 */ - {0x416, "L1xxx6(8/B)" , 0x20000800, 0x20004000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - {0x429, "L1xxx6(8/B)A" , 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF01000}, - {0x427, "L1xxxC" , 0x20001000, 0x20008000, 0x08000000, 0x08020000, 16, 256, 0x1FF80000, 0x1FF8000F, 0x1FF00000, 0x1FF02000}, - {0x436, "L1xxxD" , 0x20001000, 0x2000C000, 0x08000000, 0x08060000, 16, 256, 0x1ff80000, 0x1ff8000F, 0x1FF00000, 0x1FF02000}, - {0x437, "L1xxxE" , 0x20001000, 0x20014000, 0x08000000, 0x08060000, 16, 256, 0x1ff80000, 0x1ff8000F, 0x1FF00000, 0x1FF02000}, - /* These are not (yet) in AN2606: */ - {0x641, "Medium_Density PL" , 0x20000200, 0x00005000, 0x08000000, 0x08020000, 4, 1024, 0x1FFFF800, 0x1FFFF80F, 0x1FFFF000, 0x1FFFF800}, - {0x9a8, "STM32W-128K" , 0x20000200, 0x20002000, 0x08000000, 0x08020000, 1, 1024, 0, 0, 0, 0}, - {0x9b0, "STM32W-256K" , 0x20000200, 0x20004000, 0x08000000, 0x08040000, 1, 2048, 0, 0, 0, 0}, - {0x0} -}; diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/gpl-2.0.txt b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/gpl-2.0.txt deleted file mode 100755 index d159169d1..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/gpl-2.0.txt +++ /dev/null @@ -1,339 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/i2c.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/i2c.c deleted file mode 100755 index 10e6bb15a..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/i2c.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - - -#if !defined(__linux__) - -static port_err_t i2c_open(struct port_interface *port, - struct port_options *ops) -{ - return PORT_ERR_NODEV; -} - -struct port_interface port_i2c = { - .name = "i2c", - .open = i2c_open, -}; - -#else - -#ifdef __ANDROID__ -#define I2C_SLAVE 0x0703 /* Use this slave address */ -#define I2C_FUNCS 0x0705 /* Get the adapter functionality mask */ -/* To determine what functionality is present */ -#define I2C_FUNC_I2C 0x00000001 -#else -#include -#include -#endif - -#include - -struct i2c_priv { - int fd; - int addr; -}; - -static port_err_t i2c_open(struct port_interface *port, - struct port_options *ops) -{ - struct i2c_priv *h; - int fd, addr, ret; - unsigned long funcs; - - /* 1. check device name match */ - if (strncmp(ops->device, "/dev/i2c-", strlen("/dev/i2c-"))) - return PORT_ERR_NODEV; - - /* 2. check options */ - addr = ops->bus_addr; - if (addr < 0x03 || addr > 0x77) { - fprintf(stderr, "I2C address out of range [0x03-0x77]\n"); - return PORT_ERR_UNKNOWN; - } - - /* 3. open it */ - h = calloc(sizeof(*h), 1); - if (h == NULL) { - fprintf(stderr, "End of memory\n"); - return PORT_ERR_UNKNOWN; - } - fd = open(ops->device, O_RDWR); - if (fd < 0) { - fprintf(stderr, "Unable to open special file \"%s\"\n", - ops->device); - free(h); - return PORT_ERR_UNKNOWN; - } - - /* 3.5. Check capabilities */ - ret = ioctl(fd, I2C_FUNCS, &funcs); - if (ret < 0) { - fprintf(stderr, "I2C ioctl(funcs) error %d\n", errno); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - if ((funcs & I2C_FUNC_I2C) == 0) { - fprintf(stderr, "Error: controller is not I2C, only SMBUS.\n"); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - - /* 4. set options */ - ret = ioctl(fd, I2C_SLAVE, addr); - if (ret < 0) { - fprintf(stderr, "I2C ioctl(slave) error %d\n", errno); - close(fd); - free(h); - return PORT_ERR_UNKNOWN; - } - - h->fd = fd; - h->addr = addr; - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t i2c_close(struct port_interface *port) -{ - struct i2c_priv *h; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - close(h->fd); - free(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t i2c_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - struct i2c_priv *h; - int ret; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - ret = read(h->fd, buf, nbyte); - if (ret != nbyte) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; -} - -static port_err_t i2c_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - struct i2c_priv *h; - int ret; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - ret = write(h->fd, buf, nbyte); - if (ret != nbyte) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; -} - -static port_err_t i2c_gpio(struct port_interface *port, serial_gpio_t n, - int level) -{ - return PORT_ERR_OK; -} - -static const char *i2c_get_cfg_str(struct port_interface *port) -{ - struct i2c_priv *h; - static char str[11]; - - h = (struct i2c_priv *)port->private; - if (h == NULL) - return "INVALID"; - snprintf(str, sizeof(str), "addr 0x%2x", h->addr); - return str; -} - -static struct varlen_cmd i2c_cmd_get_reply[] = { - {0x10, 11}, - {0x11, 17}, - {0x12, 18}, - { /* sentinel */ } -}; - -struct port_interface port_i2c = { - .name = "i2c", - .flags = PORT_STRETCH_W, - .open = i2c_open, - .close = i2c_close, - .read = i2c_read, - .write = i2c_write, - .gpio = i2c_gpio, - .cmd_get_reply = i2c_cmd_get_reply, - .get_cfg_str = i2c_get_cfg_str, -}; - -#endif diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/init.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/init.c deleted file mode 100755 index 77a571bd8..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/init.c +++ /dev/null @@ -1,219 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include -#include -#include "init.h" -#include "serial.h" -#include "stm32.h" -#include "port.h" - -struct gpio_list { - struct gpio_list *next; - int gpio; -}; - - -static int write_to(const char *filename, const char *value) -{ - int fd, ret; - - fd = open(filename, O_WRONLY); - if (fd < 0) { - fprintf(stderr, "Cannot open file \"%s\"\n", filename); - return 0; - } - ret = write(fd, value, strlen(value)); - if (ret < 0) { - fprintf(stderr, "Error writing in file \"%s\"\n", filename); - close(fd); - return 0; - } - close(fd); - return 1; -} - -#if !defined(__linux__) -static int drive_gpio(int n, int level, struct gpio_list **gpio_to_release) -{ - fprintf(stderr, "GPIO control only available in Linux\n"); - return 0; -} -#else -static int drive_gpio(int n, int level, struct gpio_list **gpio_to_release) -{ - char num[16]; /* sized to carry MAX_INT */ - char file[48]; /* sized to carry longest filename */ - struct stat buf; - struct gpio_list *new; - int ret; - - sprintf(file, "/sys/class/gpio/gpio%d/direction", n); - ret = stat(file, &buf); - if (ret) { - /* file miss, GPIO not exported yet */ - sprintf(num, "%d", n); - ret = write_to("/sys/class/gpio/export", num); - if (!ret) - return 0; - ret = stat(file, &buf); - if (ret) { - fprintf(stderr, "GPIO %d not available\n", n); - return 0; - } - new = (struct gpio_list *)malloc(sizeof(struct gpio_list)); - if (new == NULL) { - fprintf(stderr, "Out of memory\n"); - return 0; - } - new->gpio = n; - new->next = *gpio_to_release; - *gpio_to_release = new; - } - - return write_to(file, level ? "high" : "low"); -} -#endif - -static int release_gpio(int n) -{ - char num[16]; /* sized to carry MAX_INT */ - - sprintf(num, "%d", n); - return write_to("/sys/class/gpio/unexport", num); -} - -static int gpio_sequence(struct port_interface *port, const char *s, size_t l) -{ - struct gpio_list *gpio_to_release = NULL, *to_free; - int ret, level, gpio; - - ret = 1; - while (ret == 1 && *s && l > 0) { - if (*s == '-') { - level = 0; - s++; - l--; - } else - level = 1; - - if (isdigit(*s)) { - gpio = atoi(s); - while (isdigit(*s)) { - s++; - l--; - } - } else if (!strncmp(s, "rts", 3)) { - gpio = -GPIO_RTS; - s += 3; - l -= 3; - } else if (!strncmp(s, "dtr", 3)) { - gpio = -GPIO_DTR; - s += 3; - l -= 3; - } else if (!strncmp(s, "brk", 3)) { - gpio = -GPIO_BRK; - s += 3; - l -= 3; - } else { - fprintf(stderr, "Character \'%c\' is not a digit\n", *s); - ret = 0; - break; - } - - if (*s && (l > 0)) { - if (*s == ',') { - s++; - l--; - } else { - fprintf(stderr, "Character \'%c\' is not a separator\n", *s); - ret = 0; - break; - } - } - if (gpio < 0) - ret = (port->gpio(port, -gpio, level) == PORT_ERR_OK); - else - ret = drive_gpio(gpio, level, &gpio_to_release); - usleep(100000); - } - - while (gpio_to_release) { - release_gpio(gpio_to_release->gpio); - to_free = gpio_to_release; - gpio_to_release = gpio_to_release->next; - free(to_free); - } - usleep(500000); - return ret; -} - -static int gpio_bl_entry(struct port_interface *port, const char *seq) -{ - char *s; - - if (seq == NULL || seq[0] == ':') - return 1; - - s = strchr(seq, ':'); - if (s == NULL) - return gpio_sequence(port, seq, strlen(seq)); - - return gpio_sequence(port, seq, s - seq); -} - -static int gpio_bl_exit(struct port_interface *port, const char *seq) -{ - char *s; - - if (seq == NULL) - return 1; - - s = strchr(seq, ':'); - if (s == NULL || s[1] == '\0') - return 1; - - return gpio_sequence(port, s + 1, strlen(s + 1)); -} - -int init_bl_entry(struct port_interface *port, const char *seq) -{ - if (seq) - return gpio_bl_entry(port, seq); - - return 1; -} - -int init_bl_exit(stm32_t *stm, struct port_interface *port, const char *seq) -{ - if (seq) - return gpio_bl_exit(port, seq); - - if (stm32_reset_device(stm) != STM32_ERR_OK) - return 0; - return 1; -} diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/init.h b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/init.h deleted file mode 100755 index 6075b519b..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/init.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _INIT_H -#define _INIT_H - -#include "stm32.h" -#include "port.h" - -int init_bl_entry(struct port_interface *port, const char *seq); -int init_bl_exit(stm32_t *stm, struct port_interface *port, const char *seq); - -#endif diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/main.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/main.c deleted file mode 100755 index f081d6131..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/main.c +++ /dev/null @@ -1,774 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright 2010 Geoffrey McRae - Copyright 2011 Steve Markgraf - Copyright 2012 Tormod Volden - Copyright 2013 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include - -#include "init.h" -#include "utils.h" -#include "serial.h" -#include "stm32.h" -#include "parsers/parser.h" -#include "port.h" - -#include "parsers/binary.h" -#include "parsers/hex.h" - -#define VERSION "Arduino_STM32_0.9" - -/* device globals */ -stm32_t *stm = NULL; - -void *p_st = NULL; -parser_t *parser = NULL; - -/* settings */ -struct port_options port_opts = { - .device = NULL, - .baudRate = SERIAL_BAUD_57600, - .serial_mode = "8e1", - .bus_addr = 0, - .rx_frame_max = STM32_MAX_RX_FRAME, - .tx_frame_max = STM32_MAX_TX_FRAME, -}; -int rd = 0; -int wr = 0; -int wu = 0; -int rp = 0; -int ur = 0; -int eraseOnly = 0; -int crc = 0; -int npages = 0; -int spage = 0; -int no_erase = 0; -char verify = 0; -int retry = 10; -char exec_flag = 0; -uint32_t execute = 0; -char init_flag = 1; -char force_binary = 0; -char reset_flag = 0; -char *filename; -char *gpio_seq = NULL; -uint32_t start_addr = 0; -uint32_t readwrite_len = 0; - -/* functions */ -int parse_options(int argc, char *argv[]); -void show_help(char *name); - -static int is_addr_in_ram(uint32_t addr) -{ - return addr >= stm->dev->ram_start && addr < stm->dev->ram_end; -} - -static int is_addr_in_flash(uint32_t addr) -{ - return addr >= stm->dev->fl_start && addr < stm->dev->fl_end; -} - -static int flash_addr_to_page_floor(uint32_t addr) -{ - if (!is_addr_in_flash(addr)) - return 0; - - return (addr - stm->dev->fl_start) / stm->dev->fl_ps; -} - -static int flash_addr_to_page_ceil(uint32_t addr) -{ - if (!(addr >= stm->dev->fl_start && addr <= stm->dev->fl_end)) - return 0; - - return (addr + stm->dev->fl_ps - 1 - stm->dev->fl_start) - / stm->dev->fl_ps; -} - -static uint32_t flash_page_to_addr(int page) -{ - return stm->dev->fl_start + page * stm->dev->fl_ps; -} - -int main(int argc, char* argv[]) { - struct port_interface *port = NULL; - int ret = 1; - stm32_err_t s_err; - parser_err_t perr; - FILE *diag = stdout; - - fprintf(diag, "stm32flash " VERSION "\n\n"); - fprintf(diag, "http://github.com/rogerclarkmelbourne/arduino_stm32\n\n"); - if (parse_options(argc, argv) != 0) - goto close; - - if (rd && filename[0] == '-') { - diag = stderr; - } - - if (wr) { - /* first try hex */ - if (!force_binary) { - parser = &PARSER_HEX; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - } - - if (force_binary || (perr = parser->open(p_st, filename, 0)) != PARSER_ERR_OK) { - if (force_binary || perr == PARSER_ERR_INVALID_FILE) { - if (!force_binary) { - parser->close(p_st); - p_st = NULL; - } - - /* now try binary */ - parser = &PARSER_BINARY; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - perr = parser->open(p_st, filename, 0); - } - - /* if still have an error, fail */ - if (perr != PARSER_ERR_OK) { - fprintf(stderr, "%s ERROR: %s\n", parser->name, parser_errstr(perr)); - if (perr == PARSER_ERR_SYSTEM) perror(filename); - goto close; - } - } - - fprintf(diag, "Using Parser : %s\n", parser->name); - } else { - parser = &PARSER_BINARY; - p_st = parser->init(); - if (!p_st) { - fprintf(stderr, "%s Parser failed to initialize\n", parser->name); - goto close; - } - } - - if (port_open(&port_opts, &port) != PORT_ERR_OK) { - fprintf(stderr, "Failed to open port: %s\n", port_opts.device); - goto close; - } - - fprintf(diag, "Interface %s: %s\n", port->name, port->get_cfg_str(port)); - if (init_flag && init_bl_entry(port, gpio_seq) == 0) - goto close; - stm = stm32_init(port, init_flag); - if (!stm) - goto close; - - fprintf(diag, "Version : 0x%02x\n", stm->bl_version); - if (port->flags & PORT_GVR_ETX) { - fprintf(diag, "Option 1 : 0x%02x\n", stm->option1); - fprintf(diag, "Option 2 : 0x%02x\n", stm->option2); - } - fprintf(diag, "Device ID : 0x%04x (%s)\n", stm->pid, stm->dev->name); - fprintf(diag, "- RAM : %dKiB (%db reserved by bootloader)\n", (stm->dev->ram_end - 0x20000000) / 1024, stm->dev->ram_start - 0x20000000); - fprintf(diag, "- Flash : %dKiB (sector size: %dx%d)\n", (stm->dev->fl_end - stm->dev->fl_start ) / 1024, stm->dev->fl_pps, stm->dev->fl_ps); - fprintf(diag, "- Option RAM : %db\n", stm->dev->opt_end - stm->dev->opt_start + 1); - fprintf(diag, "- System RAM : %dKiB\n", (stm->dev->mem_end - stm->dev->mem_start) / 1024); - - uint8_t buffer[256]; - uint32_t addr, start, end; - unsigned int len; - int failed = 0; - int first_page, num_pages; - - /* - * Cleanup addresses: - * - * Starting from options - * start_addr, readwrite_len, spage, npages - * and using device memory size, compute - * start, end, first_page, num_pages - */ - if (start_addr || readwrite_len) { - start = start_addr; - - if (is_addr_in_flash(start)) - end = stm->dev->fl_end; - else { - no_erase = 1; - if (is_addr_in_ram(start)) - end = stm->dev->ram_end; - else - end = start + sizeof(uint32_t); - } - - if (readwrite_len && (end > start + readwrite_len)) - end = start + readwrite_len; - - first_page = flash_addr_to_page_floor(start); - if (!first_page && end == stm->dev->fl_end) - num_pages = 0xff; /* mass erase */ - else - num_pages = flash_addr_to_page_ceil(end) - first_page; - } else if (!spage && !npages) { - start = stm->dev->fl_start; - end = stm->dev->fl_end; - first_page = 0; - num_pages = 0xff; /* mass erase */ - } else { - first_page = spage; - start = flash_page_to_addr(first_page); - if (start > stm->dev->fl_end) { - fprintf(stderr, "Address range exceeds flash size.\n"); - goto close; - } - - if (npages) { - num_pages = npages; - end = flash_page_to_addr(first_page + num_pages); - if (end > stm->dev->fl_end) - end = stm->dev->fl_end; - } else { - end = stm->dev->fl_end; - num_pages = flash_addr_to_page_ceil(end) - first_page; - } - - if (!first_page && end == stm->dev->fl_end) - num_pages = 0xff; /* mass erase */ - } - - if (rd) { - unsigned int max_len = port_opts.rx_frame_max; - - fprintf(diag, "Memory read\n"); - - perr = parser->open(p_st, filename, 1); - if (perr != PARSER_ERR_OK) { - fprintf(stderr, "%s ERROR: %s\n", parser->name, parser_errstr(perr)); - if (perr == PARSER_ERR_SYSTEM) - perror(filename); - goto close; - } - - fflush(diag); - addr = start; - while(addr < end) { - uint32_t left = end - addr; - len = max_len > left ? left : max_len; - s_err = stm32_read_memory(stm, addr, buffer, len); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read memory at address 0x%08x, target write-protected?\n", addr); - goto close; - } - if (parser->write(p_st, buffer, len) != PARSER_ERR_OK) - { - fprintf(stderr, "Failed to write data to file\n"); - goto close; - } - addr += len; - - fprintf(diag, - "\rRead address 0x%08x (%.2f%%) ", - addr, - (100.0f / (float)(end - start)) * (float)(addr - start) - ); - fflush(diag); - } - fprintf(diag, "Done.\n"); - ret = 0; - goto close; - } else if (rp) { - fprintf(stdout, "Read-Protecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_readprot_memory(stm); - fprintf(stdout, "Done.\n"); - } else if (ur) { - fprintf(stdout, "Read-UnProtecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_runprot_memory(stm); - fprintf(stdout, "Done.\n"); - } else if (eraseOnly) { - ret = 0; - fprintf(stdout, "Erasing flash\n"); - - if (num_pages != 0xff && - (start != flash_page_to_addr(first_page) - || end != flash_page_to_addr(first_page + num_pages))) { - fprintf(stderr, "Specified start & length are invalid (must be page aligned)\n"); - ret = 1; - goto close; - } - - s_err = stm32_erase_memory(stm, first_page, num_pages); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to erase memory\n"); - ret = 1; - goto close; - } - } else if (wu) { - fprintf(diag, "Write-unprotecting flash\n"); - /* the device automatically performs a reset after the sending the ACK */ - reset_flag = 0; - stm32_wunprot_memory(stm); - fprintf(diag, "Done.\n"); - - } else if (wr) { - fprintf(diag, "Write to memory\n"); - - off_t offset = 0; - ssize_t r; - unsigned int size; - unsigned int max_wlen, max_rlen; - - max_wlen = port_opts.tx_frame_max - 2; /* skip len and crc */ - max_wlen &= ~3; /* 32 bit aligned */ - - max_rlen = port_opts.rx_frame_max; - max_rlen = max_rlen < max_wlen ? max_rlen : max_wlen; - - /* Assume data from stdin is whole device */ - if (filename[0] == '-' && filename[1] == '\0') - size = end - start; - else - size = parser->size(p_st); - - // TODO: It is possible to write to non-page boundaries, by reading out flash - // from partial pages and combining with the input data - // if ((start % stm->dev->fl_ps) != 0 || (end % stm->dev->fl_ps) != 0) { - // fprintf(stderr, "Specified start & length are invalid (must be page aligned)\n"); - // goto close; - // } - - // TODO: If writes are not page aligned, we should probably read out existing flash - // contents first, so it can be preserved and combined with new data - if (!no_erase && num_pages) { - fprintf(diag, "Erasing memory\n"); - s_err = stm32_erase_memory(stm, first_page, num_pages); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to erase memory\n"); - goto close; - } - } - - fflush(diag); - addr = start; - while(addr < end && offset < size) { - uint32_t left = end - addr; - len = max_wlen > left ? left : max_wlen; - len = len > size - offset ? size - offset : len; - - if (parser->read(p_st, buffer, &len) != PARSER_ERR_OK) - goto close; - - if (len == 0) { - if (filename[0] == '-') { - break; - } else { - fprintf(stderr, "Failed to read input file\n"); - goto close; - } - } - - again: - s_err = stm32_write_memory(stm, addr, buffer, len); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to write memory at address 0x%08x\n", addr); - goto close; - } - - if (verify) { - uint8_t compare[len]; - unsigned int offset, rlen; - - offset = 0; - while (offset < len) { - rlen = len - offset; - rlen = rlen < max_rlen ? rlen : max_rlen; - s_err = stm32_read_memory(stm, addr + offset, compare + offset, rlen); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read memory at address 0x%08x\n", addr + offset); - goto close; - } - offset += rlen; - } - - for(r = 0; r < len; ++r) - if (buffer[r] != compare[r]) { - if (failed == retry) { - fprintf(stderr, "Failed to verify at address 0x%08x, expected 0x%02x and found 0x%02x\n", - (uint32_t)(addr + r), - buffer [r], - compare[r] - ); - goto close; - } - ++failed; - goto again; - } - - failed = 0; - } - - addr += len; - offset += len; - - fprintf(diag, - "\rWrote %saddress 0x%08x (%.2f%%) ", - verify ? "and verified " : "", - addr, - (100.0f / size) * offset - ); - fflush(diag); - - } - - fprintf(diag, "Done.\n"); - ret = 0; - goto close; - } else if (crc) { - uint32_t crc_val = 0; - - fprintf(diag, "CRC computation\n"); - - s_err = stm32_crc_wrapper(stm, start, end - start, &crc_val); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Failed to read CRC\n"); - goto close; - } - fprintf(diag, "CRC(0x%08x-0x%08x) = 0x%08x\n", start, end, - crc_val); - ret = 0; - goto close; - } else - ret = 0; - -close: - if (stm && exec_flag && ret == 0) { - if (execute == 0) - execute = stm->dev->fl_start; - - fprintf(diag, "\nStarting execution at address 0x%08x... ", execute); - fflush(diag); - if (stm32_go(stm, execute) == STM32_ERR_OK) { - reset_flag = 0; - fprintf(diag, "done.\n"); - } else - fprintf(diag, "failed.\n"); - } - - if (stm && reset_flag) { - fprintf(diag, "\nResetting device... "); - fflush(diag); - if (init_bl_exit(stm, port, gpio_seq)) - fprintf(diag, "done.\n"); - else fprintf(diag, "failed.\n"); - } - - if (p_st ) parser->close(p_st); - if (stm ) stm32_close (stm); - if (port) - port->close(port); - - fprintf(diag, "\n"); - return ret; -} - -int parse_options(int argc, char *argv[]) -{ - int c; - char *pLen; - - while ((c = getopt(argc, argv, "a:b:m:r:w:e:vn:g:jkfcChuos:S:F:i:R")) != -1) { - switch(c) { - case 'a': - port_opts.bus_addr = strtoul(optarg, NULL, 0); - break; - - case 'b': - port_opts.baudRate = serial_get_baud(strtoul(optarg, NULL, 0)); - if (port_opts.baudRate == SERIAL_BAUD_INVALID) { - serial_baud_t baudrate; - fprintf(stderr, "Invalid baud rate, valid options are:\n"); - for (baudrate = SERIAL_BAUD_1200; baudrate != SERIAL_BAUD_INVALID; ++baudrate) - fprintf(stderr, " %d\n", serial_get_baud_int(baudrate)); - return 1; - } - break; - - case 'm': - if (strlen(optarg) != 3 - || serial_get_bits(optarg) == SERIAL_BITS_INVALID - || serial_get_parity(optarg) == SERIAL_PARITY_INVALID - || serial_get_stopbit(optarg) == SERIAL_STOPBIT_INVALID) { - fprintf(stderr, "Invalid serial mode\n"); - return 1; - } - port_opts.serial_mode = optarg; - break; - - case 'r': - case 'w': - rd = rd || c == 'r'; - wr = wr || c == 'w'; - if (rd && wr) { - fprintf(stderr, "ERROR: Invalid options, can't read & write at the same time\n"); - return 1; - } - filename = optarg; - if (filename[0] == '-') { - force_binary = 1; - } - break; - case 'e': - if (readwrite_len || start_addr) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } - npages = strtoul(optarg, NULL, 0); - if (npages > 0xFF || npages < 0) { - fprintf(stderr, "ERROR: You need to specify a page count between 0 and 255"); - return 1; - } - if (!npages) - no_erase = 1; - break; - case 'u': - wu = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't write unprotect and read/write at the same time\n"); - return 1; - } - break; - - case 'j': - rp = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't read protect and read/write at the same time\n"); - return 1; - } - break; - - case 'k': - ur = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't read unprotect and read/write at the same time\n"); - return 1; - } - break; - - case 'o': - eraseOnly = 1; - if (rd || wr) { - fprintf(stderr, "ERROR: Invalid options, can't erase-only and read/write at the same time\n"); - return 1; - } - break; - - case 'v': - verify = 1; - break; - - case 'n': - retry = strtoul(optarg, NULL, 0); - break; - - case 'g': - exec_flag = 1; - execute = strtoul(optarg, NULL, 0); - if (execute % 4 != 0) { - fprintf(stderr, "ERROR: Execution address must be word-aligned\n"); - return 1; - } - break; - case 's': - if (readwrite_len || start_addr) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } - spage = strtoul(optarg, NULL, 0); - break; - case 'S': - if (spage || npages) { - fprintf(stderr, "ERROR: Invalid options, can't specify start page / num pages and start address/length\n"); - return 1; - } else { - start_addr = strtoul(optarg, &pLen, 0); - if (*pLen == ':') { - pLen++; - readwrite_len = strtoul(pLen, NULL, 0); - if (readwrite_len == 0) { - fprintf(stderr, "ERROR: Invalid options, can't specify zero length\n"); - return 1; - } - } - } - break; - case 'F': - port_opts.rx_frame_max = strtoul(optarg, &pLen, 0); - if (*pLen == ':') { - pLen++; - port_opts.tx_frame_max = strtoul(pLen, NULL, 0); - } - if (port_opts.rx_frame_max < 0 - || port_opts.tx_frame_max < 0) { - fprintf(stderr, "ERROR: Invalid negative value for option -F\n"); - return 1; - } - if (port_opts.rx_frame_max == 0) - port_opts.rx_frame_max = STM32_MAX_RX_FRAME; - if (port_opts.tx_frame_max == 0) - port_opts.tx_frame_max = STM32_MAX_TX_FRAME; - if (port_opts.rx_frame_max < 20 - || port_opts.tx_frame_max < 5) { - fprintf(stderr, "ERROR: current code cannot work with small frames.\n"); - fprintf(stderr, "min(RX) = 20, min(TX) = 5\n"); - return 1; - } - if (port_opts.rx_frame_max > STM32_MAX_RX_FRAME) { - fprintf(stderr, "WARNING: Ignore RX length in option -F\n"); - port_opts.rx_frame_max = STM32_MAX_RX_FRAME; - } - if (port_opts.tx_frame_max > STM32_MAX_TX_FRAME) { - fprintf(stderr, "WARNING: Ignore TX length in option -F\n"); - port_opts.tx_frame_max = STM32_MAX_TX_FRAME; - } - break; - case 'f': - force_binary = 1; - break; - - case 'c': - init_flag = 0; - break; - - case 'h': - show_help(argv[0]); - exit(0); - - case 'i': - gpio_seq = optarg; - break; - - case 'R': - reset_flag = 1; - break; - - case 'C': - crc = 1; - break; - } - } - - for (c = optind; c < argc; ++c) { - if (port_opts.device) { - fprintf(stderr, "ERROR: Invalid parameter specified\n"); - show_help(argv[0]); - return 1; - } - port_opts.device = argv[c]; - } - - if (port_opts.device == NULL) { - fprintf(stderr, "ERROR: Device not specified\n"); - show_help(argv[0]); - return 1; - } - - if (!wr && verify) { - fprintf(stderr, "ERROR: Invalid usage, -v is only valid when writing\n"); - show_help(argv[0]); - return 1; - } - - return 0; -} - -void show_help(char *name) { - fprintf(stderr, - "Usage: %s [-bvngfhc] [-[rw] filename] [tty_device | i2c_device]\n" - " -a bus_address Bus address (e.g. for I2C port)\n" - " -b rate Baud rate (default 57600)\n" - " -m mode Serial port mode (default 8e1)\n" - " -r filename Read flash to file (or - stdout)\n" - " -w filename Write flash from file (or - stdout)\n" - " -C Compute CRC of flash content\n" - " -u Disable the flash write-protection\n" - " -j Enable the flash read-protection\n" - " -k Disable the flash read-protection\n" - " -o Erase only\n" - " -e n Only erase n pages before writing the flash\n" - " -v Verify writes\n" - " -n count Retry failed writes up to count times (default 10)\n" - " -g address Start execution at specified address (0 = flash start)\n" - " -S address[:length] Specify start address and optionally length for\n" - " read/write/erase operations\n" - " -F RX_length[:TX_length] Specify the max length of RX and TX frame\n" - " -s start_page Flash at specified page (0 = flash start)\n" - " -f Force binary parser\n" - " -h Show this help\n" - " -c Resume the connection (don't send initial INIT)\n" - " *Baud rate must be kept the same as the first init*\n" - " This is useful if the reset fails\n" - " -i GPIO_string GPIO sequence to enter/exit bootloader mode\n" - " GPIO_string=[entry_seq][:[exit_seq]]\n" - " sequence=[-]n[,sequence]\n" - " -R Reset device at exit.\n" - "\n" - "Examples:\n" - " Get device information:\n" - " %s /dev/ttyS0\n" - " or:\n" - " %s /dev/i2c-0\n" - "\n" - " Write with verify and then start execution:\n" - " %s -w filename -v -g 0x0 /dev/ttyS0\n" - "\n" - " Read flash to file:\n" - " %s -r filename /dev/ttyS0\n" - "\n" - " Read 100 bytes of flash from 0x1000 to stdout:\n" - " %s -r - -S 0x1000:100 /dev/ttyS0\n" - "\n" - " Start execution:\n" - " %s -g 0x0 /dev/ttyS0\n" - "\n" - " GPIO sequence:\n" - " - entry sequence: GPIO_3=low, GPIO_2=low, GPIO_2=high\n" - " - exit sequence: GPIO_3=high, GPIO_2=low, GPIO_2=high\n" - " %s -i -3,-2,2:3,-2,2 /dev/ttyS0\n", - name, - name, - name, - name, - name, - name, - name, - name - ); -} - diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/Android.mk b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/Android.mk deleted file mode 100755 index afec18cd5..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/Android.mk +++ /dev/null @@ -1,6 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := libparsers -LOCAL_SRC_FILES := binary.c hex.c -include $(BUILD_STATIC_LIBRARY) diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/Makefile b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/Makefile deleted file mode 100755 index bb7df1e02..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/Makefile +++ /dev/null @@ -1,12 +0,0 @@ - -CFLAGS += -Wall -g - -all: parsers.a - -parsers.a: binary.o hex.o - $(AR) rc $@ binary.o hex.o - -clean: - rm -f *.o parsers.a - -.PHONY: all clean diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/binary.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/binary.c deleted file mode 100755 index f491952bb..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/binary.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include - -#include "binary.h" - -typedef struct { - int fd; - char write; - struct stat stat; -} binary_t; - -void* binary_init() { - return calloc(sizeof(binary_t), 1); -} - -parser_err_t binary_open(void *storage, const char *filename, const char write) { - binary_t *st = storage; - if (write) { - if (filename[0] == '-') - st->fd = 1; - else - st->fd = open( - filename, -#ifndef __WIN32__ - O_WRONLY | O_CREAT | O_TRUNC, -#else - O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, -#endif -#ifndef __WIN32__ - S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH -#else - 0 -#endif - ); - st->stat.st_size = 0; - } else { - if (filename[0] == '-') { - st->fd = 0; - } else { - if (stat(filename, &st->stat) != 0) - return PARSER_ERR_INVALID_FILE; - st->fd = open(filename, -#ifndef __WIN32__ - O_RDONLY -#else - O_RDONLY | O_BINARY -#endif - ); - } - } - - st->write = write; - return st->fd == -1 ? PARSER_ERR_SYSTEM : PARSER_ERR_OK; -} - -parser_err_t binary_close(void *storage) { - binary_t *st = storage; - - if (st->fd) close(st->fd); - free(st); - return PARSER_ERR_OK; -} - -unsigned int binary_size(void *storage) { - binary_t *st = storage; - return st->stat.st_size; -} - -parser_err_t binary_read(void *storage, void *data, unsigned int *len) { - binary_t *st = storage; - unsigned int left = *len; - if (st->write) return PARSER_ERR_WRONLY; - - ssize_t r; - while(left > 0) { - r = read(st->fd, data, left); - /* If there is no data to read at all, return OK, but with zero read */ - if (r == 0 && left == *len) { - *len = 0; - return PARSER_ERR_OK; - } - if (r <= 0) return PARSER_ERR_SYSTEM; - left -= r; - data += r; - } - - *len = *len - left; - return PARSER_ERR_OK; -} - -parser_err_t binary_write(void *storage, void *data, unsigned int len) { - binary_t *st = storage; - if (!st->write) return PARSER_ERR_RDONLY; - - ssize_t r; - while(len > 0) { - r = write(st->fd, data, len); - if (r < 1) return PARSER_ERR_SYSTEM; - st->stat.st_size += r; - - len -= r; - data += r; - } - - return PARSER_ERR_OK; -} - -parser_t PARSER_BINARY = { - "Raw BINARY", - binary_init, - binary_open, - binary_close, - binary_size, - binary_read, - binary_write -}; - diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/binary.h b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/binary.h deleted file mode 100755 index d989acfa0..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/binary.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _PARSER_BINARY_H -#define _PARSER_BINARY_H - -#include "parser.h" - -extern parser_t PARSER_BINARY; -#endif diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/hex.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/hex.c deleted file mode 100755 index 3baf85623..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/hex.c +++ /dev/null @@ -1,224 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#include -#include -#include -#include -#include -#include -#include - -#include "hex.h" -#include "../utils.h" - -typedef struct { - size_t data_len, offset; - uint8_t *data; - uint8_t base; -} hex_t; - -void* hex_init() { - return calloc(sizeof(hex_t), 1); -} - -parser_err_t hex_open(void *storage, const char *filename, const char write) { - hex_t *st = storage; - if (write) { - return PARSER_ERR_RDONLY; - } else { - char mark; - int i, fd; - uint8_t checksum; - unsigned int c; - uint32_t base = 0; - unsigned int last_address = 0x0; - - fd = open(filename, O_RDONLY); - if (fd < 0) - return PARSER_ERR_SYSTEM; - - /* read in the file */ - - while(read(fd, &mark, 1) != 0) { - if (mark == '\n' || mark == '\r') continue; - if (mark != ':') - return PARSER_ERR_INVALID_FILE; - - char buffer[9]; - unsigned int reclen, address, type; - uint8_t *record = NULL; - - /* get the reclen, address, and type */ - buffer[8] = 0; - if (read(fd, &buffer, 8) != 8) return PARSER_ERR_INVALID_FILE; - if (sscanf(buffer, "%2x%4x%2x", &reclen, &address, &type) != 3) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* setup the checksum */ - checksum = - reclen + - ((address & 0xFF00) >> 8) + - ((address & 0x00FF) >> 0) + - type; - - switch(type) { - /* data record */ - case 0: - c = address - last_address; - st->data = realloc(st->data, st->data_len + c + reclen); - - /* if there is a gap, set it to 0xff and increment the length */ - if (c > 0) { - memset(&st->data[st->data_len], 0xff, c); - st->data_len += c; - } - - last_address = address + reclen; - record = &st->data[st->data_len]; - st->data_len += reclen; - break; - - /* extended segment address record */ - case 2: - base = 0; - break; - - /* extended linear address record */ - case 4: - base = address; - break; - } - - buffer[2] = 0; - for(i = 0; i < reclen; ++i) { - if (read(fd, &buffer, 2) != 2 || sscanf(buffer, "%2x", &c) != 1) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* add the byte to the checksum */ - checksum += c; - - switch(type) { - case 0: - if (record != NULL) { - record[i] = c; - } else { - return PARSER_ERR_INVALID_FILE; - } - break; - - case 2: - case 4: - base = (base << 8) | c; - break; - } - } - - /* read, scan, and verify the checksum */ - if ( - read(fd, &buffer, 2 ) != 2 || - sscanf(buffer, "%2x", &c) != 1 || - (uint8_t)(checksum + c) != 0x00 - ) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - switch(type) { - /* EOF */ - case 1: - close(fd); - return PARSER_ERR_OK; - - /* address record */ - case 2: base = base << 4; - case 4: base = be_u32(base); - /* Reset last_address since our base changed */ - last_address = 0; - - if (st->base == 0) { - st->base = base; - break; - } - - /* we cant cope with files out of order */ - if (base < st->base) { - close(fd); - return PARSER_ERR_INVALID_FILE; - } - - /* if there is a gap, enlarge and fill with zeros */ - unsigned int len = base - st->base; - if (len > st->data_len) { - st->data = realloc(st->data, len); - memset(&st->data[st->data_len], 0, len - st->data_len); - st->data_len = len; - } - break; - } - } - - close(fd); - return PARSER_ERR_OK; - } -} - -parser_err_t hex_close(void *storage) { - hex_t *st = storage; - if (st) free(st->data); - free(st); - return PARSER_ERR_OK; -} - -unsigned int hex_size(void *storage) { - hex_t *st = storage; - return st->data_len; -} - -parser_err_t hex_read(void *storage, void *data, unsigned int *len) { - hex_t *st = storage; - unsigned int left = st->data_len - st->offset; - unsigned int get = left > *len ? *len : left; - - memcpy(data, &st->data[st->offset], get); - st->offset += get; - - *len = get; - return PARSER_ERR_OK; -} - -parser_err_t hex_write(void *storage, void *data, unsigned int len) { - return PARSER_ERR_RDONLY; -} - -parser_t PARSER_HEX = { - "Intel HEX", - hex_init, - hex_open, - hex_close, - hex_size, - hex_read, - hex_write -}; - diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/hex.h b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/hex.h deleted file mode 100755 index 02413c9c9..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/hex.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _PARSER_HEX_H -#define _PARSER_HEX_H - -#include "parser.h" - -extern parser_t PARSER_HEX; -#endif diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/parser.h b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/parser.h deleted file mode 100755 index c2fae3cf8..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/parsers/parser.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_PARSER -#define _H_PARSER - -enum parser_err { - PARSER_ERR_OK, - PARSER_ERR_SYSTEM, - PARSER_ERR_INVALID_FILE, - PARSER_ERR_WRONLY, - PARSER_ERR_RDONLY -}; -typedef enum parser_err parser_err_t; - -struct parser { - const char *name; - void* (*init )(); /* initialise the parser */ - parser_err_t (*open )(void *storage, const char *filename, const char write); /* open the file for read|write */ - parser_err_t (*close)(void *storage); /* close and free the parser */ - unsigned int (*size )(void *storage); /* get the total data size */ - parser_err_t (*read )(void *storage, void *data, unsigned int *len); /* read a block of data */ - parser_err_t (*write)(void *storage, void *data, unsigned int len); /* write a block of data */ -}; -typedef struct parser parser_t; - -static inline const char* parser_errstr(parser_err_t err) { - switch(err) { - case PARSER_ERR_OK : return "OK"; - case PARSER_ERR_SYSTEM : return "System Error"; - case PARSER_ERR_INVALID_FILE: return "Invalid File"; - case PARSER_ERR_WRONLY : return "Parser can only write"; - case PARSER_ERR_RDONLY : return "Parser can only read"; - default: - return "Unknown Error"; - } -} - -#endif diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/port.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/port.c deleted file mode 100755 index 08e58cc34..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/port.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include - -#include "serial.h" -#include "port.h" - - -extern struct port_interface port_serial; -extern struct port_interface port_i2c; - -static struct port_interface *ports[] = { - &port_serial, - &port_i2c, - NULL, -}; - - -port_err_t port_open(struct port_options *ops, struct port_interface **outport) -{ - int ret; - static struct port_interface **port; - - for (port = ports; *port; port++) { - ret = (*port)->open(*port, ops); - if (ret == PORT_ERR_NODEV) - continue; - if (ret == PORT_ERR_OK) - break; - fprintf(stderr, "Error probing interface \"%s\"\n", - (*port)->name); - } - if (*port == NULL) { - fprintf(stderr, "Cannot handle device \"%s\"\n", - ops->device); - return PORT_ERR_UNKNOWN; - } - - *outport = *port; - return PORT_ERR_OK; -} diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/port.h b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/port.h deleted file mode 100755 index 290f03496..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/port.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2014 Antonio Borneo - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_PORT -#define _H_PORT - -typedef enum { - PORT_ERR_OK = 0, - PORT_ERR_NODEV, /* No such device */ - PORT_ERR_TIMEDOUT, /* Operation timed out */ - PORT_ERR_UNKNOWN, -} port_err_t; - -/* flags */ -#define PORT_BYTE (1 << 0) /* byte (not frame) oriented */ -#define PORT_GVR_ETX (1 << 1) /* cmd GVR returns protection status */ -#define PORT_CMD_INIT (1 << 2) /* use INIT cmd to autodetect speed */ -#define PORT_RETRY (1 << 3) /* allowed read() retry after timeout */ -#define PORT_STRETCH_W (1 << 4) /* warning for no-stretching commands */ - -/* all options and flags used to open and configure an interface */ -struct port_options { - const char *device; - serial_baud_t baudRate; - const char *serial_mode; - int bus_addr; - int rx_frame_max; - int tx_frame_max; -}; - -/* - * Specify the length of reply for command GET - * This is helpful for frame-oriented protocols, e.g. i2c, to avoid time - * consuming try-fail-timeout-retry operation. - * On byte-oriented protocols, i.e. UART, this information would be skipped - * after read the first byte, so not needed. - */ -struct varlen_cmd { - uint8_t version; - uint8_t length; -}; - -struct port_interface { - const char *name; - unsigned flags; - port_err_t (*open)(struct port_interface *port, struct port_options *ops); - port_err_t (*close)(struct port_interface *port); - port_err_t (*read)(struct port_interface *port, void *buf, size_t nbyte); - port_err_t (*write)(struct port_interface *port, void *buf, size_t nbyte); - port_err_t (*gpio)(struct port_interface *port, serial_gpio_t n, int level); - const char *(*get_cfg_str)(struct port_interface *port); - struct varlen_cmd *cmd_get_reply; - void *private; -}; - -port_err_t port_open(struct port_options *ops, struct port_interface **outport); - -#endif diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/protocol.txt b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/protocol.txt deleted file mode 100755 index 039109908..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/protocol.txt +++ /dev/null @@ -1,19 +0,0 @@ -The communication protocol used by ST bootloader is documented in following ST -application notes, depending on communication port. - -In current version of stm32flash are supported only UART and I2C ports. - -* AN3154: CAN protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/CD00264321.pdf - -* AN3155: USART protocol used in the STM32(TM) bootloader - http://www.st.com/web/en/resource/technical/document/application_note/CD00264342.pdf - -* AN4221: I2C protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/DM00072315.pdf - -* AN4286: SPI protocol used in the STM32 bootloader - http://www.st.com/web/en/resource/technical/document/application_note/DM00081379.pdf - -Boot mode selection for STM32 is documented in ST application note AN2606, available in ST website: - http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial.h b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial.h deleted file mode 100755 index 227ba163b..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _SERIAL_H -#define _SERIAL_H - -typedef struct serial serial_t; - -typedef enum { - SERIAL_PARITY_NONE, - SERIAL_PARITY_EVEN, - SERIAL_PARITY_ODD, - - SERIAL_PARITY_INVALID -} serial_parity_t; - -typedef enum { - SERIAL_BITS_5, - SERIAL_BITS_6, - SERIAL_BITS_7, - SERIAL_BITS_8, - - SERIAL_BITS_INVALID -} serial_bits_t; - -typedef enum { - SERIAL_BAUD_1200, - SERIAL_BAUD_1800, - SERIAL_BAUD_2400, - SERIAL_BAUD_4800, - SERIAL_BAUD_9600, - SERIAL_BAUD_19200, - SERIAL_BAUD_38400, - SERIAL_BAUD_57600, - SERIAL_BAUD_115200, - SERIAL_BAUD_128000, - SERIAL_BAUD_230400, - SERIAL_BAUD_256000, - SERIAL_BAUD_460800, - SERIAL_BAUD_500000, - SERIAL_BAUD_576000, - SERIAL_BAUD_921600, - SERIAL_BAUD_1000000, - SERIAL_BAUD_1500000, - SERIAL_BAUD_2000000, - - SERIAL_BAUD_INVALID -} serial_baud_t; - -typedef enum { - SERIAL_STOPBIT_1, - SERIAL_STOPBIT_2, - - SERIAL_STOPBIT_INVALID -} serial_stopbit_t; - -typedef enum { - GPIO_RTS = 1, - GPIO_DTR, - GPIO_BRK, -} serial_gpio_t; - -/* common helper functions */ -serial_baud_t serial_get_baud(const unsigned int baud); -unsigned int serial_get_baud_int(const serial_baud_t baud); -serial_bits_t serial_get_bits(const char *mode); -unsigned int serial_get_bits_int(const serial_bits_t bits); -serial_parity_t serial_get_parity(const char *mode); -char serial_get_parity_str(const serial_parity_t parity); -serial_stopbit_t serial_get_stopbit(const char *mode); -unsigned int serial_get_stopbit_int(const serial_stopbit_t stopbit); - -#endif diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_common.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_common.c deleted file mode 100755 index 43e48e1ac..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_common.c +++ /dev/null @@ -1,154 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include "serial.h" - -serial_baud_t serial_get_baud(const unsigned int baud) { - switch(baud) { - case 1200: return SERIAL_BAUD_1200 ; - case 1800: return SERIAL_BAUD_1800 ; - case 2400: return SERIAL_BAUD_2400 ; - case 4800: return SERIAL_BAUD_4800 ; - case 9600: return SERIAL_BAUD_9600 ; - case 19200: return SERIAL_BAUD_19200 ; - case 38400: return SERIAL_BAUD_38400 ; - case 57600: return SERIAL_BAUD_57600 ; - case 115200: return SERIAL_BAUD_115200; - case 128000: return SERIAL_BAUD_128000; - case 230400: return SERIAL_BAUD_230400; - case 256000: return SERIAL_BAUD_256000; - case 460800: return SERIAL_BAUD_460800; - case 500000: return SERIAL_BAUD_500000; - case 576000: return SERIAL_BAUD_576000; - case 921600: return SERIAL_BAUD_921600; - case 1000000: return SERIAL_BAUD_1000000; - case 1500000: return SERIAL_BAUD_1500000; - case 2000000: return SERIAL_BAUD_2000000; - - default: - return SERIAL_BAUD_INVALID; - } -} - -unsigned int serial_get_baud_int(const serial_baud_t baud) { - switch(baud) { - case SERIAL_BAUD_1200 : return 1200 ; - case SERIAL_BAUD_1800 : return 1800 ; - case SERIAL_BAUD_2400 : return 2400 ; - case SERIAL_BAUD_4800 : return 4800 ; - case SERIAL_BAUD_9600 : return 9600 ; - case SERIAL_BAUD_19200 : return 19200 ; - case SERIAL_BAUD_38400 : return 38400 ; - case SERIAL_BAUD_57600 : return 57600 ; - case SERIAL_BAUD_115200: return 115200; - case SERIAL_BAUD_128000: return 128000; - case SERIAL_BAUD_230400: return 230400; - case SERIAL_BAUD_256000: return 256000; - case SERIAL_BAUD_460800: return 460800; - case SERIAL_BAUD_500000: return 500000; - case SERIAL_BAUD_576000: return 576000; - case SERIAL_BAUD_921600: return 921600; - case SERIAL_BAUD_1000000: return 1000000; - case SERIAL_BAUD_1500000: return 1500000; - case SERIAL_BAUD_2000000: return 2000000; - - case SERIAL_BAUD_INVALID: - default: - return 0; - } -} - -serial_bits_t serial_get_bits(const char *mode) { - if (!mode) - return SERIAL_BITS_INVALID; - switch(mode[0]) { - case '5': return SERIAL_BITS_5; - case '6': return SERIAL_BITS_6; - case '7': return SERIAL_BITS_7; - case '8': return SERIAL_BITS_8; - - default: - return SERIAL_BITS_INVALID; - } -} - -unsigned int serial_get_bits_int(const serial_bits_t bits) { - switch(bits) { - case SERIAL_BITS_5: return 5; - case SERIAL_BITS_6: return 6; - case SERIAL_BITS_7: return 7; - case SERIAL_BITS_8: return 8; - - default: - return 0; - } -} - -serial_parity_t serial_get_parity(const char *mode) { - if (!mode || !mode[0]) - return SERIAL_PARITY_INVALID; - switch(mode[1]) { - case 'N': - case 'n': - return SERIAL_PARITY_NONE; - case 'E': - case 'e': - return SERIAL_PARITY_EVEN; - case 'O': - case 'o': - return SERIAL_PARITY_ODD; - - default: - return SERIAL_PARITY_INVALID; - } -} - -char serial_get_parity_str(const serial_parity_t parity) { - switch(parity) { - case SERIAL_PARITY_NONE: return 'N'; - case SERIAL_PARITY_EVEN: return 'E'; - case SERIAL_PARITY_ODD : return 'O'; - - default: - return ' '; - } -} - -serial_stopbit_t serial_get_stopbit(const char *mode) { - if (!mode || !mode[0] || !mode[1]) - return SERIAL_STOPBIT_INVALID; - switch(mode[2]) { - case '1': return SERIAL_STOPBIT_1; - case '2': return SERIAL_STOPBIT_2; - - default: - return SERIAL_STOPBIT_INVALID; - } -} - -unsigned int serial_get_stopbit_int(const serial_stopbit_t stopbit) { - switch(stopbit) { - case SERIAL_STOPBIT_1: return 1; - case SERIAL_STOPBIT_2: return 2; - - default: - return 0; - } -} - diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_platform.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_platform.c deleted file mode 100755 index 98e256921..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_platform.c +++ /dev/null @@ -1,5 +0,0 @@ -#if defined(__WIN32__) || defined(__CYGWIN__) -# include "serial_w32.c" -#else -# include "serial_posix.c" -#endif diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_posix.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_posix.c deleted file mode 100755 index 284b35b20..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_posix.c +++ /dev/null @@ -1,395 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - -struct serial { - int fd; - struct termios oldtio; - struct termios newtio; - char setup_str[11]; -}; - -static serial_t *serial_open(const char *device) -{ - serial_t *h = calloc(sizeof(serial_t), 1); - - h->fd = open(device, O_RDWR | O_NOCTTY | O_NDELAY); - if (h->fd < 0) { - free(h); - return NULL; - } - fcntl(h->fd, F_SETFL, 0); - - tcgetattr(h->fd, &h->oldtio); - tcgetattr(h->fd, &h->newtio); - - return h; -} - -static void serial_flush(const serial_t *h) -{ - tcflush(h->fd, TCIFLUSH); -} - -static void serial_close(serial_t *h) -{ - serial_flush(h); - tcsetattr(h->fd, TCSANOW, &h->oldtio); - close(h->fd); - free(h); -} - -static port_err_t serial_setup(serial_t *h, const serial_baud_t baud, - const serial_bits_t bits, - const serial_parity_t parity, - const serial_stopbit_t stopbit) -{ - speed_t port_baud; - tcflag_t port_bits; - tcflag_t port_parity; - tcflag_t port_stop; - struct termios settings; - - switch (baud) { - case SERIAL_BAUD_1200: port_baud = B1200; break; - case SERIAL_BAUD_1800: port_baud = B1800; break; - case SERIAL_BAUD_2400: port_baud = B2400; break; - case SERIAL_BAUD_4800: port_baud = B4800; break; - case SERIAL_BAUD_9600: port_baud = B9600; break; - case SERIAL_BAUD_19200: port_baud = B19200; break; - case SERIAL_BAUD_38400: port_baud = B38400; break; - case SERIAL_BAUD_57600: port_baud = B57600; break; - case SERIAL_BAUD_115200: port_baud = B115200; break; - case SERIAL_BAUD_230400: port_baud = B230400; break; -#ifdef B460800 - case SERIAL_BAUD_460800: port_baud = B460800; break; -#endif /* B460800 */ -#ifdef B921600 - case SERIAL_BAUD_921600: port_baud = B921600; break; -#endif /* B921600 */ -#ifdef B500000 - case SERIAL_BAUD_500000: port_baud = B500000; break; -#endif /* B500000 */ -#ifdef B576000 - case SERIAL_BAUD_576000: port_baud = B576000; break; -#endif /* B576000 */ -#ifdef B1000000 - case SERIAL_BAUD_1000000: port_baud = B1000000; break; -#endif /* B1000000 */ -#ifdef B1500000 - case SERIAL_BAUD_1500000: port_baud = B1500000; break; -#endif /* B1500000 */ -#ifdef B2000000 - case SERIAL_BAUD_2000000: port_baud = B2000000; break; -#endif /* B2000000 */ - - case SERIAL_BAUD_INVALID: - default: - return PORT_ERR_UNKNOWN; - } - - switch (bits) { - case SERIAL_BITS_5: port_bits = CS5; break; - case SERIAL_BITS_6: port_bits = CS6; break; - case SERIAL_BITS_7: port_bits = CS7; break; - case SERIAL_BITS_8: port_bits = CS8; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (parity) { - case SERIAL_PARITY_NONE: port_parity = 0; break; - case SERIAL_PARITY_EVEN: port_parity = PARENB; break; - case SERIAL_PARITY_ODD: port_parity = PARENB | PARODD; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (stopbit) { - case SERIAL_STOPBIT_1: port_stop = 0; break; - case SERIAL_STOPBIT_2: port_stop = CSTOPB; break; - - default: - return PORT_ERR_UNKNOWN; - } - - /* reset the settings */ -#ifndef __sun /* Used by GNU and BSD. Ignore __SVR4 in test. */ - cfmakeraw(&h->newtio); -#else /* __sun */ - h->newtio.c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR - | IGNCR | ICRNL | IXON); - if (port_parity) - h->newtio.c_iflag |= INPCK; - - h->newtio.c_oflag &= ~OPOST; - h->newtio.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); - h->newtio.c_cflag &= ~(CSIZE | PARENB); - h->newtio.c_cflag |= CS8; -#endif /* __sun */ -#ifdef __QNXNTO__ - h->newtio.c_cflag &= ~(CSIZE | IHFLOW | OHFLOW); -#else - h->newtio.c_cflag &= ~(CSIZE | CRTSCTS); -#endif - h->newtio.c_cflag &= ~(CSIZE | CRTSCTS); - h->newtio.c_iflag &= ~(IXON | IXOFF | IXANY | IGNPAR); - h->newtio.c_lflag &= ~(ECHOK | ECHOCTL | ECHOKE); - h->newtio.c_oflag &= ~(OPOST | ONLCR); - - /* setup the new settings */ - cfsetispeed(&h->newtio, port_baud); - cfsetospeed(&h->newtio, port_baud); - h->newtio.c_cflag |= - port_parity | - port_bits | - port_stop | - CLOCAL | - CREAD; - - h->newtio.c_cc[VMIN] = 0; - h->newtio.c_cc[VTIME] = 5; /* in units of 0.1 s */ - - /* set the settings */ - serial_flush(h); - if (tcsetattr(h->fd, TCSANOW, &h->newtio) != 0) - return PORT_ERR_UNKNOWN; - -/* this check fails on CDC-ACM devices, bits 16 and 17 of cflag differ! - * it has been disabled below for now -jcw, 2015-11-09 - if (settings.c_cflag != h->newtio.c_cflag) - fprintf(stderr, "c_cflag mismatch %lx\n", - settings.c_cflag ^ h->newtio.c_cflag); - */ - - /* confirm they were set */ - tcgetattr(h->fd, &settings); - if (settings.c_iflag != h->newtio.c_iflag || - settings.c_oflag != h->newtio.c_oflag || - //settings.c_cflag != h->newtio.c_cflag || - settings.c_lflag != h->newtio.c_lflag) - return PORT_ERR_UNKNOWN; - - snprintf(h->setup_str, sizeof(h->setup_str), "%u %d%c%d", - serial_get_baud_int(baud), - serial_get_bits_int(bits), - serial_get_parity_str(parity), - serial_get_stopbit_int(stopbit)); - return PORT_ERR_OK; -} - -/* - * Roger clark. - * This function is no longer used. But has just been commented out in case it needs - * to be reinstated in the future - -static int startswith(const char *haystack, const char *needle) { - return strncmp(haystack, needle, strlen(needle)) == 0; -} -*/ - -static int is_tty(const char *path) { - char resolved[PATH_MAX]; - - if(!realpath(path, resolved)) return 0; - - - /* - * Roger Clark - * Commented out this check, because on OSX some devices are /dev/cu - * and some users use symbolic links to devices, hence the name may not even start - * with /dev - - if(startswith(resolved, "/dev/tty")) return 1; - - return 0; - */ - - return 1; -} - -static port_err_t serial_posix_open(struct port_interface *port, - struct port_options *ops) -{ - serial_t *h; - - /* 1. check device name match */ - if (!is_tty(ops->device)) - return PORT_ERR_NODEV; - - /* 2. check options */ - if (ops->baudRate == SERIAL_BAUD_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_bits(ops->serial_mode) == SERIAL_BITS_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_parity(ops->serial_mode) == SERIAL_PARITY_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_stopbit(ops->serial_mode) == SERIAL_STOPBIT_INVALID) - return PORT_ERR_UNKNOWN; - - /* 3. open it */ - h = serial_open(ops->device); - if (h == NULL) - return PORT_ERR_UNKNOWN; - - /* 4. set options */ - if (serial_setup(h, ops->baudRate, - serial_get_bits(ops->serial_mode), - serial_get_parity(ops->serial_mode), - serial_get_stopbit(ops->serial_mode) - ) != PORT_ERR_OK) { - serial_close(h); - return PORT_ERR_UNKNOWN; - } - - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t serial_posix_close(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - serial_close(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t serial_posix_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - ssize_t r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - r = read(h->fd, pos, nbyte); - if (r == 0) - return PORT_ERR_TIMEDOUT; - if (r < 0) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_posix_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - ssize_t r; - const uint8_t *pos = (const uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - r = write(h->fd, pos, nbyte); - if (r < 1) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_posix_gpio(struct port_interface *port, - serial_gpio_t n, int level) -{ - serial_t *h; - int bit, lines; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - switch (n) { - case GPIO_RTS: - bit = TIOCM_RTS; - break; - - case GPIO_DTR: - bit = TIOCM_DTR; - break; - - case GPIO_BRK: - if (level == 0) - return PORT_ERR_OK; - if (tcsendbreak(h->fd, 1)) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; - - default: - return PORT_ERR_UNKNOWN; - } - - /* handle RTS/DTR */ - if (ioctl(h->fd, TIOCMGET, &lines)) - return PORT_ERR_UNKNOWN; - lines = level ? lines | bit : lines & ~bit; - if (ioctl(h->fd, TIOCMSET, &lines)) - return PORT_ERR_UNKNOWN; - - return PORT_ERR_OK; -} - -static const char *serial_posix_get_cfg_str(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - return h ? h->setup_str : "INVALID"; -} - -struct port_interface port_serial = { - .name = "serial_posix", - .flags = PORT_BYTE | PORT_GVR_ETX | PORT_CMD_INIT | PORT_RETRY, - .open = serial_posix_open, - .close = serial_posix_close, - .read = serial_posix_read, - .write = serial_posix_write, - .gpio = serial_posix_gpio, - .get_cfg_str = serial_posix_get_cfg_str, -}; diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_w32.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_w32.c deleted file mode 100755 index 56772c0a0..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/serial_w32.c +++ /dev/null @@ -1,341 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - Copyright (C) 2010 Gareth McMullin - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "serial.h" -#include "port.h" - -struct serial { - HANDLE fd; - DCB oldtio; - DCB newtio; - char setup_str[11]; -}; - -static serial_t *serial_open(const char *device) -{ - serial_t *h = calloc(sizeof(serial_t), 1); - char *devName; - - /* timeout in ms */ - COMMTIMEOUTS timeouts = {MAXDWORD, MAXDWORD, 500, 0, 0}; - - /* Fix the device name if required */ - if (strlen(device) > 4 && device[0] != '\\') { - devName = calloc(1, strlen(device) + 5); - sprintf(devName, "\\\\.\\%s", device); - } else { - devName = (char *)device; - } - - /* Create file handle for port */ - h->fd = CreateFile(devName, GENERIC_READ | GENERIC_WRITE, - 0, /* Exclusive access */ - NULL, /* No security */ - OPEN_EXISTING, - 0, /* No overlap */ - NULL); - - if (devName != device) - free(devName); - - if (h->fd == INVALID_HANDLE_VALUE) { - if (GetLastError() == ERROR_FILE_NOT_FOUND) - fprintf(stderr, "File not found: %s\n", device); - return NULL; - } - - SetupComm(h->fd, 4096, 4096); /* Set input and output buffer size */ - - SetCommTimeouts(h->fd, &timeouts); - - SetCommMask(h->fd, EV_ERR); /* Notify us of error events */ - - GetCommState(h->fd, &h->oldtio); /* Retrieve port parameters */ - GetCommState(h->fd, &h->newtio); /* Retrieve port parameters */ - - /* PurgeComm(h->fd, PURGE_RXABORT | PURGE_TXCLEAR | PURGE_TXABORT | PURGE_TXCLEAR); */ - - return h; -} - -static void serial_flush(const serial_t *h) -{ - /* We shouldn't need to flush in non-overlapping (blocking) mode */ - /* tcflush(h->fd, TCIFLUSH); */ -} - -static void serial_close(serial_t *h) -{ - serial_flush(h); - SetCommState(h->fd, &h->oldtio); - CloseHandle(h->fd); - free(h); -} - -static port_err_t serial_setup(serial_t *h, - const serial_baud_t baud, - const serial_bits_t bits, - const serial_parity_t parity, - const serial_stopbit_t stopbit) -{ - switch (baud) { - case SERIAL_BAUD_1200: h->newtio.BaudRate = CBR_1200; break; - /* case SERIAL_BAUD_1800: h->newtio.BaudRate = CBR_1800; break; */ - case SERIAL_BAUD_2400: h->newtio.BaudRate = CBR_2400; break; - case SERIAL_BAUD_4800: h->newtio.BaudRate = CBR_4800; break; - case SERIAL_BAUD_9600: h->newtio.BaudRate = CBR_9600; break; - case SERIAL_BAUD_19200: h->newtio.BaudRate = CBR_19200; break; - case SERIAL_BAUD_38400: h->newtio.BaudRate = CBR_38400; break; - case SERIAL_BAUD_57600: h->newtio.BaudRate = CBR_57600; break; - case SERIAL_BAUD_115200: h->newtio.BaudRate = CBR_115200; break; - case SERIAL_BAUD_128000: h->newtio.BaudRate = CBR_128000; break; - case SERIAL_BAUD_256000: h->newtio.BaudRate = CBR_256000; break; - /* These are not defined in WinBase.h and might work or not */ - case SERIAL_BAUD_230400: h->newtio.BaudRate = 230400; break; - case SERIAL_BAUD_460800: h->newtio.BaudRate = 460800; break; - case SERIAL_BAUD_500000: h->newtio.BaudRate = 500000; break; - case SERIAL_BAUD_576000: h->newtio.BaudRate = 576000; break; - case SERIAL_BAUD_921600: h->newtio.BaudRate = 921600; break; - case SERIAL_BAUD_1000000: h->newtio.BaudRate = 1000000; break; - case SERIAL_BAUD_1500000: h->newtio.BaudRate = 1500000; break; - case SERIAL_BAUD_2000000: h->newtio.BaudRate = 2000000; break; - case SERIAL_BAUD_INVALID: - - default: - return PORT_ERR_UNKNOWN; - } - - switch (bits) { - case SERIAL_BITS_5: h->newtio.ByteSize = 5; break; - case SERIAL_BITS_6: h->newtio.ByteSize = 6; break; - case SERIAL_BITS_7: h->newtio.ByteSize = 7; break; - case SERIAL_BITS_8: h->newtio.ByteSize = 8; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (parity) { - case SERIAL_PARITY_NONE: h->newtio.Parity = NOPARITY; break; - case SERIAL_PARITY_EVEN: h->newtio.Parity = EVENPARITY; break; - case SERIAL_PARITY_ODD: h->newtio.Parity = ODDPARITY; break; - - default: - return PORT_ERR_UNKNOWN; - } - - switch (stopbit) { - case SERIAL_STOPBIT_1: h->newtio.StopBits = ONESTOPBIT; break; - case SERIAL_STOPBIT_2: h->newtio.StopBits = TWOSTOPBITS; break; - - default: - return PORT_ERR_UNKNOWN; - } - - /* reset the settings */ - h->newtio.fOutxCtsFlow = FALSE; - h->newtio.fOutxDsrFlow = FALSE; - h->newtio.fOutX = FALSE; - h->newtio.fInX = FALSE; - h->newtio.fNull = 0; - h->newtio.fAbortOnError = 0; - - /* set the settings */ - serial_flush(h); - if (!SetCommState(h->fd, &h->newtio)) - return PORT_ERR_UNKNOWN; - - snprintf(h->setup_str, sizeof(h->setup_str), "%u %d%c%d", - serial_get_baud_int(baud), - serial_get_bits_int(bits), - serial_get_parity_str(parity), - serial_get_stopbit_int(stopbit) - ); - return PORT_ERR_OK; -} - -static port_err_t serial_w32_open(struct port_interface *port, - struct port_options *ops) -{ - serial_t *h; - - /* 1. check device name match */ - if (!((strlen(ops->device) == 4 || strlen(ops->device) == 5) - && !strncmp(ops->device, "COM", 3) && isdigit(ops->device[3])) - && !(!strncmp(ops->device, "\\\\.\\COM", strlen("\\\\.\\COM")) - && isdigit(ops->device[strlen("\\\\.\\COM")]))) - return PORT_ERR_NODEV; - - /* 2. check options */ - if (ops->baudRate == SERIAL_BAUD_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_bits(ops->serial_mode) == SERIAL_BITS_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_parity(ops->serial_mode) == SERIAL_PARITY_INVALID) - return PORT_ERR_UNKNOWN; - if (serial_get_stopbit(ops->serial_mode) == SERIAL_STOPBIT_INVALID) - return PORT_ERR_UNKNOWN; - - /* 3. open it */ - h = serial_open(ops->device); - if (h == NULL) - return PORT_ERR_UNKNOWN; - - /* 4. set options */ - if (serial_setup(h, ops->baudRate, - serial_get_bits(ops->serial_mode), - serial_get_parity(ops->serial_mode), - serial_get_stopbit(ops->serial_mode) - ) != PORT_ERR_OK) { - serial_close(h); - return PORT_ERR_UNKNOWN; - } - - port->private = h; - return PORT_ERR_OK; -} - -static port_err_t serial_w32_close(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - serial_close(h); - port->private = NULL; - return PORT_ERR_OK; -} - -static port_err_t serial_w32_read(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - DWORD r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - ReadFile(h->fd, pos, nbyte, &r, NULL); - if (r == 0) - return PORT_ERR_TIMEDOUT; - if (r < 0) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_w32_write(struct port_interface *port, void *buf, - size_t nbyte) -{ - serial_t *h; - DWORD r; - uint8_t *pos = (uint8_t *)buf; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - while (nbyte) { - if (!WriteFile(h->fd, pos, nbyte, &r, NULL)) - return PORT_ERR_UNKNOWN; - if (r < 1) - return PORT_ERR_UNKNOWN; - - nbyte -= r; - pos += r; - } - return PORT_ERR_OK; -} - -static port_err_t serial_w32_gpio(struct port_interface *port, - serial_gpio_t n, int level) -{ - serial_t *h; - int bit; - - h = (serial_t *)port->private; - if (h == NULL) - return PORT_ERR_UNKNOWN; - - switch (n) { - case GPIO_RTS: - bit = level ? SETRTS : CLRRTS; - break; - - case GPIO_DTR: - bit = level ? SETDTR : CLRDTR; - break; - - case GPIO_BRK: - if (level == 0) - return PORT_ERR_OK; - if (EscapeCommFunction(h->fd, SETBREAK) == 0) - return PORT_ERR_UNKNOWN; - usleep(500000); - if (EscapeCommFunction(h->fd, CLRBREAK) == 0) - return PORT_ERR_UNKNOWN; - return PORT_ERR_OK; - - default: - return PORT_ERR_UNKNOWN; - } - - /* handle RTS/DTR */ - if (EscapeCommFunction(h->fd, bit) == 0) - return PORT_ERR_UNKNOWN; - - return PORT_ERR_OK; -} - -static const char *serial_w32_get_cfg_str(struct port_interface *port) -{ - serial_t *h; - - h = (serial_t *)port->private; - return h ? h->setup_str : "INVALID"; -} - -struct port_interface port_serial = { - .name = "serial_w32", - .flags = PORT_BYTE | PORT_GVR_ETX | PORT_CMD_INIT | PORT_RETRY, - .open = serial_w32_open, - .close = serial_w32_close, - .read = serial_w32_read, - .write = serial_w32_write, - .gpio = serial_w32_gpio, - .get_cfg_str = serial_w32_get_cfg_str, -}; diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/stm32.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/stm32.c deleted file mode 100755 index 74047d244..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/stm32.c +++ /dev/null @@ -1,1048 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright 2010 Geoffrey McRae - Copyright 2012-2014 Tormod Volden - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include -#include -#include -#include -#include - -#include "stm32.h" -#include "port.h" -#include "utils.h" - -#define STM32_ACK 0x79 -#define STM32_NACK 0x1F -#define STM32_BUSY 0x76 - -#define STM32_CMD_INIT 0x7F -#define STM32_CMD_GET 0x00 /* get the version and command supported */ -#define STM32_CMD_GVR 0x01 /* get version and read protection status */ -#define STM32_CMD_GID 0x02 /* get ID */ -#define STM32_CMD_RM 0x11 /* read memory */ -#define STM32_CMD_GO 0x21 /* go */ -#define STM32_CMD_WM 0x31 /* write memory */ -#define STM32_CMD_WM_NS 0x32 /* no-stretch write memory */ -#define STM32_CMD_ER 0x43 /* erase */ -#define STM32_CMD_EE 0x44 /* extended erase */ -#define STM32_CMD_EE_NS 0x45 /* extended erase no-stretch */ -#define STM32_CMD_WP 0x63 /* write protect */ -#define STM32_CMD_WP_NS 0x64 /* write protect no-stretch */ -#define STM32_CMD_UW 0x73 /* write unprotect */ -#define STM32_CMD_UW_NS 0x74 /* write unprotect no-stretch */ -#define STM32_CMD_RP 0x82 /* readout protect */ -#define STM32_CMD_RP_NS 0x83 /* readout protect no-stretch */ -#define STM32_CMD_UR 0x92 /* readout unprotect */ -#define STM32_CMD_UR_NS 0x93 /* readout unprotect no-stretch */ -#define STM32_CMD_CRC 0xA1 /* compute CRC */ -#define STM32_CMD_ERR 0xFF /* not a valid command */ - -#define STM32_RESYNC_TIMEOUT 35 /* seconds */ -#define STM32_MASSERASE_TIMEOUT 35 /* seconds */ -#define STM32_SECTERASE_TIMEOUT 5 /* seconds */ -#define STM32_BLKWRITE_TIMEOUT 1 /* seconds */ -#define STM32_WUNPROT_TIMEOUT 1 /* seconds */ -#define STM32_WPROT_TIMEOUT 1 /* seconds */ -#define STM32_RPROT_TIMEOUT 1 /* seconds */ - -#define STM32_CMD_GET_LENGTH 17 /* bytes in the reply */ - -struct stm32_cmd { - uint8_t get; - uint8_t gvr; - uint8_t gid; - uint8_t rm; - uint8_t go; - uint8_t wm; - uint8_t er; /* this may be extended erase */ - uint8_t wp; - uint8_t uw; - uint8_t rp; - uint8_t ur; - uint8_t crc; -}; - -/* Reset code for ARMv7-M (Cortex-M3) and ARMv6-M (Cortex-M0) - * see ARMv7-M or ARMv6-M Architecture Reference Manual (table B3-8) - * or "The definitive guide to the ARM Cortex-M3", section 14.4. - */ -static const uint8_t stm_reset_code[] = { - 0x01, 0x49, // ldr r1, [pc, #4] ; () - 0x02, 0x4A, // ldr r2, [pc, #8] ; () - 0x0A, 0x60, // str r2, [r1, #0] - 0xfe, 0xe7, // endless: b endless - 0x0c, 0xed, 0x00, 0xe0, // .word 0xe000ed0c = NVIC AIRCR register address - 0x04, 0x00, 0xfa, 0x05 // .word 0x05fa0004 = VECTKEY | SYSRESETREQ -}; - -static const uint32_t stm_reset_code_length = sizeof(stm_reset_code); - -extern const stm32_dev_t devices[]; - -static void stm32_warn_stretching(const char *f) -{ - fprintf(stderr, "Attention !!!\n"); - fprintf(stderr, "\tThis %s error could be caused by your I2C\n", f); - fprintf(stderr, "\tcontroller not accepting \"clock stretching\"\n"); - fprintf(stderr, "\tas required by bootloader.\n"); - fprintf(stderr, "\tCheck \"I2C.txt\" in stm32flash source code.\n"); -} - -static stm32_err_t stm32_get_ack_timeout(const stm32_t *stm, time_t timeout) -{ - struct port_interface *port = stm->port; - uint8_t byte; - port_err_t p_err; - time_t t0, t1; - - if (!(port->flags & PORT_RETRY)) - timeout = 0; - - if (timeout) - time(&t0); - - do { - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_TIMEDOUT && timeout) { - time(&t1); - if (t1 < t0 + timeout) - continue; - } - - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to read ACK byte\n"); - return STM32_ERR_UNKNOWN; - } - - if (byte == STM32_ACK) - return STM32_ERR_OK; - if (byte == STM32_NACK) - return STM32_ERR_NACK; - if (byte != STM32_BUSY) { - fprintf(stderr, "Got byte 0x%02x instead of ACK\n", - byte); - return STM32_ERR_UNKNOWN; - } - } while (1); -} - -static stm32_err_t stm32_get_ack(const stm32_t *stm) -{ - return stm32_get_ack_timeout(stm, 0); -} - -static stm32_err_t stm32_send_command_timeout(const stm32_t *stm, - const uint8_t cmd, - time_t timeout) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - port_err_t p_err; - uint8_t buf[2]; - - buf[0] = cmd; - buf[1] = cmd ^ 0xFF; - p_err = port->write(port, buf, 2); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send command\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, timeout); - if (s_err == STM32_ERR_OK) - return STM32_ERR_OK; - if (s_err == STM32_ERR_NACK) - fprintf(stderr, "Got NACK from device on command 0x%02x\n", cmd); - else - fprintf(stderr, "Unexpected reply from device on command 0x%02x\n", cmd); - return STM32_ERR_UNKNOWN; -} - -static stm32_err_t stm32_send_command(const stm32_t *stm, const uint8_t cmd) -{ - return stm32_send_command_timeout(stm, cmd, 0); -} - -/* if we have lost sync, send a wrong command and expect a NACK */ -static stm32_err_t stm32_resync(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - uint8_t buf[2], ack; - time_t t0, t1; - - time(&t0); - t1 = t0; - - buf[0] = STM32_CMD_ERR; - buf[1] = STM32_CMD_ERR ^ 0xFF; - while (t1 < t0 + STM32_RESYNC_TIMEOUT) { - p_err = port->write(port, buf, 2); - if (p_err != PORT_ERR_OK) { - usleep(500000); - time(&t1); - continue; - } - p_err = port->read(port, &ack, 1); - if (p_err != PORT_ERR_OK) { - time(&t1); - continue; - } - if (ack == STM32_NACK) - return STM32_ERR_OK; - time(&t1); - } - return STM32_ERR_UNKNOWN; -} - -/* - * some command receive reply frame with variable length, and length is - * embedded in reply frame itself. - * We can guess the length, but if we guess wrong the protocol gets out - * of sync. - * Use resync for frame oriented interfaces (e.g. I2C) and byte-by-byte - * read for byte oriented interfaces (e.g. UART). - * - * to run safely, data buffer should be allocated for 256+1 bytes - * - * len is value of the first byte in the frame. - */ -static stm32_err_t stm32_guess_len_cmd(const stm32_t *stm, uint8_t cmd, - uint8_t *data, unsigned int len) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - if (port->flags & PORT_BYTE) { - /* interface is UART-like */ - p_err = port->read(port, data, 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - len = data[0]; - p_err = port->read(port, data + 1, len + 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; - } - - p_err = port->read(port, data, len + 2); - if (p_err == PORT_ERR_OK && len == data[0]) - return STM32_ERR_OK; - if (p_err != PORT_ERR_OK) { - /* restart with only one byte */ - if (stm32_resync(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - p_err = port->read(port, data, 1); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - } - - fprintf(stderr, "Re sync (len = %d)\n", data[0]); - if (stm32_resync(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - len = data[0]; - if (stm32_send_command(stm, cmd) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - p_err = port->read(port, data, len + 2); - if (p_err != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; -} - -/* - * Some interface, e.g. UART, requires a specific init sequence to let STM32 - * autodetect the interface speed. - * The sequence is only required one time after reset. - * stm32flash has command line flag "-c" to prevent sending the init sequence - * in case it was already sent before. - * User can easily forget adding "-c". In this case the bootloader would - * interpret the init sequence as part of a command message, then waiting for - * the rest of the message blocking the interface. - * This function sends the init sequence and, in case of timeout, recovers - * the interface. - */ -static stm32_err_t stm32_send_init_seq(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - port_err_t p_err; - uint8_t byte, cmd = STM32_CMD_INIT; - - p_err = port->write(port, &cmd, 1); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send init to device\n"); - return STM32_ERR_UNKNOWN; - } - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_OK && byte == STM32_ACK) - return STM32_ERR_OK; - if (p_err == PORT_ERR_OK && byte == STM32_NACK) { - /* We could get error later, but let's continue, for now. */ - fprintf(stderr, - "Warning: the interface was not closed properly.\n"); - return STM32_ERR_OK; - } - if (p_err != PORT_ERR_TIMEDOUT) { - fprintf(stderr, "Failed to init device.\n"); - return STM32_ERR_UNKNOWN; - } - - /* - * Check if previous STM32_CMD_INIT was taken as first byte - * of a command. Send a new byte, we should get back a NACK. - */ - p_err = port->write(port, &cmd, 1); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Failed to send init to device\n"); - return STM32_ERR_UNKNOWN; - } - p_err = port->read(port, &byte, 1); - if (p_err == PORT_ERR_OK && byte == STM32_NACK) - return STM32_ERR_OK; - fprintf(stderr, "Failed to init device.\n"); - return STM32_ERR_UNKNOWN; -} - -/* find newer command by higher code */ -#define newer(prev, a) (((prev) == STM32_CMD_ERR) \ - ? (a) \ - : (((prev) > (a)) ? (prev) : (a))) - -stm32_t *stm32_init(struct port_interface *port, const char init) -{ - uint8_t len, val, buf[257]; - stm32_t *stm; - int i, new_cmds; - - stm = calloc(sizeof(stm32_t), 1); - stm->cmd = malloc(sizeof(stm32_cmd_t)); - memset(stm->cmd, STM32_CMD_ERR, sizeof(stm32_cmd_t)); - stm->port = port; - - if ((port->flags & PORT_CMD_INIT) && init) - if (stm32_send_init_seq(stm) != STM32_ERR_OK) - return NULL; - - /* get the version and read protection status */ - if (stm32_send_command(stm, STM32_CMD_GVR) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - /* From AN, only UART bootloader returns 3 bytes */ - len = (port->flags & PORT_GVR_ETX) ? 3 : 1; - if (port->read(port, buf, len) != PORT_ERR_OK) - return NULL; - stm->version = buf[0]; - stm->option1 = (port->flags & PORT_GVR_ETX) ? buf[1] : 0; - stm->option2 = (port->flags & PORT_GVR_ETX) ? buf[2] : 0; - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - /* get the bootloader information */ - len = STM32_CMD_GET_LENGTH; - if (port->cmd_get_reply) - for (i = 0; port->cmd_get_reply[i].length; i++) - if (stm->version == port->cmd_get_reply[i].version) { - len = port->cmd_get_reply[i].length; - break; - } - if (stm32_guess_len_cmd(stm, STM32_CMD_GET, buf, len) != STM32_ERR_OK) - return NULL; - len = buf[0] + 1; - stm->bl_version = buf[1]; - new_cmds = 0; - for (i = 1; i < len; i++) { - val = buf[i + 1]; - switch (val) { - case STM32_CMD_GET: - stm->cmd->get = val; break; - case STM32_CMD_GVR: - stm->cmd->gvr = val; break; - case STM32_CMD_GID: - stm->cmd->gid = val; break; - case STM32_CMD_RM: - stm->cmd->rm = val; break; - case STM32_CMD_GO: - stm->cmd->go = val; break; - case STM32_CMD_WM: - case STM32_CMD_WM_NS: - stm->cmd->wm = newer(stm->cmd->wm, val); - break; - case STM32_CMD_ER: - case STM32_CMD_EE: - case STM32_CMD_EE_NS: - stm->cmd->er = newer(stm->cmd->er, val); - break; - case STM32_CMD_WP: - case STM32_CMD_WP_NS: - stm->cmd->wp = newer(stm->cmd->wp, val); - break; - case STM32_CMD_UW: - case STM32_CMD_UW_NS: - stm->cmd->uw = newer(stm->cmd->uw, val); - break; - case STM32_CMD_RP: - case STM32_CMD_RP_NS: - stm->cmd->rp = newer(stm->cmd->rp, val); - break; - case STM32_CMD_UR: - case STM32_CMD_UR_NS: - stm->cmd->ur = newer(stm->cmd->ur, val); - break; - case STM32_CMD_CRC: - stm->cmd->crc = newer(stm->cmd->crc, val); - break; - default: - if (new_cmds++ == 0) - fprintf(stderr, - "GET returns unknown commands (0x%2x", - val); - else - fprintf(stderr, ", 0x%2x", val); - } - } - if (new_cmds) - fprintf(stderr, ")\n"); - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - if (stm->cmd->get == STM32_CMD_ERR - || stm->cmd->gvr == STM32_CMD_ERR - || stm->cmd->gid == STM32_CMD_ERR) { - fprintf(stderr, "Error: bootloader did not returned correct information from GET command\n"); - return NULL; - } - - /* get the device ID */ - if (stm32_guess_len_cmd(stm, stm->cmd->gid, buf, 1) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - len = buf[0] + 1; - if (len < 2) { - stm32_close(stm); - fprintf(stderr, "Only %d bytes sent in the PID, unknown/unsupported device\n", len); - return NULL; - } - stm->pid = (buf[1] << 8) | buf[2]; - if (len > 2) { - fprintf(stderr, "This bootloader returns %d extra bytes in PID:", len); - for (i = 2; i <= len ; i++) - fprintf(stderr, " %02x", buf[i]); - fprintf(stderr, "\n"); - } - if (stm32_get_ack(stm) != STM32_ERR_OK) { - stm32_close(stm); - return NULL; - } - - stm->dev = devices; - while (stm->dev->id != 0x00 && stm->dev->id != stm->pid) - ++stm->dev; - - if (!stm->dev->id) { - fprintf(stderr, "Unknown/unsupported device (Device ID: 0x%03x)\n", stm->pid); - stm32_close(stm); - return NULL; - } - - return stm; -} - -void stm32_close(stm32_t *stm) -{ - if (stm) - free(stm->cmd); - free(stm); -} - -stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address, - uint8_t data[], unsigned int len) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (!len) - return STM32_ERR_OK; - - if (len > 256) { - fprintf(stderr, "Error: READ length limit at 256 bytes\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->rm == STM32_CMD_ERR) { - fprintf(stderr, "Error: READ command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->rm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_send_command(stm, len - 1) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (port->read(port, data, len) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - return STM32_ERR_OK; -} - -stm32_err_t stm32_write_memory(const stm32_t *stm, uint32_t address, - const uint8_t data[], unsigned int len) -{ - struct port_interface *port = stm->port; - uint8_t cs, buf[256 + 2]; - unsigned int i, aligned_len; - stm32_err_t s_err; - - if (!len) - return STM32_ERR_OK; - - if (len > 256) { - fprintf(stderr, "Error: READ length limit at 256 bytes\n"); - return STM32_ERR_UNKNOWN; - } - - /* must be 32bit aligned */ - if (address & 0x3 || len & 0x3) { - fprintf(stderr, "Error: WRITE address and length must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->wm == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - /* send the address and checksum */ - if (stm32_send_command(stm, stm->cmd->wm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - aligned_len = (len + 3) & ~3; - cs = aligned_len - 1; - buf[0] = aligned_len - 1; - for (i = 0; i < len; i++) { - cs ^= data[i]; - buf[i + 1] = data[i]; - } - /* padding data */ - for (i = len; i < aligned_len; i++) { - cs ^= 0xFF; - buf[i + 1] = 0xFF; - } - buf[aligned_len + 1] = cs; - if (port->write(port, buf, aligned_len + 2) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_BLKWRITE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->wm != STM32_CMD_WM_NS) - stm32_warn_stretching("write"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_wunprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->uw == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE UNPROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->uw) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_WUNPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to WRITE UNPROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->uw != STM32_CMD_UW_NS) - stm32_warn_stretching("WRITE UNPROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_wprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->wp == STM32_CMD_ERR) { - fprintf(stderr, "Error: WRITE PROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->wp) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_WPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to WRITE PROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->wp != STM32_CMD_WP_NS) - stm32_warn_stretching("WRITE PROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_runprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->ur == STM32_CMD_ERR) { - fprintf(stderr, "Error: READOUT UNPROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->ur) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to READOUT UNPROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->ur != STM32_CMD_UR_NS) - stm32_warn_stretching("READOUT UNPROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_readprot_memory(const stm32_t *stm) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - - if (stm->cmd->rp == STM32_CMD_ERR) { - fprintf(stderr, "Error: READOUT PROTECT command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->rp) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - s_err = stm32_get_ack_timeout(stm, STM32_RPROT_TIMEOUT); - if (s_err == STM32_NACK) { - fprintf(stderr, "Error: Failed to READOUT PROTECT\n"); - return STM32_ERR_UNKNOWN; - } - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W - && stm->cmd->rp != STM32_CMD_RP_NS) - stm32_warn_stretching("READOUT PROTECT"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; -} - -stm32_err_t stm32_erase_memory(const stm32_t *stm, uint8_t spage, uint8_t pages) -{ - struct port_interface *port = stm->port; - stm32_err_t s_err; - port_err_t p_err; - - if (!pages) - return STM32_ERR_OK; - - if (stm->cmd->er == STM32_CMD_ERR) { - fprintf(stderr, "Error: ERASE command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->er) != STM32_ERR_OK) { - fprintf(stderr, "Can't initiate chip erase!\n"); - return STM32_ERR_UNKNOWN; - } - - /* The erase command reported by the bootloader is either 0x43, 0x44 or 0x45 */ - /* 0x44 is Extended Erase, a 2 byte based protocol and needs to be handled differently. */ - /* 0x45 is clock no-stretching version of Extended Erase for I2C port. */ - if (stm->cmd->er != STM32_CMD_ER) { - /* Not all chips using Extended Erase support mass erase */ - /* Currently known as not supporting mass erase is the Ultra Low Power STM32L15xx range */ - /* So if someone has not overridden the default, but uses one of these chips, take it out of */ - /* mass erase mode, so it will be done page by page. This maximum might not be correct either! */ - if (stm->pid == 0x416 && pages == 0xFF) - pages = 0xF8; /* works for the STM32L152RB with 128Kb flash */ - - if (pages == 0xFF) { - uint8_t buf[3]; - - /* 0xFFFF the magic number for mass erase */ - buf[0] = 0xFF; - buf[1] = 0xFF; - buf[2] = 0x00; /* checksum */ - if (port->write(port, buf, 3) != PORT_ERR_OK) { - fprintf(stderr, "Mass erase error.\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Mass erase failed. Try specifying the number of pages to be erased.\n"); - if (port->flags & PORT_STRETCH_W - && stm->cmd->er != STM32_CMD_EE_NS) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } - - uint16_t pg_num; - uint8_t pg_byte; - uint8_t cs = 0; - uint8_t *buf; - int i = 0; - - buf = malloc(2 + 2 * pages + 1); - if (!buf) - return STM32_ERR_UNKNOWN; - - /* Number of pages to be erased - 1, two bytes, MSB first */ - pg_byte = (pages - 1) >> 8; - buf[i++] = pg_byte; - cs ^= pg_byte; - pg_byte = (pages - 1) & 0xFF; - buf[i++] = pg_byte; - cs ^= pg_byte; - - for (pg_num = spage; pg_num < spage + pages; pg_num++) { - pg_byte = pg_num >> 8; - cs ^= pg_byte; - buf[i++] = pg_byte; - pg_byte = pg_num & 0xFF; - cs ^= pg_byte; - buf[i++] = pg_byte; - } - buf[i++] = cs; - p_err = port->write(port, buf, i); - free(buf); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Page-by-page erase error.\n"); - return STM32_ERR_UNKNOWN; - } - - s_err = stm32_get_ack_timeout(stm, pages * STM32_SECTERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - fprintf(stderr, "Page-by-page erase failed. Check the maximum pages your device supports.\n"); - if (port->flags & PORT_STRETCH_W - && stm->cmd->er != STM32_CMD_EE_NS) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - - return STM32_ERR_OK; - } - - /* And now the regular erase (0x43) for all other chips */ - if (pages == 0xFF) { - s_err = stm32_send_command_timeout(stm, 0xFF, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } else { - uint8_t cs = 0; - uint8_t pg_num; - uint8_t *buf; - int i = 0; - - buf = malloc(1 + pages + 1); - if (!buf) - return STM32_ERR_UNKNOWN; - - buf[i++] = pages - 1; - cs ^= (pages-1); - for (pg_num = spage; pg_num < (pages + spage); pg_num++) { - buf[i++] = pg_num; - cs ^= pg_num; - } - buf[i++] = cs; - p_err = port->write(port, buf, i); - free(buf); - if (p_err != PORT_ERR_OK) { - fprintf(stderr, "Erase failed.\n"); - return STM32_ERR_UNKNOWN; - } - s_err = stm32_get_ack_timeout(stm, STM32_MASSERASE_TIMEOUT); - if (s_err != STM32_ERR_OK) { - if (port->flags & PORT_STRETCH_W) - stm32_warn_stretching("erase"); - return STM32_ERR_UNKNOWN; - } - return STM32_ERR_OK; - } -} - -static stm32_err_t stm32_run_raw_code(const stm32_t *stm, - uint32_t target_address, - const uint8_t *code, uint32_t code_size) -{ - uint32_t stack_le = le_u32(0x20002000); - uint32_t code_address_le = le_u32(target_address + 8); - uint32_t length = code_size + 8; - uint8_t *mem, *pos; - uint32_t address, w; - - /* Must be 32-bit aligned */ - if (target_address & 0x3) { - fprintf(stderr, "Error: code address must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - mem = malloc(length); - if (!mem) - return STM32_ERR_UNKNOWN; - - memcpy(mem, &stack_le, sizeof(uint32_t)); - memcpy(mem + 4, &code_address_le, sizeof(uint32_t)); - memcpy(mem + 8, code, code_size); - - pos = mem; - address = target_address; - while (length > 0) { - w = length > 256 ? 256 : length; - if (stm32_write_memory(stm, address, pos, w) != STM32_ERR_OK) { - free(mem); - return STM32_ERR_UNKNOWN; - } - - address += w; - pos += w; - length -= w; - } - - free(mem); - return stm32_go(stm, target_address); -} - -stm32_err_t stm32_go(const stm32_t *stm, uint32_t address) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (stm->cmd->go == STM32_CMD_ERR) { - fprintf(stderr, "Error: GO command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->go) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - return STM32_ERR_OK; -} - -stm32_err_t stm32_reset_device(const stm32_t *stm) -{ - uint32_t target_address = stm->dev->ram_start; - - return stm32_run_raw_code(stm, target_address, stm_reset_code, stm_reset_code_length); -} - -stm32_err_t stm32_crc_memory(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc) -{ - struct port_interface *port = stm->port; - uint8_t buf[5]; - - if (address & 0x3 || length & 0x3) { - fprintf(stderr, "Start and end addresses must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->crc == STM32_CMD_ERR) { - fprintf(stderr, "Error: CRC command not implemented in bootloader.\n"); - return STM32_ERR_NO_CMD; - } - - if (stm32_send_command(stm, stm->cmd->crc) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = address >> 24; - buf[1] = (address >> 16) & 0xFF; - buf[2] = (address >> 8) & 0xFF; - buf[3] = address & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - buf[0] = length >> 24; - buf[1] = (length >> 16) & 0xFF; - buf[2] = (length >> 8) & 0xFF; - buf[3] = length & 0xFF; - buf[4] = buf[0] ^ buf[1] ^ buf[2] ^ buf[3]; - if (port->write(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (stm32_get_ack(stm) != STM32_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (port->read(port, buf, 5) != PORT_ERR_OK) - return STM32_ERR_UNKNOWN; - - if (buf[4] != (buf[0] ^ buf[1] ^ buf[2] ^ buf[3])) - return STM32_ERR_UNKNOWN; - - *crc = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; - return STM32_ERR_OK; -} - -/* - * CRC computed by STM32 is similar to the standard crc32_be() - * implemented, for example, in Linux kernel in ./lib/crc32.c - * But STM32 computes it on units of 32 bits word and swaps the - * bytes of the word before the computation. - * Due to byte swap, I cannot use any CRC available in existing - * libraries, so here is a simple not optimized implementation. - */ -#define CRCPOLY_BE 0x04c11db7 -#define CRC_MSBMASK 0x80000000 -#define CRC_INIT_VALUE 0xFFFFFFFF -uint32_t stm32_sw_crc(uint32_t crc, uint8_t *buf, unsigned int len) -{ - int i; - uint32_t data; - - if (len & 0x3) { - fprintf(stderr, "Buffer length must be multiple of 4 bytes\n"); - return 0; - } - - while (len) { - data = *buf++; - data |= *buf++ << 8; - data |= *buf++ << 16; - data |= *buf++ << 24; - len -= 4; - - crc ^= data; - - for (i = 0; i < 32; i++) - if (crc & CRC_MSBMASK) - crc = (crc << 1) ^ CRCPOLY_BE; - else - crc = (crc << 1); - } - return crc; -} - -stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc) -{ - uint8_t buf[256]; - uint32_t start, total_len, len, current_crc; - - if (address & 0x3 || length & 0x3) { - fprintf(stderr, "Start and end addresses must be 4 byte aligned\n"); - return STM32_ERR_UNKNOWN; - } - - if (stm->cmd->crc != STM32_CMD_ERR) - return stm32_crc_memory(stm, address, length, crc); - - start = address; - total_len = length; - current_crc = CRC_INIT_VALUE; - while (length) { - len = length > 256 ? 256 : length; - if (stm32_read_memory(stm, address, buf, len) != STM32_ERR_OK) { - fprintf(stderr, - "Failed to read memory at address 0x%08x, target write-protected?\n", - address); - return STM32_ERR_UNKNOWN; - } - current_crc = stm32_sw_crc(current_crc, buf, len); - length -= len; - address += len; - - fprintf(stderr, - "\rCRC address 0x%08x (%.2f%%) ", - address, - (100.0f / (float)total_len) * (float)(address - start) - ); - fflush(stderr); - } - fprintf(stderr, "Done.\n"); - *crc = current_crc; - return STM32_ERR_OK; -} diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/stm32.h b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/stm32.h deleted file mode 100755 index 1688fcb4b..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/stm32.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _STM32_H -#define _STM32_H - -#include -#include "serial.h" - -#define STM32_MAX_RX_FRAME 256 /* cmd read memory */ -#define STM32_MAX_TX_FRAME (1 + 256 + 1) /* cmd write memory */ - -typedef enum { - STM32_ERR_OK = 0, - STM32_ERR_UNKNOWN, /* Generic error */ - STM32_ERR_NACK, - STM32_ERR_NO_CMD, /* Command not available in bootloader */ -} stm32_err_t; - -typedef struct stm32 stm32_t; -typedef struct stm32_cmd stm32_cmd_t; -typedef struct stm32_dev stm32_dev_t; - -struct stm32 { - const serial_t *serial; - struct port_interface *port; - uint8_t bl_version; - uint8_t version; - uint8_t option1, option2; - uint16_t pid; - stm32_cmd_t *cmd; - const stm32_dev_t *dev; -}; - -struct stm32_dev { - uint16_t id; - const char *name; - uint32_t ram_start, ram_end; - uint32_t fl_start, fl_end; - uint16_t fl_pps; // pages per sector - uint16_t fl_ps; // page size - uint32_t opt_start, opt_end; - uint32_t mem_start, mem_end; -}; - -stm32_t *stm32_init(struct port_interface *port, const char init); -void stm32_close(stm32_t *stm); -stm32_err_t stm32_read_memory(const stm32_t *stm, uint32_t address, - uint8_t data[], unsigned int len); -stm32_err_t stm32_write_memory(const stm32_t *stm, uint32_t address, - const uint8_t data[], unsigned int len); -stm32_err_t stm32_wunprot_memory(const stm32_t *stm); -stm32_err_t stm32_wprot_memory(const stm32_t *stm); -stm32_err_t stm32_erase_memory(const stm32_t *stm, uint8_t spage, - uint8_t pages); -stm32_err_t stm32_go(const stm32_t *stm, uint32_t address); -stm32_err_t stm32_reset_device(const stm32_t *stm); -stm32_err_t stm32_readprot_memory(const stm32_t *stm); -stm32_err_t stm32_runprot_memory(const stm32_t *stm); -stm32_err_t stm32_crc_memory(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc); -stm32_err_t stm32_crc_wrapper(const stm32_t *stm, uint32_t address, - uint32_t length, uint32_t *crc); -uint32_t stm32_sw_crc(uint32_t crc, uint8_t *buf, unsigned int len); - -#endif - diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/stm32flash.1 b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/stm32flash.1 deleted file mode 100755 index d37292f6a..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/stm32flash.1 +++ /dev/null @@ -1,407 +0,0 @@ -.TH STM32FLASH 1 "2013\-11\-03" STM32FLASH "User command" -.SH NAME -stm32flash \- flashing utility for STM32 and STM32W through UART or I2C -.SH SYNOPSIS -.B stm32flash -.RB [ \-cfhjkouvCR ] -.RB [ \-a -.IR bus_address ] -.RB [ \-b -.IR baud_rate ] -.RB [ \-m -.IR serial_mode ] -.RB [ \-r -.IR filename ] -.RB [ \-w -.IR filename ] -.RB [ \-e -.IR num ] -.RB [ \-n -.IR count ] -.RB [ \-g -.IR address ] -.RB [ \-s -.IR start_page ] -.RB [ \-S -.IR address [: length ]] -.RB [ \-F -.IR RX_length [: TX_length ]] -.RB [ \-i -.IR GPIO_string ] -.RI [ tty_device -.R | -.IR i2c_device ] - -.SH DESCRIPTION -.B stm32flash -reads or writes the flash memory of STM32 and STM32W. - -It requires the STM32[W] to embed a bootloader compliant with ST -application note AN3155. -.B stm32flash -uses the serial port -.I tty_device -to interact with the bootloader of STM32[W]. - -.SH OPTIONS -.TP -.BI "\-a" " bus_address" -Specify address on bus for -.IR i2c_device . -This option is mandatory for I2C interface. - -.TP -.BI "\-b" " baud_rate" -Specify baud rate speed of -.IR tty_device . -Please notice that the ST bootloader can automatically detect the baud rate, -as explaned in chapter 2 of AN3155. -This option could be required together with option -.B "\-c" -or if following interaction with bootloader is expected. -Default is -.IR 57600 . - -.TP -.BI "\-m" " mode" -Specify the format of UART data. -.I mode -is a three characters long string where each character specifies, in -this strict order, character size, parity and stop bits. -The only values currenly used are -.I 8e1 -for standard STM32 bootloader and -.I 8n1 -for standard STM32W bootloader. -Default is -.IR 8e1 . - -.TP -.BI "\-r" " filename" -Specify to read the STM32[W] flash and write its content in -.I filename -in raw binary format (see below -.BR "FORMAT CONVERSION" ). - -.TP -.BI "\-w" " filename" -Specify to write the STM32[W] flash with the content of -.IR filename . -File format can be either raw binary or intel hex (see below -.BR "FORMAT CONVERSION" ). -The file format is automatically detected. -To by\-pass format detection and force binary mode (e.g. to -write an intel hex content in STM32[W] flash), use -.B \-f -option. - -.TP -.B \-u -Specify to disable write\-protection from STM32[W] flash. -The STM32[W] will be reset after this operation. - -.TP -.B \-j -Enable the flash read\-protection. - -.TP -.B \-k -Disable the flash read\-protection. - -.TP -.B \-o -Erase only. - -.TP -.BI "\-e" " num" -Specify to erase only -.I num -pages before writing the flash. Default is to erase the whole flash. With -.B \-e 0 -the flash would not be erased. - -.TP -.B \-v -Specify to verify flash content after write operation. - -.TP -.BI "\-n" " count" -Specify to retry failed writes up to -.I count -times. Default is 10 times. - -.TP -.BI "\-g" " address" -Specify address to start execution from (0 = flash start). - -.TP -.BI "\-s" " start_page" -Specify flash page offset (0 = flash start). - -.TP -.BI "\-S" " address" "[:" "length" "]" -Specify start address and optionally length for read/write/erase/crc operations. - -.TP -.BI "\-F" " RX_length" "[:" "TX_length" "]" -Specify the maximum frame size for the current interface. -Due to STM32 bootloader protocol, host will never handle frames bigger than -256 byte in RX or 258 byte in TX. -Due to current code, lowest limit in RX is 20 byte (to read a complete reply -of command GET). Minimum limit in TX is 5 byte, required by protocol. - -.TP -.B \-f -Force binary parser while reading file with -.BR "\-w" "." - -.TP -.B \-h -Show help. - -.TP -.B \-c -Specify to resume the existing UART connection and don't send initial -INIT sequence to detect baud rate. Baud rate must be kept the same as the -existing connection. This is useful if the reset fails. - -.TP -.BI "\-i" " GPIO_string" -Specify the GPIO sequences on the host to force STM32[W] to enter and -exit bootloader mode. GPIO can either be real GPIO connected from host to -STM32[W] beside the UART connection, or UART's modem signals used as -GPIO. (See below -.B BOOTLOADER GPIO SEQUENCE -for the format of -.I GPIO_string -and further explanation). - -.TP -.B \-C -Specify to compute CRC on memory content. -By default the CRC is computed on the whole flash content. -Use -.B "\-S" -to provide different memory address range. - -.TP -.B \-R -Specify to reset the device at exit. -This option is ignored if either -.BR "\-g" "," -.BR "\-j" "," -.B "\-k" -or -.B "\-u" -is also specified. - -.SH BOOTLOADER GPIO SEQUENCE -This feature is currently available on Linux host only. - -As explained in ST application note AN2606, after reset the STM32 will -execute either the application program in user flash or the bootloader, -depending on the level applied at specific pins of STM32 during reset. - -STM32 bootloader is automatically activated by configuring the pins -BOOT0="high" and BOOT1="low" and then by applying a reset. -Application program in user flash is activated by configuring the pin -BOOT0="low" (the level on BOOT1 is ignored) and then by applying a reset. - -When GPIO from host computer are connected to either configuration and -reset pins of STM32, -.B stm32flash -can control the host GPIO to reset STM32 and to force execution of -bootloader or execution of application program. - -The sequence of GPIO values to entry to and exit from bootloader mode is -provided with command line option -.B "\-i" -.IR "GPIO_string" . - -.PD 0 -The format of -.IR "GPIO_string" " is:" -.RS -GPIO_string = [entry sequence][:[exit sequence]] -.P -sequence = [\-]n[,sequence] -.RE -.P -In the above sequences, negative numbers correspond to GPIO at "low" level; -numbers without sign correspond to GPIO at "high" level. -The value "n" can either be the GPIO number on the host system or the -string "rts", "dtr" or "brk". The strings "rts" and "dtr" drive the -corresponding UART's modem lines RTS and DTR as GPIO. -The string "brk" forces the UART to send a BREAK sequence on TX line; -after BREAK the UART is returned in normal "non\-break" mode. -Note: the string "\-brk" has no effect and is ignored. -.PD - -.PD 0 -As example, let's suppose the following connection between host and STM32: -.IP \(bu 2 -host GPIO_3 connected to reset pin of STM32; -.IP \(bu 2 -host GPIO_4 connected to STM32 pin BOOT0; -.IP \(bu 2 -host GPIO_5 connected to STM32 pin BOOT1. -.PD -.P - -In this case, the sequence to enter in bootloader mode is: first put -GPIO_4="high" and GPIO_5="low"; then send reset pulse by GPIO_3="low" -followed by GPIO_3="high". -The corresponding string for -.I GPIO_string -is "4,\-5,\-3,3". - -To exit from bootloade and run the application program, the sequence is: -put GPIO_4="low"; then send reset pulse. -The corresponding string for -.I GPIO_string -is "\-4,\-3,3". - -The complete command line flag is "\-i 4,\-5,\-3,3:\-4,\-3,3". - -STM32W uses pad PA5 to select boot mode; if during reset PA5 is "low" then -STM32W will enter in bootloader mode; if PA5 is "high" it will execute the -program in flash. - -As example, supposing GPIO_3 connected to PA5 and GPIO_2 to STM32W's reset. -The command: -.PD 0 -.RS -stm32flash \-i \-3,\-2,2:3,\-2,2 /dev/ttyS0 -.RE -provides: -.IP \(bu 2 -entry sequence: GPIO_3=low, GPIO_2=low, GPIO_2=high -.IP \(bu 2 -exit sequence: GPIO_3=high, GPIO_2=low, GPIO_2=high -.PD - -.SH EXAMPLES -Get device information: -.RS -.PD 0 -.P -stm32flash /dev/ttyS0 -.PD -.RE - -Write with verify and then start execution: -.RS -.PD 0 -.P -stm32flash \-w filename \-v \-g 0x0 /dev/ttyS0 -.PD -.RE - -Read flash to file: -.RS -.PD 0 -.P -stm32flash \-r filename /dev/ttyS0 -.PD -.RE - -Start execution: -.RS -.PD 0 -.P -stm32flash \-g 0x0 /dev/ttyS0 -.PD -.RE - -Specify: -.PD 0 -.IP \(bu 2 -entry sequence: RTS=low, DTR=low, DTR=high -.IP \(bu 2 -exit sequence: RTS=high, DTR=low, DTR=high -.P -.RS -stm32flash \-i \-rts,\-dtr,dtr:rts,\-dtr,dtr /dev/ttyS0 -.PD -.RE - -.SH FORMAT CONVERSION -Flash images provided by ST or created with ST tools are often in file -format Motorola S\-Record. -Conversion between raw binary, intel hex and Motorola S\-Record can be -done through software package SRecord. - -.SH AUTHORS -The original software package -.B stm32flash -is written by -.I Geoffrey McRae -and is since 2012 maintained by -.IR "Tormod Volden " . - -Man page and extension to STM32W and I2C are written by -.IR "Antonio Borneo " . - -Please report any bugs at the project homepage -http://stm32flash.googlecode.com . - -.SH SEE ALSO -.BR "srec_cat" "(1)," " srec_intel" "(5)," " srec_motorola" "(5)." - -The communication protocol used by ST bootloader is documented in -following ST application notes, depending on communication port. -The current version of -.B stm32flash -only supports -.I UART -and -.I I2C -ports. -.PD 0 -.P -.IP \(bu 2 -AN3154: CAN protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/CD00264321.pdf -.RE - -.P -.IP \(bu 2 -AN3155: USART protocol used in the STM32(TM) bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/CD00264342.pdf -.RE - -.P -.IP \(bu 2 -AN4221: I2C protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/DM00072315.pdf -.RE - -.P -.IP \(bu 2 -AN4286: SPI protocol used in the STM32 bootloader -.P -.RS -http://www.st.com/web/en/resource/technical/document/application_note/DM00081379.pdf -.RE - -.PD - - -Boot mode selection for STM32 is documented in ST application note -AN2606, available from the ST website: -.PD 0 -.P -http://www.st.com/web/en/resource/technical/document/application_note/CD00167594.pdf -.PD - -.SH LICENSE -.B stm32flash -is distributed under GNU GENERAL PUBLIC LICENSE Version 2. -Copy of the license is available within the source code in the file -.IR "gpl\-2.0.txt" . diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/utils.c b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/utils.c deleted file mode 100755 index 271bb3ed7..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/utils.c +++ /dev/null @@ -1,45 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - -#include -#include "utils.h" - -/* detect CPU endian */ -char cpu_le() { - const uint32_t cpu_le_test = 0x12345678; - return ((const unsigned char*)&cpu_le_test)[0] == 0x78; -} - -uint32_t be_u32(const uint32_t v) { - if (cpu_le()) - return ((v & 0xFF000000) >> 24) | - ((v & 0x00FF0000) >> 8) | - ((v & 0x0000FF00) << 8) | - ((v & 0x000000FF) << 24); - return v; -} - -uint32_t le_u32(const uint32_t v) { - if (!cpu_le()) - return ((v & 0xFF000000) >> 24) | - ((v & 0x00FF0000) >> 8) | - ((v & 0x0000FF00) << 8) | - ((v & 0x000000FF) << 24); - return v; -} diff --git a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/utils.h b/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/utils.h deleted file mode 100755 index a8d37d2d5..000000000 --- a/arduino/opencr_arduino/tools/win/src/stm32flash_serial/src/utils.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - stm32flash - Open Source ST STM32 flash program for *nix - Copyright (C) 2010 Geoffrey McRae - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -*/ - - -#ifndef _H_UTILS -#define _H_UTILS - -#include - -char cpu_le(); -uint32_t be_u32(const uint32_t v); -uint32_t le_u32(const uint32_t v); - -#endif diff --git a/arduino/opencr_arduino/tools/win/src/upload-reset/upload-reset.c b/arduino/opencr_arduino/tools/win/src/upload-reset/upload-reset.c deleted file mode 100755 index 1d03bff51..000000000 --- a/arduino/opencr_arduino/tools/win/src/upload-reset/upload-reset.c +++ /dev/null @@ -1,161 +0,0 @@ -/* Copyright (C) 2015 Roger Clark - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * - * Utility to send the reset sequence on RTS and DTR and chars - * which resets the libmaple and causes the bootloader to be run - * - * - * - * Terminal control code by Heiko Noordhof (see copyright below) - */ - - - -/* Copyright (C) 2003 Heiko Noordhof - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* Function prototypes (belong in a seperate header file) */ -int openserial(char *devicename); -void closeserial(void); -int setDTR(unsigned short level); -int setRTS(unsigned short level); - - -/* Two globals for use by this module only */ -static int fd; -static struct termios oldterminfo; - - -void closeserial(void) -{ - tcsetattr(fd, TCSANOW, &oldterminfo); - close(fd); -} - - -int openserial(char *devicename) -{ - struct termios attr; - - if ((fd = open(devicename, O_RDWR)) == -1) return 0; /* Error */ - atexit(closeserial); - - if (tcgetattr(fd, &oldterminfo) == -1) return 0; /* Error */ - attr = oldterminfo; - attr.c_cflag |= CRTSCTS | CLOCAL; - attr.c_oflag = 0; - if (tcflush(fd, TCIOFLUSH) == -1) return 0; /* Error */ - if (tcsetattr(fd, TCSANOW, &attr) == -1) return 0; /* Error */ - - /* Set the lines to a known state, and */ - /* finally return non-zero is successful. */ - return setRTS(0) && setDTR(0); -} - - -/* For the two functions below: - * level=0 to set line to LOW - * level=1 to set line to HIGH - */ - -int setRTS(unsigned short level) -{ - int status; - - if (ioctl(fd, TIOCMGET, &status) == -1) { - perror("setRTS(): TIOCMGET"); - return 0; - } - if (level) status |= TIOCM_RTS; - else status &= ~TIOCM_RTS; - if (ioctl(fd, TIOCMSET, &status) == -1) { - perror("setRTS(): TIOCMSET"); - return 0; - } - return 1; -} - - -int setDTR(unsigned short level) -{ - int status; - - if (ioctl(fd, TIOCMGET, &status) == -1) { - perror("setDTR(): TIOCMGET"); - return 0; - } - if (level) status |= TIOCM_DTR; - else status &= ~TIOCM_DTR; - if (ioctl(fd, TIOCMSET, &status) == -1) { - perror("setDTR: TIOCMSET"); - return 0; - } - return 1; -} - -/* This portion of code was written by Roger Clark - * It was informed by various other pieces of code written by Leaflabs to reset their - * Maple and Maple mini boards - */ - -main(int argc, char *argv[]) -{ - - if (argc<2 || argc >3) - { - printf("Usage upload-reset \n\r"); - return; - } - - if (openserial(argv[1])) - { - // Send magic sequence of DTR and RTS followed by the magic word "1EAF" - setRTS(false); - setDTR(false); - setDTR(true); - - usleep(50000L); - - setDTR(false); - setRTS(true); - setDTR(true); - - usleep(50000L); - - setDTR(false); - - usleep(50000L); - - write(fd,"1EAF",4); - - closeserial(); - if (argc==3) - { - usleep(atol(argv[2])*1000L); - } - } - else - { - printf("Failed to open serial device.\n\r"); - } -} diff --git a/arduino/opencr_arduino/tools/win/stlink/Docs/STLINK Utility.pdf b/arduino/opencr_arduino/tools/win/stlink/Docs/STLINK Utility.pdf deleted file mode 100755 index c9cf4c3d9..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/Docs/STLINK Utility.pdf and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/Docs/STLink_UM.pdf b/arduino/opencr_arduino/tools/win/stlink/Docs/STLink_UM.pdf deleted file mode 100755 index 2c659bd86..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/Docs/STLink_UM.pdf and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/Docs/UM1075.pdf b/arduino/opencr_arduino/tools/win/stlink/Docs/UM1075.pdf deleted file mode 100755 index 8a34a8949..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/Docs/UM1075.pdf and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/Docs/license.txt b/arduino/opencr_arduino/tools/win/stlink/Docs/license.txt deleted file mode 100755 index e18b63ff5..000000000 --- a/arduino/opencr_arduino/tools/win/stlink/Docs/license.txt +++ /dev/null @@ -1,58 +0,0 @@ -SOFTWARE LICENSE AGREEMENT - - -By using this Licensed Software, You are agreeing to be bound by the terms and conditions of this License Agreement. Do not use the Licensed Software until You have read and agreed to the following terms and conditions. The use of the Licensed Software implies automatically the acceptance of the following terms and conditions. Please indicate your acceptance or NON-acceptance by selecting 'I ACCEPT' or 'I DO NOT ACCEPT' as indicated below in the media. - -DEFINITIONS. - -Licensed Software: means the enclosed SOFTWARE LIBRARY, EXAMPLES, PROJECT TEMPLATE and all the related documentation and design tools licensed in the form of object and/or source code as the case maybe. - -Product: means a product or a system that includes or incorporates solely and exclusively an executable version of the Licensed Software and provided further that such Licensed Software executes solely and exclusively on STM32 microcontrollers devices manufactured by or for ST. - -LICENSE. -STMicroelectronics (ST) grants You a non-exclusive, worldwide, non-transferable (whether by assignment or otherwise) non sub-licensable, revocable, royalty-free limited license of the Licensed Software to: -(i) make copies, prepare derivatives works, of the source code version of the Licensed Software for the sole and exclusive purpose of developing executable versions (in object and source code) of such Licensed Software only for use with the Product; -(ii) make copies, prepare derivatives works of the object code versions of the Licensed Software for the sole purpose of designing, developing and manufacturing the Products; -(iii) make, use, sell, offer to sell, lease, hire out, import and export or otherwise distribute Products. - - -OWNERSHIP AND COPYRIGHT. Title to the Licensed Software, related documentation and all copies thereof remain with ST and/or its licensors. You may not remove the copyrights notices from the Licensed Software and to any copies of the Licensed Software. You agree to prevent any unauthorized copying of the Licensed Software and related documentation. - - -RESTRICTIONS. Unless otherwise explicitly stated in this Agreement, You may not sell, assign, sublicense, lease, rent or otherwise distribute the Licensed Software for commercial purposes, in whole or in part. - -You acknowledge and agree that any use, adaptation translation or transcription of the Licensed Software or any portion or derivative thereof, for use with processors manufactured by or for an entity other than ST is a material breach of this Agreement and requires a separate license from ST. - -No source code and/or object code relating to and/or based upon Licensed Software is to be made available by You unless expressly permitted under the section 'License'. - -You acknowledge and agree that the protection of the source code of the Licensed Software warrants the imposition of reasonable security precautions -In the event ST demonstrates to You a reasonable belief that the source code of the Licensed Software has been used or distributed in violation of this Agreement, ST may by written notification request certification as to whether such unauthorized use or distribution has occurred. You shall cooperate and assist ST in its determination of whether there has been unauthorized use or distribution of the source code of the Licensed Software and will take appropriate steps to remedy any unauthorized use or distribution. - -NO WARRANTY. The Licensed Software is provided 'as is' and 'with all faults' without warranty of any kind expressed or implied. ST and its licensors expressly disclaim all warranties, expressed, implied or otherwise, including without limitation, warranties of merchantability, fitness for a particular purpose and non-infringement of intellectual property rights. ST does not warrant that the use in whole or in part of the Licensed Software will be interrupted or error free, will meet your requirements, or will operate with the combination of hardware and software selected by You. - -You are responsible for determining whether the Licensed Software will be suitable for your intended use or application or will achieve your intended results. - -ST has not authorized anyone to make any representation or warranty for the Licensed Software, and any technical, applications or design information or advice, quality characterization, reliability data or other services provided by ST shall not constitute any representation or warranty by ST or alter this disclaimer or warranty, and in no additional obligations or liabilities shall arise from STs providing such information or services. ST does not assume or authorize any other person to assume for it any other liability in connection with its Licensed Software. - -Nothing contained in this Agreement will be construed as -(i) a warranty or representation by ST to maintain production of any ST device or other hardware or software with which the Licensed Software may be used or to otherwise maintain or support the Licensed Software in any manner; and -(ii) a commitment from ST and/or its licensors to bring or prosecute actions or suits against third parties for infringement of any of the rights licensed hereby, or conferring any rights to bring or prosecute actions or suits against third parties for infringement. However, ST has the right to terminate this Agreement immediately upon receiving notice of any claim, suit or proceeding that alleges that the Licensed Software or your use or distribution of the Licensed Software infringes any third party intellectual property rights. - -All other warranties, conditions or other terms implied by law are excluded to the fullest extent permitted by law. - -LIMITATION OF LIABILITIES. In no event ST or its licensors shall be liable to You or any third party for any indirect, special, consequential, incidental, punitive damages or other damages (including but not limited to, the cost of labour, re-qualification, delay, loss of profits, loss of revenues, loss of data, costs of procurement of substitute goods or services or the like) whether based on contract, tort, or any other legal theory, relating to or in connection with the Licensed Software, the documentation or this Agreement, even if ST has been advised of the possibility of such damages. - -In no event shall STs liability to You or any third party under this Agreement, including any claim with respect of any third party intellectual property rights, for any cause of action exceed 100 US$. This section does not apply to the extent prohibited by law. For the purposes of this section, any liability of ST shall be treated in the aggregate. - -TERMINATION. ST may terminate this License Agreement license at any time if You are in material breach of any of its terms and conditions. Upon termination, You will immediately destroy or return all copies of the Licensed Software and documentation to ST. - - -APPLICABLE LAW AND JURISDICTION. In case of dispute and in the absence of an amicable settlement, the only competent jurisdiction shall be the Courts of Geneva, Switzerland. The applicable law shall be the law of Switzerland. - - -SEVERABILITY. If any provision of this agreement is or becomes, at any time or for any reason, unenforceable or invalid, no other provision of this agreement shall be affected thereby, and the remaining provisions of this agreement shall continue with the same force and effect as if such unenforceable or invalid provisions had not been inserted in this Agreement. - - -WAIVER. The waiver by either party of any breach of any provisions of this Agreement shall not operate or be construed as a waiver of any other or a subsequent breach of the same or a different provision. - -RELATIONSHIP OF THE PARTIES. Nothing in this Agreement shall create, or be deemed to create, a partnership or the relationship of principal and agent or employer and employee between the Parties. Neither Party has the authority or power to bind, to contract in the name of or to create a liability for the other in any way or for any purpose. diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x410.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x410.stldr deleted file mode 100755 index cf034faf9..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x410.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x411.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x411.stldr deleted file mode 100755 index 3967e6a2f..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x411.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x412.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x412.stldr deleted file mode 100755 index 83f6adbb4..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x412.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x413.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x413.stldr deleted file mode 100755 index 54cd56591..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x413.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x414.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x414.stldr deleted file mode 100755 index ac9e117e3..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x414.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x415.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x415.stldr deleted file mode 100755 index 12a05f02f..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x415.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x416.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x416.stldr deleted file mode 100755 index fab670e41..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x416.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x417.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x417.stldr deleted file mode 100755 index f9fafc0fa..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x417.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x418.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x418.stldr deleted file mode 100755 index 94b420499..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x418.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x419.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x419.stldr deleted file mode 100755 index 6e22d66b5..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x419.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x419_DB1M_On.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x419_DB1M_On.stldr deleted file mode 100755 index 9d9e0c351..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x419_DB1M_On.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x420.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x420.stldr deleted file mode 100755 index 3d361c306..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x420.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x421.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x421.stldr deleted file mode 100755 index ccdeafd80..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x421.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x422.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x422.stldr deleted file mode 100755 index 49f2dbb3a..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x422.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x423.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x423.stldr deleted file mode 100755 index ef0f67de9..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x423.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x425.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x425.stldr deleted file mode 100755 index 7e8f10d21..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x425.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x427.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x427.stldr deleted file mode 100755 index ea4bbb635..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x427.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x428.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x428.stldr deleted file mode 100755 index 75c46067c..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x428.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x429.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x429.stldr deleted file mode 100755 index 38b0199d1..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x429.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x430.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x430.stldr deleted file mode 100755 index 8372b59ed..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x430.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x431.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x431.stldr deleted file mode 100755 index 5a901dcda..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x431.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x432.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x432.stldr deleted file mode 100755 index a3de2a6d2..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x432.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x433.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x433.stldr deleted file mode 100755 index c88598adf..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x433.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x434.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x434.stldr deleted file mode 100755 index 9f956ec0e..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x434.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x434_DB1M_On.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x434_DB1M_On.stldr deleted file mode 100755 index 1cf4ac4d5..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x434_DB1M_On.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x436.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x436.stldr deleted file mode 100755 index 27d26c82b..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x436.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x437.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x437.stldr deleted file mode 100755 index 3183baf5f..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x437.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x438.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x438.stldr deleted file mode 100755 index 8dd027a08..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x438.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x439.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x439.stldr deleted file mode 100755 index f64c4b1ff..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x439.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x440.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x440.stldr deleted file mode 100755 index eb4b92ec5..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x440.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x442.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x442.stldr deleted file mode 100755 index 14f068ff3..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x442.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x444.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x444.stldr deleted file mode 100755 index 9f8fcf577..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x444.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x445.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x445.stldr deleted file mode 100755 index 4047c3fbe..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x445.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x446.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x446.stldr deleted file mode 100755 index 0e8ce6b14..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x446.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x447.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x447.stldr deleted file mode 100755 index c4ce5ac21..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x447.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x448.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x448.stldr deleted file mode 100755 index 8f2a32626..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x448.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x449.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x449.stldr deleted file mode 100755 index 78efc83c4..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x449.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x9A8.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x9A8.stldr deleted file mode 100755 index c673d821c..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x9A8.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x9B0.stldr b/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x9B0.stldr deleted file mode 100755 index f917e5b55..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/FlashLoader/0x9B0.stldr and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_VCP.inf b/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_VCP.inf deleted file mode 100755 index 209c3c2da..000000000 --- a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_VCP.inf +++ /dev/null @@ -1,74 +0,0 @@ - -; -; Installs the Virtual COM port interface of ST-Link based composite devices. -; - -[Version] -Signature = "$Windows NT$" -Class = Ports -ClassGUID = {4D36E978-E325-11CE-BFC1-08002BE10318} -Provider = %ManufacturerName% -CatalogFile.NTx86 = STLinkVCP_x86.cat -CatalogFile.NTAMD64 = STLinkVCP_x64.cat -DriverVer=12/10/2013,1.0 - -; ========== Manufacturer/Models sections =========== - -[Manufacturer] -%ManufacturerName% = Standard,NTx86,NTamd64 - -; List of devices supporting the Virtual COM port (with the corresponding interface ID) -[Standard.NTx86] -%DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_374A&MI_02 -%DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_374B&MI_02 -%DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_374C&MI_01 - -[Standard.NTamd64] -%DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_374A&MI_02 -%DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_374B&MI_02 -%DeviceNameVCP% =USB_InstallVCP, USB\VID_0483&PID_374C&MI_01 - -; ========== Class definition =========== - -[ClassInstall32] -AddReg = ClassInstall_AddReg - -[ClassInstall_AddReg] -HKR,,,,%ClassName% -HKR,,NoInstallClass,,1 -HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%\system32\setupapi.dll,-20" -HKR,,LowerLogoVersion,,5.2 - -; =================== Installation =================== - -[USB_InstallVCP] -Include = mdmcpq.inf -CopyFiles = FakeModemCopyFileSection -AddReg = USB_InstallVCP.AddReg - -[USB_InstallVCP.AddReg] -HKR,,DevLoader,,*ntkern -HKR,,NTMPDriver,,usbser.sys -HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" - -[USB_InstallVCP.Services] -AddService=usbser, 0x00000002, DriverService - -[DriverService] -DisplayName=%DeviceNameVCP% -ServiceType=1 -StartType=3 -ErrorControl=1 -ServiceBinary=%12%\usbser.sys - -; [DestinationDirs] -; If your INF needs to copy files, you must not use the DefaultDestDir directive here. -; You must explicitly reference all file-list-section names in this section. - -; =================== Strings =================== - -[Strings] -ManufacturerName="STMicroelectronics" -ClassName="Universal Serial Bus devices" -DeviceNameVCP="STMicroelectronics STLink Virtual COM Port" -REG_MULTI_SZ = 0x00010000 diff --git a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_dbg_winusb.inf b/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_dbg_winusb.inf deleted file mode 100755 index 18b3dfd3a..000000000 --- a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_dbg_winusb.inf +++ /dev/null @@ -1,120 +0,0 @@ -; -; Installation INF for the STMicroelectronics STLINK for Windows XP SP2 or later. -; - -[Version] -Signature = "$Windows NT$" -Class = STLinkWinUSB -ClassGUID = {88BAE032-5A81-49f0-BC3D-A4FF138216D6} -Provider = %ManufacturerName% -CatalogFile.NTx86 = STLinkDbgWinUSB_x86.cat -CatalogFile.NTAMD64 = STLinkDbgWinUSB_x64.cat -DriverVer=12/10/2013,1.01 - -; ========== Manufacturer/Models sections =========== - -[Manufacturer] -%ManufacturerName% = Standard,NTx86,NTamd64 - -[Standard.NTx86] -%DeviceName% =USB_Install, USB\VID_0483&PID_3748 -%DeviceName% =USB_Install, USB\VID_0483&PID_374A&MI_00 -%DeviceName% =USB_Install, USB\VID_0483&PID_374B&MI_00 -%DeviceNameRW% =USB_InstallRW, USB\VID_0483&PID_374A&MI_01 - -[Standard.NTamd64] -%DeviceName% =USB_Install, USB\VID_0483&PID_3748 -%DeviceName% =USB_Install, USB\VID_0483&PID_374A&MI_00 -%DeviceName% =USB_Install, USB\VID_0483&PID_374B&MI_00 -%DeviceNameRW% =USB_InstallRW, USB\VID_0483&PID_374A&MI_01 - -; ========== Class definition =========== - -[ClassInstall32] -AddReg = ClassInstall_AddReg - -[ClassInstall_AddReg] -HKR,,,,%ClassName% -HKR,,NoInstallClass,,1 -HKR,,IconPath,%REG_MULTI_SZ%,"%systemroot%\system32\setupapi.dll,-20" -HKR,,LowerLogoVersion,,5.2 - -; =================== Installation =================== - -[USB_Install] -Include = winusb.inf -Needs = WINUSB.NT - -[USB_InstallRW] -Include = winusb.inf -Needs = WINUSB.NT - -[USB_Install.Services] -Include =winusb.inf -Addservice = WinUSB, 0x00000002, WinUSB_ServiceInstall - -[USB_InstallRW.Services] -Include =winusb.inf -Addservice = WinUSB, 0x00000002, WinUSB_ServiceInstall - -[WinUSB_ServiceInstall] -DisplayName = %WinUSB_SvcDesc% -ServiceType = 1 ; SERVICE_KERNEL_DRIVER -StartType = 3 ; SERVICE_DEMAND_START -ErrorControl = 1 ; SERVICE_ERROR_NORMAL -ServiceBinary = %12%\WinUSB.sys - -[USB_Install.Wdf] -KmdfService=WINUSB, WinUsb_Install - -[USB_InstallRW.Wdf] -KmdfService=WINUSB, WinUsb_Install - -[WinUsb_Install] -KmdfLibraryVersion=1.9 - -[WinUsb_InstallRW] -KmdfLibraryVersion=1.9 - -[USB_Install.HW] -AddReg=Dev_AddReg - -[USB_InstallRW.HW] -AddReg=Dev_AddRegRW - -[Dev_AddReg] -HKR,,DeviceInterfaceGUIDs,0x10000,%STLink_GUID% - -[Dev_AddRegRW] -HKR,,DeviceInterfaceGUIDs,0x10000,%STLink_GUID_RW% - -[USB_Install.CoInstallers] -AddReg=CoInstallers_AddReg -%11%/WinUSBCoInstaller2.dll -%11%/WdfCoInstaller01009.dll - -[USB_InstallRW.CoInstallers] -AddReg=CoInstallers_AddReg -%11%/WinUSBCoInstaller2.dll -%11%/WdfCoInstaller01009.dll - -[CoInstallers_AddReg] -HKR,,CoInstallers32,0x00010000,"WdfCoInstaller01009.dll,WdfCoInstaller","WinUSBCoInstaller2.dll" - -; [DestinationDirs] -; If your INF needs to copy files, you must not use the DefaultDestDir directive here. -; You must explicitly reference all file-list-section names in this section. - -; =================== Strings =================== - -[Strings] -ManufacturerName="STMicroelectronics" -ClassName="Universal Serial Bus devices" -DeviceName="STMicroelectronics STLink dongle" -DeviceNameRW="STMicroelectronics STLink dongle RW" -WinUSB_SvcDesc="WinUSB Driver for STLink" -REG_MULTI_SZ = 0x00010000 - -;------------Replace GUID below with custom GUID-------------; -STLink_GUID="{DBCE1CD9-A320-4b51-A365-A0C3F3C5FB29}" -STLink_GUID_RW="{8326506F-7260-4854-9C03-26E416F04494}" diff --git a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_winusb_install.bat b/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_winusb_install.bat deleted file mode 100755 index 59a3090cc..000000000 --- a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_winusb_install.bat +++ /dev/null @@ -1,8 +0,0 @@ -@echo off -if "%PROCESSOR_ARCHITEW6432%" == "AMD64" goto X64 -if "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto X64 -start "" dpinst_x86.exe -goto END -:X64 -start "" dpinst_amd64.exe -:END diff --git a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_winusb_uninstall.bat b/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_winusb_uninstall.bat deleted file mode 100755 index 5f91323fc..000000000 --- a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlink_winusb_uninstall.bat +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -if "%PROCESSOR_ARCHITECTURE%"=="x86" goto X86 -dpinst_amd64.exe /u stlink_dbg_winusb.inf -dpinst_amd64.exe /u stlink_VCP.inf -goto END -:X86 -dpinst_x86.exe /u stlink_dbg_winusb.inf -dpinst_x86.exe /u stlink_VCP.inf -:END diff --git a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkdbgwinusb_x64.cat b/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkdbgwinusb_x64.cat deleted file mode 100755 index 2c04b7bfa..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkdbgwinusb_x64.cat and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkdbgwinusb_x86.cat b/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkdbgwinusb_x86.cat deleted file mode 100755 index 2f3e80e2e..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkdbgwinusb_x86.cat and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkvcp_x64.cat b/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkvcp_x64.cat deleted file mode 100755 index e7252bd85..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkvcp_x64.cat and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkvcp_x86.cat b/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkvcp_x86.cat deleted file mode 100755 index c76a573da..000000000 Binary files a/arduino/opencr_arduino/tools/win/stlink/ST-LINK_USB_V2_Driver/stlinkvcp_x86.cat and /dev/null differ diff --git a/arduino/opencr_arduino/tools/win/stlink/readme.md b/arduino/opencr_arduino/tools/win/stlink/readme.md deleted file mode 100755 index 5ec3fcbcc..000000000 --- a/arduino/opencr_arduino/tools/win/stlink/readme.md +++ /dev/null @@ -1,66 +0,0 @@ -STLink software is copyright STMicroelectronics - -See docs/license.txt - also shown below... - - - -SOFTWARE LICENSE AGREEMENT - - -By using this Licensed Software, You are agreeing to be bound by the terms and conditions of this License Agreement. Do not use the Licensed Software until You have read and agreed to the following terms and conditions. The use of the Licensed Software implies automatically the acceptance of the following terms and conditions. Please indicate your acceptance or NON-acceptance by selecting 'I ACCEPT' or 'I DO NOT ACCEPT' as indicated below in the media. - -DEFINITIONS. - -Licensed Software: means the enclosed SOFTWARE LIBRARY, EXAMPLES, PROJECT TEMPLATE and all the related documentation and design tools licensed in the form of object and/or source code as the case maybe. - -Product: means a product or a system that includes or incorporates solely and exclusively an executable version of the Licensed Software and provided further that such Licensed Software executes solely and exclusively on STM32 microcontrollers devices manufactured by or for ST. - -LICENSE. -STMicroelectronics (ST) grants You a non-exclusive, worldwide, non-transferable (whether by assignment or otherwise) non sub-licensable, revocable, royalty-free limited license of the Licensed Software to: -(i) make copies, prepare derivatives works, of the source code version of the Licensed Software for the sole and exclusive purpose of developing executable versions (in object and source code) of such Licensed Software only for use with the Product; -(ii) make copies, prepare derivatives works of the object code versions of the Licensed Software for the sole purpose of designing, developing and manufacturing the Products; -(iii) make, use, sell, offer to sell, lease, hire out, import and export or otherwise distribute Products. - - -OWNERSHIP AND COPYRIGHT. Title to the Licensed Software, related documentation and all copies thereof remain with ST and/or its licensors. You may not remove the copyrights notices from the Licensed Software and to any copies of the Licensed Software. You agree to prevent any unauthorized copying of the Licensed Software and related documentation. - - -RESTRICTIONS. Unless otherwise explicitly stated in this Agreement, You may not sell, assign, sublicense, lease, rent or otherwise distribute the Licensed Software for commercial purposes, in whole or in part. - -You acknowledge and agree that any use, adaptation translation or transcription of the Licensed Software or any portion or derivative thereof, for use with processors manufactured by or for an entity other than ST is a material breach of this Agreement and requires a separate license from ST. - -No source code and/or object code relating to and/or based upon Licensed Software is to be made available by You unless expressly permitted under the section 'License'. - -You acknowledge and agree that the protection of the source code of the Licensed Software warrants the imposition of reasonable security precautions -In the event ST demonstrates to You a reasonable belief that the source code of the Licensed Software has been used or distributed in violation of this Agreement, ST may by written notification request certification as to whether such unauthorized use or distribution has occurred. You shall cooperate and assist ST in its determination of whether there has been unauthorized use or distribution of the source code of the Licensed Software and will take appropriate steps to remedy any unauthorized use or distribution. - -NO WARRANTY. The Licensed Software is provided 'as is' and 'with all faults' without warranty of any kind expressed or implied. ST and its licensors expressly disclaim all warranties, expressed, implied or otherwise, including without limitation, warranties of merchantability, fitness for a particular purpose and non-infringement of intellectual property rights. ST does not warrant that the use in whole or in part of the Licensed Software will be interrupted or error free, will meet your requirements, or will operate with the combination of hardware and software selected by You. - -You are responsible for determining whether the Licensed Software will be suitable for your intended use or application or will achieve your intended results. - -ST has not authorized anyone to make any representation or warranty for the Licensed Software, and any technical, applications or design information or advice, quality characterization, reliability data or other services provided by ST shall not constitute any representation or warranty by ST or alter this disclaimer or warranty, and in no additional obligations or liabilities shall arise from ST’s providing such information or services. ST does not assume or authorize any other person to assume for it any other liability in connection with its Licensed Software. - -Nothing contained in this Agreement will be construed as -(i) a warranty or representation by ST to maintain production of any ST device or other hardware or software with which the Licensed Software may be used or to otherwise maintain or support the Licensed Software in any manner; and -(ii) a commitment from ST and/or its licensors to bring or prosecute actions or suits against third parties for infringement of any of the rights licensed hereby, or conferring any rights to bring or prosecute actions or suits against third parties for infringement. However, ST has the right to terminate this Agreement immediately upon receiving notice of any claim, suit or proceeding that alleges that the Licensed Software or your use or distribution of the Licensed Software infringes any third party intellectual property rights. - -All other warranties, conditions or other terms implied by law are excluded to the fullest extent permitted by law. - -LIMITATION OF LIABILITIES. In no event ST or its licensors shall be liable to You or any third party for any indirect, special, consequential, incidental, punitive damages or other damages (including but not limited to, the cost of labour, re-qualification, delay, loss of profits, loss of revenues, loss of data, costs of procurement of substitute goods or services or the like) whether based on contract, tort, or any other legal theory, relating to or in connection with the Licensed Software, the documentation or this Agreement, even if ST has been advised of the possibility of such damages. - -In no event shall ST’s liability to You or any third party under this Agreement, including any claim with respect of any third party intellectual property rights, for any cause of action exceed 100 US$. This section does not apply to the extent prohibited by law. For the purposes of this section, any liability of ST shall be treated in the aggregate. - -TERMINATION. ST may terminate this License Agreement license at any time if You are in material breach of any of its terms and conditions. Upon termination, You will immediately destroy or return all copies of the Licensed Software and documentation to ST. - - -APPLICABLE LAW AND JURISDICTION. In case of dispute and in the absence of an amicable settlement, the only competent jurisdiction shall be the Courts of Geneva, Switzerland. The applicable law shall be the law of Switzerland. - - -SEVERABILITY. If any provision of this agreement is or becomes, at any time or for any reason, unenforceable or invalid, no other provision of this agreement shall be affected thereby, and the remaining provisions of this agreement shall continue with the same force and effect as if such unenforceable or invalid provisions had not been inserted in this Agreement. - - -WAIVER. The waiver by either party of any breach of any provisions of this Agreement shall not operate or be construed as a waiver of any other or a subsequent breach of the same or a different provision. - -RELATIONSHIP OF THE PARTIES. Nothing in this Agreement shall create, or be deemed to create, a partnership or the relationship of principal and agent or employer and employee between the Parties. Neither Party has the authority or power to bind, to contract in the name of or to create a liability for the other in any way or for any purpose. - - diff --git a/arduino/opencr_arduino/tools/win/stlink_upload.bat b/arduino/opencr_arduino/tools/win/stlink_upload.bat deleted file mode 100755 index 160fcdf81..000000000 --- a/arduino/opencr_arduino/tools/win/stlink_upload.bat +++ /dev/null @@ -1,17 +0,0 @@ -@echo off -rem: Note %~dp0 get path of this batch file -rem: Need to change drive if My Documents is on a drive other than C: -set driverLetter=%~dp0 -set driverLetter=%driverLetter:~0,2% -%driverLetter% -cd %~dp0 -rem: the two line below are needed to fix path issues with incorrect slashes before the bin file name -set str=%4 -set str=%str:/=\% - - -rem: ------------- use STLINK CLI -stlink\ST-LINK_CLI.exe -c SWD -P %str% 0x8000000 -Rst -Run - -rem: Using the open source texane-stlink instead of the proprietary STM stlink exe -rem:texane-stlink\st-flash.exe write %str% 0x8000000 \ No newline at end of file diff --git a/arduino/opencr_arduino/tools/win/stm32loader.py b/arduino/opencr_arduino/tools/win/stm32loader.py deleted file mode 100755 index 72602bbc5..000000000 --- a/arduino/opencr_arduino/tools/win/stm32loader.py +++ /dev/null @@ -1,537 +0,0 @@ -#!/usr/bin/env python - -# -*- coding: utf-8 -*- -# vim: sw=4:ts=4:si:et:enc=utf-8 - -# Author: Ivan A-R -# Project page: http://tuxotronic.org/wiki/projects/stm32loader -# -# This file is part of stm32loader. -# -# stm32loader is free software; you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free -# Software Foundation; either version 3, or (at your option) any later -# version. -# -# stm32loader is distributed in the hope that it will be useful, but WITHOUT ANY -# WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with stm32loader; see the file COPYING3. If not see -# . - -from __future__ import print_function - -import sys, getopt -import serial -import time -import glob -import time -import tempfile -import os -import subprocess - -try: - from progressbar import * - usepbar = 1 -except: - usepbar = 0 - -# Verbose level -QUIET = 5 - -def mdebug(level, message): - if QUIET >= level: - print(message, file=sys.stderr) - -# Takes chip IDs (obtained via Get ID command) to human-readable names -CHIP_ID_STRS = {0x410: 'STM32F1, performance, medium-density', - 0x411: 'STM32F2', - 0x412: 'STM32F1, performance, low-density', - 0x413: 'STM32F4', - 0x414: 'STM32F1, performance, high-density', - 0x416: 'STM32L1, performance, medium-density', - 0x418: 'STM32F1, connectivity', - 0x420: 'STM32F1, value, medium-density', - 0x428: 'STM32F1, value, high-density', - 0x430: 'STM32F1, performance, XL-density'} - -class CmdException(Exception): - pass - -class CommandInterface(object): - def open(self, aport='/dev/tty.usbserial-FTD3TMCH', abaudrate=115200) : - self.sp = serial.Serial( - port=aport, - baudrate=abaudrate, # baudrate - bytesize=8, # number of databits - parity=serial.PARITY_EVEN, - stopbits=1, - xonxoff=0, # enable software flow control - rtscts=0, # disable RTS/CTS flow control - timeout=0.5 # set a timeout value, None for waiting forever - ) - - - def _wait_for_ack(self, info="", timeout=0): - stop = time.time() + timeout - got = None - while not got: - got = self.sp.read(1) - if time.time() > stop: - break - - if not got: - raise CmdException("No response to %s" % info) - - # wait for ask - ask = ord(got) - - if ask == 0x79: - # ACK - return 1 - elif ask == 0x1F: - # NACK - raise CmdException("Chip replied with a NACK during %s" % info) - - # Unknown response - raise CmdException("Unrecognised response 0x%x to %s" % (ask, info)) - - def reset(self): - self.sp.setDTR(0) - time.sleep(0.1) - self.sp.setDTR(1) - time.sleep(0.5) - - def initChip(self): - # Set boot - self.sp.setRTS(0) - self.reset() - - # Be a bit more persistent when trying to initialise the chip - stop = time.time() + 5.0 - - while time.time() <= stop: - self.sp.write('\x7f') - - got = self.sp.read() - - # The chip will ACK a sync the very first time and - # NACK it every time afterwards - if got and got in '\x79\x1f': - # Synced up - return - - raise CmdException('No response while trying to sync') - - def releaseChip(self): - self.sp.setRTS(1) - self.reset() - - def cmdGeneric(self, cmd): - self.sp.write(chr(cmd)) - self.sp.write(chr(cmd ^ 0xFF)) # Control byte - return self._wait_for_ack(hex(cmd)) - - def cmdGet(self): - if self.cmdGeneric(0x00): - mdebug(10, "*** Get command"); - len = ord(self.sp.read()) - version = ord(self.sp.read()) - mdebug(10, " Bootloader version: "+hex(version)) - dat = map(lambda c: hex(ord(c)), self.sp.read(len)) - mdebug(10, " Available commands: "+str(dat)) - self._wait_for_ack("0x00 end") - return version - else: - raise CmdException("Get (0x00) failed") - - def cmdGetVersion(self): - if self.cmdGeneric(0x01): - mdebug(10, "*** GetVersion command") - version = ord(self.sp.read()) - self.sp.read(2) - self._wait_for_ack("0x01 end") - mdebug(10, " Bootloader version: "+hex(version)) - return version - else: - raise CmdException("GetVersion (0x01) failed") - - def cmdGetID(self): - if self.cmdGeneric(0x02): - mdebug(10, "*** GetID command") - len = ord(self.sp.read()) - id = self.sp.read(len+1) - self._wait_for_ack("0x02 end") - return id - else: - raise CmdException("GetID (0x02) failed") - - - def _encode_addr(self, addr): - byte3 = (addr >> 0) & 0xFF - byte2 = (addr >> 8) & 0xFF - byte1 = (addr >> 16) & 0xFF - byte0 = (addr >> 24) & 0xFF - crc = byte0 ^ byte1 ^ byte2 ^ byte3 - return (chr(byte0) + chr(byte1) + chr(byte2) + chr(byte3) + chr(crc)) - - - def cmdReadMemory(self, addr, lng): - assert(lng <= 256) - if self.cmdGeneric(0x11): - mdebug(10, "*** ReadMemory command") - self.sp.write(self._encode_addr(addr)) - self._wait_for_ack("0x11 address failed") - N = (lng - 1) & 0xFF - crc = N ^ 0xFF - self.sp.write(chr(N) + chr(crc)) - self._wait_for_ack("0x11 length failed") - return map(lambda c: ord(c), self.sp.read(lng)) - else: - raise CmdException("ReadMemory (0x11) failed") - - - def cmdGo(self, addr): - if self.cmdGeneric(0x21): - mdebug(10, "*** Go command") - self.sp.write(self._encode_addr(addr)) - self._wait_for_ack("0x21 go failed") - else: - raise CmdException("Go (0x21) failed") - - - def cmdWriteMemory(self, addr, data): - assert(len(data) <= 256) - if self.cmdGeneric(0x31): - mdebug(10, "*** Write memory command") - self.sp.write(self._encode_addr(addr)) - self._wait_for_ack("0x31 address failed") - #map(lambda c: hex(ord(c)), data) - lng = (len(data)-1) & 0xFF - mdebug(10, " %s bytes to write" % [lng+1]); - self.sp.write(chr(lng)) # len really - crc = 0xFF - for c in data: - crc = crc ^ c - self.sp.write(chr(c)) - self.sp.write(chr(crc)) - self._wait_for_ack("0x31 programming failed") - mdebug(10, " Write memory done") - else: - raise CmdException("Write memory (0x31) failed") - - - def cmdEraseMemory(self, sectors = None): - if self.cmdGeneric(0x43): - mdebug(10, "*** Erase memory command") - if sectors is None: - # Global erase - self.sp.write(chr(0xFF)) - self.sp.write(chr(0x00)) - else: - # Sectors erase - self.sp.write(chr((len(sectors)-1) & 0xFF)) - crc = 0xFF - for c in sectors: - crc = crc ^ c - self.sp.write(chr(c)) - self.sp.write(chr(crc)) - self._wait_for_ack("0x43 erasing failed") - mdebug(10, " Erase memory done") - else: - raise CmdException("Erase memory (0x43) failed") - - - # TODO support for non-global mass erase - GLOBAL_ERASE_TIMEOUT_SECONDS = 20 # This takes a while - def cmdExtendedEraseMemory(self): - if self.cmdGeneric(0x44): - mdebug(10, "*** Extended erase memory command") - # Global mass erase - mdebug(5, "Global mass erase; this may take a while") - self.sp.write(chr(0xFF)) - self.sp.write(chr(0xFF)) - # Checksum - self.sp.write(chr(0x00)) - self._wait_for_ack("0x44 extended erase failed", - timeout=self.GLOBAL_ERASE_TIMEOUT_SECONDS) - mdebug(10, " Extended erase memory done") - else: - raise CmdException("Extended erase memory (0x44) failed") - - - def cmdWriteProtect(self, sectors): - if self.cmdGeneric(0x63): - mdebug(10, "*** Write protect command") - self.sp.write(chr((len(sectors)-1) & 0xFF)) - crc = 0xFF - for c in sectors: - crc = crc ^ c - self.sp.write(chr(c)) - self.sp.write(chr(crc)) - self._wait_for_ack("0x63 write protect failed") - mdebug(10, " Write protect done") - else: - raise CmdException("Write Protect memory (0x63) failed") - - def cmdWriteUnprotect(self): - if self.cmdGeneric(0x73): - mdebug(10, "*** Write Unprotect command") - self._wait_for_ack("0x73 write unprotect failed") - self._wait_for_ack("0x73 write unprotect 2 failed") - mdebug(10, " Write Unprotect done") - else: - raise CmdException("Write Unprotect (0x73) failed") - - def cmdReadoutProtect(self): - if self.cmdGeneric(0x82): - mdebug(10, "*** Readout protect command") - self._wait_for_ack("0x82 readout protect failed") - self._wait_for_ack("0x82 readout protect 2 failed") - mdebug(10, " Read protect done") - else: - raise CmdException("Readout protect (0x82) failed") - - def cmdReadoutUnprotect(self): - if self.cmdGeneric(0x92): - mdebug(10, "*** Readout Unprotect command") - self._wait_for_ack("0x92 readout unprotect failed") - self._wait_for_ack("0x92 readout unprotect 2 failed") - mdebug(10, " Read Unprotect done") - else: - raise CmdException("Readout unprotect (0x92) failed") - - -# Complex commands section - - def readMemory(self, addr, lng): - data = [] - if usepbar: - widgets = ['Reading: ', Percentage(),', ', ETA(), ' ', Bar()] - pbar = ProgressBar(widgets=widgets,maxval=lng, term_width=79).start() - - while lng > 256: - if usepbar: - pbar.update(pbar.maxval-lng) - else: - mdebug(5, "Read %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) - data = data + self.cmdReadMemory(addr, 256) - addr = addr + 256 - lng = lng - 256 - if usepbar: - pbar.update(pbar.maxval-lng) - pbar.finish() - else: - mdebug(5, "Read %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) - data = data + self.cmdReadMemory(addr, lng) - return data - - def writeMemory(self, addr, data): - lng = len(data) - - mdebug(5, "Writing %(lng)d bytes to start address 0x%(addr)X" % - { 'lng': lng, 'addr': addr}) - - if usepbar: - widgets = ['Writing: ', Percentage(),' ', ETA(), ' ', Bar()] - pbar = ProgressBar(widgets=widgets, maxval=lng, term_width=79).start() - - offs = 0 - while lng > 256: - if usepbar: - pbar.update(pbar.maxval-lng) - else: - mdebug(5, "Write %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) - self.cmdWriteMemory(addr, data[offs:offs+256]) - offs = offs + 256 - addr = addr + 256 - lng = lng - 256 - if usepbar: - pbar.update(pbar.maxval-lng) - pbar.finish() - else: - mdebug(5, "Write %(len)d bytes at 0x%(addr)X" % {'addr': addr, 'len': 256}) - self.cmdWriteMemory(addr, data[offs:offs+lng] + ([0xFF] * (256-lng)) ) - - -def usage(): - print("""Usage: %s [-hqVewvr] [-l length] [-p port] [-b baud] [-a addr] [file.bin] - -h This help - -q Quiet - -V Verbose - -e Erase - -w Write - -v Verify - -r Read - -l length Length of read - -p port Serial port (default: first USB-like port in /dev) - -b baud Baud speed (default: 115200) - -a addr Target address - - ./stm32loader.py -e -w -v example/main.bin - - """ % sys.argv[0]) - -def read(filename): - """Read the file to be programmed and turn it into a binary""" - with open(filename, 'rb') as f: - bytes = f.read() - - if bytes.startswith('\x7FELF'): - # Actually an ELF file. Convert to binary - handle, path = tempfile.mkstemp(suffix='.bin', prefix='stm32loader') - - try: - os.close(handle) - - # Try a couple of options for objcopy - for name in ['arm-none-eabi-objcopy', 'arm-linux-gnueabi-objcopy']: - try: - code = subprocess.call([name, '-Obinary', filename, path]) - - if code == 0: - return read(path) - except OSError: - pass - else: - raise Exception('Error %d while converting to a binary file' % code) - finally: - # Remove the temporary file - os.unlink(path) - else: - return [ord(x) for x in bytes] - -if __name__ == "__main__": - - conf = { - 'port': 'auto', - 'baud': 115200, - 'address': 0x08000000, - 'erase': 0, - 'write': 0, - 'verify': 0, - 'read': 0, - 'len': 1000, - 'fname':'' - } - -# http://www.python.org/doc/2.5.2/lib/module-getopt.html - - try: - opts, args = getopt.getopt(sys.argv[1:], "hqVewvrp:b:a:l:g") - except getopt.GetoptError as err: - # print help information and exit: - print(str(err)) # will print something like "option -a not recognized" - usage() - sys.exit(2) - - for o, a in opts: - if o == '-V': - QUIET = 10 - elif o == '-q': - QUIET = 0 - elif o == '-h': - usage() - sys.exit(0) - elif o == '-e': - conf['erase'] = 1 - elif o == '-w': - conf['write'] = 1 - elif o == '-v': - conf['verify'] = 1 - elif o == '-r': - conf['read'] = 1 - elif o == '-p': - conf['port'] = a - elif o == '-b': - conf['baud'] = eval(a) - elif o == '-a': - conf['address'] = eval(a) - elif o == '-l': - conf['len'] = eval(a) - elif o == '-g': - conf['go'] = 1 - else: - assert False, "unhandled option" - - # Try and find the port automatically - if conf['port'] == 'auto': - ports = [] - - # Get a list of all USB-like names in /dev - for name in ['tty.usbserial', 'ttyUSB']: - ports.extend(glob.glob('/dev/%s*' % name)) - - ports = sorted(ports) - - if ports: - # Found something - take it - conf['port'] = ports[0] - - cmd = CommandInterface() - cmd.open(conf['port'], conf['baud']) - mdebug(10, "Open port %(port)s, baud %(baud)d" % {'port':conf['port'], - 'baud':conf['baud']}) - try: - if (conf['write'] or conf['verify']): - mdebug(5, "Reading data from %s" % args[0]) - data = read(args[0]) - - try: - cmd.initChip() - except CmdException: - print("Can't init. Ensure BOOT0=1, BOOT1=0, and reset device") - - bootversion = cmd.cmdGet() - - mdebug(0, "Bootloader version 0x%X" % bootversion) - - if bootversion < 20 or bootversion >= 100: - raise Exception('Unreasonable bootloader version %d' % bootversion) - - chip_id = cmd.cmdGetID() -#assert len(chip_id) == 2, "Unreasonable chip id: %s" % repr(chip_id) - chip_id_num = (ord(chip_id[0]) << 8) | ord(chip_id[1]) - chip_id_str = CHIP_ID_STRS.get(chip_id_num, None) - - if chip_id_str is None: - mdebug(0, 'Warning: unrecognised chip ID 0x%x' % chip_id_num) - else: - mdebug(0, "Chip id 0x%x, %s" % (chip_id_num, chip_id_str)) - - if conf['erase']: - # Pre-3.0 bootloaders use the erase memory - # command. Starting with 3.0, extended erase memory - # replaced this command. - if bootversion < 0x30: - cmd.cmdEraseMemory() - else: - cmd.cmdExtendedEraseMemory() - - if conf['write']: - cmd.writeMemory(conf['address'], data) - - if conf['verify']: - verify = cmd.readMemory(conf['address'], len(data)) - if(data == verify): - print("Verification OK") - else: - print("Verification FAILED") - print(str(len(data)) + ' vs ' + str(len(verify))) - for i in xrange(0, len(data)): - if data[i] != verify[i]: - print(hex(i) + ': ' + hex(data[i]) + ' vs ' + hex(verify[i])) - - if not conf['write'] and conf['read']: - rdata = cmd.readMemory(conf['address'], conf['len']) - file(args[0], 'wb').write(''.join(map(chr,rdata))) - if conf['go']: - cmd.cmdGo(conf['address']) - print("Running from address" ) - - finally: - cmd.releaseChip() - diff --git a/arduino/opencr_release/opencr_core_1.0.tar.bz2 b/arduino/opencr_release/opencr_core_1.0.tar.bz2 new file mode 100644 index 000000000..da1efca6e Binary files /dev/null and b/arduino/opencr_release/opencr_core_1.0.tar.bz2 differ diff --git a/arduino/opencr_release/opencr_tools_1.0.tar.bz2 b/arduino/opencr_release/opencr_tools_1.0.tar.bz2 new file mode 100644 index 000000000..9b2dd91c2 Binary files /dev/null and b/arduino/opencr_release/opencr_tools_1.0.tar.bz2 differ diff --git a/arduino/opencr_release/package_opencr_index.json b/arduino/opencr_release/package_opencr_index.json new file mode 100644 index 000000000..d18d8aea7 --- /dev/null +++ b/arduino/opencr_release/package_opencr_index.json @@ -0,0 +1,117 @@ +{ + "packages": [ + { + "name": "OpenCR", + "maintainer": "ROBOTIS", + "websiteURL": "https://github.com/ROBOTIS-GIT/OpenCR", + "email": "chcbaram@paran.com", + "help": { + "online": "http://oroca.org" + }, + "platforms": [ + { + "name": "OpenCR", + "architecture": "OpenCR", + "version": "1.0.0", + "category": "Arduino", + "help": { + "online": "https://github.com/ROBOTIS-GIT/OpenCR" + }, + "url": "https://github.com/chcbaram/opencr_test/releases/download/opencr_arduino/opencr_core_1.0.tar.bz2", + "archiveFileName": "opencr_core_1.0.tar.bz2", + "checksum": "SHA-256:e558beada46be30046d060ecacc9a71ad0a7f989d24329e27c76c57e171a553b", + "size": "738397", + "help": { + "online": "https://github.com/ROBOTIS-GIT/OpenCR" + }, + "boards": [ + {"name": "OpenCR"} + ], + "toolsDependencies": [ + { + "packager": "OpenCR", + "name": "opencr_gcc", + "version": "5.4.0-2016q2" + }, + { + "packager": "OpenCR", + "name": "opencr_tools", + "version": "1.0" + } + + ] + } + ], + "tools":[ + { + "name": "opencr_gcc", + "version": "5.4.0-2016q2", + "systems": [ + { + "host": "i686-linux-gnu", + "url": "https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2", + "archiveFileName": "gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2", + "checksum": "SHA-256:9910b6b5df12efe564dbb3856bf1599d4c16178a6f28bd8a23c9e5c3edc219e4", + "size": "92600244" + }, + { + "host": "x86_64-pc-linux-gnu", + "url": "https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2", + "archiveFileName": "gcc-arm-none-eabi-5_4-2016q2-20160622-linux.tar.bz2", + "checksum": "SHA-256:9910b6b5df12efe564dbb3856bf1599d4c16178a6f28bd8a23c9e5c3edc219e4", + "size": "92600244" + }, + { + "host": "i686-mingw32", + "url": "https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-win32.zip", + "archiveFileName": "gcc-arm-none-eabi-5_4-2016q2-20160622-win32.zip", + "checksum": "SHA-256:562a1708fbf5dedd87ed44016bceb477e0f050cbd82ddbe2373a1fc9342c0e23", + "size": "123123549" + }, + { + "host": "i386-apple-darwin11", + "url": "https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q2-update/+download/gcc-arm-none-eabi-5_4-2016q2-20160622-mac.tar.bz2", + "archiveFileName": "gcc-arm-none-eabi-5_4-2016q2-20160622-mac.tar.bz2", + "checksum": "SHA-256:e175a0eb7ee312013d9078a5031a14bf14dff82c7e697549f04b22e6084264c8", + "size": "96963810" + } + ] + }, + { + "name": "opencr_tools", + "version": "1.0", + "systems": [ + { + "host": "i686-linux-gnu", + "url": "https://github.com/chcbaram/opencr_test/releases/download/opencr_arduino/opencr_tools_1.0.tar.bz2", + "archiveFileName": "opencr_tools_1.0.tar.bz2", + "checksum": "SHA-256:3dfef83da9aadf7c9f4397c2307344f5c785ad3ea39ae19f5243adf9fdbc30c0", + "size": "1934513" + }, + { + "host": "x86_64-pc-linux-gnu", + "url": "https://github.com/chcbaram/opencr_test/releases/download/opencr_arduino/opencr_tools_1.0.tar.bz2", + "archiveFileName": "opencr_tools_1.0.tar.bz2", + "checksum": "SHA-256:3dfef83da9aadf7c9f4397c2307344f5c785ad3ea39ae19f5243adf9fdbc30c0", + "size": "1934513" + }, + { + "host": "i686-mingw32", + "url": "https://github.com/chcbaram/opencr_test/releases/download/opencr_arduino/opencr_tools_1.0.tar.bz2", + "archiveFileName": "opencr_tools_1.0.tar.bz2", + "checksum": "SHA-256:3dfef83da9aadf7c9f4397c2307344f5c785ad3ea39ae19f5243adf9fdbc30c0", + "size": "1934513" + }, + { + "host": "i386-apple-darwin11", + "url": "https://github.com/chcbaram/opencr_test/releases/download/opencr_arduino/opencr_tools_1.0.tar.bz2", + "archiveFileName": "opencr_tools_1.0.tar.bz2", + "checksum": "SHA-256:3dfef83da9aadf7c9f4397c2307344f5c785ad3ea39ae19f5243adf9fdbc30c0", + "size": "1934513" + } + ] + } + ] + } + ] +} \ No newline at end of file