Skip to content

tinypilot under the hood

marcobergman edited this page Jul 7, 2023 · 3 revisions

WORK IN PROGRESS JUL-2023

Tinypilot runs under TinyCore Linux. This linux deviates from regular linux distributions. If you want to know the background, you are advised to read a few chapters into the very well written http://www.tinycorelinux.net/corebook.pdf.

  • For remote ssh access, log in with username 'tc' and password 'pypilot'.

Take a moment to let sink in what a main difference is between debian derivates and tinycore linux:

  • In debian, packages are .deb files and they are installed once from the .deb file onto the read-write root file system.
  • In tinycore linux, packages are .tcz files, and they are loaded at boot-time onto a memory-based read-only filesystem, and symbolic links are created to the executables. The script that loads the packages at boot-time, is the script /opt/bootlocal.sh. The command that loads .tcz packages is tce-load.

Note that /opt/bootlocal.sh runs in the background, but still outputs its data to the console. So when you look at the boot sequence on the console (if you attach a display to your pi), the shell prompt will be overwritten by the bootlocal.sh output. Pypilot will already be running, while bootlocal.sh continues loading some secondary 'development tools', which might show some error messages. This might cause you to think falsely that something went wrong in the pypilot startup, but if you check the browser interface, you are likely to find that pypilot is already up and running.

Take another moment to understand how the pypilot package (pypilot.tcz!) is loaded in tinycore. Open /opt/bootlocal.sh and eyeball the code. If you understand this, it will make your life so much easier:

# This is the pypilot package:
tc@box:~$ find / -name pypilot.tcz 2>/dev/null
/mnt/mmcblk0p2/tce/optional/pypilot.tcz

# This line is where it is being 'loaded' at boot-time:
tc@box:~$ grep pypilot /opt/bootlocal.sh | grep tce-load
chpst -utc tce-load -i python-serial python-RTIMULib python-ujson pypilot > /dev/null

# After loading, the package is availabe at this read-only filesystem:
tc@box:~$ df | grep pypilot
/dev/loop19    384.0K    384.0K    0 100% /tmp/tcloop/pypilot

# And this is how the executables are being accessed: through symbolic links into the read-only filesystem:
tc@box:~$ which pypilot
/usr/local/bin/pypilot
tc@box:~$ ls -al /usr/local/bin/pypilot
lrwxrwxrwx   1 root  root   41 Jun 11 20:00 /usr/local/bin/pypilot -> /tmp/tcloop/pypilot/usr/local/bin/pypilot

services are defined under /etc/sv/
startup with sudo sv {start|stop} servicename

log files are under /var/log/servicename/current

configuration under .pypilot/, which links to /mnt/mmcblk0p2/.pypilot/

Run pypilot at the prompt

To run pypilot at the prompt, thereby getting instantaneous logging output, stop the pypilot service, and then run the pypilot script. Remember this is the output that gets you targeted help when you post a question on the pypilot forum:

tc@box:/mnt/mmcblk0p2/.pypilot$ sudo sv stop pypilot
ok: down: pypilot: 0s
tc@box:/mnt/mmcblk0p2/.pypilot$ pypilot
ERROR loading learning.py No module named tensorflow ,  No module named learning
ERROR loading learning.py No module named tensorflow ,  No module named learning
warning, failed to make calibration process idle, trying renice
Settings file not found. Using defaults and creating settings file
Using settings file RTIMULib.ini
Detected MPU9250/MPU9255 at standard address
Using fusion algorithm Kalman STATE4
IMU Name: MPU-925x
min/max compass calibration not in use
Using ellipsoid compass calibration
Using accel calibration
loading servo calibration /home/tc/.pypilot/servocalibration
WARNING: using default servo calibration!!
connected to gpsd
Loaded Pilots: ['wind', 'simple', 'basic', 'absolute']
warning: failed to open special file /dev/watchdog0 for writing
         cannot stroke the watchdog
MPU-925x init complete
servo is running too _slowly_ 0.0678148269653
value 65535
arduino servo found on [u'/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0', 38400]
serialprobe success: /home/tc/.pypilot/servodevice [u'/dev/serial/by-id/usb-1a86_USB_Serial-if00-port0', 38400]

Step 5: The HAT interface >>>

Clone this wiki locally