编辑
2025-03-30
工作知识
0

DeepSeek-R1 是由杭州深度求索公司开发, 该模型完全开源了所有训练技术和模型权重,性能对齐闭源的 OpenAI-o1, deepseek 通过 DeepSeek-R1 的输出,蒸馏了 6 个小模型给开源社区,包括 Qwen2.5 和 Llama3.1。 本文档将讲述如何使用 RKLLM 将 DeepSeek-R1 蒸馏模型 DeepSeek-R1-Distill-Qwen-1.5B 大语言模型部署到 RK3588 上利用 NPU 进行硬件加速推理。本文介绍DeepSeek-R1在麒麟系统上的部署步骤

一、下载链接

为了支持RK3588上升级DeepSeek,需要如下下载安装包。

git clone https://www.modelscope.cn/radxa/DeepSeek-R1-Distill-Qwen-1.5B_RKLLM.git

通过克隆之后,获得如下文件列表

image.png

此时我们将安装包文件放置到RK3588的麒麟操作系统上

二、安装DeepSeek

安装DeepSeek非常简单,如下:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:~/DeepSeek-R1-Distill-Qwen-1.5B_RKLLM cd ~/DeepSeek-R1-Distill-Qwen-1.5B_RKLLM chmod +x llm_demo

三、使用DeepSeek

使用DeepSeek仅需运行如下命令即可:

./llm_demo DeepSeek-R1-Distill-Qwen-1.5B.rkllm 10000 10000

然后我们得到如下信息:

rkllm init start I rkllm: rkllm-runtime version: 1.1.4, rknpu driver version: 0.9.3, platform: RK3588 rkllm init success user:

至此我们可以开始使用DeepSeek

例如询问斐波那契数列如下:

image.png

例如询问提供医生疾病诊疗手册

image.png

image.png

其他三个小问题:

  • 翻译
  • 计算
  • 数学

image.png

四、注意事项

4.1 请确认当前机器是否支持RK3588NPU

如支持,则我们运行时可以看到NPU的负载如下:

image.png

4.2 请确认内存剩余空间

如内存紧张,可以开启swap如下:

sudo mkdir -p /swap/ # 设置分区的大小 dd if=/dev/zero of=/swap/swap0 bs=1024 count=8388616 # 设置该目录权限 sudo chmod 0600 /swap/swap0 # 创建SWAP文件 sudo mkswap /swap/swap0 # 激活SWAP文件 sudo swapon /swap/swap0
编辑
2025-03-30
工作知识
0

RTEMS是一种开源的的基于GPLv2的实时操作系统,用作导弹弹载的实时操作系统。广泛运用在各类J事领域。本文基于RTEMS介绍如何构建运行RTEMS操作系统

一、获取源码

为了获取源码,可以如下操作:

git clone https://gitlab.rtems.org/rtems/tools/rtems-source-builder.git git clone https://gitlab.rtems.org/rtems/rtos/rtems.git

二、配置环境

代码拉下来之后,我们配置编译环境即可,如下:

# ./rtems-source-builder/source-builder/sb-set-builder --list-bsets | grep aarch64 6/rtems-aarch64.bset

我们基于aarch64进行构建,上述命令会拉取所有开发环境,需要等一会儿即可

# ./rtems-source-builder/source-builder/sb-set-builder --prefix=~/work/rtems/out/

结束后,我们验证gcc是否正常,如下:

# export PATH=$PATH:~/work/rtems/out/bin/ # aarch64-rtems6-gcc --version aarch64-rtems6-gcc (GCC) 13.3.0 20240521 (RTEMS 6, RSB b1aec32059aa0e86385ff75ec01daf93713fa382-modified, Newlib 1b3dcfd) Copyright (C) 2023 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

至此,环境搭建成功

三、编译

此时我们进入rtems系统代码运行如下:

OUTPUT=~/rtems/rtems6/out/ ./waf configure --prefix=$OUTPUT

此时我们配置版型如下:

cat config.ini [aarch64/zynqmp_qemu] RTEMS_POSIX_API = True RTEMS_SMP = True

然后构建如下

./waf

安装如下

./waf install

四、运行

rtems操作系统已经构建完成,我们通过zynqmp来实现qemu的构建。接下来我们测试运行rtems,如下

# rtems-run --rtems-bsps=zynqmp_qemu build/aarch64/zynqmp_qemu/testsuites/samples/hello.exe *** BEGIN OF TEST HELLO WORLD *** *** TEST VERSION: 6.0.0.87bf49b7156b9ddf45c218e5d4fa01f27b283db7 *** TEST STATE: EXPECTED_PASS *** TEST BUILD: RTEMS_POSIX_API RTEMS_SMP *** TEST TOOLS: 13.3.0 20240521 (RTEMS 6, RSB b1aec32059aa0e86385ff75ec01daf93713fa382-modified, Newlib 1b3dcfd) Hello World *** END OF TEST HELLO WORLD *** [ RTEMS shutdown ] CPU: 0 RTEMS version: 6.0.0.87bf49b7156b9ddf45c218e5d4fa01f27b283db7 RTEMS tools: 13.3.0 20240521 (RTEMS 6, RSB b1aec32059aa0e86385ff75ec01daf93713fa382-modified, Newlib 1b3dcfd) executing thread ID: 0x0a010001 executing thread name: UI1 Run time : 0:00:02.517420

如果通过qemu直接运行,可以如下指令

qemu-system-aarch64 -no-reboot -nographic -serial mon:stdio -machine xlnx-zcu102 -m 4096 -kernel build/aarch64/zynqmp_qemu/testsuites/samples/hello.exe

此时我们看到RTEMS会打印Hello World。一切正常,我们查看hello的task的源码如下

static rtems_task Init( rtems_task_argument ignored ) { rtems_print_printer_fprintf_putc(&rtems_test_printer); TEST_BEGIN(); printf( "Hello World\n" ); TEST_END(); rtems_test_exit( 0 ); }

可以发现,源码和行为一致

至此rtems的构建已完全完成

编辑
2025-03-30
工作知识
0

我们之前构建了RTEMS操作系统,这次继续构建此实时系统的应用程序,以hello kylin为例

一、准备仓库

为了编写应用程序以及管理,需要提前准备一个本地git仓库,如下

# mkdir -p app/hello # cd app/hello # git init .

二、waf构建工具环境

waf作为rtems的构建工具,我们需要为应用程序下载此工具,如下:

# cp ../../waf . # git submodule add https://gitlab.rtems.org/rtems/tools/rtems_waf.git rtems_waf

三、编写应用

编写应用前,需要为RTEMS操作系统提供init.c,如下

/* * Simple RTEMS configuration */ #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_UNLIMITED_OBJECTS #define CONFIGURE_UNIFIED_WORK_AREAS #define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_INIT #include <rtems/confdefs.h>

然后创建hello.c应用程序如下

/* * Hello world example */ #include <rtems.h> #include <stdlib.h> #include <stdio.h> rtems_task Init( rtems_task_argument ignored ) { printf( "\nHello Kylin\n" ); exit( 0 ); }

最后为hello.c和init.c编写waf构建脚本,如下

# # Hello world Waf script # from __future__ import print_function rtems_version = "6" try: import rtems_waf.rtems as rtems except: print('error: no rtems_waf git submodule') import sys sys.exit(1) def init(ctx): rtems.init(ctx, version = rtems_version, long_commands = True) def bsp_configure(conf, arch_bsp): # Add BSP specific configuration checks pass def options(opt): rtems.options(opt) def configure(conf): rtems.configure(conf, bsp_configure = bsp_configure) def build(bld): rtems.build(bld) bld(features = 'c cprogram', target = 'hello.exe', cflags = '-g -O2', source = ['hello.c', 'init.c'])

四、构建

此时一切准备完成之后,构建应用程序和构建操作系统的命令一致,如下:

# ./waf configure --rtems=~/work/rtems/out/ --rtems-bsp=aarch64/zynqmp_qemu # ./waf

五、运行

通过rtems-run可以带起qemu运行应用程序,如下:

# rtems-run --rtems-bsps=zynqmp_qemu build/aarch64-rtems6-zynqmp_qemu/hello.exe

此时运行结果如下

RTEMS Testing - Run, 6.0.not_released Command Line: /root/work/rtems/out/bin/rtems-run --rtems-bsps=zynqmp_qemu build/aarch64-rtems6-zynqmp_qemu/hello.exe Host: Linux tf 6.8.0-47-generic #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 21:40:26 UTC 2024 x86_64 Python: 2.7.18 (default, Jan 31 2024, 16:23:13) [GCC 9.4.0] Host: Linux-6.8.0-47-generic-x86_64-with-Ubuntu-20.04-focal (Linux tf 6.8.0-47-generic #47-Ubuntu SMP PREEMPT_DYNAMIC Fri Sep 27 21:40:26 UTC 2024 x86_64 x86_64) Hello Kylin [ RTEMS shutdown ] CPU: 0 RTEMS version: 6.0.0.87bf49b7156b9ddf45c218e5d4fa01f27b283db7 RTEMS tools: 13.3.0 20240521 (RTEMS 6, RSB b1aec32059aa0e86385ff75ec01daf93713fa382-modified, Newlib 1b3dcfd) executing thread ID: 0x0a010001 executing thread name: UI1 Run time : 0:00:00.756775

至此,一个最简单的rtems的应用程序编写完成

六、提交代码

最后提交相关代码即可

# git add init.c hello.c wscript # git commit -m "My first RTEMS application."
编辑
2025-03-30
工作知识
0

rtems可以支持capture任务的执行情况,如下演示效果

一、运行capture示例

构建通过waf执行,如下

# ./waf configure --prefix=/root/work/rtems/out # ./waf

至此,我们可以运行capture示例如下

# qemu-system-aarch64 -no-reboot -nographic -s -serial mon:stdio -machine xlnx-zcu102 -m 4096 -kernel build/aarch64/zynqmp_qemu/testsuites/samples/capture.exe

此时的信息如下

*** BEGIN OF TEST CAPTURE ENGINE *** *** TEST VERSION: 6.0.0.87bf49b7156b9ddf45c218e5d4fa01f27b283db7-modified *** TEST STATE: USER_INPUT *** TEST BUILD: RTEMS_POSIX_API RTEMS_SMP *** TEST TOOLS: 13.3.0 20240521 (RTEMS 6, RSB b1aec32059aa0e86385ff75ec01daf93713fa382-modified, Newlib 1b3dcfd) Press any key to start capture engine (20s remaining) Press any key to start capture engine (19s remaining) Monitor ready, press enter to login. 1-rtems $

二、相关命令

copen <buffer-size>: 此命令默认设置capture的buffersize byte单位 cwceil <priority-value>: 此命令过滤低于优先级的所有事件 cwfloor <priority-value>: 此命令过滤高于优先级的所有事件 cwglob <on/off>: 此命令启动或关闭监视器 ctset [-?] type [to name/id] [from] [from name/id]: 此命令设置触发器类型,这里RMON是监视自身 cenable: 此命令启用capture功能 cdisable: 此命令禁用capture功能 ctrace: 此命令trace出日志 cwadd <task-name>: 此命令为特定的任务添加监视 cwtctl <task-name> <on/off>: 此命令启动或禁用特定任务 ctlist: 此命令列出当前的task

三、演示

此时我们进入captrue.exe,开启capture如下

1-rtems $ ctrace error: trace read failed: RTEMS_NOT_CONFIGURED 1-rtems $ 1-rtems $ cenable error: enable failed: RTEMS_UNSATISFIED 1-rtems $ copen 50000 capture engine opened. 1-rtems $ cwceil 100 watch ceiling is 100. 1-rtems $ cwfloor 102 watch floor is 102. 1-rtems $ cwglob on global watch enabled. 1-rtems $ ctset RMON trigger set. 1-rtems $ cenable capture engine enabled.

然后我们运行capture内置的测试程序test1,如下

1-rtems $ test1

等任务完成之后,我们关闭capture,然后查看trace如下

1-rtems $ cdisable capture engine disabled. 1-rtems $ ctrace 0 0:05:12.132637246 0a010003 CT1a 102 102 102 8192 TASK_RECORD 0 0:05:12.132782702 0 0a010003 CT1a 102 102 CREATED 0 0:05:12.133041342 258640 0a010003 CT1a 102 102 STARTED 0 0:05:12.133258110 216768 0a010003 CT1a 102 102 SWITCHED_IN 0 0:05:12.133502894 244784 0a010003 CT1a 102 102 BEGIN 0 0:05:12.134015374 512480 0a010003 CT1a 102 102 SWITCHED_OUT 0 0:05:13.130163838 0a010004 CT1b 101 101 101 8192 TASK_RECORD 0 0:05:13.130167454 996152080 0a010004 CT1b 101 101 CREATED 0 0:05:13.130238478 71024 0a010004 CT1b 101 101 STARTED 0 0:05:13.130302190 63712 0a010004 CT1b 101 101 SWITCHED_IN 0 0:05:13.130313246 11056 0a010004 CT1b 101 101 BEGIN 0 0:05:14.129783230 999469984 0a010004 CT1b 101 101 SWITCHED_OUT 0 0:05:14.129853182 0a010005 CT1c 100 100 100 8192 TASK_RECORD 0 0:05:14.129854974 71744 0a010005 CT1c 100 100 CREATED 0 0:05:14.129888638 33664 0a010005 CT1c 100 100 STARTED 0 0:05:14.129931806 43168 0a010005 CT1c 100 100 SWITCHED_IN 0 0:05:14.129936494 4688 0a010005 CT1c 100 100 BEGIN 0 0:05:14.130633246 696752 0a010005 CT1c 100 100 SWITCHED_OUT 0 0:05:14.130634638 1392 0a010004 CT1b 101 101 SWITCHED_IN 0 0:05:14.629816846 499182208 0a010004 CT1b 101 101 SWITCHED_OUT 0 0:05:14.629819598 2752 0a010003 CT1a 102 100 SWITCHED_IN 0 0:05:14.630445950 626352 0a010003 CT1a 102 102 SWITCHED_OUT

我们查看当前的任务列表,如下

1-rtems $ ctlist uptime: 0:22:34.490255513 total 2 09010001 IDLE 255 255 255 READY a--g 0a010002 RMON 1 1 1 READY a---

至此,capture的示例演示完成

编辑
2025-03-30
工作知识
0

rtems提供了trace的基本功能,如下演示此功能情况

一、trace配置文件

对于rtems的trace功能,可以通过官方提供的fileio-trace.ini示例文件配置,如下

; ; RTEMS Trace Linker FileIO Trace Configuration ; ; Copyright 2015 Chris Johns <chrisj@rtems.org> ; ;-------------------------------------------------------------------------- [tracer] name = File IO tracer ; ; The configuration ; options = fileio-options traces = fileio defines = fileio enables = fileio triggers = fileio functions = fileio-funcs, rtems-api, rtems-posix, libc-heap include = rtems.ini, rtld-base.ini, rtld-trace-buffer.ini, libc-heap.ini ;-------------------------------------------------------------------------- [fileio-options] dump-on-error = true ; ; Tools ; prefix = /opt/rtems/4.11 rtems-path = /opt/rtems/kernel/4.11 rtems-bsp = sparc/sis ; ; Generator options. ; gen-enables = enable gen-triggers = enable ;-------------------------------------------------------------------------- [fileio] generator = trace-buffer-generator define = '#define RTLD_TRACE_BUFFER_SIZE (1UL * 1024 * 1024)' trace = rtems_shell_init trace = malloc, calloc, realloc, free traces = rtems-api-semaphore, rtems-posix-mutex enable = rtems_shell_init enable = malloc, calloc, realloc, free enables = rtems-api-semaphore, rtems-posix-mutex trigger = rtems_shell_init ;-------------------------------------------------------------------------- [fileio-funcs] headers = fileio-headers signatures = fileio-signatures [fileio-headers] header = '#include <rtems/shell.h>"' [fileio-signatures] rtems_shell_init = rtems_status_code, const char*, size_t, rtems_task_priority, const char*, bool, bool, rtems_shell_login_check_t

这里关于rtems-path和rtems-bsp主要配置为当前rtems的安装路径和bsp路径,如下

prefix = /root/work/rtems/out rtems-path = /root/work/rtems/out rtems-bsp = aarch64/zynqmp_qemu

二、编译.o文件

这里以fileio为例,我们需要先将init.c编译成.o文件,如下

# /root/work/rtems/out/bin/aarch64-rtems6-gcc -MMD -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -mno-outline-atomics -mcpu=cortex-a53 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 -O2 -g -fdata-sections -ffunction-sections -Icpukit/include -I../../../cpukit/include -Icpukit/score/cpu/aarch64/include -I../../../cpukit/score/cpu/aarch64/include -Ibsps/include -I../../../bsps/include -Ibsps/aarch64/include -I../../../bsps/aarch64/include -Ibsps/aarch64/xilinx-zynqmp/include -I../../../bsps/aarch64/xilinx-zynqmp/include -Itestsuites/support/include -I../../../testsuites/support/include ../../../testsuites/samples/fileio/init.c -c -o/root/work/rtems/rtems/build/aarch64/zynqmp_qemu/testsuites/samples/fileio/fileio-init.o -DHAVE_CONFIG_H=1 -DTEST_STATE_USER_INPUT=1

此命令来源于构建是waf的verbose参数,如下可以看到waf verbose参数. 值得注意的是,我将原来构建的init.c.672.o名字重写成了fileio-init.o

# rm -rf build/aarch64/zynqmp_qemu/testsuites/samples/fileio # ./waf -v Waf: Entering directory `/root/work/rtems/rtems/build' Waf: Leaving directory `/root/work/rtems/rtems/build' 'build' finished successfully (0.045s) Waf: Entering directory `/root/work/rtems/rtems/build/aarch64/zynqmp_qemu' 08:11:11 runner 'git ls-files --modified' 08:11:11 runner 'git rev-parse HEAD' [3710/4847] Compiling testsuites/samples/fileio/init.c 08:11:13 runner ['/root/work/rtems/out/bin/aarch64-rtems6-gcc', '-MMD', '-Wall', '-Wmissing-prototypes', '-Wimplicit-function- declaration', '-Wstrict-prototypes', '-Wnested-externs', '-mno-outline-atomics', '-mcpu=cortex-a53', '-mfix-cortex-a53-835769' , '-mfix-cortex-a53-843419', '-O2', '-g', '-fdata-sections', '-ffunction-sections', '-Icpukit/include', '-I../../../cpukit/inc lude', '-Icpukit/score/cpu/aarch64/include', '-I../../../cpukit/score/cpu/aarch64/include', '-Ibsps/include', '-I../../../bsps /include', '-Ibsps/aarch64/include', '-I../../../bsps/aarch64/include', '-Ibsps/aarch64/xilinx-zynqmp/include', '-I../../../bs ps/aarch64/xilinx-zynqmp/include', '-Itestsuites/support/include', '-I../../../testsuites/support/include', '../../../testsuit es/samples/fileio/init.c', '-c', '-o/root/work/rtems/rtems/build/aarch64/zynqmp_qemu/testsuites/samples/fileio/init.c.672.o', '-DHAVE_CONFIG_H=1', '-DTEST_STATE_USER_INPUT=1'] [4847/4847] Linking build/aarch64/zynqmp_qemu/testsuites/samples/fileio.exe 08:11:14 runner ['/root/work/rtems/out/bin/aarch64-rtems6-gcc', 'testsuites/samples/fileio/init.c.672.o', '-o/root/work/rtems/ rtems/build/aarch64/zynqmp_qemu/testsuites/samples/fileio.exe', '-Wl,-Bstatic', '-L.', '-lrtemscpu', '-lrtemsbsp', '-lrtemstes t', '-Wl,-Bdynamic', '-qrtems', '-mno-outline-atomics', '-mcpu=cortex-a53', '-mfix-cortex-a53-835769', '-mfix-cortex-a53-84341 9', '-Wl,--gc-sections', '-L/root/work/rtems/rtems/bsps/aarch64/shared/start', '-L/root/work/rtems/rtems/bsps/aarch64/xilinx-z ynqmp/start', '-Wl,--wrap=printf', '-Wl,--wrap=puts', '-Wl,--wrap=putchar'] Waf: Leaving directory `/root/work/rtems/rtems/build/aarch64/zynqmp_qemu' 'build_aarch64/zynqmp_qemu' finished successfully (2.606s)

三、执行tld

根据抓到的日志信息,我们可以拿到ld的命令如下:

# /root/work/rtems/out/bin/aarch64-rtems6-gcc testsuites/samples/fileio/init.c.672.o -o/root/work/rtems/rtems/build/aarch64/zynqmp_qemu/testsuites/samples/fileio.exe -Wl,-Bstatic -L. -lrtemscpu -lrtemsbsp -lrtemstest -Wl,-Bdynamic -qrtems -mno-outline-atomics -mcpu=cortex-a53 -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 -Wl,--gc-sections -L/root/work/rtems/rtems/bsps/aarch64/shared/start -L/root/work/rtems/rtems/bsps/aarch64/xilinx-zynqmp/start -Wl,--wrap=printf -Wl,--wrap=puts -Wl,--wrap=putchar

此时我们根据gcc的verbose参数,可以得到ld的调用参数如下

# aarch64-rtems6-ld -plugin /root/work/rtems/out/libexec/gcc/aarch64-rtems6/13.3.0/liblto_plugin.so -plugin-opt=/root/work/rtems/out/libexec/gcc/aarch64-rtems6/13.3.0/lto-wrapper -plugin-opt=-fresolution=/tmp/ccBjkjvt.res -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lrtemsbsp -plugin-opt=-pass-through=-lrtemscpu -plugin-opt=-pass-through=-latomic -plugin-opt=-pass-through=-lc -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lgcc -EL -X -maarch64elf --fix-cortex-a53-835769 --fix-cortex-a53-843419 -o /root/work/rtems/rtems/build/aarch64/zynqmp_qemu/testsuites/samples/fileio.exe /root/work/rtems/out/lib/gcc/aarch64-rtems6/13.3.0/nooa/a53/fix835769/fix843419/crti.o /root/work/rtems/out/lib/gcc/aarch64-rtems6/13.3.0/nooa/a53/fix835769/fix843419/crtbegin.o -L. -L/root/work/rtems/rtems/bsps/aarch64/shared/start -L/root/work/rtems/rtems/bsps/aarch64/xilinx-zynqmp/start -L/root/work/rtems/out/lib/gcc/aarch64-rtems6/13.3.0/nooa/a53/fix835769/fix843419 -L/root/work/rtems/out/lib/gcc/aarch64-rtems6/13.3.0/../../../../aarch64-rtems6/lib/nooa/a53/fix835769/fix843419 -L/root/work/rtems/out/lib/gcc/aarch64-rtems6/13.3.0 -L/root/work/rtems/out/lib/gcc/aarch64-rtems6/13.3.0/../../../../aarch64-rtems6/lib testsuites/samples/fileio/init.c.672.o -Bstatic -lrtemscpu -lrtemsbsp -lrtemstest -Bdynamic --gc-sections --wrap=printf --wrap=puts --wrap=putchar -lgcc --start-group -lrtemsbsp -lrtemscpu -latomic -lc -lgcc --end-group -lgcc /root/work/rtems/out/lib/gcc/aarch64-rtems6/13.3.0/nooa/a53/fix835769/fix843419/crtend.o /root/work/rtems/out/lib/gcc/aarch64-rtems6/13.3.0/nooa/a53/fix835769/fix843419/crtn.o -T linkcmds

这里清晰的描述了fileio.exe的ld过程,我们将其替换成rtems-tld的调用方式如下

# rtems-tld -C build/aarch64/zynqmp_qemu/fileio-trace.ini -- -B/root/work/rtems/out/aarch64-rtems6/zynqmp_qemu/lib -qrtems -mcpu=cortex-a53 -O2 -g -ffunction-sections -fdata-sections -Wall -Wmissing-prototypes -Wimplicit-function-declaration -Wstrict-prototypes -Wnested-externs -Wl,--gc-sections -mcpu=cortex-a53 -o /root/work/rtems/rtems/build/aarch64/zynqmp_qemu/testsuites/samples/fileio.exe /root/work/rtems/rtems/build/aarch64/zynqmp_qemu/testsuites/samples/fileio/fileio-init.o -lrtemstest

这里如果是通过ld链接,则系统无法进行trace,如果通过rtems-tld链接,则系统可被trace。效果如下

四、未开启trace的现象

如果通过标准ld,如下验证

# qemu-system-aarch64 -no-reboot -nographic -s -serial mon:stdio -machine xlnx-zcu102 -m 4096 -kernel build/aarch64/zynqmp_qemu/testsuites/samples/fileio.exe *** BEGIN OF TEST FILE I/O *** *** TEST VERSION: 6.0.0.87bf49b7156b9ddf45c218e5d4fa01f27b283db7 *** TEST STATE: USER_INPUT *** TEST BUILD: RTEMS_POSIX_API RTEMS_SMP *** TEST TOOLS: 13.3.0 20240521 (RTEMS 6, RSB b1aec32059aa0e86385ff75ec01daf93713fa382-modified, Newlib 1b3dcfd) Press any key to start file I/O sample (20s remaining) ========================= RTEMS FILE I/O Test Menu ========================= p -> part_table_initialize f -> mount all disks in fs_table l -> list file r -> read file w -> write file s -> start shell Enter your selection ==>s Creating /etc/passwd and group with four useable accounts: root/pwd test/pwd rtems/NO PASSWORD chroot/NO PASSWORD Only the root user has access to all available commands. ========================= starting shell ========================= Welcome to rtems-6.0.0 (AArch64/AArch64-LP64/zynqmp_qemu) Copyright (C) 1989, 2021 RTEMS Project and contributors Login into RTEMS /dev/foobar login: root Password: RTEMS Shell on /dev/foobar. Use 'help' to list commands. SHLL [/] # rtrace status No trace buffer generated code in the application; see rtems-tld

此时我们rtrace status无法看到trace buffer,故此系统无法trace

五、开启trace的现象

我们通过rtems-tld链接的系统,如下现象

# qemu-system-aarch64 -no-reboot -nographic -s -serial mon:stdio -machine xlnx-zcu102 -m 4096 -kernel build/aarch64/zynqmp_qemu/testsuites/samples/fileio.exe *** BEGIN OF TEST FILE I/O *** *** TEST VERSION: 6.0.0.87bf49b7156b9ddf45c218e5d4fa01f27b283db7 *** TEST STATE: USER_INPUT *** TEST BUILD: RTEMS_POSIX_API RTEMS_SMP *** TEST TOOLS: 13.3.0 20240521 (RTEMS 6, RSB b1aec32059aa0e86385ff75ec01daf93713fa382-modified, Newlib 1b3dcfd) Press any key to start file I/O sample (20s remaining) Press any key to start file I/O sample (19s remaining) ========================= RTEMS FILE I/O Test Menu ========================= p -> part_table_initialize f -> mount all disks in fs_table l -> list file r -> read file w -> write file s -> start shell Enter your selection ==>s Creating /etc/passwd and group with four useable accounts: root/pwd test/pwd rtems/NO PASSWORD chroot/NO PASSWORD Only the root user has access to all available commands. ========================= starting shell ========================= Welcome to rtems-6.0.0 (AArch64/AArch64-LP64/zynqmp_qemu) Copyright (C) 1989, 2021 RTEMS Project and contributors Login into RTEMS /dev/foobar login: root Password: RTEMS Shell on /dev/foobar. Use 'help' to list commands. SHLL [/] # rtrace status RTEMS Trace Bufferring: status Running: yes Triggered: yes Level: 0% Traces: 24 SHLL [/] #

此时我们可以看到rtrace的状态

六、总结

至此,我们开启了rtems的trace系统。需要备注的是rtems的默认账号密码是root/pwd