diff --git a/src/tools/ebuspicloader.cpp b/src/tools/ebuspicloader.cpp index 76e3056e..62660350 100644 --- a/src/tools/ebuspicloader.cpp +++ b/src/tools/ebuspicloader.cpp @@ -214,6 +214,12 @@ typedef union #define WAIT_BYTE_TRANSFERRED_MILLIS 200 #define WAIT_BITRATE_DETECTION_MICROS 100 #define WAIT_RESPONSE_TIMEOUT_MILLIS 100 +// size of flash in bytes +#define END_FLASH_BYTES (END_FLASH*2) +// size of boot block in words +#define END_BOOT 0x0400 +// size of boot block in bytes +#define END_BOOT_BYTES (END_BOOT*2) long long getTime() { struct timespec ts; @@ -612,6 +618,65 @@ void closeSerial(int fd) { close(fd); } +int calcFileChecksum(uint8_t* storeFirstBlock=nullptr) { + std::ifstream inStream; + inStream.open(flashFile, ifstream::in); + if (!inStream.good()) { + std::cerr<<"unable to open file"<> ih; + if (ih.getNoErrors()>0 || ih.getNoWarnings()>0) { + std::cerr<<"unable to read file"<=END_FLASH_BYTES || endAddr(newFirmwareVersion) + << " [" << std::hex << std::setw (4) << std::setfill('0') << static_cast(checkSum) << "]" << std::endl; +} + bool flashPic(int fd) { std::ifstream inStream; inStream.open(flashFile, ifstream::in); @@ -647,18 +712,18 @@ bool flashPic(int fd) { << std::hex << std::setfill('0') << std::setw(4) << static_cast(endAddr) << std::endl; } - if (startAddr<0x800 || endAddr>=0x8000 || endAddr=END_FLASH_BYTES || endAddr(nextAddr)<(((data[1]&0xf)<<2) | ((data[0]&0xc0)>>6)) + << "." << static_cast(data[0]&0x3f) << std::endl; + if (verbose) { + std::cout << "Configuration words:" << std::endl; + readConfig(fd, 0x0007, 5*2); // Configuration Words + std::cout << "MUI:" << std::endl; + readConfig(fd, 0x0100, 9*2, true); // MUI + std::cout<<"EUI:"<(bootloaderVersion) + << " [" << std::hex << std::setw (4) << std::setfill('0') << static_cast(picSum) << "]" << std::endl; + } else { + std::cerr<<"Bootloader version not found"<(firmwareVersion) + << " [" << std::hex << std::setw (4) << std::setfill('0') << static_cast(picSum) << "]" << std::endl; + } else { + std::cout<<"Firmware version not found"<(((data[1]&0xf)<<2) | ((data[0]&0xc0)>>6)) - << "." << static_cast(data[0]&0x3f) << std::endl; - if (verbose) { - std::cout << "Configuration words:" << std::endl; - readConfig(fd, 0x0007, 5*2); // Configuration Words - std::cout << "MUI:" << std::endl; - readConfig(fd, 0x0100, 9*2, true); // MUI - std::cout<<"EUI:"<(bootloaderVersion) <(firmwareVersion) <