1. Technical Field
Embodiments of the present disclosure relate to a Universal Serial Bus (USB), and more particularly to a USB flash drive and method for switching functions of the USB flash drive.
2. Description of Related Art
Generally, a USB flash drive (also known as memory stick, flash memory, thumb drive, etc) can be used as a storage device for storing data, and as a startup disk for installation of an operating system. That is, the USB flash drive function both as a storage device and a startup disk. However, when the USB needs to function as a startup disk from functioning as a storage device, the data in the USB flash drive has to be cleared first, and a startup file of an operating system needs to copied into the USB flash drive. When the function of the startup disk needs to switch to the function of the storage device, specific sections of the USB flash drive need to be cleared to avoid the USB flash drive being considered as a startup option by a computer device. Thus, it is inconvenient to switch the two functions of the USB flash drive, and both data and time may be lost.
The disclosure is illustrated by way of example and not by way of limitation in the figures of the accompanying drawings in which like references indicate similar elements. It should be noted that references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean at least one.
In general, the word “module”, as used herein, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming language, such as, Java, C, or assembly. One or more software instructions in the modules may be embedded in firmware, such as EPROM. The modules described herein may be implemented as either software and/or hardware modules and may be stored in any type of non-transitory computer-readable medium or other storage device. Some non-limiting examples of non-transitory computer-readable media include CDs, DVDs, BLU-RAY, flash memory, and hard disk drives.
The host controller 1 may read and write data in the USB flash drive 1. The flash memory 11 stores various data in the USB flash drive 1. In some embodiments, the flash memory 11 includes a boot flash memory section 12 and a main flash memory section 13. The boot flash memory section 12 stores boot files for an installation of an operating system of the computer device 2. The boot flash memory section 12 and the main flash memory section 13 are located in different memory addresses of the flash memory 11. The bilateral switch 14 has a slip key (not shown in
The USB flash drive 1 further includes at least one processor 16. The at least one processor 16 executes one or more computerized codes and other applications of the USB flash drive 1, to provide functionality to the USB flash drive 1.
The setting module 100 sets a boot mode of the USB flash drive 1 under the condition that the bilateral switch 14 is under the first triggered status, and sets a memory mode of the USB flash drive 1 under the condition that the bilateral switch 14 is under the second triggered status.
The transmission module 102 receives an instruction to read data in the USB flash drive 1 from the computer device 2, upon the condition that the USB flash drive 1 is connected to the computer device 2.
The determination module 104 determines whether the USB flash drive 1 is in the boot mode, according to a current triggered status of the bilateral switch 14. If the determination module 104 detects that the bilateral switch 14 is under the first triggered status, the determination module 104 determines that the USB flash drive 1 is in the boot mode.
If the USB flash drive 1 is in the boot mode, the controlling module 106 controls the host controller 10 to access data in the flash memory 11 of the USB flash drive 1. Data in both the boot flash memory section 12 and the main flash memory section 13 may be processed, such as reading and writing corresponding data, for example.
If the USB flash drive 1 is not in the boot mode, the controlling module 106 controls the host controller 10 to access the data in the main flash memory section 13 in the flash memory 11, and denies access to data in the boot flash memory section 12. That is, if the USB flash drive 1 is under the memory mode, only the data in the main flash memory section 13 may be processed.
The transmission module 102 further transmits accessed data to the computer device 2.
The determination module 104 further determines whether all the accessed data has been transmitted to the computer device 2. In some embodiments, if the instruction to disconnect the USB flash drive 1 has received from the computer device 2, the determination module 104 determines that all the accessed data has been transmitted to the computer device 2. In other embodiments, the determination module 104 may determine that all the accessed data has been transmitted to the computer device, if volume of transmitted accessed data has reached a predetermined amount or number (e.g., 500 k) before transmission of the accessed data. If the transmission has not finished, the host controller 10 may continue to access data in the USB flash drive 1 according to a current mode of the USB flash drive 1.
In block S10, the setting module 100 sets a boot mode of the USB flash drive 1 under the condition that the bilateral switch 14 is under the first triggered status, and sets a memory mode of the USB flash drive 1 under the condition that the bilateral switch 14 is under the second triggered status.
In block S11, when the USB flash drive 1 is connected to the computer device 2, the transmission module 102 receives an instruction from the computer device 2 to read data in the USB flash drive 1.
In block S12, the determination module 104 determines whether the USB flash drive 1 is in the boot mode, according to a current triggered status of the bilateral switch 14. When the determination module 104 detects that the bilateral switch 14 is under the first triggered status, the determination module 104 determines the USB flash drive 1 is under the boot mode. If the USB flash drive 1 is in the boot mode, block S13 is implemented; if the USB flash drive 1 is in the memory mode, block S14 is implemented.
In block S13, the controlling module 106 controls the host controller 10 to access data in the flash memory 11 in the USB flash drive 1, and block S15 is implemented.
In block S14, the controlling module 106 further controls the host controller 10 to access data in the main flash memory section 13 in the flash memory 11, and denies access to data in the boot flash memory section 12.
In block S15, the transmission module 102 further transmits accessed data to the computer device 2.
In block S16, the determination module 104 further determines whether all the accessed data has been transmitted to the computer device 2. The determination module 104 may determine that the all the accessed data has been transmitted to the computer device 2, if an instruction to disconnect the USB flash drive 1 has received from the computer device 2. If all the accessed data has been transmitted to the computer device 2, the procedure is ended.
In block S17, if all the accessed data has not been transmitted to the computer device 2, the host controller 10 may continue to access data in the USB flash drive 1 according to a current mode of the USB flash drive 1, and block S15 is repeated.
It should be emphasized that the described exemplary embodiments are merely possible examples of implementations, and have been set forth for a clear understanding of the principles of the present disclosure. Many variations and modifications may be made to the-described exemplary embodiments without departing substantially from the spirit and principles of the present disclosure. All such modifications and variations are intended to be comprised herein within the scope of this disclosure and the described inventive embodiments, and the present disclosure is protected by the following claims.
Number | Date | Country | Kind |
---|---|---|---|
201010563794.4 | Nov 2010 | CN | national |