Advertisement
Guest User

Untitled

a guest
Aug 13th, 2014
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.49 KB | None | 0 0
  1. -- example for a buffer:
  2. print(hwp.crc_buf(hwp.CRC.RKW, {0, 1, 2, 3})
  3. -- example with a firmware
  4. local fw = hwp.load_file("fw.bin")
  5. local info = hwp.section(fw, "")
  6. -- extract all bytes expect 44 byte header and 4 bytes at the end
  7. local buf = hwp.read(fw, hwp.make_addr(info.addr + 44, ""), info.size - 48)
  8. -- compute CRC
  9. local crc = hwp.crc_buf(hwp.CRC.RKW, buf)
  10. -- write CRC
  11. hwp.write32(fw, hwp.make_addr(info.addr + info.size - 4, crc))
  12. -- write firmware
  13. hwp.save_file("fw-mod.bin")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement