Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: Pacca on April 24, 2020, 08:30:40 AM

Title: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on April 24, 2020, 08:30:40 AM
Dear all,

I arrived here searching for some help to complete a project using Raspberry Pi Zero (without Wi-Fi). I decided to use piCore for its feature of running on RAM. The reason behind this decision is that for this project the Pi Zero will be often shutdown "improperly" just removing the power connector. I am quite new to Linux and Tiny Core, but let me explain what I am trying to do.

I have a Pi Zero attached to an external monitor. No keyboard or mouse is used, just a few external push buttons. My intention is to boot the system as fast as possible (3 seconds maximum, is this even possible?) and to load directly a python script with a TK GUI, without passing through the OS desktop.

I am not quite sure how to achieve this, some help will be more than appreciated.

Another question, if I attach the Pi Zero to my Windows laptop, can I control the board through Putty directly, or do I have to install some additional packages?

Thank you very much!
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on April 24, 2020, 09:00:12 AM
Hi Pacca
If you are launching this from the console (text mode) then add the command to start your program to the end of your  ~/.profile  file.

If you are going to be running this under X (Xvesa, Xorg, Xfbdev) then add a file (any name you want) to your  ~/.X.d directory
containing the command to start your program.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: curaga on April 24, 2020, 10:01:57 AM
Side note, you're not going to get a 3s boot to GUI on such slow hw. Likely even the kernel will take longer than that.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Greg Erskine on April 24, 2020, 01:17:46 PM
For fast booting see Bare Metal:

https://www.raspberrypi.org/forums/viewforum.php?f=72
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on April 25, 2020, 03:09:25 AM
Hi Pacca
If you are launching this from the console (text mode) then add the command to start your program to the end of your  ~/.profile  file.

If you are going to be running this under X (Xvesa, Xorg, Xfbdev) then add a file (any name you want) to your  ~/.X.d directory
containing the command to start your program.

Thank you very much Rich, I will try what you suggested. Since my script generates a GUI, I will use it under X. Adding the command to the ~/.X.d directory, will it load before creating the PiCore desktop environment? I don't what the desktop to be visible.

Side note, you're not going to get a 3s boot to GUI on such slow hw. Likely even the kernel will take longer than that.
Thanks curaga, I will check what is the standard loading time with the Pi Zero for standard Pi Core. Any suggestions for how to reduce the boot time?

For fast booting see Bare Metal:

https://www.raspberrypi.org/forums/viewforum.php?f=72
Thank you for the link Greg, but I think that this goes beyond my actual knowledge and time for this project.

Another question, if I attach the Pi Zero to my Windows laptop, can I control the board through Putty directly, or do I have to install some additional packages?
OTG connection will work directly without additional modifications?

Again, thank you all for the great support!
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on April 25, 2020, 04:12:45 AM
OTG connection will work directly without additional modifications?

piCore is setup so ssh runs by default on boot - I presume this will work with putty on windows:

address: tc@ip_address (example tc@192.168.1.111)
password: piCore
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on April 25, 2020, 06:16:13 AM
Hi Pacca
... Adding the command to the ~/.X.d directory, will it load before creating the PiCore desktop environment? I don't what the desktop to be visible. ...
If you don't install a desktop, you won't get a desktop. Take a look inside  ~/.xsession:

The line that contains the  $DESKTOP  environmental variable is what starts the desktop. It gets set when a desktop (window manager)
gets installed or if you pass a  desktop=  boot code to your bootloader. If the  $DESKTOP  environmental variable is not set, then it
won't start anything.

The line that contains  $HOME/.X.d  scans your  ~/.X.d directory. For each file it finds, it executes each line in that file.

Quote
Any suggestions for how to reduce the boot time?
Add the following boot codes to your bootloader:
Code: [Select]
printk.time=1 syslogThen check  dmesg  and  /var/log/messages  for potential bottlenecks.
Don't load extensions you don't need.
Go to the search page:
http://forum.tinycorelinux.net/index.php?action=search
Search for something like  fast boot  or  reduce boot time  to see what others have done.
This sounds like it might be a kiosk type of setup, so try searching for  kiosk.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on April 26, 2020, 10:17:30 AM
OTG connection will work directly without additional modifications?

piCore is setup so ssh runs by default on boot - I presume this will work with putty on windows:

address: tc@ip_address (example tc@192.168.1.111)
password: piCore

My Pi Zero is the version without Wi-Fi. I added to the bottom of config.txt the line
Code: [Select]
dtoverlay=dwc2 and I added to command.txt the text
Code: [Select]
modules-load=dwc2,g_ether However, the ping request to raspberrypi.local is not working. What should I do? Unfortunately I have no display and keyboard right now, that's why I am trying to setup the PiCore on my Pi Zero from my Windows laptop.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on April 26, 2020, 10:38:38 AM
You should not have had to edit anything for the wired connection to work.

Do you have a means to scan for the RPi’s IP address?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Greg Erskine on April 26, 2020, 02:02:49 PM
Quote from: Pacca
However, the ping request to raspberrypi.local is not working. What should I do? Unfortunately I have no display and keyboard right now, that's why I am trying to setup the PiCore on my Pi Zero from my Windows laptop.

You have to remember piCore is extremely minimal, setting things like raspberrypi.local requires extra software, zeroconf or Avahi. If I remember correctly adding zero config increases the size of the distribution by 50%, there was a lot of dependencies!

Find your RPi's IP address using a tool on your PC or look at your router.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on April 26, 2020, 11:36:37 PM
I don't think I was very clear. I just attached the Pi Zero to my laptop via usb and I am trying to connect to the board locally. So I don't have internet connection. I can't find clear instructions here ok the forum. Is it that hard? Should I buy a usb-ethernet adapter?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on April 27, 2020, 12:45:44 AM
By default PiCore will work in the following modes:

* standalone with screen, keyboard and mouse attached
* headless with wired network cable attached

ssh is enabled on the RPi by piCore by default, so you should not have to change or edit anything on the RPi to connect over a network with ssh.

Things might work using a usb cable to a windows pc, but if so, the name windows sees is likely to be tc@box.local
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on April 27, 2020, 01:16:24 AM
From searching the web, it looks like the dwc2.ko (depends on udc-core.ko) and g_ether.ko (depends on libcomposite.ko ,u_ether.ko, usb_f_rndiskernel.ko) modules are required for the usb cable connection to work.

These modules are not included in the base piCore and so would need to be added from the relevant 4.9.22-piCore*_modules.tar.xz on the server.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on April 27, 2020, 02:08:51 AM
Thank you very much Juanito for you patience, I'm trying to get used to Linux and PiCore. Probably the best way right now is to use a micro usb to ethernet adapter, since I need to enter into PiCore to add the new modules to the kernel. I will keep you posted if everything works out!
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 02, 2020, 06:56:15 AM
I'm still struggling with the setup of PiCore. I don't have the right HDMI cable yet, so in the meantime I am trying to use a wired network connection. I copied net-usb-4.9.22-piCore.tcz and net-usb-4.9.22-piCore.tcz.md5.txt into /tce/optional and edited onboot.lst to include this extension. Still the Pi Zero is not getting an IP address in my router homepage. I think I have to wait for screen and keyboard.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 02, 2020, 07:13:14 AM
..but the drivers you need are not in net-usb-4.9.22-piCore.

As mentioned, they are here:

http://tinycorelinux.net/9.x/armv6/releases/RPi/src/kernel/4.9.22-piCore_modules.tar.xz

..you will need to extract them and create your own extension
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 02, 2020, 08:44:55 AM
Even for the usb to ethernet adapter?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 02, 2020, 08:57:44 AM
Ah, sorry, I thought you were speaking of a direct usb cable connection.

How did you try to connect to the RPi0? Which commands did you use?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 02, 2020, 09:40:32 AM
I just connected the board to the ethernet port using an usb adapter, however I see no device attached to the router from its main web page.

From the previous answers I thought that the connection over wire was automatically established. Am I wrong? Because I have no monitor or keyboard attached so I can't send any command. That's why I am trying to connect the board to the internet and access it through putty.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 02, 2020, 09:50:25 AM
The RPi's with an onboard ethernet port will automatically connect to a router when booted with piCore.

I don't know if this is the case or not for a usb ethernet adapter.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Greg Erskine on May 02, 2020, 02:17:50 PM
I just connected the board to the ethernet port using an usb adapter, however I see no device attached to the router from its main web page.

From the previous answers I thought that the connection over wire was automatically established. Am I wrong? Because I have no monitor or keyboard attached so I can't send any command. That's why I am trying to connect the board to the internet and access it through putty.

Yes it should be automatic. The USB ethernet adaptors I have tried have leds that light up indicating things are working.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 08, 2020, 05:52:52 AM
I finally managed to connect my Pi Zero to the internet! It was just a faulty usb adapter. Now I will continue with the configuration of the PiCore. Thank you all for the support!
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 11, 2020, 12:43:46 AM
I was able to install python3.6 and all the libraries that I need to run my script. Now I am trying to create the GUI. Do I need Xorg.tcz in addition to tk.tcz to create the graphical interface?

Bonus question: there is any difference between creating an extension from a python library that is loaded into ram using copy2fs.flg, and installing it through command pip install and making a backup?

Next step is boot time optimization!
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 11, 2020, 01:32:45 AM
Creating an extension and loading it copy2fs will be quicker than restoring a backup of a pip install - compiling the library with piCore flags will be better still.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 11, 2020, 08:41:41 AM
Thank you, I will try to understand how to create an extension or how to compile the library as last step of this project.

In the meantime, everything is finally working. I managed to install Python and its libraries, the script loads at startup with no problems, and X11 forwarding is working as well (while I am waiting for the HDMI cable to arrive). Thank you all for the great support!

Now I am trying to reduce the boot time, that seems to be much longer since I installed Xorg.tcz, Xprogs.tcz, Xlibs.tcz, xorg-server.tcz. Here the results of dmesg:
Code: [Select]
[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 4.9.22-piCore (root@box) (gcc version 6.3.0 (piCore) ) #1 Sat Apr 15 15:30:03 UTC 2017
[    0.000000] CPU: ARMv6-compatible processor [410fb767] revision 7 (ARMv7), cr=00c5387d
[    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT nonaliasing instruction cache
[    0.000000] OF: fdt:Machine model: Raspberry Pi Zero Rev 1.3
[    0.000000] cma: Reserved 8 MiB at 0x1b000000
[    0.000000] Memory policy: Data cache writeback
[    0.000000] On node 0 totalpages: 114688
[    0.000000] free_area_init_node: node 0, pgdat c0931188, node_mem_map dac10000
[    0.000000]   Normal zone: 1008 pages used for memmap
[    0.000000]   Normal zone: 0 pages reserved
[    0.000000]   Normal zone: 114688 pages, LIFO batch:31
[    0.000000] pcpu-alloc: s0 r0 d32768 u32768 alloc=1*32768
[    0.000000] pcpu-alloc: [0] 0
[    0.000000] Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 113680
[    0.000000] 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_enable=0 console=ttyAMA0,115200 root=/dev/ram0 elevator=deadline rootwait quiet nortc loglevel=3 noembed waitusb=1 printk.time=1 syslog
[    0.000000] PID hash table entries: 2048 (order: 1, 8192 bytes)
[    0.000000] Dentry cache hash table entries: 65536 (order: 6, 262144 bytes)
[    0.000000] Inode-cache hash table entries: 32768 (order: 5, 131072 bytes)
[    0.000000] Memory: 431364K/458752K available (6035K kernel code, 492K rwdata, 1968K rodata, 400K init, 739K bss, 19196K reserved, 8192K cma-reserved)
[    0.000000] Virtual kernel memory layout:
[    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
[    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
[    0.000000]     vmalloc : 0xdc800000 - 0xff800000   ( 560 MB)
[    0.000000]     lowmem  : 0xc0000000 - 0xdc000000   ( 448 MB)
[    0.000000]     modules : 0xbf000000 - 0xc0000000   (  16 MB)
[    0.000000]       .text : 0xc0008000 - 0xc05ecef4   (6036 kB)
[    0.000000]       .init : 0xc085c000 - 0xc08c0000   ( 400 kB)
[    0.000000]       .data : 0xc08c0000 - 0xc093b038   ( 493 kB)
[    0.000000]        .bss : 0xc093b038 - 0xc09f3e60   ( 740 kB)
[    0.000000] SLUB: HWalign=32, Order=0-3, MinObjects=0, CPUs=1, Nodes=1
[    0.000000] NR_IRQS:16 nr_irqs:16 16
[    0.000028] sched_clock: 32 bits at 1000kHz, resolution 1000ns, wraps every 2147483647500ns
[    0.000058] clocksource: timer: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 1911260446275 ns
[    0.000150] bcm2835: system timer (irq = 27)
[    0.000592] Console: colour dummy device 80x30
[    0.000623] Calibrating delay loop... 697.95 BogoMIPS (lpj=3489792)
[    0.060289] pid_max: default: 32768 minimum: 301
[    0.060703] Mount-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.060717] Mountpoint-cache hash table entries: 1024 (order: 0, 4096 bytes)
[    0.061775] Disabling cpuset control group subsystem
[    0.061975] CPU: Testing write buffer coherency: ok
[    0.062033] ftrace: allocating 21825 entries in 65 pages
[    0.180353] Setting up static identity map for 0x8200 - 0x8238
[    0.182348] devtmpfs: initialized
[    0.191309] VFP support v0.3: implementor 41 architecture 1 part 20 variant b rev 5
[    0.191734] clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
[    0.191758] futex hash table entries: 256 (order: -1, 3072 bytes)
[    0.193032] pinctrl core: initialized pinctrl subsystem
[    0.194462] NET: Registered protocol family 16
[    0.197058] DMA: preallocated 1024 KiB pool for atomic coherent allocations
[    0.207014] hw-breakpoint: found 6 breakpoint and 1 watchpoint registers.
[    0.207029] hw-breakpoint: maximum watchpoint size is 4 bytes.
[    0.207134] Serial: AMBA PL011 UART driver
[    0.209884] bcm2835-mbox 2000b880.mailbox: mailbox enabled
[    0.258825] bcm2835-dma 20007000.dma: DMA legacy API manager at dc80d000, dmachans=0x1
[    0.261585] SCSI subsystem initialized
[    0.261851] usbcore: registered new interface driver usbfs
[    0.262005] usbcore: registered new interface driver hub
[    0.262201] usbcore: registered new device driver usb
[    0.270415] raspberrypi-firmware soc:firmware: Attached to firmware from 2017-04-04 18:41
[    0.272340] clocksource: Switched to clocksource timer
[    0.326859] VFS: Disk quotas dquot_6.6.0
[    0.326974] VFS: Dquot-cache hash table entries: 1024 (order 0, 4096 bytes)
[    0.327267] FS-Cache: Loaded
[    0.327629] CacheFiles: Loaded
[    0.347160] NET: Registered protocol family 2
[    0.348492] TCP established hash table entries: 4096 (order: 2, 16384 bytes)
[    0.348579] TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
[    0.348651] TCP: Hash tables configured (established 4096 bind 4096)
[    0.348745] UDP hash table entries: 256 (order: 0, 4096 bytes)
[    0.348771] UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
[    0.349061] NET: Registered protocol family 1
[    0.349796] RPC: Registered named UNIX socket transport module.
[    0.349807] RPC: Registered udp transport module.
[    0.349811] RPC: Registered tcp transport module.
[    0.349816] RPC: Registered tcp NFSv4.1 backchannel transport module.
[    0.350269] Trying to unpack rootfs image as initramfs...
[    0.994005] Freeing initrd memory: 4464K (dbb94000 - dbff0000)
[    1.025862] hw perfevents: enabled with armv6_1176 PMU driver, 3 counters available
[    1.028216] workingset: timestamp_bits=14 max_order=17 bucket_order=3
[    1.044619] zbud: loaded
[    1.048765] FS-Cache: Netfs 'nfs' registered for caching
[    1.050470] NFS: Registering the id_resolver key type
[    1.050529] Key type id_resolver registered
[    1.050535] Key type id_legacy registered
[    1.059972] jitterentropy: Initialization failed with host not compliant with requirements: 2
[    1.060147] Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
[    1.060520] io scheduler noop registered
[    1.060532] io scheduler deadline registered (default)
[    1.060994] io scheduler cfq registered
[    1.067298] BCM2708FB: allocated DMA memory 5b100000
[    1.067359] BCM2708FB: allocated DMA channel 0 @ dc80d000
[    1.075085] Console: switching to colour frame buffer device 82x26
[    1.082531] bcm2835-rng 20104000.rng: hwrng registered
[    1.082706] vc-cma: Videocore CMA driver
[    1.082716] vc-cma: vc_cma_base      = 0x00000000
[    1.082724] vc-cma: vc_cma_size      = 0x00000000 (0 MiB)
[    1.082729] vc-cma: vc_cma_initial   = 0x00000000 (0 MiB)
[    1.083149] vc-mem: phys_addr:0x00000000 mem_base=0x1ec00000 mem_size:0x20000000(512 MiB)
[    1.108524] brd: module loaded
[    1.120949] loop: module loaded
[    1.120969] Loading iSCSI transport class v2.0-870.
[    1.121944] usbcore: registered new interface driver smsc95xx
[    1.121972] dwc_otg: version 3.00a 10-AUG-2012 (platform bus)
[    1.348142] Core Release: 2.80a
[    1.348158] Setting default values for core params
[    1.348195] Finished setting default values for core params
[    1.548546] Using Buffer DMA mode
[    1.548560] Periodic Transfer Interrupt Enhancement - disabled
[    1.548565] Multiprocessor Interrupt Enhancement - disabled
[    1.548574] OTG VER PARAM: 0, OTG VER FLAG: 0
[    1.548662] Dedicated Tx FIFOs mode
[    1.549318] WARN::dwc_otg_hcd_init:1053: FIQ DMA bounce buffers: virt = 0xdb114000 dma = 0x5b114000 len=9024
[    1.549345] FIQ FSM acceleration enabled for :
[    1.549345] Non-periodic Split Transactions
[    1.549345] Periodic Split Transactions
[    1.549345] High-Speed Isochronous Endpoints
[    1.549345] Interrupt/Control Split Transaction hack enabled
[    1.549357] dwc_otg: Microframe scheduler enabled
[    1.549441] WARN::hcd_init_fiq:459: FIQ on core 0 at 0xc0466f8c
[    1.549455] WARN::hcd_init_fiq:460: FIQ ASM at 0xc0467268 length 36
[    1.549480] WARN::hcd_init_fiq:486: MPHI regs_base at 0xdc8a5000
[    1.549551] dwc_otg 20980000.usb: DWC OTG Controller
[    1.549615] dwc_otg 20980000.usb: new USB bus registered, assigned bus number 1
[    1.549699] dwc_otg 20980000.usb: irq 56, io mem 0x00000000
[    1.549753] Init: Port Power? op_state=1
[    1.549757] Init: Power Port (0)
[    1.550139] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    1.550156] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.550165] usb usb1: Product: DWC OTG Controller
[    1.550175] usb usb1: Manufacturer: Linux 4.9.22-piCore dwc_otg_hcd
[    1.550184] usb usb1: SerialNumber: 20980000.usb
[    1.551418] hub 1-0:1.0: USB hub found
[    1.551510] hub 1-0:1.0: 1 port detected
[    1.552559] dwc_otg: FIQ enabled
[    1.552569] dwc_otg: NAK holdoff enabled
[    1.552574] dwc_otg: FIQ split-transaction FSM enabled
[    1.552596] Module dwc_common_port init
[    1.553101] usbcore: registered new interface driver usb-storage
[    1.553565] mousedev: PS/2 mouse device common for all mice
[    1.555150] bcm2835-wdt 20100000.watchdog: Broadcom BCM2835 watchdog timer
[    1.555670] bcm2835-cpufreq: min=700000 max=1000000
[    1.557052] sdhci: Secure Digital Host Controller Interface driver
[    1.557059] sdhci: Copyright(c) Pierre Ossman
[    1.557397] sdhost-bcm2835 20202000.sdhost: could not get clk, deferring probe
[    1.557618] sdhci-pltfm: SDHCI platform and OF driver helper
[    1.558132] ledtrig-cpu: registered to indicate activity on CPUs
[    1.558281] hidraw: raw HID events driver (C) Jiri Kosina
[    1.558482] usbcore: registered new interface driver usbhid
[    1.558487] usbhid: USB HID core driver
[    1.559405] vchiq: vchiq_init_state: slot_zero = 0xdb180000, is_master = 0
[    1.561503] Initializing XFRM netlink socket
[    1.561545] NET: Registered protocol family 17
[    1.561681] Key type dns_resolver registered
[    1.563549] registered taskstats version 1
[    1.563698] zswap: loaded using pool lzo/zbud
[    1.648506] Key type encrypted registered
[    1.648790] vc-sm: Videocore shared memory driver
[    1.648801] [vc_sm_connected_init]: start
[    1.649712] [vc_sm_connected_init]: end - returning 0
[    1.654797] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    1.654875] console [ttyAMA0] enabled
[    1.656631] sdhost: log_buf @ db113000 (5b113000)
[    1.732384] mmc0: sdhost-bcm2835 loaded - DMA enabled (>1)
[    1.752589] of_cfs_init
[    1.752693] of_cfs_init: OK
[    1.753164] uart-pl011 20201000.serial: no DMA platform data
[    1.754230] Freeing unused kernel memory: 400K (c085c000 - c08c0000)
[    1.754235] This architecture does not have kernel memory protection.
[    1.790208] Indeed it is in host mode hprt0 = 00021501
[    1.853088] random: fast init done
[    1.973978] mmc0: host does not support reading read-only switch, assuming write-enable
[    1.976681] mmc0: new high speed SDHC card at address aaaa
[    1.982748] mmcblk0: mmc0:aaaa SL16G 14.8 GiB
[    1.985746]  mmcblk0: p1 p2
[    2.082460] usb 1-1: new full-speed USB device number 2 using dwc_otg
[    2.082702] Indeed it is in host mode hprt0 = 00021501
[    2.394538] usb 1-1: New USB device found, idVendor=0fe6, idProduct=9700
[    2.394554] usb 1-1: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[    2.394561] usb 1-1: Product: USB 2.0 10/100M Ethernet Adaptor
[    3.559613] gpiomem-bcm2835 20200000.gpiomem: Initialised: Registers at 0x20200000
[    4.098168] zram: Added device: zram0
[    4.145310] zram0: detected capacity change from 0 to 106336256
[    4.167847] Adding 103840k swap on /dev/zram0.  Priority:-1 extents:1 across:103840k SSFS
[    4.472794] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    5.540568] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[    5.656487] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
[   20.406856] random: crng init done
[   51.337636] i2c /dev entries driver
[   53.442653] sr9700 1-1:1.0 (unnamed net_device) (uninitialized): Error reading MAC address
[   53.442896] usbcore: registered new interface driver sr9700
[   53.463731] dm9601 1-1:1.0 eth0: register 'dm9601' at usb-20980000.usb-1, Davicom DM96xx USB 10/100 Ethernet, 00:e0:4c:53:44:58
[   53.466023] usbcore: registered new interface driver dm9601
[   53.609404] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
[   53.695936] dm9601 1-1:1.0 eth0: kevent 4 may have been dropped
[   53.725864] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
[   53.820238] dm9601 1-1:1.0 eth0: link up, 100Mbps, full-duplex, lpa 0xFFFF
I still have to remove the command waitusb=1 from cmdline.txt. However I can't understand the log very well. Up to 5.656487 seconds everything seems ok, probably I can reduce the boot time furthermore only by compiling the python libraries (right now I am restoring a backup). After that, I don't know what is happening till 20.406856 seconds and afterwards.

Just to note, in the final configuration the Pi0 will not be connected to the ethernet cable. Can I disable somehow the ethernet connection?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 11, 2020, 09:44:23 AM
Hi Pacca
... After that, I don't know what is happening till 20.406856 seconds and afterwards. ...
Take a look in  /var/log/messages  (and  /var/log/messages.0  if  /var/log/messages filled up)  for more detailed timing information.
It will include extension loading, execution of  /usr/local/tce.installed/ExtensionName  scripts interleaved with the kernel messages.

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
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 12, 2020, 12:57:59 AM
Hi Rich,

thank you for your help. I'm impressed by how supportive this forum is! This is the /var/log/messages content. https://pastebin.com/wwPtpRy7 (https://pastebin.com/wwPtpRy7). Does it mean that it takes from 5.656487 to 51.337636 to load all the extensions and restore the backup? If that's the case, I think there is no way I can short the boot time. Am I right? Regarding your link, I don't see any strange delay between the log entries so probably it does not affects piCore.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 12, 2020, 07:03:44 AM
Hi Pacca
I have 3 recommendations to speed things up:
1. Stop loading unneeded extensions. One glaring example I noticed was  -dev.tcz  extensions. Those are only needed for compiling.
2. Check your  /opt/.filetool.lst  for unnecessary entries. If you're not sure, post the contents of  /opt/.filetool.lst  here.
3. Don't use  copy2fs  if you don't need to. Stick to  mount mode.

You can try any of these 3 recommendations individually or together to measure their impact.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 12, 2020, 08:06:18 AM
Hi Rich,

1. I needed -dev.tcz during the setup of the system, I didn't know I could remove them now. Great! Now I will try removing Xorg.tcz too and see if the Python GUI keeps working. Because removing this extension reduces the boot time of around 20 seconds.
2. This is my /opt/.filetool.lst:
Code: [Select]
opt
home
etc/passwd
etc/shadow
etc/group
etc/gshadow
usr/local/etc/ssh/ssh_host_dsa_key
usr/local/etc/ssh/ssh_host_dsa_key.pub
usr/local/etc/ssh/ssh_host_ecdsa_key
usr/local/etc/ssh/ssh_host_ecdsa_key.pub
usr/local/etc/ssh/ssh_host_ed25519_key
usr/local/etc/ssh/ssh_host_ed25519_key.pub
usr/local/etc/ssh/ssh_host_rsa_key
usr/local/etc/ssh/ssh_host_rsa_key.pub
usr/local/lib/python3.6/site-packages
usr/local/lib/python3.6/site-packages/pad4pi
usr/local/lib/python3.6/site-packages/pad4pi-1.1.5-py3.6.egg-info
usr/local/lib/python3.6/site-packages/simpleaudio
usr/local/lib/python3.6/site-packages/simpleaudio-1.0.4-py3.6.egg-info
I added only the entries referring to the python libs. Can I remove all the etc/... and usr/local/etc/... entries? Keep in mind that I have to setup the system once and never connect it to a pc again. So I was thinking of removing openssh.tcz from onboot.lst.
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?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 12, 2020, 08:15:06 AM
Hi Pacca
2. Your  /opt/.filetool.lst  looks OK to me. Leave the  etc  and  usr/local  entries in there.
3. I believe Greg Erskine is better versed on that topic, so I'll let him address it.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 12, 2020, 08: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
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 12, 2020, 09:01:18 AM
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.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 12, 2020, 09:01:54 AM
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)
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 12, 2020, 09:15:41 AM
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
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 13, 2020, 12: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.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 13, 2020, 05: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.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 13, 2020, 07: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 (http://forum.tinycorelinux.net/index.php/topic,20808.msg129936.html#msg129936). It looks like that mode is enough...
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 13, 2020, 08: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
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 13, 2020, 08:02:41 AM
Hi Pacca
You might also want to check  /var/log/Xorg.0.log  for errors.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 13, 2020, 08: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 (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. :)
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 13, 2020, 09:24:41 AM
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.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: curaga on May 13, 2020, 09:33:12 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.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 13, 2020, 09:44:32 AM
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.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Greg Erskine on May 13, 2020, 04: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
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 14, 2020, 12: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 (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!
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 14, 2020, 01:43:30 AM
I read more carefully usr/local/var/log/Xorg.0.log. Following the errors, I am now loading also xf86-video-fbturbo.tcz, xf86-input-evdev.tcz, xkeyboard-config.tcz and xkbcomp.tcz (almost all the extensions installed with Xorg.tcz http://tinycorelinux.net/9.x/armv6/tcz/Xorg.tcz.dep (http://tinycorelinux.net/9.x/armv6/tcz/Xorg.tcz.dep)). startx works again and the commands in ./.X.d as well. So probably only Xprogs.tcz is not necessary, right?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 14, 2020, 06:15:57 AM
Hi Pacca
... So probably only Xprogs.tcz is not necessary, right?
That sounds correct.  Xprogs  provides the programs and icons that show up in the wbar at the bottom of the screen. I don't see
anything in there that you would need for what sounds like an embedded application.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 14, 2020, 06:24:36 AM
Hi Pacca
... So probably only Xprogs.tcz is not necessary, right?
That sounds correct.  Xprogs  provides the programs and icons that show up in the wbar at the bottom of the screen. I don't see
anything in there that you would need for what sounds like an embedded application.
Hi Rich,
yes it is an embedded application, and it looks like the software side of the project is finally complete. Thank you very much!

... My intention is to boot the system as fast as possible (3 seconds maximum, is this even possible?) and to load directly a python script with a TK GUI, without passing through the OS desktop.
Even if the boot time is not even close to 3 seconds, it works perfectly. It takes a little less than 30 seconds to start the GUI script, but still it is great. And I learned a lot in the process.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 14, 2020, 06:32:58 AM
Hi Pacca
If you like, you can attach a fresh copy of  messages.txt  to your next post (not pastebin) and I'll see if I can spot any other issues.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 14, 2020, 07:02:20 AM
Hi Rich,

sure, here it is! I'll offer you a beer if you can spot anything more ;D
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 14, 2020, 09:04:27 AM
Hi Pacca
I don't see a whole lot to work with, so here are a few minor observations:

I don't have any Pi hardware so the only baseline I have to compare against is x86. On 3 machines running different TC kernels
the rootfs unpack time is 0.20 to 0.25 seconds. Your Pi takes ~0.64 seconds. Depending on the trade off between file read
speed and decompression speed, you might be able to pick up a couple hundred  milliseconds  by lowering or increasing the
compression ratio.
Code: [Select]
Jan  1 00:00:04 box user.info kernel: [    0.350381] Trying to unpack rootfs image as initramfs...
Jan  1 00:00:04 box user.info kernel: [    0.994230] Freeing initrd memory: 4464K (dbb94000 - dbff0000)


The  squashfs  driver is taking almost a full second to load. My machines (oldest to newest) take 0.04, 0.125, and 0.04 seconds.
I may be comparing apples to oranges, so just for some context, my oldest machine is a Dell 800 Mhz Pentium III from 2002 running TC4.
Code: [Select]
Jan  1 00:00:04 box user.info kernel: [    4.307435] squashfs: version 4.0 (2009/01/31) Phillip Lougher
Jan  1 00:00:05 box user.info kernel: [    5.388360] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
Jan  1 00:00:05 box user.info kernel: [    5.499410] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
My understanding is Pi boots off of  mmcblk0p1  and then unmounts it when booting is complete and extensions are stored on
mmcblk0p2  which stays mounted. My question is, why is  mmcblk0p2  being mounted twice?


How big is your  mydata.tgz  file? It looks like it takes about 3 seconds to restore.
Code: [Select]
Jan  1 00:00:17 box local2.notice sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/tar -C / -zxf /mnt/mmcblk0p2/tce/mydata.tgz
Jan  1 00:00:20 box user.notice kernel: [   20.388901] random: crng init done

Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 15, 2020, 12:33:37 AM
Hi Pacca
I don't see a whole lot to work with, so here are a few minor observations:
Hi Rich,
you have a good eye for spotting small inaccuracies!

The  squashfs  driver is taking almost a full second to load. My machines (oldest to newest) take 0.04, 0.125, and 0.04 seconds.
I may be comparing apples to oranges, so just for some context, my oldest machine is a Dell 800 Mhz Pentium III from 2002 running TC4.
Code: [Select]
Jan  1 00:00:04 box user.info kernel: [    4.307435] squashfs: version 4.0 (2009/01/31) Phillip Lougher
Jan  1 00:00:05 box user.info kernel: [    5.388360] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
Jan  1 00:00:05 box user.info kernel: [    5.499410] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
My understanding is Pi boots off of  mmcblk0p1  and then unmounts it when booting is complete and extensions are stored on
mmcblk0p2  which stays mounted. My question is, why is  mmcblk0p2  being mounted twice?
I know the specs of Raspberry Pi Zero on paper, but I don't know how they really compare in real life. Processor power and RAM size should be comparable, but the real difference I think is coming from the low-speed SD card. Regarding the double mount of mmcblk0p2, at first I thought it was coming from my multiple experiments with extensions, config.txt and cmdline.txt. But then in an old thread about piCore7 I saw that bmarkus has the same behavior with his Raspberry Pi 2. http://forum.tinycorelinux.net/index.php/topic,19759.msg122571.html#msg122571 (http://forum.tinycorelinux.net/index.php/topic,19759.msg122571.html#msg122571). I don't know why is being mounted twice, but probably is a function and not a bug.

How big is your  mydata.tgz  file? It looks like it takes about 3 seconds to restore.
Code: [Select]
Jan  1 00:00:17 box local2.notice sudo:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/tar -C / -zxf /mnt/mmcblk0p2/tce/mydata.tgz
Jan  1 00:00:20 box user.notice kernel: [   20.388901] random: crng init done
I know, mydata.tgz is 6.6 MB because I had to install two python libraries to run my script. Now I am still trying to understand how to build the *.tcz extensions instead of loading a big backup.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 15, 2020, 12:40:41 AM
If you build your python libraries like this:
Code: [Select]
$ python3 setup.py build
$ sudo python3 setup.py install --root=/tmp/pkg

..you can remove anything unneeded under /tmp/pkg (__pycache__ folders, *.pyc, *.pyo, etc) and then:
Code: [Select]
$ cd /tmp
$ sudo mksquashfs pkg/ mypython.tcz
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 15, 2020, 01:48:26 AM
Hi Juanito,
wow it is much easier than I thought, thanks! Anyway, I don't know why I can't reach out the wiki, it says permission denied.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 15, 2020, 01:50:04 AM
There is an ongoing problem with the wiki host.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 15, 2020, 02:07:07 AM
Alright, but I found a mirror here I think: https://www.linuxsecrets.com/tinycorelinux-wiki/ (https://www.linuxsecrets.com/tinycorelinux-wiki/).
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 15, 2020, 07:15:50 AM
Great, I had to change some paths to match piCore structure, but eventually it works. Now loading mydata.tgz takes less than 1 second.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 15, 2020, 07:40:41 AM
Hi Pacca
... The  squashfs  driver is taking almost a full second to load. My machines (oldest to newest) take 0.04, 0.125, and 0.04 seconds.
I may be comparing apples to oranges, so just for some context, my oldest machine is a Dell 800 Mhz Pentium III from 2002 running TC4.
Code: [Select]
Jan  1 00:00:04 box user.info kernel: [    4.307435] squashfs: version 4.0 (2009/01/31) Phillip Lougher
Jan  1 00:00:05 box user.info kernel: [    5.388360] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
Jan  1 00:00:05 box user.info kernel: [    5.499410] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
...
... I saw that bmarkus has the same behavior with his Raspberry Pi 2. http://forum.tinycorelinux.net/index.php/topic,19759.msg122571.html#msg122571 (http://forum.tinycorelinux.net/index.php/topic,19759.msg122571.html#msg122571). I don't know why is being mounted twice, but probably is a function and not a bug. ...
I see in his dmesg that loading the  squashfs  driver is taking less than 0.001 seconds compared to your 1.08 seconds. I checked
a couple of the dmesg attachments in the post just before bmarkus and  squashfs  loaded just as fast as for bmarkus.

Maybe a couple of other picore users could post there timing info for  squashfs  load time.

Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 15, 2020, 07:47:30 AM
Code: [Select]
[    1.922584] squashfs: version 4.0 (2009/01/31) Phillip Lougher
[    1.951714] usb 1-1.4: new full-speed USB device number 4 using xhci_hcd

piCore-11.x RPi4
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: redFrik on May 15, 2020, 08:33:36 AM
Code: [Select]
Jan  1 00:00:04 box user.notice kernel: [    4.507954] random: crng init done
Jan  1 00:00:04 box user.info kernel: [    4.525273] squashfs: version 4.0 (2009/01/31) Phillip Lougher
Jan  1 00:00:05 box user.info kernel: [    5.785504] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
Jan  1 00:00:05 box user.info kernel: [    5.880092] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
rpi0, piCore9.0.3
(great thread btw, i've learned a lot.  thanks.)
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 15, 2020, 08:46:06 AM
Code: [Select]
Jan  1 00:00:04 box user.notice kernel: [    4.507954] random: crng init done
Jan  1 00:00:04 box user.info kernel: [    4.525273] squashfs: version 4.0 (2009/01/31) Phillip Lougher
Jan  1 00:00:05 box user.info kernel: [    5.785504] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
Jan  1 00:00:05 box user.info kernel: [    5.880092] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
rpi0, piCore9.0.3
(great thread btw, i've learned a lot.  thanks.)
So it's either the Raspberry Pi Zero or version 9.0.3 of piCore, because you have my same setup and also for you squashfs driver takes 1.8 seconds.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 15, 2020, 08:59:32 AM
Hi Pacca
... So it's either the Raspberry Pi Zero or version 9.0.3 of piCore, because you have my same setup ...
So far that's what it looks like. The units in the  bmarkus  thread (RPi2, PIi2B, and RPiB+) did not have this delay.
Juanito also came in at a quick ~0.026 seconds with an RPi4 on piCore-11.x.

Quote
... and also for you squashfs driver takes 1.8 seconds.
I beg to differ :):
Code: [Select]
tc@box:~$ calc 5.785504-4.525273
1.26023
tc@box:~$
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: curaga on May 15, 2020, 09:26:34 AM
Aren't there other commands between the squashfs modprobe and the mount? It'd mean you can't use the mount timestamp to measure squashfs.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 15, 2020, 09:38:56 AM
Hi curaga
Aren't there other commands between the squashfs modprobe and the mount? ...
You're right. The  squashfs  module is loaded by  tc-config  and the  mount  commands are likely from there too. So there could be
something in  tc-config  causing the delay.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: redFrik on May 15, 2020, 10:58:07 AM
Code: [Select]
Jan  1 00:00:02 box user.info kernel: [    2.841660] Adding 228160k swap on /dev/zram0.  Priority:-1 extents:1 across:228160k SSFS
Jan  1 00:00:02 box user.info kernel: [    2.895318] squashfs: version 4.0 (2009/01/31) Phillip Lougher
Jan  1 00:00:03 box user.info kernel: [    3.292090] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)
Jan  1 00:00:03 box user.info kernel: [    3.395755] EXT4-fs (mmcblk0p2): mounted filesystem with ordered data mode. Opts: (null)

rpi3b, piCore9.0.3
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 15, 2020, 11:10:37 AM
Hi redFrik
Thanks for the additional data. So that appears to suggest It may be RPi0 related. The zero is a stripped down Pi, isn't it? So maybe
it's caused by something the zero doesn't have that tc-config is looking for? RTC? eth0? Random number generator? What makes
the zero different?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 16, 2020, 01:11:07 AM
Hi Rich,
RPi0 does not have an ethernet port and that's why I am using an usb adapter. Can this be the problem?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 16, 2020, 05:32:54 AM
Hi Pacca
Try adding the  nodhcp  boot code just to see if it changes the timing.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 16, 2020, 11:54:21 AM
Even with nodhcp it still takes more than one second to load.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 16, 2020, 08:46:51 PM
Hi Pacca
Well, looking through  tc-config  and the  RPi Zero  specs nothing jumps out at me. So now you have to ask yourself the following:

"How badly do i want to try to eliminate that 1 second delay?"

Before answering, consider the following:
1. There might be something inherent in the Zero and the delay can't be eliminated.
2. It might be something in the kernel, in which case it likely would be difficult to track down.
3. It is something in  tc-config, and would require adding some debug code to track down.
4. It could be something entirely different that I haven't thought of.

Only item 3 looks like you might be able to do something about. It would require extracting the  tc-config  file from the piCore image
file. You then need to find the line that says:
Code: [Select]
modprobe -q squashfs 2>/dev/null
You can now add code that writes markers to the log files so you can see execution time of sections of  tc-config,  something like:
Code: [Select]
echo "***** TC 1 *****" >> /dev/kmsg
So you would add the code like this:
Code: [Select]
modprobe -q squashfs 2>/dev/null
echo "***** TC 1 *****" >> /dev/kmsg

# Original tc-config code

echo "***** TC 2 *****" >> /dev/kmsg

# Original tc-config code

echo "***** TC 3 *****" >> /dev/kmsg

# Original tc-config code

You would then need to repack the image file. I don't know how to unpack/repack ARM images, so someone else will need to
answer that.

The logs will then have markers with whatever text you echoed into  /dev/kmsg.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 18, 2020, 01:01:51 AM
Hi
Hi Pacca
Well, looking through  tc-config  and the  RPi Zero  specs nothing jumps out at me. So now you have to ask yourself the following:

"How badly do i want to try to eliminate that 1 second delay?"
Hi Rich,
1 second delay is nothing compared to the time that the python script needs to load, so is not that bad. I was just curious to understant where that delay was coming from. The unpacking/repacking process is something completely new for me, I will try to see if I can do that. But I don't understand why I can't simply edit /etc/init.d/tc-config from PiCore and backup with filetool.sh -b.

Another idea would be to try piCore 11 but unfortunately the net-usb-KERNEL.tcz is not present in the TCZs catalog and I need that to connect to the internet and download the packages I need.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 18, 2020, 01:53:03 AM
net-usb-KERNEL added to piCore-11.x repos

Note that the python version changes to 3.8...
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 18, 2020, 04:56:14 AM
Hi Pacca
... But I don't understand why I can't simply edit /etc/init.d/tc-config from PiCore and backup with filetool.sh -b. ...
Because your backup doesn't get restored until the end of  tc-config.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 18, 2020, 11:32:43 AM
Hi Pacca
... But I don't understand why I can't simply edit /etc/init.d/tc-config from PiCore and backup with filetool.sh -b. ...
Because your backup doesn't get restored until the end of  tc-config.
Hi Rich,
it makes sense.

net-usb-KERNEL added to piCore-11.x repos

Note that the python version changes to 3.8...
Thank you very much Juanito. Unfortunately piCore 11 does not load and returns the message "kernel panic".

I think I will stick to version 9.0.3 and keep everything as it is!
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 25, 2020, 02:58:16 AM
I'm sorry for pushing this post up again. I am trying to play a wave audio file from my python script. What do I need to play audio through HDMI? Are alsa-modules-4.9.2-piCore, alsa.tcz and alsa-utils.tcz required? And then how can I force HDMI audio since Raspberry Pi Zero lacks a jack connector? Thank you very much!
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 25, 2020, 03:05:02 AM
I don't have the means to (easily) test, but on an x86/x86_64 machine you would need the graphics-KERNEL extension, which I see is not present in the piCore-9.x armv6 repo...
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 25, 2020, 03:27:12 AM
graphics-4.9.22-piCore added to the repo
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 25, 2020, 05:55:30 AM
Hi Juanito,
thank you, I will try to add this extension. Out of curiosity, why do I need it? Only to handle the HDMI connection? I read the comment in the .info file. Just to be sure, do I have to add the line
Code: [Select]
dtoverlay=vc4-fkms-v3d to config.txt?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Juanito on May 25, 2020, 07:07:48 AM
I suppose the audio is output via a graphics (hdmi) connector, hence the need for graphics-KERNEL.

I don't know if you need "dtoverlay=vc4-fkms-v3d" or not - hdmi graphics works in 2d mode without it, but I don't know if hdmi audio is enabled.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 25, 2020, 07:29:22 AM
I can't get the audio working. If I use the overlay for 3d graphics, I don't even get video output. I tried forcing HDMI setting "hdmi_drive=2" in config.txt but nothing changes. Even using the command "amixer cset numid=3 2" does nothing.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 25, 2020, 07:37:38 AM
I am sorry Juanito, I made a silly mistake. Now everything is working, thank you so much!

EDIT: alsa-modules-KERNEL.tcz and alsa.tcz are the only extensions needed.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 25, 2020, 08:17:23 AM
I saw that before loading the GUI of my python script, the piCore wallpaper is shown very briefly. Is there any way to remove it completely?
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Rich on May 25, 2020, 08:40:21 AM
Hi Pacca
It's probably caused by  ~/.xsession  calling  ~/.setbackground.  So you can remove that line from  ~/.xsession.
Title: Re: piCore 9.0.3 boot to python script with GUI
Post by: Pacca on May 25, 2020, 09:21:09 AM
Hi Rich,
it was exactly that, thanks!