2023-10-18

cmake binary file add.

cmake_minimum_required(VERSION 3.21)

project(example)

add_executable(main main.c)

add_executable(firmware firmware.bin)

target_link_libraries(main firmware)

# 대상의 크기를 바이트로 가져오는 함수 정의
function(get_size_of_data target)
  get_target_property(size ${target} SIZE)
  return(${size})
endfunction()

# 'firmware' 대상의 크기를 가져오고 'CMAKE_SIZE_OF_DATA' 변수에 저장
get_size_of_data(firmware)
set(CMAKE_SIZE_OF_DATA ${size})

# 'FIRMWARE_SIZE'를 킬로바이트(KB)로 변환
math(EXPR FIRMWARE_SIZE "${CMAKE_SIZE_OF_DATA} / 1024")

message("FIRMWARE_SIZE in KB: ${FIRMWARE_SIZE}")


사용법은....................................................................................
#include <stdio.h>

int main() {
  // 펌웨어 데이터를 가져옵니다.
  void *data = ((void(*)())firmware)();

  // 펌웨어 크기를 가져옵니다.
  int size = FIRMWARE_SIZE;

  // 펌웨어 데이터를 처리합니다.
  // ...

  return 0;
}

댓글 없음:

댓글 쓰기

[qemu] 실행

DISTRO=nodistro MACHINE=qemuarm source layers/meta-st/scripts/envsetup.sh runqemu qemuarm 다음에는 간단한 distro를 만들어서 해봐야겠다.