| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The idea here is to use that to validate that libsamsung-ipc works
fine by reading some information of the modem data or the SIM card
through libsamsung-ipc.
The code is written in a way that enables code sharing as much as
possible to be able to build other custom tests or tools for other
usages (like a PCSC interface to the SIM card for instance).
In the long run, the idea would be to be able to write very simple
applications without the huge boilerplate that is needed to handle
the modem and concentrate on the specific information the application
needs to send and receive.
A very simple application could for instance look like that:
/* A free softrware license */
/* Some includes */
/* callbacks for logging */
static int my_callback(struct ipc_client *client,
struct ipc_message *resp,
void* data)
{
/* User code */
}
static do_something(struct ipc_client *client)
{
/* User code */
}
int main(int argc, char** argv)
{
[...]
client = ipc_client_create(IPC_CLIENT_TYPE_FMT);
if (client == NULL) {
printf("Creating client failed\n");
return 1;
}
rc = init_modem(&client, STATE_LPM)
if (rc < 0)
return rc;
register_callback(&my_callback, NULL);
do_something(&client);
return 0;
}
The boilerplate would then be provided in another C file and/or
linked to from a small library.
+======+
| TODO |
+======+
The tool-name in this commit message need to be changed from
ipc-sim to ipc-imei as that was done in the code already.
On Replicant 6, we still have a segfault when
exiting though:
[D] ipc-sim: modem_read_loop done
[D] modem_stop: ipc_client_close
[D] modem_stop: ipc_client_power_off
[D] modem_stop: Modem stopped
[1] + Segmentation fault ipc-sim
In addition, we still need to fix the startup code as it
segfaults on Replicant 6 about 50% of the time:
[D] modem_start: requested state MODEM_STATE_LPM: 1
[D] Starting i9300 modem boot
[D] Opened modem image device
[D] Mapped modem image data to memory
[D] Opened modem boot device
[D] Opened modem link device
[D] Turned the modem off
[D] Turned the modem on
[D] Waited for link connected
[D] Wrote ATAT in ASCII
[D] Reading boot ACK failed
[D] Sending XMM626 HSIC PSI failed
[D] Booting failed: error -1
[1] + Stopped (signal) ipc-sim
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Fix tool name
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
| |
Before that, the command infrastructure wasn't used for
list-supported which led to more manual parsing and more code.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
| |
Without that fix command can be NULL when it reaches this assert:
assert(command->options & OPTION_FILE);
The crash can be reproduced by running nv_data-imei with command
options but without the command itself, for example with
'nv_data-imei -i 1'.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
|
| |
This was spotted by compiling nv_data-imei on Replicant 6: it gave
the following warning:
hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:1062:15:
warning: 'command' may be used uninitialized in this function
[-Wmaybe-uninitialized]
rc = command->func(nv_data_path, &offset);
^
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
In Replicant 6.0 we have:
hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:
In function 'main':
hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:1064:1:
error: control reaches end of non-void function [-Werror=return-type]
In nv_data-imei's main we had:
int main(int argc, char * const argv[])
{
[...]
assert(false);
}
and for some reasons the Replicant 6.0 toolchain[1] doesn't recognize
that adding a 'return 0;' won't change anything, however doing
that is harmless and fixes that compilation error.
This issue also affected errno_to_sysexit in the same way:
hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:
In function 'errno_to_sysexit':
hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:837:1: error:
control reaches end of non-void function [-Werror=return-type]
[1] The compiler used (which is built by vendor/replicant/build-toolchain)
returns the following when run with --version:
arm-linux-androideabi-gcc (GCC) 4.9.x 20150123 (prerelease)
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
When building nv_data-imei in Replicant 6 we have:
hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:
In function 'bruteforce_imei_offset':
hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:675:18:
warning: pointer of type 'void *' used in subtraction [-Wpointer-arith]
(ptr - buffer),
^
Using a data type with a known size like char* avoids this error.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
The include has been imported from sysexits.h from Parabola i686.
As Replicant 6 and Replicant 11 don't have sysexits.h, the
compilation of nv_data-imei will fail if it's not provided somehow:
hardware/replicant/libsamsung-ipc/tools/nv_data-imei.c:32:22:
fatal error: sysexits.h: No such file or directory
#include <sysexits.h>
^
compilation terminated.
Being able to use sysexits.h is really interesting as it provides
a standard for applications exit codes.
In turn it enables to design tests that are more fine grained
and to avoid too messy test code while doing that, simply by
following this standard.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Without that fix, when building libsamsung-ipc under GNU/Linux
with the "-Werror -W -Wall -Wunused -Wunused-function" CFLAGS,
GCC and the autotools build system, we have:
nv_data-imei.c: In function ‘bruteforce_imei_offset’:
nv_data-imei.c:695:1: error: label ‘complete’ defined
but not used [-Werror=unused-label]
complete:
^~~~~~~~
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Reviewed-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
I had two Nexus S: after breaking one, I've tried moving the
IMEI of the broken one on the working one:
- Earlier I did some backups of the EFS.
- I went into recovery mode
- I removed the .nv_data.bak and .nv_data.bak.md5 files
- I copied the .nv_data.bin to my computer and changed the
IMEI with nv_data-imei
- I copied back the .nv_data.bin and the generated .nv_data.bin.md5
and fixed the permissions.
- I booted the device
However not only the IMEI didn't change, but it was also set back
to the old one in the file.
I've also asked Paul Kocialkowski if he remembered if changing the
IMEI worked in his original code or on which device he tried it,
but he didn't remember.
So more information is probably needed to either understand if
that code is supposed to work and if so if there are conditions
in which it works or doesn't work (specific EFS, devices, etc).
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Negative error codes are used as per the kernel coding style,
however userspace, especially the tests expect positive return
code compliant with sysexits.h.
So here we map EINVAL (Invalid argument) from errno.h to EX_USAGE
(command line usage error).
Without that fix we have:
$ ./tools/nv_data-imei nv_data.bin bruteforce-imei -i 12345
The '12345' IMEI is invalid as it is composed of 5 digits instead of 15.
errno_to_sysexit: error: unknown error code -1.
errno_to_sysexit: error code -1 needs to be implemented
lt-nv_data-imei: nv_data-imei.c:836: errno_to_sysexit: Assertion `false' failed.
Aborted (core dumped)
instead of:
$ ./tools/nv_data-imei nv_data.bin bruteforce-imei -i 12345
The '12345' IMEI is invalid as it is composed of 5 digits instead of 15.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
|
| |
At first I tried to do a bruteforce that computed the IMEI once
for each location in the file. While this was inefficient, it kept
the code simple enough to validate that it worked as the code wasn't
tested before.
However, during the rewrite of that loop to make it more efficient I
forgot to complete it.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Without that fix we have:
$ ./tools/nv_data-imei nv_data.bin bruteforce-imei
IMEI option required
See nv_data-imei bruteforce-imei -h for more details.
errno_to_sysexit: error: unknown error code -22.
errno_to_sysexit: error code -22 needs to be implemented
lt-nv_data-imei: nv_data-imei.c:823: errno_to_sysexit: Assertion `false' failed.
Aborted (core dumped)
instead of:
$ ./tools/nv_data-imei nv_data.bin bruteforce-imei
IMEI option required
See nv_data-imei bruteforce-imei -h for more details.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Knowing the format and offset of the IMEI location in nv_data.bin is a
step forward to be able to to recreate nv_data.bin from scratch.
This can be used to repair devices that have their EFS partition
completely destroyed, without having to rely on nonfree tools to do it.
When asking Paul Kocialkowsk if he knew the offset at which the IMEI
were stored in the nv_data.bin files, he explained to me that he only
found it for the XMM616 and also gave me an unfinished implementation
for a tool to change it.
In order to preserve all the information in the tool and its correct
authorship, the tool source code wasn't altered. As it doesn't
compile with current versions of libsamsung-ipc, it wasn't added to
any of the build systems (Android.mk and autotools). This will have
to be fixed in subsequent commits.
Signed-off-by: Paul Kocialkowsk <contact@paulk.fr>
GNUtoo: Added commit message
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
|
|
| |
This reorders includes alphabetically and groups them together:
- C standard library includes of depth 1 are grouped together
- "System" libraries of depth > 1 age grouped together
- The (lib)samsung-ipc include(s) is/are grouped together
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Reviewed-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This contains no functional changes.
The commented out code if any has also been preserved as it
could be relevant to the understanding of the code.
It will be kept until we understand why the code has been
commented. In that case we either need to remove it completely
or to replace it by a comment explaining why not having that
code was necessary.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Reviewed-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This contains no functional changes.
checkpatch.pl still produces warning on tools/ipc-modem.c
but there were good reasons to ignore them:
- Since there is no documentation for the samsung-ipc
protocol, beside the libsamsung-ipc source code, the
code that was commented out or between #if 0 #endif
has been preserved as it could be relevant to the
understanding of the protocol.
It will be kept until we understand why the code has been
commented. In that case we either need to remove it completely
or to replace it by a comment explaining why not having that
code was necessary.
- checkpatch also emits many warnings for "quoted string
split across lines". The issue here is that we have
conflicting rules in the code style.
- In one hand there is a limit of 80 characters per line.
- On the other hand, user-visible strings should not
be broken because "that breaks the ability to grep
for them"[1].
So the strings were split in a way that limit the
probability of not finding them in grep.
The assignment of the global declaration to 0 also
triggered a checkpatch.pl error:
ERROR: do not initialise globals to 0
So they were fixed as the fix shouldn't induce any
functional change: In the the C18 standard draft[2] in the
Semantics section of the Initialization section (6.7.9) we
have:
If an object that has static or thread storage
duration is not initialized explicitly, then:
[...]
- if it has arithmetic type, it is initialized to
(positive or unsigned) zero;
References:
-----------
[1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v5.6#n81
[2]The standard doesn't seem to be available for free, but the draft
can be downloaded from the following URL:
https://web.archive.org/web/20181230041359if_/http://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Reviewed-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
This contains no functional changes.
The commented out code if any has also been preserved as it
could be relevant to the understanding of the code.
It will be kept until we understand why the code has been
commented. In that case we either need to remove it completely
or to replace it by a comment explaining why not having that
code was necessary.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
| |
This enables easy copy-paste from a terminal.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
|
| |
Without that, functions like ipc_nv_data_md5_calculate won't
print anything as the ipc_client logging requires a valid
ipc_client.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
|
|
| |
Without that, there are no ways to know the cause of failures with
ipc_nv_data_md5_calculate.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
Acked-by: Joonas Kylmälä <joonas.kylmala@iki.fi>
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
| |
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
|
|
|
|
| |
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
| |
|
| |
|
|
|
|
| |
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
| |
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
| |
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
| |
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
| |
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
| |
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
| |
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
| |
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Detailed list of the changes introduced by this commit:
* Rename ipc_client_bootstrap_modem to ipc_client_bootstrap
* Rename ipc_client_new/free to ipc_client_create/destroy
* Rename log_handler to log_callback and change arguments order
* Remove handlers common data and fd mechanisms
* Set transport, power and gprs common data for handlers
* Add data_create and data_destroy handlers
* Rework arguments order for handlers
* Add poll transport handler
* Remove functions types typedefs
* Remove dumb ipc_client_send_* functions
* Remove ipc_client_gprs_handlers_available
* Adapt device files for the new API changes
* Adapt modemctrl for the new API changes
Change-Id: Ia9ba1045dbbf9f5e31a201aa8629b49019158972
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
|
| |
Change-Id: I0ddd3a6b32920033c3d70f046aea3674f94fa75e
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
|
|
|
| |
Also some minor headers cosmetics.
Change-Id: Id2b988b118d956e91827b9b840e3f384424593ae
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
|
|
|
| |
Also refactor headers: values aligned to 16x4 spaces and other cosmetics
Change-Id: I5a6f2c2471599c88c4be74591117d0ab2dfaaddf
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
|
|
|
| |
Signed-off-by: Simon Busch <morphis@gravedo.de>
|
|
|
|
|
| |
Change-Id: If73a5bc5a87ae1bfdb0921ef16338be11cc7b989
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
|
| |
|