Merge remote-tracking branch 'upstream/master'

pull/192/head
Yihui Xiong 2014-02-27 21:32:38 +08:00
commit 21baee7cc0
4 changed files with 129 additions and 81 deletions

View File

@ -20,26 +20,27 @@ Documentation
* [mbed library internals](http://mbed.org/handbook/mbed-library-internals) * [mbed library internals](http://mbed.org/handbook/mbed-library-internals)
* [Adding a new target microcontroller](http://mbed.org/handbook/mbed-SDK-porting) * [Adding a new target microcontroller](http://mbed.org/handbook/mbed-SDK-porting)
Supported Microcontrollers Supported Microcontrollers and Boards
-------------------------- -------------------------------------
NXP: NXP:
* [LPC1768](http://mbed.org/platforms/mbed-LPC1768/) (Cortex-M3) * [mbed LPC1768](http://mbed.org/platforms/mbed-LPC1768/) (Cortex-M3)
* [LPC1768](http://mbed.org/platforms/u-blox-C027/) (Cortex-M3) * [u-blox C027 LPC1768](http://mbed.org/platforms/u-blox-C027/) (Cortex-M3)
* [LPC11U24](http://mbed.org/platforms/mbed-LPC11U24/) (Cortex-M0) * [mbed LPC11U24](http://mbed.org/platforms/mbed-LPC11U24/) (Cortex-M0)
* [LPC11U35](http://mbed.org/platforms/EA-LPC11U35/) (Cortex-M0) * [EA LPC11U35](http://mbed.org/platforms/EA-LPC11U35/) (Cortex-M0)
* LPC2368 (ARM7TDMI-S) * mbed LPC2368 (ARM7TDMI-S)
* LPC810 (Cortex-M0+) * LPC810 (Cortex-M0+)
* [LPC812](http://mbed.org/platforms/NXP-LPC800-MAX/) (Cortex-M0+) * [LPC812](http://mbed.org/platforms/NXP-LPC800-MAX/) (Cortex-M0+)
* [LPC4088](http://mbed.org/platforms/EA-LPC4088/) (Cortex-M4) * [EA LPC4088](http://mbed.org/platforms/EA-LPC4088/) (Cortex-M4)
* LPC4330 (Cortex-M4 + Cortex-M0) * LPC4330 (Cortex-M4 + Cortex-M0)
* [LPC1347](http://mbed.org/platforms/DipCortex-M3/) (Cortex-M3) * [LPC1347](http://mbed.org/platforms/DipCortex-M3/) (Cortex-M3)
* [LPC1114](http://mbed.org/platforms/LPC1114FN28/) (Cortex-M0) * [LPC1114](http://mbed.org/platforms/LPC1114FN28/) (Cortex-M0)
* LPC11C24 (Cortex-M0) * LPC11C24 (Cortex-M0)
* [LPC1549](https://mbed.org/platforms/LPCXpresso1549/) (Cortex-M3)
Freescale: Freescale:
* KL05Z (Cortex-M0+) * [FRDM-KL05Z](https://mbed.org/platforms/FRDM-KL05Z/) (Cortex-M0+)
* [KL25Z](http://mbed.org/platforms/KL25Z/) (Cortex-M0+) * [FRDM-KL25Z](http://mbed.org/platforms/KL25Z/) (Cortex-M0+)
* [KL46Z](https://mbed.org/platforms/FRDM-KL46Z/) (Cortex-M0+) * [FRDM-KL46Z](https://mbed.org/platforms/FRDM-KL46Z/) (Cortex-M0+)
STMicroelectronics: STMicroelectronics:
* [Nucleo-F103RB](https://mbed.org/platforms/ST-Nucleo-F103RB/) (Cortex-M3) * [Nucleo-F103RB](https://mbed.org/platforms/ST-Nucleo-F103RB/) (Cortex-M3)
@ -48,6 +49,9 @@ STMicroelectronics:
* [Nucleo-F401RE](https://mbed.org/platforms/ST-Nucleo-F401RE/) (Cortex-M4) * [Nucleo-F401RE](https://mbed.org/platforms/ST-Nucleo-F401RE/) (Cortex-M4)
* STM32F407 (Cortex-M4) * STM32F407 (Cortex-M4)
Nordic:
* [nRF51822-mKIT](https://mbed.org/platforms/Nordic-nRF51822/) (Cortex-M0)
Supported Toolchains and IDEs Supported Toolchains and IDEs
----------------------------- -----------------------------
* GCC ARM: [GNU Tools for ARM Embedded Processors](https://launchpad.net/gcc-arm-embedded/4.7/4.7-2012-q4-major) * GCC ARM: [GNU Tools for ARM Embedded Processors](https://launchpad.net/gcc-arm-embedded/4.7/4.7-2012-q4-major)

View File

@ -41,7 +41,7 @@ typedef enum {
#include "USBEndpoints_LPC17_LPC23.h" #include "USBEndpoints_LPC17_LPC23.h"
#elif defined(TARGET_LPC11UXX) || defined(TARGET_LPC1347) #elif defined(TARGET_LPC11UXX) || defined(TARGET_LPC1347)
#include "USBEndpoints_LPC11U.h" #include "USBEndpoints_LPC11U.h"
#elif defined(TARGET_KL25Z) #elif defined(TARGET_KL25Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D5M)
#include "USBEndpoints_KL25Z.h" #include "USBEndpoints_KL25Z.h"
#elif defined (TARGET_STM32F4XX) #elif defined (TARGET_STM32F4XX)
#include "USBEndpoints_STM32F4.h" #include "USBEndpoints_STM32F4.h"

View File

@ -16,7 +16,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#if defined(TARGET_KL25Z) #if defined(TARGET_KL25Z) | defined(TARGET_KL46Z) | defined(TARGET_K20D5M)
#include "USBHAL.h" #include "USBHAL.h"
@ -59,7 +59,7 @@ typedef struct BDT {
uint8_t dummy; // RSVD: BD[8:15] uint8_t dummy; // RSVD: BD[8:15]
uint16_t byte_count; // BD[16:32] uint16_t byte_count; // BD[16:32]
uint32_t address; // Addr uint32_t address; // Addr
} BDT; } BDT;
// there are: // there are:
@ -82,10 +82,10 @@ uint32_t USBHAL::endpointReadcore(uint8_t endpoint, uint8_t *buffer) {
return 0; return 0;
} }
USBHAL::USBHAL(void) { USBHAL::USBHAL(void) {
// Disable IRQ // Disable IRQ
NVIC_DisableIRQ(USB0_IRQn); NVIC_DisableIRQ(USB0_IRQn);
// fill in callback array // fill in callback array
epCallback[0] = &USBHAL::EP1_OUT_callback; epCallback[0] = &USBHAL::EP1_OUT_callback;
epCallback[1] = &USBHAL::EP1_IN_callback; epCallback[1] = &USBHAL::EP1_IN_callback;
@ -117,11 +117,11 @@ USBHAL::USBHAL(void) {
epCallback[27] = &USBHAL::EP14_IN_callback; epCallback[27] = &USBHAL::EP14_IN_callback;
epCallback[28] = &USBHAL::EP15_OUT_callback; epCallback[28] = &USBHAL::EP15_OUT_callback;
epCallback[29] = &USBHAL::EP15_IN_callback; epCallback[29] = &USBHAL::EP15_IN_callback;
// choose usb src as PLL // choose usb src as PLL
SIM->SOPT2 |= (SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_PLLFLLSEL_MASK); SIM->SOPT2 |= (SIM_SOPT2_USBSRC_MASK | SIM_SOPT2_PLLFLLSEL_MASK);
// enable OTG clock // enable OTG clock
SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK; SIM->SCGC4 |= SIM_SCGC4_USBOTG_MASK;
@ -129,12 +129,12 @@ USBHAL::USBHAL(void) {
instance = this; instance = this;
NVIC_SetVector(USB0_IRQn, (uint32_t)&_usbisr); NVIC_SetVector(USB0_IRQn, (uint32_t)&_usbisr);
NVIC_EnableIRQ(USB0_IRQn); NVIC_EnableIRQ(USB0_IRQn);
// USB Module Configuration // USB Module Configuration
// Reset USB Module // Reset USB Module
USB0->USBTRC0 |= USB_USBTRC0_USBRESET_MASK; USB0->USBTRC0 |= USB_USBTRC0_USBRESET_MASK;
while(USB0->USBTRC0 & USB_USBTRC0_USBRESET_MASK); while(USB0->USBTRC0 & USB_USBTRC0_USBRESET_MASK);
// Set BDT Base Register // Set BDT Base Register
USB0->BDTPAGE1=(uint8_t)((uint32_t)bdt>>8); USB0->BDTPAGE1=(uint8_t)((uint32_t)bdt>>8);
USB0->BDTPAGE2=(uint8_t)((uint32_t)bdt>>16); USB0->BDTPAGE2=(uint8_t)((uint32_t)bdt>>16);
@ -144,14 +144,14 @@ USBHAL::USBHAL(void) {
USB0->ISTAT = 0xff; USB0->ISTAT = 0xff;
// USB Interrupt Enablers // USB Interrupt Enablers
USB0->INTEN |= USB_INTEN_TOKDNEEN_MASK | USB0->INTEN |= USB_INTEN_TOKDNEEN_MASK |
USB_INTEN_SOFTOKEN_MASK | USB_INTEN_SOFTOKEN_MASK |
USB_INTEN_ERROREN_MASK | USB_INTEN_ERROREN_MASK |
USB_INTEN_USBRSTEN_MASK; USB_INTEN_USBRSTEN_MASK;
// Disable weak pull downs // Disable weak pull downs
USB0->USBCTRL &= ~(USB_USBCTRL_PDE_MASK | USB_USBCTRL_SUSP_MASK); USB0->USBCTRL &= ~(USB_USBCTRL_PDE_MASK | USB_USBCTRL_SUSP_MASK);
USB0->USBTRC0 |= 0x40; USB0->USBTRC0 |= 0x40;
} }
@ -296,9 +296,9 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_
uint32_t n, sz, idx, setup = 0; uint32_t n, sz, idx, setup = 0;
uint8_t not_iso; uint8_t not_iso;
uint8_t * ep_buf; uint8_t * ep_buf;
uint32_t log_endpoint = PHY_TO_LOG(endpoint); uint32_t log_endpoint = PHY_TO_LOG(endpoint);
if (endpoint > NUMBER_OF_PHYSICAL_ENDPOINTS - 1) { if (endpoint > NUMBER_OF_PHYSICAL_ENDPOINTS - 1) {
return EP_INVALID; return EP_INVALID;
} }
@ -335,7 +335,7 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_
if (((Data1 >> endpoint) & 1) == ((bdt[idx].info >> 6) & 1)) { if (((Data1 >> endpoint) & 1) == ((bdt[idx].info >> 6) & 1)) {
if (setup && (buffer[6] == 0)) // if no setup data stage, if (setup && (buffer[6] == 0)) // if no setup data stage,
Data1 &= ~1UL; // set DATA0 Data1 &= ~1UL; // set DATA0
else else
Data1 ^= (1 << endpoint); Data1 ^= (1 << endpoint);
} }
@ -345,7 +345,7 @@ EP_STATUS USBHAL::endpointReadResult(uint8_t endpoint, uint8_t * buffer, uint32_
else { else {
bdt[idx].info = BD_DTS_MASK | BD_OWN_MASK; bdt[idx].info = BD_DTS_MASK | BD_OWN_MASK;
} }
USB0->CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK; USB0->CTL &= ~USB_CTL_TXSUSPENDTOKENBUSY_MASK;
*bytesRead = sz; *bytesRead = sz;
@ -368,27 +368,27 @@ EP_STATUS USBHAL::endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size)
idx = EP_BDT_IDX(PHY_TO_LOG(endpoint), TX, 0); idx = EP_BDT_IDX(PHY_TO_LOG(endpoint), TX, 0);
bdt[idx].byte_count = size; bdt[idx].byte_count = size;
// non iso endpoint // non iso endpoint
if (USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT & USB_ENDPT_EPHSHK_MASK) { if (USB0->ENDPOINT[PHY_TO_LOG(endpoint)].ENDPT & USB_ENDPT_EPHSHK_MASK) {
ep_buf = endpoint_buffer[idx]; ep_buf = endpoint_buffer[idx];
} else { } else {
ep_buf = endpoint_buffer_iso[2]; ep_buf = endpoint_buffer_iso[2];
} }
for (n = 0; n < size; n++) { for (n = 0; n < size; n++) {
ep_buf[n] = data[n]; ep_buf[n] = data[n];
} }
if ((Data1 >> endpoint) & 1) { if ((Data1 >> endpoint) & 1) {
bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK; bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK;
} else { } else {
bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK | BD_DATA01_MASK; bdt[idx].info = BD_OWN_MASK | BD_DTS_MASK | BD_DATA01_MASK;
} }
Data1 ^= (1 << endpoint); Data1 ^= (1 << endpoint);
return EP_PENDING; return EP_PENDING;
} }
@ -429,7 +429,7 @@ void USBHAL::usbisr(void) {
uint8_t istat = USB0->ISTAT; uint8_t istat = USB0->ISTAT;
// reset interrupt // reset interrupt
if (istat & USB_ISTAT_USBRST_MASK) { if (istat & USB_ISTAT_USBRST_MASK) {
// disable all endpt // disable all endpt
for(i = 0; i < 16; i++) { for(i = 0; i < 16; i++) {
USB0->ENDPOINT[i].ENDPT = 0x00; USB0->ENDPOINT[i].ENDPT = 0x00;
@ -457,11 +457,11 @@ void USBHAL::usbisr(void) {
// SOF interrupt // SOF interrupt
if (istat & USB_ISTAT_SOFTOK_MASK) { if (istat & USB_ISTAT_SOFTOK_MASK) {
USB0->ISTAT = USB_ISTAT_SOFTOK_MASK; USB0->ISTAT = USB_ISTAT_SOFTOK_MASK;
// SOF event, read frame number // SOF event, read frame number
SOF(frameNumber()); SOF(frameNumber());
} }
// stall interrupt // stall interrupt
if (istat & 1<<7) { if (istat & 1<<7) {
if (USB0->ENDPOINT[0].ENDPT & USB_ENDPT_EPSTALL_MASK) if (USB0->ENDPOINT[0].ENDPT & USB_ENDPT_EPSTALL_MASK)
@ -483,7 +483,7 @@ void USBHAL::usbisr(void) {
// EP0 SETUP event (SETUP data received) // EP0 SETUP event (SETUP data received)
EP0setupCallback(); EP0setupCallback();
} else { } else {
// OUT packet // OUT packet
if (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == OUT_TOKEN) { if (TOK_PID((EP_BDT_IDX(num, dir, ev_odd))) == OUT_TOKEN) {
@ -517,11 +517,11 @@ void USBHAL::usbisr(void) {
USB0->ISTAT = USB_ISTAT_TOKDNE_MASK; USB0->ISTAT = USB_ISTAT_TOKDNE_MASK;
} }
// sleep interrupt // sleep interrupt
if (istat & 1<<4) { if (istat & 1<<4) {
USB0->ISTAT |= USB_ISTAT_SLEEP_MASK; USB0->ISTAT |= USB_ISTAT_SLEEP_MASK;
} }
// error interrupt // error interrupt
if (istat & USB_ISTAT_ERROR_MASK) { if (istat & USB_ISTAT_ERROR_MASK) {

View File

@ -41,6 +41,8 @@ Usage:
import sys import sys
import json import json
import optparse
import pprint
from prettytable import PrettyTable from prettytable import PrettyTable
from serial import Serial from serial import Serial
@ -51,6 +53,7 @@ from time import sleep, time
ROOT = abspath(join(dirname(__file__), "..")) ROOT = abspath(join(dirname(__file__), ".."))
sys.path.insert(0, ROOT) sys.path.insert(0, ROOT)
# Imports related to mbed build pi
from workspace_tools.build_api import build_project, build_mbed_libs from workspace_tools.build_api import build_project, build_mbed_libs
from workspace_tools.paths import BUILD_DIR from workspace_tools.paths import BUILD_DIR
from workspace_tools.targets import TARGET_MAP from workspace_tools.targets import TARGET_MAP
@ -60,6 +63,7 @@ from workspace_tools.tests import TEST_MAP
ROOT = abspath(join(dirname(__file__), "..")) ROOT = abspath(join(dirname(__file__), ".."))
sys.path.insert(0, ROOT) sys.path.insert(0, ROOT)
# Imports related to mbed build pi
from workspace_tools.utils import delete_dir_files from workspace_tools.utils import delete_dir_files
from workspace_tools.settings import MUTs from workspace_tools.settings import MUTs
@ -77,7 +81,9 @@ class SingleTestRunner():
""" """
if sleep_before_reset > 0: if sleep_before_reset > 0:
sleep(sleep_before_reset) sleep(sleep_before_reset)
verbose_msg = "Reset::cmd(sendBreak)" if verbose:
verbose_msg = "Reset::cmd(sendBreak)"
# Reset type decision
if mcu_name.startswith('NRF51822'): # Nordic if mcu_name.startswith('NRF51822'): # Nordic
call(["nrfjprog", "-r"]) call(["nrfjprog", "-r"])
verbose_msg = "Reset::cmd(nrfjprog)" verbose_msg = "Reset::cmd(nrfjprog)"
@ -86,6 +92,7 @@ class SingleTestRunner():
verbose_msg = "Reset::cmd(ST-LINK_CLI.exe)" verbose_msg = "Reset::cmd(ST-LINK_CLI.exe)"
else: else:
serial.sendBreak() serial.sendBreak()
if sleep_before_reset > 0: if sleep_before_reset > 0:
sleep(sleep_after_reset) sleep(sleep_after_reset)
if verbose: if verbose:
@ -97,6 +104,7 @@ class SingleTestRunner():
serial.flushOutput() serial.flushOutput()
def is_peripherals_available(self, target, peripherals=None): def is_peripherals_available(self, target, peripherals=None):
""" Checks if specified target should run specific peripheral test case."""
if peripherals is not None: if peripherals is not None:
peripherals = set(peripherals) peripherals = set(peripherals)
@ -114,7 +122,7 @@ class SingleTestRunner():
return False return False
def run_host_test(self, name, target_name, disk, port, def run_host_test(self, name, target_name, disk, port,
duration, extra_serial, verbose=True): duration, extra_serial, verbose=False):
""" """
Functions resets target and grabs by timeouted pooling test log Functions resets target and grabs by timeouted pooling test log
via serial port. via serial port.
@ -151,10 +159,14 @@ class SingleTestRunner():
# Parse test 'output' data # Parse test 'output' data
result = "UNDEF" result = "UNDEF"
for line in output.splitlines(): for line in output.splitlines():
if '{success}' in line: result = "OK" if '{success}' in line:
if '{failure}' in line: result = "FAIL" result = "OK"
if '{error}' in line: result = "ERROR" if '{failure}' in line:
if '{end}' in line: break result = "FAIL"
if '{error}' in line:
result = "ERROR"
if '{end}' in line:
break
return result return result
def print_test_result(self, test_result, target_name, toolchain_name, def print_test_result(self, test_result, target_name, toolchain_name,
@ -246,25 +258,54 @@ def shape_test_request(mcu, image_path, test_id, duration=10):
if __name__ == '__main__': if __name__ == '__main__':
start = time() # Command line options
single_test = SingleTestRunner() parser = optparse.OptionParser()
parser.add_option('-i', '--tests',
dest='test_spec_filename',
metavar="FILE",
help='Points to file with test specification')
parser.add_option('-s', '--suppress-summary',
dest='suppress_summary',
default=False,
action="store_true",
help='Suppresses display of wellformatted table with test results')
parser.add_option('-v', '--verbose',
dest='verbose',
default=False,
action="store_true",
help='Verbose mode (pronts some extra information)')
parser.epilog="Example: singletest.py -i test_spec.json"
(opts, args) = parser.parse_args()
# Below list tells script which targets and their toolchain(s) # Below list tells script which targets and their toolchain(s)
# should be covered by the test scenario # should be covered by the test scenario
test_spec = { test_spec = None
"targets": {
# "KL25Z": ["ARM", "GCC_ARM"], # Open file with test specification
# "LPC1768": ["ARM", "GCC_ARM", "GCC_CR", "GCC_CS", "IAR"], if opts.test_spec_filename:
# "LPC11U24": ["uARM"] try:
# "UBLOX_C027": ["IAR"] with open(opts.test_spec_filename) as data_file:
# "NRF51822": ["ARM"] try:
# "NUCLEO_F103RB": ["ARM"], test_spec = json.load(data_file)
# "LPC2368": ["ARM"], except ValueError as json_error_msg:
# "LPC812": ["uARM"], test_spec = None
# "LPC1549": ["uARM"] print "Error: %s" % (json_error_msg)
"LPC4088": ["ARM"] # , "GCC_CR", "GCC_ARM" except IOError as fileopen_error_msg:
} print "Error: %s" % (fileopen_error_msg)
} if opts.verbose and test_spec:
pp = pprint.PrettyPrinter(indent=4)
pp.pprint(test_spec)
if test_spec is None:
parser.print_help()
exit(-1)
# Magic happens here... ;)
start = time()
single_test = SingleTestRunner()
clean = test_spec.get('clean', False) clean = test_spec.get('clean', False)
test_ids = test_spec.get('test_ids', []) test_ids = test_spec.get('test_ids', [])
@ -287,7 +328,8 @@ if __name__ == '__main__':
if test.automated and test.is_supported(target, toolchain): if test.automated and test.is_supported(target, toolchain):
if not single_test.is_peripherals_available(target, test.peripherals): if not single_test.is_peripherals_available(target, test.peripherals):
print "TargetTest::%s::TestSkipped(%s)" % (target, ",".join(test.peripherals)) if opts.verbose:
print "TargetTest::%s::TestSkipped(%s)" % (target, ",".join(test.peripherals))
continue continue
test_result = { test_result = {
@ -296,7 +338,7 @@ if __name__ == '__main__':
'test_id': test_id, 'test_id': test_id,
} }
path = build_project(test.source_dir, join(build_dir, test_id), T, toolchain, test.dependencies, clean=clean, verbose=False) path = build_project(test.source_dir, join(build_dir, test_id), T, toolchain, test.dependencies, clean=clean, verbose=opts.verbose)
if target.startswith('NRF51822'): # Nordic: if target.startswith('NRF51822'): # Nordic:
#Convert bin to Hex and Program nrf chip via jlink #Convert bin to Hex and Program nrf chip via jlink
@ -314,19 +356,21 @@ if __name__ == '__main__':
elapsed_time = time() - start elapsed_time = time() - start
print # Human readable summary
print "Test summary:" if not opts.suppress_summary:
# Pretty table package is used to print results print
pt = PrettyTable(["Result", "Target", "Toolchain", "Test ID", "Test Description", print "Test summary:"
"Elapsed Time (sec)", "Timeout (sec)"]) # Pretty table package is used to print results
pt.align["Result"] = "l" # Left align pt = PrettyTable(["Result", "Target", "Toolchain", "Test ID", "Test Description",
pt.align["Target"] = "l" # Left align "Elapsed Time (sec)", "Timeout (sec)"])
pt.align["Toolchain"] = "l" # Left align pt.align["Result"] = "l" # Left align
pt.align["Test ID"] = "l" # Left align pt.align["Target"] = "l" # Left align
pt.align["Test Description"] = "l" # Left align pt.align["Toolchain"] = "l" # Left align
pt.padding_width = 1 # One space between column edges and contents (default) pt.align["Test ID"] = "l" # Left align
pt.align["Test Description"] = "l" # Left align
pt.padding_width = 1 # One space between column edges and contents (default)
for test in test_summary: for test in test_summary:
pt.add_row(test) pt.add_row(test)
print pt print pt
print "Completed in %d sec" % (time() - start) print "Completed in %d sec" % (time() - start)