# Download/run program?

**URL:** <https://community.sparkfun.com/t/download-run-program/3482>\
**Category:** MicroMod\
**Tags:** arm-lpc\
**Created:** [January 12, 2007, 2:52pm UTC](https://community.sparkfun.com/t/download-run-program/3482 "2007-01-12T14:52:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jw](https://avatars.discourse-cdn.com/v4/letter/j/839c29/32.png) [@jw](https://community.sparkfun.com/u/jw)\
**Post date:** [January 12, 2007, 2:52pm UTC](https://community.sparkfun.com/t/download-run-program/3482/1 "2007-01-12T14:52:47Z")

</div>

Hello!

I would like to download a program to the target, run it, and let the target reenter debug mode after the program is done. For this I need three things:

1. set registers (to pass parameters)

2. resume execution on desired address

3. let target execute instruction to go into debug mode.

While 2. is straight-forward, I can’t see how to do 1. and 3.

Any suggestions?

---

<div class="post-metadata">

**Author:** ![Dominic](https://avatars.discourse-cdn.com/v4/letter/d/13edae/32.png) [@Dominic](https://community.sparkfun.com/u/Dominic)\
**Post date:** [January 12, 2007, 4:03pm UTC](https://community.sparkfun.com/t/download-run-program/3482/2 "2007-01-12T16:03:56Z")

</div>

What’s the purpose of that program? The OpenOCD has an “algorithm” facility, that’s currently used for flash handling. This does exactly what you want, but it’s embedded in the OpenOCD code.

Depending on what you want to achieve, this may, or may not, be the right way.

Regards,

Dominic

---

<div class="post-metadata">

**Author:** ![jw](https://avatars.discourse-cdn.com/v4/letter/j/839c29/32.png) [@jw](https://community.sparkfun.com/u/jw)\
**Post date:** [January 14, 2007, 8:36pm UTC](https://community.sparkfun.com/t/download-run-program/3482/3 "2007-01-14T20:36:49Z")

</div>

> Dominic:  
> What’s the purpose of that program?

Well, I did not want to disclose it before I have something working. But since you ask, the idea is to have a flash-program that runs completely on the target. So you do something like

```auto
load_binary spansion_algorithm 0x8100000
load_binary kernel 0x81001000
set r0 0x80000000 # address of the flash
resume erase
set r0 0x80000000 # address of the flash
set r1 0x81001000 # address of the contents which shall be flashed
resume flash_algorithm

```

With this, it would be possible to implement arbitrary flash algorithms without modifying openocd.

---

<div class="post-metadata">

**Author:** ![adyer](https://avatars.discourse-cdn.com/v4/letter/a/eb9ed0/32.png) [@adyer](https://community.sparkfun.com/u/adyer)\
**Post date:** [January 24, 2007, 10:20pm UTC](https://community.sparkfun.com/t/download-run-program/3482/4 "2007-01-24T22:20:19Z")

</div>

> jw:  
> Hello!
> 
> I would like to download a program to the target, run it, and let the target reenter debug mode after the program is done. For this I need three things:
> 
> 1. set registers (to pass parameters)
> 
> 2. resume execution on desired address
> 
> 3. let target execute instruction to go into debug mode.
> 
> While 2. is straight-forward, I can’t see how to do 1. and 3.
> 
> Any suggestions?

maybe I’m silly, but isn’t this exactly the purpose of the gdb support? gdb is pretty easily scripted.
