mbed JTAG mechanism

02 Jun 2011

Hi,

LPC1768 is connected to the underside chip LPC2138 for downloading, semihosting, serial to USB

I have measured with oscilloscope

1) JTAG lines are active and data is passed every 10ms. This is happening continuously! NEVER STOPS

2) Reset when activated is LOW for 250ms then HIGH for 25ms then LOW 25ms and finally is HIGH

3) Reset is not activated when the reset-button is pressed if [the JTAG lines are not connected from LPC2148 to LPC1768]

It seems that large mbed program DO NOT RUN on a LPC1768 board other than mbed.

It only RUN if it is reset by LPC2148 connected with JTAG and RESET to target LPC1768.

If LPC2148 is disconnected and Power is OFF then

Program does not RUN or it RUNS partially (USB file can not open)

Is it the above RESET pattern that needed

Or, is it something hidden in the mbed library that has to 'see' the LPC2148 of the mbed-board?

I checked the case that the RESET pattern could solve the issue,

NO, I replicated the above RESET-pattern, no difference!

OR it could be that LPC1768 stays in something like debug-mode?

02 Jun 2011

Hi,..

I must admit I don't understand a lot of your post, but if you search for "FlashMagic" on this site, you'll see that the mbed code will run on a product 1768 board without the exta "mbed" bits.

The mbed gives you an easy compiler and an easy way of getting the code you've written into the 1768, but you can take that code and get it into a 1768 using a bin to hex converter, and flashmagic.

cheers

Dave.

02 Jun 2011

Hi Nikos,

Here are a few explanations which hopefully make it clear what you are seeing:

The interface chip provides a number of services as you say; downloading, semihosting and the serial to USB. The serial to USB is just a pass through of the LPC1768 UART in to a virtual USB Com port, so we can ignore that one (it is basically transparent to the LPC1768, as if you were using a RS232-USB converter).

To support downloading, the interface uses JTAG; when you hit reset, it will use the JTAG interface to transfer the code as any normal debugger would.

To support semihosting (which is used to provide special debug services such as the LocalFileSystem, getting a UID, etc), the interface must use JTAG to poll the target to see if it has requested a service (i.e. a breakpoint); this is a non-invasive poll like any debugger providing semihost services would do. Only if the target has actually requested anything will it do anything about it.

An LPC1768 binary will run on an mbed or bare metal target fine, assuming you don't use one of these special mbed services. The likely ones would be:

  • Accessing the mbed interface LocalFileSystem
  • Requesting the UID/MAC Address of the mbed interface

If you are using networking code, it may well be requesting the mbed MAC address (this is the most likely non-obvious use of the interface). You will need to provide your own MAC address somehow (hard coded, as part of your program, etc). You can see how to reimplement that on the Ethernet page:

There is no hidden code to try and check the interface is there :)

Hope that makes things clear.

Simon

02 Jun 2011

Hi Simon,

The "no hidden code" statement is very welcome :)

My Hardware Setup:

- MyTargetLPC1769Board connects to

- RS232 level translator- then to PC serial port

- Modified-mbed (desoldered LPC1768) then to PC USB port

So I can download to target via modified mbed (JTAG), or via Flashmagic (bootloader) without disconnect anything.

I use NO Ethernet. I am using the published madplayer project with some minor additions, Reading the MP3 files from USB stick.

It is not clear to me how and if the USB related libraries are using the LocalFileSystem. Do all filesystem libraries have the same problem? I don't need the LocalFileSystem. Only the USB-stick

I tried with bin2hex/Flashmagic recipe ( switch /4 for larger programs) It works only if there is the JTAG connection ACTIVE.

IS THERE A WAY TO OVERCOME THIS ISSUE AND READ THE USB-STICK FROM MY TARGET BOARD?

02 Jun 2011

Here: http://mbed.org/handbook/LocalFileSystem

Says

Other filesystems (such as ones to talk to an SD card, or a USB FLASH drive) run on the target itself, so don't talk to the mbed Interface at all and these restrictions don't necessarily apply.

But seems that we have different situation...

02 Jun 2011

Hi Nikos,

Just to confirm, are you using the USB Host interface to access a USB Flash drive on an LPC1768, thats is *not* and mbed?

If you are using Igor's code, you might be interest to know that I have republished this as a library. The published library contains a fix, that, although completely unverified, has so far seemed to solve the problem of the USB MSC library not working on a stand alone LPC1768. The fix was to remove the WFI(); call in Host_WDHWait() found in usbhost_lpc17xx.c.

If it is Igors code you were using previously on a custom LPC1768 board, you might find this fix solves your problem.

Cheers, Chris

02 Jun 2011

MSCFileSystem.cpp

MSCFileSystem.h

Are in the project, There is igor's name in the header

I Guess are the ones you mention as "igor's" code

As I undersatnd, I will remove these files from the project.

Which library should I import? MSCFileSystem_Lib ???

02 Jun 2011

It should be: MSCFileSystem

at http://mbed.org/users/chris/libraries/MSCFileSystem/ls4sbj

I imported this one to the project and I deleted MSCFileSystem.cpp, MSCFileSystem.h

But now I have a lot of ERRORS

What to do?

02 Jun 2011

Hi Nikos,

well that certainly sounds like Igors code.

As well as the two files you list, there is probably a folder called USBHostLite.

If you;'d rather just make the modifications in your existing code rather than import new libraries, open the usbhost_lpc17xx.c, found in the USBHostLite folder, and at around line 618, change the Host_WDHWait() function so it looks like this :

void  Host_WDHWait (void)
{
  while (!HOST_WdhIntr) {
    ;
  }
  HOST_WdhIntr = 0;
}

That might just fix the problem you are seeing.

Cheers, Chris

02 Jun 2011

YES CHRIS,

:) IT WORKS :)

My LPC1769 board reads the USB-stick, stand alone

You are exactly ON-TARGET

THIS IS GREAT SUPPORT !!

THANKS

25 Aug 2011

can anyone post me jtag emulator code for mbed.. plzzz

25 Aug 2011

Prashant Achari wrote:

can anyone post me jtag emulator code for mbed.. plzzz