Closed xianglin1998 closed 4 years ago
@doegox
It's interesting indeed. Could you try that process on your client/android/CMakeLists.txt ? So making your CMakeLists.txt more similar to the one of the libpm3 branch + a script to call cmake with these parameters. Then, once the libpm3 branch is mature and merged, we can bridge the gap with your client/android/CMakeLists.txt and have one common approach.
I am now trying to compile with NDK directly under the /client. If it succeeds, it is possible to run PM3 client directly on Android platform in Linux executable mode in the future. No JNI is needed, which also helps me integrate termux view.
If don't need to customize Java API in android, then client/android/CMakeLists.txt Will no longer be used.
Interesting, looking forward to hear of your results
Now I am compiling /android/CmakeLists.txt. It's strange that readLine is not referenced in the cmake list, but I still get this error.
There are stuff like src/cmdhflegic.c 16:#include <readline/readline.h>
Hmm that one is guarded with #ifndef ANDROID but maybe there are new ones...
It is like a complie err?we can know is a lib can't found, -lreadline
I think it's because of amiibo, just remove pm3rrg_rdv4_amiibo
from target_link_libraries
It's not used at the moment anyway
yes it's in client/deps/amiibo.cmake :
target_link_libraries(pm3rrg_rdv4_amiibo PRIVATE
readline
Wow, yes ...
I'm build successfully.
Next i will test cross compilation. Thanks. :)
great !
Great!
@doegox I always get a err on compile lua:
I tried to replace it with the gnu99 standard and it didn't work.
If you look in the offending file, you see that define is guarded by LUA_USE_POSIX. I guess adapting to android? Did you have this problem before?
#if defined(LUA_USE_POSIX)
#define l_fseek(f,o,w) fseeko(f,o,w)
#define l_ftell(f) ftello(f)
#define l_seeknum off_t
I found this problem, but I still reported an error when I tried to set the compilation standard on cmake.
I didn't find this problem before, maybe because my cmake didn't add the -Werror flag.
As @doegox mentioned before, your cmakelists.txt is different from the one we use in client folder. The idea was to make your android specific stuff in to it.
Anyway, Where did you add the -std=gnu99
flag?
@iceman1001 In /deps/lua.cmake
Inside this?
target_compile_options(pm3rrg_rdv4_lua PRIVATE -Wall -Werror -O3)
Look :)
Use function add_compile_options()
Don't know if it makes any difference, but setting it like you did, doesn't that set it for the rest of the whole project? look at the line second from the bottom, that is how we set it using module and PRIVATE
If you can tell us how to reproduce your current cross-compiling environment, we can try on our side
Donwload NDK toolchain, see: https://dl.google.com/android/repository/android-ndk-r21-linux-x86_64.zip
Extract and remember the directory of NDK
I believe you already have cmake environment, so next run cmake see: cmake -DCMAKE_TOOLCHAIN_FILE=(Your NDK DIR)/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_NATIVE_API_LEVEL=$android-19 CmakeLists.txt
All operations are performed under the client. You will get the same error as me without any accident.
error: implicit declaration of function 'fseeko' is invalid in C99
@doegox
thanks, I'll try
aaaaaaaaaaa, I'm realy sad,i always get error error: implicit declaration of function 'fseeko' is invalid in C99 is NDK error
see: https://android.googlesource.com/platform/bionic/+/master/docs/32-bit-abi.md fu*k, i delete that define, it can work.
@doegox Now we need to deal with the macro definition. In liolib.c
I pushed https://github.com/RfidResearchGroup/proxmark3/commit/526407ed5c219e263b4bdd31bea53f072109ee19 which fixed Lua under Android. Now if you want to really compile the proxmark3 client and not a libpm3, we need readline.
OK,how can we solve the dependency problem of readLine? Do you want to bind a version of readLine or download it through shell and build it?
I pushed more stuff to disable readline. There are still a few issues with commands calling kbd_enter_pressed() but the client is usable with commands less interactive or with option "-c". My current way:
rm -rf build && mkdir build && cd build && \
cmake -DCMAKE_TOOLCHAIN_FILE=~/devel/00android/android-ndk-r21/build/cmake/android.toolchain.cmake -DANDROID_ABI=armeabi-v7a -DANDROID_NATIVE_API_LEVEL=android-19 -DSKIPREADLINE=1 -DSKIPBT=1 .. && \
make -j
Which now fails at finding bzip2. For that one, it would be nice to be able to bring bzip2 somehow. It's here: https://android.googlesource.com/platform/external/bzip2/
@doegox I found a cmake function
It is can work to download and build readline.
This is build successfully, we need to include this path as a head file dir.
interesting ! we'll need sth similar for bzip2
If has source, we can xxx.cmake again, download and cross compile.
As I said, src is here https://android.googlesource.com/platform/external/bzip2/
BTW I didn't merge the code with SKIPREADLINE in master yet, so if you do changes related to readline, please do it on the opt_readline branch.
OK
@doegox merged the readline changes. It still the bzlib.h issue.
Make successfully, we need reddline & ncurses & bzip2. Next i will push to phone to test. if no problem, i will push changed to repo.
great news !
It is working, but have some problems:
backspace key delete char but console print space
detele key print char "~", yes, under normal circumstances, the terminal will not respond to delete key.
up key and down key can't show history.
The user dir error.
It is worth mentioning that the problem of input exception also appears when Windows compiles proxmark3.exe. Their common feature is static compilation.
@doegox @iceman1001
When finishing the branch of libpm3, I thought about the compilation process of NDK. By adding NDK path and some ABI parameters to the environment, we can directly compile the executable files corresponding to ABI, and then send them to Android devices for execution, without building any compilation environment (like termux) on the mobile side.
See: https://developer.android.com/ndk/guides/cmake#command-line
As mentioned in the above document, we need to specify some parameters, which can be obtained from a properties file or the system environment. When this variable exists, we can compile PM3 into the specified ABI executable file.
But we may need to solve the problems of other libraries' platforms.
If all the construction processes are solved by cmake, then multi platform support will be very simple, let's look forward to it.