Author Topic: GDB debugging on HW?  (Read 11935 times)

0 Members and 3 Guests are viewing this topic.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
GDB debugging on HW?
« on: November 22, 2014, 09:55:42 am »
So, as there is gdbstub in nspire_emu and OCD.
I thought about combinging these two and support native GDB debugging on calc either over serial or USB with NavNet and libti*/libnspire
Would there be interest in this? If yes, USB or serial? Both have some downsides.
« Last Edit: November 22, 2014, 10:00:57 am by Vogtinator »

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: GDB debugging on HW?
« Reply #1 on: November 22, 2014, 10:29:54 am »
I know it might be (much) more complex, but what about having the TI-Nspire behave as an RNDIS network device (or similar, the same way as the CAS+ works)? The TI-Nspire uses the BSD usb implementation so it might be possible to use it as network gadget. That way you could have the GDB stuff over a socket.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: GDB debugging on HW?
« Reply #2 on: November 22, 2014, 11:08:04 am »
If the usb gadget api functions were known it'd be possible, but for now there are only the usbd_ functions, which don't support gadget mode, do they?
Otherwise it would be easy to implement the MTP protocol for easier file transfer as well.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: GDB debugging on HW?
« Reply #3 on: November 22, 2014, 12:26:28 pm »
Ah, I didn't check what API functions were exposed. I never really looked into the usb library.

In any case I think it can be very interesting, mainly USB debugging considering that most people don't have an RS-232 TTL level adaptor.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: GDB debugging on HW?
« Reply #4 on: November 23, 2014, 12:26:39 pm »
Hmmm, why not just hijack the USB controller and run a better USB stack of our own ? I think this would solve the issue of not having control over it (if it's not too much of a complex solution).
Also, having a serial console over the USB port in addition to GDB and a better file transfer protocol would rock.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: GDB debugging on HW?
« Reply #5 on: November 23, 2014, 12:47:33 pm »
Yeah, a custom USB stack for device mode would be great, but much work. You can read http://wiki.osdev.org/USB to get an idea on how insanely much work that'd be.
It may be possible to adapt an existing stack though, for example from libraries for microcontrollers.

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: GDB debugging on HW?
« Reply #6 on: November 23, 2014, 01:43:39 pm »
Yeah, I've heard about how much of a pain USB is. <_< I didn't want to implement a stack from scratch lol, that would take years.

Offline bb010g

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 428
  • Rating: +22/-1
  • I do stuff
    • View Profile
    • elsewhere on the net
Re: GDB debugging on HW?
« Reply #7 on: November 23, 2014, 03:48:44 pm »
Arch Linux user
Haskell newbie | Warming up to Lua | Being dragged into C++
Calculators: HP 50g, HP 35s, Casio Prizm, TI-Nspire CX CAS, HP 28s, HP Prime, Mathematica 9 (if that counts)
π: 3.14...; l: 108; i: 105; e: 101; l+i+e: 314
THE CAKE IS A LIE IS A PIE

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: GDB debugging on HW?
« Reply #8 on: November 23, 2014, 04:11:58 pm »
That's the wrong side. libusb is for Host (PC) -> Device (nspire). What we're searching for is on the device side.

Offline tangrs

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 229
  • Rating: +98/-0
    • View Profile
    • tangrs blog
Re: GDB debugging on HW?
« Reply #9 on: November 26, 2014, 05:26:09 pm »
It's definitely possible to debug the calculator through serial. GDB has built in support for attaching to serial.

I actually wrote an implementation of the GDB server protocol for one of my projects with breakpoint support and everything. I'll post it up if I find it.


Incidentally, the project I used this in was in writing a minimal USB stack for the TI-Nspire - the lesson learned: it's hard. If anyone wants the full source code of the project (it's pretty much dead now), I'll be glad to post it. The USB stack has enumeration working but no actual transfer of data.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: GDB debugging on HW?
« Reply #10 on: November 27, 2014, 06:34:48 am »
Quote
It's definitely possible to debug the calculator through serial. GDB has built in support for attaching to serial.
Yeah, as long as data can be sent and received, GDB supports it.

Quote
I actually wrote an implementation of the GDB server protocol for one of my projects with breakpoint support and everything. I'll post it up if I find it.
Is it better than nspire_emu's?

Quote
Incidentally, the project I used this in was in writing a minimal USB stack for the TI-Nspire - the lesson learned: it's hard. If anyone wants the full source code of the project (it's pretty much dead now), I'll be glad to post it. The USB stack has enumeration working but no actual transfer of data.
Host or device stack? Host wouldn't be so interesting, as the BSD api is already working. Or does the device side also require enumeration?

Offline tangrs

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 229
  • Rating: +98/-0
    • View Profile
    • tangrs blog
Re: GDB debugging on HW?
« Reply #11 on: November 29, 2014, 08:28:10 am »

Quote
Is it better than nspire_emu's?

Depends on whether you like GDB better or the nspire_emu debugger better :)

Quote
Host or device stack? Host wouldn't be so interesting, as the BSD api is already working. Or does the device side also require enumeration?

It's a device stack.

Offline Vogtinator

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1193
  • Rating: +108/-5
  • Instruction counter
    • View Profile
Re: GDB debugging on HW?
« Reply #12 on: November 29, 2014, 08:30:44 am »
Quote
Is it better than nspire_emu's?
Depends on whether you like GDB better or the nspire_emu debugger better :)
I meant nspire_emu's GDB stub.

Quote
Quote
Host or device stack? Host wouldn't be so interesting, as the BSD api is already working. Or does the device side also require enumeration?
It's a device stack.
Then the source code would actually be quite interesting. Is it for CX, Classic or even both?

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: GDB debugging on HW?
« Reply #13 on: December 02, 2014, 04:59:19 pm »
I'm not sure nspire_emu's GDB is much used, neither is OCD. So you wouldn't find a broader audience, but it would indeed be technically interesting :)
Ndless.me with the finest TI-Nspire programs

Offline Legimet

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 336
  • Rating: +29/-0
    • View Profile
Re: GDB debugging on HW?
« Reply #14 on: December 02, 2014, 10:45:34 pm »
Well, the reason I don't use GDB is because it's not supported for the make-prg'd Zehn files (is that still true?), and I use 3.1 for testing stuff (because it's faster, especially with file transfers). If Zehn support is backported to 3.1, I'll probably use it.
« Last Edit: December 02, 2014, 10:50:45 pm by Legimet »