summaryrefslogtreecommitdiff
path: root/fw/CMakeLists.txt
blob: 0541836ffc9717acc5b5c28facea14ed1206d7e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# This Source Code Form is subject to the terms of the Mozilla Public License,
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.

cmake_minimum_required(VERSION 3.20.0)

set(BOARD "native_sim/native/64")
set(ZEPHYR_MODULES
	"${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/modules/hal/cmsis"
	"${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/modules/hal/stm32"
	"${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/modules/crypto/mbedtls"
	"${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/bootloader/mcuboot"
)

string(REPLACE ";" "," ZEPHYR_MODULES_COMMA "${ZEPHYR_MODULES}")
include(ExternalProject)
ExternalProject_Add(
	bootloader
	PREFIX bootloader
	SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/bootloader/mcuboot/boot/zephyr"
	BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/bootloader"
	INSTALL_COMMAND ""
	LIST_SEPARATOR ","
	CMAKE_ARGS
		"-DBOARD=nucleo_f767zi"
		"-DZEPHYR_MODULES=${ZEPHYR_MODULES_COMMA}"
		"-DEXTRA_CONF_FILE=${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/bootloader/bootloader.conf"
		-DCONFIG_BOOT_SIGNATURE_KEY_FILE="${KEY}"
)

find_package(Zephyr
	REQUIRED
	HINTS
		"${CMAKE_CURRENT_SOURCE_DIR}/zephyrproject/zephyr"
)

project(iot-contact-fw)

target_sources(app
	PRIVATE
		"${CMAKE_CURRENT_SOURCE_DIR}/src/syslog.c"
		"${CMAKE_CURRENT_SOURCE_DIR}/src/network.c"
		"${CMAKE_CURRENT_SOURCE_DIR}/src/http.c"
		"${CMAKE_CURRENT_SOURCE_DIR}/src/ws.c"
		"${CMAKE_CURRENT_SOURCE_DIR}/src/heart.c"
		"${CMAKE_CURRENT_SOURCE_DIR}/src/firmware.c"
)

zephyr_linker_sources(SECTIONS sections-rom.ld)
zephyr_linker_section(NAME http_resource_desc_http_service
                      KVMA RAM_REGION GROUP RODATA_REGION
                      SUBALIGN ${CONFIG_LINKER_ITERABLE_SUBALIGN})

generate_inc_file_for_target(
	app
	src/index.html
	${ZEPHYR_BINARY_DIR}/include/generated/index.html.gz.inc
	--gzip
)

generate_inc_file_for_target(
	app
	src/iot-contact.js
	${ZEPHYR_BINARY_DIR}/include/generated/iot-contact.js.gz.inc
	--gzip
)