XO laptop / Pi Zero share Chromium and Desktop

Carrol Riddle ebox382 at scishare.com
Thu Nov 29 00:04:05 EST 2018


This is feedback to an earlier request to this list and the resulting assistance provided by the list for XO laptop sharing its keyboard, display and wifi with Raspberry Pi Zero to provide Chromium browser to XO.

Below is a tested procedure for doing this using simple manual commands. This is a one time setup of links.

A Sugar Activity is available for automating the links so simple commands (chrom,desk) can be used in Terminal Activity .  Actually, a second copy of Terminal Activity was modified to use the Raspberry icon.  The Activity (PiChrom) copies a command file (pilink) from PiChrom.activity directory to /home/olpc/ and runs it. This provides a user a simple way to modify the user and hostname in pilink and run it. 

Python's SimpleHTTPServer on the Pi Zero provides a simple way to serve Pi files to the XO over the same link and using a browser on the XO to download. The Pi Zero's wired ethernet ip address is available with ifconfig  (on Pi Zero).
 
Below is the file pilink and the file activity.py in PiChrom Activity.  The PiChrome Activity is available on request.  It has been extracted from TuxMath Activity by G. Odiard.

 Chromium Browser By XO Laptop / Raspberry Pi Zero Sharing

An XO laptop can act as a display, keyboard, wifi and power for a Raspberry Pi Zero single
board computer running Chromium Browser. The Pi Zero is plugged into an XO USB port, the
connection configured as a wired ethernet, and the XO wifi is configured to share its wifi with
other computers. SSH and X windows on the XO is used to provide all input to and output from
Chromium in the Pi Zero’s Raspbian Desktop software.

PREPARE PI ZERO

The Raspbian Desktop software can be downloaded (to PC or XO) and transferred to a micro SD
(with adapter or USB card reader). Use 8, 16, 32 GB, new or empty in FAT 16 or 32 format).
unzip -p “downloaded file” | sudo dd of=/dev/sda bs=4M conf=fsync (on XO omit conf=fsync)

The /boot/cmdline.txt is modified to enable ethernet over USB. Add driver line to end of /boot/
config.txt (see example below). An empty file ssh is added to /boot/ directory to enable SSH.

CONFIGURE XO LAPTOP

Using the Gnome Desktop mode on the XO , a connection method is added / edited by right
clicking on the terminal icon near the right of the toolbar (Pi Zero NOT CONNECTED). Left
click on Edit, select Add, and Create (wired connection). Accept Ethernet default and on the tab
IPv4 select “share with other computers” (default values for all other fields) and then save.
Switch the XO back to the Sugar mode and run Terminal Activity.
Enable SSH with: sudo systemctl enable sshd.service and then sudo systemctl start sshd.service
Create (using vi, nano or echo ) two files in directory /sbin and permissions set to match others
in /sbin. (chmod 755 chrom) Example for user pi on hostname: raspberrypi
chrom      sudo ssh -X pi at raspberrypi.local chromium-browser
desk       sudo ssh -X pi at raspberrypi.local /etc/X11/xinit/xinitrc
Power down XO laptop

CONFIGURE PI ZERO

Connect the Pi Zero to an XO USB port using USB cable (standard A end and micro B end).
Connect the micro end of the cable to the middle (NOT END) micro USB port on the Pi Zero.
Power the XO. Run Terminal Activity.
Connect to Pi Zero using command sudo ssh pi at raspberrtpi.local . Password: raspberry
Configure Pi Zero to boot to command line using sudo /usr/lib/raspi-config .
Also, recommend changing hostname (raspberrypi part) and password as security.

RUNNING (with WiFi available)

Power XO laptop into Sugar .
Go to Neighborhood view and connect to the desired WiFi (if not already connected).
Start Terminal Activity. Type the command chrom --- starts in about 10 seconds.

Example cmdline.txt : dw_otg.lpm_enable=0 console-serial=0,115200 console=tty1
root=PARTIDD=cd8cc3e2-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
modules-load=dwc2,g_ether quiet init=/usr/lib/raspi-config/init_resize.sh splash
plymouth.ignore-serial-several-consoles

Example config.txt: add dtoverlay=dwc2 to end of config.txt using Vi or Nano editor.

File pilink:

su -c 'echo "sudo ssh -X pi at raspberrypi.local chromium-browser" > /sbin/chrom'
su -c 'echo "sudo ssh -X pi at raspberrypi.local /etc/X11/xinit/xinitrc" > /sbin/desk'
su -c 'echo "ssh -X pi at raspberrypi.local chromium-browser" > /sbin/lchrom'    
su -c 'echo "ssh -X pi at raspberrypi.local /etc/X11/xinit/xinitrc" > /sbin/ldesk'
su -c 'echo "ssh pi at raspberry.local python SimpleHTTPServer.py" > /sbin/pfile' 
su -c 'chmod 755 /sbin/chrom'
su -c 'chmod 755 /sbin/desk'
su -c 'chmod 755 /sbin/lchrom'
su -c 'chmod 755 /sbin/ldesk'
su -c 'chmod 755 /sbin/pfile'
su -c 'systemctl enable sshd.service'


File:   activity.py from PiChrom Activity

import os
import commands
import subprocess
import logging

import glib
import gtk

from sugar.activity.activity import Activity


class PiLinkLauncher(Activity):

    def __init__(self, handle):
        # Initialize the parent
        Activity.__init__(self, handle)
        hbox = gtk.HBox()
        self.set_canvas(hbox)
        self.show_all()
        pipe = os.popen('{ ' + 'cp /home/olpc/Activities/PiLink.activity/pilink /home/olpc/pilink' + '; } 2>&1', 'r')
        pipe = os.popen('{ ' + '/home/olpc/pilink ' + '; } 2>&1', 'r')
        # logging.debug(options)
        glib.timeout_add_seconds(5, gtk.main_quit)


More information about the Devel mailing list