ARM LPC2148 and Linux

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.

Toolchain

  • 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 mikrocontroller.net. 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.

    Crt0

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

    Linkerscript

    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;
        Initialize();
        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.

    pic1 pic2 pic3

    download source

    6 comments

    1. hi

      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
      Gromick

      sorry for my english i’m french!!

    2. 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. 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. 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)..
      thanks..
      bye

    5. 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.

    Leave a Reply

    Your email address will not be published. Required fields are marked *