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;
}

댓글 없음:

댓글 쓰기

gitea 설치

깃 서버 wget -O gitea https://dl.gitea.com/gitea/1.22.0/gitea-1.22.0-linux-amd64 chmod a+x gitea ./gitea web github 에서 미러링시에, access token을 넣어야...