diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-01-21 17:16:35 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2017-01-21 17:16:35 +0300 |
commit | 5298472fee1a83878e4670c1f8c885aefc087765 (patch) | |
tree | 20d04d4e103f17d401633d28a24a83eb18367356 /zephyr/main.c | |
parent | 1459f8142919352b5615751566d443e0c319bc8e (diff) |
zephyr: Enable SLIP networking for the default build.
This makes MicroPython app running in QEMU be pingable from the host (by
following QEMU networking setup instructions,
https://www.zephyrproject.org/doc/samples/net/qemu_setup.html).
Diffstat (limited to 'zephyr/main.c')
-rw-r--r-- | zephyr/main.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/zephyr/main.c b/zephyr/main.c index d812f9609..6d7fca802 100644 --- a/zephyr/main.c +++ b/zephyr/main.c @@ -28,6 +28,12 @@ #include <stdio.h> #include <string.h> +#include <zephyr.h> +#ifdef CONFIG_NETWORKING +#include <net/net_context.h> +#include <net/nbuf.h> +#endif + #include "py/nlr.h" #include "py/compile.h" #include "py/runtime.h" @@ -60,6 +66,14 @@ void do_str(const char *src, mp_parse_input_kind_t input_kind) { static char *stack_top; static char heap[MICROPY_HEAP_SIZE]; +void init_zephyr(void) { + #ifdef CONFIG_NET_IPV4 + // TODO: Make address configurable + static struct in_addr in4addr_my = { { { 192, 0, 2, 1 } } }; + net_if_ipv4_addr_add(net_if_get_default(), &in4addr_my, NET_ADDR_MANUAL, 0); + #endif +} + int real_main(void) { int stack_dummy; stack_top = (char*)&stack_dummy; @@ -67,6 +81,8 @@ int real_main(void) { // Make MicroPython's stack limit somewhat smaller than full stack available mp_stack_set_limit(CONFIG_MAIN_STACK_SIZE - 512); + init_zephyr(); + soft_reset: #if MICROPY_ENABLE_GC gc_init(heap, heap + sizeof(heap)); |