Abstract:
The invention consists of a boot loader for a device, comprising an IP stack supporting Internet protocols, and a scripting engine to run a default script. The IP stack includes address discovery service (for example, BOOTP and DHCP), a URI to IP address translator (for example, DNS), and a protocol for file transfer over the Internet (for example, HTTP, FTP and/or TFTP). On start-up of the device, the boot loader runs the default script to initialize the device and verify the integrity of any data and operating systems in memory on the device.

Description:
FIELD  
         [0001]    The invention relates to a boot loader designed to access boot information via the Internet, allowing for automatic provisioning, upgrades and recovery of corrupted device images based on a unique device ID.  
         BACKGROUND  
         [0002]    Most desktop computers and similar devices have a boot loader. The function of the boot loader is to load an operating system into the computer&#39;s main memory or random access memory (RAM). Once the operating system is loaded (for example, on a PC, when you see the initial Windows or Mac desktop screen), it is ready for users to run applications.  
           [0003]    The boot loader is a small program that loads the operating system into the computer. Furthermore, a boot loader can give the user the choice to load an operating system from a list of available operating systems. This would be done by creating partitions in the Flash memory, hard disk or Read Only Memory (ROM). Each partition would include a single operating system or user data. During the booting process the user would be prompted to select from the list of available operating systems. Once the choice is made, the boot loader proceeds to load the desired operating system into RAM and then hand control to the operating system.  
           [0004]    Embedded devices such as Personal Digital Assistants (PDAs) and mobile phones are being widely adopted in everyday life. Embedded computers are also built into appliances such as microwave ovens and used extensively in industrial control. The manufacturers of these devices have to sell devices where a wide variety of hardware and software is available on the device. The consumers of these devices can be largely non-technical people with no knowledge of how to fix or modify these devices if need be. There might be thousands of these devices that need the same software or upgrades.  
           [0005]    In the past, when a device is corrupted or the software needs to be replaced, the customer is expected to send it back to the manufacturer for repair. Repair might take weeks or months. There is a need for a system that will allow the user to get immediate repair of a corrupted device or updates to an outdated device with very little effort or knowledge.  
           [0006]    It is an object of this invention to provide a boot loader with standard Internet protocols (HTTP, TFTP, FTP) to allow the disassociation of the software and hardware at the manufacturing time. The boot loader should maintain all the functionality of a traditional boot loader as described above, such as partition of the device&#39;s memory in order to facilitate the loading of multiple operating systems. Additionally, the boot loader should allow for the device image (partition) to be loaded using Internet protocols.  
           [0007]    It is a further object of this invention to provide a boot loader that allows a device to have disaster recovery features. Whenever a virus, or any other factor corrupts the device, it will automatically attempt to restore itself to a working state via the boot loader.  
           [0008]    It is a still further object of this invention to provide a boot loader that allows a device to automatically update software running on, or data required by the device whenever an update is available.  
           [0009]    It is a still further object of this invention to provide a boot loader that is operated by a simple scripting language that instructs a device to check for an update of data on a periodic basis. The scripting language may also include instructions to download further scripts off the Internet that augment the execution of the script.  
         SUMMARY  
         [0010]    The invention consists of a boot loader for a device, comprising an IP stack supporting Internet protocols, and a scripting engine to run a default script. The IP stack includes address discovery service (for example, BOOTP and DHCP), a URI to IP address translator (for example, DNS), and a protocol for file transfer over the Internet (for example, HTTP, FTP and/or TFTP). On start-up of the device, the boot loader runs the default script to initialize the device and verify the integrity of any data and operating systems in memory on the device.  
           [0011]    Preferably, the default script generates and verifies a primary partition table and a secondary partition table in memory on the device, the partition tables being identical in content. The content of the partition tables is partition metadata describing one or more partitions in memory on the device. The initialization further includes generating and verifying the partitions in memory on the device using the partition metadata.  
           [0012]    On start-up of the device, the boot loader will attempt to go through the redundant partition tables and check if they are valid. If no partition tables exist or the update flag is set, the boot loader will retrieve the unique ID of the device and use the recovery script to create the partition tables. The script might instruct the boot loader to download scripts and/or data from a server on the Internet.  
           [0013]    If one of the partition tables is invalid then the boot loader will attempt to recover the partition table contents using the redundant copy of the partition tables.  
           [0014]    This process may be streamlined by the use of prepared device profiles and scripts located on the remote web server.  
           [0015]    After validating the partition tables, the boot loader loads and runs a start-up script.  
           [0016]    The start-up script may instruct the boot loader to check for updated versions of software present on the server, either at start-up, or at set intervals. The boot loader may further use the same mechanism to repair or replace corrupted software on the device.  
           [0017]    Additionally, the boot loader can support memory partition, to allow for multiple operating systems on a single device.  
           [0018]    The invention also comprises the method of using the above boot loader for loading a device image into an Internet-connected device. 
       
    
    
     BRIEF DESCRIPTION OF THE DRAWINGS  
       [0019]    The invention itself both as to organization and method of operation, as well as additional objects and advantages thereof, will become readily apparent from the following detailed description when read in connection with the accompanying drawings:  
         [0020]    [0020]FIG. 1 is a block diagram of the architectural components of a boot loader according to the present invention;  
         [0021]    [0021]FIG. 2 is a flowchart for determining a valid boot partition;  
         [0022]    [0022]FIG. 3 is a flowchart of the partition table processing logic for a single partition;  
         [0023]    [0023]FIG. 4 is a flowchart of the user interface logic;  
         [0024]    [0024]FIG. 5 is a flowchart of a partition chain update and a loading process for multiple partitions;  
         [0025]    [0025]FIG. 6 is a table for a Partition Table Header Layout;  
         [0026]    [0026]FIG. 7 is a table for a Partition Entry Layout. 
     
    
     DETAILED DESCRIPTION  
       [0027]    In the following description, a “device image” means an executable operating system and/or data required for proper operation of a device. A device image may contain file systems or plain data, as required.  
         [0028]    A “device unique ID” is a serial number or string that unique identifies a device from any other device. The device unique ID must be stored in a non-volatile manner and allow for easy retrieval at any time. Frequently, the MAC address is used as a device unique ID, however, any number or string that meets the requirements will suffice. A MAC (Media Access Control) address is a computer&#39;s unique hardware number. Ethernet MAC addresses are unique and are administered and distributed by the IEEE.  
         [0029]    [0029]FIG. 1 shows the architectural components of a boot loader  10  according to the present invention. The components of the boot loader  10  are installed onto a hardware platform  11 . Each of the components is described in detail below.  
         [0030]    The Operating System  12  supports a wide variety of potential peripheral device drivers  14  including Ethernet, 802.11 WiFi, USB and Serial.  
         [0031]    The Operating System  12  can also include a User Interface (UI) designed to be accessible through serial or network interfaces, LCD touch screens, or any other input method as required. The UI contains an extensible lexical analyzer for parsing regular expressions in the input stream. The lexical analyzer should be extensible to allow for understanding of complex UI commands as needed.  
         [0032]    The IP stack  16  provides the essential support for high-level protocols and services  18  to allow successful communication over the Internet. These may include BOOTP and DHCP for address discovery, a DNS resolver to translate URIs to IP addresses and HTTP, FTP and TFTP for downloading images over the Internet.  
         [0033]    The IP stack  16  also supports a scripting engine  20 , which runs scripts written in a scripting language  22 . The scripts contain the logic used by the boot loader  10  upon start-up of the hardware  11 .  
         [0034]    The scripting language  22  provides the functionality for implementing the different desired recovery and update scenarios. The scripting language should be extensible via scripts on a server that contains various device profiles. The device profiles are selected on the server based on the unique ID of the device. This allows changes to the device image to be made according to data stored on a server, without user interaction or modification of the boot loader  10  on the device.  
         [0035]    An example of the typical constructs in the scripting language  22  is set forth below. Obviously, commands and syntax can be freely modified to achieve the same effect or to create additional effects.  
         [0036]    Variables  
         [0037]    VARIABLE=expression  
         [0038]    Assign a value to a variable.  
         [0039]    Conditional Execution  
         [0040]    IF (expression) ELSE ENDIF  
         [0041]    Conditionally execute commands. Used in scripting.  
         [0042]    PRINT—Console Output  
         [0043]    PRINT expression  
         [0044]    Print an expression on the console without CR/LF at the end.  
         [0045]    PRINTLN expression  
         [0046]    Print an expression on the console with CR/LF at the end  
         [0047]    FLASH—Copy memory to Flash  
         [0048]    FLASH start source bytes  
         [0049]    Copy an image to the start address in flash memory from any other memory location for the number of bytes indicated.  
         [0050]    LOCK—Lock flash memory  
         [0051]    LOCK  
         [0052]    Lock the selected partitions flash memory.  
         [0053]    LOCK partition  
         [0054]    Lock the indicated partitions flash memory.  
         [0055]    LOCK Start Length  
         [0056]    Lock a range of memory in flash from Start for length bytes.  
         [0057]    UNLOCK—Unlock flash memory  
         [0058]    UNLOCK  
         [0059]    Unlocks the selected partitions flash memory.  
         [0060]    UNLOCK partition  
         [0061]    Unlocks the indicated partitions flash memory.  
         [0062]    UNLOCK Start Length  
         [0063]    Unlocks a range of memory in flash from Start for length bytes.  
         [0064]    ERASE—Erase flash memory  
         [0065]    ERASE  
         [0066]    Erase the selected partitions flash memory.  
         [0067]    ERASE partition  
         [0068]    Erase the indicated partitions flash memory.  
         [0069]    ERASE Start Length  
         [0070]    Erase a range of memory in flash from Start for length bytes.  
         [0071]    Modify Partition Entry  
         [0072]    CHAIN partition  
         [0073]    Chain partitions to the selected partition.  
         [0074]    UNCHAIN  
         [0075]    Unchain all partitions from the selected partition.  
         [0076]    PERMISSION=RO/RW  
         [0077]    Change the permissions of the selected partition to RO (Read Only) or RW (Read/Write)  
         [0078]    RELOCATE=YES/NO  
         [0079]    Set the relocation flag for the selected partition.  
         [0080]    If selected, this partition will be copied to RAM before execution.  
         [0081]    LOADADDRESS=entry  
         [0082]    Set the entry point for the selected partition.  
         [0083]    PARAMETERS=STRING  
         [0084]    Set the kernel parameters for the selected partition.  
         [0085]    The parameters will be passed to the kernel when it is executed.  
         [0086]    TYPE=ImageType  
         [0087]    Set the image type to one of the following supported types: JFFS/CE/LINUX/RAMDISK/BOOTLOADER  
         [0088]    SOURCE=STRING  
         [0089]    Set the origin of the selected partition. This URL or filename will be used to download the image.  
         [0090]    Manage Partition Entry.  
         [0091]    CREATE Start Length  
         [0092]    Create a new partition in flash memory from the Start block indicated for the number of blocks indicated by the Length parameter. This will also select this partition for further partition manipulation.  
         [0093]    DELETE partition  
         [0094]    Delete the partition and make it&#39;s space available for reuse.  
         [0095]    SELECT partition  
         [0096]    Select the partition for further partition manipulation.  
         [0097]    ACTIVE partition  
         [0098]    Set the partition as the Active partition. This partition will be automatically used at the next reboot.  
         [0099]    UPDATE partition  
         [0100]    Download the image of the partition from its origin and copy it to flash using the information stored in the partition Meta data.  
         [0101]    UPDATE  
         [0102]    Download the image of the selected partition from its origin and copy it to flash using the information stored in the partition Meta data.  
         [0103]    SAVE  
         [0104]    Save the modifications made to the partition table.  
         [0105]    DISPLAY partition  
         [0106]    Display all the Meta data related to the partition.  
         [0107]    LIST  
         [0108]    List the contents of the partition table in table form.  
         [0109]    DOWNLOAD IP Name  
         [0110]    Download a file using the TFTP at IP. Upon successful completion the address and length where the file is stored will be printed on the console. The variables ‘start’ and ‘length’ will also be set to the appropriate values.  
         [0111]    DOWNLOAD Name/URL  
         [0112]    Download a file using the default TFTP server or use HTTP if a valid URL is entered. Upon successful completion the address and length where the file is stored will be printed on the console. The variables ‘start’ and ‘length’ will also be set to the appropriate values.  
         [0113]    Memory Manipulation  
         [0114]    DUMP Start Length  
         [0115]    Display the contents of memory from Start for Length bytes.  
         [0116]    COPY Dest Source Length  
         [0117]    Copy memory from Source to Dest(ination) for Length bytes.  
         [0118]    General  
         [0119]    INFO  
         [0120]    Display hardware and network configuration.  
         [0121]    RESTORE=URL  
         [0122]    Set the restore URL. This is the URL that will be used to download a script to configure the board.  
         [0123]    SERVER=IP  
         [0124]    Set the default TFTP server IP address.  
         [0125]    HOST=IP  
         [0126]    Set the IP address of the board manually. This will only be used if DHCP is not available.  
         [0127]    DNS1=IP  
         [0128]    Set the IP address of the Primary DNS server manually.  
         [0129]    This will only be used if DHCP is not available.  
         [0130]    DNS2=IP  
         [0131]    Set the IP address of the Secondary DNS server manually. This will only be used if DHCP is not available.  
         [0132]    CODE  
         [0133]    This variable is always set to the return value of the last command executed.  
         [0134]    EXEC IP Filename  
         [0135]    Download and execute the script using the specified TFTP server.  
         [0136]    EXEC Filename/URL  
         [0137]    Download and execute the script using the default TFTP server or use HTTP if a valid URL is entered.  
         [0138]    BOOT partition parameter  
         [0139]    Boot the image stored in the indicated partition and pass the parameter string in as an argument.  
         [0140]    BOOT partition  
         [0141]    Boot the image stored in the indicated partition.  
         [0142]    BOOT parameter  
         [0143]    Boot the image stored in the active partition and pass the parameter string in as an argument.  
         [0144]    BOOT  
         [0145]    Boot the image stored in the active partition.  
         [0146]    VERSION  
         [0147]    Return the current partition version number.  
         [0148]    VALID  
         [0149]    Return TRUE if the partition is calculated to be valid, return FALSE otherwise. The validity of a partition can be determined by calculating a checksum or CRC value.  
         [0150]    UPDATEFLAG=Yes/No  
         [0151]    Set the update flag to be either on or off.  
         [0152]    The scripting language  22  can be extended to support other needs of the boot loader  10 . For example, the script language  22  can include support for security protocols to allow for authentication of servers when downloading scripts and device images.  
         [0153]    The server supports predetermined device profiles. A device profile is a collection of device images that define the behavior of a device. For example, device profile A might contain a StrongArm Linux kernel image and a file system image. Device profile B might contain a PXA250 kernel image and the same file system image. The server selects the device profile based on the unique device ID. This allows the boot loader  10  to synchronize the local device with its device profile on the web server for a robust and reliable connection.  
         [0154]    Memory Partitioning  
         [0155]    Memory (flash memory in most devices) is a single resource like an unformatted computer disk drive in a PC. Management is problematic since many users try to allocate sections for use in their applications. To manage the flash memory block in a consistent familial way, the same partitioning scheme used in a PC Disk Drives can be used with enhancements to accommodate flash memory. A partition table keeps track of all the allocated blocks in the flash memory. Only one active partition gets control when the system boots. The active partition can be set to any valid bootable partition.  
         [0156]    Flash memory is very slow to update. It can take several seconds to write a block of data to Flash Memory. Therefore, during the write operation, there is a risk of events occurring that can put the Flash Block in an inconsistent state. To address this problem, the boot loader uses two partition tables: a Primary Partition Table (PPT) and a Secondary Partition Table (SPT). Both Partition Tables have a CRC field to check the validity of the Partition Table. The algorithm is shown in FIG. 2.  
         [0157]    The following rules are used to make sure the flash memory stays consistent:  
         [0158]    The PPT will always be used unless it is invalid. (step  30 )  
         [0159]    The SPT will be used if it is valid and the PPT is invalid (step  32 ).  
         [0160]    If the PPT is invalid and the SPT is valid, the PPT will be replaced by the SPT. (step  38 )  
         [0161]    If the SPT is invalid and the PPT is valid, the SPT will be replaced by the PPT. (steps  34 ,  36 )  
         [0162]    If both PPT and SPT are invalid, both Partition Tables will be initialized to an empty state. (step  40 )  
         [0163]    To accommodate everything that a boot loader can do with a partition, there needs to be some metadata information associated to it. This information will be stored in the Partition Table entry associated with the Partition. The structure of the header for the Partition Table entry is shown in FIG. 6. An example of this metadata is the very specific kernel parameters that must be passed to a Linux kernel at startup.  
         [0164]    An operating system might consist of more than one type of Image. For example a typical Linux OS will need the following images:  
         [0165]    Kernel Image  
         [0166]    Root Ram disk Image  
         [0167]    Flash File system Image.  
         [0168]    To boot Linux, the Kernel Image and Root Ram disk Image must be moved into the system&#39;s RAM before the Kernel gets control. This is accomplished with Partition Table links originating from the Kernel&#39;s Partition Entry as shown in FIGS.  6  (Partition Header) and  7  (Partition Entry Layout).  
         [0169]    Definition of metadata terms used in FIGS. 6 and 7:  
         [0170]    Image Checksum:  
         [0171]    Calculated checksum of Stored Image.  
         [0172]    Start Block:  
         [0173]    Start of Flash block containing Image  
         [0174]    Number Of Blocks:  
         [0175]    Number of Flash blocks used by the data of a Partition (minimum=1).  
         [0176]    Partition Type:  
         [0177]    Operating system (e.g. Linux, eCOS, Windows CE), file system (e.g. JFFS, ext2, RAMfs), etc.  
         [0178]    Permissions:  
         [0179]    Read Only/Read-Write/Boot.  
         [0180]    In place Flag:  
         [0181]    Indicates that image must be copied to RAM (See Load Address).  
         [0182]    Version Info:  
         [0183]    Version number of the image.  
         [0184]    Load Address:  
         [0185]    Start address in RAM that the image must be copied to.  
         [0186]    Actual Size:  
         [0187]    Size of image in bytes.  
         [0188]    Next partition:  
         [0189]    Next partition in the linked list of partitions. (0=end of the list).  
         [0190]    Parameters:  
         [0191]    Image-specific parameters.  
         [0192]    Where the boot loader differs from the conventional start-up process is at the boot record retrieval phase. Instead of searching for the boot programs on a diskette or hard drive, the boot loader searches the partitions in memory (shown in FIG. 2). Valid partitions are determined in accordance with the logic described in FIG. 2. Once the partitions are validated, the system either switches (step  42 ) to interactive mode, if a choice of OS is needed from the user (FIG. 4), or proceeds to the partition table processing steps (FIG. 3). FIG. 3 shows the start of the boot process, which may continue to FIG. 5 if chained partitions are processed.  
         [0193]    The boot loader proceeds through the steps set out in FIG. 3 to find a bootable partition. The partition table is read (step  50 ) and the table is checked for a bootable partition chain (step  52 ). If one is not present, a script is downloaded (steps  54 ,  56 ) from the URI specified in the partition header and run (step  58 ). If the download fails, the system will either (step  60 ) pass control to the user interface (FIG. 4) or re-attempt the download (step  54 ) after a short delay (step  62 ). Once a bootable partition is found, the boot loader will process all the chained partitions (FIG. 5) and then pass control to the first partition.  
         [0194]    For a multiple partition device using a partition chain, each partition must be validated (or updated, as required) according to the steps in FIG. 5. First (step  70 ), the partition table is checked to see if any partitions remain on the list. If not, then the system boots the first bootable partition on the chain (step  88 ).  
         [0195]    If partitions remain, then the next partition header in the chain is loaded (step  72 ). The partition is checked to determine if the partition update flag is set or if the partition is invalid. If the partition is valid and the update flag is not set, the partition is processed (step  76 ) and the list in the partition table is checked for any remaining partitions (step  70 ). Otherwise the script for the partition entry must be downloaded (step  78 ) according to the URI in the partition entry. After a successful download (step  80 ) the script is run (step  82 ) and the partition processed (step  76 ). If the download fails, the system will either (step  84 ) pass control to the user interface (FIG. 4) or re-attempt the download (step  78 ) after a short delay (step  86 ).  
         [0196]    The end result is that, either the first bootable partition is booted (FIG. 5, step  88 ), or the interactive user interface is run (FIG. 4) to allow the user to choose from multiple bootable partitions.  
         [0197]    Definitions of terms in FIGS.  2 - 5 :  
         [0198]    Configure Networking:  
         [0199]    This step includes setting up all the networking protocols and establishing networking connections making sure that they work.  
         [0200]    Primary Partition Valid:  
         [0201]    Check the validity of the primary partition. The check can be performed in many ways, most commonly by Cyclic Redundancy Checking (CRC).  
         [0202]    Switch to Interactive Mode:  
         [0203]    A check is performed to see if the user is interested in switching to command based interactive mode. This can be done by checking if any button is pressed or if the user is pressing a certain button on the keyboard.  
         [0204]    Run Interactive User Interface:  
         [0205]    Bring up a command line on the display and allow the user to enter commands.  
         [0206]    Read Partition Table:  
         [0207]    Process the partition table entries to view all metadata available in the table.  
         [0208]    Bootable partition chain flagged:  
         [0209]    Check if the partition table metadata indicates that this partition is bootable.  
         [0210]    Delay:  
         [0211]    Delay for a certain amount of time (i.e. 5 seconds), so as not to flood the processor.  
         [0212]    Run Script:  
         [0213]    Execute all the commands in the script as described above.  
         [0214]    In effect, on start-up, the boot loader uniquely identifies the device to the web server, over the Internet, processes the script commands from the web server according to the scripting language, and synchronizes the local device with the data (e.g. device profile) provided by the web server. The boot process then continues in the same fashion as a conventional boot loader, transparent to the user.  
         [0215]    Accordingly, while this invention has been described with reference to illustrative embodiments, this description is not intended to be construed in a limiting sense. Various modifications of the illustrative embodiments, as well as other embodiments of the invention, will be apparent to persons skilled in the art upon reference to this description. It is therefore contemplated that the appended claims will cover any such modifications or embodiments as fall within the scope of the invention.