September 23, 2011

portoist portoist
Lab Rat
75 posts

[Solved] Embedded Linux data directory

 

Hi,
i’ve been trying to run Qt app on embedded device but i am getting following error:

Cannot create Qt for Embedded Linux data directory: /tmp/qtembedded-0

This message is right because my root dir is read only partition, read write partition is mounted on /APPL. Is there any way to tell Qt to use ie /APPL/tmp to create data directory?
Thanks for you answers!

5 replies

September 23, 2011

ZapB ZapB
Ant Farmer
1442 posts

Hmmm, good question and I’m not sure. A possible work around is to make /tmp writable. You could do this by making it a tmpfs filesystem type. ie add something like this to your /etc/fstab:

  1. none                    /tmp/        tmpfs           size=1M         0 0

which would create a tmpfs ramdisk with maximum size of 1MB.

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

September 23, 2011

ZapB ZapB
Ant Farmer
1442 posts

OK I’ve done some digging and here’s what I’ve found. The QWSServer object tries to create and listen on a local socket which by default is /tmp/qtembedded-0. This is done in qwindowsystem_qws.cpp:

  1. void QWSServerPrivate::initServer(int flags)
  2. {
  3.     Q_Q(QWSServer);
  4.     Q_ASSERT(!qwsServer);
  5.     qwsServer = q;
  6.     qwsServerPrivate = this;
  7.     disablePainting = false;
  8. #ifndef QT_NO_QWS_MULTIPROCESS
  9.     ssocket = new QWSServerSocket(qws_qtePipeFilename(), q);
  10.     ...
  11. }

where the function qws_qtePipeFilename() is defined in qapplication_qws.cpp and in turn calls qws_dataDir() which is in the same file. This in turn calls:

  1. QString qws_dataDir()
  2. {
  3.     static QString result;
  4.     if (!result.isEmpty())
  5.         return result;
  6.     result = QT_VFB_DATADIR(qws_display_id);
  7.     ...
  8. }

where QT_VFB_DATADIR is a macro in qvfbhdr.h declared as:

  1. #define QT_VFB_DATADIR(DISPLAY) QString("%1/qtembedded-%2-%3") \
  2.                                 .arg(QT_QWS_TEMP_DIR).arg(getuid()).arg(DISPLAY)

and finally we see trace down that we need QT_QWS_TEMP_DIR which is declared as:

  1. #ifndef QT_QWS_TEMP_DIR
  2. #define QT_QWS_TEMP_DIR "/tmp"
  3. #endif

So now we see that to locate the socket to a different location we somehow need to define QT_QWS_TEMP_DIR to a path of your choice that is writeable by the user your application will be running as.

I think you should be able to do this by defining QT_QWS_TEMP_DIR in the qplatformdefs.h of your custom mkspec. Then rebuild Qt Embedded for your target device and deploy and test.

Good luck!

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

September 26, 2011

portoist portoist
Lab Rat
75 posts

Hello,
thanks a lot for your answer and digging:) I’v decided to take simple solution and made /tmp writable. I was hoping that there will be some kind of easy solution like setting some enviroment variable not rebuilding Qt Embedded:)

September 26, 2011

Scylla Scylla
Lab Rat
232 posts

We made the /tmp directory as “tmpfs” as ZapB mentioned above.

September 26, 2011

ZapB ZapB
Ant Farmer
1442 posts

No problem. Either solution will work. It depends on your device configuration and other constraints as to what is the easiest. I’ve used the tmpfs approach too when we were booting a very minimal system using just an initramfs to launch only our application.

 Signature 

Nokia Certified Qt Specialist
Interested in hearing about Qt related work

 
  ‹‹ [Solved] App suddenly not showing in the main applications menu on N950      camera interfacing - Qt ››

You must log in to post a reply. Not a member yet? Register here!