Monday, 23 April 2012

arm-elf-gdb as arm-simulator

To make your development more efficient and reduce time to market, you must take help of simulators. Today, I will talk about using arm-elf-gdb/run as arm-simulator

main.c
#include <stdio.h>
 
int main(void)
{
  puts("Hello World");
 
  return 0;
}

Get Newlib-syscalls.c

compile code as follows:
$ arm-elf-gcc -o main.elf -g hello.c Newlib-syscalls.c

# Run
arm-elf-run main.elf
Hello World!

# Debug
arm-elf-gdb main.elf
(gdb) target sim
Connected to the simulator.
(gdb) load
Loading section .init, size 0x20 vma 0x8000
Loading section .text, size 0x2f70 vma 0x8020
Loading section .fini, size 0x1c vma 0xaf90
Loading section .rodata, size 0x1c vma 0xafac
Loading section .eh_frame, size 0x4 vma 0xafc8
Loading section .ctors, size 0x8 vma 0xb0cc
Loading section .dtors, size 0x8 vma 0xb0d4
Loading section .jcr, size 0x4 vma 0xb0dc
Loading section .data, size 0x934 vma 0xb0e0
Start address 0x8100
Transfer rate: 116896 bits in <1 sec.
(gdb) list
1       #include <stdio.h>
2        
3       int main(void)
4       {
5         puts("Hello World");
6        
7         return 0;
8       }
(gdb) break 5
Breakpoint 1 at 0x8218: file main.c, line 5.
(gdb) run
Starting program: /private/tmp/main.elf 

Breakpoint 1, main () at main.c:5
5         puts("Hello World");
(gdb) cont
Continuing.
Hello World

Program exited normally.


courtesy "http://embdev.net"

Saturday, 21 April 2012

Setup arm-elf-gcc on your Linux machine

I have been using WinARM as compiler and flashmagic for flashing ARM binary for couple of months. Since, I wanted to move my development-setup on  Ubuntu, I was desperately searching arm-elf-gcc toolchain in Linux. Finally I got some info about ready-made arm-elf-gcc binaries version #4.1.0. thanks to google!! Here are the steps for doing setup:

1) Download arm-elf-gcc
    $ curl -O -C - http://www.mikrocontroller.net/download/arm-toolchain-linux-2.tar.bz2
2) Unzip the file
    $ tar -xjvf arm-toolchain-linux-2.tar.bz2
3) append your PATH variable with address of unzipped folder.
4) Once your binary is ready, flash the code using lpc21isp.
Syntax:  lpc21isp -control -hex executable.hex comport baudrate Oscillator_in_kHz
    -control   for controlling RS232 lines for easier booting   (Reset = DTR, EnableBootLoader = RTS) 
In my case command looks as follows:
    $ lpc21isp -control  -hex main.hex /dev/ttyUSB0 9600 14746

I will explore more to build arm-elf-gcc OR arm-eabi-gcc on Linux, all by myself.

Tuesday, 3 April 2012

What is Embedded System?
Well, Literal meaning of embedded is "inserted as an integral part of a surrounding whole". In embedded system, processor is inserted as integral part of the system. Typically, embedded system has micro-controller-unit or DSP to achieve a specific need. This is in contrast with general-purpose-PC. Embedded system is used in wide area right from mobile phones to Mars rover.

In this blog series, I will try to touch all aspects of embedded system.