Commit Graph

6568 Commits (hacking-on-plane)

Author SHA1 Message Date
Daniel Thompson a960916b4f zephyr: Initial attempt at machine.Pin
The integration with Zephyr is fairly clean but requires us to use
two arguments to describe a pin:

  drv_name - Name to be sent to device_get_binding()
  pin      - Pin number within the port identified by drv_name

There is support for in/out pins and pull up/pull down but currently
there is no interrupt support.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-29 17:16:32 -07:00
Daniel Thompson a241931fff zephyr: Fix incremental build
Currently incremental build does not work because there is no
dependancy between zephyr.lnk and libmicropython.a . We fix
this is an rather brutal way by unconditionally forcing a
re-link.

Sorry!

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-29 17:16:21 -07:00
Daniel Thompson a83f1f6468 zephyr: Exploit "make outputexports"
This feature is not upstream yet but its very difficult to compile
micropython using the current build system (some board files include
targets that conflict with the micropython build.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-28 14:21:58 -07:00
Daniel Thompson 5697f83e22 zephyr: Implement utime module
This provides time and sleep together with the usual
ticks_us/_ms_diff and sleep_us/ms family.

We also provide access to Zephyr's high precision timer
as ticks_cycles (augmented by cycles_to_ns).

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-24 16:45:49 -07:00
Daniel Thompson 225189221e zephyr: Implement the help() function
The boot issue text mentions a help() function and encourages
the user to run it. It is very disconcerting to find that the
function does not exist...

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-24 16:45:49 -07:00
Daniel Thompson 6dacfe36be zephyr: Keep .config during a clean
Currently "make clean" clobbers the .config file, which may
contain user customization. For zephyr this is unexpected.
Normally config files are preserved during a clean and
only get removed during pristine or mrproper rules.

Fix this by making the zephyr half of the build system
responsible for tidying up the zephyr output directory.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-24 16:45:49 -07:00
Daniel Thompson 0a0426a20b zephyr: Allow NETWORKING and MBEDTLS to be disabled
Allow micropython to automatically disable features that
Zephyr has been configured not to support.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-24 16:45:49 -07:00
Daniel Thompson 57c0a77a98 zephyr: Improve the range of config targets
These targets are intended to allow zephyr to ship with a
rich set of config options in prj.conf but to allow these
options to be disabled to run on especially small systems
(such as qemu_cortex_m3). The use case ends up looking
something like:

    make initconfig
    $ZEPHYR_BASE/scripts/config \
        --file outdir/$BOARD/.config \
        --disable NETWORKING --disable MBEDTLS
    make oldconfig
    # Check config file if needed

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-24 19:46:54 +01:00
Daniel Thompson 1d20df0a65 zephyr: Add a .gitignore file
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-24 18:59:22 +01:00
Paul Sokolovsky ef0bf69d0b zephyr/Makefile: Automatically derive target-specific CFLAGS.
By tricking Zephyt arch Makefiles compute them for us (not just for
Zephyr). This make potentially break as Zephyr evolves.
2016-09-23 14:31:16 +03:00
Daniel Thompson 3f39068a08 zephyr: Switch sub-makes to use proper environment variables
Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-23 14:31:16 +03:00
Daniel Thompson 00a3b12f5f zephyr: Support extra make targets
The two variables, GENERIC_TARGETS and CONFIG_TARGETS come, respectively,
from the the lists shown during "make help" and "make kconfig-help".

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-23 14:31:16 +03:00
Daniel Thompson fc217133ad zephyr: Automatically derive ARCH
Currently to compile for anything that except ARCH=x86 we have to
provide ARCH via the environment or make arguments. We can do better
than that!

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-23 14:31:16 +03:00
Daniel Thompson db9f7d5266 zephyr: Use ?= for BOARD
The main zephyr build system allows BOARD to come from the environment
but the micropython pre-build does not. Fix this.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
2016-09-23 14:31:16 +03:00
Paul Sokolovsky a20f4f96c7 zephyr: Switch to build against Zephyr 1.6.0 by default. 2016-09-23 14:31:16 +03:00
Paul Sokolovsky 4683f05240 zephyr/prj.conf: Bump number of RX/TX buffers.
TLS generates a lot, plus there're leaks.
2016-09-23 14:31:16 +03:00
Paul Sokolovsky 0867a52177 zephyr/main: Execute main.py frozen module on boot, if available. 2016-09-23 14:31:16 +03:00
Paul Sokolovsky 3074d4f4e2 zephyr/modsocket: Be sure to define default gateway address (uip_draddr).
Talking to Internet won't work without this.
2016-09-23 14:31:16 +03:00
Paul Sokolovsky 1125d7890a zephyr/mbedtls-config-upy.h: Disable asm support for now.
It has issues even on various ARM variants (e.g. armv7e-m errors out).
2016-09-23 14:31:16 +03:00
Paul Sokolovsky 140152f07b zephyr/modsocket: Don't consult uip_connr flags when decides conn state.
The fact that *now* connection closed doesn't mean there's no data in the
queue. We should process packet queue in order, and consider connection
closed only when hit corresponding state change packet (the latter requires
patches to Zephyr, because otherwise it doesn't deliver connection state
change packets to an app).
2016-09-23 14:31:15 +03:00
Paul Sokolovsky 82c481755b zephyr/prj.mdef: Bump "main" stack size to 8K.
More heavier use, like real-world TLS, can smash default 4K. And *this*
stack appears to be used by main(), not CONFIG_MAIN_STACK_SIZE.
2016-09-23 14:31:15 +03:00
Paul Sokolovsky 58c95ceff2 zephyr: Add mbedTLS config for the port.
Zephyr appear to include only constrained config, we need more features to
access real-world HTTPS, etc.
2016-09-23 14:31:15 +03:00
Paul Sokolovsky f48425b60c zephyr: Bump heap size to 24K, as required for umqtt.simple. 2016-09-23 14:31:15 +03:00
Paul Sokolovsky 469ad079a3 zephyr: Enable ustruct module, required for umqtt.simple. 2016-09-23 14:31:15 +03:00
Paul Sokolovsky d5c564ae81 zephyr/modsocket: socket_write: Send only data fitting in a netbuf. 2016-09-23 14:31:15 +03:00
Paul Sokolovsky 236e749884 zephyr/modsocket: Detect connection reset in connect().
TODO: Think about connection reset in other places too.
2016-09-23 14:31:15 +03:00
Paul Sokolovsky 375db1918c zephyr: Enable frozen modules support. 2016-09-23 14:31:15 +03:00
Paul Sokolovsky d569483d11 zephyr: Enable building ussl_mbedtls module.
Using Zephyr's builtin mbedtls.
2016-09-23 14:31:15 +03:00
Paul Sokolovsky 7bbda4dbb5 zephyr/prj.conf: Add network debug logging options (commented). 2016-09-23 14:31:15 +03:00
Paul Sokolovsky 6d1eb1baeb zephyr/prj.conf: Enable mbedTLS. 2016-09-23 14:31:14 +03:00
Paul Sokolovsky c160813a75 zephyr/modsocket: Add DEBUG_printf() logging. 2016-09-23 14:31:14 +03:00
Paul Sokolovsky 58d63c0c9a zephyr/modsocket: socket_read: Handle zero-length packets.
Zephyr actually filters these out, and requires patching to let them thru.
And underlying uIP uses them to e.g. communicate changes in connection
state (like peer closed connection). Without this change (and associated
Zephyr patch), socket read requests may hang if peer close happened after
read request was issued.
2016-09-23 14:31:14 +03:00
Paul Sokolovsky f51421f51c zephyr/modsocket: repr(): Dump even more internal socket info. 2016-09-23 14:31:14 +03:00
Paul Sokolovsky cfe6ab9aa4 zephyr/modsocket: Implement partial reads/writes. 2016-09-23 14:31:14 +03:00
Paul Sokolovsky 023364cdd6 zephyr/modsocket: Initial implementation of stream protocol. 2016-09-23 14:31:14 +03:00
Paul Sokolovsky c3695b3212 zephyr/Makefile: Add qemu-net target to run QEMU virtual networking. 2016-09-23 14:31:14 +03:00
Paul Sokolovsky 6b1ed34336 zephyr: Enable building of modsocket. 2016-09-23 14:31:14 +03:00
Paul Sokolovsky 90a01bb5c6 zephyr/modsocket: Add initial implementation of usocket module. 2016-09-23 14:31:13 +03:00
Paul Sokolovsky f0a3ca0be1 zephyr: Enable (IPv4) networking support. 2016-09-23 14:31:13 +03:00
Paul Sokolovsky 21bc7ccbaf zephyr: Implement smart way to access Zephyr config variables.
For this, we first build Z part with libmicropython.a not existing. This
produces autoconf.h with all setiings, but eventually fails on linking
stage due to missing libmicropython.a. We then build MicroPython, which
now can access values in autoconf.h. Then we execute Z build again, which
now succeeds.
2016-09-23 14:31:13 +03:00
Paul Sokolovsky e4d4c55621 zephyr/Makefile: Switch to qemu_x86 by default.
As it supports QEMU virtual networking.
2016-09-23 14:31:13 +03:00
Paul Sokolovsky 9af8e49885 zephyr: Switch to microkernel, required for network to work in background. 2016-09-23 14:31:13 +03:00
Paul Sokolovsky 372fdb7a8c zephyr: Enable stack checking and micropython.mem_info(). 2016-09-23 14:31:13 +03:00
Paul Sokolovsky d3e4ba1c94 zephyr/prj.conf: Set main thread stack size to 4K.
An interpreted language needs good size of stack to do anything useful
(minimum can be set to a lower value of course).
2016-09-23 14:31:13 +03:00
Paul Sokolovsky 069c8e7c82 zephyr: Add README. 2016-09-23 14:31:13 +03:00
Paul Sokolovsky fef0b4463e zephyr: Add zephyr_getchar module to handle console input.
From https://github.com/pfalcon/zephyr_getchar .
2016-09-23 14:31:13 +03:00
Paul Sokolovsky 42ab119d9f zephyr: Initial Zephyr RTOS port, Zephyr part. 2016-09-23 14:31:13 +03:00
Paul Sokolovsky ca4ba17c68 zephyr: Initial Zephyr RTOS port, MicroPython part. 2016-09-23 14:31:13 +03:00
Paul Sokolovsky 9cc8ec843e py/py.mk: Add support for building modussl_mbedtls. 2016-09-23 14:30:46 +03:00
Damien George 6d310a5552 py/parse: Only replace constants that are standalone identifiers.
This fixes constant substitution so that only standalone identifiers are
replaced with their constant value (if they have one).  I.e. don't
replace NAME in expressions like obj.NAME or NAME = expr.
2016-09-23 17:23:16 +10:00