Commit Graph

53 Commits

Author SHA1 Message Date
Maureen Helm
bc3ce86a5a zephyr: Remove reference to syscall_macros_h_target.
Zephyr removed the build target syscall_macros_h_target in commit
f4adf107f31674eb20881531900ff092cc40c07f.  Removes reference from
MicroPython to fix build errors in the zephyr port.

This change is not compatible with zephyr v2.1 or earlier.  It will be
compatible with Zephyr v2.2 when released.
2020-02-04 17:10:24 +11:00
Maureen Helm
a7663b862e zephyr: Replace deprecated time conversion macro.
The SYS_CLOCK_HW_CYCLES_TO_NS macro was deprecated in zephyr commit
8892406c1de21bd5de5877f39099e3663a5f3af1.  This commit updates MicroPython
to use the new k_cyc_to_ns_floor64 api and fix build warnings in the zephyr
port.

This change is compatible with Zephyr v2.1 and later.
2020-02-04 17:09:59 +11:00
Maureen Helm
c25e12d0dd zephyr: Update include paths for Zephyr v2.0.
Zephyr restructured its includes in v2.0 and removed compatibility shims
after two releases in commit 1342dadc365ee22199e51779185899ddf7478686.
Updates include paths in MicroPython accordingly to fix build errors in
the zephyr port.

These changes are compatible with Zephyr v2.0 and later.
2020-02-04 17:09:19 +11:00
Kamil Klimek
53f3cbc2c4 zephyr/main: Use mp_stack API instead of local pointer for stack top.
The MP_STATE_THREAD(stack_top) is always available so use it instead of
creating a separate variable.  This also allows gc_collect() to be used as
an independent function, without real_main() being called.
2019-10-29 23:05:07 +11:00
Damien George
d2384efa80 py: Automatically provide weak links from "foo" to "ufoo" module name.
This commit implements automatic module weak links for all built-in
modules, by searching for "ufoo" in the built-in module list if "foo"
cannot be found.  This means that all modules named "ufoo" are always
available as "foo".  Also, a port can no longer add any other weak links,
which makes strict the definition of a weak link.

It saves some code size (about 100-200 bytes) on ports that previously had
lots of weak links.

Some changes from the previous behaviour:
- It doesn't intern the non-u module names (eg "foo" is not interned),
  which saves code size, but will mean that "import foo" creates a new qstr
  (namely "foo") in RAM (unless the importing module is frozen).
- help('modules') no longer lists non-u module names, only the u-variants;
  this reduces duplication in the help listing.

Weak links are effectively the same as having a set of symbolic links on
the filesystem that is searched last.  So an "import foo" will search
built-in modules first, then all paths in sys.path, then weak links last,
importing "ufoo" if it exists.  Thus a file called "foo.py" somewhere in
sys.path will still have precedence over the weak link of "foo" to "ufoo".

See issues: #1740, #4449, #5229, #5241.
2019-10-22 15:30:52 +11:00
Paul Sokolovsky
c4a6d9c631 zephyr: Switch back to enabling I2C in board-specific configs.
I2C can't be enabled in prj_base.conf because it's a board-specific
feature.  For example, if a board doesn't have I2C but CONFIG_I2C=y then
the build will fail (on Zephyr build system side).  The patch here gets the
qemu_cortex_m3 build working again.
2019-05-24 15:33:02 +10:00
Paul Sokolovsky
b88bf42793 zephyr/README: Reorder content related to recently added I2C.
So it fits better with existing narrative.
2019-05-24 15:29:29 +10:00
Damien George
647b27d028 zephyr/machine_i2c: Update to support new C-level I2C API. 2019-05-20 15:04:29 +10:00
Damiano Mazzella
3c9f78b048 zephyr/CMakeLists.txt: Set AR to point to the Zephyr toolchain exe. 2019-04-11 12:24:05 +10:00
Maureen Helm
2befcb8a9d zephyr/i2c: Add support for hardware i2c.
Adds support for hardware i2c to the zephyr port. Similar to other ports
such as stm32 and nrf, we only implement the i2c protocol functions
(readfrom and writeto) and defer memory operations (readfrom_mem,
readfrom_mem_into, and writeto_mem) to the software i2c implementation.
This may need to change in the future because zephyr is considering
deprecating its i2c_transfer function in favor of i2c_write_read; in this
case we would probably want to implement the memory operations directly
using i2c_write_read.

Tested with the accelerometer on frdm_k64f and bbc_microbit boards.
2019-03-26 16:16:26 +11:00
Maureen Helm
493ee7df18 zephyr/prj_frdm_kw41z.conf: Add new board configuration.
Adds a new board configuration for the frdm_kw41z board, including support
for the fxos8700 accelerometer/magnetometer/die temperature sensor.
2019-03-12 17:12:13 +11:00
Maureen Helm
7748375b6e zephyr/prj_frdm_k64f.conf: Add fxos8700 sensor.
Adds the fxos8700 accelerometer/magnetometer/die temperature sensor to the
frdm_k64f board configuration.
2019-03-12 17:12:00 +11:00
Paul Sokolovsky
6d82499a48 zephyr/Makefile: Proxy ram_report, rom_report targets from Zephyr. 2019-03-12 17:11:52 +11:00
Paul Sokolovsky
755b0b807b zephyr/prj_minimal.conf: Switch to CONFIG_STDOUT_CONSOLE.
Prompted by code size analysis, after arduino_101 build overflowing ROM.
2019-03-12 17:11:46 +11:00
Paul Sokolovsky
21fc0c448e zephyr/modzsensor: Rename "TEMP" sensor channel to "DIE_TEMP".
I.e. on-die temperature sensor.  Upstream made more fine-grained channels
for different kinds of temperature.
2019-03-12 17:11:30 +11:00
Paul Sokolovsky
a42c1d9fd5 zephyr/modzephyr: Revamp stacks_analyze() call.
Underlying k_call_stacks_analyze() was gone in Zephyr, reimplement using
k_thread_foreach().
2019-03-12 17:11:09 +11:00
Damien George
6e30f96b0b ports: Convert legacy uppercase macro names to lowercase. 2019-02-12 14:54:51 +11:00
Paul Sokolovsky
2f5d113fad py/warning: Support categories for warnings.
Python defines warnings as belonging to categories, where category is a
warning type (descending from exception type). This is useful, as e.g.
allows to disable warnings selectively and provide user-defined warning
types.  So, implement this in MicroPython, except that categories are
represented just with strings.  However, enough hooks are left to implement
categories differently per-port (e.g. as types), without need to patch each
and every usage.
2019-01-31 16:48:30 +11:00
Paul Sokolovsky
5a91fce9f8 py/objstr: Make str.count() method configurable.
Configurable via MICROPY_PY_BUILTINS_STR_COUNT.  Default is enabled.
Disabled for bare-arm, minimal, unix-minimal and zephyr ports.  Disabling
it saves 408 bytes on x86.
2018-10-22 22:49:05 +11:00
Paul Sokolovsky
0bce110872 zephyr/CMakeLists: Update for latest Zephyr CMake usage refactorings.
Added cmake_minimum_required and updated target_link_libraries directives.
2018-09-14 13:21:13 +10:00
Paul Sokolovsky
ed1a5bc88e zephyr/prj_base.conf: Update for net_config subsys refactor.
net_config subsystem was split off from net_app, and as a result, settings
need renaming from CONFIG_NET_APP_* to CONFIG_NET_CONFIG_*.
2018-09-14 13:21:13 +10:00
Damien George
05e0103e9e zephyr: Rename CONFIG_CONSOLE_PULL to CONFIG_CONSOLE_SUBSYS.
Following a similar change in the Zephyr Project.
2018-06-27 15:33:59 +10:00
Paul Sokolovsky
735358bcf4 zephyr/prj_qemu_x86.conf: Remove outdated CONFIG_RAM_SIZE.
Target RAM size is no longer set using Kconfig options, but instead using
DTS (device tree config). Fortunately, the default is now set to a high
value, so we don't need to use DTS fixup.
2018-06-27 14:59:17 +10:00
Paul Sokolovsky
543352ac21 zephyr/prj_base.conf: Remove outdated CONFIG_NET_NBUF_RX_COUNT option.
CONFIG_NET_NBUF_RX_COUNT no longer exists in Zephyr, for a while. That
means we build with the default RX buf count for a while too, and it works,
so just remove it (instead of switching to what it was renamed to,
CONFIG_NET_PKT_RX_COUNT).
2018-06-27 14:58:54 +10:00
Paul Sokolovsky
478410b409 zephyr/Makefile: Add kobj_types_h_target to Z_EXPORTS.
New generated Zephyr header file, without it build breaks.
2018-05-21 10:35:16 +10:00
Paul Sokolovsky
5a023372df zephyr: Add prj_disco_l475_iot1.conf with sensor drivers. 2018-05-21 10:35:16 +10:00
Paul Sokolovsky
7afbc49863 zephyr/prj_base.conf: Enable DHCP and group static IPs together.
Add CONFIG_NET_DHCPV4, which, after
https://github.com/zephyrproject-rtos/zephyr/pull/5750 works as follows:
static addresses are configured after boot, and DHCP requests are sent
at the same time. If valid DHCP reply is received, it overrides static
addresses.

This setup works out of the box for both direct connection to a
workstation (DHCP server usually is not available) and for connection
to a router (DHCP is available and required).
2018-05-21 10:35:16 +10:00
Paul Sokolovsky
0e52ee957d zephyr/modzsensor: Zephyr sensor subsystem bindings. 2018-05-21 10:35:16 +10:00
Paul Sokolovsky
080b0be1c8 zephyr/mpconfigport.h: Enable uhashlib and ubinascii modules.
To be able to use data integrity checks in various tests.
2018-05-21 10:35:16 +10:00
Paul Sokolovsky
9480c188e8 zephyr/main: After builtin testsuite, drop to REPL.
It makes sense to make even testsuite-enabled builds be suitable for
interactive use.
2018-05-21 10:35:16 +10:00
Paul Sokolovsky
1050045979 zephyr/README: Hint about existence of qemu_x86_nommu. 2018-05-21 10:35:16 +10:00
Damien George
cf31d384f1 py/stream: Switch stream close operation from method to ioctl.
This patch moves the implementation of stream closure from a dedicated
method to the ioctl of the stream protocol, for each type that implements
closing.  The benefits of this are:

1. Rounds out the stream ioctl function, which already includes flush,
   seek and poll (among other things).

2. Makes calling mp_stream_close() on an object slightly more efficient
   because it now no longer needs to lookup the close method and call it,
   rather it just delegates straight to the ioctl function (if it exists).

3. Reduces code size and allows future types that implement the stream
   protocol to be smaller because they don't need a dedicated close method.

Code size reduction is around 200 bytes smaller for x86 archs and around
30 bytes smaller for the bare-metal archs.
2018-04-10 13:41:32 +10:00
Paul Sokolovsky
7a9a73ee84 zephyr/main: Remove unused do_str() function.
The artifact of initial porting effort.
2017-12-26 20:16:08 +02:00
Paul Sokolovsky
d9977a8ad9 zephyr/Makefile: clean: Clean libmicropython.a too. 2017-12-26 14:46:16 +02:00
Paul Sokolovsky
dd35fe7ca0 zephyr/prj_base.conf: Bump MAIN_STACK_SIZE to let builtin testsuite run. 2017-12-15 18:17:00 +02:00
Paul Sokolovsky
6b19520a74 zephyr: Add support for binary with builtin testsuite.
If TEST is defined, file it refers to will be used as the testsuite
source (should be generated with tools/tinytest-codegen.py).

"make-bin-testsuite" script is introduce to build such a binary.
2017-12-15 12:10:39 +02:00
Paul Sokolovsky
55d33d5897 zephyr/main: Move var declarations to the top of file. 2017-12-08 12:39:57 +02:00
Paul Sokolovsky
ada1dc1c03 zephyr/CMakeLists.txt: Properly separate CFLAGS parts gotten from CMake.
Lack of spaces between them led to weird option artifacts like -Ifoo-Dbar.
2017-12-06 16:45:27 +02:00
Paul Sokolovsky
ccec4ee7ad zephyr/CMakeLists.txt: Update for latest Zephyr buildsys changes. 2017-12-06 15:31:07 +02:00
Paul Sokolovsky
bb047558da zephyr/Makefile: syscall_macros.h generation was moved from CMake to make.
Required for #include <zephyr.h> to work.
2017-12-01 13:45:03 +02:00
Paul Sokolovsky
b369c1bb96 zephyr/Makefile: Make prj_$(BOARD).conf optional, again.
This time hopefully should work reliably, using make $(wildcard) function,
which in this case either expands to existing prj_$(BOARD).conf file, or to
an empty string for non-existing one.
2017-11-28 18:19:48 +02:00
Paul Sokolovsky
a036554a77 zephyr/Makefile: Convert to new CMake-based Zephyr build system.
Zephyr 1.10 switches to CMake-based build system (already in master).
2017-11-28 16:37:51 +02:00
Paul Sokolovsky
25b7c7d7c6 zephyr/prj_base.conf: Force zephyr.bin build output.
As useful for CI systems. 1.10 doesn't build .bin for qemu_* for example.

Also, remove deprecated CONFIG_LEGACY_KERNEL option.
2017-11-28 14:11:46 +02:00
Paul Sokolovsky
53e06e05c9 zephyr/Makefile: clean: Remove generated prj_*_merged.conf. 2017-11-28 13:37:26 +02:00
Damien George
4601759bf5 py/objstr: Remove "make_qstr_if_not_already" arg from mp_obj_new_str.
This patch simplifies the str creation API to favour the common case of
creating a str object that is not forced to be interned.  To force
interning of a new str the new mp_obj_new_str_via_qstr function is added,
and should only be used if warranted.

Apart from simplifying the mp_obj_new_str function (and making it have the
same signature as mp_obj_new_bytes), this patch also reduces code size by a
bit (-16 bytes for bare-arm and roughly -40 bytes on the bare-metal archs).
2017-11-16 13:17:51 +11:00
Paul Sokolovsky
3a9b15fd79 zephyr/README: "make qemu" was replaced with "make run". 2017-11-01 15:16:01 +02:00
Paul Sokolovsky
4514f073c1 zephyr: Switch to interrupt-driven pull-style console.
While this console API improves handling on real hardware boards
(e.g. clipboard paste is much more reliable, as well as programmatic
communication), it vice-versa poses problems under QEMU, apparently
because it doesn't emulate UART interrupt handling faithfully. That
leads to inability to run the testsuite on QEMU at all. To work that
around, we have to suuport both old and new console routines, and use
the old ones under QEMU.
2017-10-07 17:36:16 +03:00
Paul Sokolovsky
58ea239510 zephyr: Use CONFIG_NET_APP_SETTINGS to setup initial network addresses.
Ideally, these should be configurable from Python (using network module),
but as that doesn't exist, we better off using Zephyr's native bootstrap
configuration facility.
2017-10-07 14:08:50 +03:00
Damien George
a3dc1b1957 all: Remove inclusion of internal py header files.
Header files that are considered internal to the py core and should not
normally be included directly are:
    py/nlr.h - internal nlr configuration and declarations
    py/bc0.h - contains bytecode macro definitions
    py/runtime0.h - contains basic runtime enums

Instead, the top-level header files to include are one of:
    py/obj.h - includes runtime0.h and defines everything to use the
        mp_obj_t type
    py/runtime.h - includes mpstate.h and hence nlr.h, obj.h, runtime0.h,
        and defines everything to use the general runtime support functions

Additional, specific headers (eg py/objlist.h) can be included if needed.
2017-10-04 12:37:50 +11:00
Damien George
da8c4c2653 py/builtinhelp: Change signature of help text var from pointer to array.
As a pointer (const char *) it takes up an extra word of storage which is
in RAM.
2017-09-12 16:03:52 +10:00