diff options
Diffstat (limited to 'utils/hwpatcher/lib.lua')
-rw-r--r-- | utils/hwpatcher/lib.lua | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/utils/hwpatcher/lib.lua b/utils/hwpatcher/lib.lua index 7a3e4a4115..4c0d6ff7ab 100644 --- a/utils/hwpatcher/lib.lua +++ b/utils/hwpatcher/lib.lua | |||
@@ -8,16 +8,21 @@ At global level: | |||
8 | - exit() Same as quit() | 8 | - exit() Same as quit() |
9 | 9 | ||
10 | In the hwp table: | 10 | In the hwp table: |
11 | - load_file(filename) Load a firmware and guess type | 11 | - load_file(filename) Load a firmware and guess type |
12 | - load_elf_file(filename) Load a firmware as ELF | 12 | - load_elf_file(filename) Load a firmware as ELF |
13 | - load_sb_file(filename) Load a firmware as SB | 13 | - load_sb_file(filename) Load a firmware as SB |
14 | - load_sb1_file(filename) Load a firmware as SB1 | 14 | - load_sb1_file(filename) Load a firmware as SB1 |
15 | - load_bin_file(filename) Load a firmware as binary | 15 | - load_bin_file(filename) Load a firmware as binary |
16 | - save_file(obj, filename) Save a firmware to a file | 16 | - save_file(fw, filename) Save a firmware to a file |
17 | - read(obj, addr, len) Read data from a firmware | 17 | - read(fw, addr, len) Read data from a firmware |
18 | - write(obj, addr, data) Write data to a firmware | 18 | - write(fw, addr, data) Write data to a firmware |
19 | - section_info(obj, sec) Return information about a section in a table (or nil) | 19 | - section_info(fw, sec) Return information about a section in a table (or nil) |
20 | - md5sum(filename) Compute the MD5 sum of a file | 20 | - md5sum(filename) Compute the MD5 sum of a file |
21 | - crc_buf(crc_type, buf) Compute the CRC of a byte buffer and return a byte buffer | ||
22 | - crc(crc_type, fw, addr, len) Compute the CRC of a firmware part | ||
23 | |||
24 | The list of CRCs available is available the hwp.CRC table: | ||
25 | - RKW | ||
21 | 26 | ||
22 | Data read/written from/to a firmware must must be an array of bytes. | 27 | Data read/written from/to a firmware must must be an array of bytes. |
23 | The address must be a table of the following fields: | 28 | The address must be a table of the following fields: |
@@ -27,7 +32,7 @@ Data section information is a table with the following fields: | |||
27 | - address: first address if the section | 32 | - address: first address if the section |
28 | - size: size of the section | 33 | - size: size of the section |
29 | We provide the following functions to help dealing with addresses: | 34 | We provide the following functions to help dealing with addresses: |
30 | - make_addr | 35 | - make_addr(addr, section) Build a firmware address from a raw address and a section |
31 | 36 | ||
32 | ]]-- | 37 | ]]-- |
33 | 38 | ||
@@ -105,3 +110,8 @@ function hwp.md5str(md5) | |||
105 | end | 110 | end |
106 | return s | 111 | return s |
107 | end | 112 | end |
113 | |||
114 | -- compute the CRC of a firmware part | ||
115 | function hwp.crc(crc_type, fw, addr, len) | ||
116 | return hwp.crc_buf(crc_type, hwp.read(fw, addr, len)) | ||
117 | end | ||