Difference between revisions of "LeapFrog Pollux Platform: OpenLFConnect"

From eLinux.org
Jump to: navigation, search
(Added CBF commands)
(Command List)
Line 297: Line 297:
  
 
== Command List ==
 
== Command List ==
==== General Commands ====
+
==== General ====
 
'''debug_on'''
 
'''debug_on'''
 
  Usage:
 
  Usage:
Line 381: Line 381:
  
  
==== FileSystem Commands ====
+
==== FileSystem ====
 
'''cwdr'''
 
'''cwdr'''
 
  Usage:
 
  Usage:
Line 640: Line 640:
  
  
==== Firmware Commands ====
+
==== Firmware ====
=====Explorer=====
+
===== Explorer =====
  
 
'''lx_rename_firmware'''
 
'''lx_rename_firmware'''
Line 652: Line 652:
  
  
=====LF2/LFP Packages=====
+
===== LF2/LFP Packages =====
  
 
'''package_extract'''
 
'''package_extract'''
Line 662: Line 662:
  
  
=====CBF Files=====
+
===== CBF Files =====
  
 
'''cbf_unwrap'''
 
'''cbf_unwrap'''

Revision as of 18:54, 25 January 2012

OpenLFConnect is a Python and sg3_utils command line based replacement application for the LeapFrog LFConnect program. For Explorer and LeapPad it can use their dftpdevice to upload firmware. It also manages uploading the surgeon.cbf file for USB boot recovery mode and is capable of enabling sshd on both devices. For Didj it can mount the USB drive, copy firmware over, and send the eject command that will attempt to start flashing the firmware.

WARNING: This program attempts to flash new firmware, has the ability to make and delete, upload and download, files could be destroyed, firmware flashing could go wrong. There is no prompts for second chances. Make sure you understand what you're doing, and use fresh batteries or an A/C adapter during updating.


Downloads

https://github.com/jrspruitt/OpenLFConnect

Requirements

Windows or Linux compatible

Python 2.6 - No special modules needed. Windows or Linux

sg3_utils

  • Included for Windows, common on many Linux distros

Windows

  • LeapFrog Ethernet Driver
  • If LFConnect is installed, or previously was, this is already installed.
  • If not, when it prompts you for a driver, use the Windows update service.

Bonjour For auto device IP discovery

  • If LFConnect is installed, or previously was, this is already installed.


Install

Extract archive or clone git repo to a location of your choice.

Windows

If LFConnect is installed you may want to make sure Monitor.exe is disabled, which can be done via Task Manager, before plugging a device in, this is the program that auto starts LFConnect. Or permanently stop it by deleting the regkey:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run\Monitor

Didj

You'll need to assign the Didj' USB Disk a drive letter as LFConnect will have assigned it another mount point instead. The letter you pick doesn't matter, as long as it doesn't conflict with something else. Plug your Didj in and then go to Disk Management, depending on what version of Windows it should be something like:

Administrative Tools > Computer Management > Disk Management

Right click the drive, and select Change Drive Letters and Paths click Add and assign the letter.

LeapPad and Explorer

Windows will default to a zeroconfig address, if you like you can just let it do that. But it takes a bit over a minute for it to do it. Static IP will greatly speed up the process.

Plug your device in and turn it on. You should see an icon in the Start Bar about trying to connect, if not go to Network Connections, right click and choose status. Then properties, scroll down to TCP/IP click on its properties, and make sure to set a static IP. Unless your device is set to a non standard IP, it will be on the 169.254. subnet. Windows will actually default to an address on this subnet, it takes a little over a minute from first turn on though, static IP is much faster.

Static IP: 169.254.0.1
Broadcast Mask: 255.255.0.0

Linux

Extract archive or clone git repo to a location of your choice.

You'll have to decide if you want to run OpenLFConnect.py with sudo or not. If you do not want to, you will need to copy the OpenLFConnect/src/udev_rules files to /etc/udev/rules.d/ The Mass_Storage rules are for all 3 devices. Didj in normal use and LeapPad, Explorer in USB Boot mode. The create a persistent generic SCSI device name /dev/leapfrog that is set to allow regular users permission to use.

Make sure the rule is owned by root:root and set to permission 644.

Didj

Other than the udev rules there is nothing to configure for Didj. One issue that may arise on your system, is Linux won't unmount when the didj_eject command is run. Didj will get the command, but you will have to unmount the drive in Nautilus or the command line for it to happen. The didj_umount command fails to work at all on Linux because of this.

LeapPad and Explorer

Plug your device in and turn it on, then check

System > Preferences > Network Connections

If you see Auto Eth1 open up its properties and got to the IPv4 tab, on the Methods drop down pick Link Local.

If you do not see the Auto Eth1 or something similar, you can copy the udev rules for Net to /etc/udev/rules.d/ This will trigger avahi-autoipd on plug in, and assign an IP address to the interface. This is basically what Network Manager does when set to Link Local.

Make sure the rule is owned by root:root and set to permission 644.


Usage

General

From a terminal or the command prompt run OpenLFConnect.py this will bring up the python command line. In windows you can also double click on the file.

The basics are very similar to the Linux command line, and once first started, you will be able to navigate around the local filesystem. Some examples

This changes the directory

local>cd files/LX

This lists a directory's contents

local>ls files/Didj

To get a full list of commands type help. For instructions and information on what each command does and if it needs an argument with it or not, type help <command>

It should be noted, that you can delete directories and files, with out any pompting. Make sure you double check before doing so. And remember to pay attention to the command line prefix: This means you are on the host computer and the commands will take action on it.

local> command arg

This indicates you are about to run a command on the device.

remote> command arg

The two exceptions to this rule are upload and download which will switch locations on their own and switch back once done. So no matter if its remote or local, upload /path/to/file will always take /path/to/file and try and upload it to the device, in the current directory you are in on it. The opposite is true for download.

The current directory is maintained on an individual basis. So you can switch between remote and local, and you will stay in the same place. The cwdl and cwdr commands Current Working Directory Local and Current Working Directory Remote respectively, can be used to check what that path is, regardless of the command lines current location.

Didj

General

Once Didj is plugged in and turned on, you run:

local>didj_mount
Mounted on /dev/Didj

This will obtain the location the Didj is mounted on. You should see a new window pop up with the contents, or it show up in your file browser, depending on the OS used. For general purpose looking around, its far easier to use the OS's file browser. But if you would like to run an update of the firmware or bootloader, OpenLFConnect can make it rather painless.

Updates

Preperation OpenLFConnect comes with a directory called files/, inside you'll find the Didj/ directory, its a convenient place to keep your firmwares.

Bootloader Make a directory called bootloader-LF_LF1000. Put your lightning-boot.bin and bootflags.jffs2 (optional) into it.

Firmware Make a directory called firmware-LF_LF1000. Put your kernel.bin and erootfs.jffs2 files into it.

In OpenLFConnect navigate to the location of these files. You can be one above, or just inside the one you want to update. If you are going to do both, you must be in the parent directory of both of them.

Depending on what you want to do, update just the bootloader, just firmware, or both, there is a command for each.

Update both with change to directory.

local>cd /Didj

local>ls
bootloader-LF_LF1000
firmware-LF_LF1000

local>didj_update

Update Firmware using the path argument.

local>didj_update_firmware Didj/

Update Bootloader with path argument

local>didj_update_bootloader Didj/bootloader-LF_LF1000

It will take a second for the command prompt to come back after the files have transferred and eject command sent. If on Linux eject the device now. Once ejected the Didj screen should change, it will say "Learning new tricks" Then "Disconnect Now". Once you do it will shutdown. Turn it back on and plug it in. run:

local>didj_mount
local>didj_update_cleanup

This removes the file to prevent unwanted firmware flashes if the eject command is sent again. If everything went okay your files will have been flashed to the Didj and you can now use it.

LeapPad and Explorer

General

There are a few things worth doing with OpenLFConnect and your Explorer. You can send a surgeon.cbf file, or any kernel and or initramfs you want to test that has been converted to cbf (script included in sources). You can run firmware updates, there is a convenience function for enabling sshd, or you can use it like a basic ftp browser. There are commands for uploading and downloading, along with basics, cd, ls, rm, rmdir, and mkdir.

Connect

Plug in your Explorer to the USB and turn it on. Depending if its booted or not this command could take a few seconds to run.

local>dftp_connect
Device:		Explorer
Firmware Version:	1.3.4-2044
IP:			169.254.3.208
DFTP Version: 		1.8

OpenLFConnect makes a best guess about which device is connected by the Major Firmware Version in this case 1, is Explorer, if it was 2.0.2.2044 or something like that, it would assume you connected a LeapPad. You can manually configure most all settings, to attempt to get around issues arising from custom firmware.

Examples

Get help for each command

local>help command

Change to remote device

local>remote
remote>

Change to local from remote

remote>local
local>

Make a directory

remote>cd /tmp
remote>mkdir NewDir
remote>ls
NewDir/
temp.socket
temp.file

remote>local
local>ls
etc/
bin/
home/
var/
usr/

Handling of Paths

One thing to note, other than upload and download, the generic commands run on what ever the command line prefix says it is set to, remote or local, caution when you are deleting something, to double check where you're located. The paths are persistent so remote doesn't change when you switch to local and vice versa. Basically remote or local, just tells OpenLFConnect which path to use for a given command. Anytime you want to check a particular one. Run one of these commands:

Check local path

remote>cwdl
D:\Programs\OpenLFConnect\files\LX

remote>cwdr
/LF/Bulk

Enable sshd

!!!I don't have a LeapPad to test on, so this section is theoretical for the LeapPad implementation, but it is pretty basic Linux stuff, and shouldn't cause catastrophic damage if my guess is wrong. If someone is willing to risk it, please let me know if it worked or not, so this feature can be less theoretical and more confirmed.!!!

This command will upload two files from OpenLFConnect/files/[Lpad|LX]/enable_ssh/ rcS and sshd_config, they are stock files, except for what is necessary to enable the sshd server on start up. This command is a hard coded convenience feature it needs to find the files in those spots. It will also, pick which directory based on what it determines your device to be, LeapPad or Explorer. It is basically just using the upload function, so if you require something a little more fancy, that is what you should use.

Turn the device on and plug in the USB cable.

local>dftp_connect
... device info ...
remote>enable_sshd
remote>dftp_reboot

If your device does not reboot, go ahead and switch it off, then back on. I generally wait for a few seconds after the second jingle that it make before attempting to reconnect, as it will take a minute or so for a newly enabled sshd server to generate the necessary keys. dftp_connect might time out if you try and connect right away.

On Linux you can install the service-discovery-applet since the Explorer uses avahi to announce to the network certain services, sftp is one of them. Then go in Places>Networks and you should see it available.

Login

Username:root

Password:[blank]

Upload Download

OpenLFConnect also provides the ability to upload and download files to and from the device. There is no check if the file exists or not, and they will be over written if so, so be careful. Upload and Download are different in that they don't care if you are set to remote, or local. They handle all that in the background.

Download takes a remote path argument to a file, and will download it to the current local directory.

Upload takes a local path argument to a file, and will upload it to the current remote directory.

Example Connect to the device

local>dftp_connect
... device info ...

Set the remote directory to where the file you want to download resides in, switch back to local and navigate to where you want to save it. Then download.

remote>cd etc/
remote>local
local>cd LX/temp
local>download vsftpd.conf
local>ls
vsftpd.conf

Set your remote directory to where you want the file to be put, then upload a local file using the path argument.

remote>cd ../etc/avahi/
remote>upload ../../user/scripts/avahi-autoipd.action
remote>ls
avahi-autopid.action

Explorer

Update

Preparation Create a directory called Firmware-Base/ and load it with the firmware files. These files must be named as they are, as the name has significance to the flashing process. The first number is the NAND address in decimal to flash to, and the second is the size of the partition in packets, which the packet size is 131072. Check [Leapster_Explorer#Technical_Information] for the partitions numbers.

1048576,8,FIRST.32.rle
2097152,64,kernel.cbf
10485760,688,erootfs.ubi

You will also need a surgeon.cbf file, this will be sent to the Explorer while its in USB boot mode, and establishes the necessary systems for the flashing process.

Once you got your firmware ready, plug in the device hold down both shoulder buttons and the ? button while turning it on, then run:

local>boot_surgeon /path/to/Explorer/surgeon.cbf

Connect to the device

local>dftp_connect

It will take a few for the device to boot up, you will then have the command line back. And can start flashing your files.

remote>dftp_update /path/to//Firmware-Base

It will print out the file its uploading and say when its done, it will say it skipped any files that were not present, like if only kernel.bin was in your directory.

Once done uploading reboot the device.

remote>dftp_reboot

You can now unplug the USB cord, or otherwise let it boot normally. You can connect again if you like, and browse around too.

LeapPad

!!!I don't have a LeapPad to test on, so this section, minus the generic stuff, is theoretical If someone is willing to risk it, please let me know if it worked or not, so this feature can be less theoretical and more confirmed. But be warned, it could do some SERIOUS damage. So if you know what you are doing, maybe this can be of some assistance in getting there!!!

Another hurdle, is getting the LeapPad into USB Boot mode. I'm not exactly sure how to do this, as the device is missing the buttons used on the Explorer to trigger it.

Update

Preparation The LeapPad is vary similar to the Explorer, but it uses a different structure and flash system for its firmware. The update will look for the files in certain directories and place them in /LF/fuse/firmware/sd/* as needed. The structure looks like this

firmware/sd/raw/1/FIRST_Lpad.cbf
firmware/sd/raw/2/kernel.cbf
firmware/sd/ext4/3/rfs

You will also need the LeapPad specific surgeon.cbf file, this will be sent to the LeapPad while its in USB boot mode, and establishes the necessary systems for the flashing process.

Once you got your firmware ready, plug in the device hold down both shoulder buttons and the ? button while turning it on, then run:

local>boot_surgeon /path/to/LeapPad/surgeon.cbf

Connect to the device

local>dftp_connect

It will take a few for the device to boot up, you will then have the command line back. And can start flashing your files.

remote>dftp_update /path/to/firmware

It will print out the file its uploading and say when its done, it will say it skipped any files that were not present, like if only kernel.bin was in your directory.

Once done uploading reboot the device.

remote>dftp_reboot

You can now unplug the USB cord, or otherwise let it boot normally. You can connect again if you like, and browse around too.

Command List

General

debug_on

Usage:
   debug_on

Setting this prevents updates from actually happening, instead printing the files that would have been uploaded.


debug_off

Usage:
   debug_off

Turns off debugging mode. Updates will be attempted.


get_device_id

Usage:
   get_dev_id

Returns the currently configured device id.


get_mount_point

Usage:
   get_mount_point

Returns the currently configured mount point to use when creating a new mount client client.


set_mount_point

Usage:
   set_mount_point <mount point>

Set the mount point to use when creating a new mount client. 
The mount point, ex. Linux /media/didj, or Windows D:\
To reset to auto determine leave input blank.


get_device_ip

Usage:
   get_device_ip

Returns currently configured device IP to use when creating a new network client.


set_device_ip

Usage:
   set_device_ip <IP>

Set the device IP address to use when creating a new network client.
ex. 169.254.123.123
To reset to auto determine leave input blank.


get_host_ip

Usage:
   get_host_ip

Returns currently configured host IP to use when creating a new network client.


set_host_ip

Usage:
   set_host_ip <IP>

Set the host IP address to use when creating a new network client.
ex. 169.254.123.123
To reset to auto determine leave input blank.


remote

Usage:
   remote

Set to remote device for filesystem navigation.


local

Usage:
   local

Set to prompt to local host for filesystem navigation.


FileSystem

cwdr

Usage:
   cwdr

Print current remote directory path.


cwdl

Usage:
   cwdl

Print current local directory path.


exit

Usage:
   exit

Exit OpenLFConnect

ls

Usage:
   ls [path]

List directory contents. Where depends on which is set, remote or local


cd

Usage:
   cd <path>

Change directories. Where depends on which is set, remote or local


mkdir

Usage:
   mkdir <path>

Create directory. Where depends on which is set, remote or local


rmdir

Usage:
   rmd <path>

Delete directory. Where depends on which is set, remote or local


rm

Usage:
   rm <file>

Delete file. Where depends on which is set, remote or local


upload

Usage:
   upload <local file>

Upload the specified local file to the current remote directory, Will overwrite with out prompt.


upload_dir

Usage:
   upload_dir <local directory>

Upload the specified local directory into the current remote directory, Will overwrite with out prompt.


download

Usage:
   download <remote file>

Download the specified remote file to the current local directory, will over write with out prompt.


download_dir

Usage:
   download_dir <remote directory>

Download the specified remote directory into the current local directory, will over write with out prompt.


cat

Usage:
   cat <path>

Prints the contents of a file to the screen.
Doesn't care what kind or how big of a file.


Didj

didj_mount

Usage:
   didj_mount [mount name]

Unlock Didj to allow it to mount on host system.


didj_umount

Usage:
   didj_umount

Lock Didj which will un mount on host system. Only seems to work in Windows.


didj_eject

Usage:
   didj_eject
Eject the Didj which will unmount on host system, if the firmware updates are 
on the Didj, an update will be triggered. If they are not, it will ask you to unplug it. For
Linux hosts, you'll also have to eject it from the system.


didj_device_info

Usage:
   didj_device_info

Returns various information about device and mount.


didj_update

Usage:
   didj_update <path>

CAUTION:
!!Attempts to flash firmware, could potentially be harmful.!!
!!Make sure Battery's are Fresh, or A/C adpater is used!!

Update Didj firmware and bootloader. Files must be in bootloader-LF_LF1000 and firmware-LF_LF1000 directories.
Searches from the current local directory for the top level directory of the firmware, local path can be directly inside the top level directory or  one above it.
MD5 files will be created automatically.


didj_update_firmware

Usage:
   didj_update_firmware <path>

CAUTION:
!!Attempts to flash firmware, could potentially be harmful.!!
!!Make sure Battery's are Fresh, or A/C adpater is used!!

Update Didj firmware. Files must be in firmware-LF_LF1000 directory.
Searches from the current local directory for the top level directory of the firmware, local path can be directly inside the top level directory or  one above it.
MD5 files will be created automatically.


didj_update_bootloader

Usage:
   didj_update_bootloader <path>
CAUTION:
!!Attempts to flash firmware, could potentially be harmful.!!
!!Make sure Battery's are Fresh, or A/C adpater is used!!

Update Didj bootloader. Files must be in bootloader-LF_LF1000 directory.
Searches from the current local directory for the top level directory of the firmware, local path can be directly inside the top level directory or  one above it.
MD5 files will be created automatically.


didj_update_cleanup

Usage:
   didj_update_cleaup

Remove Didj firmware and bootloader from device.


DFTP

Used for LeapPad and Explorer.

dftp_connect

Usage:
   dftp_connect

Connect to device for dftp session.
Will attempt to configure IPs as needed.
This could take a minute or so, if you just booted the device.


dftp_disconnect

Usage:
   dftp_disconnect

Disconnect DFTP client.
This will cause the DFTP server to start announcing its IP again, except Explorer's surgeon.cbf version,   which will reboot the device


dftp_server_version

Usage
   dftp_server_version [number]

Sets the version number of the dftp server. Or retrieves if none specified
OpenLFConnect checks for version 1.12 for surgeon running before a firmware update.
Set this to 1.12 if getting complaints, or surgeon has its dftp version updated.


dftp_device_info

Usage:
   dftp_device_info

Returns various information about the device, and connection.
Note: Device name is guessed from board id.


dftp_update

Usage:
   update <local path>

CAUTION:
!!Attempts to flash firmware, could potentially be harmful.!!
!!Make sure Battery's are Fresh, or A/C adpater is used!!
Uploads and flashes to NAND the files in <local path>.
Note: Files must conform to LF naming conventions. Explorer in a Firmware-Base/* directory, LeapPad in  firmware/sd/*
Searches from the current local directory for the top level directory of the firmware, local path can be  directly inside the top level directory or one above it.
What firmware it to tries to upload depends on the board id.
LeaPad > 10
Explorer <= 10
Caution: Has not been tested on LeapPad, theoretically it should work though, please confirm to author yes or no if you get the chance.


dftp_reboot

Usage:
    update_reboot
After running update, run this to trigger a reboot


dftp_send

Usage:
   send <raw command>
Advanced use only, don't know, probably shouldn't.


dftp_enable_sshd

Usage:
   enable_sshd
    
Uploads two custom files, to enable the ssh server on boot, files found in <app   path>/files/[LX|Lpad]/sshd_enable/.
After uploaded and first reboot of the device, give it a minute to generate the keys before trying to  connect.
File paths are hard coded, will work from anywhere.
Username:root
Password:<blank>

Caution: Has not been tested on LeapPad, theoretically it should work though, please confirm to author yes or no if you get the chance.


USB Boot

boot_surgeon

Usage:
   boot_surgeon <path to surgeon.cbf>

Uploads a Surgeon.cbf file to a device in USB Boot mode. 
File can be any name, but must conform to CBF standards.


Firmware

Explorer

lx_rename_firmware

Usage:
   lx_rename_firmware [path]

Renames a the current or specified directory of files, with first, kernel, and or erootfs in the file names.
Prepends the proper number prefix to each file.
Will rename all files in the directory that match.


LF2/LFP Packages

package_extract

Usage:
   package_extract [path]

Extracts LF Package files (lfp ,lfp2)
Takes a file path, or will extract all packages in a directory.


CBF Files

cbf_unwrap

Usage:
   cbf_unwrap <file path>

Removes the CBF wrapper and prints a summary.
CBF is used on kernels and surgeon, to wrap a zImage or Image file.
Saves the image file to the same directory the cbf file was in.
If image file already exists will fail.


cbf_wrap_surgeon

Usage:
   cbf_wrap_surgeon <file path>

Creates the CBF wrapper named surgeon.cbf and prints a summary.
CBF is used on kernels and surgeon, to wrap a zImage or Image file.
Saves the image file to the same directory the kernel file was in.
Kernel should be a zImage or Image file.
If cbf file already exists will fail.


cbf_wrap_kernel

Usage:
   cbf_wrap_kernel <file path>

Creates the CBF wrapper named kernel.cbf and prints a summary.
CBF is used on kernels and surgeon, to wrap a zImage or Image file.
Saves the image file to the same directory the kernel file was in.
Kernel should be a zImage or Image file.
If cbf file already exists will fail.


cbf_summary

Usage:
   cbf_summary <file path>

Display the CBF wrapper summary.
CBF is used on kernels and surgeon, to wrap a zImage or Image file.