Discussion:
[OpenOCD-devel] implementation of system call such as system(), popen(), etc on a semihosting mode.
Diego Alejandro Parra Guzman
2017-05-01 18:55:38 UTC
Permalink
Dear all.

I'm working with ARM-GNU-ECLIPSE and the board STM32F401RE in a
semihosting mode, I want to execute system calls while I'm debuging since I
need to retrieve the name of a function passing a specific address; calling
the binary arm-none-eabi-addr2line.exe.

Well, after a week of test I didn't figure out why this functionality Is no
working with the openocd, for that reason I want to implement this
functionality on openocd how ever before to star I need to ask few
questions about openocd.

1) Really openocd doesn't support system calls on a semihosting mode.?
2) if I need to start from scratch I want to know If someone had
implemented something on this topic.
3) otherwise which could be the starting point in order to include such
functionality as fast as possible.
4) I'll appreciate any other recommendation.

thanks so much
--
Diego Alejandro Parra Guzmán
Estudiante de ingeniería electrónica
Universidad distrital FJC
Paul Fertser
2017-05-01 20:19:38 UTC
Permalink
Hello,
Post by Diego Alejandro Parra Guzman
1) Really openocd doesn't support system calls on a semihosting mode.?
It should support the calls described in ARM specs[1].

system() should be supported already. Are you using newlib's librdimon
to do semihosting?

I do not see how popen() can be expected to work given the specs[1]
though. You should be able to pass some data back via the return code.

[1] http://infocenter.arm.com/help/topic/com.arm.doc.dui0471g/CHDGGIID.html
--
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:***@gmail.com
Diego Alejandro Parra Guzman
2017-05-01 20:42:49 UTC
Permalink
*Hello* Paul Fertser

whit respect to my first question.
Yes, you are correct, I'm using newlib librdimon to do semihosting, but I
guess that something is wrong since when I test the system() function the
return value indicates that there is not any command processor
(shell(LINUX) or the command line(WINDOWS)) available therefore I've
concluded that there is some issue on that implementation.

The return value of *system*() is one of the following:

* If *command* is NULL, then a nonzero value if a shell is available,
or 0 if no shell is available.

do you have some info about my other questions.

2) if I need to start from scratch I want to know If someone had
implemented something on this topic.
3) otherwise which could be the starting point in order to include
such functionality as fast as possible.
4) I'll appreciate any other recommendation.
Post by Paul Fertser
Hello,
Post by Diego Alejandro Parra Guzman
1) Really openocd doesn't support system calls on a semihosting mode.?
It should support the calls described in ARM specs[1].
system() should be supported already. Are you using newlib's librdimon
to do semihosting?
I do not see how popen() can be expected to work given the specs[1]
though. You should be able to pass some data back via the return code.
[1] http://infocenter.arm.com/help/topic/com.arm.doc.
dui0471g/CHDGGIID.html
--
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
--
Diego Alejandro Parra Guzmán
Estudiante de ingeniería electrónica
Universidad distrital FJC
Liviu Ionescu
2017-05-01 20:46:42 UTC
Permalink
... newlib librdimon to do semihosting, but I guess that something is wrong
most probably your newlib was built without support for system().


Liviu
Paul Fertser
2017-05-02 05:30:32 UTC
Permalink
2) if I need to start from scratch I want to know If someone had implemented
something on this topic.
3) otherwise which could be the starting point in order to include such
functionality as fast as possible. 
4) I'll appreciate any other recommendation.
Newlib part:
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=libgloss/arm/syscalls.c;h=0ccad215cdb436cf3ff669038077e773bb35cbe7;hb=HEAD#l804

OpenOCD part:
http://openocd.zylin.com/gitweb?p=openocd.git;a=blob;f=src/target/arm_semihosting.c;h=252511962da1bdbda1fe1430ad0dd6bc0df4bb84;hb=HEAD#l524

If you spot an error in this implementation, please share.

HTH
--
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:***@gmail.com
Diego Alejandro Parra Guzman
2017-05-02 05:56:29 UTC
Permalink
Thanks in advance. I'll check it.
Post by Diego Alejandro Parra Guzman
Post by Diego Alejandro Parra Guzman
2) if I need to start from scratch I want to know If someone had
implemented
Post by Diego Alejandro Parra Guzman
something on this topic.
3) otherwise which could be the starting point in order to include such
functionality as fast as possible.
4) I'll appreciate any other recommendation.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.
git;a=blob;f=libgloss/arm/syscalls.c;h=0ccad215cdb436cf3ff669038077e7
73bb35cbe7;hb=HEAD#l804
http://openocd.zylin.com/gitweb?p=openocd.git;a=blob;f=
src/target/arm_semihosting.c;h=252511962da1bdbda1fe1430ad0dd6
bc0df4bb84;hb=HEAD#l524
If you spot an error in this implementation, please share.
HTH
--
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
--
Diego Alejandro Parra Guzmán
Estudiante de ingeniería electrónica
Universidad distrital FJC
Liviu Ionescu
2017-05-02 06:51:59 UTC
Permalink
Post by Paul Fertser
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=libgloss/arm/syscalls.c;h=0ccad215cdb436cf3ff669038077e773bb35cbe7;hb=HEAD#l804
before that part, there is:

https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=newlib/libc/stdlib/system.c;h=135a9d05be92eba9d7851d2a14d6872213330e6c;hb=HEAD

I'm not sure, but my understanding is that the arm-none-eabi-gcc toolchain is built without HAVE_SYSTEM, which means it'll return -1 & ENOSYS without ever calling _system().


in my projects (like µOS++) I reimplemented most of the stdlib calls to "take back control" (hi! hi! hi! BoJo! out British readers know more...) over the library.

https://github.com/micro-os-plus/micro-os-plus-iii/blob/xpack/src/semihosting/c-syscalls-semihosting.cpp


regards,

Liviu

Loading...