PDA

View Full Version : QML application on read only raspberry pi



mefi100
25th May 2016, 09:12
Hello everyone,

I am developing a QML application that is to be used on raspberry pi. I also want to make file system read only so users can't mess something up and also I want to prolong micro SD card's life and prevent memory corruption in case of power loss.

When the application is started in writeble mode it works fine, but when I mount the file system as read only and try starting application i get the following error after about a second of running it(so the interface is shown and everything is working as supposed):
"QWidget: Cannot create a QWidgete without QApplication
Aborted"

I suppose that application tries to write something on file system and breaks when it fails. Can anyone help me by explaining how does it work under hood, and what must be kept writable so applications can work as supposed?

I found a alternative solution to mounting as read only, That is to use chattr command to force immunity on files(still don't know which ones exactly). But I am not sure can OS itself still access them when it needs to or not. As I said corruption during power loss is my greatest problem at the moment.

In addition I just want to say I am using Raspbian Jessie Lite, and Qt version is 5.6.0 if that means something to you.

Thanks in advance

anda_skoa
25th May 2016, 09:34
The directory where an application is installed is usually read-only as far as the user running the program is concerned.

You could run the program with strace and see which file it tries to write to, though I wonder why it would fail that way even if it can't.

Cheers,
_

mefi100
25th May 2016, 10:32
Thanks for quick answer, I tried running it with strace, but I am not that good with linux so I don't really understand it well. I understood to some extent, but not last 50 lines. before that I saw some files were opened, so thats ok, The log includes little less then 5000 lines, but its mostly opening some files and using them for something. Here are last 50 or so lines so if you can see something there and share it with me I would appreciate it greatly.

mmap2(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x6b304000
write(14, "\1\0\0\0\0\0\0\0", 8) = 8
futex(0x1d7e8c0, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x1d7e664, FUTEX_WAIT_PRIVATE, 23, NULL) = 0
futex(0x1d7e648, FUTEX_WAKE_PRIVATE, 1) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x6e334000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x6b303000
brk(0x2004000) = 0x2004000
mmap2(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x6b1c0000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x6b302000
brk(0x2025000) = 0x2025000
clock_gettime(CLOCK_MONOTONIC, {3331, 491951609}) = 0
write(3, "\1\0\0\0\0\0\0\0", 8) = 8
mmap2(NULL, 8388608, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x68865000
mprotect(0x68865000, 4096, PROT_NONE) = 0
clone(child_stack=0x69063f88, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND| CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARE NT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x690644b8, tls=0x69064910, child_tidptr=0x690644b8) = 928
futex(0x1ef6da0, FUTEX_WAKE_PRIVATE, 1) = 1
write(3, "\1\0\0\0\0\0\0\0", 8) = 8
write(3, "\1\0\0\0\0\0\0\0", 8) = 8
mmap2(NULL, 8388608, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x68065000
mprotect(0x68065000, 4096, PROT_NONE) = 0
clone(child_stack=0x68863f88, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND| CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARE NT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x688644b8, tls=0x68864910, child_tidptr=0x688644b8) = 929
clock_gettime(CLOCK_MONOTONIC, {3331, 499909732}) = 0
poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}, {fd=18, events=POLLIN}], 4, 0) = 1 ([{fd=3, revents=POLLIN}])
write(3, "\1\0\0\0\0\0\0\0", 8) = 8
write(3, "\1\0\0\0\0\0\0\0", 8) = 8
futex(0x75df7578, FUTEX_WAKE_PRIVATE, 1) = 0
write(3, "\1\0\0\0\0\0\0\0", 8) = 8
futex(0x75df7578, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x75df7578, FUTEX_WAIT_PRIVATE, 3, NULL) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x75df7578, FUTEX_WAKE_PRIVATE, 1) = 0
brk(0x2046000) = 0x2046000
futex(0x75df7578, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x75df7578, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x75df7578, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x75df7578, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x75df7578, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x75df7578, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x75df7578, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0x1e407ac, FUTEX_WAKE_OP_PRIVATE, 1, 1, 0x1e407a8, {FUTEX_OP_SET, 0, FUTEX_OP_CMP_GT, 1}) = 1
futex(0x1e40790, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x1e404a4, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x1e40474, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x1e404d4, FUTEX_WAIT_PRIVATE, 3, NULLQWidget: Cannot create a QWidget without QApplication
<unfinished ...>
+++ killed by SIGABRT +++
Aborted

anda_skoa
25th May 2016, 11:13
Hmm, there is no file access in there.

I assume /tmp is writable, most likely of type tmpfs?

Which QPA are you using? XCB with an X-Server? Can you start any other application?

Cheers,
_

mefi100
25th May 2016, 11:36
You are correct about tmp, my fstab is like this

proc /proc proc defaults 0 0
/dev/mmcblk0p1 /boot vfat defaults,ro 0 2
/dev/mmcblk0p2 / ext4 defaults,noatime,ro 0 1
# a swapfile is not a swap partition, no line here
# use dphys-swapfile swap[on|off] for that
tmpfs /tmp tmpfs nosuid,nodev 0 0
tmpfs /var/log tmpfs nosuid,nodev 0 0
tmpfs /var/tmp tmpfs nosuid,nodev 0 0

I tried running a few applications and they run ok as log as I dont use video qml elements. I am using a image found here http://thebugfreeblog.blogspot.rs/2016/03/fully-optimised-raspbian-jessie-lite.html?showComment=1460636270248#c4904161712099 995888 it is optimised for playing videos(which I must do in application), but it looks like it can't be run on read only system. for some reason...

Looks like I will have to consult that image author about this problem.

By the way thanks for ideas on what to try and what to do once again.

[EDIT] - My mistake, other applications with video qml elements work, I just forgot to add a single directive on start, so it seams this is not problem with image...

Garretttews
17th September 2016, 09:16
It is possible to connect LJ DAQ eg. U3 to Raspberry Pi and get it working?Raspberry uses Debian on ARM processor.I would like to control LJ U3 by Python application.

rainsee
25th October 2016, 04:39
You could run the program with strace and see which file it tries to write to, though I wonder why it would fail that way even if it can't.