diff --git a/boards/x86/qemu_x86/board.cmake b/boards/x86/qemu_x86/board.cmake index 6c4d98020e0..3cf001f7c82 100644 --- a/boards/x86/qemu_x86/board.cmake +++ b/boards/x86/qemu_x86/board.cmake @@ -13,7 +13,6 @@ set(QEMU_FLAGS_${ARCH} -nographic -vga none -display none - -net none -no-acpi -machine type=pc-0.14 ) diff --git a/cmake/app/boilerplate.cmake b/cmake/app/boilerplate.cmake index fc116ebc548..e0b3707564e 100644 --- a/cmake/app/boilerplate.cmake +++ b/cmake/app/boilerplate.cmake @@ -327,6 +327,28 @@ message(STATUS "Cache files will be written to: ${USER_CACHE_DIR}") include(${BOARD_DIR}/board.cmake OPTIONAL) +# If we are using a suitable ethernet driver inside qemu, then these options +# must be set, otherwise a zephyr instance cannot receive any network packets. +# The Qemu supported ethernet driver should define CONFIG_ETH_NIC_MODEL +# string that tells what nic model Qemu should use. +if(CONFIG_QEMU_TARGET) + if(CONFIG_NET_QEMU_ETHERNET) + if(CONFIG_ETH_NIC_MODEL) + list(APPEND QEMU_FLAGS_${ARCH} + -nic tap,model=${CONFIG_ETH_NIC_MODEL},script=no,downscript=no,ifname=zeth + ) + else() + message(FATAL_ERROR + "No Qemu ethernet driver configured! +Enable Qemu supported ethernet driver like e1000 at drivers/ethernet") + endif() + else() + list(APPEND QEMU_FLAGS_${ARCH} + -net none + ) + endif() +endif() + zephyr_library_named(app) add_subdirectory(${ZEPHYR_BASE} ${__build_dir}) diff --git a/cmake/emu/qemu.cmake b/cmake/emu/qemu.cmake index 580504507bc..0da8456e690 100644 --- a/cmake/emu/qemu.cmake +++ b/cmake/emu/qemu.cmake @@ -72,8 +72,10 @@ endif() # pass data between them. The QEMU flags are not set for standalone # tests defined by CONFIG_NET_TEST. if(CONFIG_NETWORKING) - if(CONFIG_NET_SLIP_TAP) - set(QEMU_NET_STACK 1) + if(CONFIG_NET_QEMU_SLIP) + if(CONFIG_NET_SLIP_TAP) + set(QEMU_NET_STACK 1) + endif() endif() endif() diff --git a/drivers/ethernet/Kconfig.e1000 b/drivers/ethernet/Kconfig.e1000 index d566498f103..8f504c13faa 100644 --- a/drivers/ethernet/Kconfig.e1000 +++ b/drivers/ethernet/Kconfig.e1000 @@ -12,3 +12,12 @@ menuconfig ETH_E1000 depends on NET_L2_ETHERNET && PCI_ENUMERATION help Enable Intel(R) PRO/1000 Gigabit Ethernet driver. + +# Hidden option +config ETH_NIC_MODEL + string + default "e1000" + depends on ETH_E1000 + help + Tells what Qemu network model to use. This value is given as + a parameter to -nic qemu command line option. diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index ba81db89547..b81302436e1 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -35,6 +35,7 @@ # menuconfig SLIP bool "SLIP driver" + depends on (!QEMU_TARGET || NET_QEMU_SLIP) select UART_PIPE select UART_INTERRUPT_DRIVEN diff --git a/subsys/net/ip/Kconfig b/subsys/net/ip/Kconfig index e2a693cb304..13337145083 100644 --- a/subsys/net/ip/Kconfig +++ b/subsys/net/ip/Kconfig @@ -20,6 +20,28 @@ config NET_RAW_MODE if !NET_RAW_MODE +choice + prompt "Qemu networking" + default NET_QEMU_SLIP + depends on QEMU_TARGET + help + Can be used to select how the network connectivity is established + from inside qemu to host system. This can be done either via + serial connection (SLIP) or via Qemu ethernet driver. + +config NET_QEMU_SLIP + bool "SLIP" + help + Connect to host or to another Qemu via SLIP. + +config NET_QEMU_ETHERNET + bool "Ethernet" + help + Connect to host system via Qemu ethernet driver support. One such + driver that Zephyr supports is Intel e1000 ethernet driver. + +endchoice + config NET_INIT_PRIO int default 90 @@ -355,6 +377,7 @@ config NET_TEST config NET_SLIP_TAP bool "TAP SLIP driver" + depends on NET_QEMU_SLIP select SLIP select UART_PIPE select UART_INTERRUPT_DRIVEN