How to get ARM code unto an actual device, JTAG? Possible to make Impromptu JTAG with Arduino?
Asked Answered
G

3

14

Ok, I am a little confused about programming for ARM processors. Barrage of questions time:

  • How does one get the compiled binary into an ARM processor?
  • Is JTAG the normal method (I think that is what my research has indicated ...)?
  • Is it the only method?
  • If it is a valid method, exactly how do you use it in that fashion?
  • If it isn't then what is/how do I do it?

Furthermore, can something such as an Arduino be used to create an impromptu JTAG interface (if that is indeed what is needed to program ARM devices). . .?

I've already set up QEMU for testing the code and such, but I'm not sure how to proceed to actually get my code into the physical realm.

I'm basically asking: is JTAG the device programmer of the ARM world? Can I spoof one with an Arduino (Arduino wiggler Clone o.o)? If JTAG isn't, what is, and can I spoof it?

Oh... And I might need a better explanation of exactly how JTAG works.

Now for a little background information:
I have an old Palm Device (LifeDrive), that has the XScale PXA270 processor I believe. There doesn't seem to be any active community development going on for it anymore, and I have little use for it anymore, so I kind of just want to play/mess around with it. Basically, this could be a good way to get to play around with what is essentially a mass of sensors, and other miscellaneous inputs and outputs, and also get used to ARM Assembly.

Feel free to tell me if I am taking the wrong approach, but at least provide alternatives (though I am pretty set on messing with the LifeDrive specifically, if I just wanted to play around with embedded programming, I would do so on my Arduino instead.)

Pretty much right now everything is a shot in the dark. I'm a bit tired of rolling around going nowhere, thus I posted this.

George answered 17/1, 2011 at 1:0 Comment(3)
How does one get the compiled binary into an x86 processor?Tentage
I wont even try to compete with Clifford's (excellent) answer. I have a number of arm examples for a number of low cost arm boards. The stm32f4 discovery for $20 is a good path, what you need to load comes with the board. The $10 stm32 value line discovery, similar/same story. github.com/dwelch67 I have some arm simulators as well thumbulator and amber_samples, so you can get your feet wet for free.Hwu
in my lpc-h2148_samples README there are a couple of links to low cost jtag devices for ARM. I use an amontek jtag-tiny all day at work and for fun at home, the shipping cost is the primary distast unless you are ordering many of them. The Signalyzer LITE is equivalent but reasonable shipping in the us. And the jlink edu is good for non-commercial use. I think it is supposed to support the swd (single wire? serial jtag thing) that some devices are using instead of the many pin traditional jtag.Hwu
N
18

That's a lot of questions! Here are a few answers:

How does one get the compiled binary into an ARM processor?

It varies depending on a number of factors.

Is JTAG the normal method (I think that is what my research has indicated ...)?

Most (perhaps all) modern ARM based devices include a JTAG interface to connect to the on-chip debug (soft-cores on an FPGA perhaps excepted). This can generally be used to program on-chip or external flash or load directly into RAM. The JTAG interface is also the interface to on-chip debug and trace features. Some devices have additional debug/programming interfaces, such as ARM's SWD for example.

Is it the only method?

In some cases. Some ARM based microcontrollers include an on-chip bootloader ROM that may support serial, USB or other means of programming on-chip flash. Sometimes such a facility is very simple and intended only to load and run a secondary bootloader that executes from RAM and does the actual flash programming.

If it is a valid method, exactly how do you use it in that fashion?

By using appropriate host software. JTAG is a very simple interface, and it does not define any particular functionality, only a means of data transfer. Typically the programming software will need to know what device it is communicating with, and if the flash memory is not on-chip, it will need to know the flash device and its address. Often the development toolchain will include support for device programming, especially for devices with on-chip memory. If you are using the GNU toolchain, you can use OpenOCD to both program the device and interface the GNU debugger.

If it isn't then what is/how do I do it?

If your target is a COTS, it may well include a bootloader already allowing software update over USB, serial, or Ethernet for example.

Furthermore, can something such as an Arduino be used to create an impromptu JTAG interface (if that is indeed what is needed to program ARM devices). . .?

Probably, as I said JTAG itself is trivially simple to implement, the problem is making it compatible with whatever host software you will use (or making the software compatible with it). The simplest "wiggler" JTAG adapters are implemented using PC parallel port I/O - not particularly fast, but functional.

I'm basically asking: is JTAG the device programmer of the ARM world?

It was originally defined as a boundary scan test interface, but is now widely used on most microprocessors and microcontrollers that include on-chip debug and programming.

Can I spoof one with an Arduino (Arduino wiggler Clone o.o)? If JTAG isn't, what is, and can I spoof it?

It is not a matter of "spoofing", the interface can be implemented in many ways. How you implemnt it primarly affects the speed of the interface. 16 MHz can be achived, but a simpler parallel port wiggler would probably sustain no more that 500 kHz. It is a synchronous interface, so variable clock rates are not a problem.

Oh... And I might need a better explanation of exactly how JTAG works.

I am sure that I cannot do better than the explanation in Wikipedia's JTAG. But for the implementation on your target device, you should consult the part's reference manual/data sheet.

I have an old Palm Device (LifeDrive), that has the XScale PXA270 processor I believe.

"Believing" is probably not enough; you will need to know. Are the JTAG pins even exposed on the board? It would be usual on a consumer product to omit an actual JTAG connector. Even if there is one, it will likely be a proprietary connector and pin-out (JTAG itself defines neither, and there are several defined for ARM, but what you might find on a development board may not be included on the final consumer product.

Basically, this could be a good way to get to play around with what is essentially a mass of sensors, and other miscellaneous inputs and outputs, and also get used to ARM assembly language.

It is probably better to get an off-the shelf development board with exposed I/O pins and interfaces. On a consumer product, only those pins required by the target application are likely to be exposed, and even then they may not be accessible if they are connected to BGA devices. Also, XScale is at the complex end of ARM devices (falling approximately between ARM9 and ARM11), if you are not familiar with such devices and things like PLL clock control, SDRAM control and timing, and MMU configuration, you may want to look at something simpler. Not only that but since both Flash and RAM will be off-chip, you will require details of the address mapping of the memory and other external devices, as well as the necessary SDRAM timing details. Being a consumer device, such details may not be available other than by reverse engineering.

Now that said, regarding the earlier comment about bootloaders, Palm provide a user installable ROM update for the device, so it must have a bootloader. However you would still need details of the image file format and data transfer protocol. These are unlikely to be published, and probably difficult to reverse engineer.

if I just wanted to play around with embedded programming, I would do so on my Arduino instead.)

There are plenty of low cost ARM development board available. Try Olimex for example: they even have a low cost "Wiggler" clone JTAG adapter.

Noreen answered 18/1, 2011 at 0:56 Comment(4)
Thank you very much for your excellent answer :D. Yes, it is infact the PXA270, and I found something at hackndev that outlines where the JTAG pins are on the lifedrive. Furthermore I know (I think atleast!) where most of the various devices are mapped to memory upon boot, so would that be of use in this situation?George
well, that makes it much more feasible. still harder than an eval board.Heraldry
SWD is not unique to ST, many ARMs use this. NXP/Freescale for example.Leanto
@Leanto : True; it is part of ARM's CoreSight (arm.com/products/processors/serial-wire-debug.php). Six years ago when I started using STM32, I guess I assumed it was proprietary. A bit of SO archaeology on your part!Noreen
N
1

JTAG is the easiest way to get onto the board to execute out of RAM or flash. It is a debugging tool that allows you to read and write al the internal registers of a CPU and also control all the I/O pins. Most modern CPUs support JTAG.

It can be as simple as a parallel port bit banger (wriggler) or expensive purpose build hardware. I would buy a small USB device just to get started like this one. This guy used it with a PXA270.

For all things OpenOCD related go here. This will help with debugging and programming and they list all kinds of simple JTAG hardware.

A note on the processor you have. It does not seem to be to widely supported. Maybe you should look at an inexpensive development board with a more widely supported processor.

Nostoc answered 18/1, 2011 at 8:13 Comment(2)
Hmm, will OpenOCD not work with the PXA270? On the macraigor website it seems to indicate that the Wiggler supports this processor, or is more an issue with the Host software. Also, how is UrJtag in comparison to Open OCD, or are they jut separate incomparable entities?George
It will work. Open OCD is used by most people for ARM, I do not know anything about UrTjag but it might work.Nostoc
F
0

I can't help you specifically, but I do work with ARMs. It's with ARM compilers and linkers and testing with debuggers specifically designed for the device, and then the code is flashed onto media that the device runs natively.

You therefore are going to need a way to flash information onto a media that your Palm can run, or are going to need a software emulator for testing. I wish I knew more about the Palm, but I'm more on the game development side of things :) It sounds like JTAG might be an x86 emulator of some sort, so I'd probably start there.

Fendig answered 17/1, 2011 at 1:12 Comment(6)
JTAG is some sort of Circuit Debugging interface. . . Something like various chips on the board are daisychained together, and then can all be accessed and debugged using a JTAG interface. I'm not quite sure myself, but thanks for answering anyway. But tell me more about how the code is flashed unto the "media" (and what kind of media it is). And what do you mean that the device runs natively? Kind of like how PCs boot from a harddrive?George
Most devices have an area in RAM where they first look in order to start running their code - a boot strap area per se. That area usually have a jmp command to where you want your startup code to live. The code that controls this I've found is usually called crt.s or something similiar. This sets up stack sizes, clears RAM, loads statics, and such, then calls a "main" routine that most C/C++ code is expecting as an entrance. Yes, kinda like a hard drive. For many cell phones / game hadhelds, SD cards are used for booting. More coming...Fendig
For an example on a device that I've worked on, check out gbadev.org for some howto on creating an app for the Game Boy Advanced and Game Boy DS. These are both ARM7/ARM9 devices with a ton of documentation and forum help. It will also give you a nice crash course on basic embedded programming. I've been working in embedded land for so long now that I get annoyed when I work on systems with OSs now :)Fendig
I'd also check out GCC as it natively supports cross platform development for ARM and x86 and might be more accessable than an ARM envirnoment.Fendig
Yeah, I've actually already got a toolchain set up (CodeSourcery, which I believe is based on GCC), and have been testing a bit with QEMU. And I have also looked at some GBA tutorials (most notable the ones at coranac.com/tonc/text/toc.htm ) . Though that was a separate thing I did just to familiarize myself with arm assembly code.George
@Michael Dorgan - If most devices start running code from an area in RAM, how does this RAM get loaded with the correct instructions after power up? Isn't RAM a volatile form of memory (i.e. is not able to retain it contents without power)?Heard

© 2022 - 2024 — McMap. All rights reserved.