Merge pull request #12981 from miri64/native/feat/stdio
stdio_native: initial import
This commit is contained in:
commit
501e700a3d
@ -423,7 +423,7 @@ ifneq (,$(filter newlib,$(USEMODULE)))
|
|||||||
ifeq (,$(filter newlib_syscalls_%,$(USEMODULE)))
|
ifeq (,$(filter newlib_syscalls_%,$(USEMODULE)))
|
||||||
USEMODULE += newlib_syscalls_default
|
USEMODULE += newlib_syscalls_default
|
||||||
endif
|
endif
|
||||||
ifeq (,$(filter stdio_cdc_acm stdio_null stdio_rtt,$(USEMODULE)))
|
ifeq (,$(filter stdio_cdc_acm stdio_native stdio_null stdio_rtt,$(USEMODULE)))
|
||||||
USEMODULE += stdio_uart
|
USEMODULE += stdio_uart
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|||||||
@ -15,6 +15,10 @@ ifneq (,$(filter socket_zep,$(USEMODULE)))
|
|||||||
DIRS += socket_zep
|
DIRS += socket_zep
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq (,$(filter stdio_native,$(USEMODULE)))
|
||||||
|
DIRS += stdio_native
|
||||||
|
endif
|
||||||
|
|
||||||
ifneq (,$(filter mtd_native,$(USEMODULE)))
|
ifneq (,$(filter mtd_native,$(USEMODULE)))
|
||||||
DIRS += mtd
|
DIRS += mtd
|
||||||
endif
|
endif
|
||||||
|
|||||||
@ -1,3 +1,6 @@
|
|||||||
ifneq (,$(filter periph_spi,$(USEMODULE)))
|
ifneq (,$(filter periph_spi,$(USEMODULE)))
|
||||||
USEMODULE += periph_spidev_linux
|
USEMODULE += periph_spidev_linux
|
||||||
endif
|
endif
|
||||||
|
ifeq (,$(filter stdio_%,$(USEMODULE)))
|
||||||
|
USEMODULE += stdio_native
|
||||||
|
endif
|
||||||
|
|||||||
@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include "board_internal.h"
|
#include "board_internal.h"
|
||||||
#include "native_internal.h"
|
#include "native_internal.h"
|
||||||
|
#include "stdio_base.h"
|
||||||
#include "tty_uart.h"
|
#include "tty_uart.h"
|
||||||
|
|
||||||
#include "periph/init.h"
|
#include "periph/init.h"
|
||||||
@ -399,6 +400,8 @@ static void _reset_handler(void)
|
|||||||
__attribute__((constructor)) static void startup(int argc, char **argv, char **envp)
|
__attribute__((constructor)) static void startup(int argc, char **argv, char **envp)
|
||||||
{
|
{
|
||||||
_native_init_syscalls();
|
_native_init_syscalls();
|
||||||
|
/* initialize stdio as early as possible */
|
||||||
|
stdio_init();
|
||||||
|
|
||||||
_native_argv = argv;
|
_native_argv = argv;
|
||||||
_progname = argv[0];
|
_progname = argv[0];
|
||||||
|
|||||||
1
cpu/native/stdio_native/Makefile
Normal file
1
cpu/native/stdio_native/Makefile
Normal file
@ -0,0 +1 @@
|
|||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
39
cpu/native/stdio_native/stdio_native.c
Normal file
39
cpu/native/stdio_native/stdio_native.c
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Freie Universität Berlin
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @author Martine S. Lenders <m.lenders@fu-berlin.de>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kernel_defines.h"
|
||||||
|
#include "native_internal.h"
|
||||||
|
#include "vfs.h"
|
||||||
|
|
||||||
|
#include "stdio_base.h"
|
||||||
|
|
||||||
|
void stdio_init(void)
|
||||||
|
{
|
||||||
|
if (IS_USED(MODULE_VFS)) {
|
||||||
|
vfs_bind_stdio();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t stdio_read(void* buffer, size_t max_len)
|
||||||
|
{
|
||||||
|
return real_read(STDIN_FILENO, buffer, max_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
ssize_t stdio_write(const void* buffer, size_t len)
|
||||||
|
{
|
||||||
|
return real_write(STDOUT_FILENO, buffer, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @} */
|
||||||
7
tests/vfs_plus_stdio/Makefile
Normal file
7
tests/vfs_plus_stdio/Makefile
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
DEVELHELP=0
|
||||||
|
include ../Makefile.tests_common
|
||||||
|
|
||||||
|
USEMODULE += vfs
|
||||||
|
USEMODULE += fmt
|
||||||
|
|
||||||
|
include $(RIOTBASE)/Makefile.include
|
||||||
27
tests/vfs_plus_stdio/main.c
Normal file
27
tests/vfs_plus_stdio/main.c
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2019 Freie Universität Berlin
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup tests
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief Tests VFS together with stdio on a board
|
||||||
|
*
|
||||||
|
* @author Martine S. Lenders <m.lenders@fu-berlin.de>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "fmt.h"
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
print_str("SUCCESS\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
18
tests/vfs_plus_stdio/tests/01-run.py
Executable file
18
tests/vfs_plus_stdio/tests/01-run.py
Executable file
@ -0,0 +1,18 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Copyright (C) 2019 Freie Universität Berlin
|
||||||
|
#
|
||||||
|
# This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
# General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
# directory for more details.
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from testrunner import run
|
||||||
|
|
||||||
|
|
||||||
|
def testfunc(child):
|
||||||
|
child.expect_exact('SUCCESS')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(run(testfunc, timeout=1))
|
||||||
Loading…
x
Reference in New Issue
Block a user