aboutsummaryrefslogtreecommitdiff
path: root/ports/zephyr
AgeCommit message (Collapse)Author
2021-04-09py/py.cmake: Introduce MICROPY_INC_CORE as a list with core includes.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2021-03-12tests: Rename run-tests to run-tests.py for consistency.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2021-02-17zephyr/modusocket: Fix parameter in calls to net_context_get_XXX().PTH
The following simple usocket example throws an error EINVAL on connect import usocket s = usocket.socket() s.connect(usocket.getaddrinfo('www.micropython.org', 80)[0][-1]) Traceback (most recent call last): File "<stdin>", line 1, in <module> OSError: [Errno 22] EINVAL Fixing the context parameter in calls of net_context_get_family() and net_context_get_type(), the connect works fine. Tested on a nucleo_h743zi board.
2021-02-17zephyr/boards: Add support for the nucleo_h743zi board.PTH
2021-02-16zephyr: Build MicroPython as a cmake target.Maureen Helm
Refactors the zephyr build infrastructure to build MicroPython as a cmake target, using the recently introduced core cmake rules. This change makes it possible to build the zephyr port like most other zephyr applications using west or cmake directly. It simplifies building with extra cmake arguments, such as specifying an alternate conf file or adding an Arduino shield. It also enables building the zephyr port anywhere in the host file system, which will allow regressing across multiple boards with the zephyr twister script. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2021-02-16zephyr: Remove unused build files.Maureen Helm
Removes zephyr port build files that aren't being used anymore. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2021-02-16zephyr: Disable frozen source modules.Maureen Helm
Disables frozen source modules in the zephyr port. They are deprecated in the makefile rules and not implemented in the new cmake rules. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2021-02-16zephyr: Update to zephyr v2.5.0.Maureen Helm
Updates the zephyr port build instructions and CI to use the latest zephyr release tag. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2021-02-01zephyr/machine_uart: Fix arg of machine_uart_ioctl to make it uintptr_t.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2021-01-23zephyr: Add basic UART functionality to machine module.Yonatan Schachter
Currently supports only polling read and write. Signed-off-by: Yonatan Schachter <yonatan.schachter@gmail.com>
2020-12-07zephyr: Guard I2C code with appropriate ifdef config.Jonathan Bruchim
To reduce binary code size when not using I2C. Signed-off-by: Jonathan Bruchim <yonbruchim@gmail.com>
2020-12-07zephyr: Replace broken shell_net_iface() with more general shell_exec().Maureen Helm
The zephyr function net_shell_cmd_iface() was removed in zephyr v1.14.0, therefore the MicroPython zephyr port did not build with newer zephyr versions when CONFIG_NET_SHELL=y. Replace with a more general shell_exec() function that can execute any zephyr shell command. For example: >>> zephyr.shell_exec("net") Subcommands: allocs :Print network memory allocations. arp :Print information about IPv4 ARP cache. conn :Print information about network connections. dns :Show how DNS is configured. events :Monitor network management events. gptp :Print information about gPTP support. iface :Print information about network interfaces. ipv6 :Print information about IPv6 specific information and configuration. mem :Print information about network memory usage. nbr :Print neighbor information. ping :Ping a network host. pkt :net_pkt information. ppp :PPP information. resume :Resume a network interface route :Show network route. stacks :Show network stacks information. stats :Show network statistics. suspend :Suspend a network interface tcp :Connect/send/close TCP connection. vlan :Show VLAN information. websocket :Print information about WebSocket connections. >>> zephyr.shell_exec("kernel") kernel - Kernel commands Subcommands: cycles :Kernel cycles. reboot :Reboot. stacks :List threads stack usage. threads :List kernel threads. uptime :Kernel uptime. version :Kernel version. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-11-23extmod/machine_i2c: Add init protocol method for generic I2C bindings.Damien George
Hardware I2C implementations must provide a .init() protocol method if they want to support reconfiguration. Otherwise the default is that i2c.init() raises an OSError (currently the case for all ports). mp_machine_soft_i2c_locals_dict is renamed to mp_machine_i2c_locals_dict to match the generic SPI bindings. Fixes issue #6623 (where calling .init() on a HW I2C would crash). Signed-off-by: Damien George <damien@micropython.org>
2020-10-01ports: Support legacy soft I2C/SPI construction via id=-1 arg.Damien George
With a warning that this way of constructing software I2C/SPI is deprecated. The check and warning will be removed in a future release. This should help existing code to migrate to the new SoftI2C/SoftSPI types. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01ports: Add SoftI2C and SoftSPI to machine module where appropriate.Damien George
Previous commits removed the ability for one I2C/SPI constructor to construct both software- or hardware-based peripheral instances. Such construction is now split to explicit soft and non-soft types. This commit makes both types available in all ports that previously could create both software and hardware peripherals: machine.I2C and machine.SPI construct hardware instances, while machine.SoftI2C and machine.SoftSPI create software instances. This is a breaking change for use of software-based I2C and SPI. Code that constructed I2C/SPI peripherals in the following way will need to be changed: machine.I2C(-1, ...) -> machine.SoftI2C(...) machine.I2C(scl=scl, sda=sda) -> machine.SoftI2C(scl=scl, sda=sda) machine.SPI(-1, ...) -> machine.SoftSPI(...) machine.SPI(sck=sck, mosi=mosi, miso=miso) -> machine.SoftSPI(sck=sck, mosi=mosi, miso=miso) Code which uses machine.I2C and machine.SPI classes to access hardware peripherals does not need to change. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01extmod/machine_i2c: Remove "id" arg in SoftI2C constructor.Damien George
The SoftI2C constructor is now used soley to create SoftI2C instances, it can no longer delegate to create a hardware-based I2C instance. Signed-off-by: Damien George <damien@micropython.org>
2020-10-01extmod/machine_i2c: Rename type to SoftI2C and add custom print method.Damien George
Also rename machine_i2c_type to mp_machine_soft_i2c_type. These changes make it clear that it's a soft-I2C implementation, and match SoftSPI. Signed-off-by: Damien George <damien@micropython.org>
2020-09-30zephyr: Update build instructions to v2.4.0.Maureen Helm
Updates the zephyr port build instructions to use the latest zephyr release tag. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-09-30zephyr: Const-ify struct device instance pointers.Maureen Helm
Zephyr v2.4.0 added a const qualifier to usages of struct device to allow storing device driver instances exclusively in flash and thereby reduce ram footprint. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-09-30zephyr: Replace zephyr integer types with C99 types.Maureen Helm
Zephyr v2.4.0 stopped using custom integer types in favor of C99 types instead. Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-09-04lib/utils/mpirq: Add mp_irq_init func, and clean up unused init method.Damien George
mp_irq_init() is useful when the IRQ object is allocated by the caller. The mp_irq_methods_t.init method is not used anywhere so has been removed. Signed-off-by: Damien George <damien@micropython.org>
2020-08-28zephyr/README: Update required Zephyr version and mention new features.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-08-22py/mphal.h: Introduce mp_hal_time_ns and implement on various ports.Damien George
This should return a 64-bit value being the number of nanoseconds since 1970/1/1. Signed-off-by: Damien George <damien@micropython.org>
2020-08-21zephyr: Include storage/flash_map.h unconditionally.Maureen Helm
Include storage/flash_map.h unconditionally so we always have access to the FLASH_AREA_LABEL_EXISTS macro, even if CONFIG_FLASH_MAP is not defined. This fixes a build error for the qemu_x86 board: main.c:108:63: error: missing binary operator before token "(" 108 | #elif defined(CONFIG_FLASH_MAP) && FLASH_AREA_LABEL_EXISTS(storage) | ^ ../../py/mkrules.mk:88: recipe for target 'build/genhdr/qstr.i.last' failed Signed-off-by: Maureen Helm <maureen.helm@nxp.com>
2020-06-30zephyr/make-minimal: Disable FAT and LFS2 options to make it build.Damien George
Signed-off-by: Damien George <damien@micropython.org>
2020-06-30zephyr: Implement machine.Pin.irq() for setting callbacks on pin change.Damien George
Supports hard and soft interrupts. In the current implementation, soft interrupt callbacks will only be called when the VM is executing, ie they will not be called during a blocking kernel call like k_msleep. And the behaviour of hard interrupt callbacks will depend on the underlying device, as well as the amount of ISR stack space. Soft and hard interrupts tested on frdm_k64f and nucleo_f767zi boards. Signed-off-by: Damien George <damien@micropython.org>
2020-06-12zephyr: Use cmake find_package to locate zephyr.Maureen Helm
Updates the zephyr port to use the ZEPHYR_BASE environment variable only to locate the zephyr cmake package, allowing cmake to cache the variable.
2020-06-12zephyr: Increase minimum required cmake version to 3.13.1.Maureen Helm
The minimum required cmake version has been 3.13.1 since zephyr 1.14.0.
2020-06-12zephyr: Convert DT_FLASH_AREA usages to new dts macros.Maureen Helm
Converts DT_FLASH_AREA usages in the zephyr port to new device tree macros introduced in zephyr 2.3. Tested with littlefs on the reel_board.
2020-06-12zephyr: Update to new zephyr timeout API.Maureen Helm
Updates the zephyr port to use the new timeout api introduced in zephyr 2.3.
2020-06-12zephyr: Update for refactored zephyr device structures.Maureen Helm
Updates the zephyr port to use refactored device structures introduced in zephyr 2.3.
2020-06-12zephyr: Fix floating point configuration.Maureen Helm
Zephyr renamed CONFIG_FLOAT to CONFIG_FPU to better reflect its semantics of enabling the hardware floating point unit (FPU) rather than enabling toolchain-level floating point support (i.e., software floating point for FPU-less socs).
2020-06-12zephyr: Fix and rename stacks_analyze function in zephyr module.Maureen Helm
Zephyr deprecated and then removed its stack_analyze function because it was unsafe. Use the new zephyr thread analyzer instead and rename the MicroPython function to zephyr.thread_analyze() to be more consistent with the implementation. Tested on mimxrt1050_evk. The output now looks like this: >>> zephyr.thread_analyze() Thread analyze: 80004ff4 : unused 400 usage 112 / 512 (21 %) rx_workq : unused 1320 usage 180 / 1500 (12 %) tx_workq : unused 992 usage 208 / 1200 (17 %) net_mgmt : unused 656 usage 112 / 768 (14 %) sysworkq : unused 564 usage 460 / 1024 (44 %) idle : unused 256 usage 64 / 320 (20 %) main : unused 2952 usage 1784 / 4736 (37 %)
2020-05-05zephyr: Use zephyr build system to merge configurations.Maureen Helm
The zephyr build system supports merging application-level board configurations, so there is no need to reproduce this functionality in MicroPython. If CONF_FILE is not explicitly set, then the zephyr build system looks for prj.conf in the application directory. Therefore we rename the MicroPython prj_base.conf to prj.conf. Furthermore, if the zephyr build system finds boards/$(BOARD).conf in the application directory, it merges that configuration with prj.conf. Therefore we rename all the MicroPython board .conf files and move them into a boards/ directory. The minimal configuration, prj_minimal.conf, is left in the application directory because it is used as an explicitly set CONF_FILE in make-minimal.
2020-04-23all: Format code to add space after C++-style comment start.stijn
Note: the uncrustify configuration is explicitly set to 'add' instead of 'force' in order not to alter the comments which use extra spaces after // as a means of indenting text for clarity.
2020-04-05all: Use MP_ERROR_TEXT for all error messages.Jim Mussared
2020-03-25zephyr: Update machine.Pin class to use new zephyr gpio api.Maureen Helm
Zephyr v2.2 reworked its gpio api to support linux device tree bindings and pin logical levels. This commit updates the zephyr port's machine.Pin class to replace the deprecated gpio api calls with the new supported gpio api. This resolves several build warnings. Tested on frdm_k64f and mimxrt1050_evk boards.
2020-03-11zephyr: Execute main.py file if it exists.Maureen Helm
Adds support in the zephyr port to execute main.py if the file system is enabled and the file exists. Existing support for executing a main.py frozen module is preserved, since pyexec_file_if_exists() works just like pyexec_frozen_module() if there's no vfs.
2020-03-11zephyr: Enable usb mass storage class on mimxrt1050_evk.Maureen Helm
Enables the zephyr usb device stack and mass storage class on the mimxrt1050_evk board. The mass storage class is backed by the sdhc disk access driver, so it's now possible to browse and modify the contents of the SD card from a USB host (your PC). This is in preparation to support writing a main.py script to the SD card, and then executing it after the next reset.
2020-03-11zephyr: Mount a file system during init.Maureen Helm
Adds support in the zephyr port to mount a file system if a block device (sdhc disk access or flash area) is available. The mount point is either "/sd" or "/flash" depending on the type of block device. Tested with an sdhc disk access block device and fatfs on the mimxrt1050_evk board. Tested with a flash area block device and littlefs on the reel_board.
2020-02-28all: Reformat C and Python source code with tools/codeformat.py.Damien George
This is run with uncrustify 0.70.1, and black 19.10b0.
2020-02-07zephyr: Enable littlefs.Maureen Helm
Enables the littlefs (v1 and v2) filesystems in the zephyr port. Example usage with the internal flash on the reel_board or the rv32m1_vega_ri5cy board: import os from zephyr import FlashArea bdev = FlashArea(FlashArea.STORAGE, 4096) os.VfsLfs2.mkfs(bdev) os.mount(bdev, '/flash') with open('/flash/hello.txt','w') as f: f.write('Hello world') print(open('/flash/hello.txt').read()) Things get a little trickier with the frdm_k64f due to the micropython application spilling into the default flash storage partition defined for this board. The zephyr build system doesn't enforce the flash partitioning when mcuboot is not enabled (which it is not for micropython). For now we can demonstrate that the littlefs filesystem works on frdm_k64f by constructing the FlashArea block device on the mcuboot scratch partition instead of the storage partition. Do this by replacing the FlashArea.STORAGE constant above with the value 4.
2020-02-07zephyr: Implement block device protocol via zephyr flash map api.Maureen Helm
Introduces a new zephyr.FlashArea class that uses the zephyr flash map api to implement the uos.AbstractBlockDev protocol. The flash driver is enabled on the frdm_k64f board, reel_board, and rv32m1_vega_ri5cy board. The standard and extended block device protocols are both supported, therefore this class can be used with file systems like littlefs which require the extended interface.
2020-02-07zephyr: Enable fatfs.Maureen Helm
Enables the fatfs filesystem in the zephyr port. Example usage with an SD card on the mimxrt1050_evk board: import zephyr, os bdev = zephyr.DiskAccess('SDHC') os.VfsFat.mkfs(bdev) os.mount(bdev, '/sd') with open('/sd/hello.txt','w') as f: f.write('Hello world') print(open('/sd/hello.txt').read())
2020-02-07zephyr: Enable virtual file system and uos module.Maureen Helm
Enables the virtual file system and uos module in the zephyr port. No concrete file system implementations are enabled yet.
2020-02-07zephyr: Implement block device protocol via zephyr disk access api.Maureen Helm
Introduces a new zephyr.DiskAccess class that uses the zephyr disk access api to implement the uos.AbstractBlockDev protocol. This can be used with any type of zephyr disk access driver, which currently includes SDHC, RAM, and FLASH implementations. The SDHC driver is enabled on the mimxrt1050_evk board. Only the standard block device protocol (without the offset parameter) can be supported with the zephyr disk access api, therefore this class cannot be used with file systems like littlefs which require the extended interface. In the future it may be possible to implement the extended interface in a new class using the zephyr flash api.
2020-02-04zephyr: Remove reference to syscall_macros_h_target.Maureen Helm
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-04zephyr: Replace deprecated time conversion macro.Maureen Helm
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-04zephyr: Update include paths for Zephyr v2.0.Maureen Helm
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.
2019-10-29zephyr/main: Use mp_stack API instead of local pointer for stack top.Kamil Klimek
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.