Debugging via JTAG - problems?

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Debugging via JTAG - problems?

Lukas Riezler

Hello ecos-guys!

For my FM3-Port I've customized the clocking.
I thougt this would be enough to debug a first "Hello World" application (blinking LED) with JTAG.

What I did is following:

1) I customized clocking (that contains of course customizing the dependent header files and cdl files
2) I built a ecos library. I took care that I disable virtual vector table. Richard Rauch advised me of this because I want ecos to run without RedBoot.
3) I created a makefile project in eclipse
4) with this makefile project I'm now able to compile my "Hello World" application and then linking it with the ecos library
5) an elf file is generated
6) then I did the configurations for debugging in eclipse
7) I use arm-none-eabi-gdb from YAGARTO toolchain (arm-eabi-gdb which comes with ecos doesn't work?), Segger GDB Server and onboard JTAG
8) I am able to start debugging --> the debugger starts at vectors.S and after some steps I get into the main() of Hello World. What makes me a little
   perplex is that I don't leave vectors.S until I reach the main() of Hello World.
   I expected that I should run through the different files of the HAL to see among other things the steps of my clock initialisation.
9) like I said I arrive at main() of Hello World...but exactly the line of code which should cause the LED to switch on is ignored by the debugger!
   A few steps later I get with the debugger to serial.c
Do you know what I'm doing wrong? If there are some passages you don't really understand because of my english --> please tell ;)

---

By the way - can you tell me what I have to do for answering in the mailing-list? I think I still don't understand how that works ;)
With kind regards, Lukas

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Re: Debugging via JTAG - problems?

Ilija Kocho [Илија Кочо]
On 25.04.2013 02:13, Lukas Riezler wrote:
> Hello ecos-guys!
>
[snip]
> 8) I am able to start debugging --> the debugger starts at vectors.S and after some steps I get into the main() of Hello World. What makes me a little
>    perplex is that I don't leave vectors.S until I reach the main() of Hello World.
>    I expected that I should run through the different files of the HAL to see among other things the steps of my clock initialisation.

How do you get to main? by single stepping? Breakpoint?
Put breakpoint on hal_system_init() . That's an early breakpoint and
will give you chance to step through system booting.

> 9) like I said I arrive at main() of Hello World...but exactly the line of code which should cause the LED to switch on is ignored by the debugger!

It is possible that your code has been optimised by GCC. Did you get
some warnings for unused variables from GCC? I assume you are writing to
some port, try to declare the port (variable) as volatile.

>    A few steps later I get with the debugger to serial.c
> Do you know what I'm doing wrong? If there are some passages you don't really understand because of my english --> please tell ;)
>
> ---
>
> By the way - can you tell me what I have to do for answering in the mailing-list? I think I still don't understand how that works ;)
> With kind regards, Lukas

You simply reply to the e-mail (I assume that you do so). If you click
reply to all recipients than the mailing list address should appear as
either To or Cc. One thing that you should take care is to send only
plain text (no HTML).

Ilija


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Aw: Re: [ECOS] Debugging via JTAG - problems?

Lukas Riezler
Hi Ilija!

> How do you get to main? by single stepping? Breakpoint?
> Put breakpoint on hal_system_init() . That's an early breakpoint and
> will give you chance to step through system booting.

Yes, I did it by single stepping. Like you advised I tried it now with a breakpoint at hal_system_init().
Eclipse shows me that this breakpoint exists and it also shows me that the breakpoint is located in the correct file! That's good.
Now I try to "run" (with "Resume" / F8) the program until the breakpoint should halt it. But unfortunately nothing happens?

With kind regards,
Lukas

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Aw: Re: [ECOS] Debugging via JTAG - problems?

Lukas Riezler
In reply to this post by Ilija Kocho [Илија Кочо]
Hi Ilija!
 
> How do you get to main? by single stepping? Breakpoint?
> Put breakpoint on hal_system_init() . That's an early breakpoint and
> will give you chance to step through system booting.
 
Yes, I did it by single stepping. Like you advised I tried it now with a breakpoint at hal_system_init().
Eclipse shows me that this breakpoint exists and it also shows me that the breakpoint is located in the correct file! That's good.
Now I try to "run" (with "Resume" / F8) the program until the breakpoint should halt it. But unfortunately nothing happens?
 
With kind regards,
Lukas

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Re: Re: [ECOS] Debugging via JTAG - problems?

Edgar Grimberg-2
Resent for the list... first attempt failed due to HTML email.


On Thu, Apr 25, 2013 at 3:31 PM, Edgar Grimberg
<[hidden email]> wrote:

>
>
> On Thu, Apr 25, 2013 at 3:03 PM, Lukas Riezler <[hidden email]> wrote:
>>
>> Hi Ilija!
>>
>> > How do you get to main? by single stepping? Breakpoint?
>> > Put breakpoint on hal_system_init() . That's an early breakpoint and
>> > will give you chance to step through system booting.
>>
>> Yes, I did it by single stepping. Like you advised I tried it now with a breakpoint at hal_system_init().
>> Eclipse shows me that this breakpoint exists and it also shows me that the breakpoint is located in the correct file! That's good.
>> Now I try to "run" (with "Resume" / F8) the program until the breakpoint should halt it. But unfortunately nothing happens?
>
>
> Hi Lukas,
>
> Some advices related to debugging:
> - Be sure everything is compiled with -O0 (no optimization).
> - Try using the gdb in command line until you are sure you are doing the right thing.
> - If you are trying to debug I/O, don't mouse around in Eclipse, as you might trigger an unwanted read operation by hovering over a variable.
> - Be sure you have compiled the latest version of the source code.
> - Be sure you have loaded the elf file to the target (I assume it's a RAM application, isn't it?)
>
> Post the exact steps you are doing in command line gdb (copy + paste commands and output), it might be clearer like that.
>
> Regards,
> Edgar
>
>
>>
>>
>> With kind regards,
>> Lukas
>>
>> --
>> Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
>> and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
>>
>

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Aw: Re: Re: [ECOS] Debugging via JTAG - problems?

Lukas Riezler
Hi Edgar!
 
> - Be sure everything is compiled with -O0 (no optimization).
So I have to add this flag at the global build options in the configuration tool?

> - Be sure you have compiled the latest version of the source code.
I have ecos installed like it is described here: http://ecos.sourceware.org/getstart.html
Is this ecos source code the latest one? I know about the CVS but I thougt the only difference is that there are more ports listed.

> - Be sure you have loaded the elf file to the target (I assume it's a RAM application, isn't it?)
Yes, it is a RAM application. But I selected JTAG as startup type in the configuration tool.
But how can I get sure the elf file is loaded to the target? Sorry for my silly question :/
 
> - Try using the gdb in command line until you are sure you are doing the right thing.
> - Post the exact steps you are doing in command line gdb (copy + paste commands and output), it might be clearer like that.
 
I'll do that :)
 
 
With kind regards,
Lukas

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Re: Aw: Re: Re: [ECOS] Debugging via JTAG - problems?

Ilija Kocho [Илија Кочо]
On 25.04.2013 16:19, Lukas Riezler wrote:
> Hi Edgar!
>  
>> - Be sure everything is compiled with -O0 (no optimization).
> So I have to add this flag at the global build options in the configuration tool?
>
>> - Be sure you have compiled the latest version of the source code.
> I have ecos installed like it is described here: http://ecos.sourceware.org/getstart.html
> Is this ecos source code the latest one? I know about the CVS but I thougt the only difference is that there are more ports listed.

I strongly advise you to switch to CVS. Although it is not a release it
is pretty much stable. eCos CVS is not a development repository but
rather a rolling release.

>> - Be sure you have loaded the elf file to the target (I assume it's a RAM application, isn't it?)
> Yes, it is a RAM application. But I selected JTAG as startup type in the configuration tool.
> But how can I get sure the elf file is loaded to the target? Sorry for my silly question :/

It would be best to start with configuration that only employs on-chip
memory. I do not know your configuration (CDL, memory layout) so I shall
talk in terms of Kinetis and STM32 port. They have SRAM startup type
that is intended for usage with JTAG. Provided that your controller has
enough internal RAM this is the simplest way to bring system to life and
JTAG should work from scratch. ROM startup that uses only on-chip ROM
ans RAM is almost equally easy provided that you have a tool to program
controller's flash.

To sum up try to build system with on-chip memory first.

Ilija


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Aw: Re: Re: Re: [ECOS] Debugging via JTAG - problems?

Lukas Riezler
Hello Ilja & Edgar!
 
>I strongly advise you to switch to CVS. Although it is not a release it
>is pretty much stable. eCos CVS is not a development repository but
>rather a rolling release.
 
Okay, I'll switch to the CVS source during this weekend :)
 
>It would be best to start with configuration that only employs on-chip
>memory. I do not know your configuration (CDL, memory layout) so I shall
>talk in terms of Kinetis and STM32 port. They have SRAM startup type
>that is intended for usage with JTAG. Provided that your controller has
>enough internal RAM this is the simplest way to bring system to life and
>JTAG should work from scratch. ROM startup that uses only on-chip ROM
>ans RAM is almost equally easy provided that you have a tool to program
>controller's flash.
>To sum up try to build system with on-chip memory first.
 
I've changed the startup type to SRAM.

Now it looks a little bit better: I reach hal_reset_vsr() in the architecture HAL.
The problem I have now is that I hang at the line
 
__asm__ volatile("swi");
 
Does this indicates a specific matter I have not attended to?
 
Please don't get me wrong - I'm not too lazy for researching solutions for my problems. But in this theme I don't really know how I could handle my problems. So thank you very much for all your previous answers!

Have a nice weekend, Lukas

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Aw: Re: Re: Re: [ECOS] Debugging via JTAG - problems?

Lukas Riezler
In reply to this post by Ilija Kocho [Илија Кочо]
Does not anybody have an idea why I'm hanging with my debugging problem?
 
I did the clocking...cdl, linker scripts, sources and headers are matched to my new FM3 hardware.
I've no idea what I additional could do or where a mistake could be.
 
With kind regards, Lukas

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Re: Aw: Re: Re: Re: [ECOS] Debugging via JTAG - problems?

Ilija Kocho [Илија Кочо]
In reply to this post by Lukas Riezler
On 26.04.2013 15:00, Lukas Riezler wrote:

> Hello Ilja & Edgar!
>  
>> I strongly advise you to switch to CVS. Although it is not a release it
>> is pretty much stable. eCos CVS is not a development repository but
>> rather a rolling release.
>  
> Okay, I'll switch to the CVS source during this weekend :)
>  
>> It would be best to start with configuration that only employs on-chip
>> memory. I do not know your configuration (CDL, memory layout) so I shall
>> talk in terms of Kinetis and STM32 port. They have SRAM startup type
>> that is intended for usage with JTAG. Provided that your controller has
>> enough internal RAM this is the simplest way to bring system to life and
>> JTAG should work from scratch. ROM startup that uses only on-chip ROM
>> ans RAM is almost equally easy provided that you have a tool to program
>> controller's flash.
>> To sum up try to build system with on-chip memory first.
>  
> I've changed the startup type to SRAM.
>
> Now it looks a little bit better: I reach hal_reset_vsr() in the architecture HAL.
> The problem I have now is that I hang at the line
>  
> __asm__ volatile("swi");

This exception should pass without problems, but your debugger may have
problem stepping through it while continual run may pass. Have tried to
put breakpoint(s) after this line?


>  
> Does this indicates a specific matter I have not attended to?
>  
> Please don't get me wrong - I'm not too lazy for researching solutions for my problems. But in this theme I don't really know how I could handle my problems. So thank you very much for all your previous answers!
>
> Have a nice weekend, Lukas
>


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Aw: Re: Re: Re: Re: [ECOS] Debugging via JTAG - problems?

Lukas Riezler
>This exception should pass without problems, but your debugger may have
>problem stepping through it while continual run may pass. Have tried to
>put breakpoint(s) after this line?

Not directly, because I noticed something "new"...

I tried to debug via the command line (like Edgar advised me):
I can set a breakpoint at hal_system_init() without problems but when I try to set a breakpoint at the main() which is in my "Hello World" file, I get following message:

Make breakpoint pending on future shared library load? (y or or [n]) [answered N; input not from terminal]
(gdb) Function "main" not defined

I've read that I have to use the command "set breakpoint pending on" if I want to answer the question with YES.
But main is still not defined :/
That sounds like a linking problem, doesn't it?


With kind regards, Lukas

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Aw: Re: Re: Re: Re: [ECOS] Debugging via JTAG - problems?

Lukas Riezler
Add on:
I use the makefile from the examples package! When I look in Eclipse and "open" there my elf file by clicking on it, I can see all the files which are "included" in this elf file. There is my "Hello World" file listed (where my main() is located) - but why does then gdb tell me that the function main() is not defined?
 
With kind regards,
Lukas

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Aw: Re: Re: Re: Re: [ECOS] Debugging via JTAG - problems?

Lukas Riezler

Hi all,
 
sorry for my mail storm! ;)
The problems I've told from in the last 2-3 mails are over.
 
I reach now my main(). I think the problem was my interrupt stacksize which was too big.
Okay, now I reach main() - but I can't really do any steps. The "debug cursor" always stays
at the first line.
Is this a "normal" problem or does it indicate anything I should know?

The function looks like this (only some lines of code for test purposes):

__________________________

int main()
{
 int i=0;
 int k=0;

 while(1)
 {
   if(i==0) k=0;
   else k=1;
 }

 return 0;
}
__________________________


With kind regards, Lukas

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Re: Aw: Re: Re: Re: Re: [ECOS] Debugging via JTAG - problems?

Ilija Kocho [Илија Кочо]
It is likely that compiler has optimised the code out. Try to declare
the variables volatile or some output with diag_printf(). Or compile
with -O0.
I hope this helps.

Ilija

On 08.05.2013 01:24, Lukas Riezler wrote:

> Hi all,
>  
> sorry for my mail storm! ;)
> The problems I've told from in the last 2-3 mails are over.
>  
> I reach now my main(). I think the problem was my interrupt stacksize which was too big.
> Okay, now I reach main() - but I can't really do any steps. The "debug cursor" always stays
> at the first line.
> Is this a "normal" problem or does it indicate anything I should know?
>
> The function looks like this (only some lines of code for test purposes):
>
> __________________________
>
> int main()
> {
>  int i=0;
>  int k=0;
>
>  while(1)
>  {
>    if(i==0) k=0;
>    else k=1;
>  }
>
>  return 0;
> }
> __________________________
>
>
> With kind regards, Lukas
>


--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

Reply | Threaded
Open this post in threaded view
|

Aw: Re: Re: Re: Re: Re: [ECOS] Debugging via JTAG - problems?

Lukas Riezler
>It is likely that compiler has optimised the code out. Try to declare
>the variables volatile or some output with diag_printf(). Or compile
>with -O0.
>I hope this helps.

Thank you very much - it works!!! :)

With kind regards, Lukas

--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss