This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS570LC4357: GCC toolchain and BE32 mode

Part Number: TMS570LC4357
Other Parts Discussed in Thread: HALCOGEN

I tried to use GCC toolchain to create application binary generated by HAL Code Generator. I can't generate BE32 format binary. It seems that all built-in libraries are compiled for LE. Are there any examples of Makefiles using GCC to create binary for this processor. This is my Makefile in root directory of project created by HAL Code Generator.

PREFIX = arm-none-eabi-
CC = $(PREFIX)gcc
LD = $(PREFIX)gcc
OBJCOPY = $(PREFIX)objcopy

CFLAGS   = -Wall -Werror -I include -mfpu=vfpv3-d16 -march=armv7-r -mcpu=cortex-r4f
CFLAGS  += -fomit-frame-pointer -fno-strict-aliasing -mbig-endian
LDFLAGS  = --specs=nosys.specs -Wl,--gc-sections -mbig-endian
BINFLAGS = -O binary

SRCS  = $(wildcard source/*.c)
ASRCS = $(wildcard source/*.s)
OBJS  = $(patsubst %.c, %.o, $(SRCS))
AOBJS = $(patsubst %.s, %.o, $(ASRCS))

.SECONDARY:

all: app.bin

%.bin: %.elf
	$(OBJCOPY) $< $(BINFLAGS) $@

%.elf: $(OBJS) $(AOBJS)
	$(LD) $^ $(LDFLAGS) -o $@ -Xlinker -Map=output.map -T source/HL_sys_link.ld 

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

%.o: %.s
	$(CC) $(CFLAGS) -c $< -o $@

clean:
	rm -f $(OBJS) $(AOBJS) app.elf app.bin

This fails with errors such as:

/usr/bin/../lib/gcc/arm-none-eabi/6.3.1/crti.o: compiled for a little endian system and target is big endian

Should one compile libraries for big endian? Is that even possible for GCC?

  • Hello User,

    Unfortunately, the GCC compiler only supports LE format. This is a GCC toolchain issue. It is included as an option within Halcogen because our RM devices are LE devices.
  • I succeded to compile and link Halcogen code with GCC in BE format and it works. Problem is in libraries libc and libgcc which are compiled for LE format. For some reason HL_sys_startup file calls exit function after main function which is unnecessary. If that call is removed and references to libc in linker script, everything works. In case of using libc and other built-in functions they should be compiled again. Here is example LED project for GCC:

    github.com/.../hercules-gcc