aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Patchset statusreviews/Add-a-bit-more-abstraction-and-IMEI-toolDenis 'GNUtoo' Carikli2021-09-010-0/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | From: Denis 'GNUtoo' Cariklii To: Replicant mailing list Subject: Re: [Replicant] [libsamsung-ipc] Add a bit more abstraction and IMEI tool Date: Mon, 12 Oct 2020 16:07:56 +0200 On Mon, 12 Oct 2020 00:22:11 +0200 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> wrote: > Hi, > > I got one (very useful) review for the "Last patches for the > Replicant 6 0004 RC3?" patch set (thanks). > > The idea here is not to send too have too much of my patches under > review at the same time (else no one has the time to review them > all). > > Since the other patches of that Replicant 6 serie don't weren't > reviewed yet having been on the mailing list (in various form of > advancement) for quite some time, so it's probably safe to assume > that at least the older ones won't be reviewed, and there are only > 2 new patches. > > So I guess that it shound't be too much burden if I don't wait more > to send this serie. By waiting too much I completely forgot that the abstraction patchset wasn't really used yet: while each individual patch were ready, it just produce dead code as the other part of the code wasn't converted yet to use it. Denis. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* modems: xmm626: abstract xmm626_kernel_smdk4412_nv_data_sendDenis 'GNUtoo' Carikli2021-09-015-0/+10
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* modems: xmm626: abstract xmm626_kernel_smdk4412_firmware_sendDenis 'GNUtoo' Carikli2021-09-015-0/+17
| | | | | | | | | | | | | | The idea is to build an abstraction for loading the various subpartitions of the modem OS partition in the modem. To do that we start small and just wrap the various loading function as-is. At the end, the function are expected to be generic and the modem would implement them while the devices will provide a struct with the relevant subpartition informations. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* modems: xmm626: unify xmm626_{hsic/mipi}_firmware_sendDenis 'GNUtoo' Carikli2021-09-0112-52/+42
| | | | | | | These two functions are now identical so it makes no sense to keep them both. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* modems: xmm626: unify xmm626_{hsic/mipi}_nv_data_sendDenis 'GNUtoo' Carikli2021-09-0112-84/+49
| | | | | | | These two functions are now identical so it makes no sense to keep them both. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* modems: xmm626: use modem_data_sendDenis 'GNUtoo' Carikli2021-09-012-12/+12
| | | | | | | Now that we have the modem_data_send abstraction, we can replace all the mm626_{hsic/hsic}_modem_data_send instances by it. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* modems: xmm626: abstract xmm626_{hsic/mipi}_modem_data_sendDenis 'GNUtoo' Carikli2021-09-0112-0/+91
| | | | | | | | | | | The only difference between xmm626_hsic_nv_data_send and xmm626_mipi_nv_data_send is the use of xmm626_hsic_modem_data_send instead of xmm626_mipi_modem_data_send. Abstracting these functions would enable to use a common xmm626_nv_data_send. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: fix nv-data-md5 compilation with Replicant 6replicant-6.0-0004-rc5-transitionreplicant-6.0-0004-rc5Denis 'GNUtoo' Carikli2021-03-172-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | When compiling nv-data-md5 under Replicant 6 we have: hardware/replicant/libsamsung-ipc/tools/nv_data-md5.c: In function 'main': hardware/replicant/libsamsung-ipc/tools/nv_data-md5.c:103:1: error: control reaches end of non-void function [-Werror=return-type] } ^ cc1: some warnings being treated as errors So we simply need to add a return in the error path. While we're at it, we use an exit code referenced in sysexits.h to follow a standard. This can help differentiating between different types of errors. Thanks to that, it can also simplify the code when writing tests. As Android doesn't have sysexits.h, we also need to use the one that has been copied inside libsamsung-ipc in tools/include/glibc, else it would also fail to compile because of the missing header file. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: add option to call a numberDenis 'GNUtoo' Carikli2021-03-171-10/+27
| | | | | | | | | | | | | | | The ipc-modem tool contained commented code to call a specific phone number. This patch reuses that code and retrieve the number to call from the command line. The number to call is expected to be in the same country as the caller SIM card and network. Adding support for international calls could be done by computing the right prefix instead of hardcoding the IPC_CALL_PREFIX_NONE prefix. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: fix potential out of bounds sim_pin memcpyDenis 'GNUtoo' Carikli2021-03-171-11/+12
| | | | | | | | | | If for instance "1234" is given as pin, the size of optarg should be 5 but memcpy would copy 8. In addition, the current code also makes sure that there is a terminating null byte ('\0') inside the sim_pin array. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-modem: remove unused DEF_SIM_PIN definitionDenis 'GNUtoo' Carikli2021-03-171-1/+0
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* partitions: android: Add open_android_modem_partition_by_nameDenis 'GNUtoo' Carikli2021-03-042-0/+65
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Partitions: android: add tests for open_android_modem_partitionDenis 'GNUtoo' Carikli2021-03-048-3/+366
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Libraries typically have a public API and some internal implementation of that API. In libsamsung-ipc, the public API is defined in the include/ directory from the top directory. When compiling and installing libsamsung-ipc, that include/ directory is installed as well. Anything that is not defined in include/ is not part of that public API. However here we need to precisely test functions that are not part of that public API: The open_android_modem_partition function being tested here is only used by the herolte device, and that device doesn't have a battery that is easily replaceable, so most Replicant contributors will not want to get that device. As currently all the non static symbols of libsamsung-ipc are exported and that open_android_modem_partition isn't static, we can simply link to libsamsung-ipc for now and use its internal headers to access the functions to test. If at some point, libsamsung-ipc only exports the symbols defined in include/ we would need to find other ways to run such tests, for instance by using test frameworks that take care of that or by compiling libsamsung-ipc source code into the test programs. Some of the code of the libsamsung-ipc-test utility was adapted from code from the nv_data-md5 utility (which is currently in tools/). Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc: move Android partition handling in its own directoryDenis 'GNUtoo' Carikli2021-03-035-25/+88
| | | | | | | This code could also be useful for other devices and in any cases it's not device specific. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* MAINTAINERS: Update git URLDenis 'GNUtoo' Carikli2021-02-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | While libsamsung-ipc is not limited to Replicant (it can be used on GNU/Linux or in other Android distributions), it is currently maintained by Replicant. In order to make that more clear, it was renamed by the commit aa4f61805b2d8943e94847cae825ec209060569e ("Move libsamsung-ril and libsamsung-ipc in vendor/replicant") in the Replicant manifest repository[1]. Because of that we also need to adjust the git URL in the MAINTAINERS file. In addition we use https because it's safer than git:// as it uses TLS, and because we have redirects in place for http(s) but not for git://, so if the repository URL changes again, the old URL will most likely continue to work with http(s). [1]https://git.replicant.us/replicant/manifest.git Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc: move TOC handling in its own directoryDenis 'GNUtoo' Carikli2021-02-286-33/+93
| | | | | | This could enable other devices to use the TOC handling functions. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc/Makefile.am: split it in subdirectoriesDenis 'GNUtoo' Carikli2021-02-283-36/+43
| | | | | | | | | The samsung-ipc/Makefile.am became pretty big. Because of that, it's It's better to split it to have one Makefile.am per subdirectory. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Android.mk: Add support for Android 11Denis 'GNUtoo' Carikli2021-02-282-0/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If we configure Replicant 11, libsamsung-ipc and libsamsung-ril to have both libraries in /system/lib/, tools work fine on the Galaxy SIII (GT-I9300): # find -name libsamsung-ril.so 2>/dev/null ./system/lib/libsamsung-ril.so # find -name libsamsung-ipc.so 2>/dev/null ./system/lib/libsamsung-ipc.so # find -name nv_data-md5 2>/dev/null ./system/bin/nv_data-md5 # nv_data-md5 Usage: nv_data-md5 [nv_data.bin] And libsamsung-ril tries to load libsamsung-ipc from the right location in /system/lib/, but it fails due to the vendor and system separation: 01-14 15:50:57.739 1475 1475 E RILD : dlopen failed: dlopen failed: library "/system/lib/libsamsung-ril.so" needed or dlopened by "/system/vendor/bin/hw/rild" is not accessible for the namespace "(default)" Adding LOCAL_PROPRIETARY_MODULE fixes that. Note that the name of that property can be misleading here: libsamsung-ipc is free software and shall remain free software. Instead we need to understand LOCAL_PROPRIETARY_MODULE as a way to tell the Android build system that libsamsung-ipc is not part of the base Android code but instead that it is code that is specific to a device, set of devices and/or Android distribution. LOCAL_MODULE_RELATIVE_PATH cannot be used instead: even if the binaies end up in /vendor/bin/hw/, and that the libraries ends up in /vendor/lib/hw/, for some reasons the libraries can't be found: i9300:/ # /system/vendor/bin/hw/nv_data-md5 CANNOT LINK EXECUTABLE "/system/vendor/bin/hw/nv_data-md5": library "libsamsung-ipc.so" not found: needed by main executable And most importantly, rild has the same issue than before: E RILD : dlopen failed: dlopen failed: library "libsamsung-ipc.so" not found: needed by /system/vendor/lib/hw/libsamsung-ril.so in namespace (default) Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Initial support for herolte (Samsung Galaxy S7 GSM).Tony Garnock-Jones2021-02-226-0/+717
| | | | | | | | | | | | | | | | | | | | | | | | | | A previous version of this patch was tested on the herolte, however since then, several light functional changes were introduced. With the previous patch, it was possible to boot the modem and it was probably possible to send message to, and receive messages from the modem. For the TARGET_DEVICE we use in our Android.mk, In the Android.mk of android_device_samsung_herolte[1] we have: ifneq ($(filter herolte, $(TARGET_DEVICE)),) include $(call all-makefiles-under,$(LOCAL_PATH)) endif so we can safely assume that the TARGET_DEVICE is herolte. [1]https://github.com/LineageOS/android_device_samsung_herolte Signed-off-by: Tony Garnock-Jones <tonyg@leastfixedpoint.com> GNUtoo: rebased, code cleanup, more debug prints, commit message content but not its summary. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Android.mk: order libsamsung_ipc_local_src_files alphabeticallyDenis 'GNUtoo' Carikli2021-02-221-19/+19
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Android.mk: order target devices alphabeticallyDenis 'GNUtoo' Carikli2021-02-221-12/+12
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc/utils: add data_read and data_writeDenis 'GNUtoo' Carikli2021-02-162-0/+46
| | | | | | | | | | | | | | These wrappers are meant to handle the case where read or writes handles a smaller number of bytes than requested. This way that handling doesn't need to be duplicated everywhere in libsamsung-ipc. Having access to the ipc_client struct could enable future logging of read and writes without having to change any of the code already using data_read and data_write. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: handle list-supported in a more generic wayDenis 'GNUtoo' Carikli2021-02-131-48/+48
| | | | | | | 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>
* tools: nv_data-imei: fix crash with commands options without commandDenis 'GNUtoo' Carikli2021-02-111-3/+4
| | | | | | | | | | | 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>
* tools: nv_data-imei: main: Fix uninitialized command and command_option structsDenis 'GNUtoo' Carikli2021-02-111-2/+2
| | | | | | | | | | | | 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>
* tools: nv_data-imei: Fix return-type compilation errors on Replicant 6.0Denis 'GNUtoo' Carikli2021-02-101-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* scripts: guix.scm: Add Replicant 6 TARGET_ERROR_FLAGSDenis 'GNUtoo' Carikli2021-02-101-5/+12
| | | | | | | | | | | | The TARGET_ERROR_FLAGS are available from build/core/config.mk in Replicant 6. -Werror=non-virtual-dtor was only added to CLANG because it fails to be recognized with GCC: cc1: error: ‘-Werror=’ argument ‘-Werror=non-virtual-dtor’ is not valid for C [-Werror] Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* scripts: guix.scm: Add Replicant 6 COMMON_GLOBAL_CFLAGSDenis 'GNUtoo' Carikli2021-02-101-0/+3
| | | | | | | The COMMON_GLOBAL_CFLAGS are available from build/core/config.mk in Replicant 6. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: get rid of "pointer of type 'void *' used in subtraction"Denis 'GNUtoo' Carikli2021-02-101-3/+3
| | | | | | | | | | | | | 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>
* scripts: guix.scm: reorder CLFAGSDenis 'GNUtoo' Carikli2021-02-101-1/+8
| | | | | | This enables to more easily add new flags. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add sysexits.h for AndroidDenis 'GNUtoo' Carikli2021-02-102-1/+115
| | | | | | | | | | | | | | | | | | | | | 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>
* scripts: guix.scm: use latest clangDenis 'GNUtoo' Carikli2021-02-101-2/+2
| | | | | | | | | | | | | | Without that, it will end up using clang-10 while we now have clang-11. This will make Guix build clang-10 which is time consuming. Instead by using the latest clang we can use binary packages (Guix calls that substitutes) of clang which speeds up the build of libsamsung-ipc a lot, since most of the time we don't need to build any dependencies. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* ipc_utils: add ipc_group_stringDenis 'GNUtoo' Carikli2021-02-012-0/+51
| | | | | | | | | | | | | While ipc_group_string is not used by libsamsung-ipc (yet), it's still a good idea to add it as tools and applications using libsamsung-ipc can then use it to display the group of a command. It's also a better idea to have it in libsamsung-ipc than in each tool using it as libsamsung-ipc centralizes the knowledge about the samsung-ipc protocol, so if new groups appear at some point, the ipc_group_string function could be updated along the way. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* include: samsung-ipc.h: fix missing off_t definitionDenis 'GNUtoo' Carikli2021-02-011-0/+1
| | | | | | | | | | Including samsung-ipc.h in a file without other includes results in a compilation error: .../include/samsung-ipc.h:161:1: error: unknown type name ‘off_t’ 161 | off_t file_data_size(struct ipc_client *client, [...] | ^~~~~ Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* include: samsung-ipc.h: fix missing size_t definitionDenis 'GNUtoo' Carikli2021-02-011-0/+2
| | | | | | | | | | | | | | | | | | | Including samsung-ipc.h in a file without other includes results in a compilation error: .../include/samsung-ipc.h:51:2: error: unknown type name ‘size_t’ 51 | size_t size; | ^~~~~~ .../include/samsung-ipc.h:77:7: error: unknown type name ‘size_t’ 77 | size_t size), | ^~~~~~ .../include/samsung-ipc.h:26:1: note: ‘size_t’ is defined in header ‘<stddef.h>’; did you forget to ‘#include <stddef.h>’? 25 | #include <sys/time.h> +++ |+#include <stddef.h> 26 | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* include: samsung-ipc.h: move include inside the #ifdef/#endif guardsDenis 'GNUtoo' Carikli2021-02-011-2/+2
| | | | | | | | | | | | | | | | | This separates more what is part of the header and what is not so things are more clear to the people reading the code. In addition, having all includes statements inside the #ifdef #endif header guards avoids issues with the inclusion of headers that are missing such guards. This can happen with headers imported from vendor kernels. So while headers imported from vendor kernels are typically not included in the headers exported by libsamsung-ipc, it's still good to have a consistent code style between exported and non exported headers. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Move guix.scm to scriptsDenis 'GNUtoo' Carikli2021-01-111-6/+7
| | | | | | | | | | | | | | | | | The scripts directory already has several scripts that are not needed to use libsamsung-ipc, but all of them are (or were) useful to work on patches for libsamsung-ipc. As this also applies to the guix.scm and that scheme is a scripting language, it would be more clear to have it moved in the scripts directory. In addition it could also make it more simple for distributions to not ship these files if they aren't interested in having them and/or if they only want files compatibles with the license currently used by libsamsung-ipc (GPLv2 or later). Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* ipc_nv_data_md5_calculate: handle size mismatch betterreplicant-6.0-0004-rc4Denis 'GNUtoo' Carikli2020-12-032-2/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently libsamsung-ipc assumes that the size of nv_data.bin files are always 0x200000. While it's supposed to be the case for all the devices we support, it is still a good idea to make sure that a meaningful error message is reported to the users of nv_data-md5. For instance if we created an empty file of 1 kB with the following command: $ ddrescue -s 1k /dev/zero zero.img and that we used nv_data-md5 on it: $ ./tools/nv_data-md5 zero.img [ipc] file_data_read: Error: rc < 0 [ipc] ipc_nv_data_md5_calculate failed: data is NULL Calculating nv_data backup md5 failed we had a completely meaningless error message. With this patch the error message looks like that instead: $ ./tools/nv_data-md5 zero.img [ipc] ipc_nv_data_md5_calculate: Checking zero.img size failed: requested size: 2097152, file size: 1000 Calculating nv_data backup md5 failed Here users have at least a fighting chance of being able to understand what is going wrong. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-md5: Add testsDenis 'GNUtoo' Carikli2020-12-032-2/+73
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add guix.scmDenis 'GNUtoo' Carikli2020-12-031-0/+214
| | | | | | | | | | | | | | | | | | | The guix.scm file can be used to test the build in various configurations in a reproducible way. Once you have guix installed, and up to date, you can use it with the following command: $ guix build --file=guix.scm The filename (guix.scm) is a convention that is also used in other packages to also do build tests in various configurations. For more background on the use of guix.scm see the Guix days 2020 presentation about it[1]. [1]https://xana.lepiller.eu/guix-days-2020/guix-days-2020-efraim-flashner-build-it-with-guix.webm Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: nv_data-imei: fix unused-labelDenis 'GNUtoo' Carikli2020-12-031-1/+0
| | | | | | | | | | | | | | 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>
* samsung-ipc: rfs: fix incorrect sign comparison for md5 file lengthJoonas Kylmälä2020-12-031-3/+5
| | | | | | | | | | | | | | | | | | When compiling with warnings (-Werror -W -Wall -Wunused -Wunused-function) enabled we get: rfs.c: In function ‘ipc_nv_data_md5_path_check’: rfs.c:115:17: error: comparison of integer expressions of different signedness: ‘__off_t’ {aka ‘long int’} and ‘long unsigned int’ [-Werror=sign-compare] if (st.st_size < 2 * sizeof(char) * MD5_DIGEST_LENGTH) { ^ This simplifies the comparison by making sure we have exactly 32 bytes (2*MD5_DIGEST_LENGTH, i.e. md5 digest in ascii) in the file we read the MD5 digest from. Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> Tested-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Acked-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* checkpatch: ignore files added, moved, deleted warningDenis 'GNUtoo' Carikli2020-11-261-0/+7
| | | | | | | | | | | | | | Without that patch we always have the following warning when adding, moving, or deleting files when using checkpatch.pl: WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #93: new file mode 100644 Since we have only one maintainer for now, we can safely ignore that warning and add it back as soon as we have a second co-maintainer on board. Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Cosmetic: sort #includes alphabetically in ipc_devices.hTony Garnock-Jones2020-11-261-4/+4
| | | | | | Signed-off-by: Tony Garnock-Jones <tonyg@leastfixedpoint.com> GNUtoo: rebased on top of libsamsung-ipc master Acked-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* libsamsung-ipc: improve board drivers print (issue #2150)Belgin Stirbu2020-11-234-50/+164
| | | | | | | | | | | | | | | | | | | | These are the functions and their corresponding error messages: xmm626_kernel_smdk4412_power -> "Powering on/off the modem failed" xmm626_kernel_smdk4412_hci_power -> "Powering on/off the HCI bus failed" xmm626_kernel_smdk4412_link_control_enable -> "Enabling/Disabling the modem link failed" xmm626_kernel_smdk4412_link_control_active -> "Activating/Deactivating the modem link failed" Signed-off-by: Belgin Stirbu <belginstirbu@hotmail.com> Acked-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* nv_data-imei: indicate that write-imei may or may not workDenis 'GNUtoo' Carikli2020-11-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* nv_data-imei: Fix get_imei return codesDenis 'GNUtoo' Carikli2020-11-081-3/+3
| | | | | | | | | | | | | | | | | | | | | | 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>
* nv_data-imei: fix leftover from bruteforce_imei_offsetDenis 'GNUtoo' Carikli2020-11-081-7/+18
| | | | | | | | | | | | 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>
* nv_data-imei: handle missing command line arguments errorDenis 'GNUtoo' Carikli2020-11-071-0/+2
| | | | | | | | | | | | | | | | | 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>
* tools: Add a new nv_data-imei tool based on rfs-imeiDenis 'GNUtoo' Carikli2020-11-036-258/+1284
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>