Tiny Core Linux

Tiny Core Base => Raspberry Pi => Topic started by: Will8 on February 23, 2019, 01:23:01 PM

Title: Newbie: Have I undersood how this works?
Post by: Will8 on February 23, 2019, 01:23:01 PM
Hi guys,

Background:
I'm running a robotics program for 14 years olds (https://hr-robocon.org/) which uses a Raspberry Pi3b+, but some people are never happy and are complaining about system boot and shutdown times. Ever willing to throw myself into extra work, and keen to improve resilience against "abrupt power loss", TCL seems to be what I'm looking for... but I have a specific set of requirements which i'm having trouble with.

Detail:

Firstly, we have a mix of Pi3B and 3B+ I think means I need v10, but its still in beta. What does "Beta" mean for TCL?

The software stack consists of a PI, PI camera (Is this supported?), a custom board on I2C which provides Analog in, Digital IO and servos (I2C is supported as a kernal module), a motor controller hat which uses the GPIO and PWM (supported though wiringpi.tcz?). Students might extend the system by plugging in ardinio like devices (supported by usb-serial-4.19.13-piCore-v7.tcz). The board is shut down though a GPIO device tree module (all device tree stuff is supported because its just a RPI kernel - but you need to manually mount /boot?).

In development mode our system boots as a HostAP and dnsmasq (these appear to be missing on 10.x - are they inside some other package, do I have to build them some other way, or are they missing because they don't build yet?) redirects all traffic to a local port which serves a code development interface written in Python2 (python2.7.tcz), students write code through the interface and when they 'save' it the code is written to the PI filesystem so it persists from boot to boot (is filetool.sh -b meant to be used like this? Saving is reasonably infrequent.)

When the code is "run" any logs are displayed in the web interface and images that are taken by the camera are displayed. The images are analyzed by a python/C library, identifying simplified QR codes which the robot uses to navigate autonomously, these images and logs don't need to persist, but if a user has inserted a USB stick then they are saved there for inspection later.

Finally, during the competition there are 4 special USB sticks which allocate the corner of the arena to a robot (and hence which walls and cubes it hunts). The sticks are mounted using udev rules (I assume this supported, but I'm not sure how to make changes - do I make my own tcz, if so can you point me at instructions?) and at the next boot the brain is reconfigured to connect to an arena Access Point(wifi.tcz, wireless-4.19.13-piCore-v7.tcz, wpa_supplicant.tcz), with a fixed IP address (so the red corner is always 192.168.0.2 etc). I haven't worked out exactly why, but this requires a reboot to switch from HostAP mode.


Am I on the right track?
Title: Re: Newbie: Have I undersood how this works?
Post by: Greg Erskine on February 23, 2019, 01:51:31 PM
hi Will8,

What is a typical boot time?

My initial thought was "that is a lot of work and they will still complain about boot times at the end of it!"

regards
Greg
Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 23, 2019, 02:27:42 PM
Boot time is in the 30s range at the moment, shutdown is in the 10s.

Oddly i get more complaints about shutdown because people just want to hit the button and pull the battery.

The real problem I'm sidestepping is the two boot cycle time to change between arena mode and development mode - which I'm sure is going to turn out to be something in Rasperian that i'm not properly resetting (I think that I've got a stale IP hanging round somewhere when the mode switches - rebooting fixes it, but is slow).

Personally my priority is making it more robust from pulling power, but this is the second year and we haven't had a fault that can be directly traced to that, so perhaps i'm worrying about nothing.
Title: Re: Newbie: Have I undersood how this works?
Post by: Rich on February 23, 2019, 05:42:16 PM
Hi Will8
Keeping the size of your backups to a minimum will help keep boot/shutdown times down. Setting up persistent  /home  and
/opt  directories will allow you to remove those 2 entries from your  /opt/filetool.lst  file. If, for example, you have a config file
called  /usr/local/etc/alsa/asound.state  that you need to preserve, add that to your backup. Don't backup entire subdirectories
unnecessarily.

If you want to see where your boot time is being spent, add the following boot codes:
Code: [Select]
printk.time=1 syslogIf you then execute (after rebooting):
Code: [Select]
dmesg > dmesg.txtyou can see if there are any slowdowns in the boot process by looking through  dmesg.txt.  You can also look through
/var/log/messages  to check for other possible delays.

Quote
In development mode our system boots as a HostAP and dnsmasq (these appear to be missing on 10.x - are they inside some other package,
Why don't you run 9.x? According to this:
http://tinycorelinux.net/9.x/armv6/tcz/info.lst
it has  hostapd.tcz  and  dnsmasq.tcz.

If you haven't already, you might also want to take an hour to read this excellent book:
http://tinycorelinux.net/book.html
While not specific to Pi, there's a lot of useful information about using Tinycore.

Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 24, 2019, 12:39:05 AM
Ive already tied optimizing boot time in Rasprian, but not got as far as having the system up on TCL.

I started with 9.x but I get a flashing red light and stuck on the rainbow screen with flashing power signal which is indicative of firmware too old to run the pi3b+. 10.x runs and boots fine.

I don't know if there is a backport for the kernel and firmware to support the 3b+ on 9.x, if such a thing exists, can I install it onto the SDcard from a (linux) machine, I can't so it from within 9.x because I have no way to boot it (The Pi3s are out in the field till May)
Title: Re: Newbie: Have I undersood how this works?
Post by: mocore on February 24, 2019, 03:13:15 AM

Quote
In development mode our system boots as a HostAP and dnsmasq (these appear to be missing on 10.x - are they inside some other package,
Why don't you run 9.x?

i guess because of the b3+
http://forum.tinycorelinux.net/index.php/topic,21170.msg137021.html#msg137021
Just trying to boot a RPI 3 B+ with 9.0.3
I get the rainbow screen with power symbol. 
piCore 9 is not compatible with RPi 3 B+, yo will need piCore 10


FTR copying a updated rpi firmware to a 9x picore and it should boot on a b3+, but the b3+ wifi kernel module will be 'missing' ...


According to this:
http://tinycorelinux.net/9.x/armv6/tcz/info.lst
it has  hostapd.tcz  and  dnsmasq.tcz.
i guess it would be possible to try and copy ` hostapd.tcz  and  dnsmasq.tcz ` and deps from picore 9x to 10x ?



Title: Re: Newbie: Have I undersood how this works?
Post by: Rich on February 24, 2019, 05:31:40 AM
Hi mocore

Quote
In development mode our system boots as a HostAP and dnsmasq (these appear to be missing on 10.x - are they inside some other package,
Why don't you run 9.x?

i guess because of the b3+
http://forum.tinycorelinux.net/index.php/topic,21170.msg137021.html#msg137021
Thanks, wasn't aware of that.
Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 24, 2019, 05:42:09 AM
a TCZ is just a squshfs filesystem right?

If so, where would i find the actual files?

http://tinycorelinux.net/9.x/armv7/tcz/ appears to be a list

and how would I use them - copy them into the tce/optional directory?

is there a cost to loading lots of tcz's - is there some flattening of the filesystem I should do once I have a working image?
Title: Re: Newbie: Have I undersood how this works?
Post by: Rich on February 24, 2019, 05:45:54 AM
Hi Will8
According to this:
http://tinycorelinux.net/9.x/armv6/tcz/info.lst
it has  hostapd.tcz  and  dnsmasq.tcz.
i guess it would be possible to try and copy ` hostapd.tcz  and  dnsmasq.tcz ` and deps from picore 9x to 10x ?
You could try downloading the following 2 files:
http://tinycorelinux.net/9.x/armv6/tcz/hostapd.tcz
http://tinycorelinux.net/9.x/armv6/tcz/hostapd.tcz.dep
then run a dependency check on 10.x to resolve any missing dependencies.

dnsmasq.tcz  may present a problem. According to this:
http://tinycorelinux.net/9.x/armv6/tcz/dnsmasq.tcz.dep
it depends on  ipv6-KERNEL.tcz  which is kernel specific and not yet available in TC10.
Title: Re: Newbie: Have I undersood how this works?
Post by: Rich on February 24, 2019, 05:51:53 AM
Hi Will8
a TCZ is just a squshfs filesystem right?
Yes.

Quote
If so, where would i find the actual files?
They are usually  loop mounted  under  /tmp/tcloop/.

Quote
newbielink:http://tinycorelinux.net/9.x/armv7/tcz/ [nonactive] appears to be a list

and how would I use them - copy them into the tce/optional directory?
Append the filename of interest to the URL as shown in my previous answer.
Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 24, 2019, 05:58:01 AM
Cool.
Its possible that dnsmasq won't be a problem because I'm not actually using any IPv6 stuff - assuming dnsmasq loads libraries on demand.

In most cases the PI will only ever be connected to one other device, I can't imagine more than five people connecting to it, at which time they will be so busy fighting about who is editing the code that the robot could burst into flames and nobody would notice.
Title: Re: Newbie: Have I undersood how this works?
Post by: Rich on February 24, 2019, 06:10:02 AM
Hi Will8
Cool.
Its possible that dnsmasq won't be a problem because I'm not actually using any IPv6 stuff - assuming dnsmasq loads libraries on demand.
It's worth a shot, just don't download the  .dep  file.
Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 24, 2019, 06:23:05 AM
 :( Trying to install the dependencies first - when I try

tce-load -wi wireless_tools

it fails with

md5sum: wireless-4.14.42-piCore-v7.tcz: No such file or directory

which looks suspiciously like a kernel module so can't be pulled over :(
Title: Re: Newbie: Have I undersood how this works?
Post by: Rich on February 24, 2019, 06:36:25 AM
Hi Will8
As far as I can see here:
http://tinycorelinux.net/10.x/armv6/tcz/info.lst
I don't see kernel dependent extensions. They probably haven't been compiled yet.
Title: Re: Newbie: Have I undersood how this works?
Post by: Paul_123 on February 24, 2019, 06:48:20 AM
Beta5 has moved to a 4.19.y kernel base, Betas 1-4 are no longer viable.  (Beta5 is only loaded for the armv7 boards)

hostapd depends on openssl, which has been updated in 10.x, so you cannot copy it from the 9.x repo.  I have it built, I'll send it in.
Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 24, 2019, 06:59:47 AM
Hi Paul.

It seems I'm an idiot enabled by alphanumeric sorting :)

In the browser 12b is a lower value than 5a!

I'll update now :)
Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 24, 2019, 07:10:23 AM
Its also missing libiw, can this be swallowed from the 9.x branch?
Title: Re: Newbie: Have I undersood how this works?
Post by: mocore on February 24, 2019, 07:13:06 AM
If so, where would i find the actual files?

http://tinycorelinux.net/9.x/armv7/tcz/ appears to be a list

using a mirror with ftp access @ distro.ibiblio.org/tinycorelinux its easy to see the dir layout !

Code: [Select]
lftp -e "ls;exit" ftp://distro.ibiblio.org/tinycorelinux/9.x/x86/tcz/
eg
Code: [Select]
$ svr_lst=$( lftp -e "ls;exit" ftp://distro.ibiblio.org/tinycorelinux/9.x/x86/tcz/ )#cd ok, cwd=/tinycorelinux/9.x/x86/tcz
Code: [Select]
$ echo "$svr_lst" | grep -e "lftp"
Quote
-rw-rw-r--    1 2432     100         36864 Jan 04  2018 lftp-doc.tcz
-rw-rw-r--    1 2432     100           576 Jan 04  2018 lftp-doc.tcz.info
-rw-rw-r--    1 2432     100           104 Jan 04  2018 lftp-doc.tcz.list
-rw-rw-r--    1 2432     100            47 Jan 04  2018 lftp-doc.tcz.md5.txt
-rw-rw-r--    1 2432     100           300 Jan 04  2018 lftp-doc.tcz.zsync
...
-rw-rw-r--    1 2432     100        598016 Jan 04  2018 lftp.tcz
-rw-rw-r--    1 2432     100            48 Jan 04  2018 lftp.tcz.dep
-rw-rw-r--    1 2432     100           577 Jan 04  2018 lftp.tcz.info
-rw-rw-r--    1 2432     100           255 Jan 04  2018 lftp.tcz.list
-rw-rw-r--    1 2432     100            43 Jan 04  2018 lftp.tcz.md5.txt
-rw-rw-r--    1 2432     100            89 Mar 03  2018 lftp.tcz.tree
-rw-rw-r--    1 2432     100          1937 Jan 04  2018 lftp.tcz.zsync
Title: Re: Newbie: Have I undersood how this works?
Post by: Paul_123 on February 24, 2019, 12:07:24 PM
Its also missing libiw, can this be swallowed from the 9.x branch?

yes it can.
Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 25, 2019, 03:39:06 AM
I think I'm getting there!

hostapd from 9.x expects usr/local/lib/libssl.so.1.0.0
but I have installed OpenSSL from 10.x which provides usr/local/lib/libssl.so.1.1

will symlinking these cause very bad things to happen (expect so!)

if so, how do I uninstall OpenSSL (10.x) so I can install (9.x), is it as simple as writing the 9.x file over tce/optional/openssl.tcz?
Title: Re: Newbie: Have I undersood how this works?
Post by: Juanito on February 25, 2019, 03:47:15 AM
To upgrade (or downgrade) extensions with the same name:

* create a folder named tce/optional/upgrade
* copy extension_name.tcz{,.dep,.md5.txt} to that folder
* reboot
Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 25, 2019, 03:49:33 AM
Cool. Unfortunatly i seems I need 1.1 as well as 1.0 because wpa_passphrase and ssh needs it
Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 25, 2019, 03:54:56 AM
I'm a bad man.

I've put both old and new in onboot.lst

This appears to work, but they both provide some files with the same name, I assume that the later of the two overlays the earlier?
Title: Re: Newbie: Have I undersood how this works?
Post by: Paul_123 on February 25, 2019, 07:19:21 AM
You asked in your OP about Beta Software.   And this is what you are facing.  I would recommend against trying to keep openssl 1.1 and 1.0 on your system, you are going to run into problems.

Either wait for hostapd that I submitted to get on the repo, or build it yourself.

Title: Re: Newbie: Have I undersood how this works?
Post by: Will8 on February 25, 2019, 12:49:23 PM
Thanks Paul.

I'm finding Tinycore Linux equally frustrating and refreshing, and I get that is partially because I'm using a beta version because I am forced to by using current PI hardware.

Getting the system to do what I want is far easier without the hundreds of scripts "helping" out that you get with thicker distributions - my terrible experience with rasprian UDEV rules, and trying to switch between AP and normal mode works like a dream on TCL.

But while i am no newbie to linux and programming, i'm still trying to get my head round how to put things together - I'm not sure where I'd even start on building missing pieces.