Fixes #1793 - cp won't work on some Linux distributions
This commit is contained in:
@@ -38,7 +38,7 @@ void CopyProcess::onTimer()
|
||||
|
||||
if (sourceFile.open(QIODevice::ReadOnly)) {
|
||||
QFile destinationFile(destination);
|
||||
if (destinationFile.open(QIODevice::WriteOnly)) {
|
||||
if (destinationFile.open(QIODevice::ReadWrite)) {
|
||||
progress->addText(tr("Writing file: "));
|
||||
for (int i=0; i<blocks; i++) {
|
||||
int read = sourceFile.read(buf, BLKSIZE);
|
||||
|
||||
@@ -79,7 +79,7 @@ const unsigned char STORAGE_Inquirydata[] = {//36
|
||||
};
|
||||
|
||||
#if defined(BOOT)
|
||||
int32_t fat12Write( const uint8_t *buffer, uint16_t sector, uint32_t count ) ;
|
||||
int32_t fat12Write( const uint8_t *buffer, uint16_t sector, uint16_t count ) ;
|
||||
int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count ) ;
|
||||
#endif
|
||||
|
||||
@@ -158,7 +158,7 @@ int8_t STORAGE_GetCapacity (uint8_t lun, uint32_t *block_num, uint32_t *block_si
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
{
|
||||
if (!SD_CARD_PRESENT())
|
||||
return -1;
|
||||
|
||||
@@ -744,10 +744,15 @@ int32_t fat12Read( uint8_t *buffer, uint16_t sector, uint16_t count )
|
||||
return 0 ;
|
||||
}
|
||||
|
||||
int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint32_t count )
|
||||
int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint16_t count)
|
||||
{
|
||||
static uint8_t eepromOffset = 0;
|
||||
static uint8_t firmwareAllowed = 0;
|
||||
enum FatWriteOperation {
|
||||
FATWRITE_NONE,
|
||||
FATWRITE_EEPROM,
|
||||
FATWRITE_FIRMWARE
|
||||
};
|
||||
|
||||
static unsigned int operation = FATWRITE_NONE;
|
||||
|
||||
TRACE("FAT12 Write(sector=%d, count=%d)", sector, count);
|
||||
|
||||
@@ -755,20 +760,21 @@ int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint32_t count )
|
||||
// reserved, read-only
|
||||
}
|
||||
else if (sector < 3 + (EESIZE/BLOCKSIZE)) {
|
||||
// eeprom
|
||||
while (count) {
|
||||
if (eepromOffset == 0 && isEepromStart(buffer)) {
|
||||
if (operation == FATWRITE_NONE && isEepromStart(buffer)) {
|
||||
TRACE("EEPROM start found in sector %d", sector);
|
||||
eepromOffset = sector;
|
||||
operation = FATWRITE_EEPROM;
|
||||
}
|
||||
if (eepromOffset && sector >= eepromOffset && (sector-eepromOffset) < EESIZE/BLOCKSIZE) {
|
||||
eeWriteBlockCmp((uint8_t *)buffer, (sector-eepromOffset)*BLOCKSIZE, BLOCKSIZE);
|
||||
if (operation == FATWRITE_EEPROM) {
|
||||
eeWriteBlockCmp((uint8_t *)buffer, (sector-3)*BLOCKSIZE, BLOCKSIZE);
|
||||
}
|
||||
buffer += BLOCKSIZE;
|
||||
sector++;
|
||||
count--;
|
||||
if (sector-eepromOffset >= EESIZE/BLOCKSIZE) {
|
||||
if (sector-3 >= (EESIZE/BLOCKSIZE)) {
|
||||
TRACE("EEPROM end written at sector %d", sector-1);
|
||||
eepromOffset = 0;
|
||||
operation = FATWRITE_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -778,24 +784,28 @@ int32_t fat12Write(const uint8_t *buffer, uint16_t sector, uint32_t count )
|
||||
address = sector - 3 - (EESIZE/BLOCKSIZE);
|
||||
address *= BLOCKSIZE;
|
||||
address += FIRMWARE_ADDRESS;
|
||||
|
||||
while (count) {
|
||||
for (uint32_t i=0; i<BLOCKSIZE/FLASH_PAGESIZE; i++) {
|
||||
if (address >= FIRMWARE_ADDRESS+BOOTLOADER_SIZE/*protect bootloader*/ && address <= FIRMWARE_ADDRESS+FLASHSIZE-FLASH_PAGESIZE) {
|
||||
if (address == FIRMWARE_ADDRESS+BOOTLOADER_SIZE) {
|
||||
firmwareAllowed = isFirmwareStart(buffer);
|
||||
if (address == FIRMWARE_ADDRESS+BOOTLOADER_SIZE && isFirmwareStart(buffer)) {
|
||||
TRACE("FIRMWARE start found in sector %d", sector);
|
||||
operation = FATWRITE_FIRMWARE;
|
||||
}
|
||||
if (firmwareAllowed) {
|
||||
if (operation == FATWRITE_FIRMWARE) {
|
||||
writeFlash((uint32_t *)address, (uint32_t *)buffer);
|
||||
}
|
||||
}
|
||||
address += FLASH_PAGESIZE;
|
||||
buffer += FLASH_PAGESIZE;
|
||||
}
|
||||
sector++;
|
||||
count--;
|
||||
if (sector-3-(EESIZE/BLOCKSIZE) >= (FLASHSIZE/BLOCKSIZE)) {
|
||||
TRACE("FIRMWARE end written at sector %d", sector-1);
|
||||
operation = FATWRITE_NONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0 ;
|
||||
}
|
||||
#endif
|
||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|
||||
|
||||
Reference in New Issue
Block a user