WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: piCore 9.0.3 boot to python script with GUI  (Read 22295 times)

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11594
Re: piCore 9.0.3 boot to python script with GUI
« Reply #30 on: May 12, 2020, 11:33:01 AM »
Hi Pacca
... You might want to take a look at this to see if it affects piCore too:
http://forum.tinycorelinux.net/index.php/topic,23333.msg146167.html#msg146167
I think this might be affecting piCore too.

I found this in your  messages  file:
Code: [Select]
Jan  1 00:00:43 box local2.notice sudo:       tc : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/local/tce.installed/fontconfig
Jan  1 00:00:47 box local2.notice sudo:       tc : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/sbin/udevadm trigger
It appears the  /usr/local/tce.installed/fontconfig  script is taking about 4 seconds to complete.

See if this eliminates that delay (you will need  squashfs-tools.tcz  for this):
Code: [Select]
# Change to the extensions directory.
cd /etc/sysconfig/tcedir/optional

# Unpack the extension.
unsquashfs fontconfig.tcz

# Rewrite the installed script so it backgrounds the  fc-cache  command.
echo -e "#!/bin/sh\nfc-cache -sf 1>/dev/null &" > squashfs-root/usr/local/tce.installed/fontconfig

# Repack the extension.
mksquashfs squashfs-root/ fontconfig.tcz -noappend

# Remove the unpacked extension directory.
rm -rf squashfs-root

# Remove the  md5.txt  so an update can't overwrite your modified  fontconfig.tcz  extension.
rm -f fontconfig.tcz.md5.txt

# Back to your home directory
cd
« Last Edit: May 12, 2020, 12:01:53 PM by Rich »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11594
Re: piCore 9.0.3 boot to python script with GUI
« Reply #31 on: May 12, 2020, 12:01:18 PM »
Hi Pacca
... See if this eliminates that delay (you will need  unsquashfs.tcz  for this): ...
Sorry, that was a typo. It should have been:
Quote
See if this eliminates that delay (you will need  squashfs-tools.tcz  for this):

I'll fix my original post.

Offline Pacca

  • Newbie
  • *
  • Posts: 37
Re: piCore 9.0.3 boot to python script with GUI
« Reply #32 on: May 12, 2020, 12:01:54 PM »
Ops, I missed it :-[ Your solution works perfectly and now the boot time is 4 seconds faster! Anyway, if Xorg.tcz is not loaded the fontconfig script takes less than 1 second to complete.

3. I use copy2fs and unmount /mnt/mmcblk0p2/ to avoid problems with hard shutdown. Is mount mode enough or do I really need copy mode?
This is the last open point. Everything else is working perfectly, thank you all! 8)

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11594
Re: piCore 9.0.3 boot to python script with GUI
« Reply #33 on: May 12, 2020, 12:15:41 PM »
Hi Pacca
... Anyway, if Xorg.tcz is not loaded the fontconfig script takes less than 1 second to complete. ...
All the more reason to make the  fc-cache  command nonblocking. Its execution time appears to be affected by what other
extensions are being loaded. Processor type may also be a factor. GNUser was experiencing 12 to 14 second delay times:
http://forum.tinycorelinux.net/index.php/topic,23333.msg146174.html#msg146174

Offline Pacca

  • Newbie
  • *
  • Posts: 37
Re: piCore 9.0.3 boot to python script with GUI
« Reply #34 on: May 13, 2020, 03:36:00 AM »
Hi Rich,

your help has been invaluable, thank you. This has been a great start into the Linux world!

Regarding mount/copy modes, I gave another read to the Book. At the end of the "copy mode" section, it says:
Quote
It should be noted that using a bulk selection, that is, loading all extensions to RAM, allows the storage to be unmounted, and the system to avoid any corruption on power loss.
So I might stick with copy mode.
« Last Edit: May 13, 2020, 03:39:13 AM by Pacca »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11594
Re: piCore 9.0.3 boot to python script with GUI
« Reply #35 on: May 13, 2020, 08:40:17 AM »
Hi Pacca
... So I might stick with copy mode.
That's fine. I thought I remembered one of the piCorePlayer guys once mentioning they did some testing for corruption from power
loss and found no issues. Maybe that was Paul_123.

Just for fun, maybe you could post your boot times for copy mode and mount mode.

Offline Pacca

  • Newbie
  • *
  • Posts: 37
Re: piCore 9.0.3 boot to python script with GUI
« Reply #36 on: May 13, 2020, 10:16:44 AM »
Hi Rich,

sure, here they are! With copy mode the last entry of /var/log/messages is:
Code: [Select]
Jan  1 00:00:37 box user.info kernel: [   37.506929] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFFwhile for mount mode I obtain:
Code: [Select]
Jan  1 00:00:23 box user.info kernel: [   23.594375] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFFThis is a lot less time. I will try to search on the piCore/piCorePlayer forums something on data corruption from power loss. This is important for my project because I plan to just unplug the power cord to shut down the system.

While playing with Xorg.tcz.dep and onboot.lst, I found out that I only need to load Xlibs.tcz to run my python GUI (at least through SSH), saving up to 5 seconds. But in this configuration startx is not working and the commands in ~/.X.d are ignored. Can I run my python script from .profile? I tried and it seems to work fine, I just want to be sure that it's ok to do like this.

EDIT: I think this is the message you are referring to: http://forum.tinycorelinux.net/index.php/topic,20808.msg129936.html#msg129936. It looks like that mode is enough...
« Last Edit: May 13, 2020, 10:47:42 AM by Pacca »

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11594
Re: piCore 9.0.3 boot to python script with GUI
« Reply #37 on: May 13, 2020, 11:01:03 AM »
Hi Pacca
... This is a lot less time. ...
Yes it is. Since "faster" is a relative term, I wanted to see some numbers to put it into perspective. I'm sure this will be of interest to
others as well.

Quote
But in this configuration startx is not working and the commands in ~/.X.d are ignored.
That sounds like it is exiting the  ~/.xsession  script at  waitforX.

Instead of startx, do you see any errors if you start  Xorg  manually:
Code: [Select]
/usr/local/bin/Xorg -nolisten tcp

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11594
Re: piCore 9.0.3 boot to python script with GUI
« Reply #38 on: May 13, 2020, 11:02:41 AM »
Hi Pacca
You might also want to check  /var/log/Xorg.0.log  for errors.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11594
Re: piCore 9.0.3 boot to python script with GUI
« Reply #39 on: May 13, 2020, 11:19:13 AM »
Hi Pacca
...  I thought I remembered one of the piCorePlayer guys once mentioning they did some testing for corruption from power
loss and found no issues. ...
... EDIT: I think this is the message you are referring to: http://forum.tinycorelinux.net/index.php/topic,20808.msg129936.html#msg129936. It looks like that mode is enough...
Well done. It appears my memory is still at least partially functional. :)

Offline Pacca

  • Newbie
  • *
  • Posts: 37
Re: piCore 9.0.3 boot to python script with GUI
« Reply #40 on: May 13, 2020, 12:24:41 PM »
Hi Rich,

...Instead of startx, do you see any errors if you start  Xorg  manually:
Code: [Select]
/usr/local/bin/Xorg -nolisten tcp
Probably I did not explain myself very well. I tried not to load Xorg.tcz but only Xlibs.tcz, so I can't load Xorg manually, right? The command you suggested returns:
Code: [Select]
-sh: /usr/local/bin/Xorg: not found

Hi Pacca
You might also want to check  /var/log/Xorg.0.log  for errors.
And so there is no log as well.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11044
Re: piCore 9.0.3 boot to python script with GUI
« Reply #41 on: May 13, 2020, 12:33:12 PM »
You do need a local X server to display a picture locally. "ssh -X" (or -Y, or X11Forwarding=yes in config) uses your local computer's X server, not the remote's.
The only barriers that can stop you are the ones you create yourself.

Online Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11594
Re: piCore 9.0.3 boot to python script with GUI
« Reply #42 on: May 13, 2020, 12:44:32 PM »
Hi Pacca
... Probably I did not explain myself very well. I tried not to load Xorg.tcz but only Xlibs.tcz, so I can't load Xorg manually, right?  ...
Before you edited your post, it also said you loaded  xorg-server.tcz,  though I did not include that part in my quote.  That is what I
was responding to.

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: piCore 9.0.3 boot to python script with GUI
« Reply #43 on: May 13, 2020, 07:13:30 PM »
Hi Pacca
... So I might stick with copy mode.
That's fine. I thought I remembered one of the piCorePlayer guys once mentioning they did some testing for corruption from power
loss and found no issues. Maybe that was Paul_123.

Just for fun, maybe you could post your boot times for copy mode and mount mode.

We don't get corruptions pulling the plug with piCorePlayer, but pCP doesn't do writing to SD card once it has been configured.

I have written and tested copy2fs code but the it was never implemented in production as the anticipated corruption problem didn't arise.

When people load LMS (the music server component) as it is a database application we recommend shutting the RPi down properly.

The dirty bit on the boot partition often get set but this doesn't cause a problem. Again I wrote the code to fix this but never implemented it because no one complained and it required an extra extension loaded.

We have thousands of pCP installations and pCP has been around for over 6 years, so we would have heard if there was an corruption issue.

So it depends on your application and if you can live with a dirty bit set.

Being an ex-IT person, I had to train myself to just pull the plug. Hard to do after years of working in the computer industry...lol

Offline Pacca

  • Newbie
  • *
  • Posts: 37
Re: piCore 9.0.3 boot to python script with GUI
« Reply #44 on: May 14, 2020, 03:14:55 AM »
You do need a local X server to display a picture locally. "ssh -X" (or -Y, or X11Forwarding=yes in config) uses your local computer's X server, not the remote's.
Hi Curaga,
I was suspecting this. Finally now I have a mini hdmi to hdmi cable and I could test myself this behavior. So I loaded back xorg-server.tcz.

Hi Pacca
Before you edited your post, it also said you loaded  xorg-server.tcz,  though I did not include that part in my quote.  That is what I
was responding to.
Hi Rich,
sorry for my bad habit of editing continuously my posts  :-[ Anyway, I xorg-server.tcz is back in my onboot.lst. Using the command you suggested, I got this error (both using ssh or an external display):
Code: [Select]
X.Org X Server 1.18.3
Release Date: 2016-04-04
X Protocol Version 11, Revision 0
Build Operating System: Linux 4.4.15-piCore_v7+ armv7l
Current Operating System: Linux box 4.9.22-piCore #1 Sat Apr 15 15:30:03 UTC 2017 armv6l
Kernel command line: bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enabe=0 console=/dev/null,115200 root=/dev/ram0 elevator=deadline rootwait quiet nortc loglevel=3 noembed avoid_warnings=1 logo.nologo vt.global_cursor_default=0 printk.time=1 syslog
Build Date: 06 August 2016  05:29:32PM

Current version of pixman: 0.34.0
Before reporting problems, check http://wiki.x.org to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting, (++) from command line, (!!) notice, (II) informational, (WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/usr/local/var/log/Xorg.0.log", Time: Wed May 13 18:55:51 2020
(==) Using system config directory "/usr/local/share/X11/xorg.conf.d"
(EE) Fatal server error:
(EE) no screens found
(EE)
(EE) Please consult the The X.Org Foundation support at http://wiki.x.org for help.
(EE) Please also check the log file at "/usr/local/var/log/Xorg.0.log" for additional information.
(EE)
(EE) Server terminated with error (1). Closing log file.
Here the content of usr/local/var/log/Xorg.0.log https://pastebin.com/1pz3s1Z1. I do not understand why there is a no screen found error even when the raspberry is attached to the external screen.

We don't get corruptions pulling the plug with piCorePlayer, but pCP doesn't do writing to SD card once it has been configured.

I have written and tested copy2fs code but the it was never implemented in production as the anticipated corruption problem didn't arise.

When people load LMS (the music server component) as it is a database application we recommend shutting the RPi down properly.

The dirty bit on the boot partition often get set but this doesn't cause a problem. Again I wrote the code to fix this but never implemented it because no one complained and it required an extra extension loaded.

We have thousands of pCP installations and pCP has been around for over 6 years, so we would have heard if there was an corruption issue.

So it depends on your application and if you can live with a dirty bit set.
Hi Greg Erskine,
after booting piCore I load only a Python script that doesn't write anything to the disk during its functioning. My setup is a headless raspberry so issuing the shutdown command is not an option. The other path could have been to use a supercapacitor shield but that is a completely different difficulty level. So I think that using mount mode can be safe enough also in my case.
Being an ex-IT person, I had to train myself to just pull the plug. Hard to do after years of working in the computer industry...lol
Shock therapy sometimes works!