basilfx / lpc_checksum Goto Github PK
View Code? Open in Web Editor NEWPython script to calculate LPC firmware checksums.
License: MIT License
Python script to calculate LPC firmware checksums.
License: MIT License
sudo pip install lpc_checksum
lpc_checksum mybinary.bin
-> Error: ord() expected string of length 1, but int found
Running on Python 3.7
In your script you attempt to do a 32-bit unsigned add in python.
Line 88 in 14ff53e
However, when an overflow occurrs, meaning the result is larger than 32 bits, the upper bits are discarded by the CPU and only the lower 32 bits are retained. Thus it's wrong to do modulo, there should be an AND
. For reference, see https://stackoverflow.com/a/210747/5296568
Example: The original program and your script compute different values for this firmware.bin.
gcc -o lpcrc lpcrc.c && lpcrc.exe firmware.bin && python lpcrc.py firmware.bin
-- lpcrc.exe --
succesfully updated crc to: 02b6aa66
-- lpcrc.py --
Firmware path: firmware.bin
Wrote checksum 0x2b6aa63 into binary.
When patching it with the python script, openocd
complains
** Programming Started **
Warn : Verification will fail since checksum in image (0x02b6aa63) to be written to flash is different from calculated vector checksum (0x02b6aa66).
Warn : To remove this warning modify build tools on developer PC to inject correct LPC vector checksum.
** Programming Finished **
** Verify Started **
Error: checksum mismatch - attempting binary compare
embedded:startup.tcl:449: Error: ** Verify Failed **
The script returns the same checksum as the C program after applying the patch above for &
instead of %
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.