blob: ce939d1629d9b92f6f34da623ee0ebbaa92f9dff (
plain) (
blame)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
ESP_KCONFIGS=
ESP_KCONFIGS_PROJBUILD=
ESP_LDFRAGMENTS=
ESP_SDKCONFIG_RENAMES=
macro ESP_KCONFIG(Kconfig) {
SET_APPEND(ESP_KCONFIGS \${input;hide:$Kconfig})
SET_APPEND(ESP_KCONFIGS_GLOBAL ${pre=$ARCADIA_ROOT/$MODDIR/:Kconfig})
}
macro ESP_KCONFIG_PROJBUILD(Kconfig) {
SET_APPEND(ESP_KCONFIGS_PROJBUILD \${input;hide:$Kconfig})
SET_APPEND(ESP_KCONFIGS_PROJBUILD_GLOBAL ${pre=$ARCADIA_ROOT/$MODDIR/:Kconfig})
}
macro ESP_LDFRAGMENTS(Fragments...) {
SET_APPEND(ESP_LDFRAGMENTS ${pre=\$\{input\;hide\:\";suf=\"\}:Fragments})
SET_APPEND(ESP_LDFRAGMENTS_GLOBAL ${pre=$ARCADIA_ROOT/$MODDIR/:Fragments})
}
macro ESP_SDKCONFIG_RENAME(Rename) {
SET_APPEND(ESP_SDKCONFIG_RENAMES \${input;hide:$Rename})
SET_APPEND(ESP_SDKCONFIG_RENAMES_GLOBAL ${pre=$ARCADIA_ROOT/$MODDIR/:Rename})
}
ESP_LINK_LIB=$LINK_LIB $ESP_KCONFIGS $ESP_KCONFIGS_PROJBUILD $ESP_LDFRAGMENTS $ESP_SDKCONFIG_RENAMES
ESP_CONFIG=contrib/libs/esp-idf/config
module ESP_LIBRARY: LIBRARY {
.CMD=ESP_LINK_LIB
.GLOBAL=ESP_KCONFIGS ESP_KCONFIGS_PROJBUILD ESP_LDFRAGMENTS ESP_SDKCONFIG_RENAMES
ADDINCL(GLOBAL $ESP_CONFIG)
}
ESP_KCONFIGS_CMD=$WRITER_PY --file ${tmp:"kconfigs.in"} -m ${pre="source \"";suf="\"":ESP_KCONFIGS_GLOBAL}
ESP_KCONFIGS_PROJBUILD_CMD=$WRITER_PY --file ${tmp:"kconfigs_projbuild.in"} -m ${pre="source \"";suf="\"":ESP_KCONFIGS_PROJBUILD_GLOBAL}
ESP_SDKCONFIG_DEFAULTS=contrib/libs/esp-idf/sdkconfig.defaults
macro _ESP_CONFGEN_DEFAULTS_HELPER(Defaults...) {
.CMD=${pre=--defaults :Defaults}
}
macro _ESP_CONFGEN_DEFAULTS_ARGS(Defaults...) {
.CMD=$_ESP_CONFGEN_DEFAULTS_HELPER(${input:Defaults})
}
ESP_CONFGEN_CMD= \
${tool:"contrib/libs/esp-idf/tools/kconfig_new/confgen"} \
$_ESP_CONFGEN_DEFAULTS_ARGS($ESP_SDKCONFIG_DEFAULTS) \
--kconfig ${input:"contrib/libs/esp-idf/Kconfig"} \
--sdkconfig-rename ${input:"contrib/libs/esp-idf/sdkconfig.rename"} \
--env IDF_CMAKE=y \
--env IDF_TARGET=esp32c3 \
--env IDF_ENV_FPGA= \
--env IDF_PATH=$ARCADIA_ROOT/contrib/libs/esp-idf \
--env COMPONENT_KCONFIGS_SOURCE_FILE=${tmp:"kconfigs.in"} \
--env COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=${tmp:"kconfigs_projbuild.in"} \
--env COMPONENT_SDKCONFIG_RENAMES=${join=" ":ESP_SDKCONFIG_RENAMES_GLOBAL} \
--output config ${output:"sdkconfig"} \
--output header ${output:"sdkconfig.h"}
ESP_LIBRARIES_CMD=$WRITER_PY --file ${tmp:"ldgen_libraries"} -m $PEERS
ESP_LDGEN_CMD= \
${tool:"contrib/libs/esp-idf/tools/ldgen"} \
--config ${tmp:"sdkconfig"} \
--fragments $ESP_LDFRAGMENTS_GLOBAL \
--input ${input:"contrib/libs/esp-idf/components/esp_system/ld/esp32c3/sections.ld.in"} \
--output ${output:"sections.ld"} \
--kconfig ${input:"contrib/libs/esp-idf/Kconfig"} \
--env IDF_CMAKE=y \
--env IDF_TARGET=esp32c3 \
--env IDF_ENV_FPGA= \
--env IDF_PATH=$ARCADIA_ROOT/contrib/libs/esp-idf \
--env COMPONENT_KCONFIGS_SOURCE_FILE=${tmp:"kconfigs.in"} \
--env COMPONENT_KCONFIGS_PROJBUILD_SOURCE_FILE=${tmp:"kconfigs_projbuild.in"} \
--libraries-file ${tmp:"ldgen_libraries"} \
--objdump $OBJDUMP_TOOL
ESP_FLASH_SIZE=4MB
macro _ESP_ELF2IMAGE(Elf, Args...) {
.CMD=${cwd:BINDIR} ${tool:"contrib/tools/esptool/esptool"} --chip esp32c3 elf2image $Args --flash_mode dio --flash_freq 80m --flash_size $ESP_FLASH_SIZE --min-rev 3 -o ${output;noext:Elf.bin} $Elf
}
ESP_PARTITION_TABLE_OFFSET=0x8000
ESP_PARTITION_TABLE=partitions.csv
ESP_GEN_ESP32PART_CMD= \
${tool:"contrib/libs/esp-idf/components/partition_table/gen_esp32part"} \
--flash-size $ESP_FLASH_SIZE \
--offset $ESP_PARTITION_TABLE_OFFSET \
--secure \
${input:ESP_PARTITION_TABLE} \
${output:"partition-table.bin"}
ESP_LINK_EXE= \
&& $ESP_KCONFIGS_CMD \
&& $ESP_KCONFIGS_PROJBUILD_CMD \
&& $ESP_CONFGEN_CMD \
&& $ESP_LIBRARIES_CMD \
&& $ESP_LDGEN_CMD \
&& $ESP_GEN_ESP32PART_CMD \
&& $LINK_EXE \
&& $_ESP_ELF2IMAGE($MODULE_PREFIX$REALPRJNAME, "--secure-pad-v2")
### @usage: ESP_PROGRAM([progname])
###
### Program module for Espressif microcontrollers.
### Converts ELF to binary image file suitable for flashing.
### Currently, only ESP32-C3 is supported.
module ESP_PROGRAM: PROGRAM {
.CMD=ESP_LINK_EXE
.GLOBAL=ESP_KCONFIGS ESP_KCONFIGS_PROJBUILD ESP_LDFRAGMENTS ESP_SDKCONFIG_RENAMES
ALLOCATOR(FAKE)
NO_PLATFORM()
LINKER_SCRIPT_VALUE+=-T$ARCADIA_BUILD_ROOT/$MODDIR/sections.ld
}
ESP_BOOTLOADER_LINK_EXE= \
&& $LINK_EXE \
&& $_ESP_ELF2IMAGE($MODULE_PREFIX$REALPRJNAME, "--pad-to-size", "4KB")
module ESP_BOOTLOADER: PROGRAM {
.CMD=ESP_BOOTLOADER_LINK_EXE
ALLOCATOR(FAKE)
NO_PLATFORM()
}
when ($ESP_BOOTLOADER_BUILD == "yes") {
CFLAGS+=-DBOOTLOADER_BUILD -fno-stack-protector
}
|