Hello,
I have a device (K60) with code built using the Keil MDK-Pro and using the TCP_CM3.lib library. I am able receive every UDP packet sent from the PC to the K60. But every other response packet from the K60 is not received by the PC.
This error seems to be rather intermittent. If I build with the No Init options (in Target options) for both IRAM1 and IRAM2 the problem "sometimes" goes away.
Has anyone seen this issue before?
Any ideas?
Thanks, Mike
I have a hunch that the issue is related to initialized data. I modified the TCP_CM3.lib options such that "Other Data" is placed in the IRAM1 area. Rebuilt the firmware and it I now get every response. At least for now.
I am rather concerned with this as a solution.
Turns out the problem with this issue and others I experienced was the result of my own actions. When I started the project the debugger would not run to main for some reason (have yet to figure out why). When looking at the code I saw the label __main which looked odd. So I edited it to main and it would run to main. But the initialization code was not running (unbeknown to me) thus the strange behavior. I changed main back to __main and all is good at the moment. Don't know why it runs to main now, but that is another issue.
Your main() gets an additional leading underscore in the object file, so links as _main. But there is also an external symbol __main that is part of the runtime library startup code and that must be called first.
The use of a leading _ when translating C symbols is to give the assembler world a protected namespace, i.e. the only way to create symbols without leading underscores.
The C library on the other hand is the only one allowed to have C source symbols with a leading underscore (resulting in double leading underscores when linking) to make sure that the C library also gets a protected namespace for private symbols that should not clash with normal C code.