((.venv) ) chyi@earth:~/zephyrproject2/zephyr$ west build -p always -b stm32mp257f_dk/stm32mp257fxx/m33 samples/subsys/ipc/openamp_rsc_table
-- west build: making build dir /home/chyi/zephyrproject2/zephyr/build pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/chyi/zephyrproject2/zephyr/samples/subsys/ipc/openamp_rsc_table
-- CMake version: 3.22.1
-- Found Python3: /home/chyi/zephyrproject2/.venv/bin/python3.12 (found suitable version "3.12.13", minimum required is "3.12") found components: Interpreter
-- Cache files will be written to: /home/chyi/.cache/zephyr
-- Zephyr version: 4.3.99 (/home/chyi/zephyrproject2/zephyr)
-- Found west (found suitable version "1.5.0", minimum required is "0.14.0")
-- Board: stm32mp257f_dk, qualifiers: stm32mp257fxx/m33
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.17.4 (/home/chyi/zephyr-sdk-0.17.4)
-- Found toolchain: zephyr 0.17.4 (/home/chyi/zephyr-sdk-0.17.4)
-- Found Dtc: /home/chyi/zephyr-sdk-0.17.4/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.7.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/chyi/zephyrproject2/zephyr/boards/st/stm32mp257f_dk/stm32mp257f_dk_stm32mp257fxx_m33.dts
-- Found devicetree overlay: /home/chyi/zephyrproject2/zephyr/samples/subsys/ipc/openamp_rsc_table/boards/stm32mp257f_dk_stm32mp257fxx_m33.overlay
-- Generated zephyr.dts: /home/chyi/zephyrproject2/zephyr/build/zephyr/zephyr.dts
-- Generated pickled edt: /home/chyi/zephyrproject2/zephyr/build/zephyr/edt.pickle
-- Generated devicetree_generated.h: /home/chyi/zephyrproject2/zephyr/build/zephyr/include/generated/zephyr/devicetree_generated.h
warning: PRINTK (defined at subsys/debug/Kconfig:145) was assigned the value 'n' but got the value
'y'. See http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_PRINTK and/or look up PRINTK in
the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration
Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.
Parsing /home/chyi/zephyrproject2/zephyr/Kconfig
Loaded configuration '/home/chyi/zephyrproject2/zephyr/boards/st/stm32mp257f_dk/stm32mp257f_dk_stm32mp257fxx_m33_defconfig'
Merged configuration '/home/chyi/zephyrproject2/zephyr/samples/subsys/ipc/openamp_rsc_table/prj.conf'
Merged configuration '/home/chyi/zephyrproject2/zephyr/samples/subsys/ipc/openamp_rsc_table/boards/stm32mp257f_dk_stm32mp257fxx_m33.conf'
Configuration saved to '/home/chyi/zephyrproject2/zephyr/build/zephyr/.config'
Kconfig header saved to '/home/chyi/zephyrproject2/zephyr/build/zephyr/include/generated/zephyr/autoconf.h'
-- Found GnuLd: /home/chyi/zephyr-sdk-0.17.4/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (found version "2.38")
-- The C compiler identification is GNU 12.2.0
-- The CXX compiler identification is GNU 12.2.0
-- The ASM compiler identification is GNU
-- Found assembler: /home/chyi/zephyr-sdk-0.17.4/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
-- libmetal version: 1.9.0 (/home/chyi/zephyrproject2/zephyr/samples/subsys/ipc/openamp_rsc_table)
-- Build type:
-- Host: Linux/x86_64
-- Target: Generic/arm
-- Machine: arm
-- Vendor: none
-- Looking for include file stdatomic.h
-- Looking for include file stdatomic.h - found
-- open-amp version: 1.8.0 (/home/chyi/zephyrproject2/modules/lib/open-amp/open-amp)
-- Host: Linux/x86_64
-- Target: Generic/arm
-- Machine: arm
-- C_FLAGS : -Wall -Wextra
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Using ccache: /usr/bin/ccache
-- Found gen_kobject_list: /home/chyi/zephyrproject2/zephyr/scripts/build/gen_kobject_list.py
-- Configuring done
-- Generating done
-- Build files have been written to: /home/chyi/zephyrproject2/zephyr/build
-- west build: building application
[1/224] Preparing syscall dependency handling
[3/224] Generating include/generated/zephyr/version.h
-- Zephyr version: 4.3.99 (/home/chyi/zephyrproject2/zephyr), build: v4.3.0-8239-g91a6b1ec452b
[224/224] Linking C executable zephyr/zephyr_openamp_rsc_table.elf
Memory region Used Size Region Size %age Used
FLASH: 72800 B 8 MB 0.87%
RAM: 21244 B 8 MB 0.25%
DDR_CODE: 0 GB 8 MB 0.00%
DDR_SYS: 0 GB 8 MB 0.00%
IDT_LIST: 0 GB 32 KB 0.00%
Generating files from /home/chyi/zephyrproject2/zephyr/build/zephyr/zephyr_openamp_rsc_table.elf for board: stm32mp257f_dk/stm32mp257fxx/m33
역시 개발자라면, 이번에도 아래 파일들을 한번 쯤 훑어 보는 것이 신상에 해롭지 않을까 싶다. 😋
[그림 9.19] 자동생성된 stm32mp257f_dk_stm32mp257fxx_m33.dts file
[그림 9.20] stm32mp257f_dk_stm32mp257fxx_m33.overlay file
[그림 9.21] 자동생성된 zephyr.dts file
자, build된 elf file을 target board로 copy하도록 하자.
$ scp /home/chyi/zephyrproject2/zephyr/build/zephyr/zephyr_openamp_rsc_table.elf root@192.168.8.227:~/workspace/03182026
<Target board>
root@stm32mp2-e3-d2-e5:~# modprobe rpmsg_client_sample
-> 먼저 rmsg_client_sample.ko(linux samples 디렉토리에 있는 예제)를 구동시키도록 하자.
root@stm32mp2-e3-d2-e5:~# lsmod | grep rpmsg
rpmsg_client_sample 16384 0
rpmsg_tty 16384 0
rpmsg_ctrl 12288 0
rpmsg_char 20480 1 rpmsg_ctrl
virtio_rpmsg_bus 24576 0
i2c_rpmsg 16384 0
irq_rpmsg 12288 0
다음으로, 앞서 build한 zephyr_openamp_rsc_table.elf를 구동시킬 차례이다.
root@stm32mp2-e3-d2-e5:~# cd ~/workspace/03182026
root@stm32mp2-e3-d2-e5:~# cp ./zephyr_openamp_rsc_table.elf /usr/local/Cube-M33-examples/STM32MP257F-DK/Demonstrations/USBPD_DRP_UCSI/lib/firmware/USBPD_DRP_UCSI_CM33_NonSecure_stripped.elf
-> 내용을 분석해 보니, fw_cortex_m33.sh에서 USBPD_DRP_UCSI_CM33_NonSecure_stripped.elf 파일을 /lib/firmware로 복사 후, 구동 준비를 하는 관계로, 일단은 이렇게 복사를 하도록 한다.
root@stm32mp2-e3-d2-e5:~# cd /usr/local/Cube-M33-examples/STM32MP257F-DK/Demonstrations/USBPD_DRP_UCSI
root@stm32mp2-e3-d2-e5:~# fw_cortex_m33.sh stop
root@stm32mp2-e3-d2-e5:~# fw_cortex_m33.sh start
-> fw_cortex_m33.sh script를 이용하여 M33에 올라가 있는 firmware를 중지시킨 후, 새로운 firmware로 재구동시킨다.
(이 상태에서) linux console과 zephyr console을 통해 각각 확인해 보니, 서로 rpmsg를 주고 받는 모습이 보인다. 😎
$ sudo minicom -D /dev/ttyACM0
[그림 9.22] linux console - fw_cortex_m33.sh stop -> start
$ sudo minicom -D /dev/ttyACM1
[그림 9.23] zephyr console - fw_cortex_m33.sh start 시 출력되는 내용
참고로, 위의 zephyr_openamp_rsc_table 예제 코드는 (main 함수에서) 3개의 thread를 띄우고 있는데, 아래 thread를 사용하면, tty를 활용한 또 다른 시험이 가능하다.
-----------------------------------------------------------------------------
k_thread_create(&thread_tty_data, thread_tty_stack, APP_TTY_TASK_STACK_SIZE,
app_rpmsg_tty,
NULL, NULL, NULL, K_PRIO_COOP(7), 0, K_NO_WAIT);
-----------------------------------------------------------------------------
<시험 내용#2>
/dev/ttyRPMSG0 <-----OpenAMP------> zephyr_openamp_rsc_table.elf
(Linux ) (zephyr firmware image)
root@stm32mp2-e3-d2-e5:~# lsmod | grep rpmsg
rpmsg_client_sample 16384 0
rpmsg_tty 16384 0 <---- 이번에는 얘가 사용되는데, 이미 구동되어 있다.
rpmsg_ctrl 12288 0
rpmsg_char 20480 1 rpmsg_ctrl
virtio_rpmsg_bus 24576 0
i2c_rpmsg 16384 0
irq_rpmsg 12288 0
root@stm32mp2-e3-d2-e5:~# cat /dev/ttyRPMSG0 &
-> 먼저, 이 명령을 실행하여 /dev/ttyRPMSG0로 들어오는 값을 출력할 준비를 해 둔다.
root@stm32mp2-e3-d2-e5:~# echo "Hello Zephyr" > /dev/ttyRPMSG0
-> Hello Zephyr string을 /dev/ttyRPMSG0로 내보낸다(zephyr로 내보낸다).
Hello Zephyr
[그림 9.24] linux console - fw_cortex_m33.sh stop -> start
한가지 재밌는 사실은 /dev/ttyRPMSG0를 통해 명령을 전달할 경우, 해당 명령이 zephyr rtos 상에서 실행된 후, 그 결과가 linux로 전달되어 console에 출력된다는 점이다.
9.5 STM32CubeMP2 example 돌려 보기
Cortex-M33 CPU core에 firmware를 올리는 방법은 다양하게 존재한다. 이번 절에서는 STM32CubeMP2 example code를 build하여 올려보는 내용을 소개하고자 한다. 사실 이와 관련해서는 (오래전에) STM32MP157C-DK2 보드를 사용하여 비슷한 내용을 소개한 바가 있다. 따라서, 여기에서는 아래 link를 참조하는 것으로 이를 대신하고자 한다. 😂
댓글 없음:
댓글 쓰기