Coder Social home page Coder Social logo

JTAG primer about edbg HOT 3 CLOSED

ooxi avatar ooxi commented on September 3, 2024
JTAG primer

from edbg.

Comments (3)

ataradov avatar ataradov commented on September 3, 2024 1

For JTAG in CMSIS-DAP there are two distinct modes. First one is the normal transfers. This is ARM specific, but more standard, of course.

For this mode to work, simply replace

  dap_connect(DAP_INTERFACE_SWD);

with

  dap_connect(DAP_INTERFACE_JTAG);
  dap_jtag_configure(2, (int[]){ 4, 5 });
  dap_jtag_set_index(0);

Here 4 and 5 are IR lengths of the devices in the JTAG chain. Many ARM device (STM32f4xx in this case) have 2 devices in the chain. One is for boundary scan (5) and one for the ARM core (4). devices are declared in the order starting from the end of the chain (first device attached to TDO). And index is the index of the device corresponding to the ARM core (0 in this case, as the core is last in the chain).

After that the resto of the code would work as is. In my tests I used "dap_read_word(0xe0042000);". This is where ID of the device is located. And this worked for both JTAG and SWD mode only with the change above. I did not implement the whole driver, as I have no particular need for that device. I just used it as a test target.

If there are any other external devices in the chain, they need to be added too. If there is an actual need to support some JTAG-only device, then this would be passed through the command line.

The second mode is just bit banging, which would work for any device. OpenOCD uses this mode exclusively for everything.

The example of this mode is in the function dap_jtag_scan_chain(). It does some basic operation of resetting the JTAG TAP, shifting out the DR until it reads 0, those enumerating all IDCODEs for all the devices. It then measures the total length of the IR registers in the chain (9 in this case).

This is as much of the automated identification as you can do. It is impossible to identify individual IR lengths of the devices. You just need to have a huge database of IDCODEs and corresponding lengths.

JTAG mode here was added for testing of the free-dap implementation. I just did not want to throw away the effort completely, so I packaged it into the minimal changes that made sense.

It would probably be changed a bit once there is a real need to support JTAG-only device. It is likely to be some FPGA rather than MCU though.

from edbg.

ataradov avatar ataradov commented on September 3, 2024 1

I've added a first real JTAG-only target. It is Lattice LCMXO2 FPGA.

I had a project where I needed to program the FPGA from the MCU anyway, so I just ported that code to edbg.

from edbg.

ooxi avatar ooxi commented on September 3, 2024

Thank you very much for such a detailed response. I'll try to play around with it a bit and will come back if I need additional support.

from edbg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.