blob: 03d6e0db917d64cdd397e52ecbde042583572677 [file] [log] [blame]
Shubham Kulkarnic75b3c72021-07-20 11:43:28 +05301cmake_minimum_required(VERSION 3.13)
2
3project(hal)
4
5set(esp_idf_dir ${IDF_PATH})
6
7set(SRC_DIR ${CMAKE_CURRENT_LIST_DIR}/src)
8set(INCLUDE_DIRS
9 ${CMAKE_CURRENT_LIST_DIR}/include
10 ${CMAKE_CURRENT_LIST_DIR}/include/${MCUBOOT_TARGET})
11
12list(APPEND INCLUDE_DIRS
13 ${esp_idf_dir}/components/esp_common/include
14 ${esp_idf_dir}/components/esp_rom/include
15 ${esp_idf_dir}/components/xtensa/${MCUBOOT_TARGET}/include
16 ${esp_idf_dir}/components/spi_flash/include
17 ${esp_idf_dir}/components/spi_flash/private_include
18 ${esp_idf_dir}/components/xtensa/include
19 ${esp_idf_dir}/components/soc/${MCUBOOT_TARGET}/include
20 ${esp_idf_dir}/components/${MCUBOOT_TARGET}/include
21 ${esp_idf_dir}/components/soc/include
22 ${esp_idf_dir}/components/esp_hw_support/include
23 ${esp_idf_dir}/components/hal/${MCUBOOT_TARGET}/include
24 ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}
25 ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/private_include
26 ${esp_idf_dir}/components/bootloader_support/include
27 ${esp_idf_dir}/components/bootloader_support/include_bootloader
28 ${esp_idf_dir}/components/hal/include
29 ${esp_idf_dir}/components/efuse/include
30 ${esp_idf_dir}/components/efuse/${MCUBOOT_TARGET}/include
31 )
32set(hal_srcs
33 ${SRC_DIR}/bootloader_init.c
34 ${SRC_DIR}/bootloader_wdt.c
35 ${esp_idf_dir}/components/hal/mpu_hal.c
36 ${esp_idf_dir}/components/bootloader_support/src/bootloader_flash.c
37 ${esp_idf_dir}/components/bootloader_support/src/bootloader_flash_config_${MCUBOOT_TARGET}.c
38 ${esp_idf_dir}/components/bootloader_support/src/bootloader_clock_init.c
39 ${esp_idf_dir}/components/bootloader_support/src/bootloader_efuse_${MCUBOOT_TARGET}.c
40 ${esp_idf_dir}/components/bootloader_support/src/bootloader_panic.c
41 ${esp_idf_dir}/components/bootloader_support/src/bootloader_mem.c
42 ${esp_idf_dir}/components/spi_flash/${MCUBOOT_TARGET}/spi_flash_rom_patch.c
43 ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_init.c
44 ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_time.c
45 ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_clk.c
46 ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_clk_init.c
47 ${esp_idf_dir}/components/hal/wdt_hal_iram.c
48 ${esp_idf_dir}/components/esp_hw_support/cpu_util.c
49 ${esp_idf_dir}/components/esp_rom/patches/esp_rom_uart.c
50 ${esp_idf_dir}/components/${MCUBOOT_TARGET}/clk.c
51 )
52
53set(CFLAGS
54 "-nostdlib"
55 "-mlongcalls"
56 "-Wno-frame-address"
57 "-Wall"
58 "-Wextra"
59 "-W"
60 "-Wwrite-strings"
61 "-Wlogical-op"
62 "-Wshadow"
63 "-ffunction-sections"
64 "-fdata-sections"
65 "-fstrict-volatile-bitfields"
66 "-Werror=all"
67 "-Wno-error=unused-function"
68 "-Wno-error=unused-but-set-variable"
69 "-Wno-error=unused-variable"
70 "-Wno-error=deprecated-declarations"
71 "-Wno-unused-parameter"
72 "-Wno-sign-compare"
73 "-ggdb"
74 "-Os"
75 "-D_GNU_SOURCE"
76 "-std=gnu99"
77 "-Wno-old-style-declaration"
78 "-Wno-implicit-int"
79 )
80
81set(LDFLAGS
82 "-mlongcalls"
83 "-Wno-frame-address"
84 "-Wl,--cref"
85 "-Wl,--Map=${APP_NAME}.map"
86 "-fno-rtti"
87 "-fno-lto"
88 "-Wl,--gc-sections"
89 "-Wl,--undefined=uxTopUsedPriority"
90 "-lm"
91 "-lgcc"
92 "-lgcov"
Shubham Kulkarnic75b3c72021-07-20 11:43:28 +053093 )
94
95add_library(hal STATIC ${hal_srcs} ${INCLUDE_DIRS})
96
97set_source_files_properties(
98 ${esp_idf_dir}/components/bootloader_support/src/bootloader_flash.c
99 ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_clk_init.c
100 ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_clk.c
101 ${esp_idf_dir}/components/esp_hw_support/port/${MCUBOOT_TARGET}/rtc_time.c
102 PROPERTIES COMPILE_FLAGS
103 "-Wno-unused-variable")
104
105target_include_directories(
106 hal
107 PUBLIC
108 ${INCLUDE_DIRS}
109 )
110
111target_compile_options(
112 hal
113 PUBLIC
114 ${CFLAGS}
115 )
116
117target_link_libraries(
118 hal
119 PUBLIC
120 ${LDFLAGS}
121 -T${esp_idf_dir}/components/esp_rom/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.rom.ld
122 -T${esp_idf_dir}/components/esp_rom/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.rom.libgcc.ld
123 -T${esp_idf_dir}/components/esp_rom/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.rom.api.ld
124 -T${esp_idf_dir}/components/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.peripherals.ld
125 -T${esp_idf_dir}/components/esp_rom/${MCUBOOT_TARGET}/ld/${MCUBOOT_TARGET}.rom.newlib-funcs.ld
126 )