Skip to content

Commit dc60713

Browse files
committed
Merge branch 'master' of github.com:ARMmbed/mbed-os
2 parents 7e7903e + 0a3b256 commit dc60713

File tree

5,008 files changed

+885337
-449295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,008 files changed

+885337
-449295
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,5 @@ cscope.*
7575
*.swp
7676
*~
7777

78+
# Visual Studio Code
79+
.vscode/

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ script:
55
- make -C events/equeue test clean
66
- PYTHONPATH=. python tools/test/config_test/config_test.py
77
- PYTHONPATH=. python tools/test/build_api/build_api_test.py
8+
- PYTHONPATH=. python tools/test/targets/target_test.py
89
- python tools/test/pylint.py
910
- py.test tools/test/toolchains/api.py
1011
- python tools/test/memap/memap_test.py

README.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
# ARM mbed OS
22

3-
mbed OS is an open-source embedded operating system designed specifically for the "things" in the Internet of Things (IoT). It includes all the features you need to develop a connected product based on an ARM Cortex-M microcontroller.
3+
mbed OS is an open-source embedded operating system designed for the "things" in the Internet of Things (IoT). mbed OS includes the features you need to develop a connected product using an ARM Cortex-M microcontroller.
44

5-
mbed OS accelerates the process of creating a connected product by providing a platform operating system that includes robust security foundations, standards based communication capabilities, built-in cloud management services, and drivers for sensors, I/O devices and connectivity. mbed OS is built as a modular, configurable software stack so that you can readily customize it to the device you're developing for, and reduce memory requirements by excluding unnecessary software components.
5+
mbed OS provides a platform that includes:
6+
- Security foundations.
7+
- Cloud management services.
8+
- Drivers for sensors, I/O devices and connectivity.
9+
10+
mbed OS is modular, configurable software that you can customize it to your device and to reduce memory requirements by excluding unused software.
11+
612

7-
## Current release
13+
## Release Notes
14+
15+
The [Release Notes](https://docs.mbed.com/docs/mbed-os-release-notes/en/latest/) detail the current release and previous versions.
16+
17+
## Continuous Integration Status
818

9-
The current release, along with a selection of previous versions are detailed here:
10-
[Release Notes](https://docs.mbed.com/docs/mbed-os-release-notes/en/latest/)
19+
We run continuous integration on all of our branches and pull requests to verify the stability of mbed OS. The following are the Travis CI indicators for mbed OS.
20+
21+
- Master branch [![Master Branch CI Badge](https://travis-ci.org/ARMmbed/mbed-os.svg?branch=master)](https://travis-ci.org/ARMmbed/mbed-os)
22+
- Latest release [![Latest Tag CI Badge](https://travis-ci.org/ARMmbed/mbed-os.svg?branch=latest)](https://travis-ci.org/ARMmbed/mbed-os/branches)
1123

1224
## Getting Started for Developers
1325

14-
We have a getting started guide for developers using mbed OS in applications:
15-
16-
- [Getting Started](https://docs.mbed.com/docs/mbed-os-handbook/en/5.2/)
26+
You need [mbed CLI](https://github.com/ARMmbed/mbed-cli) to build mbed OS. For more details, read the [mbed OS Handbook](https://docs.mbed.com/docs/mbed-os-handbook/en/latest/).
1727

1828
## Getting Started for Contributors
1929

20-
We have a getting started guide for contributors working on mbed OS:
21-
22-
- Have a look in the docs directory
30+
We have a [Contributing and Publishing Guide](https://docs.mbed.com/docs/mbed-os-handbook/en/latest/cont/contributing/) in the mbed OS Handbook.

TESTS/events/queue/main.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ SIMPLE_POSTS_TEST(0)
7070

7171

7272
void time_func(Timer *t, int ms) {
73-
TEST_ASSERT_INT_WITHIN(2, ms, t->read_ms());
73+
TEST_ASSERT_INT_WITHIN(5, ms, t->read_ms());
7474
t->reset();
7575
}
7676

@@ -210,7 +210,7 @@ void event_class_helper_test() {
210210

211211
void event_inference_test() {
212212
counter = 0;
213-
EventQueue queue (2048);
213+
EventQueue queue(2048);
214214

215215
queue.event(count5, 1, 1, 1, 1, 1).post();
216216
queue.event(count5, 1, 1, 1, 1).post(1);
@@ -219,9 +219,16 @@ void event_inference_test() {
219219
queue.event(count5, 1).post(1, 1, 1, 1);
220220
queue.event(count5).post(1, 1, 1, 1, 1);
221221

222+
queue.event(callback(count5), 1, 1, 1, 1, 1).post();
223+
queue.event(callback(count5), 1, 1, 1, 1).post(1);
224+
queue.event(callback(count5), 1, 1, 1).post(1, 1);
225+
queue.event(callback(count5), 1, 1).post(1, 1, 1);
226+
queue.event(callback(count5), 1).post(1, 1, 1, 1);
227+
queue.event(callback(count5)).post(1, 1, 1, 1, 1);
228+
222229
queue.dispatch(0);
223230

224-
TEST_ASSERT_EQUAL(counter, 30);
231+
TEST_ASSERT_EQUAL(counter, 60);
225232
}
226233

227234

TESTS/events/timing/main.cpp

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#include "mbed_events.h"
2+
#include "mbed.h"
3+
#include "rtos.h"
4+
#include "greentea-client/test_env.h"
5+
#include "unity.h"
6+
#include "utest.h"
7+
#include <cstdlib>
8+
#include <cmath>
9+
10+
using namespace utest::v1;
11+
12+
13+
// Test delay
14+
#ifndef TEST_EVENTS_TIMING_TIME
15+
#define TEST_EVENTS_TIMING_TIME 20000
16+
#endif
17+
18+
#ifndef TEST_EVENTS_TIMING_MEAN
19+
#define TEST_EVENTS_TIMING_MEAN 25
20+
#endif
21+
22+
#ifndef M_PI
23+
#define M_PI 3.14159265358979323846264338327950288
24+
#endif
25+
26+
// Random number generation to skew timing values
27+
float gauss(float mu, float sigma) {
28+
float x = (float)rand() / ((float)RAND_MAX+1);
29+
float y = (float)rand() / ((float)RAND_MAX+1);
30+
float x2pi = x*2.0*M_PI;
31+
float g2rad = sqrt(-2.0 * log(1.0-y));
32+
float z = cos(x2pi) * g2rad;
33+
return mu + z*sigma;
34+
}
35+
36+
float chisq(float sigma) {
37+
return pow(gauss(0, sqrt(sigma)), 2);
38+
}
39+
40+
41+
Timer timer;
42+
DigitalOut led(LED1);
43+
44+
equeue_sema_t sema;
45+
46+
// Timer timing test
47+
void timer_timing_test() {
48+
timer.reset();
49+
timer.start();
50+
int prev = timer.read_us();
51+
52+
while (prev < TEST_EVENTS_TIMING_TIME*1000) {
53+
int next = timer.read_us();
54+
if (next < prev) {
55+
printf("backwards drift %d -> %d (%08x -> %08x)\r\n",
56+
prev, next, prev, next);
57+
}
58+
TEST_ASSERT(next >= prev);
59+
prev = next;
60+
}
61+
}
62+
63+
// equeue tick timing test
64+
void tick_timing_test() {
65+
unsigned start = equeue_tick();
66+
int prev = 0;
67+
68+
while (prev < TEST_EVENTS_TIMING_TIME) {
69+
int next = equeue_tick() - start;
70+
if (next < prev) {
71+
printf("backwards drift %d -> %d (%08x -> %08x)\r\n",
72+
prev, next, prev, next);
73+
}
74+
TEST_ASSERT(next >= prev);
75+
prev = next;
76+
}
77+
}
78+
79+
// equeue semaphore timing test
80+
void semaphore_timing_test() {
81+
srand(0);
82+
timer.reset();
83+
timer.start();
84+
85+
int err = equeue_sema_create(&sema);
86+
TEST_ASSERT_EQUAL(0, err);
87+
88+
while (timer.read_ms() < TEST_EVENTS_TIMING_TIME) {
89+
int delay = chisq(TEST_EVENTS_TIMING_MEAN);
90+
91+
int start = timer.read_us();
92+
equeue_sema_wait(&sema, delay);
93+
int taken = timer.read_us() - start;
94+
95+
printf("delay %dms => error %dus\r\n", delay, abs(1000*delay - taken));
96+
TEST_ASSERT_INT_WITHIN(5000, taken, delay * 1000);
97+
98+
led = !led;
99+
}
100+
101+
equeue_sema_destroy(&sema);
102+
}
103+
104+
105+
// Test setup
106+
utest::v1::status_t test_setup(const size_t number_of_cases) {
107+
GREENTEA_SETUP((number_of_cases+1)*TEST_EVENTS_TIMING_TIME/1000, "default_auto");
108+
return verbose_test_setup_handler(number_of_cases);
109+
}
110+
111+
const Case cases[] = {
112+
Case("Testing accuracy of timer", timer_timing_test),
113+
Case("Testing accuracy of equeue tick", tick_timing_test),
114+
Case("Testing accuracy of equeue semaphore", semaphore_timing_test),
115+
};
116+
117+
Specification specification(test_setup, cases);
118+
119+
int main() {
120+
return !Harness::run(specification);
121+
}
122+

TESTS/mbed_drivers/flashiap/main.cpp

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
2+
/* mbed Microcontroller Library
3+
* Copyright (c) 2017 ARM Limited
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#if !DEVICE_FLASH
19+
#error [NOT_SUPPORTED] Flash API not supported for this target
20+
#endif
21+
22+
#include "utest/utest.h"
23+
#include "unity/unity.h"
24+
#include "greentea-client/test_env.h"
25+
26+
#include "mbed.h"
27+
28+
using namespace utest::v1;
29+
30+
void flashiap_init_test()
31+
{
32+
FlashIAP flash_device;
33+
uint32_t ret = flash_device.init();
34+
TEST_ASSERT_EQUAL_INT32(0, ret);
35+
ret = flash_device.deinit();
36+
TEST_ASSERT_EQUAL_INT32(0, ret);
37+
}
38+
39+
void flashiap_program_test()
40+
{
41+
FlashIAP flash_device;
42+
uint32_t ret = flash_device.init();
43+
TEST_ASSERT_EQUAL_INT32(0, ret);
44+
45+
// get the last sector size (flash size - 1)
46+
uint32_t sector_size = flash_device.get_sector_size(flash_device.get_flash_start() + flash_device.get_flash_size() - 1UL);
47+
uint32_t page_size = flash_device.get_page_size();
48+
TEST_ASSERT_NOT_EQUAL(0, sector_size);
49+
TEST_ASSERT_NOT_EQUAL(0, page_size);
50+
TEST_ASSERT_TRUE(sector_size % page_size == 0);
51+
const uint8_t test_value = 0xCE;
52+
uint8_t *data = new uint8_t[page_size];
53+
for (uint32_t i = 0; i < page_size; i++) {
54+
data[i] = test_value;
55+
}
56+
57+
// the one before the last sector in the system
58+
uint32_t address = (flash_device.get_flash_start() + flash_device.get_flash_size()) - (sector_size);
59+
TEST_ASSERT_TRUE(address != 0UL);
60+
ret = flash_device.erase(address, sector_size);
61+
TEST_ASSERT_EQUAL_INT32(0, ret);
62+
63+
64+
for (uint32_t i = 0; i < sector_size / page_size; i++) {
65+
uint32_t page_addr = address + i * page_size;
66+
ret = flash_device.program(data, page_addr, page_size);
67+
TEST_ASSERT_EQUAL_INT32(0, ret);
68+
}
69+
70+
uint8_t *data_flashed = new uint8_t[page_size];
71+
for (uint32_t i = 0; i < sector_size / page_size; i++) {
72+
uint32_t page_addr = address + i * page_size;
73+
ret = flash_device.read(data_flashed, page_addr, page_size);
74+
TEST_ASSERT_EQUAL_INT32(0, ret);
75+
TEST_ASSERT_EQUAL_UINT8_ARRAY(data, data_flashed, page_size);
76+
}
77+
delete[] data;
78+
delete[] data_flashed;
79+
80+
ret = flash_device.deinit();
81+
TEST_ASSERT_EQUAL_INT32(0, ret);
82+
}
83+
84+
void flashiap_program_error_test()
85+
{
86+
FlashIAP flash_device;
87+
uint32_t ret = flash_device.init();
88+
TEST_ASSERT_EQUAL_INT32(0, ret);
89+
90+
// get the last sector size (flash size - 1)
91+
uint32_t sector_size = flash_device.get_sector_size(flash_device.get_flash_start() + flash_device.get_flash_size() - 1UL);
92+
uint32_t page_size = flash_device.get_page_size();
93+
TEST_ASSERT_NOT_EQUAL(0, sector_size);
94+
TEST_ASSERT_NOT_EQUAL(0, page_size);
95+
TEST_ASSERT_TRUE(sector_size % page_size == 0);
96+
const uint8_t test_value = 0xCE;
97+
uint8_t *data = new uint8_t[page_size];
98+
for (uint32_t i = 0; i < page_size; i++) {
99+
data[i] = test_value;
100+
}
101+
102+
// the one before the last page in the system
103+
uint32_t address = (flash_device.get_flash_start() + flash_device.get_flash_size()) - (sector_size);
104+
TEST_ASSERT_TRUE(address != 0UL);
105+
106+
// unaligned address
107+
ret = flash_device.erase(address + 1, sector_size);
108+
TEST_ASSERT_EQUAL_INT32(-1, ret);
109+
ret = flash_device.program(data, address + 1, page_size);
110+
TEST_ASSERT_EQUAL_INT32(-1, ret);
111+
112+
// unaligned page size
113+
ret = flash_device.program(data, address, page_size + 1);
114+
TEST_ASSERT_EQUAL_INT32(-1, ret);
115+
116+
delete[] data;
117+
118+
ret = flash_device.deinit();
119+
TEST_ASSERT_EQUAL_INT32(0, ret);
120+
}
121+
122+
Case cases[] = {
123+
Case("FlashIAP - init", flashiap_init_test),
124+
Case("FlashIAP - program", flashiap_program_test),
125+
Case("FlashIAP - program errors", flashiap_program_error_test),
126+
};
127+
128+
utest::v1::status_t greentea_test_setup(const size_t number_of_cases) {
129+
GREENTEA_SETUP(20, "default_auto");
130+
return greentea_test_setup_handler(number_of_cases);
131+
}
132+
133+
Specification specification(greentea_test_setup, cases, greentea_test_teardown_handler);
134+
135+
int main() {
136+
Harness::run(specification);
137+
}

TESTS/mbed_drivers/race_test/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#include "SingletonPtr.h"
2323
#include <stdio.h>
2424

25+
#ifndef MBED_RTOS_SINGLE_THREAD
26+
#error [NOT_SUPPORTED] test not supported for single threaded enviroment
27+
#endif
28+
2529
using namespace utest::v1;
2630

2731
#define TEST_STACK_SIZE 1024

0 commit comments

Comments
 (0)