ros2 / ros2_embedded_nuttx

This repository isn't actively being worked on. If you would like to take over maintainership please open a ticket on https://github.com/ros2/ros2
72 stars 34 forks source link

NuttX Linux simulation (previous "using Qemu for simulation") #11

Open vmayoral opened 9 years ago

vmayoral commented 9 years ago

@codebot9000 in order to allow others to use our current implementation we are trying to make it work in Qemu. While using this configuration i get the following error:

 make
make[1]: Entering directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/tools'
mkconfig.c:1:0: error: CPU you selected does not support x86-64 instruction set
 /****************************************************************************
 ^
mkconfig.c:1:0: error: CPU you selected does not support x86-64 instruction set
cfgdefine.c:1:0: error: CPU you selected does not support x86-64 instruction set
 /****************************************************************************
 ^
cfgdefine.c:1:0: error: CPU you selected does not support x86-64 instruction set
make[1]: *** [mkconfig] Error 1
make[1]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/tools'
make: *** [tools/mkconfig] Error 2

@nuttx i tried activating several x86-64 options through menuconfig but it didn't help. Do you know if there's a way to build NuttX for Qemu on 64 bit machines?.

gregory-nutt commented 9 years ago

On 10/6/2014 3:38 PM, Víctor Mayoral Vilches wrote:

@codebot9000 <https://github.com/codebot9000> in order to allow others to

use our current implementation we are trying to make it work in Qemu. While using this configuration https://github.com/ros2/ros2_embedded_nuttx/blob/master/nuttx/configs/qemu-i486/dds/defconfig i get the following error:

...
mkconfig.c:1:0: error: CPU you selected does not support x86-64

instruction set

@nuttx https://github.com/nuttx i tried activating several x86-64 options through menuconfig but it didn't help. Do you know if there's a way to build NuttX for Qemu on 64 bit machines?.

You don't mention what toolchain you are using. My guess is that there is something in you HOSTCFLAGS that the tools/Makefile.host does not like on your platform. The x86_64 configuration options only relate to building the target x86 code (it only effects CFLAGS). Those options have no effect on the tools whatsoever (they use HOSTCFLAGS as defined in Make.defs. You should be able to see the gcc command line options when you build).

Googling "CPU you selected does not support x86-64 instruction set" brings a lot of hits. Have you studied them?

You should also be able to build a 32-bit version with -m32 in the HOSTCFLAGS.

I don't know anything about Qemu, there is an i486 Qemu version in the source tree, but I have not used it in years. Are you trying to build that?

You know that NuttX has it own, built-in host simulation right? Try building configs/sim/nsh for example. The x86_64 options do apply in that case. I have only built with AMD x86_64 so Intel might not work. There is a configuration option that should for the -m32 option too.

Greg

vmayoral commented 9 years ago

@nuttx thanks for sharing that NuttX includes the sim config. This will be a great asset for developing applications without having the actual hardware.

I tested the sim/nsh configuration you recommend:

make clean; make clean_context; make
....
make[1]: *** No rule to make target `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/include/arch/chip/irq.h', needed by `os_start.o'.  Stop.
make[1]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/sched'
make: *** [sched/libsched.a] Error 2

I searched around and found some blog posts where you point out that it might be a matter of a bad link. I also played a bit with the menuconfig options without much luck. Any recommendation?

gregory-nutt commented 9 years ago

On October 6, 2014 at 7:41 PM Víctor Mayoral Vilches notifications@github.com wrote:

@nuttx https://github.com/nuttx thanks for sharing that NuttX includes the sim config. This will be a great asset for developing applications without having the actual hardware.

I tested the sim/nsh configuration you recommend:

make clean; make clean_context; make .... make[1]: * No rule to make target /home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/include/arch/chip/irq.h', needed byos_start.o'. Stop. make[1]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/sched' make: * [sched/libsched.a] Error 2

I searched around and found some blog posts where you point out that it might be a matter of a bad link. I also played a bit with the menuconfig options without much luck. Any recommendation?

Yes that sounds an issue with symbolic links. Look at /home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/include/arch. That should be a symbolic link to /home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/arch/sim/include.

I don't know what you did before make clean; make clean_context; make. I don't see a distclean.

You should have done this:

cd nuttx

make distclean

cd tools

./configure.sh sim/nsh

cd -

make

Greg

gregory-nutt commented 9 years ago

A better explanation is that you are still using dependencies from an old build. If you don't do 'make distclean' then all of the old dependencies are still left. So the sched/Make.dep file is probably old and refers to a non existent chip/irq.h header file that used to be included in a previous configuration.

Greg

On October 6, 2014 at 7:41 PM Víctor Mayoral Vilches notifications@github.com wrote:

@nuttx https://github.com/nuttx thanks for sharing that NuttX includes the sim config. This will be a great asset for developing applications without having the actual hardware.

I tested the sim/nsh configuration you recommend:

make clean; make clean_context; make .... make[1]: * No rule to make target /home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/include/arch/chip/irq.h', needed byos_start.o'. Stop. make[1]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/sched' make: * [sched/libsched.a] Error 2

I searched around and found some blog posts where you point out that it might be a matter of a bad link. I also played a bit with the menuconfig options without much luck. Any recommendation?

— Reply to this email directly or view it on GitHub https://github.com/ros2/ros2_embedded_nuttx/issues/11#issuecomment-58121717 .

vmayoral commented 9 years ago

@nuttx that did it thanks. Will leave note of the importance of make disclean.

I read your comments about the issues with the network and the tap device (/dev/net/tun) to emulate an Ethernet NIC. I tried sim/nettest and i got:

make[1]: `libmm.a' is up to date.
make[1]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/mm'
make[1]: Entering directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/arch/sim/src'
AS:  up_setjmp.S
up_setjmp.S: Assembler messages:
up_setjmp.S:134: Error: operand type mismatch for `jmp'
make[1]: *** [up_setjmp.o] Error 1
make[1]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/arch/sim/src'
make: *** [arch/sim/src/libarch.a] Error 2

Seems that something is broken in there.

gregory-nutt commented 9 years ago

I keep forgetting that you are not using the latest code. Just last week I updated the simulation so that would build and run natively on a 64-bit machine. So up_setjmp.S does not even exists anymore; it is replaced with up_setjmp32.S and up_setjmp64.S.

There are two possibilities here:

1) Your compiler may be incompatible with the assembly language syntax used in up_setjmp.s. That does happen from time to time. OR

2) You may be trying to build a native 64-bit simulation with the older code that will not support that. I can't tell by looking at that cryptic error message. I actually would expect more errors in that case.

If #2 is the problem, then you can fix it by adding -m32 to the host CFLAGS. The configuration option CONFIG_SIM_M32 should accomplish that if it is supported in your Make.defs file.

Greg

vmayoral commented 9 years ago

@nuttx just rebased the code with the last commit at nuttx/master repository and tried it again. Here's my result:

cd nuttx
make distclean
cd tools
./configure.sh sim/nsh
cd ..
make
CC:  nsh_ddcmd.c
CC:  nsh_proccmds.c
CC:  nsh_mmcmds.c
CC:  nsh_envcmds.c
CC:  nsh_dbgcmds.c
CC:  nsh_session.c
CC:  nsh_builtin.c
CC:  nsh_fileapps.c
CC:  nsh_romfsetc.c
CC:  nsh_mntcmds.c
CC:  nsh_consolemain.c
CC:  nsh_test.c
AR:   nsh_init.o nsh_parse.o nsh_console.o nsh_script.o nsh_command.o nsh_fscmds.o nsh_ddcmd.o nsh_proccmds.o nsh_mmcmds.o nsh_envcmds.o nsh_dbgcmds.o nsh_session.o nsh_builtin.o nsh_fileapps.o nsh_romfsetc.o nsh_mntcmds.o nsh_consolemain.o nsh_test.o
make[2]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/apps/nshlib'
make[2]: Entering directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/apps/platform'
AR:   
make[2]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/apps/platform'
make[2]: Entering directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/apps/system/readline'
make[2]: *** No rule to make target `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/include/arch/chip/irq.h', needed by `readline_common.o'.  Stop.
make[2]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/apps/system/readline'
make[1]: *** [system/readline_all] Error 2
make[1]: Leaving directory `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/apps'

Can you confirm that you obtain the same behaviour?

gregory-nutt commented 9 years ago

@vmayoral "No rule to make target `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/include/arch/irq.h"

/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/include/arch/irq.h should be a symbolic link pointing to/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/arch/sim/include. irq.h should be there in the repository so this sounds like a problem with your environment.

gregory-nutt commented 9 years ago

@vmayoral "No rule to make target `/home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/include/arch/irq.h"

I just repeated your steps and the code build and executed with no problem.

vmayoral commented 9 years ago

@nuttx did you repeated it with nuttx/master or with our code There's indeed something we modified that is messing up the sim. It seems that the symlink is fine:

victor@frcsim:~/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/include$ ll
total 384
drwxrwxr-x  9 victor victor  4096 Oct 22 14:38 ./
drwxrwxr-x 21 victor victor  4096 Oct 22 14:38 ../
-rw-rw-r--  1 victor victor  6596 Oct 21 15:01 aio.h
lrwxrwxrwx  1 victor victor    67 Oct 22 14:38 apps -> /home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/../apps/include/
lrwxrwxrwx  1 victor victor    68 Oct 22 14:38 arch -> /home/victor/Dropbox/OSRF/ros2_embedded_nuttx/nuttx/arch/sim/include/
drwxrwxr-x  2 victor victor  4096 Oct 21 15:01 arpa/
-rw-rw-r--  1 victor victor  4778 Oct 21 15:01 assert.h
-rw-rw-r--  1 victor victor  3072 Oct 21 15:01 crc16.h
-rw-rw-r--  1 victor victor  3072 Oct 21 15:01 crc32.h
-rw-rw-r--  1 victor victor  7543 Oct 21 15:01 ctype.h
drwxrwxr-x  2 victor victor  4096 Oct 21 15:01 cxx/
-rw-rw-r--  1 victor victor 19289 Oct 21 15:01 debug.h
-rw-rw-r--  1 victor victor  4357 Oct 21 15:01 dirent.h
-rw-rw-r--  1 victor victor 11947 Oct 21 15:01 elf32.h
-rw-rw-r--  1 victor victor 15907 Oct 21 15:01 errno.h
-rw-rw-r--  1 victor victor  7595 Oct 21 15:01 fcntl.h
-rw-rw-r--  1 victor victor 10787 Oct 21 15:01 fixedmath.h
-rw-rw-r--  1 victor victor    66 Oct 21 15:01 .gitignore
-rw-rw-r--  1 victor victor  5669 Oct 21 15:01 inttypes.h
-rw-rw-r--  1 victor victor  2635 Oct 21 15:01 libgen.h
-rw-rw-r--  1 victor victor  8065 Oct 21 15:01 limits.h
-rw-rw-r--  1 victor victor  4295 Oct 21 15:01 mqueue.h
drwxrwxr-x  2 victor victor  4096 Oct 21 15:01 net/
drwxrwxr-x  2 victor victor  4096 Oct 22 10:37 netinet/
drwxrwxr-x  2 victor victor  4096 Oct 21 15:01 netpacket/
drwxrwxr-x 22 victor victor  4096 Oct 22 14:38 nuttx/
-rw-rw-r--  1 victor victor  8245 Oct 21 15:01 nxflat.h
-rw-rw-r--  1 victor victor  4812 Oct 21 15:01 poll.h
-rw-rw-r--  1 victor victor 15037 Oct 21 15:01 pthread.h
-rw-rw-r--  1 victor victor  4563 Oct 21 15:01 queue.h
-rw-rw-r--  1 victor victor  5400 Oct 21 15:01 sched.h
-rw-rw-r--  1 victor victor  5216 Oct 21 15:01 semaphore.h
-rw-rw-r--  1 victor victor  2199 Oct 22 10:37 setjmp.h
-rw-rw-r--  1 victor victor 10142 Oct 21 15:01 signal.h
-rw-rw-r--  1 victor victor  9228 Oct 21 15:01 spawn.h
-rw-rw-r--  1 victor victor  4886 Oct 21 15:01 stdbool.h
-rw-rw-r--  1 victor victor  4277 Oct 21 15:01 stddef.h
-rw-rw-r--  1 victor victor  8712 Oct 21 15:01 stdint.h
-rw-rw-r--  1 victor victor  6308 Oct 21 15:01 stdio.h
-rw-rw-r--  1 victor victor  6409 Oct 21 15:01 stdlib.h
-rw-rw-r--  1 victor victor  4390 Oct 21 15:01 string.h
drwxrwxr-x  2 victor victor  4096 Oct 21 15:01 sys/
-rw-rw-r--  1 victor victor  2871 Oct 21 15:01 syscall.h
-rw-rw-r--  1 victor victor  9893 Oct 21 15:01 syslog.h
-rw-rw-r--  1 victor victor 13745 Oct 21 15:01 termios.h
-rw-rw-r--  1 victor victor  8650 Oct 21 15:01 threads.h
-rw-rw-r--  1 victor victor  7014 Oct 21 15:01 time.h
-rw-rw-r--  1 victor victor  6357 Oct 21 15:01 unistd.h
vmayoral commented 9 years ago

All right, i removed manually some dependencies from the apps/system/readline/Make.dep that were referring to stm32 and arm7-v and that did it. I'm guessing that make distclean was for some reason not cleaning those files aproppiately.

In any case, not it seems to work. Thanks for your support @nuttx

vmayoral commented 9 years ago

Although the README reports that somebody made apps/examples/nettest work it's not straightforward. Making it work will be the first step towards getting the DDS application to get simulated.

Needs more work.

gregory-nutt commented 9 years ago

@vmayoral Max Holtzberg is the person who claimed that it works: https://groups.yahoo.com/neo/groups/nuttx/conversations/topics/4316

b-sh commented 9 years ago

@vmayoral I needed to remove and checkout readline to get everything build otherwise I got an error nsh_session.c:144: undefined reference to `readline' . I could not build it when switched from stm to sim just by the distclean as you mentioned already. By the way in your README one step to initialize the stlink and tinq-core as submodules is missing and therefore build will fail. As far as I can see you have only rmdir the stlink and checkouted by normal git clone which would not be required. Let me know if I have misunderstood something. Thanks.