Go to file
mjrgh 094d9ac909 Fix crash with events in the past
ticker_insert_event() can crash on KLXX (and probably other platforms) if an event is inserted with a timestamp before the current real time.  

The problem is easy to trigger:  you just need to set up a Ticker object, and then disable interrupts for slightly longer than the Ticker object's interval.  It's generally bad practice to disable interrupts for too long, but there are some cases where it's unavoidable, and anyway it would be better for the core library function not to crash.  The case where I had an unavoidably long interrupts-off interval was writing flash with the FTFA.  The FTFA hardware prohibits flash reads while an FTFA command is in progress, so interrupts must be disabled for the whole duration of each command to ensure that there are no instruction fetches from flash-resident ISRs in the course of the execution.  An FTFA "erase sector" command takes a fairly long time (milliseconds), and I have a fairly high frequency Ticker (1ms).

The problem and the fix are pretty straightforward.  ticker_insert_event() searches the linked list to figure out where to insert the new event, looking for a spot earlier than any event currently queued.  If the event is in the past, it'll usually end up at the head of the list.  When the routine sees that the new event belongs at the head of the list, it calls data->interface->set_interrupt() to schedule the interrupt for the event, since it's the new soonest event.  The KLXX version of us_ticker_set_interrupt() then looks to see if the event is in the past, which we've stipulated that it is, so rather than actually setting the interrupt, it simply calls the handler directly.  The first thing the Ticker interrupt handler does is re-schedule itself, so we re-enter ticker_insert_event() at this point.  This is where the problem comes in:  we didn't finish updating the linked list before we called set_interrupt() and thus before we recursed back into ticker_insert_event().  We set the head of the list to the new event but we didn't set the new event's 'next' pointer.

The fix is simply to finish updating the list before we call set_interrupt(), which we can do by moving the obj->next initialization ahead of the head pointer update.
2017-03-21 12:02:33 -07:00
.github Update pull_request_template.md 2016-09-08 12:05:47 +03:00
TESTS Renamed files in platform to match source names 2017-02-22 18:17:54 -06:00
cmsis uVisor: Update to version 0.27.0 2017-02-21 13:24:23 +00:00
drivers Merge pull request #3827 from betzw/betzw_wb_i2c 2017-03-14 14:33:42 +00:00
events Merge pull request #3782 from geky/events-callback-inference 2017-02-21 10:53:14 -06:00
features Merge pull request #3691 from adustm/STM_aes_f439zi 2017-03-14 14:32:25 +00:00
hal Fix crash with events in the past 2017-03-21 12:02:33 -07:00
platform Fixed size_t issue for mbed 2 builds 2017-03-10 11:04:05 -06:00
rtos Merge pull request #3862 from c1728p9/thread_start_assert 2017-03-14 14:36:39 +00:00
targets Merge pull request #3927 from TsungtaWu/master 2017-03-14 14:48:23 +00:00
tools Merge pull request #3931 from c1728p9/arm_pack_manager_improvements 2017-03-14 14:47:35 +00:00
.gitattributes Added .gitattributes for automatic LF line ending conversion 2013-08-08 13:19:34 +03:00
.gitignore Ignore .vscode folder 2017-01-11 20:48:05 +02:00
.pylintrc Add pylint configuration file 2016-08-16 11:48:45 -05:00
.travis.yml Enforce device_name is valid in targets.json 2017-02-08 14:54:26 -06:00
CONTRIBUTING.md Update CONTRIBUTING.md 2016-09-11 21:24:11 +08:00
DOXYGEN_FRONTPAGE.md Very minimal text 2016-08-04 14:09:59 +01:00
Jenkinsfile Update Jenkinsfile 2016-09-20 16:05:59 +03:00
LICENSE Add Apache v2 LICENSE file 2013-08-06 12:05:04 +01:00
README.md README: Minor interpunction fix 2017-01-19 16:06:08 +00:00
mbed.h Filesystem: Integrate filesystem classes with common mbed.h entry point 2017-02-24 11:56:45 -06:00
requirements.txt Remove pycurl dependency 2016-10-20 16:24:47 -05:00

README.md

ARM mbed OS

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.

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.

Current release

The current release, along with a selection of previous versions are detailed here: Release Notes

Getting Started for Developers

Please note that you will require mbed CLI to build mbed OS. For more details, please read the getting started guide for developers using mbed OS in applications:

Getting Started for Contributors

We have a getting started guide for contributors working on mbed OS:

  • Have a look in the docs directory