Hello,
- I’ll try to explain what the Makefile lines do:
arm-elf-gcc -I./ -c -fno-common -O0 -g main.c
arm-elf-gcc is the GNU C compiler for ARM
-I./ adds the current directory (./) to the search directories for include files
-c tells gcc to compile the file, but not to link
-fno-common tells gcc not to put uninitialized globals into common blocks, but into the data section. if the same global is declared in several files, without a prepending “extern”, you’ll get an error
-O0 disables optimization (good for debugging)
-g includes debug information in the output
main.c is the C file to be compiled
arm-elf-as -ahls -mapcs-32 -o crt.o crt.s > crt.lst
arm-elf-as is the GNU assembler for ARM
-ahls tells the assembler to create a listing with lots of information (put into crt.lst)
-mapcs-32 tells the assembler to use the ARM procedure call standard APCS-32. You have to use the same procedure call standard for all object files
-o crt.o tells the assembler to output into the file crt.o
crt.s is the source assembly file
crt.lst redirects all output to crt.lst (produced by -ahls above)
arm-elf-ld -v -Map main.map -Tdemo2148_blink_flash.cmd -o main.out crt.o main.o
arm-elf-ld is the ARM linker
-v outputs version information
-Map main.map tells the linker to output a map file with the used memory configuration, sections, globals, functions
-Tdemo2148_blink_flash.cmd tells the linker to use demo2148_blink_flash.cmd as the linker script
-o output everything into main.out (an ELF file)
crt.o main.o include these objects into the executable
arm-elf-objdump -O ihex main.out > main.dmp
arm-elf-objdump dumps information about ARM object files
don’t know where you got this line from, in my makefiles this looks different.
arm-elf-objcopy -O ihex main.out main.hex
arm-elf-objcopy is used to convert between file formats
-O ihex tells objcopy to output an Intel Hex file (a human-readable ascii file containing addresses and hex values)
main.out is the source file to be copied
main.hex is the destination file
-
The reason for outputting a Hex file is that this is what the Philips flash tool expects. When using the OpenOCD (an open source jtag debugger, openocd.berlios.de, which coincidentally happens to be written by me ;)), you would have to output a plain binary file (-O binary), as this is what the OpenOCD expects.
-
You can’t use less files (not without a loss of maintainability, readability and comfort). Similar files are being used by commercial ideas, you just don’t see what’s going on (or don’t have to look at it).
The crt.s is the startup file provides the exception vectors, and sets up the data/bss sections and the stack, giving you a environment where C code an execute. The header file contains definitions for the on-chip peripherals (you could do without this, but that would make the code less readable and less maintainable). main.c is the application itself. demo2148_blink_flash.cmd is the linker script, which tells the linker how the executable fits into target memory. The makefile is required to get everything together.
Actually, this is really close to the hardware - just look at the linker script and the startup file to see how the hardware is being initialized.
Regards,
Dominic