Skip to content
This repository has been archived by the owner on Aug 2, 2018. It is now read-only.

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

Open
vmayoral opened this issue Oct 6, 2014 · 14 comments
Open

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

vmayoral opened this issue Oct 6, 2014 · 14 comments

Comments

@vmayoral
Copy link
Member

vmayoral commented Oct 6, 2014

@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
Copy link
Contributor

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
Copy link
Member Author

vmayoral commented Oct 7, 2014

@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
Copy link
Contributor

On October 6, 2014 at 7:41 PM Víctor Mayoral Vilches
[email protected] 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
Copy link
Contributor

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
[email protected] 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
#11 (comment)
.

@vmayoral
Copy link
Member Author

vmayoral commented Oct 7, 2014

@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
Copy link
Contributor

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 vmayoral changed the title Using Qemu for simulation NuttX Linux simulation (previous "using Qemu for simulation") Oct 14, 2014
@vmayoral
Copy link
Member Author

@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
Copy link
Contributor

@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
Copy link
Contributor

@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
Copy link
Member Author

@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
Copy link
Member Author

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
Copy link
Member Author

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
Copy link
Contributor

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

@b-sh
Copy link

b-sh commented Feb 28, 2015

@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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants