Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usrsock:refine usrsock's architecture #6949

Merged
merged 1 commit into from
Sep 9, 2022

Conversation

ethanlcz
Copy link
Contributor

@ethanlcz ethanlcz commented Aug 29, 2022

Summary

Seperate usrsock device driver with usrsock core function layer
to make it more flexiable to adopt other kind of usrsock interface driver

Impact

Code refactor only, the behaviour should be same as before

Testing

@xiaoxiang781216
Copy link
Contributor

@ethanlcz please fetch the last code and rebase your change.

@ethanlcz
Copy link
Contributor Author

@ethanlcz please fetch the last code and rebase your change.

done

@masayuki2009
Copy link
Contributor

masayuki2009 commented Aug 29, 2022

@ethanlcz, @xiaoxiang781216
Before refining the usrsock architecture, I think we need to pass apps/examples/usrsocktest first.

net/usrsock/usrsock_dev.c Outdated Show resolved Hide resolved
net/usrsock/usrsock_dev.c Show resolved Hide resolved
xiaoxiang781216 added a commit to xiaoxiang781216/incubator-nuttx-apps that referenced this pull request Aug 29, 2022
fix the conflict after usrsock reconstruct:
apache/nuttx#6949

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
@xiaoxiang781216
Copy link
Contributor

The break is fixed here: apache/nuttx-apps#1301

masayuki2009 pushed a commit to apache/nuttx-apps that referenced this pull request Aug 29, 2022
fix the conflict after usrsock reconstruct:
apache/nuttx#6949

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
net/usrsock/usrsock_dev.c Outdated Show resolved Hide resolved
net/usrsock/usrsock_dev.c Outdated Show resolved Hide resolved
@masayuki2009
Copy link
Contributor

@ethanlcz
I tried this PR with spresense:wifi_smp but it does not work.

NuttShell (NSH)
nsh> uname -a
NuttX  0.0.0 6bb1c0902d Aug 30 2022 14:01:59 arm spresense
nsh> ps
  PID GROUP CPU PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK   STACK   USED  FILLED COMMAND
    0     0   0   0 FIFO     Kthread N-- Assigned           00000000 001000 000456  45.6%  CPU0 IDLE
    1     1   1   0 FIFO     Kthread N-- Running            00000000 001000 000228  22.8%  CPU1 IDLE
    2     2 --- 224 RR       Kthread --- Waiting  Signal    00000000 001992 000476  23.8%  hpwork 0x2d057324
    3     3 ---  60 RR       Kthread --- Waiting  Semaphore 00000000 001992 000284  14.2%  lpwork 0x2d057334
    5     5 --- 200 RR       Task    --- Waiting  MQ empty  00000000 000976 000472  48.3%  cxd56_pm_task
    6     6   0 100 RR       Task    --- Running            00000000 003024 001240  41.0%  spresense_main
nsh> free
                   total       used       free    largest  nused  nfree
        Umem:    1201120      41872    1159248    1157360    119      2
nsh> mount
  /mnt/spif type smartfs
  /proc type procfs
nsh> ifconfig
wlan0	Link encap:Ethernet HWaddr 00:00:00:00:00:00 at UP
	inet addr:0.0.0.0 DRaddr:0.0.0.0 Mask:0.0.0.0

nsh> gs2200m raspi3-g wifi-test-24g & 
gs2200m [7:50]
nsh> renew wlan0
Traceback (most recent call last):
  File "/home/ishikawa/script/expect_nuttx_wifi_streaming_test.py", line 39, in <module>
    child.expect('nsh> ', timeout=7)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/spawnbase.py", line 344, in expect
    timeout, searchwindowsize, async_)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/spawnbase.py", line 372, in expect_list
    return exp.expect_loop(timeout)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/expect.py", line 181, in expect_loop
    return self.timeout(e)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/expect.py", line 144, in timeout

@ethanlcz
Copy link
Contributor Author

@ethanlcz I tried this PR with spresense:wifi_smp but it does not work.

NuttShell (NSH)
nsh> uname -a
NuttX  0.0.0 6bb1c0902d Aug 30 2022 14:01:59 arm spresense
nsh> ps
  PID GROUP CPU PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK   STACK   USED  FILLED COMMAND
    0     0   0   0 FIFO     Kthread N-- Assigned           00000000 001000 000456  45.6%  CPU0 IDLE
    1     1   1   0 FIFO     Kthread N-- Running            00000000 001000 000228  22.8%  CPU1 IDLE
    2     2 --- 224 RR       Kthread --- Waiting  Signal    00000000 001992 000476  23.8%  hpwork 0x2d057324
    3     3 ---  60 RR       Kthread --- Waiting  Semaphore 00000000 001992 000284  14.2%  lpwork 0x2d057334
    5     5 --- 200 RR       Task    --- Waiting  MQ empty  00000000 000976 000472  48.3%  cxd56_pm_task
    6     6   0 100 RR       Task    --- Running            00000000 003024 001240  41.0%  spresense_main
nsh> free
                   total       used       free    largest  nused  nfree
        Umem:    1201120      41872    1159248    1157360    119      2
nsh> mount
  /mnt/spif type smartfs
  /proc type procfs
nsh> ifconfig
wlan0	Link encap:Ethernet HWaddr 00:00:00:00:00:00 at UP
	inet addr:0.0.0.0 DRaddr:0.0.0.0 Mask:0.0.0.0

nsh> gs2200m raspi3-g wifi-test-24g & 
gs2200m [7:50]
nsh> renew wlan0
Traceback (most recent call last):
  File "/home/ishikawa/script/expect_nuttx_wifi_streaming_test.py", line 39, in <module>
    child.expect('nsh> ', timeout=7)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/spawnbase.py", line 344, in expect
    timeout, searchwindowsize, async_)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/spawnbase.py", line 372, in expect_list
    return exp.expect_loop(timeout)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/expect.py", line 181, in expect_loop
    return self.timeout(e)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/expect.py", line 144, in timeout

I will try this project later after I get the test board.

@masayuki2009
Copy link
Contributor

I will try this project later after I get the test board.
@ethanlcz
Please change this PR to Draft.

@ethanlcz
Copy link
Contributor Author

@ethanlcz I tried this PR with spresense:wifi_smp but it does not work.

NuttShell (NSH)
nsh> uname -a
NuttX  0.0.0 6bb1c0902d Aug 30 2022 14:01:59 arm spresense
nsh> ps
  PID GROUP CPU PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK   STACK   USED  FILLED COMMAND
    0     0   0   0 FIFO     Kthread N-- Assigned           00000000 001000 000456  45.6%  CPU0 IDLE
    1     1   1   0 FIFO     Kthread N-- Running            00000000 001000 000228  22.8%  CPU1 IDLE
    2     2 --- 224 RR       Kthread --- Waiting  Signal    00000000 001992 000476  23.8%  hpwork 0x2d057324
    3     3 ---  60 RR       Kthread --- Waiting  Semaphore 00000000 001992 000284  14.2%  lpwork 0x2d057334
    5     5 --- 200 RR       Task    --- Waiting  MQ empty  00000000 000976 000472  48.3%  cxd56_pm_task
    6     6   0 100 RR       Task    --- Running            00000000 003024 001240  41.0%  spresense_main
nsh> free
                   total       used       free    largest  nused  nfree
        Umem:    1201120      41872    1159248    1157360    119      2
nsh> mount
  /mnt/spif type smartfs
  /proc type procfs
nsh> ifconfig
wlan0	Link encap:Ethernet HWaddr 00:00:00:00:00:00 at UP
	inet addr:0.0.0.0 DRaddr:0.0.0.0 Mask:0.0.0.0

nsh> gs2200m raspi3-g wifi-test-24g & 
gs2200m [7:50]
nsh> renew wlan0
Traceback (most recent call last):
  File "/home/ishikawa/script/expect_nuttx_wifi_streaming_test.py", line 39, in <module>
    child.expect('nsh> ', timeout=7)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/spawnbase.py", line 344, in expect
    timeout, searchwindowsize, async_)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/spawnbase.py", line 372, in expect_list
    return exp.expect_loop(timeout)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/expect.py", line 181, in expect_loop
    return self.timeout(e)
  File "/home/ishikawa/.local/lib/python3.6/site-packages/pexpect/expect.py", line 144, in timeout

I will try this project later after I get the test board.

I tried both spresense:wifi_smp and spresense:wifi, but the board fail to bootup, uart log show the following assert information:
Terminal ready
[ 0.420000] up_assert: Assertion failed at file:wireless/gs2200m.c line: 897 task: lpwork
[ 0.420000] up_assert: Assertion failed at file:armv7-m/arm_hardfault.c line: 173 task: lpwork

It seems the communication between spresense board and GS2200M modules goes wrong.
I connect spresense board and GS2200M according to the following picture.
Do you have any idea how to fix this?
image

@masayuki2009
Copy link
Contributor

@ethanlcz
Can you try to add CONFIG_WIFI_BOARD_IS110B_HARDWARE_VERSION_10C=y to defconfig?
If it still does not work, try CONFIG_WIFI_BOARD_IS110B_HARDWARE_VERSION_10B=y

@ethanlcz
Copy link
Contributor Author

gs2200m

Thanks Masayuki !
It works after set "CONFIG_WIFI_BOARD_IS110B_HARDWARE_VERSION_10C=y".

@xiaoxiang781216 xiaoxiang781216 marked this pull request as draft August 31, 2022 05:50
@ethanlcz ethanlcz force-pushed the usrsock_refactor branch 2 times, most recently from b032d4d to 902f698 Compare September 1, 2022 04:23
@xiaoxiang781216
Copy link
Contributor

@ethanlcz need rebase the change again.

@ethanlcz ethanlcz force-pushed the usrsock_refactor branch 2 times, most recently from 1aabad5 to d125639 Compare September 6, 2022 08:57
@ethanlcz
Copy link
Contributor Author

ethanlcz commented Sep 6, 2022

@masayuki2009 spresense:wifi_smp should work with latest patchset now.

@ethanlcz
Copy link
Contributor Author

ethanlcz commented Sep 7, 2022

@ethanlcz Please do not merge the master into your branch but rebase the master on your branch.

done

@masayuki2009
Copy link
Contributor

@hmm,

The assertion still happens with the latest code.
Could you provide the following info?

I'm using the following defconfig and run the nuttx sim on Ubuntu 18.04 x86_64.
What OS are you using to test the nuttx sim?

@ethanlcz
Copy link
Contributor Author

ethanlcz commented Sep 8, 2022

@hmm,

The assertion still happens with the latest code. Could you provide the following info?

I'm using the following defconfig and run the nuttx sim on Ubuntu 18.04 x86_64.
What OS are you using to test the nuttx sim?

I can reproduce it now with all the following options enabled(last time I only enabled CONFIG_DEBUG_ASSERTIONS=y), let me check what happened.

CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_ERROR=y
CONFIG_DEBUG_FEATURES=y
CONFIG_NDEBUG=y

@ethanlcz
Copy link
Contributor Author

ethanlcz commented Sep 8, 2022

@xiaoxiang781216 @masayuki2009
Please help to review again.
The patch passed all usrsocktest cases without assert now.
Thanks!

@xiaoxiang781216
Copy link
Contributor

LGTM, @masayuki2009 could you try it again? Thanks.

@masayuki2009
Copy link
Contributor

@ethanlcz
Because #7039 has just been merged, could you rebase again?

@ethanlcz
Copy link
Contributor Author

ethanlcz commented Sep 8, 2022

@ethanlcz Because #7039 has just been merged, could you rebase again?

it's done.

@masayuki2009
Copy link
Contributor

@ethanlcz
I tried the latest PR with spresense:wifi_smp
However, it does not work with this PR.

Without this PR,

nsh> uname -a
NuttX  0.0.0 b6e76966b9 Sep  8 2022 18:41:20 arm spresense
nsh> ps
  PID GROUP CPU PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK   STACK   USED  FILLED COMMAND
    0     0   0   0 FIFO     Kthread N-- Assigned           00000000 001000 000456  45.6%  CPU0 IDLE
    1     1   1   0 FIFO     Kthread N-- Running            00000000 001000 000228  22.8%  CPU1 IDLE
    2     2 --- 224 RR       Kthread --- Waiting  Signal    00000000 001992 000492  24.6%  hpwork 0x2d057c74
    3     3 ---  60 RR       Kthread --- Waiting  Semaphore 00000000 001992 000300  15.0%  lpwork 0x2d057c84
    5     5 --- 200 RR       Task    --- Waiting  MQ empty  00000000 000976 000472  48.3%  cxd56_pm_task
    6     6   0 100 RR       Task    --- Running            00000000 003024 001404  46.4%  spresense_main
nsh> free
                   total       used       free    largest  nused  nfree
        Umem:    1200400      41872    1158528    1156640    119      2
nsh> mount
  /mnt/spif type smartfs
  /proc type procfs
nsh> ifconfig
nsh> gs2200m raspi3-g wifi-test-24g & 
gs2200m [7:50]
nsh> renew wlan0
nsh> ntpcstart
Started the NTP daemon as PID=24
nsh> ls -l /proc/net
/proc/net:
 -r--r--r--       0 wlan0
nsh> ifconfig
wlan0	Link encap:Ethernet HWaddr 3c:95:09:00:89:96 at UP
	inet addr:192.168.10.22 DRaddr:192.168.10.1 Mask:255.255.255.0

With this PR,

nsh> uname -a
NuttX  0.0.0 5264777f24 Sep  8 2022 18:45:51 arm spresense
nsh> ps
  PID GROUP CPU PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK   STACK   USED  FILLED COMMAND
    0     0   0   0 FIFO     Kthread N-- Assigned           00000000 001000 000456  45.6%  CPU0 IDLE
    1     1   1   0 FIFO     Kthread N-- Running            00000000 001000 000228  22.8%  CPU1 IDLE
    2     2 --- 224 RR       Kthread --- Waiting  Signal    00000000 001992 000492  24.6%  hpwork 0x2d057d0c
    3     3 ---  60 RR       Kthread --- Waiting  Semaphore 00000000 001992 000300  15.0%  lpwork 0x2d057d1c
    5     5 --- 200 RR       Task    --- Waiting  MQ empty  00000000 000976 000472  48.3%  cxd56_pm_task
    6     6   0 100 RR       Task    --- Running            00000000 003024 001240  41.0%  spresense_main
nsh> free
                   total       used       free    largest  nused  nfree
        Umem:    1200400      41872    1158528    1156640    119      2
nsh> mount
  /mnt/spif type smartfs
  /proc type procfs
nsh> ifconfig
nsh> gs2200m raspi3-g wifi-test-24g & 
gs2200m [7:50]
nsh> renew wlan0
nsh> ntpcstart
Started the NTP daemon as PID=24
nsh> ls -l /proc/net
/proc/net:

@ethanlcz
Copy link
Contributor Author

ethanlcz commented Sep 9, 2022

@ethanlcz I tried the latest PR with spresense:wifi_smp However, it does not work with this PR.

Without this PR,

nsh> uname -a
NuttX  0.0.0 b6e76966b9 Sep  8 2022 18:41:20 arm spresense
nsh> ps
  PID GROUP CPU PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK   STACK   USED  FILLED COMMAND
    0     0   0   0 FIFO     Kthread N-- Assigned           00000000 001000 000456  45.6%  CPU0 IDLE
    1     1   1   0 FIFO     Kthread N-- Running            00000000 001000 000228  22.8%  CPU1 IDLE
    2     2 --- 224 RR       Kthread --- Waiting  Signal    00000000 001992 000492  24.6%  hpwork 0x2d057c74
    3     3 ---  60 RR       Kthread --- Waiting  Semaphore 00000000 001992 000300  15.0%  lpwork 0x2d057c84
    5     5 --- 200 RR       Task    --- Waiting  MQ empty  00000000 000976 000472  48.3%  cxd56_pm_task
    6     6   0 100 RR       Task    --- Running            00000000 003024 001404  46.4%  spresense_main
nsh> free
                   total       used       free    largest  nused  nfree
        Umem:    1200400      41872    1158528    1156640    119      2
nsh> mount
  /mnt/spif type smartfs
  /proc type procfs
nsh> ifconfig
nsh> gs2200m raspi3-g wifi-test-24g & 
gs2200m [7:50]
nsh> renew wlan0
nsh> ntpcstart
Started the NTP daemon as PID=24
nsh> ls -l /proc/net
/proc/net:
 -r--r--r--       0 wlan0
nsh> ifconfig
wlan0	Link encap:Ethernet HWaddr 3c:95:09:00:89:96 at UP
	inet addr:192.168.10.22 DRaddr:192.168.10.1 Mask:255.255.255.0

With this PR,

nsh> uname -a
NuttX  0.0.0 5264777f24 Sep  8 2022 18:45:51 arm spresense
nsh> ps
  PID GROUP CPU PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK   STACK   USED  FILLED COMMAND
    0     0   0   0 FIFO     Kthread N-- Assigned           00000000 001000 000456  45.6%  CPU0 IDLE
    1     1   1   0 FIFO     Kthread N-- Running            00000000 001000 000228  22.8%  CPU1 IDLE
    2     2 --- 224 RR       Kthread --- Waiting  Signal    00000000 001992 000492  24.6%  hpwork 0x2d057d0c
    3     3 ---  60 RR       Kthread --- Waiting  Semaphore 00000000 001992 000300  15.0%  lpwork 0x2d057d1c
    5     5 --- 200 RR       Task    --- Waiting  MQ empty  00000000 000976 000472  48.3%  cxd56_pm_task
    6     6   0 100 RR       Task    --- Running            00000000 003024 001240  41.0%  spresense_main
nsh> free
                   total       used       free    largest  nused  nfree
        Umem:    1200400      41872    1158528    1156640    119      2
nsh> mount
  /mnt/spif type smartfs
  /proc type procfs
nsh> ifconfig
nsh> gs2200m raspi3-g wifi-test-24g & 
gs2200m [7:50]
nsh> renew wlan0
nsh> ntpcstart
Started the NTP daemon as PID=24
nsh> ls -l /proc/net
/proc/net:

Deadlock happened between net_lock and devsem(in usrsock_dev.c) and it is now fixed.

Seperate usrsock device driver with usrsock core function layer
to make it more flexiable to adopt other kind of usrsock interface driver

Signed-off-by: liangchaozhong <liangchaozhong@xiaomi.com>
@ethanlcz
Copy link
Contributor Author

ethanlcz commented Sep 9, 2022

@masayuki2009
Could you please help to review again?
Thanks!

@xiaoxiang781216
Copy link
Contributor

@masayuki2009 can the last version pass your test? @ethanlcz has more patches depend on this change.

@masayuki2009
Copy link
Contributor

@ethanlcz
The latest PR now works with spresense:wifi_smp.

@masayuki2009 masayuki2009 merged commit 644c4af into apache:master Sep 9, 2022
Shunichi-K pushed a commit to SPRESENSE/nuttx-apps that referenced this pull request Dec 12, 2022
anchao pushed a commit to anchao/nuttx-apps that referenced this pull request Feb 13, 2023
fix the conflict after usrsock reconstruct:
apache/nuttx#6949

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.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