|
Up: introduction
Tutorials Toolchain • LPC2103 flashing “Hello, world” GPIO and leds 7-segment indicator PWM and RGB-led Links LPC2103 user manual |
0. Introduction: bootloader and ISPLPC2103 chip contains a bootloader. This bootloader is able to do so-called ISP: In-System Programming. This means that on-chip flash memory can be programmed using bootloader and serial port (which on Embedded Artist's LPC2103 boards is available through USB). The bootloader is executed every time when you reset (or power on) your system. After that there are two possibilities: if on P0.14 CPU pin there is a low level, then bootloader enters ISP commands mode; otherwise it starts user application code. So if you want to program flash using ISP, you need some means to put low level on P0.14 at reset time. On LPC2103 educational board you can achieve this result by pressing reset button, pressing P0.14 button, releasing reset buton and then releasing P0.14 button. For this sequence to work, both jumpers next to the buttons must be removed. On LPC2103 “Christmas tree” there are no buttons for reset or P0.14. Luckily, both of the boards have some hardware way to control reset and P0.14: through serial port DTR/RTS signals (DTR controls reset, and RTS controls P0.14). You really do not need to know anything more about it; just realize that the flashing software will be able automatically put bootloader in ISP mode. 1. Flashing tool: lpc21ispThere are many flashing tools for LPC2103 you may find, some of them work under Linux. I use lpc21isp tool. You may find the source code in files area of LPC21ISP Yahoo group; the version 1.48 is also available from support area of Embedded Artist's website after you register your board. Yahoo group has more up-to-date version but you have to register to access files area there. I did not try latest versions; 1.48 from Embedded Artist's website works good enough for my purposes. 2. Installation of lpc21ispI suppose that you downloaded the file lpc21isp_148x.c from Embedded Artists. Put it in some directory and then compile the tool as following: make lpc21isp_148x Then copy executable to some directory in your path. If you followed my guidelines in toolchain section then /opt/LPC2103/bin is a good place: sudo cp lpc21isp_148x /opt/LPC2103/bin 3. Finding USB-serial device nameNow it's time to connect your board to your host computer with USB cable! It should start execution of pre-flashed demo program immediately (you will see lights blinking). Now we need to find corresponding device for USB-serial bridge. Run command ls /dev/ttyUSB*, it will show you the name of the device. Most probably it will be ttyUSB0; if it's different use that name instead of ttyUSB0 in the instructions below. The device name may change if you unplug the board and plug it in again. 4. Checking if everything worksExecute the following command: lpc21isp_148x -detectonly -control foo /dev/ttyUSB0 115200 14746 You should see something like: lpc21isp version 1.48 ioctl get ok, status = 6 ioctl set ok, status = 6 ioctl get ok, status = 6 ioctl get ok, status = 6 ioctl set ok, status = 4 ioctl get ok, status = 4 ioctl get ok, status = 4 ioctl set ok, status = 0 ioctl get ok, status = 0 Synchronizing (ESC to abort). OK Read bootcode version: 2 2 Read part ID: LPC2103, 32 kiB ROM / 8 kiB SRAM (327441) Congratulations! Your board is connected and you can access the bootloader. 5. Explanation of the lpc21isp_148x options
-detectonly means that you are not really flashing anything now. -control tells lpc21isp to control reset and P0.14 using DTR/RTS signals. foo is just a placeholder; lpc21isp expects here the name of the file you want to send to the board but you are not sending anything. /dev/ttyUSB0 is the name of the device corresponding to USB-serial bridge (see above). 115200 is the speed of the port. 14746 is the oscillator frequency in kHz; more on this later. For now treat it as a “magic number”. 6. Possible problemsIf something goes wrong check: — The name of the device — is it ttyUSB0? — Do you have access to /dev/ttyUSB0? You should be (at least in Debian) the member of dialout group; so either add yourself to that group or run lpc21isp as a root (for example, using sudo). — Did you specify -control option? — On LPC2103 educational board: do you have jumpers installed (next to the reset and P0.14 buttons)? So now you should have toolchain to compile the code and lpc21isp to download it to the board. Time to write “Hello, world!” application. |
Search this site
| ||||||||||||||||||||
...
...
...
