0

I'm trying to compile Arduino's .ino files in Android. So I am making use of avr-gcc, avr-g++, avr-objcopy executable(binary) files. These files produces certain files as output in a given location. I have used /data/local/tmp (/data/user/0/com.dtlabz.dreamkit/files/local/tmp/) directory in internal storage. But these executable files are not able to output the files.

Here is my code to execute the executable files:

private void execCommand(List<String> comm) throws Exception {

    StringBuilder sb = new StringBuilder();
    for(String c : comm) {
        sb.append(c);
        sb.append(" ");
    }
    exec(sb.toString());
    try {

        Log.d(LOG,"Comm: "+comm);

        Process process = Runtime.getRuntime().exec(comm.toArray(new String[0]));

        MessageSiphon in = new MessageSiphon(process.getInputStream(), new MessageConsumer() {
            public void message(String s) {
                stdout(s);
            }
        });
        MessageSiphon err = new MessageSiphon(process.getErrorStream(), new MessageConsumer() {
            public void message(String s) {
                stderr(s);
                if(s.contains("error:")) {
                    Util.p("it's an error");
                    errorHappened = true;
                    errorString = s;
                }
            }
        });
        try {
            in.join();
            err.join();
            int result = process.waitFor();
            Log.d(LOG,"Result is: "+ result);
        } catch (Exception ex) {
            Log.e(LOG,"ExecCommand MsgSiphon Join Error: "+ex);
        }
        if(errorHappened) {
            throw new CompileException("compiler error",errorString);
        }


    } catch (IOException e) {
        Log.e(LOG,"Exec error: "+ e.getMessage());
    }
}

Here is the command. Like for example I'm giving the following command as comm:

/data/user/0/com.dtlabz.dreamkit/files/local/tmp/arduino_compiler_files/tools/avr/bin/avr-g++ -c -g -Os -Wall -fno-exceptions -ffunction-sections -fdata-sections -mmcu=atmega328p -DF_CPU=16000000L -MMD -DARDUINO=101 -DUSB_VID= -DUSB_PID= -I/data/user/0/com.dtlabz.dreamkit/files/local/tmp/arduino_compiler_files/hardware/arduino/cores/arduino -I/data/user/0/com.dtlabz.dreamkit/files/local/tmp/arduino_compiler_files/hardware/arduino/variants/standard /data/user/0/com.dtlabz.dreamkit/files/local/tmp/arduino_compiler_files/hardware/arduino/cores/arduino/CDC.cpp -o /data/user/0/com.dtlabz.dreamkit/files/local/tmp/CDC.cpp.o

This command should produce CDC.cpp.o file. But I'm getting the following error through process.GetErrorStream() in my above given code.

Cannot create temporary file in ./: Read-only file system

Please Help.

  • `/data/local/tmp directory in sdcard`. Strange path. That can not be in sdcard if it starts with a /. Please tell full absolute path. – greenapps May 20 '16 at 17:23
  • I have mentioned the full path now. This path is used to store executable files. – Suraj Shettigar May 22 '16 at 02:59
  • The path you mention is not on microSD card. Your path starts with /data/local/ so its internal memory where you dont have acces to unless device is rooted. – greenapps May 22 '16 at 05:18
  • `/data/local/tmp (/data/user/0/com.dtlabz.dreamkit/files/local/tmp/)`. Why are you mentioning two completely different paths? You suggest a similarity between them. What would that be? And certainly its not on sdcard. Please start explaining why you think it is. You can have access to the second path. But not to the first. – greenapps May 22 '16 at 05:23
  • `This path is used to store executable files. `. Used? I think you try to use it to store files. But you dont succeed. – greenapps May 22 '16 at 05:27
  • No its the path where app data is stored. And no, i have succeeded in storing the files.. – Suraj Shettigar May 22 '16 at 10:59
  • And sorry about the confusion. It is in internal storage. – Suraj Shettigar May 22 '16 at 11:00
  • @greenapps I have succeeded in storing as well as executing the file. But while executing, it is not able to produce the output file. – Suraj Shettigar May 22 '16 at 11:06
  • Because that new process has no access to your app'as internal memory i think. Use an external memory path instead and request write external storage access for it. – greenapps May 22 '16 at 11:35
  • @greenapps Okay. Will try it out. Thank you for your help – Suraj Shettigar May 23 '16 at 05:16

0 Answers0