I am having this issue when compiling TWRP for a specific Spreadtrum device:
In function 'rule_map_new', inlined from 'parse' at external/sepolicy/tools/check_seapp.c:968:17: external/sepolicy/tools/check_seapp.c:580:5: error: 'strncat' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] 580 | strncat(new_map->key, k->key, key_len); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
and
In function 'rule_map_new', inlined from 'parse' at external/sepolicy/tools/check_seapp.c:968:17: external/sepolicy/tools/check_seapp.c:581:5: error: 'strncat' output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] 581 | strncat(new_map->key, k->value, val_len);
I'm also using a special mkbootimg makefile that signs the image with DHTB signature.
Related
I trying to get all data from my android phone. I got alot of files named: ".backup".
step 1:
cat userdata_20200107_174037.backup userdata_20200107_174037.backup1 userdata_20200107_174037.backup2 userdata_20200107_174037.backup3 userdata_20200107_174037.backup4 userdata_20200107_174037.backup5 userdata_20200107_174037.backup6 userdata_20200107_174037.backup7 userdata_20200107_174037.backup8 userdata_20200107_174037.backup9 userdata_20200107_174037.backup10 userdata_20200107_174037.backup11 userdata_20200107_174037.backup12 userdata_20200107_174037.backup13 > userdata.img
step 2 if this not works goto step3:
dd if=userdata.img bs=512 skip=1 | gunzip -c | tar xv
gzip: stdin: not in gzip format tar: This does not look like a tar
archive tar: Exiting with failure status due to previous errors
step 3:
simg2img userdata.img userdata_raw.img
Invalid sparse file format at header magi Failed to read sparse file
step 4:
sudo mount -t ext4 -o loop,rw userdata.img /media/phone/
mount: wrong fs type, bad option, bad superblock on /dev/loop8,
missing codepage or helper program, or other error In some cases
useful info is found in syslog - try dmesg | tail or so
i Follow the stack overflow here: https://android.stackexchange.com/questions/141805/how-to-extract-backup-files-created-by-android-stock-recovery
Is there a easy way to backup all data in android ? and how can i do it? hole data include system??
Note:
then i run (file userdata.img) it's data file
and not Android sparse image (file)
I am trying to build cyanogenmod, but the build fails with the following. My drive on /mnt has plenty of space, however the root-partition where /tmp resides has less space, so I assume this happens while writing a temporary file.
Therefore I would like to redirect the temporary directory for this to somewhere under /mnt as well, how can I do this in cyanogenmod/Android build system? I tried setting TMP and TEMP but they don't seem to have any effect.
Package OTA: /mnt/android/system/out/target/product/oneplus3/cm_oneplus3-ota-178d4560f4.zip
unzipping target target-files...
running: unzip -o -q /mnt/android/system/out/target/product/oneplus3/obj/PACKAGING/target_files_intermediates/cm_oneplus3-target_files-178d4560f4.zip -d /tmp/targetfiles-RM6VsH
--- target info ---
...
cache_size = (int) 268435456
...
recovery_size = (int) 67108864
...
userdata_size = (int) 57436708864
(using device-specific extensions from target_files)
loaded device-specific extensions from /tmp/targetfiles-RM6VsH/META/releasetools.py
Warning: could not find RADIO/filesmap in <zipfile.ZipFile object at 0x2b4193f91fd0>.
using prebuilt recovery.img from BOOTABLE_IMAGES...
using system.img from target-files
Total of 770048 4096-byte output blocks in 2698 input chunks.
Generating digraph...
Finding vertex sequence...
Reversing backward edges...
0/0 dependencies (0.00%) were violated; 0 source blocks stashed.
Improving vertex order...
Revising stash size...
Total 0 blocks are packed as new blocks due to insufficient cache size.
Reticulating splines...
Traceback (most recent call last):
File "./build/tools/releasetools/ota_from_target_files", line 1772, in <module>
main(sys.argv[1:])
File "./build/tools/releasetools/ota_from_target_files", line 1727, in main
WriteFullOTAPackage(input_zip, output_zip)
File "./build/tools/releasetools/ota_from_target_files", line 664, in WriteFullOTAPackage
system_diff = common.BlockDifference("system", system_tgt, src=None)
File "/mnt/android/system/build/tools/releasetools/common.py", line 1302, in __init__
b.Compute(self.path)
File "/mnt/android/system/build/tools/releasetools/blockimgdiff.py", line 299, in Compute
self.ComputePatches(prefix)
File "/mnt/android/system/build/tools/releasetools/blockimgdiff.py", line 618, in ComputePatches
new_f.write(piece)
IOError: [Errno 28] No space left on device
make: *** [/mnt/android/system/out/target/product/oneplus3/cm_oneplus3-ota-178d4560f4.zip] Error 1
make: Leaving directory `/mnt/android/system'
Update: I found a workaround by editing /mnt/android/system/build/tools/releasetools/common.py and setting a temp-dir manually with something like tmpdir = tempfile.mkdtemp(dir='/mnt/tmp') at line 1299, according to documentation mkdtemp should use TMP and TEMP, however that seems to not have worked for me here! Python is at version 2.7.6.
To set the TMPDIR environment variable, specify a directory that is accessible to the user ID that runs the replication or publishing programs. Ensure that files cannot be deleted by other user IDs.
For example, the following command specifies the /home/repldba/tempfiles/ directory:
export TMPDIR=/home/repldba/tempfiles/
I have a weird issue where I am reading a binary file with cat. Piping the output is adding extra characters, specifically 0D0D. So I can read a file in a binary editor and it looks like this
...82 FF B3 C9 0A 97....
However, when I cat the output to a text file it mysteriously adds 0D0D like this
...82 FF B3 C9 0D 0D 0A 97...
I am reading a btsnoop_hci.log file generated by an android phone. These are the actual characters in question. I know for a fact that this happens in the middle of a string of characters that make up a Bluetooth link key, so those extra characters should DEFINITELY not be getting added. Does anyone know what is going on, and why cat is adding extra characters??
You are getting two carriage return bytes inserted before a line feed byte. These characters are significant, in different combinations, as line terminators for various operating systems. (Windows uses the two-byte terminator 0D 0A, Unix and OS X use just 0A, and the original MacOS used just 0D).
It looks, therefore, as if you are getting some kind of text mode processing of your binary data, though why you get that specific processing I couldn't say. I'm somewhat surprised by your claim that cat is performing such munging, but if it's really cat and not something else in the pipeline then you probably need to use a different tool.
cat is not adding any characters. Try the following:
$ adb shell
android$ md5 yourfile
android$ cat yourfile > newfile
android$ md5 newfile
Here's an example from my device:
shell#hammerhead:/mnt/sdcard $ md5 /system/bin/sh
cf3301e2cf56e5edc88ee20e3899a31e /system/bin/sh
shell#hammerhead:/mnt/sdcard $ cat /system/bin/sh > newfile
shell#hammerhead:/mnt/sdcard $ md5 newfile
cf3301e2cf56e5edc88ee20e3899a31e newfile
shell#hammerhead:/mnt/sdcard $
You'll notice that the checksums are identical. cat did not modify the file in any way.
Now let's try adb:
$ adb shell cat /system/bin/sh | md5sum
23c023cc5eaca953d4b1733afcdd1097 -
The checksum is different.
The problem is not with cat. Delete this question and ask a followup about adb.
when I executed the command ' staprun ' on the android , I met following problem :
# /data/systemtap-1.0-omap/bin/staprun /data/local/msyscall_all.ko
/data/systemtap-1.0-omap/bin/staprun: 1: Syntax error: "(" unexpected
#
the module msyscall_all.ko is cross-compiled with the kernel that my android run on.
firstly, I am sure that msyscall_all.ko is exactlly right , because I use command ' insomd ' and ' lsmod ' to ensure it is right .I did it as following :
# lsmod
omaplfb 8986 0 - Live 0xbf032000
pvrsrvkm 137346 29 omaplfb, Live 0xbf000000
# insmod /data/local/msyscall_all.ko
# lsmod
msyscall_all 1121778 0 - Live 0xbf037000
omaplfb 8986 0 - Live 0xbf032000
pvrsrvkm 137346 29 omaplfb, Live 0xbf000000
#
secondly, I followed the instruction in :http://omappedia.org/wiki/Systemtap#Systemtap_1.0_code_update_for_OMAP_ARM_platforms
And my systemtap-1.0-omap was cross-compiled successfully!! Howerver, after I used 'adb push' to pushed the systemtap-1.0-omap to my android device and ran it ,I got the error below :
/data/systemtap-1.0-omap/bin/staprun: 1: Syntax error: "(" unexpected
when the 'staprun' was ran on the ubuntu ,it gave me advice how run ' staprun ' , and when it was run on the android device ,it went wrong :
# /data/systemtap-1.0-omap/bin/staprun
/data/systemtap-1.0-omap/bin/staprun: 1: Syntax error: "(" unexpected
# exit
ubuntu#ubuntu:~$ cd systemtap-1.0-omap/bin/
ubuntu#ubuntu:~/systemtap-1.0-omap/bin$ ./staprun
ERROR: Need a module name or path to load.
./staprun [-v] [-c cmd ] [-x pid] [-u user] [-A|-L|-d]
[-b bufsize] [-o FILE [-D] [-S size[,N]]] MODULE [module-options]
-v Increase verbosity.
-c cmd Command 'cmd' will be run and staprun will
exit when it does. The '_stp_target' variable
will contain the pid for the command.
-x pid Sets the '_stp_target' variable to pid.
-o FILE Send output to FILE. This supports strftime(3)
formats for FILE.
-b buffer size The systemtap module specifies a buffer size.
Setting one here will override that value. The
value should be an integer between 1 and 4095
which be assumed to be the buffer size in MB.
That value will be per-cpu in bulk mode.
-L Load module and start probes, then detach.
-A Attach to loaded systemtap module.
-d Delete a module. Only detached or unused modules
the user has permission to access will be deleted. Use "*"
(quoted) to delete all unused modules.
-D Run in background. This requires '-o' option.
-S size[,N] Switches output file to next file when the size
of file reaches the specified size. The value
should be an integer greater than 1 which is
assumed to be the maximum file size in MB.
When the number of output files reaches N, it
switches to the first output file. You can omit
the second argument.
MODULE can be either a module name or a module path. If a
module name is used, it is looked for in the following
directory: /lib/modules/`uname -r`/systemtap
ubuntu#ubuntu:~/systemtap-1.0-omap/bin$
I have tried my best , but I can not solve it !!
Development Environment:
NDK: r7
SDK & Tools: r15
AVD: GB2.3.3, API Level 10
I wrote a test application in which thread will be launched in the native. I Kept a break point in the thread. (Intially when i tried on Galaxy S2 i was getting an error, "Thread debugging not supported in this Platform". So i created an AVD 2.3.3 Level 10).
After this i was getting an error like this
#0 0xafd0c51c in epoll_wait () from /Volumes/SecureCode/webos/rta/android/obj/local/armeabi/libc.so
#1 0xa81216a6 in ?? ()
I googled and found this Solution (Link Here).
I followed the guide lines there
$ adb pull /system/lib lib
$ ndk-gdb
...
(gdb) set solib-search-path lib
But after this also I am not able to hit the break point. I am still getting stuck at this poll_wait() and not moving forward.
D:\EclipseTestWorkspace\CallbackJava>sh
sh-4.1$ ndk-gdb --force --start --verbose
Android NDK installation path: /cygdrive/c/Android/android-ndk
Using default adb command: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb
ADB version found: Android Debug Bridge version 1.0.29
Using final ADB command: '/cygdrive/c/Android/android-sdk-windows/platform-tools/adb'
Using auto-detected project path: .
Found package name: com.callback
ABIs targetted by application: armeabi
Device API Level: 10
Device CPU ABI: armeabi
Compatible device ABI: armeabi
Found debuggable flag: true
Found device gdbserver: /data/data/com.callback/lib/gdbserver
Using gdb setup init: ./libs/armeabi/gdb.setup
Using toolchain prefix: /cygdrive/c/Android/android-ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/windows/bin/arm-linux-androideabi-
Using app out directory: ./obj/local/armeabi
Found data directory: '/data/data/com.callback'
Found first launchable activity: .CallbackJavaActivity
Launching activity: com.callback/.CallbackJavaActivity
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb shell am start -n com.callback/.CallbackJavaActivity
Starting: Intent { cmp=com.callback/.CallbackJavaActivity }
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb shell sleep 2
Found running PID: 352
Launched gdbserver succesfully.
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb shell run-as com.callback lib/gdbserver +debug-socket --attach 352
Setup network redirection
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb forward tcp:5039 localfilesystem:/data/data/com.callback/debug-socket
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb pull /system/bin/app_process obj/local/armeabi/app_process
Attached; pid = 352
Listening on sockaddr socket debug-socket
19 KB/s (5660 bytes in 0.281s)
Pulled app_process from device/emulator.
## COMMAND: /cygdrive/c/Android/android-sdk-windows/platform-tools/adb pull /system/lib/libc.so obj/local/armeabi/libc.so
80 KB/s (273868 bytes in 3.325s)
Pulled libc.so from device/emulator.
GNU gdb 6.6
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "--host=i586-mingw32msvc --target=arm-elf-linux".
(no debugging symbols found)
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
----- So many similar errors -----
Error while mapping shared library sections:
gralloc.default.so: No such file or directory.
(no debugging symbols found)
warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.
warning: shared library handler failed to enable breakpoint
0xafd0c51c in epoll_wait () from D:/EclipseTestWorkspace/CallbackJava/obj/local/armeabi/libc.so
(gdb) set solib-search-path lib
Error while mapping shared library sections:
/system/bin/linker: No such file or directory.
Error while mapping shared library sections:
gralloc.default.so: No such file or directory.
Symbol file not found for /system/bin/linker
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so...(no debugging symbols found)...done.
Loaded symbols for D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
----- So many similar errors -----
Loaded symbols for D:\EclipseTestWorkspace\CallbackJava/lib/libwebcore.so
Symbol file not found for gralloc.default.so
(gdb) file ./libs/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./libs/armeabi/libcallbacks.so...(no debugging symbols found)...done.
(gdb) file ./obj/local/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./obj/local/armeabi/libcallbacks.so...done.
(gdb) break callbacks_java.cpp:appcallback_register
Breakpoint 1 at 0x1a64: file D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp, line 419.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00001a64 in appcallback_register at D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp:419
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x1a64: Input/output error.
(gdb)
Which i would like to concentrate on main part as
(gdb) file ./libs/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./libs/armeabi/libcallbacks.so...(no debugging symbols found)...done.
(gdb) file ./obj/local/armeabi/libcallbacks.so
A program is being debugged already.
Are you sure you want to change the file? (y or n) y
Reading symbols from D:\EclipseTestWorkspace\CallbackJava/./obj/local/armeabi/libcallbacks.so...done.
(gdb) break callbacks_java.cpp:appcallback_register
Breakpoint 1 at 0x1a64: file D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp, line 419.
(gdb) info breakpoints
Num Type Disp Enb Address What
1 breakpoint keep y 0x00001a64 in appcallback_register at D:/EclipseTestWorkspace/CallbackJava/jni/callbacks_java.cpp:419
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) where
#0 0xafd0c51c in epoll_wait () from D:\EclipseTestWorkspace\CallbackJava/lib/libc.so
#1 0xa81211b4 in android::Looper::pollInner () from D:\EclipseTestWorkspace\CallbackJava/lib/libutils.so
#2 0x00000000 in ?? ()
(gdb) c
Continuing.
Warning:
Cannot insert breakpoint 1.
Error accessing memory address 0x1a64: Input/output error.
(gdb)
So from the last error what i understand is its considering the absolute address 0x1a64. Its not considering the relative address (runtime address), so not able to hit the break point. and also its getting stuck at the epoll_wait () , not moving further.
Will any one please help me how can I proceed further?
Thanks & Regards,
SSuman185
You could try debugging in Eclipse with DS-5 CE plugin. Tutorial how to install and setup it you can find here http://forums.arm.com/index.php?/topic/15575-arm-ds-5-tutorial-for-android/ (last post is how to make it work on SGS2).
I know that is not an exact answer to your question, but if you need NDK debugging on SGS2 you might want to try it, also it's for Eclipse, not a command line gdb (but who could ever prefer command-line debugging instead of debugging in IDE??)
PS. DS-5 CE is a first NDK debugging tool that worked for me with SGS2 (it's not perfect - possibly because of bugs/limitations in SGS2 - but at least works).