I'm trying to get started with the RK3568 controller (cortex a55)
I have a project and a makefile
I managed to output the character using registers and flashing the LED.
But if I try to output a string using printf, the program just freezes without any signs of life.
I was looking for a solution to the problem, and the main solution is to implement the _write function(int file, char *ptr, int len)
, which the standard printf function should use. But it doesn't help.
I tried to connect another Printf function from github and it works. I don't understand what the reason is.
I tried to call other functions from the standard library, for example strlen
and it has the same behavior as printf
int _write(int file, char *ptr, int len)
{
__io_putchar('w');
int DataIdx;
for (DataIdx = 0; DataIdx < len; DataIdx++)
{
__io_putchar( *ptr++ );
}
return len;
}
I am using the AArch64 bare-metal target compiler (aarch64-none-elf) I tried using another AArch32 bare-metal target compiler (arm-none-eabi), but there are even more problems with it. He can't even build the project and throws assembler errors.
Error: selected processor does not support requested special purpose register -- `msr tpidr_el 1,xzr'
Error: ARM register expected -- `ldr x1,=_start'
and many more similar
my makefile, maybe its help
PWD := $(shell pwd)
PRJ_BUILD := $(PWD)/build
CC := aarch64-none-elf-gcc
LD := aarch64-none-elf-ld
OBJCOPY := aarch64-none-elf-objcopy
OBJDUMP := aarch64-none-elf-objdump
SRC := src/entry_point.S
SRC += src/cache.S
SRC += src/main.c
SRC += src/stub.c
SRC := $(addprefix $(PWD)/,$(SRC))
INCLUDES := .
INCLUDES += src
INCLUDES := $(addprefix -I$(PWD)/,$(INCLUDES))
CFLAGS := -c -g
#CFLAGS += -march=armv8.2-a -mcpu=cortex-a55
CFLAGS += -mcpu=cortex-a55
#-mcpu=cortex-a55 -mfloat-abi=hard
define get_library_path
$(shell dirname $(shell $(CC) $(CFLAGS) -print-file-name=$(1)))
endef
LDFLAGS += -L $(call get_library_path,libc.a)
LDFLAGS += -L $(call get_library_path,libgcc.a)
LDFLAGS += -T $(PWD)/link.lds -lgcc -lc
all: app.elf
app.elf:
$(info $(PWD))
$(info SRC:[$(SRC)])
$(info INCLUDES:[$(INCLUDES)])
cd $(PRJ_BUILD) && $(CC) $(CFLAGS) $(INCLUDES) $(SRC)
cd $(PRJ_BUILD) && \
$(LD) -o app.elf $(PRJ_BUILD)/*.o \
$(LDFLAGS) -Map app.map
cd $(PRJ_BUILD) && $(OBJCOPY) -O binary app.elf app.bin
cd $(PRJ_BUILD) && $(OBJDUMP) app.elf -dS > app.lst
clean:
cd $(PRJ_BUILD) && rm -f *.*
I would be glad to at least some advice
In the end I was able to solve this problem I tried to do the following
_sbrk
function (get from this)_write
function (but did not touch _write_r
[!])memcmp
, memset
, memmove
, memcpy
functions
In reality, item No. has the greatest impact on work.4. If you remove everything except point 4, then the code works and I can output "Hello world"!
Let me remind you that I use aarch64-none-elf-gcc
item 4 I took from here https://embeddedartistry.com/blog/2017/03/22/memset-memcpy-memcmp-and-memmove/