Author Topic: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)  (Read 26574 times)

0 Members and 4 Guests are viewing this topic.

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« on: September 17, 2012, 05:33:15 pm »
(Not to be confused with calculator linking)

I am currently developing two big projects, one public and one secret! They are both C based, and are very exciting to develop!
However... there are always concerning linking problems! The code can be perfectly valid, but it will never compile/link! There are also some interesting features that I would like to see in ndless, which if possible, I'd like to help with.

That said, here are some things that I would like to get fixed:
1) Standard C Library Collisions (or undefined references!)
This applies to both projects, though the public one's error messages were shorter and probably easier to fix:
Code: [Select]
nspire-ld obj/*.o -L./nrgbsdk/lib -lRGB -lgcc -nostdlib -lc -lm -o nrgbwabbit
/usr/local/arm/lib/gcc/arm-none-eabi/4.6.3/../../../../arm-none-eabi/lib/libc.a(lib_a-svfscanf.o): In function `__ssvfscanf_r':
/home/albert/ndless/modern_toolchain/build/arm-none-eabi/newlib/libc/stdio/../../../../../newlib-1.20.0/newlib/libc/stdio/vfscanf.c:1584: undefined reference to `__aeabi_d2f'
/usr/local/arm/lib/gcc/arm-none-eabi/4.6.3/../../../../arm-none-eabi/lib/libc.a(lib_a-syscalls.o): In function `_sbrk':
/home/albert/ndless/modern_toolchain/build/arm-none-eabi/newlib/libc/sys/arm/../../../../../../newlib-1.20.0/newlib/libc/sys/arm/syscalls.c:499: undefined reference to `end'
/usr/local/arm/lib/gcc/arm-none-eabi/4.6.3/../../../../arm-none-eabi/lib/libc.a(lib_a-strtod.o): In function `strtof':
/home/albert/ndless/modern_toolchain/build/arm-none-eabi/newlib/libc/stdlib/../../../../../newlib-1.20.0/newlib/libc/stdlib/strtod.c:1194: undefined reference to `__aeabi_d2f'
collect2: ld returned 1 exit status
This does NOT link to the standard library and instead depends on the ndless syscalls and definitions. However, this causes problems, as seen above. When linking with the standard library, it ends up having multiple definition errors instead. Maybe there could be a define allowing the use of newlib instead?

2) New feature: ELF loader with dynamic libraries support
BFLT does *not* implement this at all. Only ELF can load dynamic libraries on the fly (dlopen, dlsym, etc.). This would be very useful for plugin support in my secret project, which works but is very limited without ELF support.

3) Multithreading
This may or may not be needed for SDLWabbitemu, but it would be nice to have. tangrs I believe made a proof of concept, and NUCLEUS OS indicates support for it. (Maybe there's a syscall out there?)

4) Secret project with secret changes requested to disable something with a define. :P (ExtendeD knows what I'm referring to - I am willing to create the patches for that if you don't have time!)

Thanks in advance!
« Last Edit: September 17, 2012, 05:54:29 pm by alberthrocks »
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« Reply #1 on: September 18, 2012, 01:04:29 am »
ELF is very complicated. tangrs had made an ELF loader, but ELF files could be overly big in some simple cases.

And Nucleus is indeed a multi-threaded RTOS.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« Reply #2 on: September 18, 2012, 09:42:25 am »
ELF is very complicated. tangrs had made an ELF loader, but ELF files could be overly big in some simple cases.
Yes indeed... but dynamically loading libraries is essential for any application that depends of plugins written in C.
I guess what I'm asking for is some implementation of dlopen(), dlsym(), and dlclose() for BFLT.

And Nucleus is indeed a multi-threaded RTOS.
Yup, as I thought: http://www.mentor.com/embedded-software/nucleus/kernel
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« Reply #3 on: September 18, 2012, 05:00:47 pm »
1) Try to remove the -nostdlib switch and any #include directive for the standard headers. Conflicts between newlib and os.h are an Ndless design flaw, sorry about that.

3) This may only be a matter of exporting the pthreads definition from the OS (for example phtread_create() an pthread_join() have already be found: https://www.unsads.com/scm/svn/nsptools/symbols/trunk/OS_cascx-3.1.0.idc [guest/guest]).
But the OS clock cursor will once again annoy us since interrupts must be able for these functions to work.
Ndless.me with the finest TI-Nspire programs

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« Reply #4 on: September 18, 2012, 07:23:08 pm »
1) Try to remove the -nostdlib switch and any #include directive for the standard headers. Conflicts between newlib and os.h are an Ndless design flaw, sorry about that.
In the end, this is what I did:
 - open Ndless-SDK/ndless/system/ldscript and add end = .;
 - open Ndless-SDK/ndless/system/osstub.c and comment out void _exit(void) { exit(-1); } and rebuild Ndless
 - build the object files with -nostdlib
 - at linking, remove -nostdlib
It builds successfully, but it doesn't load at all (and crashes)! Not sure what is happening now... I guess I'll have to find a way to hook up GDB to the nspire_emu.

3) This may only be a matter of exporting the pthreads definition from the OS (for example phtread_create() an pthread_join() have already be found: https://www.unsads.com/scm/svn/nsptools/symbols/trunk/OS_cascx-3.1.0.idc [guest/guest]).
But the OS clock cursor will once again annoy us since interrupts must be able for these functions to work.
Ah, interesting! I would assume that there would be more API functions that are hidden (like pthread_exit()), of course. And for the OS clock cursor, are you referring to the startup screen? Is there no way to disable that?

As always, thank you for your help! :)
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« Reply #5 on: September 19, 2012, 01:38:01 am »
Quote
And for the OS clock cursor, are you referring to the startup screen? Is there no way to disable that?
The clock cursor does indeed appear on the startup screen, but he's talking about the clock cursor which appears during the execution of Ndless programs unless they disable interrupts :)
It would certainly be possible to perform brain surgery on the OS for having it not display this clock any longer (even when interrupts are enabled), but none of us ever did, AFAICT.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« Reply #6 on: September 19, 2012, 07:42:21 am »
Although it's just a matter of setting a simple OS switch. Ndless really requires developers to help me handle all these requests, I can't do it alone anymore.

- open Ndless-SDK/ndless/system/osstub.c and comment out void _exit(void) { exit(-1); } and rebuild Ndless

What is this one for?


It builds successfully, but it doesn't load at all (and crashes)! Not sure what is happening now...

Using newlib functions is not recommended as long as tangr's bFLT loader hasn't been merged into Ndless, since some of these functions require relocation, and you can't guess which ones.


I guess I'll have to find a way to hook up GDB to the nspire_emu.

This one is also at the top of the TODO list.
Lionel Debroux has already merge my GDB stub into the latest (but not released publicly?) update of nspire_emu. I'll do some non-regression tests on Ndless and update the SDK with it as soon as possible.

Once again sorry for the delay. Fill free to contribute a way or another to all these tasks, I can give update rights to the repository to anyone I trust willing to contribute if needed.
Ndless.me with the finest TI-Nspire programs

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« Reply #7 on: September 19, 2012, 12:21:29 pm »
Although it's just a matter of setting a simple OS switch. Ndless really requires developers to help me handle all these requests, I can't do it alone anymore.
I would be more than happy to help when I have time, if I know this OS switch. :)

- open Ndless-SDK/ndless/system/osstub.c and comment out void _exit(void) { exit(-1); } and rebuild Ndless

What is this one for?
This is a modification to the SVN checkout of ndless to fix the "multiple definition of _exit()" error (building *.c with -nostdlib, then nspire-ld without that option). It links but crashes (of course).

Using newlib functions is not recommended as long as tangr's bFLT loader hasn't been merged into Ndless, since some of these functions require relocation, and you can't guess which ones.
Yeah, that's probably the cause of these crashes.


I guess I'll have to find a way to hook up GDB to the nspire_emu.

This one is also at the top of the TODO list.
Lionel Debroux has already merge my GDB stub into the latest (but not released publicly?) update of nspire_emu. I'll do some non-regression tests on Ndless and update the SDK with it as soon as possible.
That's great! I'm looking forward to seeing that integrated! (And perhaps in a release of the graphical version too!)

Once again sorry for the delay. Fill free to contribute a way or another to all these tasks, I can give update rights to the repository to anyone I trust willing to contribute if needed.
No problem! I'm busy as well, so I can understand your situation. (Again, only work when you get the chance!) I would love to get update rights, though I would prefer getting an experimental branch on the Ndless SVN** so I can push my changes to my own SVN branch without some innocent user accidentally blowing up their calculator! ;) Do you have any particular coding standards? Also, is there anything I need to know to get familiar with the code structure?

** Actually, I could create a Google Code SVN instead and do management from there, if the code can be public. It would be easier for anyone to add people that are willing to contribute. Later, when the code becomes stable, I can simply commit my repo to the official source tree. Let me know your opinion/decision on this! :)
« Last Edit: September 19, 2012, 12:22:17 pm by alberthrocks »
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« Reply #8 on: September 20, 2012, 01:34:02 am »
Maybe an external Git repository, containing a mirror of the SVN as the main branch and experimental branches ?
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« Reply #9 on: September 22, 2012, 02:37:03 am »
Sure, an experimental branch on another repository would be a good idea.
Ndless.me with the finest TI-Nspire programs

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: Nspire (Ndless) C Linking Frenzy (+requests for Ndless)
« Reply #10 on: September 23, 2012, 12:17:30 pm »
I've set up a Google Code repository for Ndless!
http://code.google.com/p/ndless/

I've also set up a branch for one of my own changes. The tree can be found here and changes here.
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)