WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

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

Offline Pacca

  • Newbie
  • *
  • Posts: 37
piCore 9.0.3 boot to python script with GUI
« on: April 24, 2020, 11: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!

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: piCore 9.0.3 boot to python script with GUI
« Reply #1 on: April 24, 2020, 12:00:12 PM »
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.

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 11049
Re: piCore 9.0.3 boot to python script with GUI
« Reply #2 on: April 24, 2020, 01:01:57 PM »
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.
The only barriers that can stop you are the ones you create yourself.

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: piCore 9.0.3 boot to python script with GUI
« Reply #3 on: April 24, 2020, 04:17:46 PM »

Offline Pacca

  • Newbie
  • *
  • Posts: 37
Re: piCore 9.0.3 boot to python script with GUI
« Reply #4 on: April 25, 2020, 06: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!

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: piCore 9.0.3 boot to python script with GUI
« Reply #5 on: April 25, 2020, 07: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

Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: piCore 9.0.3 boot to python script with GUI
« Reply #6 on: April 25, 2020, 09: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.

Offline Pacca

  • Newbie
  • *
  • Posts: 37
Re: piCore 9.0.3 boot to python script with GUI
« Reply #7 on: April 26, 2020, 01:17:30 PM »
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.
« Last Edit: April 26, 2020, 01:34:53 PM by Pacca »

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: piCore 9.0.3 boot to python script with GUI
« Reply #8 on: April 26, 2020, 01:38:38 PM »
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?

Offline Greg Erskine

  • Sr. Member
  • ****
  • Posts: 404
Re: piCore 9.0.3 boot to python script with GUI
« Reply #9 on: April 26, 2020, 05: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.

Offline Pacca

  • Newbie
  • *
  • Posts: 37
Re: piCore 9.0.3 boot to python script with GUI
« Reply #10 on: April 27, 2020, 02:36:37 AM »
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?

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: piCore 9.0.3 boot to python script with GUI
« Reply #11 on: April 27, 2020, 03: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

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: piCore 9.0.3 boot to python script with GUI
« Reply #12 on: April 27, 2020, 04: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.

Offline Pacca

  • Newbie
  • *
  • Posts: 37
Re: piCore 9.0.3 boot to python script with GUI
« Reply #13 on: April 27, 2020, 05: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!

Offline Pacca

  • Newbie
  • *
  • Posts: 37
Re: piCore 9.0.3 boot to python script with GUI
« Reply #14 on: May 02, 2020, 09: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.