Skip to content

Commit 915583b

Browse files
committed
mbed_retarget: Make filehandles optional to reduce code size
The retarget code allocates an array of FileHandle* for console and file handling (filehandles). A tiny target only needs a console (putc/getc). There is no need for file handling. The POSIX layer and the array of FileHandle* is not required for small targets that only need a console ; this code should be optionally compiled out if the configuration parameter `platform.stdio-console-only` is selected instead of `platform-stdio-buffered-serial`.
1 parent 83fca60 commit 915583b

File tree

3 files changed

+165
-2
lines changed

3 files changed

+165
-2
lines changed

platform/mbed_lib.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
"value": false
1717
},
1818

19+
"stdio-minimal-console-only": {
20+
"help": "(Applies if target.console-uart is true.) Enable this instead of `stdio-buffered-serial` if filehandles are not required to access the serial interface as console to only to print.",
21+
"value": false
22+
},
23+
1924
"stdio-baud-rate": {
2025
"help": "(Applies if target.console-uart is true.) Baud rate for stdio",
2126
"value": 9600

platform/mbed_retarget.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,6 +586,10 @@ extern "C" {
586586
long telldir(DIR *);
587587
void seekdir(DIR *, long);
588588
int mkdir(const char *name, mode_t n);
589+
#if MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY
590+
ssize_t minimal_console_putc(const void *buffer, size_t length);
591+
ssize_t minimal_console_getc(void *buffer, size_t length);
592+
#endif // MBED_CONF_PLATFORM_STDIO_MINIMAL_CONSOLE_ONLY
589593
#if __cplusplus
590594
}; // extern "C"
591595

0 commit comments

Comments
 (0)