FPGARelated.com
Forums

Nios II debugging with gdb

Started by David Brown August 18, 2004
I'm working with a Nios II processor on an Altera fpga.  Mostly, I'm doing
fine, but there is one feature of the Eclipse interface to gdb that I seem
to be missing - a gdb command window.  There is a "nios2-gdb-server output"
option for the Console window, but that's for output only.  I want to be
able to type my own commands.  When using other gui front-ends for gdb,
including gvd, insight and ddd, there is no problem doing this, but I can't
find any way to get it in Eclipse.

If I can't get this working, does anyone know of information about using gdb
directly from the command line on the Nios2, such as references for the
nios2-gdb-server parameters?

--
David

"I love deadlines.  I love the whooshing noise they make as they go past."
Douglas Adams


"David Brown" <david@no.westcontrol.spam.com> wrote in message news:<cfv864$qi8$1@news.netpower.no>...
> I'm working with a Nios II processor on an Altera fpga. Mostly, I'm doing > fine, but there is one feature of the Eclipse interface to gdb that I seem > to be missing - a gdb command window. There is a "nios2-gdb-server output" > option for the Console window, but that's for output only. I want to be > able to type my own commands. When using other gui front-ends for gdb, > including gvd, insight and ddd, there is no problem doing this, but I can't > find any way to get it in Eclipse. > > If I can't get this working, does anyone know of information about using gdb > directly from the command line on the Nios2, such as references for the > nios2-gdb-server parameters?
Hi David, Here is some info on this from our engineering team: GDB console from the IDE: 1) Start a debug session in the IDE. 2) In the toolbar for the console window, select the triangle next to the "display output from selected processes" icon (which looks like a the "man who looks like he just got a beer from the fridge" icon). 3) Select the "Show Default Output" from the menu. This will switch the Console window to "Nios II Debugger". 4) To allow the user to type gdb commands in this window you need to click the "Show debugger console on target selection" icon from the debug toolbar (right next to the familiar "Step Return/Step Out" debug icon). 5) You can now type gdb commands in the console window. Ensure that your cursor is at the bottom line of the window. Alternatively, here is how you would do the same, but from the command line: 1) Launch a Nios SDK shell from the "Start" menu. 2) Type "nios2-gdb-server". It will tell you what port it's listening on. 3) Write-down the port-number printed by nios2-gdb-server on a post-it note. 4) Launch a *second* Nios SDK shell from the "Start" menu. 5) Type "nios2-elf-gdb" 6) At the (gdb) prompt, type: "target remote localhost:<PORT-NUMBER> 7) You're now talking to the target using command-line gdb. I don't think there's any gdb-command-line facility from *within* the eclipse environment, but you'd better get an answer from Peter Brookes (copied on this message) on that one. If you want to know the command-line parameters for nios2-gdb-server, type "nios2-gdb-server --help."
"David Brown" <david@no.westcontrol.spam.com> wrote in message news:<cfv864$qi8$1@news.netpower.no>...
> I'm working with a Nios II processor on an Altera fpga. Mostly, I'm doing > fine, but there is one feature of the Eclipse interface to gdb that I seem > to be missing - a gdb command window. There is a "nios2-gdb-server output" > option for the Console window, but that's for output only. I want to be > able to type my own commands. When using other gui front-ends for gdb, > including gvd, insight and ddd, there is no problem doing this, but I can't > find any way to get it in Eclipse. > > If I can't get this working, does anyone know of information about using gdb > directly from the command line on the Nios2, such as references for the > nios2-gdb-server parameters?
Hi David (and other readers), Please disregard the 2nd to last paragraph in my reply to your question; I did not intend to post that, but pressed the button too soon! Quite obviously there is a method from the IDE (Mr. Brookes provided it). Jesse Kempa Altera Corp. jkempa at altera dot com
"David Brown" <david@no.westcontrol.spam.com> wrote in message news:<cfv864$qi8$1@news.netpower.no>...
> I'm working with a Nios II processor on an Altera fpga. Mostly, I'm doing > fine, but there is one feature of the Eclipse interface to gdb that I seem > to be missing - a gdb command window. There is a "nios2-gdb-server output" > option for the Console window, but that's for output only. I want to be > able to type my own commands. When using other gui front-ends for gdb, > including gvd, insight and ddd, there is no problem doing this, but I can't > find any way to get it in Eclipse. > > If I can't get this working, does anyone know of information about using gdb > directly from the command line on the Nios2, such as references for the > nios2-gdb-server parameters?
Hi David (and other readers), Please disregard the 2nd to last paragraph in my reply to your question; I did not intend to post that, but pressed the button too soon! Quite obviously there is a method from the IDE (Mr. Brookes provided it). Jesse Kempa Altera Corp. jkempa at altera dot com
Hi,

I don't know what Mr. Brookes method is, since it was not posted here.
Perhaps he (or you) tried to email me a copy, but failed to notice the "no
spam" addition to my news-posting address.

However, just at the moment I have a far bigger problem that is stopping me
doing any debugging at all - nios2-gdb-server is now refusing to connect to
my Nios2 jtag port.  I have tried all sorts of things, including rebuilding
a new (fairly minimal) nios2 design on my board, with no luck.  The last
thing I did was take a test project I made on my original Nios Cyclone
development kit and replace the Nios 1 with a Nios 2, and I still can't get
any contact.  This is hardware that I know without doubt is working fine - I
can download designs with the jtag interface (ByteBlaster II), and can
connect gdb to the Nios 1 design.  But I can no longer contact a Nios 2 for
debugging over the jtag interface.  When I run
"nios2-gdb-server --verbosity=4" and try to connect to it with
nios2-elf-gdb, I get the information:

# [nios2-gdb-server] g_verbosity: 4
# [nios2-gdb-server] nios2-gdb-server listening on port 2342
# [nios2-gdb-server] accepting gdb connection
# [nios2-gdb-server] connecting to JTAG debug module
# [nios2-gdb-server] CPU will be reset on connect
# [nios2-gdb-server] JTAG cable: ""
# [nios2-gdb-server] JTAG device: -1
# [nios2-gdb-server] JTAG debug module instance: -1
# [nios2-gdb-server] using MDI port: "sld"
# [nios2-gdb-server] MDI error FindAndOpenNode Lock Chain:
AJI_BAD_HARDWARE. -105 (nios2-gdb-server_mdi.c line 161)
# [nios2-gdb-server] failed to connect

Similarly, the IDE debug setup finds my ByteBlasterII on lpt1, but reports
<no devices connected> for the jtag device.  I had this same effect when I
first used the Nios 2, with the ByteBlaster II connected to lpt2.  This
worked fine for the Nios, and for downloading fpga designs, but the Nios2
debugger could not see the Nios 2.  Switching to lpt1 fixed that.  I was not
too surprised with that, since I have had little luck getting my lpt2 card
to work with other jtag-type debuggers - in fact, I was very surprised when
it *did* work with the Nios 1.

I've now tried everything I can think of, so if anyone else has any bright
ideas for me, I'd be very grateful!

David






"Jesse Kempa" <kempaj@yahoo.com> wrote in message
news:95776079.0408181242.3398fe9e@posting.google.com...
> "David Brown" <david@no.westcontrol.spam.com> wrote in message
news:<cfv864$qi8$1@news.netpower.no>...
> > I'm working with a Nios II processor on an Altera fpga. Mostly, I'm
doing
> > fine, but there is one feature of the Eclipse interface to gdb that I
seem
> > to be missing - a gdb command window. There is a "nios2-gdb-server
output"
> > option for the Console window, but that's for output only. I want to be > > able to type my own commands. When using other gui front-ends for gdb, > > including gvd, insight and ddd, there is no problem doing this, but I
can't
> > find any way to get it in Eclipse. > > > > If I can't get this working, does anyone know of information about using
gdb
> > directly from the command line on the Nios2, such as references for the > > nios2-gdb-server parameters? > > Hi David (and other readers), > > Please disregard the 2nd to last paragraph in my reply to your > question; I did not intend to post that, but pressed the button too > soon! Quite obviously there is a method from the IDE (Mr. Brookes > provided it). > > Jesse Kempa > Altera Corp. > jkempa at altera dot com
"David Brown" <david@no.westcontrol.spam.com> wrote in message news:<cg2eqt$s7v$1@news.netpower.no>...
> Hi, > > I don't know what Mr. Brookes method is, since it was not posted here. > Perhaps he (or you) tried to email me a copy, but failed to notice the "no > spam" addition to my news-posting address. > > However, just at the moment I have a far bigger problem that is stopping me > doing any debugging at all - nios2-gdb-server is now refusing to connect to > my Nios2 jtag port. I have tried all sorts of things, including rebuilding > a new (fairly minimal) nios2 design on my board, with no luck. The last > thing I did was take a test project I made on my original Nios Cyclone > development kit and replace the Nios 1 with a Nios 2, and I still can't get > any contact. This is hardware that I know without doubt is working fine - I > can download designs with the jtag interface (ByteBlaster II), and can > connect gdb to the Nios 1 design. But I can no longer contact a Nios 2 for > debugging over the jtag interface. When I run > "nios2-gdb-server --verbosity=4" and try to connect to it with > nios2-elf-gdb, I get the information: > > # [nios2-gdb-server] g_verbosity: 4 > # [nios2-gdb-server] nios2-gdb-server listening on port 2342 > # [nios2-gdb-server] accepting gdb connection > # [nios2-gdb-server] connecting to JTAG debug module > # [nios2-gdb-server] CPU will be reset on connect > # [nios2-gdb-server] JTAG cable: "" > # [nios2-gdb-server] JTAG device: -1 > # [nios2-gdb-server] JTAG debug module instance: -1 > # [nios2-gdb-server] using MDI port: "sld" > # [nios2-gdb-server] MDI error FindAndOpenNode Lock Chain: > AJI_BAD_HARDWARE. -105 (nios2-gdb-server_mdi.c line 161) > # [nios2-gdb-server] failed to connect > > Similarly, the IDE debug setup finds my ByteBlasterII on lpt1, but reports > <no devices connected> for the jtag device. I had this same effect when I > first used the Nios 2, with the ByteBlaster II connected to lpt2. This > worked fine for the Nios, and for downloading fpga designs, but the Nios2 > debugger could not see the Nios 2. Switching to lpt1 fixed that. I was not > too surprised with that, since I have had little luck getting my lpt2 card > to work with other jtag-type debuggers - in fact, I was very surprised when > it *did* work with the Nios 1. > > I've now tried everything I can think of, so if anyone else has any bright > ideas for me, I'd be very grateful! > > David
Hi David, Sorry, the reference to that gentleman was only in the context of talking to GDB directly from within the IDE as you had originally inquired about - I posted that information during the first reply (I just forgot to remove some of the email chain that wasn't relevant to your question). About your problem: Can you download/debug a hello-world type application without doing the gdb commands manually? This would be a good starting point. One thing I noticed from the error message dump is that there is no JTAG cable ("") -- you might try the following: Make a new "run" or "debug" target in the IDE (this is covered in the Nios II SW dev tutorial in the IDE on-line help), and in the 'Run' screen go to 'Target Connection' and manually pick the programming cable you're using from the drop-down, and if necessary the device in the JTAG chain (if there are multiple devices). Here you can also 'Refresh' the lists to see that things are being detected properly. This is necessary more often than not if you have two programming cables installed (and it sounds like you might, one in lpt1, and one in lpt2). FYI, the "list" of programming cables comes from Quartus (what ever programming cables the Quartus programmer sees, the IDE will have access to). If the above doesn't help I'd suggest that you contact your FAE or Altera support team for some one-on-one help on the issue. Jesse Kempa Altera Corp. jkempa at altera dot com
Hi,

I've got it working again - comments underneath.


"Jesse Kempa" <kempaj@yahoo.com> wrote in message
news:95776079.0408191527.4bf80942@posting.google.com...
> "David Brown" <david@no.westcontrol.spam.com> wrote in message
news:<cg2eqt$s7v$1@news.netpower.no>...
> > Hi, > > > > I don't know what Mr. Brookes method is, since it was not posted here. > > Perhaps he (or you) tried to email me a copy, but failed to notice the
"no
> > spam" addition to my news-posting address. > > > > However, just at the moment I have a far bigger problem that is stopping
me
> > doing any debugging at all - nios2-gdb-server is now refusing to connect
to
> > my Nios2 jtag port. I have tried all sorts of things, including
rebuilding
> > a new (fairly minimal) nios2 design on my board, with no luck. The last > > thing I did was take a test project I made on my original Nios Cyclone > > development kit and replace the Nios 1 with a Nios 2, and I still can't
get
> > any contact. This is hardware that I know without doubt is working
fine - I
> > can download designs with the jtag interface (ByteBlaster II), and can > > connect gdb to the Nios 1 design. But I can no longer contact a Nios 2
for
> > debugging over the jtag interface. When I run > > "nios2-gdb-server --verbosity=4" and try to connect to it with > > nios2-elf-gdb, I get the information: > > > > # [nios2-gdb-server] g_verbosity: 4 > > # [nios2-gdb-server] nios2-gdb-server listening on port 2342 > > # [nios2-gdb-server] accepting gdb connection > > # [nios2-gdb-server] connecting to JTAG debug module > > # [nios2-gdb-server] CPU will be reset on connect > > # [nios2-gdb-server] JTAG cable: "" > > # [nios2-gdb-server] JTAG device: -1 > > # [nios2-gdb-server] JTAG debug module instance: -1 > > # [nios2-gdb-server] using MDI port: "sld" > > # [nios2-gdb-server] MDI error FindAndOpenNode Lock Chain: > > AJI_BAD_HARDWARE. -105 (nios2-gdb-server_mdi.c line 161) > > # [nios2-gdb-server] failed to connect > > > > Similarly, the IDE debug setup finds my ByteBlasterII on lpt1, but
reports
> > <no devices connected> for the jtag device. I had this same effect when
I
> > first used the Nios 2, with the ByteBlaster II connected to lpt2. This > > worked fine for the Nios, and for downloading fpga designs, but the
Nios2
> > debugger could not see the Nios 2. Switching to lpt1 fixed that. I was
not
> > too surprised with that, since I have had little luck getting my lpt2
card
> > to work with other jtag-type debuggers - in fact, I was very surprised
when
> > it *did* work with the Nios 1. > > > > I've now tried everything I can think of, so if anyone else has any
bright
> > ideas for me, I'd be very grateful! > > > > David > > Hi David, > > Sorry, the reference to that gentleman was only in the context of > talking to GDB directly from within the IDE as you had originally > inquired about - I posted that information during the first reply (I > just forgot to remove some of the email chain that wasn't relevant to > your question). >
I see what you mean now - you had given me instructions how to do what I wanted (although I couldn't try it until now), along with a note saying it couldn't be done... I've now got my gdb command prompt from within Eclipse, just as I wanted.
> About your problem: Can you download/debug a hello-world type > application without doing the gdb commands manually? This would be a > good starting point. One thing I noticed from the error message dump
I couldn't get that far - I'd have been happy getting a "0x00000000 in ?? ()" message indicating some contact with gdb.
> is that there is no JTAG cable ("") -- you might try the following: > Make a new "run" or "debug" target in the IDE (this is covered in the > Nios II SW dev tutorial in the IDE on-line help), and in the 'Run' > screen go to 'Target Connection' and manually pick the programming > cable you're using from the drop-down, and if necessary the device in > the JTAG chain (if there are multiple devices). Here you can also > 'Refresh' the lists to see that things are being detected properly. > This is necessary more often than not if you have two programming > cables installed (and it sounds like you might, one in lpt1, and one > in lpt2). >
I'd been doing that until I was blue in the face...
> FYI, the "list" of programming cables comes from Quartus (what ever > programming cables the Quartus programmer sees, the IDE will have > access to). >
I had two cables in the jtag setup from Quartus programmer, and had tried swapping between them - both worked fine for programming from Quartus. What finally got the debugger working was to remove lpt2 from the Quartus setup - after that, the IDE had no problem seeing the Nios2 and selecting it automatically. I can see now why running gdb-server from the command-line was unlikely to work when I had two cables set up - I had tried without specifing a cable, and with "lpt1" and "lpt2" as cable arguements. Now when I run nios2-gdb-server from the command line, it reports the cable as "ByteBlasterII [LPT1]", so maybe I should have specified that whole string. Anyway, I'm only using one board at a time, so I'm happy enough with just lpt1 setup. The strange thing is that both were set up in Quartus the other day when Nios2 debugging was working fine. Perhaps there is an obscure bug in the debugger server - after all, I doubt that two parallel port cables is a setup that has figured greatly in testing, and I suppose I'll be moving to a USB Blaster before long anyway.
> If the above doesn't help I'd suggest that you contact your FAE or > Altera support team for some one-on-one help on the issue. >
I've talked to him, and he was going to ask others at Altera. I'm happy that my debugging is now working exactly as I wanted, both on the development kit and my own hardware. Many thanks! David
> Jesse Kempa > Altera Corp. > jkempa at altera dot com