Thanks to Xiang and Greg, I got Internet networking running in the
simulator.

Xiang, your configuration as you sent it didn't work for me, but using it
as a base with some modifications, I got the simulator to compile.
Then with some debugging and using your simbridge script, I was able to get
the simulator's network working. I had some problems with /dev/net/tun file
permissions and capabilities– apparently on Ubuntu (and maybe other recent
Linuxes?) to access /dev/net/tun as a regular user, the program has to have
the cap_net_admin capability. This is detailed in the Linux TUN/TAP Readme
<https://github.com/torvalds/linux/blob/master/Documentation/networking/tuntap.txt>.
I was able to get the nuttx simulator working as root. Then I got it
running as a regular user by doing this:

sudo chmod 0666 /dev/net/tun
> sudo setcap cap_net_admin+ep ./nuttx
>

I can execute the tcpecho command, so now I can use it as a comparison to
the SAMA5D36-Xplained board while debugging the GMAC.

I'm not using the simbridge.sh script, I wrote a different one based on it,
and instead of bridging I use local routes and iptables to let the nuttx
box access the Internet. (The simbridge.sh script caused some problems with
how I accessed my VMWare linux installation.)

I will write a more full guide to getting everything set up in the next few
days.

Thank you both for your help!

cheers
adam

On Mon, Feb 10, 2020 at 10:44 PM Adam Feuer <a...@starcat.io> wrote:

> Xiang,
>
> Thank you! It's late here in Seattle WA USA; I'll try it tomorrow!
>
> cheers
> adam
>
> On Mon, Feb 10, 2020 at 10:40 PM Xiang Xiao <xiaoxiang781...@gmail.com>
> wrote:
>
>> MAC is assigned through:
>> tapdev_init->set_macaddr->netdriver_setmacaddr
>>
>> netinit task is responsible for the networking initialization, so it
>> is a good indicator that the iniitaliation finish succesfully if ps
>> doesn't list it any more.
>>
>> Here is my config:
>> #
>> # This file is autogenerated: PLEASE DO NOT EDIT IT.
>> #
>> # You can use "make menuconfig" to make any modifications to the
>> installed .config file.
>> # You can then do "make savedefconfig" to generate a new defconfig
>> file that includes your
>> # modifications.
>> #
>> CONFIG_ARCH="sim"
>> CONFIG_ARCH_BOARD="sim"
>> CONFIG_ARCH_BOARD_SIM=y
>> CONFIG_ARCH_CHIP="sim"
>> CONFIG_ARCH_SIM=y
>> CONFIG_BOARDCTL_POWEROFF=y
>> CONFIG_BUILTIN=y
>> CONFIG_CLOCK_MONOTONIC=y
>> CONFIG_DEBUG_ASSERTIONS=y
>> CONFIG_DEBUG_ERROR=y
>> CONFIG_DEBUG_FEATURES=y
>> CONFIG_DEBUG_INFO=y
>> CONFIG_DEBUG_SYMBOLS=y
>> CONFIG_DEBUG_WARN=y
>> CONFIG_DEV_LOOP=y
>> CONFIG_DEV_ZERO=y
>> CONFIG_DRIVERS_VIDEO=y
>> CONFIG_ELF=y
>> CONFIG_EXAMPLES_FTPC=y
>> CONFIG_EXECFUNCS_HAVE_SYMTAB=y
>> CONFIG_FS_BINFS=y
>> CONFIG_FS_HOSTFS=y
>> CONFIG_FS_LITTLEFS=y
>> CONFIG_FS_PROCFS=y
>> CONFIG_FS_TMPFS=y
>> CONFIG_IDLETHREAD_STACKSIZE=2048
>> CONFIG_INPUT=y
>> CONFIG_IOB_NOTIFIER=y
>> CONFIG_LIBC_EXECFUNCS=y
>> CONFIG_LIBC_IOCTL_VARIADIC=y
>> CONFIG_LIBC_LOCALE=y
>> CONFIG_LIBC_LOCALTIME=y
>> CONFIG_LIBM=y
>> CONFIG_MTD=y
>> CONFIG_NET=y
>> CONFIG_NETDB_DNSCLIENT=y
>> CONFIG_NETDB_DNSCLIENT_MAXRESPONSE=176
>> CONFIG_NETDB_DNSCLIENT_RECV_TIMEOUT=3
>> CONFIG_NETDB_DNSSERVER_IPv4ADDR=0x771d1d1d
>> CONFIG_NETDEVICES=y
>> CONFIG_NETDEV_STATISTICS=y
>> CONFIG_NETINIT_DHCPC=y
>> CONFIG_NETINIT_THREAD=y
>> CONFIG_NETUTILS_DHCPC=y
>> CONFIG_NETUTILS_FTPC=y
>> CONFIG_NETUTILS_TELNETD=y
>> CONFIG_NETUTILS_TFTPC=y
>> CONFIG_NETUTILS_WEBCLIENT=y
>> CONFIG_NET_ARP_SEND=y
>> CONFIG_NET_BROADCAST=y
>> CONFIG_NET_ICMP=y
>> CONFIG_NET_ICMP_SOCKET=y
>> CONFIG_NET_ICMPv6=y
>> CONFIG_NET_ICMPv6_AUTOCONF=y
>> CONFIG_NET_ICMPv6_NEIGHBOR=y
>> CONFIG_NET_ICMPv6_SOCKET=y
>> CONFIG_NET_IPv6=y
>> CONFIG_NET_LOOPBACK=y
>> CONFIG_NET_SENDFILE=y
>> CONFIG_NET_SLIP=y
>> CONFIG_NET_SOLINGER=y
>> CONFIG_NET_STATISTICS=y
>> CONFIG_NET_TCP=y
>> CONFIG_NET_TCPBACKLOG=y
>> CONFIG_NET_TCP_WRITE_BUFFERS=y
>> CONFIG_NET_UDP=y
>> CONFIG_NET_UDP_BINDTODEVICE=y
>> CONFIG_NET_UDP_WRITE_BUFFERS=y
>> CONFIG_NSH_ARCHINIT=y
>> CONFIG_NSH_BUILTIN_APPS=y
>> CONFIG_NSH_FILE_APPS=y
>> CONFIG_NSH_READLINE=y
>> CONFIG_NSH_TELNETD_CLIENTSTACKSIZE=4096
>> CONFIG_POSIX_SPAWN_PROXY_STACKSIZE=2048
>> CONFIG_PSEUDOFS_SOFTLINKS=y
>> CONFIG_PSEUDOTERM=y
>> CONFIG_PSEUDOTERM_BSD=y
>> CONFIG_PTHREAD_CLEANUP=y
>> CONFIG_PTHREAD_CLEANUP_STACKSIZE=2
>> CONFIG_PTHREAD_MUTEX_TYPES=y
>> CONFIG_PTHREAD_STACK_DEFAULT=8192
>> CONFIG_RAMMTD=y
>> CONFIG_READLINE_CMD_HISTORY=y
>> CONFIG_READLINE_TABCOMPLETION=y
>> CONFIG_SCHED_CHILD_STATUS=y
>> CONFIG_SCHED_HAVE_PARENT=y
>> CONFIG_SCHED_HPWORK=y
>> CONFIG_SCHED_ONEXIT=y
>> CONFIG_SERIAL_TERMIOS=y
>> CONFIG_SIG_DEFAULT=y
>> CONFIG_SIG_EVTHREAD=y
>> CONFIG_SIM_M32=y
>> CONFIG_SIM_NET_BRIDGE=y
>> CONFIG_STACK_COLORATION=y
>> CONFIG_SYSLOG_BUFFER=y
>> CONFIG_SYSLOG_CHARDEV=y
>> CONFIG_SYSLOG_TIMESTAMP=y
>> CONFIG_SYSTEM_CLE=y
>> CONFIG_SYSTEM_NSH=y
>> CONFIG_SYSTEM_NSH_STACKSIZE=4096
>> CONFIG_SYSTEM_NTPC=y
>> CONFIG_SYSTEM_PING6=y
>> CONFIG_SYSTEM_PING6_STACKSIZE=4096
>> CONFIG_SYSTEM_PING=y
>> CONFIG_SYSTEM_PING_STACKSIZE=4096
>> CONFIG_SYSTEM_SYSTEM=y
>> CONFIG_SYSTEM_TELNET_CLIENT=y
>> CONFIG_SYSTEM_TELNET_CLIENT_STACKSIZE=4096
>> CONFIG_SYSTEM_TIME64=y
>> CONFIG_TELNET_CHARACTER_MODE=y
>> CONFIG_TTY_SIGINT=y
>> CONFIG_TTY_SIGSTP=y
>> CONFIG_USERMAIN_STACKSIZE=4096
>> CONFIG_USER_ENTRYPOINT="nsh_main"
>>
>> On Tue, Feb 11, 2020 at 2:18 PM Adam Feuer <a...@starcat.io> wrote:
>> >
>> > Xiang,
>> >
>> > Looks like attachments aren't making it through for some reason. Would
>> you
>> > be willing to just paste the config into an email message?
>> >
>> > BTW my ethernet interface isn't getting a MAC address... it's all 0's.
>> Your
>> > virtual ethernet has one. So something is wrong with the netinit for my
>> > interface.
>> >
>> > cheers
>> > adam
>> >
>> > On Mon, Feb 10, 2020 at 10:03 PM Xiang Xiao <xiaoxiang781...@gmail.com>
>> > wrote:
>> >
>> > > It's my full config, but to avoid the LittleVGL downloading, I remove
>> > > some graphic related config.
>> > > Here is my output with the latest mainline:
>> > > xiaoxiang@xiaoxiang-VirtualBox:~/nuttx/nuttx$ sudo ./nuttx
>> > >
>> > > NuttShell (NSH) NuttX-8.2
>> > > nsh> ps
>> > >   PID GROUP PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK
>> > > STACK   USED  FILLED COMMAND
>> > >     0     0   0 FIFO     Kthread N-- Ready              00000000
>> > > 000000 000000   0.0%  Idle Task
>> > >     1     1 224 FIFO     Kthread --- Waiting  Signal    00000000
>> > > 002032 000460  22.6%  hpwork
>> > >     2     1 100 FIFO     Kthread --- Waiting  Signal    00000000
>> > > 002032 000924  45.4%  lpwork
>> > >     3     1 100 FIFO     Task    --- Running            00000000
>> > > 004080 002096  51.3%  init
>> > >     5     4 100 FIFO     Task    --- Waiting  Semaphore 00000010
>> > > 002000 000804  40.2%  Telnet daemon 0x56623690
>> > >     6     4 100 FIFO     Task    --- Waiting  Semaphore 00000010
>> > > 002000 000804  40.2%  Telnet daemon 0x56624510
>> > >     7     4 100 FIFO     Task    --- Waiting  Semaphore 00000000
>> > > 002016 001828  90.6%! NTP daemon
>> > > nsh> ifconfig
>> > > eth0    Link encap:Ethernet HWaddr 42:09:36:15:9c:19 at UP
>> > >     inet addr:10.0.2.18 DRaddr:10.0.2.2 Mask:255.255.255.0
>> > >     inet6 addr: fe80::4009:36ff:fe15:9c19/64
>> > >     inet6 DRaddr: ::/64
>> > >
>> > >     RX: Received Fragment Errors
>> > >         00000014 00000000 00000000
>> > >         IPv4     IPv6     ARP      Dropped
>> > >         00000003 00000010 00000001 00000000
>> > >     TX: Queued   Sent     Errors   Timeouts
>> > >         00000012 00000012 00000000 00000000
>> > >     Total Errors: 00000000
>> > >
>> > > lo    Link encap:Local Loopback at UP
>> > >     inet addr:127.0.0.1 DRaddr:127.0.0.1 Mask:255.0.0.0
>> > >     inet6 addr: ::1/128
>> > >     inet6 DRaddr: ::1/128
>> > >
>> > >     RX: Received Fragment Errors
>> > >         00000000 00000000 00000000
>> > >         IPv4     IPv6     ARP      Dropped
>> > >         00000000 00000000 00000000 00000000
>> > >     TX: Queued   Sent     Errors   Timeouts
>> > >         00000000 00000000 00000000 00000000
>> > >     Total Errors: 00000000
>> > >
>> > >              IPv4  IPv6   TCP   UDP  ICMP  ICMPv6
>> > > Received     0003  0010  0000  0009  0000  000a
>> > > Dropped      0000  0000  0000  0000  0000  0008
>> > >   IPv4        VHL: 0000   Frg: 0000
>> > >   IPv6        VHL: 0000
>> > >   Checksum   0000  ----  0000  0000  ----  ----
>> > >   TCP         ACK: 0000   SYN: 0000
>> > >               RST: 0000  0000
>> > >   Type       0000  0000  ----  ----  0000  0007
>> > > Sent         0006  000d  0000  0006  0000  000d
>> > >   Rexmit     ----  ----  0000  ----  ----  ----
>> > > nsh> ping www.google.com
>> > > PING 216.58.200.68 56 bytes of data
>> > > 56 bytes from 216.58.200.68: icmp_seq=0 time=240 ms
>> > > 56 bytes from 216.58.200.68: icmp_seq=1 time=220 ms
>> > > 56 bytes from 216.58.200.68: icmp_seq=2 time=210 ms
>> > > 56 bytes from 216.58.200.68: icmp_seq=3 time=210 ms
>> > > 56 bytes from 216.58.200.68: icmp_seq=4 time=210 ms
>> > > 56 bytes from 216.58.200.68: icmp_seq=5 time=160 ms
>> > > 56 bytes from 216.58.200.68: icmp_seq=6 time=120 ms
>> > > 56 bytes from 216.58.200.68: icmp_seq=7 time=120 ms
>> > > 56 bytes from 216.58.200.68: icmp_seq=8 time=260 ms
>> > > 56 bytes from 216.58.200.68: icmp_seq=9 time=130 ms
>> > > 10 packets transmitted, 10 received, 0% packet loss, time 10100 ms
>> > >
>> > >
>> > > On Tue, Feb 11, 2020 at 1:38 PM Adam Feuer <a...@starcat.io> wrote:
>> > > >
>> > > > Thank you Xiang.
>> > > >
>> > > > I tried your config options, but the simulator still crashes when I
>> do a
>> > > > ping.
>> > > >
>> > > > You didn't attach a whole config file– would you be willing to send
>> one?
>> > > >
>> > > > cheers
>> > > > adam
>> > > >
>> > > > On Mon, Feb 10, 2020 at 8:50 PM Xiang Xiao <
>> xiaoxiang781...@gmail.com>
>> > > > wrote:
>> > > >
>> > > > > Do you enable CONFIG_SIM_NET_BRIDGE?
>> > > > > To get the basic network, the below options are required:
>> > > > > CONFIG_NET=y
>> > > > >
>> > > > > CONFIG_NETINIT_DHCPC=y
>> > > > > CONFIG_NETUTILS_DHCPC=y
>> > > > >
>> > > > > CONFIG_NET_ICMP=y
>> > > > > CONFIG_NET_ICMP_SOCKET=y
>> > > > >
>> > > > > CONFIG_NET_UDP=y
>> > > > > CONFIG_NET_UDP_BINDTODEVICE=y
>> > > > >
>> > > > > CONFIG_SIM_NET_BRIDGE=y
>> > > > >
>> > > > > CONFIG_SYSTEM_PING=y
>> > > > >
>> > > > > IPv6 need more options:
>> > > > > CONFIG_NET_ICMPv6=y
>> > > > > CONFIG_NET_ICMPv6_AUTOCONF=y
>> > > > > CONFIG_NET_ICMPv6_SOCKET=y
>> > > > >
>> > > > > CONFIG_NET_IPv6=y
>> > > > >
>> > > > > CONFIG_SYSTEM_PING6=y
>> > > > >
>> > > > > Anyway, you can try the attached config which has more options to
>> get
>> > > > > the better network.
>> > > > >
>> > > > >
>> > > > > On Tue, Feb 11, 2020 at 12:22 PM Adam Feuer <a...@starcat.io>
>> wrote:
>> > > > > >
>> > > > > > Xiang,
>> > > > > >
>> > > > > > Thanks for the tips! I tried to get this working, but I don't
>> see any
>> > > > > > network interfaces on my nuttx system other than loopback.
>> > > > > >
>> > > > > > I ran the script on my Linux box, it created a nuttx0: interface
>> > > with an
>> > > > > IP
>> > > > > > address.  But on the nuttx simulator all I see is this:
>> > > > > >
>> > > > > > nsh> ifconfig
>> > > > > > > lo Link encap:Local Loopback at UP
>> > > > > > > inet addr:127.0.0.1 DRaddr:127.0.0.1 Mask:255.0.0.0
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > > Do you have a defconfig that I can run that will bring up NSH?
>> Or
>> > > any
>> > > > > > defconfig that will show the network is working?
>> > > > > >
>> > > > > > cheers
>> > > > > > adam
>> > > > > >
>> > > > > >
>> > > > > >
>> > > > > > On Mon, Feb 10, 2020 at 7:45 PM Xiang Xiao <
>> > > xiaoxiang781...@gmail.com>
>> > > > > > wrote:
>> > > > > >
>> > > > > > > Adam, please follow this instruction if you want to connect
>> the
>> > > real
>> > > > > > > network instead loopback:
>> > > > > > >
>> > > > > > >
>> > > > >
>> > >
>> https://github.com/apache/incubator-nuttx/pull/249/commits/1b489449f790c2b4618df9133114bb05f0132e87
>> > > > > > > The setup is very simple, you don't need config any IP address
>> > > > > manually.
>> > > > > > >
>> > > > > > > Thanks
>> > > > > > > Xiang
>> > > > > > >
>> > > > > > > On Tue, Feb 11, 2020 at 2:23 AM Gregory Nutt <
>> spudan...@gmail.com>
>> > > > > wrote:
>> > > > > > > >
>> > > > > > > >
>> > > > > > > > > I'm trying to get the NuttX simulator working with TCP/IP
>> > > > > networking. I
>> > > > > > > > > used the sim:nsh defconfig as a base, then used "make
>> > > menuconfig"
>> > > > > to
>> > > > > > > select
>> > > > > > > > > TCP/IP, ICMP, and ping commands.
>> > > > > > > > >
>> > > > > > > > > My host is Ubuntu 19.10 Eoan. I installed bridge-utils and
>> > > > > configured a
>> > > > > > > > > bridge device nuttx0 and gave it an IP address 10.0.1.1.
>> From
>> > > > > linux I
>> > > > > > > can
>> > > > > > > > > ping the bridge.
>> > > > > > > > >
>> > > > > > > > > I can compile and run the simulator. Commands seem to
>> work. I
>> > > can
>> > > > > > > configure
>> > > > > > > > > the eth0 interface with IP address 10.0.1.2 and bring it
>> up
>> > > using
>> > > > > > > ifup. But
>> > > > > > > > > when I try to ping the bridge, the nuttx simulator
>> immediately
>> > > > > exits
>> > > > > > > with
>> > > > > > > > > no messages.
>> > > > > > > > >
>> > > > > > > > > I checked the .config against the sim:nettest defconfig,
>> and my
>> > > > > > > settings in
>> > > > > > > > > .config match that one.
>> > > > > > > > >
>> > > > > > > > > What am I doing wrong? How do I debug this?
>> > > > > > > >
>> > > > > > > > I don't use TCP/IP networking with the simulator.  Perhaps
>> Xiao
>> > > Xiang
>> > > > > > > > will respond later.
>> > > > > > > >
>> > > > > > > > I am creating a simulator example that runs the TCP blaster
>> > > example
>> > > > > > > > using the loopback 127.0.0.1 device.  I will give that to
>> you
>> > > once I
>> > > > > > > > verify it.
>> > > > > > > >
>> > > > > > > >
>> > > > > > >
>> > > > > >
>> > > > > >
>> > > > > > --
>> > > > > > Adam Feuer <a...@starcat.io>
>> > > > >
>> > > >
>> > > >
>> > > > --
>> > > > Adam Feuer <a...@starcat.io>
>> > >
>> >
>> >
>> > --
>> > Adam Feuer <a...@starcat.io>
>>
>
>
> --
> Adam Feuer <a...@starcat.io>
>


-- 
Adam Feuer <a...@starcat.io>

Reply via email to