kasual

LG G3 pn544 namespace failure

Dec 16th, 2016
263
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.18 KB | None | 0 0
  1. The problem
  2. 12-16 09:18:44.677 6154 22401 E NFCJNI : phLibNfc_Mgt_ConfigureDriver() returned 0x0106[NFCSTATUS_INVALID_DEVICE]
  3. 12-16 09:18:44.677 6154 22401 E NFCJNI : phLibNfc_Mgt_Initialize() returned 0x0001[NFCSTATUS_INVALID_PARAMETER]
  4. 12-16 09:18:44.678 6154 22401 E NFCJNI : phLibNfc_Mgt_ConfigureDriver() returned 0x0106[NFCSTATUS_INVALID_DEVICE]
  5. 12-16 09:18:44.689 6154 22401 E linker : library "/vendor/firmware/libpn544_fw.so" ("/system/vendor/firmware/libpn544_fw.so") needed or dlopened by "/system/lib/libnfc.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/system/app/Nfc/lib/arm:/system/app/Nfc/Nfc.apk!/lib/armeabi-v7a:/system/lib:/system/vendor/lib", permitted_paths="/data:/mnt/expand:/data/data/com.android.nfc:/system/lib:/system/vendor/lib"]
  6. 12-16 09:18:44.689 6154 22401 E NFC-HCI : Could not open /vendor/firmware/libpn544_fw.so
  7. 12-16 09:18:44.689 6154 22401 D NFCJNI : phLibNfc_Mgt_UnConfigureDriver() returned 0x0000[NFCSTATUS_SUCCESS]
  8. 12-16 09:18:44.689 6154 22401 E NFCJNI : phLibNfc_Mgt_Initialize() (download) returned 0x0001[NFCSTATUS_INVALID_PARAMETER]
  9. 12-16 09:18:44.689 6154 22401 W NFCJNI : Firmware update FAILED
  10. 12-16 09:18:44.689 6154 22401 E NFCJNI : phLibNfc_Mgt_ConfigureDriver() returned 0x0106[NFCSTATUS_INVALID_DEVICE]
  11. 12-16 09:18:44.702 6154 22401 E linker : library "/vendor/firmware/libpn544_fw.so" ("/system/vendor/firmware/libpn544_fw.so") needed or dlopened by "/system/lib/libnfc.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/system/app/Nfc/lib/arm:/system/app/Nfc/Nfc.apk!/lib/armeabi-v7a:/system/lib:/system/vendor/lib", permitted_paths="/data:/mnt/expand:/data/data/com.android.nfc:/system/lib:/system/vendor/lib"]
  12. 12-16 09:18:44.702 6154 22401 E NFC-HCI : Could not open /vendor/firmware/libpn544_fw.so
  13. 12-16 09:18:44.702 6154 22401 D NFCJNI : phLibNfc_Mgt_UnConfigureDriver() returned 0x0000[NFCSTATUS_SUCCESS]
  14. 12-16 09:18:44.702 6154 22401 E NFCJNI : phLibNfc_Mgt_Initialize() (download) returned 0x0001[NFCSTATUS_INVALID_PARAMETER]
  15. 12-16 09:18:44.702 6154 22401 W NFCJNI : Firmware update FAILED
  16. 12-16 09:18:44.702 6154 22401 E NFCJNI : phLibNfc_Mgt_ConfigureDriver() returned 0x0106[NFCSTATUS_INVALID_DEVICE]
  17. 12-16 09:18:44.713 6154 22401 E linker : library "/vendor/firmware/libpn544_fw.so" ("/system/vendor/firmware/libpn544_fw.so") needed or dlopened by "/system/lib/libnfc.so" is not accessible for the namespace: [name="classloader-namespace", ld_library_paths="", default_library_paths="/system/app/Nfc/lib/arm:/system/app/Nfc/Nfc.apk!/lib/armeabi-v7a:/system/lib:/system/vendor/lib", permitted_paths="/data:/mnt/expand:/data/data/com.android.nfc:/system/lib:/system/vendor/lib"]
  18. 12-16 09:18:44.713 6154 22401 E NFC-HCI : Could not open /vendor/firmware/libpn544_fw.so
  19. 12-16 09:18:44.713 6154 22401 D NFCJNI : phLibNfc_Mgt_UnConfigureDriver() returned 0x0000[NFCSTATUS_SUCCESS]
  20. 12-16 09:18:44.713 6154 22401 E NFCJNI : phLibNfc_Mgt_Initialize() (download) returned 0x0001[NFCSTATUS_INVALID_PARAMETER]
  21. 12-16 09:18:44.713 6154 22401 W NFCJNI : Firmware update FAILED
  22. 12-16 09:18:44.713 6154 22401 E NFCJNI : Unable to update firmware, giving up
  23. 12-16 09:18:44.763 6154 22401 D NFCJNI : Terminating client thread...
  24. 12-16 09:18:44.764 6154 22401 W NfcService: Error enabling NFC
  25.  
  26.  
  27.  
  28.  
  29. The solution (created by Matt Mower)
  30. https://paste.ubuntu.com/18137835/
  31. I read the contents of nxp_nfc_full_version[] and nxp_nfc_fw[] using a simple executable linked to
  32. libpn544_fw.so. I didn't want to deal with Android denying me the ability to load the library,
  33. but I needed a linker available, so I prepared these instructions for use with TWRP.
  34.  
  35. 1) Save http://paste.ubuntu.com/18137145/ as a patch (e.g. pnfw.patch)
  36.  
  37. 2) In your device tree:
  38. $ git am /path/to/pnfw.patch
  39.  
  40. 3) Copy the libpn544_fw.so blob to the pnfw/ subdirectory
  41.  
  42. 4) Read the symbols from the libpn544_fw.so blob:
  43. $ ./prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-readelf -Ws vendor/lge/ls990/proprietary/vendor/firmware/libpn544_fw.so
  44. Sample output: http://paste.ubuntu.com/18137244/
  45.  
  46. 5) What matters to me is:
  47. a) nxp_nfc_fw has size 66504
  48. b) nxp_nfc_full_version has size 12
  49.  
  50. 6) Edit pnfw/pnfw.c to adjust the size of nxp_nfc_fw_len and nxp_nfc_full_version_len accordingly
  51.  
  52. 7) From the top of your cm tree, lunch for your device and then build the module: mka pnfw
  53.  
  54. 8) For reasons unknown to me, the linker renames the shared lib in the executable, so the following
  55. replacement was necessary:
  56. $ strings $OUT/recovery/root/sbin/pnfw | grep libpn544_fw
  57. libpn544_fw_C3_1_41_SP.so
  58. $ sed -i "s|libpn544_fw_C3_1_41_SP.so|libpn544_fw.so\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0|g" $OUT/recovery/root/sbin/pnfw
  59. Make sure the replacement string is the same length as the original, hence the \x0 fillers.
  60.  
  61. 9) In TWRP, the linker is in /sbin:
  62. $ sed -i "s|/system/bin/linker\x0|/sbin/linker\x0\x0\x0\x0\x0\x0\x0|g" $OUT/recovery/root/sbin/pnfw
  63.  
  64. 10) Push the files to your device
  65. $ adb push $OUT/recovery/root/sbin/pnfw /sbin/pnfw
  66. $ adb push $OUT/recovery/root/sbin/libpn544_fw.so /sbin/libpn544_fw.so
  67.  
  68. 10) Run the executable (in TWRP):
  69. $ adb shell
  70. $ pnfw > /tmp/fw.c
  71. $ exit
  72. $ adb pull /tmp/fw.c
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81. ./prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-readelf -dW vendor/lge/ls990/proprietary/vendor/firmware/libpn544_fw.so
  82.  
  83. produces
  84.  
  85.  
  86. Dynamic section at offset 0xd014 contains 23 entries:
  87. Tag Type Name/Value
  88. 0x00000003 (PLTGOT) 0xd0dc
  89. 0x00000002 (PLTRELSZ) 8 (bytes)
  90. 0x00000017 (JMPREL) 0x390
  91. 0x00000014 (PLTREL) REL
  92. 0x00000011 (REL) 0x398
  93. 0x00000012 (RELSZ) 16 (bytes)
  94. 0x00000013 (RELENT) 8 (bytes)
  95. 0x6ffffffa (RELCOUNT) 2
  96. 0x00000006 (SYMTAB) 0x168
  97. 0x0000000b (SYMENT) 16 (bytes)
  98. 0x00000005 (STRTAB) 0x288
  99. 0x0000000a (STRSZ) 261 (bytes)
  100. 0x00000004 (HASH) 0xd4
  101. 0x00000001 (NEEDED) Shared library: [libc.so]
  102. 0x00000001 (NEEDED) Shared library: [libstdc++.so]
  103. 0x00000001 (NEEDED) Shared library: [libm.so]
  104. 0x0000000e (SONAME) Library soname: [libpn544_fw_C3_1_41_SP.so]
  105. 0x00000019 (INIT_ARRAY) 0xd000
  106. 0x0000001b (INIT_ARRAYSZ) 8 (bytes)
  107. 0x0000001a (FINI_ARRAY) 0xd008
  108. 0x0000001c (FINI_ARRAYSZ) 12 (bytes)
  109. 0x00000016 (TEXTREL) 0x0
  110. 0x00000010 (SYMBOLIC) 0x0
  111.  
  112.  
  113.  
  114. ./prebuilts/gcc/linux-x86/aarch64/aarch64-linux-android-4.9/bin/aarch64-linux-android-readelf -Ws vendor/lge/ls990/proprietary/vendor/firmware/libpn544_fw.so
  115.  
  116. Symbol table '.dynsym' contains 18 entries:
  117. Num: Value Size Type Bind Vis Ndx Name
  118. 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
  119. 1: 0000cca0 12 OBJECT GLOBAL DEFAULT 8 nxp_nfc_full_version
  120. 2: 000003d8 51397 OBJECT GLOBAL DEFAULT 8 nxp_nfc_fw
  121. 3: 00000000 0 FUNC GLOBAL DEFAULT UND __cxa_finalize
  122. 4: 0000d0f0 0 NOTYPE GLOBAL DEFAULT 13 __dso_handle
  123. 5: 0000d000 0 NOTYPE GLOBAL DEFAULT 9 __INIT_ARRAY__
  124. 6: 0000d008 0 NOTYPE GLOBAL DEFAULT 10 __FINI_ARRAY__
  125. 7: 0000ccac 0 NOTYPE GLOBAL DEFAULT ABS __exidx_end
  126. 8: 0000ccac 0 NOTYPE GLOBAL DEFAULT ABS __exidx_start
  127. 9: 0000d0ec 0 NOTYPE GLOBAL DEFAULT ABS __data_start
  128. 10: 0000d0ec 0 NOTYPE GLOBAL DEFAULT ABS _edata
  129. 11: 0000d0ec 0 NOTYPE GLOBAL DEFAULT ABS __bss_start
  130. 12: 0000d0ec 0 NOTYPE GLOBAL DEFAULT ABS __bss_start__
  131. 13: 0000d100 0 NOTYPE GLOBAL DEFAULT ABS _bss_end__
  132. 14: 0000d100 0 NOTYPE GLOBAL DEFAULT ABS __bss_end__
  133. 15: 0000d100 0 NOTYPE GLOBAL DEFAULT ABS __end__
  134. 16: 0000d100 0 NOTYPE GLOBAL DEFAULT ABS _end
  135. 17: 00080000 0 NOTYPE GLOBAL DEFAULT ABS _stack
Advertisement
Add Comment
Please, Sign In to add comment