diff options
| author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-10-07 17:09:53 +0300 |
|---|---|---|
| committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-10-07 17:36:16 +0300 |
| commit | 4514f073c18ab94b3f0f790ae813de61f38d367b (patch) | |
| tree | 021c1025084d0c1a88fd2d444e86ca3e2700804e /ports | |
| parent | 71c1a05d88c9ac84212d164458c5a501e59be389 (diff) | |
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.
Diffstat (limited to 'ports')
| -rw-r--r-- | ports/zephyr/prj_base.conf | 6 | ||||
| -rw-r--r-- | ports/zephyr/prj_qemu_cortex_m3.conf | 4 | ||||
| -rw-r--r-- | ports/zephyr/prj_qemu_x86.conf | 4 | ||||
| -rw-r--r-- | ports/zephyr/src/zephyr_start.c | 5 | ||||
| -rw-r--r-- | ports/zephyr/uart_core.c | 14 |
5 files changed, 33 insertions, 0 deletions
diff --git a/ports/zephyr/prj_base.conf b/ports/zephyr/prj_base.conf index a4cc14513..fbcedf260 100644 --- a/ports/zephyr/prj_base.conf +++ b/ports/zephyr/prj_base.conf @@ -4,6 +4,12 @@ CONFIG_REBOOT=y CONFIG_STDOUT_CONSOLE=y CONFIG_CONSOLE_HANDLER=y CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS=y + +CONFIG_CONSOLE_PULL=y +CONFIG_CONSOLE_GETCHAR=y +CONFIG_CONSOLE_GETCHAR_BUFSIZE=128 +CONFIG_CONSOLE_PUTCHAR_BUFSIZE=128 + CONFIG_NEWLIB_LIBC=y CONFIG_FLOAT=y CONFIG_MAIN_STACK_SIZE=4096 diff --git a/ports/zephyr/prj_qemu_cortex_m3.conf b/ports/zephyr/prj_qemu_cortex_m3.conf index 09614c362..1ade981e2 100644 --- a/ports/zephyr/prj_qemu_cortex_m3.conf +++ b/ports/zephyr/prj_qemu_cortex_m3.conf @@ -1,3 +1,7 @@ +# Interrupt-driven UART console has emulation artifacts under QEMU, +# disable it +CONFIG_CONSOLE_PULL=n + # Networking drivers # SLIP driver for QEMU CONFIG_NET_SLIP_TAP=y diff --git a/ports/zephyr/prj_qemu_x86.conf b/ports/zephyr/prj_qemu_x86.conf index ef60cfec9..9bc81259a 100644 --- a/ports/zephyr/prj_qemu_x86.conf +++ b/ports/zephyr/prj_qemu_x86.conf @@ -1,3 +1,7 @@ +# Interrupt-driven UART console has emulation artifacts under QEMU, +# disable it +CONFIG_CONSOLE_PULL=n + # Networking drivers # SLIP driver for QEMU CONFIG_NET_SLIP_TAP=y diff --git a/ports/zephyr/src/zephyr_start.c b/ports/zephyr/src/zephyr_start.c index 9e8a90beb..452e304ca 100644 --- a/ports/zephyr/src/zephyr_start.c +++ b/ports/zephyr/src/zephyr_start.c @@ -24,11 +24,16 @@ * THE SOFTWARE. */ #include <zephyr.h> +#include <console.h> #include "zephyr_getchar.h" int real_main(void); void main(void) { +#ifdef CONFIG_CONSOLE_PULL + console_init(); +#else zephyr_getchar_init(); +#endif real_main(); } diff --git a/ports/zephyr/uart_core.c b/ports/zephyr/uart_core.c index 1e85053cd..e41fb9acc 100644 --- a/ports/zephyr/uart_core.c +++ b/ports/zephyr/uart_core.c @@ -28,6 +28,7 @@ #include "src/zephyr_getchar.h" // Zephyr headers #include <uart.h> +#include <console.h> /* * Core UART functions to implement for a port @@ -35,11 +36,23 @@ // Receive single character int mp_hal_stdin_rx_chr(void) { +#ifdef CONFIG_CONSOLE_PULL + return console_getchar(); +#else return zephyr_getchar(); +#endif } // Send string of given length void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { +#ifdef CONFIG_CONSOLE_PULL + while (len--) { + char c = *str++; + while (console_putchar(c) == -1) { + k_sleep(1); + } + } +#else static struct device *uart_console_dev; if (uart_console_dev == NULL) { uart_console_dev = device_get_binding(CONFIG_UART_CONSOLE_ON_DEV_NAME); @@ -48,4 +61,5 @@ void mp_hal_stdout_tx_strn(const char *str, mp_uint_t len) { while (len--) { uart_poll_out(uart_console_dev, *str++); } +#endif } |
