Skip to content

ARM LPC2148 and Linux

Last updated on 2021-05-31

Just got my ARM LPC2148 Dev Board from [Olimex](

I put together a small overview how to get things working using a linux host system.


  • GNU Compiler Toolchain
  • Serial Programmer
  • Sample Code

  • Crt0
  • Linkerscript
  • Init Routine
  • Simple IO Test
  • SIO Debug Console
  • GNU Compiler Toolchain

    I use a standard arm GNU toolchain. Actuallay found [this binary]( download from But also my GBA Toolchain worked and produced good binaries. So a Gentoo ARM Crossdev should to the work.
    Think that the LPC is not too picky about that.

    Serial Programmer

    I tried [lpc21isp]( but it didn’t work for me. So i ended up using [lpc2k_pgm]( It has little gui and where you can setup all needed configs. I use iHex format to upload to the dev board, where i had best results using quite slow sio speed like 9600bps. You have to enable BSL on the LPC2148 for ICSP. On my LPC the switch is called ‘ICSP1’ which needs to be set into ON position.


    Nothing special about that. Took it from similar LPC based projects.Just setup stack sizes and default IRQ
    vectors. Worked out of the box.


    Tooks this from a other LPC project. The script specifies the memory layout of the target system and defines the sections for the binary output.

    Init Routine

    Code found in startup.c does the PLL init. The LPC2148 has 12 Mhz internal crystal but can run up to 60Mhz when setting the PLL. Also the default IRQ Handlers are defined here.

    Simple IO Test

    I used the on-board leds for a simple IO test.

    int main(void)
        unsigned int i;
        ConsoleInit(60000000 / (16 * BAUD_RATE));
        puts("Init done\n");
        IODIR0 |= 1 << 10;          // P0.10 is an output
        IODIR0 |= 1 << 11;          // P0.10 is an output
        IOSET0 = 1 << 10;           //LED off
        IOSET0 = 1 << 11;           //LED off
        while (1) {
            for (i = 0; i < 1000000; i++);
            IOSET0 = 1 << 10;       //LED off
            IOCLR0 = 1 << 11;       //LED on
            puts("led1: off  led2: on\n");
            for (i = 0; i < 1000000; i++);
            IOCLR0 = 1 << 10;       //LED on
            IOSET0 = 1 << 11;       //LED off
            puts("led1: on   led2: off\n");

    SIO Debug Console

    Addes a little module that uses one of the two serial line for debugging output. I use the same serial port as for for the ICSP, so after the flashing lpc2k_gpm will display the output directly without any setup changes.


    [download source](


    1. gromick gromick


      im actually working on the olimex development board LPC2148 and ive got trouble with SDcard.

      I can write on it but i when i read all values are wrong.

      Can you help me
      if you want you can give me a response on my mail and i will give you my .c and .h
      I just want to read the data on the Sd card
      thank you

      sorry for my english i’m french!!

    2. disketto disketto

      Hello, i have a question… maybe you can know why something happens to my lpc2148
      I just compile FreeRTOS lpc2148_demo with an arm-elf-gcc 4.1.1, then i upload via OpenOCD+JTAG (jtag connected on the parallel with the Wiggler) giving the instruction:
      (after erasing the flash)

      [openocdcommand] [file] [offset] [type of bytecode]
      flash write
      image code.hex 0x0 ihex

      well… my setup of GPIOs is correct, but it won’t start anything….
      my question is… there is some difference between lpc2k_pgm and OpenOCD writing the flash ?…. maybe lpc2k.. maps instructions in registers while OpenOCD just writes on the flash..could it be something like this ?

    3. Administrator Administrator

      Jap, u a need different linker script to reflect the memory layout, since using jtag u write the program to ram and not flash. After uploading u should start the programm by jumping into it 🙂

    4. disketto disketto

      hi admin… thanks.. you were right….
      well… i need another help (pardon plz)..

      there is a good guide to learn how to debug lpc2148 with gdb under Linux…?
      i continually find tools that run just with windows or under cygwin… that could be similar with linux… but using cygwin under wintozz, well other tools u need are for win32 … so….
      i just can’t find anything useful…
      (arm-elf-insight gives me a problem with a libexpat.. that i can’t understand)..

    5. John Rambo John Rambo

      downloaded the binary have arm-elf-gcc v 4.1.1
      on linux fedora 24

      I removed push and pop errors i removed kbd and lcd entirely from being built

      then i get undefined references
      please help.

    Comments are closed, but trackbacks and pingbacks are open.