Include name of binary file in crc2.py and sysinfo (#918)

* preparations for lwip2

* Add CRC32 to settings

* Add CRC to progmem

* Add crc of program memory to stettings and security settings

.. so that there is a warning if the settings are used by another binary than they were written with.

* Moved to md5

* Flash included, moved to MD5 now

* Broken comment

* Stability improvements

free memory went as low as 3000 bytes which made the webserver unresponsive.

* Add binary filename to crc2.py and sysinfo

* Update WebServer.ino
This commit is contained in:
s0170071
2018-02-22 18:55:45 +01:00
committed by DatuX
parent c04b80b2f1
commit 8f4a52a6f1
3 changed files with 29 additions and 4 deletions
+24 -4
View File
@@ -1,10 +1,12 @@
import sys
import binascii
import struct
import md5
MD5DUMMY = "MD5_MD5_MD5_MD5_BoundariesOfTheSegmentsGoHere..."
import os
MD5DUMMY = "MD5_MD5_MD5_MD5_BoundariesOfTheSegmentsGoHere..." #48 chars
FILENAMEDUMMY = "ThisIsTheDummyPlaceHolderForTheBinaryFilename..." #48 chars
MemorySegmentStart,MemorySegmentEnd,MemoryContent=[],[],[]
##################################################################
@@ -14,12 +16,15 @@ def showSegments (fileContent,offset):
global MemorySegmentStart, MemorySegmentEnd, MemoryContent
header = struct.unpack("ii", fileContent[offset:offset+8])
herestr =""
herestr2 =""
MemorySegmentStart.append(struct.pack("I",header[0]))
MemorySegmentEnd.append(struct.pack("I",header[0]+header[1]))
MemoryContent.append(fileContent[offset+8:offset+8+header[1]])
if fileContent.find( MD5DUMMY, offset+8, offset+8+header[1]) >0 :
herestr= " <-- CRC is here."
print ("SEGMENT "+ str(len(MemorySegmentStart)-1)+ ": memory position: " + hex(header[0])+" to " + hex(header[0]+header[1]) + " length: " + hex(header[1])+herestr)
if fileContent.find( FILENAMEDUMMY, offset+8, offset+8+header[1]) >0 :
herestr2= " <-- filename is here."
print ("SEGMENT "+ str(len(MemorySegmentStart)-1)+ ": memory position: " + hex(header[0])+" to " + hex(header[0]+header[1]) + " length: " + hex(header[1])+herestr+herestr2)
#print ("first byte positoin in file: " + hex( offset+8))
#print ("last byte postion in file: " + hex(offset+8+header[1]-1))
return (8+offset+ header[1]); # return start of next segment
@@ -82,6 +87,17 @@ while len(startArray) < 16 :
if (len(endArray) + len (startArray)) != 32 :
print("ERROR: please make sure you add / remove padding if you change the semgents.")
BinaryFileName = "";
if fileContent.find( FILENAMEDUMMY) < 0:
print("ERROR: FILENAMEDUMMY dummy not found in binary")
else:
BinaryFileName=os.path.basename(FileName) +"\0"
if len(BinaryFileName) >48: # check that filename is <48 chars
BinaryFileName=BinaryFileName[0:48] # truncate if necessary. 49th char in ESP is zero already
else:
BinaryFileName= BinaryFileName.ljust(48,'\0'); # pad with zeros.
if fileContent.find( MD5DUMMY) < 0:
print("ERROR: MD5 dummy not found in binary")
else:
@@ -91,6 +107,10 @@ else:
md5hash = m.digest()
print("MD5 hash: "+ m.hexdigest())
print("\nwriting output file:\n" + FileName)
fileContent=fileContent.replace(MD5DUMMY,md5hash+startArray+endArray)
fileContent=fileContent.replace(FILENAMEDUMMY,BinaryFileName)
with open(FileName, mode='wb') as file: # b is important -> binary
file.write(fileContent.replace(MD5DUMMY,md5hash+startArray+endArray))
file.write(fileContent)
#k=input("press close to exit")
+1
View File
@@ -485,6 +485,7 @@ WiFiUDP portUDP;
struct CRCStruct{
char compileTimeMD5[16+32+1]= "MD5_MD5_MD5_MD5_BoundariesOfTheSegmentsGoHere...";
char binaryFilename[16+32+1]= "ThisIsTheDummyPlaceHolderForTheBinaryFilename...";
char compileTime[16]= __TIME__;
char compileDate[16]= __DATE__;
uint8_t runTimeMD5[16]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
+4
View File
@@ -320,6 +320,7 @@ void sendWebPageChunkedBegin(String& log)
void sendWebPageChunkedData(String& log, String& data)
{
checkRAM(F("sendWebPageChunkedData"));
if (data.length() > 0)
{
statusLED(true);
@@ -4576,6 +4577,9 @@ void handle_sysinfo() {
reply += " ";
reply += String(CRCValues.compileTime);
reply += F("<TR><TD>Binary filename<TD>");
reply += String(CRCValues.binaryFilename);
reply += F("<TR><TD colspan=2><H3>ESP board</H3></TD></TR>");
reply += F("<TR><TD>ESP Chip ID<TD>");