stmhal: Set entry point for ELF binary debugging

When loading the ELF binary to the board with a debugger, the debugger
needs to know at which point to start executing the code. Currently the
entry point defaults to the start of the .text section.

Signed-off-by: Sven Wegener <sven.wegener@stealer.net>
Implement kwargs for builtin open() and _io.FileIO

This makes open() and _io.FileIO() more CPython compliant.
The mode kwarg is fully iplemented.
The encoding kwarg is allowed but not implemented; mainly to allow
the tests to specify encoding for CPython, see #874
Use mode/encoding kwargs in io and unicode tests

mode argument is used to assert it works
encoding argument is used to make sure CPython uses the correct encoding
as it does not automatically use utf-8
Merge pull request #922 from swegener/for-upstream

stmhal: Set entry point for ELF binary debugging
py: Make mp_const_empty_bytes globally available.
stmhal: Overhaul UART class to use read/write, and improve it.

UART object now uses a stream-like interface: read, readall, readline,
readinto, readchar, write, writechar.

Timeouts are configured when the UART object is initialised, using
timeout and timeout_char keyword args.

The object includes optional read buffering, using interrupts.  You can set
the buffer size dynamically using read_buf_len keyword arg.  A size of 0
disables buffering.
stmhal: Change cc3k.recv to only make 1 call to underlying recv().

Also make cc3k.send and cc3k.recv independent functions (not wrapped by
stream write/read).  Also make wiznet5k.recv more memory efficient.

This might address issue #920.
Add pyb.hard_reset, and make sys.exit() or raise SystemExit do a soft reset.
stmhal: Don't return SystemExit value from parse_compile_execute.

There is no need, since we don't (currently) use the value.
Fixed TIM2_CH1 definition.

TIM2_CH1_ETR is really bundling 2 functions to the same pin:
TIM2_CH1 (where its used as a channel)
TIM2_ETR (where iss used as an external trigger).

I fixed most of these a while back, but it looks like I missed this one.
stmhal: Add MMA_INT/PB2 to available pins on PYBV10.

This allows you to register ExtInt on the MMA interrupt pin.
py: Remove unused and unneeded SystemError exception.

It's purpose is for internal errors that are not catastrophic (ie not as
bad as RuntimeError).  Since we don't use it, we don't need it.
Add pydfu.py to the micropython tree. Use dfu_util bgy default

You can do:

make USE_PYDFU=1 deploy

to use pydfu.py
tools, pydfu: Some fixes to support Python 3.
py: Fix smallint modulo with negative arguments.

Addresses issue #927.
extmod: Add uheapq module.
py: Clean up edge cases of malloc/realloc/free.
py: Use MP_OBJ_NULL instead of NULL in a few places.
py: Add builtin memoryview object (mostly using array code).
py: Properly free string parse-node; add assertion to gc_free.