27 Commits

Author SHA1 Message Date
Konrad Dybcio
5ecd2fe926 Merge pull request #17 from lumag/fix-sysfs-path
Fix the code handling the firmware path set in sysfs
v1.1
2025-12-30 15:09:23 +01:00
Dmitry Baryshkov
fbace0b23e Handle "path not set in sysfs" without extra warnings
Stop printing the obscure warning about path being too long when the
firmware path isn't set in sysfs.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2025-12-30 07:47:45 +02:00
Dmitry Baryshkov
8ce2895666 Use correct paths when firmware path isn't set in sysfs
Swap arguments to concat_path, passing "/lib/firmware" into the first
argument and keeping the second one (firmware-path from remoteproc).

Fixes: 4946411bbb ("Use firmware load path from sysfs")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2025-12-30 07:43:43 +02:00
Dmitry Baryshkov
5f7a33d8ed Pass down the length of the buffer when calculating firmware paths
Stop using sizeof(char*) to get the size of the buffer. Instead pass
down the correct length. Also removing the hidden knowledge of the
buffer being PATH_LEN bytes.

Fixes: 4946411bbb ("Use firmware load path from sysfs")
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
2025-12-30 07:43:21 +02:00
Konrad Dybcio
0a43c8be56 Merge pull request #16 from dsankouski/support_msm_firmware_loader
firmware: get path from firmware class
2025-11-03 15:14:21 +01:00
Dzmitry Sankouski
4946411bbb Use firmware load path from sysfs
Some distributions override firmware loading path
using /sys/module/firmware_class/parameters/path.
Kernel supports it, teach pd-mapper to support it too.

Signed-off-by: Dzmitry Sankouski <dsankouski@gmail.com>
Co-authored-by: Alexey Minnekhanov <alexeymin@postmarketos.org>
2025-05-06 19:43:10 +03:00
Konrad Dybcio
e7c42e1522 Merge pull request #14 from tobhe/master
pd-mapper.service: Drop qrtr-ns dependency
2024-06-20 00:23:03 +02:00
Tobias Heider
fa2ad72bda pd-mapper.service: Drop qrtr-ns dependency
qrtr-ns has moved to the kernel so we don't need the userland
service.

Signed-off-by: Tobias Heider <tobias.heider@canonical.com>
2024-06-18 19:41:06 +00:00
Jeremy Linton
10997ba7c4 pd-mapper: Add ability to decompress .xz json files
Many distros and ship Linux firmware in compressed form.
In the case of fedora that is .xz format, so lets add the
ability for pd-mapper to understand LZMA compressed JSON files.

Signed-off-by: Jeremy Linton <lintonrjeremy@gmail.com>
2023-09-01 09:55:20 -05:00
Amit Pundir
107104b20b ANDROID: pd-mapper: Update Android.bp srcs
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2023-01-17 22:59:13 -06:00
Amit Pundir
352a39cd0c ANDROID: pd-mapper: Use /vendor/firmware path for AOSP
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
2023-01-17 22:59:13 -06:00
Brian Masney
b4c1e362f1 correct SIGSEGV when firmware is not present
pd-mapper will fail to start due to a SIGSEGV when any of the firmware
for the various remoteprocs are not present. ltrace isolated where the
problem was:

    ....
    strlen("qcom/sc8280xp/LENOVO/21BX/qcadsp"...)                                       = 41
    dirname(0xfffff9b66450, 0xfffff9b683b0, 36, 0xfffffff)                              = 0xfffff9b66450
    strcat("/lib/firmware/", "qcom/sc8280xp/LENOVO/21BX")                               = "/lib/firmware/qcom/sc8280xp/LENO"...
    opendir("/lib/firmware/qcom/sc8280xp/LENO"...)                                      = nil
    readdir(nil <no return ...>
    --- SIGSEGV (Segmentation fault) ---
    +++ killed by SIGSEGV +++

With this fix, pd-mapper now displays the following messages when the
firmware is not present:

    pd-mapper: Cannot open /lib/firmware/qcom/sc8280xp/LENOVO/21BX: No such file or directory
    pd-mapper: Cannot open /lib/firmware/qcom/sc8280xp/LENOVO/21BX: No such file or directory
    no pd maps available

Signed-off-by: Brian Masney <bmasney@redhat.com>
2023-01-17 22:58:43 -06:00
Jami Kettunen
a500e63481 Makefile: allow $(CFLAGS), $(LDFLAGS) override
The caller might have specified CFLAGS or LDFLAGS. Let's respect those.
2023-01-17 22:58:11 -06:00
Amit Pundir
9d78fc0c61 pd-mapper: Null terminate firmware_value string
Null terminate firmware_value string to prevent
strlen() read past the end of buffer error on AOSP.

Otherwise pd-mapper will crash:
  console:/ # pd-mapper
  FORTIFY: strlen: detected read past end of buffer
  Aborted
  134|console:/ #

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
v1.0
2022-02-08 10:14:15 -08:00
Khem Raj
d7fe25fa6e pd-mapper: Include limits.h for PATH_MAX
Fixes
pd-mapper.c:199:22: error: 'PATH_MAX' undeclared (first use in this function); did you mean 'AF_MAX'?

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2020-10-22 16:03:40 -07:00
Peter Collingbourne
1bcf3c83c9 Fix an out-of-bounds read in assoc_next.
Found using HWASan.
2020-10-22 16:01:25 -07:00
Bjorn Andersson
ab5074fdd5 pd-mapper: Use remoteproc firmware to find jsons
Traverse the remoteproc class and use the firmware location for each one
to search for json files and load these.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-03-14 22:35:16 -07:00
Bjorn Andersson
95431902a6 pd-mapper: Introduce associative array implementation
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-03-14 22:35:16 -07:00
Bjorn Andersson
afce7e2db1 fixup! json: Introduce JSON parser 2020-03-14 22:35:16 -07:00
Bjorn Andersson
1048a84703 pd-mapper: Load JSON files
Load mappings from JSON files instead of hard coding only the WLAN.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-03-14 22:35:16 -07:00
Bjorn Andersson
48d5389fd3 json: Introduce JSON parser
Mappings are stored in JSON structured files, introduce a JSON parser to
load these.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-03-14 22:35:16 -07:00
Amit Pundir
0dd6ca7944 ANDROID: Add Android.bp makefile
Add Android.bp makefile to build pd-mapper for AOSP.

Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2020-02-07 10:44:25 -08:00
Bjorn Andersson
4236829a62 pd-mapper.service: Add systemd service
Add pd-mapper.service and install this.

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-07-25 11:30:16 -07:00
Bjorn Andersson
0b04023885 Add LICENSE file
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
2019-03-15 11:31:53 -07:00
opendata26
79ac237b42 use pd_map for name checking
pd_maps is always the same,  pd_map however is incremented

signed-off-by Craig Tatlor <ctatlor97@gmail.com>
2018-09-25 13:44:21 -07:00