comparison Discovery/Src/tComm.c @ 1040:74be24428049 GasConsumption

Bugfix Fontpack update for large blocks: The update of a font pack with a size > 768000 byte was interrupted and a manuel switch to bootloader had to be performed to get the font pack flashed. Rootcause was a missing address adjustment during the block read back function which caused a false error detection. Blocks > 768000 are read in two step while only one buffer is used for comparation. To fill the correct data into this buffer a dummy read of the flash data was added to get the data pointers to the correct offset. Another bug was regardings the read back itself where only the first byte was checked. After array indexing the complete buffer is noch verified.
author Ideenmodellierer
date Mon, 13 Oct 2025 20:54:25 +0200
parents 158100a84ebd
children b018e1f3082e
comparison
equal deleted inserted replaced
1039:f8e2895c91e5 1040:74be24428049
1548 uint32_t checksum, checksumCalc = 0; 1548 uint32_t checksum, checksumCalc = 0;
1549 uint8_t id; 1549 uint8_t id;
1550 const uint8_t id_Region1_firmware = 0xFF; 1550 const uint8_t id_Region1_firmware = 0xFF;
1551 const uint8_t id_RTE = 0xFE; 1551 const uint8_t id_RTE = 0xFE;
1552 uint8_t textpointer = 0; 1552 uint8_t textpointer = 0;
1553 uint32_t index = 0;
1553 1554
1554 //Get length 1555 //Get length
1555 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000 1556 if(HAL_UART_Receive(&UartHandle, sBuffer, 4,5000)!= HAL_OK) // 58000
1556 { 1557 {
1557 return 0; 1558 return 0;
1718 } 1719 }
1719 else 1720 else
1720 return 0xFF; 1721 return 0xFF;
1721 } 1722 }
1722 else 1723 else
1723 //if(region == 2) 1724 if(id == id_FONT)
1724 { 1725 {
1725 uint8_t ptr = 0; 1726 uint8_t ptr = 0;
1726 ptr += gfx_number_to_string(7,0,&display_text[ptr],lengthTotal); 1727 ptr += gfx_number_to_string(7,0,&display_text[ptr],lengthTotal);
1727 strcpy(&display_text[ptr]," bytes with "); 1728 strcpy(&display_text[ptr]," bytes with ");
1728 ptr += 12; 1729 ptr += 12;
1733 ptr += 25; 1734 ptr += 25;
1734 display_text[255] = ptr + 1; 1735 display_text[255] = ptr + 1;
1735 } 1736 }
1736 1737
1737 1738
1738 // only non RTE !! 1739 /* only non RTE !! (at this point RTE path already performed a return some lines above */
1739 uint8_t* pBufferCompare = (uint8_t*)getFrame(20); 1740 uint8_t* pBufferCompare = (uint8_t*)getFrame(20);
1740 ByteCompareStatus = 0; 1741 ByteCompareStatus = 0;
1741 1742
1742 if(id == id_Region1_firmware) 1743 if(id == id_Region1_firmware)
1743 { 1744 {
1747 ext_flash_write_firmware(pBuffer1, length1); 1748 ext_flash_write_firmware(pBuffer1, length1);
1748 lengthCompare = ext_flash_read_firmware(pBufferCompare,768000,0); 1749 lengthCompare = ext_flash_read_firmware(pBufferCompare,768000,0);
1749 1750
1750 if(lengthCompare != length1) 1751 if(lengthCompare != length1)
1751 ByteCompareStatus = 10000; 1752 ByteCompareStatus = 10000;
1752 for(int i = 0; i < length1; i++) 1753 for(index = 0; index < length1; index++)
1753 { 1754 {
1754 if(pBuffer1[0] != pBufferCompare[0]) 1755 if(pBuffer1[index] != pBufferCompare[index])
1755 ByteCompareStatus++; 1756 ByteCompareStatus++;
1756 } 1757 }
1757 } 1758 }
1758 else 1759 else
1759 //if(region == 2) 1760 if(id == id_FONT)
1760 { 1761 {
1761 /* upper region firmware can be larger (1MB) */ 1762 /* upper region firmware can be larger (1MB) */
1762 if(ext_flash_read_firmware2(0, pBufferCompare,4, 0,0) != 0xFFFFFFFF) 1763 if(ext_flash_read_firmware2(0, pBufferCompare,4, 0,0) != 0xFFFFFFFF)
1763 ext_flash_erase_firmware2(); 1764 ext_flash_erase_firmware2();
1764 ext_flash_write_firmware2(offsetTotal, pBuffer1, length1, pBuffer2, length2); 1765 ext_flash_write_firmware2(offsetTotal, pBuffer1, length1, pBuffer2, length2);
1766 1767
1767 if(lengthCompare != length1 + length2) 1768 if(lengthCompare != length1 + length2)
1768 ByteCompareStatus = 10000; 1769 ByteCompareStatus = 10000;
1769 if(offsetTotal != offsetCompare) 1770 if(offsetTotal != offsetCompare)
1770 ByteCompareStatus += 20000; 1771 ByteCompareStatus += 20000;
1771 for(int i = 0; i < length1; i++) 1772 for(index = 0; index < length1; index++)
1772 { 1773 {
1773 if(pBuffer1[0] != pBufferCompare[0]) 1774 if(pBuffer1[index] != pBufferCompare[index])
1774 ByteCompareStatus++; 1775 ByteCompareStatus++;
1775 } 1776 }
1776 1777
1777 lengthCompare = ext_flash_read_firmware2(0, 0,768000, pBufferCompare,768000); 1778 lengthCompare = ext_flash_read_firmware2(0, 0,768000, pBufferCompare,768000);
1778 for(int i = 0; i < length2; i++) 1779 for(index = 0; index < length2; index++)
1779 { 1780 {
1780 if(pBuffer2[0] != pBufferCompare[0]) 1781 if(pBuffer2[index] != pBufferCompare[index])
1781 ByteCompareStatus++; 1782 ByteCompareStatus++;
1782 } 1783 }
1783 } 1784 }
1784 1785
1785 releaseFrame(20,(uint32_t)pBufferCompare); 1786 releaseFrame(20,(uint32_t)pBufferCompare);