I am using the Olimex installation with the LPC-P2103 and I am a beginner at ARM programming.
I’ve been sitting with this stupid
undefined reference to `__udivsi3'
I managed to find out that I need some library in the linker directives but I’m not very used to fiddling with gcc and makefile editing so it took me a while.
What I needed to fix my problem was (interesting fragments):
peter_m that fixed my divide problems like a charm, but now when i use sprintf, it complains:
c:\gccfd\yagarto\bin../arm-elf/lib\libc.a(lib_a-syscalls.o): In function `_sbrk’:
C:\msys\1.0\home\yagarto\newlib-build\arm-elf\newlib\libc\sys\arm/…/…/…/…/…/…/newlib-1.16.0/newlib/libc/sys/arm/syscalls.c:506: undefined reference to `end’
make: *** [main.out] Error 1
I tried a bunch of other solutions out there but to no avail. Apparently _end needs to be defined in my linker script somewhere. I am sure the solution is simple but I am running XP with eclipse and not super familiar with the way XP emulates gcc or whatever. Any suggestions??
Nice to hear Although credit should go to the ones who provided the solution above.
I also got the error you are describing
I googled and found a way to fix it but I can’t say I’m 100% sure it’s the only or best way to do it. But here’s what I did.
Edit the .cmd file in your project. It’s a linker script and the end of it looks like this:
_end = .; /* define a global symbol marking the end of application RAM */
I found somewhere that , for reasons only known to people who know what they are doing, there should be another line so the final result will look like this:
_end = .; /* define a global symbol marking the end of application RAM */
PROVIDE(end = .);
Hope that helps.
Now, if you’re doing anything similar to what I’m doing, I foresee that you will have problems with divisions in your program once it starts to run and it will cause an exception and get stuck in UNDEF_Routine()
I don’t know how to fix that yet but I’ve posted a thread about it.
In my search for this problem, I read that putting that at the end makes the stack for the linker start in strange places in memory. (I certainly don’t know what it means lol). Anyways, thanks for the help. You would think since Olimex supplies the CD with the dev board, everything would be in order. This is definitely not the case. At least I know I am not the only one with this problem
In my search for this problem, I read that putting that at the end makes the stack for the linker start in strange places in memory. (I certainly don’t know what it means lol). Anyways, thanks for the help. You would think since Olimex supplies the CD with the dev board, everything would be in order. This is definitely not the case. At least I know I am not the only one with this problem
Still stuck with this problem… If i get to a spot like everyone else seems to be, it just says undefined referennce to ‘end’, so i put the PROVIDE(end= .); as stated above, but then i get the memory error. Anyone have any suggestions?? I am getting desperate here…
I spent half my vacation (1 week out of 2) trying to get that **** to link properly. I’m not getting your error but rather when I link to the other libraries with yagarto I get some sort of crash, probably due to that the address the code jumps to, both for malloc and for divisions.
They all contain zeros and look like just blank memory. So, I assume the linker ****** up.
I have not tried WinARM or any other tools yet, except Rowley CrossWorks which I downloaded and requested a trial license for (valid for 1 month).
Works like a charm, debugging is so sweet. You can get CPU flags, VICaddresses, Timer registers and so in in a separate window.
Personal license for hobbyists is $150 and I am seriously considering that $150 is worth it. I don’t do this for a living. I do it for fun. I want my tools to work. It’s not fun when they don’t do, especially when they are delivered with the product I am trying to use them with.
I know I know, I can’t demand anything, they’re free blablabla, but at the end of the day (and my vacation) I am just sitting there cursing everything when I just can’t divide two variables.
So. 150 bucks? It’s money, yes, but my vacation is worth more than that.
I recommend you take a look at some other tools to see if you can get them to work “out of the box”. I gave up on the Eclipse+yagarto crap.
Sorry I can’t help you but neither can anyone else it seems
peter_m:
I spent half my vacation (1 week out of 2) trying to get that **** to link properly. I’m not getting your error but rather when I link to the other libraries with yagarto I get some sort of crash, probably due to that the address the code jumps to, both for malloc and for divisions.
They all contain zeros and look like just blank memory. So, I assume the linker ****** up.
I have not tried WinARM or any other tools yet, except Rowley CrossWorks which I downloaded and requested a trial license for (valid for 1 month).
Works like a charm, debugging is so sweet. You can get CPU flags, VICaddresses, Timer registers and so in in a separate window.
Personal license for hobbyists is $150 and I am seriously considering that $150 is worth it. I don’t do this for a living. I do it for fun. I want my tools to work. It’s not fun when they don’t do, especially when they are delivered with the product I am trying to use them with.
I know I know, I can’t demand anything, they’re free blablabla, but at the end of the day (and my vacation) I am just sitting there cursing everything when I just can’t divide two variables.
So. 150 bucks? It’s money, yes, but my vacation is worth more than that.
I recommend you take a look at some other tools to see if you can get them to work “out of the box”. I gave up on the Eclipse+yagarto crap.
Sorry I can’t help you but neither can anyone else it seems
LOL thats awesome, I just did the same. Just got my trial licence as well. I think I came to the same conclusion as you, $150 is well worth it. After struggling with this linking problem for so long, all I want to do is get back to coding, if I need to pay $150 to get a reliable tool, then so be it at this point…
It is good to know that you found Crossworks to be much easier. I have NEVER used them before so i hope i can get a project goin quickly and transfer all my code. The only thing that worries me is not knowing how to do the first setup to get goin…
quick question for you peter_m, is it able to generate a .hex file? i have a fancy usb debugger, but at this point i would just like to load the .hex file to the arm with the serial flash utility…
I don’t know if it can generate hex files. The way it is done now is that it makes elf files. Not that I know what the difference is but I assume they’re not the same
I don’t know if it can generate hex files. The way it is done now is that it makes elf files. Not that I know what the difference is but I assume they’re not the same
Good luck with your project
Thanks, for reference if you want to generate .hex in Crossworks…
Project->properties->make sure your project is highlighted and scroll down in the window to Linker options section and make Additional Output Format say “hex”
I literary copy and pasted my source files from eclipse and it compiled and made a hex with zero errors. (I was very surprised) I burned the .hex but nothing is happening. I am curious, I assumed I would need to supply a “lpc21xx.h” header file but some examples out there just calling it from the library (Crossworks supplied one?). I am sorry to bug you again peter_m, but did you supply your own lpc header file? If not, what #include did you use? I am looking all over the net for a “blink” demo or something prepackaged from Crossworks but so far no luck. Once I get a light to blink or something, I can move forward.
peter_m:
There are packages you need to download and install for the LPC chips. You can do that from within crossworks, should be easy to find.
Like you, I also tried copying my source code.
I noticed “LPC21xx.h” was not found during compilation but I looked at some of the examples in the packages I downloaded and saw I could:
#include <targets/LPC210x.h>
#include <targets/LPC2103.h>
That solved the compilation problems I had.
Hope it helps
Thanks peter_m I had the NXP lpc2000 cpu processor packages installed but I didn’t see some of the examples you were mentioning till I installed the olimex lpc2106 package which had some examples. I added those lines to the code, as before it compiled but no signs of life from the LPC-P2103 board. I guess the nice thing about eclipse was they had those demo projects preinstalled that worked from the get go, then again I suppose nothing else did ;). anyways thanks for the pointers, i am going to go through some of those packages and see if there is more examples. The ones that I am seeing look pretty hard to decifier, in eclipse, it was very transparent (if i wanted to call a register, i could just look in the header file) I look at their’s and it seems to call files from libraries that i can’t find to see the addresses.
Thanks again for the help, good luck on your Crossworks adventures!
A friend of mine (who is more into this kind of programming, well any programming) passed by today and found my problem with the Eclipse/Yagarto config.
Turns out everything was working EXCEPT that the commands I used for flashing had a problem.
In the debug config under the “Commands” tab where the flash commands are, the command to erase the flash memory had wrong parameters because I had copied them from a small example program.
The culprit was this one:
monitor flash erase_sector 0 0 0
It turns out that it erased 4k flash. The arguments mean
erase bank0 from sector 0 to sector 0
and my friend noticed everything above 4k looked like garbage so he said it wasn’t erased. I checked around a bit and found what the arguments meant and assumed a sector is 4k.
So, I tried to erase all 32kB of flash by changing to this:
monitor flash erase_sector 0 0 7
and of course it worked… Bah, took him half an hour and I couldn’t fix it in a week.
Anyway, I’m not gonna use CrossWorks because there is a remote chance that I might do something commercial with my project if I finish it and then Rowley demands I puke up $1500 to pay for a commercial CrossWorks license. Fat chance… No $'s for you Rowley!
Anyway, I’m going back to Eclipse+Yagarto again because of it.
peter_m, thats awesome! Glad to see that it all worked out. If its not too much trouble, I was wondering if you could post your Makefile. At this point I, like you, am closer to a solution on Eclipse+Yagarto than I am on getting Crossworks to work. I think we might be even using the same target board. I have a feeling that it is something small. Anyways, hope it’s all smooth sailing for you now on!
Please note that I have changed the name of the linker script (the .cmd file) but just change it to what you have in your project. I think it originally was demo2106_blink_flash.cmd.
Also, you of course need to edit which source and object files should be used.
Oh, and I’m using Olimex LPC-P2103 board with the Olimex USB-OpenOCD-Tiny interface.
Thanks peter_m I will see if that fixes the sprintf linker problem. I actually went forward without using sprintf and made my own int to string function and was surprised to find out that it works pretty well. Once I was past that hurtle, the rest was all downhill. I would like to use sprintf for other things so thanks for posting your makefile For future reference, if you need an int to string function for writing a temperature value to a lcd (say a 128x128) let me know and I can paste the functions I used. Thanks again!
IAR and Keil have professional quality compilers and IDE, no makefile fights, and the free version (of IAR) does up to 32KB of code, if that helps you in a non-commercial application.