In my previous post I explained how to
get started with Nuttx on Qemu emulating Stellaris Soc.
In the following I show how to go
further and configure the network in order to perform simple
networking operations like ping and telnet.
So first of all let's update the Nuttx
version:
$cd nuttx
$export
PATH=`pwd`/../misc/buildroot/build_arm_nofpu/staging_dir/bin:$PATH
$export CROSSDEV=arm-elf-
$git pull
As I write the latest commit, the one I
use, is d4e59915c6072e917b5017d5fefe2afb840d4097
Now we can configure the Nuttx
$cd tools
$./configure.sh lm3s6965-ek/nsh
$cd ..
$make menuconfig
At this point we should have a menu
like the one showed below, here you can configure almost all the
features of Nuttx.
Select ARP feature:
Networking Support →ARP Configuration→ ARP send
We
must now modify few things in the Nuttx's Ethernet driver of the
Stellaris chip.
You
can apply the following patch with the command:
$patch
-p1 < patch
diff
--git a/nuttx/arch/arm/src/tiva/lm3s_ethernet.c
b/nuttx/arch/arm/src/tiva/lm3s_ethernet.c
index
87334ab..98e5285 100644
---
a/nuttx/arch/arm/src/tiva/lm3s_ethernet.c
+++
b/nuttx/arch/arm/src/tiva/lm3s_ethernet.c
@@
-368,6 +368,7 @@ static void tiva_ethreset(struct tiva_driver_s
*priv)
putreg32(regval,
TIVA_SYSCON_RCGC2);
nllvdbg("RCGC2:
%08x\n", regval);
+#if
0
/*
Put the Ethernet controller into the reset state */
regval
= getreg32(TIVA_SYSCON_SRCR2);
@@
-387,7 +388,7 @@ static void tiva_ethreset(struct tiva_driver_s
*priv)
/*
Wait just a bit, again. If we touch the ethernet too soon, we may
busfault. */
up_mdelay(2);
-
+#endif
/*
Enable Port F for Ethernet LEDs: LED0=Bit 3; LED1=Bit 2 */
#ifdef
CONFIG_TIVA_ETHLEDS
@@
-1198,11 +1199,13 @@ static int tiva_ifup(struct net_driver_s *dev)
*/
nlldbg("Waiting
for link\n");
+#if
0
do
{
phyreg
= tiva_phyread(priv, MII_MSR);
}
while
((phyreg & MII_MSR_LINKSTATUS) == 0);
+#endif
nlldbg("Link
established\n");
/*
Reset the receive FIFO */
Actually I am removing some code using
the #if 0 preprocessor macro.
The first #if 0 is to avoid to write at
offset 0x048 (SRCR2)
as you can see from
http://git.qemu.org/?p=qemu.git;a=blob;f=hw/arm/stellaris.c;h=cb515ec76520d3237c793d2ba406d27cd0b392f5;hb=HEAD#l546
Qemu does not implement write on this offset and it will end up in an annoying “Peripheral reset not implemented” log when you start Qemu.
Qemu does not implement write on this offset and it will end up in an annoying “Peripheral reset not implemented” log when you start Qemu.
The second #if 0 is to avoid
Nuttx waiting for link up forever as the emulator does not seem to
report the link status correctly.
Compile the new Nuttx image
$make
We now need to set up a basic virtual
network between the host and Qemu, with the real board we would
connect the board to a PC throught an ethernet cable.
So let's create a virtual device acting
as a tap (tap means it emulate the ethernet)
$sudo ip tap add mode tap
let's give it a ip address:
$sudo ifconfig tap0 10.0.0.1
We are now ready to start our Qemu:
$qemu-system-arm -M lm3s6965evb -kernel
nuttx -net nic,model=stellaris -net
tap,ifname=tap0,script=no,downscript=no
Basically we are telling Qemu to
emulate lm3s6965 evaluation board, using the image we built, a
network interface that is the one of the stallaris SOC, and is linked
to tap0 of the host and to not run any script associated to that tap.
As Qemu starts we could press
CRTL+ALT+3 in order to get the console, we can now configure the
Stellaris network interface inside the Qemu console and ping the
host:
nsh> ifconfig 10.0.0.2 gw 10.0.0.1
nsh> ping 10.0.0.1
Just to end we could give a try to the
telnet server run by Nuttx, from a host console give the command:
# telnet
10.0.0.2
this
is what you will get.
user@nuttx-VirtualBox:~/nuttx_workdir/nuttx-stellaris/nuttx$
telnet 10.0.0.2
Trying 10.0.0.2...
Connected to 10.0.0.2.
Escape character is '^]'.
NuttShell (NSH)
nsh> help
help usage: help [-v] [<cmd>]
[ df hexdump
mkdir ping sleep
? echo ifconfig
mkfatfs ps test
break exec ifdown
mkfifo put true
cat exit ifup
mkrd pwd umount
cd false kill
mh rm unset
cp free losetup
mount rmdir usleep
cmp get ls
mv set wget
dd help mb
mw sh xd
nsh>
No comments :
Post a Comment