Skip to content

Commit

Permalink
Add support for build in GCC ARM.
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Kovalenko committed Dec 24, 2017
1 parent 80f32a9 commit 9036897
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 17 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
*.bak
*.Administrator
*.dep
.out
.out_rel
.out_gcc
.out
.dep
.lst
Expand Down
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,15 @@

Engine ECU CAN-BUS emulator (Mitsubishi based). Make simple CAN-BUS events and process some PID-requests.

More information on igorkov.org/bcomp11 and igorkov.org/bcomp11v2 pages.
More information on <a href="igorkov.org/bcomp11">igorkov.org/bcomp11</a> and <a href="igorkov.org/bcomp11v2">igorkov.org/bcomp11v2</a> pages.

---------
Compilation

Use <a href="http://www.keil.com">Keil MDK</a> or <a href="https://developer.arm.com/open-source/gnu-toolchain/gnu-rm/downloads">GCC ARM</a>.

---------
Program MCU

For program MCU, please use USB-UART converter with DTR/RST control and programming utility as <a href="http://www.flashmagictool.com/">Flash Magic</a> or <a href="https://sourceforge.net/projects/lpc21isp/">lpc21isp</a>.

1 change: 1 addition & 0 deletions ecu.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ int main (void) {

#if defined( _DBGOUT )
UART_Init(115200);
DBG("UART_Init() ok!\r\n");
#endif
event_init();
leds_init();
Expand Down
33 changes: 18 additions & 15 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ CFG_GCC_DIR = /gccarm/bin/
# (Note: 3 is not always the best optimization level!)
#OPT = 0
#OPT = 1
#OPT = 2
OPT = s
OPT = 2
#OPT = s
# Íà óðîâíå îïòèìèçàöèè -Os, åñòü ïðîáëåìû
#
#

# List C source files here:
SRC = ecu.c
Expand Down Expand Up @@ -98,7 +101,7 @@ ALLSRC = $(SRC) $(CPPSRC) $(ASRC)
CSTANDARD = -std=gnu99

# Place -D or -U options for C here:
CDEFS = -D__GCC__ -D__ARM__ -DCORTEX
CDEFS = -D__GCC__ -D__ARM__ -DCORTEX -D_DBGOUT

# Place -I options here:
CINCS =
Expand Down Expand Up @@ -151,8 +154,8 @@ CPPFLAGS += -fno-rtti -fno-exceptions -fno-use-cxa-atexit
# -Wl,...: tell GCC to pass this to linker.
# -Map: create map file
# --cref: add cross reference to map file
LDFLAGS = -nostartfiles -Wl,-Map=.out/$(TARGET).map,--cref
LDFLAGS += -lc -lm -lgcc -L./ -L$(CFG_LIB_DIR) -mthumb-interwork
LDFLAGS = -nostartfiles -Wl,-Map=.out_gcc/$(TARGET).map,--cref
LDFLAGS += -lc -lm -lgcc -L./ -L$(CFG_LIB_DIR) -mthumb-interwork
LDFLAGS += -T$(LDSCRIPT).ld

# Define programs and commands.
Expand Down Expand Up @@ -204,13 +207,13 @@ build: elf hex
# Link: create ELF output file from object files.
elf: $(OBJ)
$(CC) -c $(ALL_ASFLAGS) $(ASRC) -o .obj/$(ASRC:.s=.o)
@echo $(MSG_LINKING) .out/$(TARGET).elf
$(CC) $(ALL_CFLAGS) $(addprefix .obj/,$(OBJ)) --output .out/$(TARGET).elf $(LDFLAGS)
@echo $(MSG_LINKING) .out_gcc/$(TARGET).elf
$(CC) $(ALL_CFLAGS) $(addprefix .obj/,$(OBJ)) --output .out_gcc/$(TARGET).elf $(LDFLAGS)

hex:
@echo
@echo $(MSG_FLASH) hex
$(OBJCOPY) -O $(FORMAT) .out/$(TARGET).elf .out/$(TARGET).hex
$(OBJCOPY) -O $(FORMAT) .out_gcc/$(TARGET).elf .out_gcc/$(TARGET).hex

# Eye candy.
begin:
Expand All @@ -221,10 +224,10 @@ prebuild:
@if [ ! -e .dep ]; then mkdir .dep; fi;
@if [ ! -e .obj ]; then mkdir .obj; fi;
@if [ ! -e .lst ]; then mkdir .lst; fi;
@if [ ! -e .out ]; then mkdir .out; fi;
@if [ ! -e .out_gcc ]; then mkdir .out_gcc; fi;

postbuild:
$(OBJDUMP) -xD .out/$(TARGET).ELF --disassembler-options=force-thumb > .out/$(TARGET).asm
$(OBJDUMP) -xD .out_gcc/$(TARGET).ELF --disassembler-options=force-thumb > .out_gcc/$(TARGET).asm

finished:
@echo $(MSG_ERRORS_NONE)
Expand All @@ -233,11 +236,11 @@ end:
@echo $(MSG_END)

# Display size of file.
HEXSIZE = $(SIZE) --target=$(FORMAT) .out/$(TARGET).hex
ELFSIZE = $(SIZE) -A .out/$(TARGET).elf
HEXSIZE = $(SIZE) --target=$(FORMAT) .out_gcc/$(TARGET).hex
ELFSIZE = $(SIZE) -A .out_gcc/$(TARGET).elf

sizeafter:
@if [ -f .out/$(TARGET).elf ]; then echo; echo $(MSG_SIZE); $(ELFSIZE); fi;
@if [ -f .out_gcc/$(TARGET).elf ]; then echo; echo $(MSG_SIZE); $(ELFSIZE); fi;

# Compile: create object files from C source files.
%.o : %.c
Expand All @@ -261,11 +264,11 @@ clean: begin clean_list finished end
clean_list:
@echo
@echo $(MSG_CLEANING)
$(REMOVE) -r .out
$(REMOVE) -r .out_gcc
$(REMOVE) -r .lst
$(REMOVE) -r .obj
$(REMOVE) -r .dep
mkdir .out
mkdir .out_gcc
mkdir .obj
mkdir .lst
mkdir .dep
Expand Down
2 changes: 1 addition & 1 deletion rom.ld
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SECTIONS /* Section Definitions */
. = ALIGN(4);
.text : /* first section is .text which is used for code */
{
*startup.o (.text) /* Startup code */
*startup_LPC11xx_gcc.o (.text) /* Startup code */
*(.text) /* remaining code */
} > ROM

Expand Down
14 changes: 14 additions & 0 deletions startup_LPC11xx_gcc.s
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@

.global ProtectDelay
.global SystemInit
.global leds_init
.global led_red
.global led_green

.text

Expand Down Expand Up @@ -161,6 +164,17 @@ ctor_end:
//; Jump to C entry point.
LDR R0, =ProtectDelay
BLX R0

LDR R0, =leds_init
BLX R0
MOV R0, #1
LDR R1, =led_green
BLX R1
MOV R0, #0
LDR R1, =led_red
BLX R1


LDR R0, =SystemInit
BLX R0
LDR R4, =main
Expand Down

0 comments on commit 9036897

Please sign in to comment.