可以在Cortex A55上运行简单的printf

发布于 2025-01-31 23:55:56 字数 2369 浏览 2 评论 0 原文

我正在尝试使用RK3568控制器(Cortex A55) 我有一个项目和一个makefile 我设法使用寄存器输出角色并刷新LED。 但是,如果我尝试使用printf输出一个字符串,则该程序就不会冻结没有任何生命迹象。 我正在寻找解决该问题的解决方案,主要解决方案是实现 _WRITE函数(int文件,char *ptr,int len),标准printf函数应使用。但这无济于事。 我试图连接GitHub的另一个printf函数,并且它起作用。我不明白原因是什么。 我尝试从标准库中调用其他功能,例如 strlen ,它的行为与 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;
}

我正在使用AARCH64 BARE-METAL TARGET COMPILER( aarch644-none-felf ) 我尝试使用另一个AARCH32 BARE-METAL目标编译器( arm-nore-none-eabi ),但是还有更多问题。他甚至无法构建项目并丢弃汇编程序错误。

Error: selected processor does not support requested special purpose register -- `msr tpidr_el 1,xzr'
Error: ARM register expected -- `ldr x1,=_start'

还有更多类似的

我的制作费,也许它的帮助

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'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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱情眠于流年 2025-02-07 23:55:56

最后我能够解决这个问题
I tried to do the following

  1. I implemented the _sbrk function (get from
  2. 我试图突出显示堆和堆栈
  3. 我实现了 _write 函数(但没有触摸 _write_r [!])
  4. 我提供了 memcmp 的实现
    实际上,项目编号对工作的影响最大。4。如果您删除除点4以外的所有内容,则代码可以工作,我可以输出“ Hello World”!
    让我提醒您,我使用 AARCH64-NONE-FEL-GCC
    项目4我从这里

In the end I was able to solve this problem
I tried to do the following

  1. I implemented the _sbrk function (get from this)
  2. I tried to highlight heap and stack
  3. I implemented the _write function (but did not touch _write_r [!])
  4. I provided the implementation of the 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/
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文