aboutsummaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* remove ueless top_srcdirpatches-todo/only-export-public-symbolsDenis 'GNUtoo' Carikli2021-03-021-1/+1
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Fix mistakesDenis 'GNUtoo' Carikli2021-03-021-1/+1
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* test: reuse libsamsung-ipc source filesDenis 'GNUtoo' Carikli2021-03-024-67/+30
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add commonDenis 'GNUtoo' Carikli2021-03-022-13/+16
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* partitionsDenis 'GNUtoo' Carikli2021-03-022-8/+5
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* restore modems/Makefile.amDenis 'GNUtoo' Carikli2021-03-023-13/+22
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* restore devices/Makefile.amDenis 'GNUtoo' Carikli2021-03-022-25/+29
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* make libsamsung-ipc-test standaloneDenis 'GNUtoo' Carikli2021-03-024-3/+70
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* switch to topdirDenis 'GNUtoo' Carikli2021-03-025-68/+58
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* partitions: android: add testsDenis 'GNUtoo' Carikli2021-03-015-0/+349
| | | | | | | | TODO: - move libsamsung-ipc-test in samsung-ipc/tests/ - cleanup the code Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Test another poll implementationDenis 'GNUtoo' Carikli2021-03-013-2/+26
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* last fixesDenis 'GNUtoo' Carikli2021-03-013-13/+21
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* common: modem: Add more loggingDenis 'GNUtoo' Carikli2021-03-012-5/+15
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add better common tools loggingDenis 'GNUtoo' Carikli2021-03-011-26/+42
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Use itDenis 'GNUtoo' Carikli2021-03-011-15/+18
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* ipc-sim: improve loggingDenis 'GNUtoo' Carikli2021-03-011-4/+20
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* tools: ipc-imei: remove unused codeDenis 'GNUtoo' Carikli2021-03-011-9/+0
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* device: generic: get rid of printfDenis 'GNUtoo' Carikli2021-03-012-14/+16
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* device: generic: Fix xmm626_kernel_linux_modem_openDenis 'GNUtoo' Carikli2021-03-012-6/+5
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* devices: generic: remove some useless lsusbDenis 'GNUtoo' Carikli2021-03-011-8/+2
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* herolte: fix pointer warningDenis 'GNUtoo' Carikli2021-03-011-1/+1
| | | | | | TODO: check if it's the right way to fix it Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* [wip] tools: add ipc-imeiDenis 'GNUtoo' Carikli2021-03-015-0/+709
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add generic deviceSimon Shields2021-03-017-254/+708
| | | | | | Signed-off-by: Simon Shields <simon@lineageos.org> GNUtoo@cyberdimension.org: [rebase, fixes and cleanups] Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* Add generic modemSimon Shields2021-03-012-0/+294
| | | | | | Signed-off-by: Simon Shields <simon@lineageos.org> GNUtoo: rebase, fixes and cleanups Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* partitions: android: Add open_android_modem_partition_by_nameDenis 'GNUtoo' Carikli2021-03-012-0/+65
| | | | Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
* samsung-ipc: move Android partition handling in its own directoryDenis 'GNUtoo' Carikli2021-02-285-25/+88
| | | | | | TODO: check const * const * + pointer 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>