• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..--

data/11-Mar-2024-105102

main/11-Mar-2024-10472

CMakeLists.txtD11-Mar-2024236 75

MakefileD11-Mar-2024183 92

README.mdD11-Mar-20242.8 KiB8059

sdkconfig.defaultsD11-Mar-202478 32

semihost_vfs_example_test.pyD11-Mar-20242.3 KiB6047

README.md

1# Semihosting VFS driver example
2
3(See the README.md file in the upper level 'examples' directory for more information about examples.)
4
5This example demonstrates how to use semihosting VFS driver with ESP32. Example does the following steps:
6
71. Uses `esp_vfs_semihost_register` function to register exposed host directory in VFS, enabling C standard library and POSIX functions to be used.
82. Redirects `stdout` from the UART to the file on the host using `freopen`.
93. Prints several messages to the redirected.
104. Switches back to UART `stdout` using `freopen`.
115. Opens text file on the host.
126. Reads the file and prints its content on stdout.
13
14## How to use example
15
16### Hardware and tools required
17
18This example does not require any special hardware, and can be run on any common development board.
19This example requires [OpenOCD](https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/jtag-debugging/index.html#run-openocd).
20NOTE: In order to run this example you need OpenOCD version `v0.10.0-esp32-20190313` or later.
21
22Run OpenOCD using command:
23```
24bin/openocd -s share/openocd/scripts -c 'set ESP_SEMIHOST_BASEDIR '$IDF_PATH/examples/storage/semihost_vfs/data -f board/esp32-wrover-kit-3.3v.cfg
25```
26This command also configures OpenOCD to expose example project `data` subdirectory to the target's semihosting VFS driver.
27
28### Build and flash
29
30Replace PORT with serial port name:
31
32```
33idf.py -p PORT flash monitor
34```
35
36(To exit the serial monitor, type ``Ctrl-]``.)
37
38See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects.
39
40## Example output
41
42There are two types of outputs produced by example:
431. File `esp32_stdout.txt` in the host directory mounted to the target:
44
45```
46W (274) example: Switched to semihosted stdout
47Semihosted stdout write 0
48Semihosted stdout write 1
49Semihosted stdout write 2
50...
51Semihosted stdout write 98
52Semihosted stdout write 99
53W (274) example: Switch to UART stdout
54```
55
562. On the boards console:
57
58```
59W (274) example: Switch to semihosted stdout
60W (274) example: Switched back to UART stdout
61I (274) example: Wrote 2798 bytes
62====================== HOST DATA START =========================
63The following are the graphical (non-control) characters defined by
64ISO 8859-1 (1987).  Descriptions in words aren't all that helpful,
65but they're the best we can do in text.  A graphics file illustrating
66the character set should be available from the same archive as this
67file.
68
69Hex Description                 Hex Description
70
7120  SPACE
72...
737D  RIGHT CURLY BRACKET         FD  SMALL LETTER Y WITH ACUTE
747E  TILDE                       FE  SMALL LETTER THORN (Icelandic)
75                                FF  SMALL LETTER Y WITH DIAERESIS
76====================== HOST DATA END =========================
77I (694) example: Read 6121 bytes
78```
79
80