Content originally posted in LPCWare by CodeRedSupport on Mon Sep 13 02:09:11 MST 2010
Quote: bmentink
As mentioned in my original post, I am not getting any output to the console window .. no errors.
Your original post just says "I am having trouble getting printf to work via semihosting" - it doesn't actually say in what way it doesn't work :cool: I just wanted to ensure I wasn't misunderstanding.
Quote:
I have attached my makefile for reference .. I am not sure why you think the linker is not envoking the --gc-sections" option correctly, it is passed as a linker option, remember this is a makefile project, not a gui one .. please re-read my original post.
You are invoking the linker via the compiler. The --gc-sections option therefore needs to be prefixed with the -Xlinker option to cause the compiler to pass it directly through to the linker. Your makefile does this for the -map option, but not for --gc-sections.
Quote:
By the way, I notice in the map file, that the printf functions are called from the libcr_c.a library, should they not be called out of the semihosting version of that lib? Do I need to remove libcr_c.a from the GROUP( ... line in my loader file perhaps ??
No - the two libraries work in collaboration. The main C library code for printf (in libcr_c.a) calls out to the function "__write" (in libcr_semihost.a) which actually handles the interaction up the debug link up to the debugger.
[Aside, for future proofing, I would suggest switching your group so that the semihosting library is specified before the main C library:
[FONT=Courier New][SIZE=1]GROUP(libcr_semihost.a libcr_c.a libcr_eabihelpers.a)[/SIZE][/FONT]
]
Anyway, I think that your makefile has given me a possible clue. Can you confirm what actual tools you are using to build you code here? There is reference at the top of your makefile to "/home/bmentink/opt/arm-2010q1/bin". This makes me suspicious that you might have "hacked" a different version of the GNU tools into your LPCXpresso installation.
If you have done this, then you should note that this is not a means of operation of LPCXpresso that we cannot provide support on. If you have done this, it makes it very likely that you are actually including newlib header files, but then, due to your library script, linking with redlib library code. This is likely to lead to the sorts of problems that you are having.
Regards,
CodeRedSupport