Commit graph

78 commits

Author SHA1 Message Date
Solomon Peachy
9eba95d625 FS13192: rbutil: Fix linking error on Fedora 32 beta
Change-Id: I350553db037ad9f65aced3f974afeaeee3fe822a
2020-03-29 18:57:08 +02:00
Franklin Wei
a5f228eee2 rbutil: fix windows cross compile (via M cross environment)
This fixes a couple of issues when cross-compiling for windows:
 - lib builds (i.e. mks5lboot) were overriding the cross CC/CXX with the
   native CC, producing incompatible binaries.
 - Qt made the accessibility plugin part of the core library, so we no
   longer need to import it.

Change-Id: I9d884aee62dfa51d3624a3fa9b99c23b3b375f20
2019-11-09 20:54:57 -05:00
Amaury Pouly
759a78e5df imxtools/sbtools: switch SHA1 implementation to Crypto++
The current implementation was custom and super slow. Since we use Crypto++
anyway, we might as well get use a good implementation.

Change-Id: I761ad7401653471e54000e1c2bc3d9882378112f
2017-01-16 19:59:28 +01:00
Amaury Pouly
8b3f5a8ad7 imxtools/sbtools: switch AES implementation to Crypto++
Instead of having our own copy of the AES code, use a good library to do that.
Crypto++ is well-maintained, supports a lot of ciphers, works on many OSes, and
is optimized for many architectures.

Change-Id: I7d7d24b47993206d7338c5f9bac8bbdd3915a667
2017-01-16 19:59:26 +01:00
Amaury Pouly
5ff3a3a98f imxtools/sbtools: various fixes
Change bug() macro, fix memory leaks, always use -h for help, fix usage(),
fix comment, remove useless macro

Change-Id: I30554b5e07e6f2845560a570808603cf8c4da5ad
2017-01-16 19:58:31 +01:00
Amaury Pouly
2b20026dd7 imxtools/sbtools: rework cryptography
It was a mess, a mix of crypto_* and cbc_mac calls. I made everything call crypto
functions, and also separate key setup from cryptographic operations, this will
be useful to speed up the code in the upcoming commits. Drop support for "usbotp"
key, since the crypto code for that was never mainlined and we can always get the
keys from a device as long as we have code execution (using the DCP debug registers).

Change-Id: I7aa24d12207ffb744225d1b9cc7cb1dc7281dd22
2017-01-16 19:58:24 +01:00
Amaury Pouly
cb8a98e365 imxtools: correctly read unencrypted images in raw mode
Change-Id: I87830b81a017f36d2887d9c289d09812f227b157
2017-01-16 19:51:12 +01:00
Amaury Pouly
a5950c69af imxtools: rework key/IV overriding logic
The overriding of the IV and real key should be the exception, there is no
need to manually set them to false.

Change-Id: Id66754f20a79aa5c1a991839345d1242e0aa587d
2017-01-16 19:50:25 +01:00
Amaury Pouly
2df6b1fc43 imxtools: rework sb file production
The old code had some annoying way of dealing with padding by adding explicit
instructions to the stream, which is 1) ugly 2) not in par with freescale
tools. The trick, which this new version implements, is to put the useful length
of the section in the section header, and the actual (with padding) length in
the boot tag. This way the tools can just ignore padding instruction by
reading the section header, and the bootloader can still load the image because
it uses the boot tags.
Also correctly handle the case where the first section does not start right
after the header (there is a bug in freescale tools for this case by the way).
There is an ambiguity in the way the padding instructions should be encrypted:
the bootloader should logically treat them as regular instruction of the section
stream, but it appears the freescale tools do not generate them as part of the
stream and instead encrypt them like boot tags, which is stupid because there
is no way the bootloader could decrypt them, and anyway we don't care because
the bootloader doesn't decrypt them at all.

Change-Id: Iabdc1d1f9f82d374779bf03efb75c2c3998f5b5d
2017-01-16 19:49:07 +01:00
Amaury Pouly
985f6e6935 imxtools: fix bug aes128 (did not update cbc-macp)
Although this does bug is never triggered because we never decrypt and use the
resulting CBC-MAC, it's a major overlook.

Change-Id: I3c5d318e6428d528483bf888ea284e9ded3889f0
2017-01-01 19:52:00 +01:00
Amaury Pouly
515a07e51d sb1: fix buggy comparison
cppcheck reported:
[rockbox/utils/imxtools/sbtools/sb1.c:440]: (warning) Comparison of a boolean expression with an integer other than 0 or 1.

Thanks to Thomas Jarosch

Change-Id: I0078232706d4014a1f2acea310a7a0d0edf7788b
2014-12-20 15:31:18 +01:00
Amaury Pouly
3c558127b8 sbtools: add option to ignore sha1 errors
Change-Id: I6bf9e4671e57f8ff3f436660e8ecb561027a036c
2014-09-07 17:47:00 +02:00
Amaury Pouly
1dc1a9310e sbtools: use default transfer size if it cannot be probed
A older commit removed this ability but it tends to be a problem since the HID
driver can prevent probing of transfer size which then needs to be entered
by hand on the command line.

Change-Id: Ie5a556ffdcc2adec0e1c984810983e19136b6473
2014-09-07 17:44:53 +02:00
Amaury Pouly
99835fa38b imxtools/sbtools/sb1: fix parsing/debug bug about jump/call arguments
Change-Id: Ib406cfc03ced6c8689ed467c154d6a7447a34e5c
2013-12-06 15:22:38 +01:00
Amaury Pouly
6eefc418dc imxtools/sbtools/elf: fix debug code
Change-Id: If043eb214417a41f71e6c05fc6a725eb8f983373
2013-12-06 15:22:38 +01:00
Amaury Pouly
c5b209f2d8 elftosb: fix crash on invalid command file
Change-Id: Ifef61b7ca6a391960d1d696ba455e0d14462c967
2013-12-06 11:37:49 +01:00
Amaury Pouly
468aa959c7 imxtools/sbloader: rewrite hid code
Rewrite code with proper documentation: it uses a UMS like CBW/CSW to wrap
commands and status.

Change-Id: I10476c87aaea96d4b9e54f8c1c266835c8e89721
2013-10-09 13:06:41 +02:00
Amaury Pouly
1c63993e05 imxtools/sbtools: always probe report size for HID recovery mode
Some older versions of the ROM (TA3 for example), use a 64 byte report size
instead of 1024, so hardcoding 1024 is just a bad idea.

Change-Id: I720c4465cfe2f519bffa307175614bba58766dce
2013-10-09 13:05:43 +02:00
Amaury Pouly
8785a499f4 imxtools/efltosb: fix extern() in db files
Change-Id: I5f1acd619b2f280e709d2bd06a28a3e88cc05e27
2013-09-10 23:19:34 +02:00
Amaury Pouly
acaedfdb89 sbtools: fix elf section naming
Change-Id: I4500bf70028af26cc4b8136f111f527e1396d16e
2013-08-22 15:05:13 +02:00
Amaury Pouly
260399ee8c sbtools: more work on sbtoelf and elftosb, support more attributes
Now handle timestamp, sb minor version, component/product versions,
section flags.

Change-Id: I35313efe60c28f04ea3732b36e5e01be3213cf9e
2013-08-22 14:39:46 +02:00
Amaury Pouly
a122b52d66 sbtools: factor code in command parser
Change-Id: I790c373b8a0319cdb00650d3c59919bd4b0b96f6
2013-08-22 01:15:00 +02:00
Amaury Pouly
81f97f67e2 sbtools: now generate a db file along with with elf/rsrc files
Now always generate a "make.db" file which aims at being the exact
representation of the file, ie running sbtoelf and elftosb using
the generated command file should produce the exact same file
(except for the random paddings). We still miss the support
for some option parsing to achieve that though.

Change-Id: Ib7d6b241f7855fd35225df8ab8e0711f69d9ee5a
2013-08-22 00:58:19 +02:00
Amaury Pouly
e64008bf9a sbtools: fix buffer overflow
Change-Id: I7b1c963e58eec88da215722ec219569a0a5a9cea
2013-08-22 00:49:34 +02:00
Amaury Pouly
8dc7970bb5 sbtools: fix red
Change-Id: I28b7d4d59d8f14abbba2a70e2bdea6987b6a3a98
2013-08-21 23:02:49 +02:00
Amaury Pouly
99f3ca174e sbtools: more code refactoring
Factor all printf method with a unique one defined in misc.h

Change-Id: I58fbf8916b76e873a2e6678506d2c8aece7834ec
2013-08-21 22:20:53 +02:00
Amaury Pouly
cb8274373b sbtools: more printf fixing
Change-Id: Id617297c196b381fd1c381da3eff4345e3157529
2013-08-10 21:37:27 +02:00
Amaury Pouly
c0aba07f1a sbtools: fix output printing
The code used printf instead of the provided printf functions,
resulting in strange output.

Change-Id: I2c7c2531d8d54ecdea97e8c189d18d351320ca7d
2013-08-06 21:24:38 +02:00
Amaury Pouly
97459def3c sbtools: fix handling of NOP instructions
Change-Id: I05ab8176f368a6e2d075dfb2059692871e0c00b3
2013-08-06 21:24:38 +02:00
Amaury Pouly
8b13d2f5f1 elf: fix handling of virtual/physical addresses
Remove the hackish elf_translate_addresses which should not have
existed in the first place, on write always compute the physical
address of a section using elf_translate_virtual_address which
makes it possible to specify any virtual to physical mapping and
fail nicely if there is none.

Change-Id: I4f436945e90280a6fd9430de6c642dbeb8e23d40
2013-08-06 21:24:38 +02:00
Amaury Pouly
8e69c37b5a sbtools: various fixes
Change-Id: I82c4642aea325cf22d66e9b49fc2d47319cd70eb
2013-08-06 21:24:38 +02:00
Amaury Pouly
e69293ecdb sbtools: standard sb print function is now standard
Change-Id: I2746bfff9a360ef4fc823853859609ffed5d2b67
2013-08-06 21:24:38 +02:00
Amaury Pouly
f72617c002 sbtools: elf library can now load global symbols
Change-Id: I4d9f38ce31e65542d6ab192158bff52b6fad8f09
2013-08-06 21:24:38 +02:00
Amaury Pouly
e4c9eaa7e8 sbtools: add helper to determine if a file is a valid ELF image
Change-Id: Ie0e9c05569ca9b02fd36f31fd7323f02b14e1b60
2013-08-06 21:24:38 +02:00
Amaury Pouly
76446dda45 sbtools: make code aware of elf section names
Change-Id: I7ab657959e38d2fcb2c7e6d9858facfb83101423
2013-08-06 21:24:38 +02:00
Amaury Pouly
1c8c24183e sbtools: refactor and cleanup
Factor common elf/sb read/write/printf routines. Factor sb zero
key, move sb version guess.

Change-Id: I5ae1885587456736e782e623610281bbee545039
2013-07-18 00:27:12 +02:00
Amaury Pouly
87b84c07d7 sbtools: fix sbloader (allow transfer size override)
Change-Id: Id6d3188b7f837726c29845f01b0b1588acf40407
2013-06-18 14:59:13 +02:00
Amaury Pouly
505f37e1b8 sbtools: various little fixes, mostly cosmetics
Change-Id: Ic53ef0283bdaee8d3272f648b71eff567b25059b
2013-06-17 13:58:59 +02:00
Amaury Pouly
c1eafa1b65 sbtools: add Sansa Express bootloader key
Change-Id: I167a6410e40478173e5ce496ace4f705c3e26a1b
2013-06-17 13:38:31 +02:00
Amaury Pouly
7c7fa36918 sbtools,mkximboot: fix whitespace
Change-Id: I8d8adb783707172d1aaef302366c240310350ed8
2013-06-15 22:27:34 +02:00
Amaury Pouly
9ad50ade17 imxtools: add Zen, Zen Mozaic and Zen X-Fi bootloader keys
Change-Id: I856e5b91c8e9a1c02b367960052c36f9b527046b
2013-06-13 02:31:19 +02:00
Amaury Pouly
07e82c163e imxtools: rewrite sbloader to handle both versions + user friendly
The tool can now load sb1 and sb files to devices. Detection has
been improved and the tool can infer the packet size for the HID
description as well. The command line interface has been vastly
improved too, this breaks the old one.

Change-Id: I01a0ff8f8a007514aa81c56f114c0f0a86e3303c
2013-06-13 02:29:36 +02:00
Amaury Pouly
1dae3a82e2 sbtools: fix encryption and cosmetics
Change-Id: Id302f236ad3ec13a5166de4e22a3fc85b2a6c64f
2013-06-13 02:27:30 +02:00
Amaury Pouly
bc05242517 imxtools/sbtools: silence warning
Change-Id: I423e760bbc8e418bcce3afe01c5831b5a3e655f3
2013-02-18 13:43:55 +01:00
Amaury Pouly
4362a7ba33 imxtools/sbtools: add -jump command, fix help
Change-Id: I0d5d61c1dc137333bda5e403d06a43d16f2750bf
2013-02-18 13:40:25 +01:00
Amaury Pouly
ac9304299d sbtools/elftosb1: implement key file loading
Change-Id: I2273b8d6314250620611ec50d159237edc6d76c2
2013-02-18 13:40:25 +01:00
Amaury Pouly
b05b762ed4 sbtools: add brute force option for sb1 in sbtoelf
After some reverse engineering, it appears that the keys of the
sb1 format are very weak: the 128 bytes are generated from the
laserfuse words 4,5 and 6 but in a weird manner: 4 and 5 are
simply ORed and 6 is only half used (somehow), making it "only" a
48 bit word to find.

Change-Id: I40702e19d0924ef51c01894efce3cb65bd664456
2013-02-16 20:49:07 +01:00
Amaury Pouly
4db4985f21 sbtools: increase performance by compiling with O3, add zenv key
Change-Id: I2301f695e49d306d21bb9efa9c44acf1d3296a08
2013-02-16 20:49:07 +01:00
Amaury Pouly
6d5b1b2448 imxtools/sbtoelf: add more robust version guess
Change-Id: I41ce1005d997cf35153e085b19294bb7d418e968
2013-01-29 20:46:28 +00:00
Amaury Pouly
5b00e59614 imxtools/sbtools: fix file type detection
Change-Id: I872e98f5810df3ecc975e025385f9c5ca7b47a44
2013-01-26 18:24:50 +00:00