Skip to content

nsh: Decouple with CONFIG_FILE_STREAM - #1559

Merged
xiaoxiang781216 merged 1 commit into
apache:masterfrom
no1wudi:master
Feb 22, 2023
Merged

nsh: Decouple with CONFIG_FILE_STREAM#1559
xiaoxiang781216 merged 1 commit into
apache:masterfrom
no1wudi:master

Conversation

@no1wudi

@no1wudi no1wudi commented Feb 10, 2023

Copy link
Copy Markdown
Contributor

Summary

Replace all fwrite/fread/fgets/... to write/read/... .

Before:

       text    data     bss     dec     hex filename
 109827     601    6608  117036   1c92c nuttx/nuttx

After:

       text    data     bss     dec     hex filename
108053     601    6608  115262   1c23e nuttx/nuttx

After with CONFIG_FILE_STREAM disabled:

       text    data     bss     dec     hex filename
 105667     601    6608  112876   1b8ec nuttx/nuttx

Impact

nsh

Testing

QEMU

@xiaoxiang781216

Copy link
Copy Markdown
Contributor

CI break is fixed by apache/nuttx#8498

Comment thread nshlib/nsh.h Outdated
Comment thread nshlib/nsh_altconsole.c Outdated
Comment thread nshlib/nsh_altconsole.c Outdated
Comment thread nshlib/nsh_altconsole.c Outdated
Comment thread nshlib/nsh_altconsole.c Outdated
@no1wudi
no1wudi force-pushed the master branch 2 times, most recently from b42d4c9 to 78b6b8b Compare February 11, 2023 14:48
Comment thread system/readline/readline_fd.c
Comment thread system/readline/readline_fd.c
Comment thread nshlib/nsh_script.c Outdated
Comment thread nshlib/nsh_script.c Outdated
Comment thread nshlib/nsh_script.c Outdated
Comment thread nshlib/nsh_parse.c Outdated
Comment thread nshlib/nsh_console.c Outdated
Comment thread nshlib/nsh_console.c Outdated
Comment thread nshlib/nsh_console.c Outdated
Comment thread nshlib/nsh_console.c Outdated
@no1wudi
no1wudi force-pushed the master branch 7 times, most recently from a76f7e6 to 28ddefe Compare February 13, 2023 12:15
Comment thread system/readline/readline_common.c Outdated
Comment thread system/readline/readline_common.c Outdated
Comment thread system/readline/readline_fd.c
Comment thread nshlib/nsh_telnetlogin.c Outdated
Comment thread nshlib/nsh_telnetlogin.c Outdated
Comment thread nshlib/nsh_telnetlogin.c Outdated
Comment thread nshlib/nsh_console.c Outdated
Comment thread nshlib/nsh_console.c
Comment thread nshlib/nsh_console.c Outdated
@no1wudi
no1wudi force-pushed the master branch 2 times, most recently from e3cd73e to 6b8ac4d Compare February 16, 2023 05:52
@no1wudi

no1wudi commented Feb 16, 2023

Copy link
Copy Markdown
Contributor Author

Split to 2 PR (readline relative and nsh)

@no1wudi
no1wudi force-pushed the master branch 3 times, most recently from 4396ea7 to 3fab20d Compare February 20, 2023 08:54
@no1wudi no1wudi closed this Feb 21, 2023
@no1wudi

no1wudi commented Feb 23, 2023

Copy link
Copy Markdown
Contributor Author

@masayuki2009 Which board/config used in your testing ? Could you check the CONFIG_TELNET_TXBUFFER_SIZE value ?

xiaoxiang781216 added a commit to xiaoxiang781216/nuttx-apps that referenced this pull request Feb 23, 2023
continue the change from apache#1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
xiaoxiang781216 added a commit to xiaoxiang781216/nuttx-apps that referenced this pull request Feb 23, 2023
continue the change from apache#1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
@no1wudi

no1wudi commented Feb 23, 2023

Copy link
Copy Markdown
Contributor Author

@masayuki2009 Which board/config used in your testing ? Could you check the CONFIG_TELNET_TXBUFFER_SIZE value ?

I've tested telnetd on esp32c3-devkit, and I can't reproduce this behavior on it.

@masayuki2009

Copy link
Copy Markdown
Contributor

@no1wudi
I’m on holiday today so I can not confirm the config now.
However, the above movies were based on spresense:wifi_smp

xiaoxiang781216 added a commit to xiaoxiang781216/nuttx-apps that referenced this pull request Feb 23, 2023
continue the change from apache#1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
xiaoxiang781216 added a commit to xiaoxiang781216/nuttx-apps that referenced this pull request Feb 23, 2023
continue the change from apache#1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
@masayuki2009

Copy link
Copy Markdown
Contributor

@no1wudi

Could you check the CONFIG_TELNET_TXBUFFER_SIZE value

$ grep -i CONFIG_TELNET_TX .config
CONFIG_TELNET_TXBUFFER_SIZE=256

xiaoxiang781216 added a commit to xiaoxiang781216/nuttx-apps that referenced this pull request Feb 23, 2023
continue the change from apache#1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
xiaoxiang781216 added a commit to xiaoxiang781216/nuttx-apps that referenced this pull request Feb 23, 2023
continue the change from apache#1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
@masayuki2009

Copy link
Copy Markdown
Contributor

@no1wudi

However, the above movies were based on spresense:wifi_smp

The same issue happens with spresense:rndis_smp too.

@masayuki2009

Copy link
Copy Markdown
Contributor

@no1wudi
The same issue also happens with rv-virt:netnsh_smp (qemu) on ubuntu 18.04 (x86_64)
However, the host PC is fast so the symptom is not worse than the spresense.

@masayuki2009

Copy link
Copy Markdown
Contributor

@no1wudi
As for esp32-devkitc, I found out how to reproduce the issue.
Please try wapi_smp without CONFIG_NET_TCP_WRITE_BUFFERS=y.
You would see the same symptom as spresense:wifi_smp
In this case (i.e. esp32-devkitc:wapi_smp without CONFIG_NET_TCP_WRITE_BUFFERS=y), reverting this PR would not cause the issue.

--- a/boards/xtensa/esp32/esp32-devkitc/configs/wapi_smp/defconfig
+++ b/boards/xtensa/esp32/esp32-devkitc/configs/wapi_smp/defconfig
@@ -67,7 +67,6 @@ CONFIG_NET_ICMP=y
 CONFIG_NET_ICMP_SOCKET=y
 CONFIG_NET_STATISTICS=y
 CONFIG_NET_TCP=y
-CONFIG_NET_TCP_WRITE_BUFFERS=y
 CONFIG_NET_UDP=y
 CONFIG_NFS=y
 CONFIG_NSH_ARCHINIT=y

@no1wudi

no1wudi commented Feb 24, 2023

Copy link
Copy Markdown
Contributor Author

@masayuki2009 Thanks for your information, I'll continue debug it.

@no1wudi

no1wudi commented Feb 24, 2023

Copy link
Copy Markdown
Contributor Author

@no1wudi As for esp32-devkitc, I found out how to reproduce the issue. Please try wapi_smp without CONFIG_NET_TCP_WRITE_BUFFERS=y. You would see the same symptom as spresense:wifi_smp In this case (i.e. esp32-devkitc:wapi_smp without CONFIG_NET_TCP_WRITE_BUFFERS=y), reverting this PR would not cause the issue.

BTW, in my test, I'm using esp32c3-devkit, is'a single core chip.

@masayuki2009

Copy link
Copy Markdown
Contributor

BTW, in my test, I'm using esp32c3-devkit, is'a single core chip.

I've just confirmed that non-SMP can reproduce the issue too.

--- a/boards/xtensa/esp32/esp32-devkitc/configs/wapi_smp/defconfig
+++ b/boards/xtensa/esp32/esp32-devkitc/configs/wapi_smp/defconfig
@@ -67,7 +67,6 @@ CONFIG_NET_ICMP=y
 CONFIG_NET_ICMP_SOCKET=y
 CONFIG_NET_STATISTICS=y
 CONFIG_NET_TCP=y
-CONFIG_NET_TCP_WRITE_BUFFERS=y
 CONFIG_NET_UDP=y
 CONFIG_NFS=y
 CONFIG_NSH_ARCHINIT=y
@@ -89,8 +88,6 @@ CONFIG_RTC_DRIVER=y
 CONFIG_RTC_NALARMS=2
 CONFIG_SCHED_LPWORK=y
 CONFIG_SIG_DEFAULT=y
-CONFIG_SMP=y
-CONFIG_SMP_NCPUS=2
 CONFIG_SPI=y
 CONFIG_SPIFFS_NAME_MAX=48
 CONFIG_STACK_COLORATION=y

@no1wudi

no1wudi commented Feb 24, 2023

Copy link
Copy Markdown
Contributor Author

@masayuki2009 The root case is that write ops in telnet driver is nearly unbuffered ,so there are many 1 byte write to socket without stdio's buffer , I'll fix it soon.

GUIDINGLI pushed a commit that referenced this pull request Feb 24, 2023
continue the change from #1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
anchao pushed a commit to anchao/nuttx-apps that referenced this pull request Mar 6, 2023
continue the change from apache#1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
acassis added a commit to apache/nuttx that referenced this pull request Jun 26, 2026
The audio tone generator stopped working with the 'echo' command
since apache/nuttx-apps#1559

Before that PR:

nsh> echo "t120o1l16b9n0baan0bn0bn0baaan0b9n0baan0b" > /dev/tone0
tone_write: Received 41 bytes
nsh>

After that PR:

nsh> echo "t120o1l16b9n0baan0bn0bn0baaan0b9n0baan0b" > /dev/tone0
tone_write: Received 40 bytes
tone_write: Received 1 bytes
nsh>

Unfortunately the Audio Tone was not block new write attempts even
when it was already playing a melody.

This commit fix it and avoids the issue caused by that PR.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
michallenc pushed a commit that referenced this pull request Jun 27, 2026
This commit fixes the previous behavior where an echo with a
single string and its default new line is send as single write().

This issue came from:  #1559

Signed-off-by: Alan C. Assis <acassis@gmail.com>
acassis added a commit to apache/nuttx that referenced this pull request Jul 2, 2026
The audio tone generator stopped working with the 'echo' command
since apache/nuttx-apps#1559

Before that PR:

nsh> echo "t120o1l16b9n0baan0bn0bn0baaan0b9n0baan0b" > /dev/tone0
tone_write: Received 41 bytes
nsh>

After that PR:

nsh> echo "t120o1l16b9n0baan0bn0bn0baaan0b9n0baan0b" > /dev/tone0
tone_write: Received 40 bytes
tone_write: Received 1 bytes
nsh>

Unfortunately the Audio Tone was not block new write attempts even
when it was already playing a melody.

This commit fix it and avoids the issue caused by that PR.

Signed-off-by: Alan C. Assis <acassis@gmail.com>
crafcat7 pushed a commit to crafcat7/vela-nuttx-apps that referenced this pull request Jul 14, 2026
continue the change from apache/nuttx-apps#1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
crafcat7 pushed a commit to crafcat7/vela-nuttx-apps that referenced this pull request Jul 14, 2026
continue the change from apache/nuttx-apps#1559

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
xiaoxiang781216 pushed a commit that referenced this pull request Aug 4, 2026
This commit fixes the previous behavior where an echo with a
single string and its default new line is send as single write().

This issue came from:  #1559

Signed-off-by: Alan C. Assis <acassis@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants