Installing eLua on the LPC2888 CPU from NXP
The LPC2888 CPU from NXP packs some interesting features: huge internal 1Mbyte flash memory, on-chip USB 2.0 high speed interface, and the most complex (by far) clocking network that I've ever seen on an ATM7TDMI chip. Also, it implements the USB DFU (Device Firmware Update) profile over its USB interface, so it's quite easy to program it in-circuit. I'm using the Olimex LPC-H2888 development board built around this chip, which packs 32MBytes of external SDRAM and also 2MBytes of external flash, which is more than enough for my needs. However, it does have its fair share of downsides. For starters, its support package (from NXP) is very poot when compared to other targets on which eLua runs. You don't even get drivers for all your peripherals, just a a few (quite incomplete) examples. Its datasheet could be much more explit at times, especially when referring to the clocking section (which is quite complicated). On my board, the DFU download mode (firmware upgrade via USB) stopped working out of the blue, without any apparent reasons, and I was unable to use DFU on the chip since then, I had to resort to using OpenOCD (and come up with a configuration file, since it was impossible to find one for LPC2888). The CPU itself has a very interesting limitation: because of a silicon error, it's impossible to run Thumb code from the on-chip flash, you can only run regular ARM code (?!). Also, the board that I got from Olimex completely ignores the fact that this chip can run in DFU mode (it doesn't include any kind of jumper and/or switch to enable this mode), so I had to build a support board for it. Which is something I had to do also because the board doesn't export a RS232 interface, I had to build one around a MAX232 chip. All in all, my experience with this chip (and with the Olimex board) wasn't that pleasant, but this doesn't change the fact that the LPC-H2888 is one of the most powerful (resource-wise) boards on which eLua runs.
Prerequisites
Before you'll be able to use eLua on the LPC2888 CPU, make sure that:
- if you're going to use DFU for firmware programming, you'll need Windows (although I heard reports of Linux programs that can program this chip in DFU mode, but I won't cover them here). If you're going to use OpenOCD, Linux, Windows, or any other OS that has support for OpenOCD will do. In this case, you might want to have a look at my OpenOCD tutorial before continuing.
- also, if you're going to use DFU, you'll need a way to boot the chip in DFU firmware upgrade mode. This is done by pulling up (tie to VCC) the P2.3 pin at startup. On my board I included a switch for this. Press the switch, press RESET while holding the switch pressed, then release the switch. You chip is now in DFU mode.
- if you're using DFU, you have installed the LPC2888 flash programming utility from here (the package also contains the Windows DFU drivers).
- if you're using OpenOCD, you have followed the instructions from my OpenOCD tutorial.
- you already have your eLua image for the LPC2888 CPU (built or downloaded).
Burning eLua to the LPC2888 using the DFU tool from NXP
The DFU flashing application doesn't work directly on the .bin files you get after building eLua, you need to run them though NXP's "hostcrypt" program (which is part of the LPC2888 DFU package). After you have your eLua .bin file, do this from a Windows command prompt (make sure that hostcryptv2.exe is in the path):
C:> hostcryptv2 elua_lua_lpc2888.bin elua.ebn -K0 -F0
As a result, you'll have a new file (elua.ebn). Now boot your chip in DFU firmware upgrade mode (see above) and use the DFU utility (MassDFUApplication.exe) to load elua.ebn into your chip (the instructions on using MassDFUApplication are in a PDF file that's included in the LPC2888 DFU package). Reset the board and enjoy.
Burning eLua to the LPC2888 using OpenOCD
If you're as lucky as me and your board refuses to use DFU anymore, follow my OpenOCD tutorial to burn your image using OpenOCD.