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).
This commit is contained in:
Paul Sokolovsky 2017-01-21 17:16:35 +03:00
parent 1459f81429
commit 5298472fee
2 changed files with 29 additions and 0 deletions

View File

@ -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));

View File

@ -4,3 +4,16 @@ CONFIG_UART_CONSOLE_DEBUG_SERVER_HOOKS=y
CONFIG_NEWLIB_LIBC=y
CONFIG_FLOAT=y
CONFIG_MAIN_STACK_SIZE=4096
# Networking config
CONFIG_NETWORKING=y
CONFIG_NET_IPV4=y
CONFIG_TEST_RANDOM_GENERATOR=y
CONFIG_NET_NBUF_RX_COUNT=4
# Networking drivers
# SLIP driver for QEMU
CONFIG_NET_SLIP_TAP=y
# BOARD-specific config (qemu_x86)
CONFIG_RAM_SIZE=256