# Patent

## Title
Method and system providing a self-test on one or more sensors coupled to a device

## Abstract

A method and system for providing a self-test configuration in a device is disclosed. The method and system comprise providing a self-test mechanism in a kernel space of a memory and enabling a hook in a user space of the memory, wherein the hook is in communication with the self-test mechanism. The method and system also include running the self-test driver and utilizing the results.

## Background
CROSS REFERENCE TO RELATED APPLICATION
Under 35 U.S.C. 120, this application is a Continuation Application and claims priority to U.S. application Ser. No. 13/797,058, filed Mar. 12, 2013, entitled “METHOD AND SYSTEM PROVIDING A SELF-TEST ON ONE OR MORE SENSORS COUPLED TO A DEVICE,” which claims the benefit of priority of U.S. Patent Application No. 61/610,421, filed on Mar. 13, 2012, entitled “SELF-TEST METHOD IN LINUX DEVICE DRIVER FOR SENSOR”, all of which are incorporated herein by reference in their entireties.


FIELD OF THE INVENTION
The present invention relates generally to a device which receives data from one or more sensors and more particularly to a self-test utilized within such a device.
BACKGROUND OF THE INVENTION
A driver is a computer program which allows higher-level computer programs to interact with a hardware device. A sensor is a chip that can detect physical quantity and convert it into electronic signals that is readable by computer programs within the device. A driver is necessary for a processor to interact with a sensor.
Conventionally, a self-test program is a separate program that runs in the user space of a memory associated with the device. This has several disadvantages. First, the self-test program is a separate program from the driver, and therefore could be lost or mismatched with the driver. If the driver is upgraded to a newer version and an old self-test program is used, an incorrect result could be generated.
Second, providing the self-test program within in the user space is more complicated because a separate software program has to be copied into the operating system of the device. This may not be convenient or even not allowed in some situations. Third, it provides for the possibility of a hacker providing a fake self-test program. If a fake program is utilized to provide the self-test function the result is completely un-predictable.
Accordingly what is needed is a system and method that addresses the above identified issues. The present invention addresses such a need.
SUMMARY OF THE INVENTION
A method and system for providing a self-test in a device is disclosed. The method and system comprise providing a self-test mechanism in a kernel space of a memory and enabling a hook in a user space of the memory, wherein the hook is in communication with the self-test mechanism. The method and system also includes running the self-test mechanism based on a user input via the self-test hook and utilizing the results.



BRIEF DESCRIPTION OF THE DRAWINGS
FIG. 1 illustrates a hardware device coupled to one or more sensors.
FIG. 2 shows a more detailed view of the memory which is utilized with a system and method in accordance with the present invention.
FIG. 3 is a flow chart of a self-test process in accordance with the present invention.



DETAILED DESCRIPTION
The present invention relates generally to a device which receives data from one or more sensors and more particularly to a self-test configuration utilized within such a device. The following description is presented to enable one of ordinary skill in the art to make and use the invention and is provided in the context of a patent application and its requirements. Various modifications to the preferred embodiments and the generic principles and features described herein will be readily apparent to those skilled in the art. Thus, the present invention is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features described herein.
FIG. 1 illustrates system 100 that includes a hardware device 112 coupled to one or more sensors 102. In this embodiment, the sensors are a MEMS sensor 102. However one of ordinary skill in the art readily recognizes that the sensors could be any number and/or any type and their use would be within the spirit and scope of the present invention. For example the types of sensors that could used include and are not limited to accelerometers pressure sensors, temperature gyroscopes and any other type of sensors, motion sensing or otherwise. The device 112 includes a processor 116 and a memory 118 which is in communication with the processor 116. The memory 118 includes a volatile memory 120 and a non-volatile memory 122. System 100 receives self-test input 104 and executes the self-test on the sensors and returns the self-test result.
In an embodiment, the sensors can include MEMS accelerometers, gyroscope, magnetometer and pressure sensors. Some embodiments include accelerometer, gyroscope, and magnetometer each provide measurement along three axis orthogonal to each other. Other embodiments may not include all the sensors or may provide measurements along one or more axis. The sensors are formed on a first substrate.
The device 100 further includes electronic circuit to receive the measurement outputs. The electronic circuit is implemented on a second silicon substrate. The first substrate is vertically bonded to the second substrate. In one embodiment, the first substrate is bonded to the second substrate through wafer bonding, as described in commonly owned U.S. Pat. No. 7,104,129 (assigned to the assignee of the present application and incorporated herein by reference above) that simultaneously provides electrical connections and hermetically seals the MEMS devices. This unique and novel fabrication technique is the key enabling technology that allows for the design and manufacture of high performance, multi-axis, inertial sensors in a very small and economical package. Integration at the wafer-level minimizes parasitic capacitances, allowing for improved signal-to-noise relative to a discrete solution. Such integration at the wafer-level also enables the incorporation of a rich feature set which minimizes the need for external amplification.
Accordingly, a system and method in accordance with the present invention addresses these issues. A method and system for providing a self-test configuration in a device is disclosed. The system and method comprise providing a self-test mechanism in a kernel space of a memory and enabling a hook in a user space of the memory, wherein the hook is in communication with the self-test mechanism. The method also includes running the self-test driver and returning the results to a user.
In so doing, the above identified difficulties are overcome. To describe the features of the present invention in more detail refer now to the following description in conjunction with the accompanying figures.
A system that utilizes self-test process in accordance with the present invention can take the form of an entirely hardware implementation, an entirely software implementation, or an implementation containing both hardware and software elements. In one implementation, this disclosure is implemented in software, which includes, but is not limited to, application software, firmware, resident software, microcode, etc.
Furthermore, this managing application process can take the form of a computer program product accessible from a computer-usable or computer-readable medium providing program code for use by or in connection with a computer or any instruction execution system. For the purposes of this description, a computer-usable or computer-readable medium can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
The medium can be an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system (or apparatus or device) or a propagation medium. Examples of a computer-readable medium include a semiconductor or solid state memory, magnetic tape, a removable computer diskette, a random access memory (RAM), a read-only memory (ROM), a rigid magnetic disk, and an optical disk. Current examples of optical disks include DVD, compact disk-read-only memory (CD-ROM), and compact disk-read/write (CD-R/W).
FIG. 2 shows a more detailed view of the memory 118 which is utilized with a system and method in accordance with the present invention. The memory 118 includes a volatile memory 120 and non-volatile memory 122. Volatile memory 120 includes of a kernel space 202 and user space 204. Kernel space 202, includes the self-test driver execution space 206 and kernel section space 214 and Self-test hook 208 resides in the user-space. Self-test input 220 is stored in user space before executing self-test, similarly, self-test output 222 is stored in user space 204 before returning the result to the user. The self-test driver execution 206 is in communication with the self-test hook 208. The non-volatile memory 122 stores the self-test driver 210 and kernel 212.
FIG. 3 is a flow chart of a self-test process in accordance with the present invention. Referring to FIGS. 2 and 3 together, first power is applied to the device 112, via step 302. Then, a kernel is loaded from non-volatile memory 122 to volatile memory 120, via step 304. Next an input is received by the device, via step 306. Thereafter, a self-test hook is enabled, via step 308. The self-test driver is run based upon that hook, via step 310. Then the results of the self-test are provide to the user space, via step 312.
Referring back to FIG. 2, the volatile memory 122 is divided into two spaces, a kernel space 202 and user space 204. The kernel space 202 is strictly for an operating system kernel (such as Linux, Mozilla or Windows) and driver programs and is protected from unauthorized changes from user space 204. User space 204 is where normal user programs are running. Kernel 202 and driver programs 206 usually expose some handlers to user space 204 so that the user can use these services.
As an example, Sysfs is a command utilized in Linux to export information about device drivers to the user space 204 and is also used for configuration. A device driver could have many configurations such as data rate, sample rate, etc. These configurations are exposed as separate files in a specified directory that the user space 204 can access. If a user wants to change one configuration, all the user needs to do is write to this file like writing to a normal file. Some settings are for information only. The files corresponding to these settings are set as read-only. User space 202 programs can read these files like reading a normal file. The output of these read actions are the configuration values. For example, to get current sample rate “cat sample_rate” command can be executed in the directory containing the sysfs file “sample_rate”. The value of the sample rate will be returned to user. The command “cat” is a Linux command that reads a file and returns the result to the standard output, i.e., the screen in normal situations. The file “sample_rate” is one of the device driver's settings that stores the current value of the sample rate.
The self-test function is provided in the device driver code and is a file in a directory along with device driver's other configurations. For example, this file could be called “self_test”. A command “cat self_test” would trigger the driver to set the device 112 to pre-determined settings and perform a self-test. The test result “pass/fail” would return to user as the result of “cat self_test”.
A system and method in accordance with the present invention has several advantages over conventional self-test mechanisms. Firstly, one program performs the entire function. Hence, there are no mismatch/version problems. Furthermore the self-test mechanism is part of the kernel space. Therefore the self-test function is protected and cannot be changed once the operating system starts running. Also, the user interface is simple. Typically the command can be an operating system built in command. Finally, it is easier to run the self-test function during manufacturing because the easy interface and the whole software system does not need to be brought.
For example, the command “cat” is a built-in command of the Linux operating system. The simplest “bare-bone” kernel has this command. Therefore, no special program is required to install in order to perform the test. A system and method in accordance with the present invention allows for the self-test function to be contained in the driver and exposed into a system interface.
Another feature of the present invention is that the self-test driver can include a calibration function. For instance, with a MEMs gyroscope, often there is bias. If a user requirement is to not move the device while running the self-test, then while taking test data, the average of the gyroscope sensor output will be the gyroscope bias. This information can then be used by either the driver or a calling program to calibrate the gyroscope by saving and removing this bias. Often, for a self-test for gyroscopes, the sensor has to be stationary ensuring the user constraint of no motion for a proper self-test. If a further user constraint is given for accelerometers such that one of the axes of the accelerometers sensor is parallel to earth's gravity field (one example is being laid flat with respect to the earth's gravity), then the accelerometer can also be calibrated while running the self-test. When lying flat, the sensor should have a known value. Any deviation from the known value would be the bias on the accelerometer. This bias can also be saved and removed by either the driver or the calling program.
Although the present invention has been described in accordance with the embodiments shown, one of ordinary skill in the art will readily recognize that there could be variations to the embodiments and those variations would be within the spirit and scope of the present invention. Accordingly, many modifications may be made by one of ordinary skill in the art without departing from the spirit and scope of the appended claims.

## Claims

1. A computer implemented method for providing a self-test on one or more sensors coupled to a device, wherein the one or more sensors include any of an accelerometer, a gyroscope, a magnetometer and a pressure sensor, the method comprising: enabling a hook in a user space of a memory, wherein the hook is in communication with a self-test mechanism; receiving a user input via the hook; executing the self-test mechanism in a kernel space of the memory within the device; and returning the results to the user space; wherein the returning step includes returning the results to the user.

2. A device comprising: one or more sensors; wherein the one or more sensors include any of an accelerometer, a gyroscope, a magnetometer and a pressure sensor; a processing system; and a memory system in communication with the processing system, the memory including a volatile memory and a nonvolatile memory; wherein the nonvolatile memory stores a self-test mechanism for the one or more sensors coupled to the device, wherein the volatile memory comprises a kernel space and a user space; wherein the self-test mechanism is executed in the kernel space based upon a hook in the user space, wherein the hook is enabled by a user input, wherein results from the self-test mechanism are utilized.

3. The device of claim 2, wherein the gyroscope is stationary.

4. The device of claim 2 further comprising calibrating the accelerometer when one axes of the accelerometer is parallel to the earth's gravity field.

5. The device of claim 2, wherein the self-test mechanism comprises a self-test driver.

6. The device of claim 2, wherein the utilizing comprises returning the results to the user.

7. The device of claim 2, wherein the results are utilized for calibrating one of the one or more sensors.

8. The device of claim 2, wherein the results are the sampling rates of one of the one or more sensors.

9. A computer implemented method for providing a self-test on one or more sensors coupled to a device, the method comprising: enabling a hook in a user space of a memory, wherein the hook is in communication with a self-test mechanism; receiving a user input via the hook; executing the self-test mechanism in a kernel space of the memory within the device; wherein the kernel space is for any of a Linux operating system kernel, a Windows operating system kernel or a Mozilla operating kernel; and returning the results to the user space.

10. The computer implemented method of claim 9, wherein the hook comprises a file.

11. The computer implemented method of claim 9, wherein the memory comprises a nonvolatile memory and a volatile memory.

12. The computer implemented method of claim 11, wherein the user space and the kernel space are within the volatile memory.

13. The computer implemented method of claim 11, wherein the nonvolatile memory stores the self-test mechanism.

14. A computer implemented method for providing a self-test on one or more sensors coupled to a device, the method comprising: enabling a hook in a user space of a memory, wherein the hook is in communication with a self-test mechanism; receiving a user input via the hook; executing the self-test mechanism in a kernel space of the memory within the device; and returning the results to the user space; wherein the returning step includes returning the results to the user; wherein one of the results returned is a pass/fail indicator.

15. A device comprising: one or more sensors; wherein the one or more sensors include any of an accelerometer, a gyroscope, a magnetometer and a pressure sensor; a processing system; and a memory system in communication with the processing system, the memory including a volatile memory and a nonvolatile memory; wherein the nonvolatile memory stores a self-test mechanism for the one or more sensors coupled to the device, wherein the volatile memory comprises a kernel space and a user space; wherein the self-test mechanism is executed in the kernel space based upon a hook in the user space, wherein the hook is enabled by a user input, wherein results from the self-test mechanism are utilized; wherein one of the results is a pass/fail indicator.