SparkFun Forums 

Where electronics enthusiasts find answers.

Everything ARM and LPC
By hsutherl
#158944
After a lengthy haitus where I mostly played with ST parts, I'm working with an LPC1768. And I'm really struggling with the bootloader when re-flashing.

* LPC1768FBD100
* bargain(?) (sub-)basement dev board
* 20 pin JTAG (not SWD), tRST and sRST separate
* Olimex ARM-USB-OCD
* openOCD 0.6.1
* telnet interface
* host is i686, Linux 3.8.5 (don't think this is important..)

After hours of experimentation, I've temporarily adopted the following flash sequence:

* reset_config trst_and_srst (configure reset to drive both tRST and sRST)
* halt
* [flash vector table is now at address 0]
* erase** appropriate sectors
* reset halt
* [ROM vector table is now at address 0]
* flash write_image unlock path-to-hex 0 ihex (flash image)
* reset

I'm curious whether anyone has a less cumbersome procedure, especially with openOCD. Maybe this should be in the openOCD forum, but I thought some of the Crossworks or IAR users might have insight on the LPC1768 flashing process. I don't try to provide any log files etc.at this point because my efforts so far have been too random to be useful. I don't-know-anything-about / didn't-check how openOCD actually implements a command such as flash write_image erase unlock.

**various / repeated attempts to erase and write prior to the first reset will erase, but not write the new code (I did manage to write garbage in sector 0 by playing with the MEMMAP register @ 0x400fc040).
By stevech
#159072
Assuming the LPC1768 has a serial port bootloader similar to the LPC2xxx chips... the freeware FlashMagic program should flash just fine.
With Flash Magic, you just setup the chip type and its oscillator freq, and serial port #. Then it's one click. On the LPC21xx parts, there's a jumper to enable the serial port boot loader.

I've used JTAG (J-link) a lot on 21xx chips. But I just use it with IAR's flash and debug utility. So it's a no-brainer as compared to fighting with the freeware stuff like openOCD.

Linux is always problematic for microprocessor development tools - takes far more expertise and tinkering that do the Windows based dev. tools.
By mlu
#159147
well ... :)

Microsoft and USB drivers is a complete mess compared to Linuc and Mac OSX where standard device types just works
out of the box, no installation needed and no drivers needed. And more and more microprocessor dev tools interface through
USB, either as serial ports, exposing a file system interface or DFU.

Then the ease of use and setup of the toolchains is another discussion, but thats about the toolchains and not about the OS platform ... IMHO :)

Regards
Magnus
By mlu
#159150
Next, regarding the process to flash the LPC1768, the process used is standard, not specific to the particular chip and can probably be found
in lots of premade flash write scripts. I can definetly agree that OpenOCD documentation is not very easy to read and find help in.

Your first reset_config doesnt actually reset anything.
The reset halt after erase has been found by many to improve stability,
thats probably a bug in OpenOCD, but the reset halt is a useable workaround.
The unlock is probably not necessary unless you lock flash after writing to it.

Now its not hard to make a script of this sequence and call it from a makefile.

Also its worth noting that OpenOCD is not simply a flash writing tool, its a debug interface
so it can help you find out what problems you have in your not quite working but sucessfully
flashed code.

Finally, again I can accept that the process could be easier, but its free, and targeted at
a lot of arm platforms, and gives access and control at a low level, often more control than
the professional tools will allow you.

Its a matter of taste, choise and wallet, but its important to choose tools according to what you want to achieve.

Regards
Magnus
By hsutherl
#159167
Thanks for the responses guys. FlashMagic does work flawlessly with this board. And J-Link appears to be the most popular ARM debug interface. I'm toying with the idea of trying a commercial setup with a J-Link. As a hobbyist, Crossworks Personal would be the only system I could justify. But I can experiment with IAR Kickstarter and/or the the Keil** Demo version.

As I re-read my original post, it looks more like venting than a request for information. I certainly don't want to imply / express any negative criticism of OpenOCD. I'm in awe of its authors, and amazed at the time Spen must devote to researching and answering questions in that forum. Similarly, while efforts to understand how the LPC bootloader behaves are good, grousing about that behavior is useless and unproductive.

Agreed that the procedure is trivial to script. In fact I was thinking that as I composed the original post. Again, mostly frustration at the time I'd spent getting to that point. (Although I'm still curious as to whether that reset after erase is needed.)

Magnus' final observation is quite pertinent. I really like the idea of open source tools. But the more time I spend getting my tools to work, and the less time I spend on the projects, the greater the odds that I'll always be a hobbyist.

-Hugh

** Actually the first tool I attempted to use with Arm uCs was one of the Keil demo versions. At the time, the included examples were not only written for the Arm/Keil demo boards, but were set up for an obsolete version of the Keil tools. Trying to get up to speed on Arm was already like trying to sprint up a steep slope - those two additional hurdles defeated me.
By stevech
#159349
Take a look at emIDE.org - fairly easy to get going. Lightweight compared to Eclipse, and omits the huge amount of irrelevant junk.
Rowley's IDE is good, a bit of an overkill for hobby work, (it uses GCC).

The LPC2xxx boot loader just works, for me. I've not used the later ones.

In my work stuff, I've long used IAR with J-Link, and the miracle of flash breakpoints. It's like blue sky, versus a hurricane.

Keil and IAR have free 32KB-limited IDE/compilers for ARM. If your projects stay that small, that's the way to go. I found IAR simpler to learn.