LibrieX

Download LibrieX (1.8 MB)

Introduction

LibrieX (or Librié, eXtended) is a toolkit that turns the Librié E-book Reader into a platform with High Tinkering Potential. Highlights are a way to establish TCP/IP connection with a host machine and a preliminary port of the Nano-X graphic server.

Requirements

  • A Linux box. (The USB driver is not available on other platforms. You might get away with a Linux instance running in a VMware or similar virtual machine, grant it access to the USB port and have it forward network traffic from the Mac/Win/Other host to the Librié. I did not test this, though—if you do, please send instructions so that they can be included here.)
  • On the Linux box: /usr/sbin/pppd, /usr/bin/chat, kernel headers or configured kernel source. (Tested with 2.6.15.)
  • On the Librié: the translated firmware.

Installation

No system-wide installation is necessary for the host, you can place the distribution directory where you prefer. Running some commands, though, will require root permissions.

Preparing the host computer

Assuming you the distribution tarball was unpacked in $LIBRIEX:

  1. Build the kernel module for USB communication:

    
    
      user@host:~$ cd $LIBRIEX; make module
        
    
  2. Optionally link the librie script to somewhere in your $PATH:

    
      user@host:~$ sudo ln -s $LIBRIEX/bin/librie /usr/local/sbin
        
    

Preparing the Librié

Copy $LIBRIEX/target/libriex.tar and $LIBRIEX/target/lbhook.sh to the root directory of the memory stick.

Connecting via TCP/IP

Connect the Librié and your computer via USB. Boot the Librié with the memory stick in.

On the host, execute:


  user@host:~$ sudo librie setup
  user@host:~$ sudo librie startnet


If everything goes well, you will see PPP debug information:


  Serial connection established.
  using channel 16
  Using interface ppp0
  Connect: ppp0 <--> /dev/pts/10
  rcvd [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xe82b13bf> <pcomp> <accomp>]
  sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0xf0a322c1> <pcomp> <accomp>]
  sent [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xe82b13bf> <pcomp> <accomp>]
  rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0xf0a322c1> <pcomp> <accomp>]
  sent [LCP EchoReq id=0x0 magic=0xf0a322c1]
  sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
  sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 192.168.1.98>]
  rcvd [IPCP ConfReq id=0x1 <addr 0.0.0.0> <compress VJ 0f 01>]
  sent [IPCP ConfNak id=0x1 <addr 192.168.1.99>]
  rcvd [LCP EchoRep id=0x0 magic=0xe82b13bf]
  rcvd [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15>]
  sent [CCP ConfAck id=0x1 <deflate 15> <deflate(old#) 15>]
  rcvd [CCP ConfAck id=0x1 <deflate 15> <deflate(old#) 15> <bsd v1 15>]
  Deflate (15) compression enabled
  rcvd [IPCP ConfAck id=0x1 <compress VJ 0f 01> <addr 192.168.1.98>]
  rcvd [IPCP ConfReq id=0x2 <addr 192.168.1.99> <compress VJ 0f 01>]
  sent [IPCP ConfAck id=0x2 <addr 192.168.1.99> <compress VJ 0f 01>]
  found interface ath0 for proxy arp
  local  IP address 192.168.1.98
  remote IP address 192.168.1.99
  Script /etc/ppp/ip-up started (pid 12428)
  Script /etc/ppp/ip-up finished (pid 12428), status = 0x0


The host will have been assigned the address 192.168.1.98 and the Librié will be reachable at 192.168.1.99 (addresses can be configured in $LIBRIEX/host/etc/librie.ppp). You can verify this by pinging and checking the network interface:


  user@host:~$ ping 192.168.1.99
  PING 192.168.1.99 (192.168.1.99) 56(84) bytes of data.
  64 bytes from 192.168.1.99: icmp_seq=1 ttl=255 time=9.39 ms
  64 bytes from 192.168.1.99: icmp_seq=2 ttl=255 time=11.0 ms
  64 bytes from 192.168.1.99: icmp_seq=3 ttl=255 time=10.7 ms
    C-c C-c
  --- 192.168.1.99 ping statistics ---
  3 packets transmitted, 3 received, 0% packet loss, time 2002ms
  rtt min/avg/max/mdev = 9.390/10.411/11.089/0.739 ms

  user@host:~$ /sbin/ifconfig ppp0
  ppp0      Link encap:Point-to-Point Protocol  
            inet addr:192.168.1.98  P-t-P:192.168.1.99  Mask:255.255.255.255
            UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
            RX packets:9 errors:0 dropped:0 overruns:0 frame:0
            TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
            collisions:0 txqueuelen:3 
            RX bytes:362 (362.0 b)  TX bytes:369 (369.0 b)

Or open a telnet connection (username: "root", password: "librie"):


  user@host:~$ telnet 192.168.1.99
  Trying 192.168.1.99...
  Connected to 192.168.1.99.
  Escape character is '^]'.
  [SSL not available]
  
  MontaVista Linux 2.1, Professional Edition
  Linux/armv4l 2.4.17_n12
  
  librie login: root
  Password: 
  Last login: Wed Sep  7 18:00:04 2005 from 192.168.1.98 on ttyp1
  Linux (none) 2.4.17_n12 #145 2004ǯ 6·î 15Æü ²ÐÍËÆü 12:58:50 JST armv4l unknown
  Welcome to MontaVista Linux 2.1, Professional Edition
  
  root@librie:~#

FTP is active as well. If anything goes wrong with telnet, a passwordless (and promptless) backdoor is available on port 42.

Direct Console Access

To get a direct (i.e. non-networked) access, instead of librie startnet, execute:


  user@host:~$ sudo librie console

To close the console, from another shell execute:


  user@host:~$ librie killconsole

Using Nano-X

Open a telnet connection. Once inside, kill the standard Librié software:


  root@librie:~# kill_librie_progs

Run the Nano-X server:


  root@librie:~# nano-X

The screen will be cleared. Open a second telnet connection and let your Librié greet the world:

root@librie:~# demo2

Stop it by pressing Control+C. The X server will exit as well (since the first client has exited), so start it again as above. Other demo programs you can try (note that input will not work, see status below):


  root@librie:~# nxclock
  root@librie:~# nterm
  root@librie:~# demo
  root@librie:~# polydemo
  root@librie:~# fontdemo
  root@librie:~# slider
  root@librie:~# npanel

All the demos come from the Nano-X distribution.

Writing programs

You will need a cross compilation toolchain in order to compile programs from your Linux host. On Debian-based distributions, you can add the following repository to /etc/apt/sources.list:


  # EmDebian, gcc 2.95 toolchain
  deb http://emdebian.sourceforge.net/emdebian unstable main      

Then it will be possible to install the toolchain with:


  user@host:~$ sudo apt-get install task-cross-arm

Status

TCP/IP connection works, but FTP is flaky, probably because it puts more strain than telnet on the underlying layer which is not very reliable to begin with.

Connection is not very fast, tests showed FTP transfers not faster than 300KB/sec and sometimes as low as 30KB/sec. This should be improved by more tweaking on the usbpd_con and usbpdtg_con programs, and/or pppd settings.

No Nano-X input driver has been written, so for now graphical clients can only be managed from the shell.

To do

  • A proper source distribution
  • An input driver for Nano-X
  • Port Tetris

Related work

Credits

Nothing of this would have been possible without the work done by the Librie Translation Project.

Background

My first attempt at bringing up a TCP/IP connection with the Librié was usbnet. The build process needed some tweaking but at last the module compiled cleanly from the Librié kernel tree. No luck in loading it, though, as the usbtg_pd and usbtg_core modules would not unload until they were in use by system programs, and trying to load usbnet before the system programs started got a chance to require the modules caused a kernel ooops. Trying to kill system programs would cause a reboot. Modifying init scripts so that these modules (that are needed to reflash the Librié) didn't get loaded at all seemed a bit too close to asking for a bricked device.

For the second, successful attempt, I used the USBPD console by Marko Bolowski. I modified it slightly so that the host side would transfer up to one hundred characters at a time instead of one, then used the host console as a vehicle to carry PPP traffic. (One character at a time coming from the host was apparently too little for the pppd program on the Librié to understand what was going on). If you've ever connected to the Internet using a serial modem, where PPP traffic is passes through a remote terminal, you've done something similar.

Getting Nano-X to work required one more hack. Usually, a graphics controller constantly transfers what it finds in a certain memory area (the framebuffer) to the display. This must happen many times per second or the thousands light bulbs that make up the screen would simply go off. As a consequence, the programmer just has to draw in the framebuffer memory area and what he draws is shown automatically.

The Librié is different: refreshing the display is an expensive operation which can require about a second; on the other hand, the display keeps its state even when not refreshed, so there is no need to refresh it if nothing changed. Because of this, the programmer draws something in the framebuffer memory area, and when he is finished, explicitly requests a refresh.

The X server assumes the first case. This is how I bridged the two approaches:

  • Hook the part of the code that calls the low-level, device-specific graphic operations, e.g. DrawPixel, DrawHorzLine, and so on. (src/engine/devdraw.c)
  • Each of the "hooked" routines calls the device-specific routine, then increments a global operation counter
  • When the server is started, a timer is registered which invokes a callback every 750ms. (src/nanox/srvmain.c)
  • The callback (RefreshCB) checks the global operation counter. If it is not zero, then some graphic operation has been performed since the last time the callback run, so request a display refresh, and reset the counter to zero.

Here is the patch for Nano-X: microwindows-0.91_librie.diff

Syndicate content