From bda033dc8e9cf6b18e474124cce803f07119b865 Mon Sep 17 00:00:00 2001 From: Yihui Xiong Date: Thu, 28 Aug 2014 16:23:15 +0800 Subject: [PATCH 1/6] [nrf51822][gcc_arm][c++]: fix 'impossible constraint in asm' error, used by ble app --- .../s110_nrf51822_7.0.0_API/include/nrf_svc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_API/include/nrf_svc.h b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_API/include/nrf_svc.h index e75083ed86..5604b957a4 100644 --- a/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_API/include/nrf_svc.h +++ b/libraries/mbed/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_API/include/nrf_svc.h @@ -16,7 +16,7 @@ { \ __asm( \ "svc %0\n" \ - "bx r14" : : "I" (number) : "r0" \ + "bx r14" : : "I" ((uint32_t)number) : "r0" \ ); \ } #elif defined (__ICCARM__) From cb75014f092da19fdcb9977bc0698412b2c2cfbf Mon Sep 17 00:00:00 2001 From: Yihui Xiong Date: Thu, 28 Aug 2014 16:54:06 +0800 Subject: [PATCH 2/6] [nrf51822][gcc_arm]: fix softdevice path and srec_cat params of makefile templates --- workspace_tools/export/gcc_arm_arch_ble.tmpl | 8 ++++---- workspace_tools/export/gcc_arm_nrf51822.tmpl | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/workspace_tools/export/gcc_arm_arch_ble.tmpl b/workspace_tools/export/gcc_arm_arch_ble.tmpl index 9cf2053382..8487d82632 100644 --- a/workspace_tools/export/gcc_arm_arch_ble.tmpl +++ b/workspace_tools/export/gcc_arm_arch_ble.tmpl @@ -9,7 +9,7 @@ INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %} LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %} LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %} LINKER_SCRIPT = {{linker_script}} -SOFTDEVICE = mbed/TARGET_NRF51822/TARGET_NORDIC/TARGET_NRF51822/Lib/s110_nrf51822_6_0_0/s110_nrf51822_6.0.0_softdevice.hex +SOFTDEVICE = mbed/TARGET_ARCH_BLE/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_softdevice.hex ############################################################################### AS = $(GCC_BIN)arm-none-eabi-as @@ -23,7 +23,7 @@ CPU = -mcpu=cortex-m0 -mthumb CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -fno-exceptions -ffunction-sections -fdata-sections CC_SYMBOLS = {% for s in symbols %}-D{{s}} {% endfor %} -LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float +LD_FLAGS = -mcpu=cortex-m0 -mthumb -Wl,--gc-sections -Wl,--wrap=main --specs=nano.specs -u _printf_float -u _scanf_float LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys ifeq ($(DEBUG), 1) @@ -32,7 +32,7 @@ else CC_FLAGS += -DNDEBUG -Os endif -all: $(PROJECT).hex merge +all: $(PROJECT).hex clean: rm -f $(PROJECT).hex $(PROJECT).elf $(OBJECTS) @@ -54,4 +54,4 @@ $(PROJECT).hex: $(PROJECT).elf $(OBJCOPY) -O ihex $< $@ merge: - $(SREC_CAT) $(SOFTDEVICE) -intel $(PROJECT).hex -binary --offset 0x14000 -o combined.hex -intel --line-length=46 + $(SREC_CAT) $(SOFTDEVICE) -intel $(PROJECT).hex -intel -o combined.hex -intel --line-length=44 diff --git a/workspace_tools/export/gcc_arm_nrf51822.tmpl b/workspace_tools/export/gcc_arm_nrf51822.tmpl index 823298e9d1..ca491c401c 100644 --- a/workspace_tools/export/gcc_arm_nrf51822.tmpl +++ b/workspace_tools/export/gcc_arm_nrf51822.tmpl @@ -9,7 +9,7 @@ INCLUDE_PATHS = {% for p in include_paths %}-I{{p}} {% endfor %} LIBRARY_PATHS = {% for p in library_paths %}-L{{p}} {% endfor %} LIBRARIES = {% for lib in libraries %}-l{{lib}} {% endfor %} LINKER_SCRIPT = {{linker_script}} -SOFTDEVICE = mbed/TARGET_NRF51822/TARGET_NORDIC/TARGET_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_softdevice.hex +SOFTDEVICE = mbed/TARGET_NRF51822/TARGET_NORDIC/TARGET_MCU_NRF51822/Lib/s110_nrf51822_7_0_0/s110_nrf51822_7.0.0_softdevice.hex ############################################################################### AS = $(GCC_BIN)arm-none-eabi-as @@ -32,7 +32,7 @@ else CC_FLAGS += -DNDEBUG -Os endif -all: $(PROJECT).hex merge +all: $(PROJECT).hex clean: rm -f $(PROJECT).hex $(PROJECT).elf $(OBJECTS) @@ -54,4 +54,4 @@ $(PROJECT).hex: $(PROJECT).elf $(OBJCOPY) -O ihex $< $@ merge: - $(SREC_CAT) $(SOFTDEVICE) -intel $(PROJECT).hex -intel --offset 0x16000 -o combined.hex -intel --line-length=46 + $(SREC_CAT) $(SOFTDEVICE) -intel $(PROJECT).hex -intel -o combined.hex -intel --line-length=44 From 61b1d75032ce453acbeacbb06b860414778106f6 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 3 Sep 2014 14:27:53 +0100 Subject: [PATCH 3/6] Added dynamic test printing --- workspace_tools/host_tests/echo.py | 6 +++++- workspace_tools/host_tests/stdio_auto.py | 6 +++++- workspace_tools/test_api.py | 14 ++++++-------- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/workspace_tools/host_tests/echo.py b/workspace_tools/host_tests/echo.py index d0dd06e8e4..534807e44a 100644 --- a/workspace_tools/host_tests/echo.py +++ b/workspace_tools/host_tests/echo.py @@ -26,7 +26,11 @@ class EchoTest(Test): def test(self): # Let's wait for Mbed to print its readiness, usually "{{start}}" - c = self.mbed.serial_read(16) + if self.mbed.serial_timeout(None) is None: + self.print_result("ioerr_serial") + return + + c = self.mbed.serial_read(len('{{start}}')) if c is None: self.print_result("ioerr_serial") return diff --git a/workspace_tools/host_tests/stdio_auto.py b/workspace_tools/host_tests/stdio_auto.py index 05f95e2ff1..3b49d7d126 100644 --- a/workspace_tools/host_tests/stdio_auto.py +++ b/workspace_tools/host_tests/stdio_auto.py @@ -29,7 +29,11 @@ class StdioTest(DefaultTest): test_result = True # Let's wait for Mbed to print its readiness, usually "{{start}}" - c = self.mbed.serial_read(16) + if self.mbed.serial_timeout(None) is None: + self.print_result("ioerr_serial") + return + + c = self.mbed.serial_read(len('{{start}}')) if c is None: self.print_result("ioerr_serial") return diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index 80ef80fd41..6f46d00fa8 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -799,6 +799,7 @@ class SingleTestRunner(object): if verbose: print "Executing '" + " ".join(cmd) + "'" + print "Test::Output::Start" proc = Popen(cmd, stdout=PIPE, cwd=HOST_TESTS) obs = ProcessObserver(proc) @@ -813,7 +814,8 @@ class SingleTestRunner(object): if c: output.append(c) - sys.stdout.write(c) + if verbose: + sys.stdout.write(c) # Give the mbed under test a way to communicate the end of the test if c in ['\n', '\r']: if '{end}' in line: @@ -829,16 +831,12 @@ class SingleTestRunner(object): if c: output.append(c) - sys.stdout.write(c) + if verbose: + sys.stdout.write(c) + print "Test::Output::Finish" # Stop test process obs.stop() - # Handle verbose mode - if verbose: - print "Test::Output::Start" - print "".join(output) - print "Test::Output::Finish" - # Parse test 'output' data result = self.TEST_RESULT_TIMEOUT for line in "".join(output).splitlines(): From 2df3125ca4c7a9b3b62176c862c5ba03e6030e72 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Wed, 3 Sep 2014 15:01:19 +0100 Subject: [PATCH 4/6] Fixed missing STDOUT in Echo test Fixed missing opening and closing brackets in {{start}} --- libraries/tests/mbed/echo/main.cpp | 4 +++- workspace_tools/host_tests/echo.py | 9 ++++++++- workspace_tools/host_tests/stdio_auto.py | 8 +++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libraries/tests/mbed/echo/main.cpp b/libraries/tests/mbed/echo/main.cpp index ddb25cd406..ead626ac13 100644 --- a/libraries/tests/mbed/echo/main.cpp +++ b/libraries/tests/mbed/echo/main.cpp @@ -22,11 +22,13 @@ int main() { Serial pc(TXPIN, RXPIN); pc.baud(115200); + + pc.puts("{{"); pc.puts(TEST_ENV_START); // Host test is expecting preamble + pc.puts("}}"); while (1) { pc.gets(buf, 256); - pc.printf("%s", buf); } } diff --git a/workspace_tools/host_tests/echo.py b/workspace_tools/host_tests/echo.py index 534807e44a..6771653cd6 100644 --- a/workspace_tools/host_tests/echo.py +++ b/workspace_tools/host_tests/echo.py @@ -15,6 +15,7 @@ See the License for the specific language governing permissions and limitations under the License. """ import uuid +from sys import stdout from host_test import Test @@ -28,12 +29,18 @@ class EchoTest(Test): # Let's wait for Mbed to print its readiness, usually "{{start}}" if self.mbed.serial_timeout(None) is None: self.print_result("ioerr_serial") - return + return c = self.mbed.serial_read(len('{{start}}')) if c is None: self.print_result("ioerr_serial") return + print c + stdout.flush() + + if self.mbed.serial_timeout(1) is None: + self.print_result("ioerr_serial") + return self.mbed.flush() self.notify("Starting the ECHO test") diff --git a/workspace_tools/host_tests/stdio_auto.py b/workspace_tools/host_tests/stdio_auto.py index 3b49d7d126..55e026ddea 100644 --- a/workspace_tools/host_tests/stdio_auto.py +++ b/workspace_tools/host_tests/stdio_auto.py @@ -37,6 +37,12 @@ class StdioTest(DefaultTest): if c is None: self.print_result("ioerr_serial") return + print c + stdout.flush() + + if self.mbed.serial_timeout(1) is None: + self.print_result("ioerr_serial") + return for i in range(1, 5): random_integer = random.randint(-99999, 99999) @@ -64,7 +70,7 @@ class StdioTest(DefaultTest): stdout.flush() break else: - print "Error: No IP and port information sent from server" + print "Error: No data from MUT sent" self.print_result('error') exit(-2) From c12b5de37b1561b3fa80cf69216cb5961ff9c2e2 Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Thu, 4 Sep 2014 10:10:55 +0100 Subject: [PATCH 5/6] Fixed NET_(4,6,13) client tests so after reset we wait for device to send print it's ready Fixed small print issue with -V option --- .../tests/net/echo/tcp_client_loop/main.cpp | 4 +++- .../tests/net/helloworld/udpclient/main.cpp | 8 +++++--- .../host_tests/tcpecho_client_auto.py | 19 +++++++++++++++++++ .../host_tests/udpecho_client_auto.py | 17 +++++++++++++++++ workspace_tools/test_api.py | 4 +++- workspace_tools/tests.py | 2 +- 6 files changed, 48 insertions(+), 6 deletions(-) diff --git a/libraries/tests/net/echo/tcp_client_loop/main.cpp b/libraries/tests/net/echo/tcp_client_loop/main.cpp index 46f613237f..39ea62ee4c 100644 --- a/libraries/tests/net/echo/tcp_client_loop/main.cpp +++ b/libraries/tests/net/echo/tcp_client_loop/main.cpp @@ -1,4 +1,5 @@ #include "mbed.h" +#include "test_env.h" #include "EthernetInterface.h" struct s_ip_address @@ -11,6 +12,7 @@ struct s_ip_address #define MAX_ECHO_LOOPS 100 + int main() { char buffer[256] = {0}; char out_buffer[] = "Hello World\n"; @@ -36,7 +38,7 @@ int main() { wait(1); } - // Test loop for multiple client conenctions + // Test loop for multiple client connections bool result = true; int count_error = 0; for (int i = 0; i < MAX_ECHO_LOOPS; i++) { diff --git a/libraries/tests/net/helloworld/udpclient/main.cpp b/libraries/tests/net/helloworld/udpclient/main.cpp index 0cc446d31e..843d906ca2 100644 --- a/libraries/tests/net/helloworld/udpclient/main.cpp +++ b/libraries/tests/net/helloworld/udpclient/main.cpp @@ -5,8 +5,10 @@ namespace { const char *HTTP_SERVER_NAME = "utcnist.colorado.edu"; const int HTTP_SERVER_PORT = 37; + const float YEARS_TO_PASS = 114.0; } + int main() { bool result = false; EthernetInterface eth; @@ -30,14 +32,14 @@ int main() { const int n = sock.receiveFrom(nist, in_buffer_tab, sizeof(in_buffer_tab)); if (n > 0) { + result = true; const unsigned int timeRes = ntohl(in_buffer_uint); const float years = timeRes / 60.0 / 60.0 / 24.0 / 365; printf("UDP: Received %d bytes from server %s on port %d\r\n", n, nist.get_address(), nist.get_port()); printf("UDP: %u seconds since 01/01/1900 00:00 GMT ... %s\r\n", timeRes, timeRes > 0 ? "[OK]" : "[FAIL]"); - printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > 114.0 ? "[OK]" : "[FAIL]"); - result = true; + printf("UDP: %.2f years since 01/01/1900 00:00 GMT ... %s\r\n", years, timeRes > YEARS_TO_PASS ? "[OK]" : "[FAIL]"); - if (years < 114.0) { + if (years < YEARS_TO_PASS) { result = false; } } diff --git a/workspace_tools/host_tests/tcpecho_client_auto.py b/workspace_tools/host_tests/tcpecho_client_auto.py index 1d8b6b0f82..7dd89b5bde 100644 --- a/workspace_tools/host_tests/tcpecho_client_auto.py +++ b/workspace_tools/host_tests/tcpecho_client_auto.py @@ -19,6 +19,7 @@ from SocketServer import BaseRequestHandler, TCPServer import socket from host_test import Test from sys import stdout +from time import sleep SERVER_IP = str(socket.gethostbyname(socket.getfqdn())) SERVER_PORT = 7 @@ -31,7 +32,25 @@ class TCPEchoClientTest(Test): def send_server_ip_port(self, ip_address, port_no): print "Resetting target..." self.mbed.reset() + + # Let's wait for Mbed to print its readiness, usually "{{start}}" + if self.mbed.serial_timeout(None) is None: + self.print_result("ioerr_serial") + return + + c = self.mbed.serial_read(len('TCPCllient waiting for server IP and port...')) + if c is None: + self.print_result("ioerr_serial") + return + print c + stdout.flush() + + if self.mbed.serial_timeout(1) is None: + self.print_result("ioerr_serial") + return + print "Sending server IP Address to target..." + stdout.flush() connection_str = ip_address + ":" + str(port_no) + "\n" self.mbed.serial_write(connection_str) diff --git a/workspace_tools/host_tests/udpecho_client_auto.py b/workspace_tools/host_tests/udpecho_client_auto.py index 9d65bac3a8..906537d6a3 100644 --- a/workspace_tools/host_tests/udpecho_client_auto.py +++ b/workspace_tools/host_tests/udpecho_client_auto.py @@ -30,6 +30,23 @@ class UDPEchoClientTest(Test): def send_server_ip_port(self, ip_address, port_no): print "Resetting target..." self.mbed.reset() + + # Let's wait for Mbed to print its readiness, usually "{{start}}" + if self.mbed.serial_timeout(None) is None: + self.print_result("ioerr_serial") + return + + c = self.mbed.serial_read(len('UDPCllient waiting for server IP and port...')) + if c is None: + self.print_result("ioerr_serial") + return + print c + stdout.flush() + + if self.mbed.serial_timeout(1) is None: + self.print_result("ioerr_serial") + return + print "Sending server IP Address to target..." connection_str = ip_address + ":" + str(port_no) + "\n" self.mbed.serial_write(connection_str) diff --git a/workspace_tools/test_api.py b/workspace_tools/test_api.py index 6f46d00fa8..054c1bea23 100644 --- a/workspace_tools/test_api.py +++ b/workspace_tools/test_api.py @@ -833,7 +833,9 @@ class SingleTestRunner(object): output.append(c) if verbose: sys.stdout.write(c) - print "Test::Output::Finish" + + if verbose: + print "Test::Output::Finish" # Stop test process obs.stop() diff --git a/workspace_tools/tests.py b/workspace_tools/tests.py index 7a7f18f112..53e2976619 100644 --- a/workspace_tools/tests.py +++ b/workspace_tools/tests.py @@ -727,7 +727,7 @@ TESTS = [ { "id": "NET_13", "description": "TCP client echo loop", "source_dir": join(TEST_DIR, "net", "echo", "tcp_client_loop"), - "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY], + "dependencies": [MBED_LIBRARIES, RTOS_LIBRARIES, ETH_LIBRARY, TEST_MBED_LIB], "automated": True, "duration": 15, "host_test": "tcpecho_client_auto", From beed8358f922753d06eb7fd5d79ef75c3c50da0f Mon Sep 17 00:00:00 2001 From: Przemek Wirkus Date: Thu, 4 Sep 2014 15:30:08 +0100 Subject: [PATCH 6/6] Improvements to RTC's host_test test case --- workspace_tools/host_tests/hello_auto.py | 1 + workspace_tools/host_tests/rtc_auto.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/workspace_tools/host_tests/hello_auto.py b/workspace_tools/host_tests/hello_auto.py index 5b4149a942..8361eb560d 100644 --- a/workspace_tools/host_tests/hello_auto.py +++ b/workspace_tools/host_tests/hello_auto.py @@ -28,6 +28,7 @@ class HelloTest(DefaultTest): self.print_result("ioerr_serial") return print "Read %d bytes"% len(c) + print c stdout.flush() result = True # Because we can have targetID here let's try to decode diff --git a/workspace_tools/host_tests/rtc_auto.py b/workspace_tools/host_tests/rtc_auto.py index be2514c86c..86cabc8282 100644 --- a/workspace_tools/host_tests/rtc_auto.py +++ b/workspace_tools/host_tests/rtc_auto.py @@ -44,6 +44,9 @@ class RTCTest(DefaultTest): result_msg = "OK" if (time_str == correct_time_str) else "FAIL" print "Got RTC time: " + c[:-1] + " ... " + result_msg stdout.flush() + else: + test_result = False + break if test_result: # All numbers are the same self.print_result('success')