-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathxmake.lua
567 lines (527 loc) · 26.6 KB
/
xmake.lua
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
set_project("EC618")
set_xmakever("2.7.2")
set_version("0.0.2", {build = "%Y%m%d%H%M"})
add_rules("mode.debug", "mode.release")
set_defaultmode("debug")
local VM_64BIT = nil
SDK_TOP = "."
local SDK_PATH
local USER_PROJECT_NAME = "example"
local USER_PROJECT_NAME_VERSION
USER_PROJECT_DIR = ""
local LUAT_SCRIPT_SIZE
local LUAT_SCRIPT_OTA_SIZE
local script_addr = nil
local full_addr = nil
package("gnu_rm")
set_kind("toolchain")
set_homepage("https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm")
set_description("GNU Arm Embedded Toolchain")
local version_map = {
["2021.10"] = "10.3-2021.10"
}
if is_host("windows") then
set_urls("http://cdndownload.openluat.com/xmake/toolchains/gcc-arm/gcc-arm-none-eabi-$(version)-win32.zip", {version = function (version)
return version_map[tostring(version)]
end})
add_versions("2021.10", "d287439b3090843f3f4e29c7c41f81d958a5323aecefcf705c203bfd8ae3f2e7")
elseif is_host("linux") then
set_urls("http://cdndownload.openluat.com/xmake/toolchains/gcc-arm/gcc-arm-none-eabi-$(version)-x86_64-linux.tar.bz2", {version = function (version)
return version_map[tostring(version)]
end})
add_versions("2021.10", "97dbb4f019ad1650b732faffcc881689cedc14e2b7ee863d390e0a41ef16c9a3")
elseif is_host("macosx") then
set_urls("https://armkeil.blob.core.windows.net/developer/Files/downloads/gnu-rm/10.3-2021.10/gcc-arm-none-eabi-$(version)-mac.tar.bz2", {version = function (version)
return version_map[tostring(version)]
end})
add_versions("2021.10", "fb613dacb25149f140f73fe9ff6c380bb43328e6bf813473986e9127e2bc283b")
end
on_install("@windows", "@linux", "@macosx", function (package)
os.vcp("*", package:installdir())
end)
package_end()
if os.getenv("GCC_PATH") then
toolchain("arm_toolchain")
set_kind("standalone")
set_sdkdir(os.getenv("GCC_PATH"))
toolchain_end()
set_toolchains("arm_toolchain")
else
add_requires("gnu_rm 2021.10")
set_toolchains("gnu-rm@gnu_rm")
end
-- 获取项目名称
if os.getenv("PROJECT_NAME") then
USER_PROJECT_NAME = os.getenv("PROJECT_NAME")
end
-- 是否为rndis csdk
if os.getenv("EC618_RNDIS") == "enable" then
is_rndis = true
add_defines("LUAT_EC618_RNDIS_ENABLED=1")
else
is_rndis = false
end
-- 是否启用低速模式, 内存更大, 但与rndis不兼容
if is_rndis == false and os.getenv("LSPD_MODE") == "enable" then
is_lspd = true
else
is_lspd = false
end
-- 若启用is_lspd, 加上额外的宏
if is_lspd == true then
add_defines("LOW_SPEED_SERVICE_ONLY")
end
if os.getenv("ROOT_PATH") then
SDK_TOP = os.getenv("ROOT_PATH")
else
SDK_TOP = os.curdir()
end
SDK_TOP = SDK_TOP .. "/"
SDK_PATH = SDK_TOP
if os.getenv("PROJECT_DIR") then
USER_PROJECT_DIR = os.getenv("PROJECT_DIR")
else
USER_PROJECT_DIR = SDK_TOP .. "/project/" .. USER_PROJECT_NAME
end
set_plat("cross")
set_arch("arm")
set_languages("gnu99", "cxx11")
set_warnings("everything")
-- ==============================
-- === defines =====
add_defines("__EC618",
"CHIP_EC618",
"CORE_IS_AP",
"SDK_REL_BUILD",
"EC_ASSERT_FLAG",
"PM_FEATURE_ENABLE",
"UINILOG_FEATURE_ENABLE",
"FEATURE_OS_ENABLE",
"configUSE_NEWLIB_REENTRANT=1",
"ARM_MATH_CM3",
"FEATURE_YRCOMPRESS_ENABLE",
"FEATURE_CCIO_ENABLE",
"DHCPD_ENABLE_DEFINE=1",
"LWIP_CONFIG_FILE=\"lwip_config_ec6180h00.h\"",
"FEATURE_MBEDTLS_ENABLE",
"LFS_NAME_MAX=63",
"LFS_DEBUG_TRACE",
"WDT_FEATURE_ENABLE=1",
"FEATURE_UART_HELP_DUMP_ENABLE",
"DEBUG_LOG_HEADER_FILE=\"debug_log_ap.h\"",
"TRACE_LEVEL=5",
"SOFTPACK_VERSION=\"\"",
"HAVE_STRUCT_TIMESPEC",
"HTTPS_WITH_CA",
"FEATURE_HTTPC_ENABLE",
-- "LITE_FEATURE_MODE",
-- "RTE_RNDIS_EN=0", "RTE_ETHER_EN=0",
"RTE_USB_EN=1",
"RTE_PPP_EN=0",
"RTE_OPAQ_EN=0",
"RTE_ONE_UART_AT=0",
"RTE_TWO_UART_AT=0",
"__USER_CODE__",
"__PRINT_ALIGNED_32BIT__",
"_REENT_SMALL",
"_REENT_GLOBAL_ATEXIT"
)
if is_rndis then
else
add_defines("LITE_FEATURE_MODE")
end
set_optimize("smallest")
add_cxflags("-g3",
"-mcpu=cortex-m3",
"-mthumb",
"-std=gnu99",
"-nostartfiles",
"-mapcs-frame",
"-ffunction-sections",
"-fdata-sections",
"-fno-isolate-erroneous-paths-dereference",
"-freorder-blocks-algorithm=stc",
"-Wall",
"-Wno-format",
"-gdwarf-2",
"-fno-inline",
"-mslow-flash-data",
"-fstack-usage",
"-Wstack-usage=4096",
{force=true})
add_cxflags("-Werror=maybe-uninitialized")
add_ldflags(" -Wl,--wrap=clock ",{force = true})
add_ldflags(" -Wl,--wrap=localtime ",{force = true})
add_ldflags(" -Wl,--wrap=gmtime ",{force = true})
add_ldflags(" -Wl,--wrap=time ",{force = true})
add_ldflags(" -Wl,--wrap=SetUnilogUart", {force=true})
add_ldflags("--specs=nano.specs", {force=true})
add_asflags("-Wl,--cref -Wl,--check-sections -Wl,--gc-sections -lm -Wl,--print-memory-usage -Wl,--wrap=_malloc_r -Wl,--wrap=_free_r -Wl,--wrap=_realloc_r -mcpu=cortex-m3 -mthumb -DTRACE_LEVEL=5 -DSOFTPACK_VERSION=\"\" -DHAVE_STRUCT_TIMESPEC")
add_defines("sprintf=sprintf_")
add_defines("snprintf=snprintf_")
add_defines("vsnprintf=vsnprintf_")
-- 开启网络IP包拦截
if USER_PROJECT_NAME == "luatos" then
add_defines("LUAT_NET_IP_INTERCEPT=1")
add_ldflags("-Wl,--wrap=ps_ip_input",{force = true})
end
-- ==============================
-- === includes =====
add_includedirs(
SDK_TOP .. "/PLAT/device/target/board/common/ARMCM3/inc",
SDK_TOP .. "/PLAT/device/target/board/ec618_0h00/common/inc",
SDK_TOP .. "/PLAT/device/target/board/ec618_0h00/ap/gcc",
SDK_TOP .. "/PLAT/device/target/board/ec618_0h00/ap/inc",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/audio",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/camera",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/camera/bf30a2",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/camera/gc6153",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/camera/gc032A",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/camera/gc6123",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/camera/sp0A39",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/camera/sp0821",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/eeprom",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/lcd",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/lcd/ST7571",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/lcd/ST7789V2",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/inc/ntc",
SDK_TOP .. "/PLAT/driver/chip/ec618/ap/inc",
SDK_TOP .. "/PLAT/driver/chip/ec618/ap/inc_cmsis",
SDK_TOP .. "/PLAT/driver/hal/common/inc",
SDK_TOP .. "/PLAT/driver/hal/ec618/ap/inc",
SDK_TOP .. "/PLAT/os/freertos/inc",
SDK_TOP .. "/PLAT/os/freertos/CMSIS/common/inc",
SDK_TOP .. "/PLAT/os/freertos/CMSIS/ap/inc",
SDK_TOP .. "/PLAT/os/freertos/portable/mem/tlsf",
SDK_TOP .. "/PLAT/os/freertos/portable/gcc",
SDK_TOP .. "/PLAT/middleware/developed/debug/inc",
SDK_TOP .. "/PLAT/middleware/developed/nvram/inc",
SDK_TOP .. "/PLAT/middleware/developed/cms/psdial/inc",
SDK_TOP .. "/PLAT/middleware/developed/cms/cms/inc",
SDK_TOP .. "/PLAT/middleware/developed/cms/psil/inc",
SDK_TOP .. "/PLAT/middleware/developed/cms/psstk/inc",
SDK_TOP .. "/PLAT/middleware/developed/cms/sockmgr/inc",
SDK_TOP .. "/PLAT/middleware/developed/cms/cmsnetlight/inc",
SDK_TOP .. "/PLAT/middleware/developed/ecapi/appmwapi/inc",
SDK_TOP .. "/PLAT/middleware/developed/ecapi/psapi/inc",
SDK_TOP .. "/PLAT/middleware/developed/common/inc",
SDK_TOP .. "/PLAT/middleware/developed/psnv/inc",
SDK_TOP .. "/PLAT/os/freertos/portable/gcc",
SDK_TOP .. "/PLAT/middleware/developed/tcpipmgr/app/inc",
SDK_TOP .. "/PLAT/middleware/developed/tcpipmgr/common/inc",
SDK_TOP .. "/PLAT/os/freertos/inc",
SDK_TOP .. "/PLAT/middleware/developed/yrcompress",
SDK_TOP .. "/PLAT/os/freertos/portable/gcc",
SDK_TOP .. "/PLAT/prebuild/PS/inc",
SDK_TOP .. "/PLAT/middleware/thirdparty/lwip/src/include",
SDK_TOP .. "/PLAT/middleware/thirdparty/lwip/src/include/lwip",
SDK_TOP .. "/PLAT/middleware/developed/ccio/pub",
SDK_TOP .. "/PLAT/middleware/developed/ccio/device/inc",
SDK_TOP .. "/PLAT/middleware/developed/ccio/service/inc",
SDK_TOP .. "/PLAT/middleware/developed/ccio/custom/inc",
SDK_TOP .. "/PLAT/middleware/developed/fota/pub",
SDK_TOP .. "/PLAT/middleware/developed/fota/custom/inc",
SDK_TOP .. "/PLAT/middleware/developed/at/atdecoder/inc",
SDK_TOP .. "/PLAT/middleware/developed/at/atps/inc",
SDK_TOP .. "/PLAT/middleware/developed/at/atps/inc/cnfind",
SDK_TOP .. "/PLAT/middleware/developed/at/atcust/inc",
SDK_TOP .. "/PLAT/middleware/developed/at/atcust/inc/cnfind",
SDK_TOP .. "/PLAT/middleware/developed/at/atentity/inc",
SDK_TOP .. "/PLAT/middleware/developed/at/atreply/inc",
SDK_TOP .. "/PLAT/middleware/developed/at/atref/inc",
SDK_TOP .. "/PLAT/middleware/developed/at/atref/inc/cnfind",
SDK_TOP .. "/PLAT/os/freertos/portable/gcc",
SDK_TOP .. "/thirdparty/httpclient",
SDK_TOP .. "/PLAT/os/freertos/portable/gcc",
SDK_TOP .. "/PLAT/middleware/thirdparty/lwip/src/include",
SDK_TOP .. "/PLAT/middleware/thirdparty/lwip/src/include/posix",
SDK_TOP .. "/PLAT/os/freertos/inc",
SDK_TOP .. "/PLAT/os/freertos/portable/gcc",
SDK_TOP .. "/thirdparty/littlefs",
SDK_TOP .. "/thirdparty/littlefs/port",
SDK_TOP .. "/PLAT/os/freertos/portable/gcc",
SDK_TOP .. "/PLAT/prebuild/PS/inc",
SDK_TOP .. "/PLAT/prebuild/PLAT/inc",
SDK_TOP .. "/PLAT/core/common/include",
SDK_TOP .. "/PLAT/core/tts/include",
SDK_TOP .. "/PLAT/core/multimedia/include",
SDK_TOP .. "/PLAT/core/driver/include",
SDK_TOP .. "/thirdparty/antbot/include",
SDK_TOP .. "/thirdparty/linksdk",
SDK_TOP .. "/thirdparty/printf",
{public = true})
if USER_PROJECT_NAME ~= 'luatos' then
add_defines("MBEDTLS_CONFIG_FILE=\"config_user_ssl.h\"")
add_includedirs(SDK_TOP .. "/interface/include",
SDK_TOP .. "/interface/base_include",
SDK_TOP .. "/interface/private_include",
SDK_TOP .. "/thirdparty/mbedtls/include",
SDK_TOP .. "/thirdparty/mbedtls/include/mbedtls",
SDK_TOP .. "/thirdparty/mbedtls/configs",
SDK_TOP .. "/thirdparty/fal/inc",
SDK_TOP .. "/thirdparty/flashdb/inc",
{public = true})
else
if os.getenv("LUAT_EC618_LITE_MODE") == "1" then
add_defines("LUAT_EC618_LITE_MODE", "LUAT_SCRIPT_SIZE=448", "LUAT_SCRIPT_OTA_SIZE=284")
end
if os.getenv("LUAT_USE_TTS") == "1" then
add_defines("LUAT_USE_TTS")
end
if os.getenv("LUAT_USE_TTS_ONCHIP") == "1" then
add_defines("LUAT_USE_TTS_ONCHIP")
end
add_defines("__LUATOS__","LWIP_NUM_SOCKETS=8")
add_defines("MBEDTLS_CONFIG_FILE=\"mbedtls_ec618_config.h\"")
end
--linkflags
local LD_BASE_FLAGS = "-Wl,--cref -Wl,--check-sections -Wl,--gc-sections -lm -Wl,--print-memory-usage"
LD_BASE_FLAGS = LD_BASE_FLAGS .. " -L" .. SDK_TOP .. "/PLAT/device/target/board/ec618_0h00/ap/gcc/"
--LD_BASE_FLAGS = LD_BASE_FLAGS .. " -T" .. SDK_TOP .. "/PLAT/device/target/board/ec618_0h00/ap/gcc/ec618_0h00_flash.ld -Wl,-Map,$(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME.."_$(mode).map "
LD_BASE_FLAGS = LD_BASE_FLAGS .. " -T" .. SDK_TOP .. "/PLAT/core/ld/ec618_0h00_flash.ld -Wl,-Map,$(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME.."_$(mode).map "
LD_BASE_FLAGS = LD_BASE_FLAGS .. " -Wl,--wrap=_malloc_r -Wl,--wrap=_free_r -Wl,--wrap=_realloc_r -mcpu=cortex-m3 -mthumb -DTRACE_LEVEL=5 -DSOFTPACK_VERSION=\"\" -DHAVE_STRUCT_TIMESPEC"
local LIB_BASE = SDK_TOP .. "/PLAT/libs/libstartup.a "
LIB_BASE = LIB_BASE .. SDK_TOP .. "/PLAT/libs/libcore_airm2m.a "
LIB_BASE = LIB_BASE .. SDK_TOP .. "/PLAT/libs/libfreertos.a "
LIB_BASE = LIB_BASE .. SDK_TOP .. "/PLAT/libs/libpsnv.a "
LIB_BASE = LIB_BASE .. SDK_TOP .. "/PLAT/libs/libtcpipmgr.a "
LIB_BASE = LIB_BASE .. SDK_TOP .. "/PLAT/libs/libyrcompress.a "
LIB_BASE = LIB_BASE .. SDK_TOP .. "/PLAT/libs/libmiddleware_ec.a "
LIB_BASE = LIB_BASE .. SDK_TOP .. "/PLAT/libs/liblwip.a "
if os.getenv("LUAT_FAST_ADD_USER_LIB") == "1" then
LIB_BASE = LIB_BASE .. SDK_TOP .. os.getenv("USER_LIB") .. " "
end
if is_rndis then
LIB_PS_PRE = SDK_TOP .. "/PLAT/prebuild/PS/lib/gcc"
LIB_PLAT_PRE = SDK_TOP .. "/PLAT/prebuild/PLAT/lib/gcc"
else
LIB_PS_PRE = SDK_TOP .. "/PLAT/prebuild/PS/lib/gcc/lite"
LIB_PLAT_PRE = SDK_TOP .. "/PLAT/prebuild/PLAT/lib/gcc/lite"
end
LIB_BASE = LIB_BASE .. LIB_PS_PRE .. "/libps.a "
LIB_BASE = LIB_BASE .. LIB_PS_PRE .. "/libpsl1.a "
LIB_BASE = LIB_BASE .. LIB_PS_PRE .. "/libpsif.a "
LIB_BASE = LIB_BASE .. LIB_PLAT_PRE .. "/libosa.a "
LIB_BASE = LIB_BASE .. LIB_PLAT_PRE .. "/libmiddleware_ec_private.a "
LIB_BASE = LIB_BASE .. LIB_PLAT_PRE .. "/libccio.a "
LIB_BASE = LIB_BASE .. LIB_PLAT_PRE .. "/libdeltapatch.a "
LIB_BASE = LIB_BASE .. LIB_PLAT_PRE .. "/libfota.a "
LIB_BASE = LIB_BASE .. LIB_PLAT_PRE .. "/libdriver_private.a "
LIB_BASE = LIB_BASE .. LIB_PLAT_PRE .. "/libusb_private.a "
LIB_USER = ""
after_load(function (target)
for _, sourcebatch in pairs(target:sourcebatches()) do
if sourcebatch.sourcekind == "as" then -- only asm files
for idx, objectfile in ipairs(sourcebatch.objectfiles) do
sourcebatch.objectfiles[idx] = objectfile:gsub("%.S%.o", ".o")
end
end
if sourcebatch.sourcekind == "cc" then -- only c files
for idx, objectfile in ipairs(sourcebatch.objectfiles) do
sourcebatch.objectfiles[idx] = objectfile:gsub("%.c%.o", ".o")
end
end
end
end)
target("driver")
set_kind("static")
add_deps(USER_PROJECT_NAME)
--driver
add_files(SDK_TOP .. "/PLAT/driver/board/ec618_0h00/src/**.c",
SDK_TOP .. "/PLAT/driver/chip/ec618/ap/**.c",
SDK_TOP .. "/PLAT/driver/chip/ec618/common/gcc/memcpy-armv7m.S",
SDK_TOP .. "/PLAT/driver/hal/**.c",
SDK_TOP .. "/PLAT/core/speed/*.c"
)
remove_files(SDK_TOP .. "/PLAT/driver/board/ec618_0h00/src/camera/camAT.c",
SDK_TOP .. "/PLAT/driver/board/ec618_0h00/src/exstorage/*.c",
SDK_TOP.."/PLAT/driver/chip/ec618/ap/src/usb/usb_device/usb_bl_test.c",
SDK_TOP.."/PLAT/driver/chip/ec618/ap/src_cmsis/bsp_lpusart_stub.c",
SDK_TOP.."/PLAT/driver/chip/ec618/ap/src/tls.c",
SDK_TOP.."/PLAT/driver/chip/ec618/ap/src_cmsis/bsp_spi.c"
)
set_targetdir("$(buildir)/libdriver_" .. USER_PROJECT_NAME)
target_end()
includes(USER_PROJECT_DIR)
target(USER_PROJECT_NAME..".elf")
set_kind("binary")
-- add_deps(USER_PROJECT_NAME)
set_targetdir("$(buildir)/"..USER_PROJECT_NAME)
add_deps("driver")
-- if os.getenv("GCC_PATH") then
-- LD_BASE_FLAGS = " --specs=nano.specs " .. LD_BASE_FLAGS
-- end
if USER_PROJECT_NAME ~= 'luatos' then
add_files(SDK_TOP .. "/interface/private_src/*.c",{public = true})
add_files(SDK_TOP .. "/thirdparty/mbedtls/library/*.c",{public = true})
add_files(SDK_TOP .. "/thirdparty/printf/*.c",{public = true})
add_files(SDK_TOP.."/thirdparty/fal/src/*.c",{public = true})
add_files(SDK_TOP.."/thirdparty/flashdb/src/*.c",{public = true})
add_files(SDK_TOP .. "/interface/src/*.c",{public = true})
add_files(SDK_TOP .. "/thirdparty/littlefs/**.c",{public = true})
else
remove_files(SDK_TOP .. "/interface/src/luat_kv_ec618.c")
end
add_ldflags(LD_BASE_FLAGS .. " -Wl,--whole-archive -Wl,--start-group " .. LIB_BASE .. LIB_USER .. " -Wl,--end-group -Wl,--no-whole-archive -Wl,--no-undefined -Wl,--no-print-map-discarded -ldriver", {force=true})
on_load(function (target)
if USER_PROJECT_NAME == 'luatos' then
local conf_data = io.readfile("$(projectdir)/project/luatos/inc/luat_conf_bsp.h")
USER_PROJECT_NAME_VERSION = conf_data:match("#define LUAT_BSP_VERSION \"(%w+)\"")
VM_64BIT = conf_data:find("\r#define LUAT_CONF_VM_64bit") or conf_data:find("\n#define LUAT_CONF_VM_64bit")
local TTS_ONCHIP = conf_data:find("\r#define LUAT_USE_TTS_ONCHIP") or conf_data:find("\n#define LUAT_USE_TTS_ONCHIP")
local TLS_DISABLE = conf_data:find("\r#define LUAT_USE_TLS_DISABLE") or conf_data:find("\n#define LUAT_USE_TLS_DISABLE")
local mem_map_data = io.readfile("$(projectdir)/PLAT/device/target/board/ec618_0h00/common/inc/mem_map.h")
FLASH_FOTA_REGION_START = tonumber(mem_map_data:match("#define FLASH_FOTA_REGION_START%s+%((%g+)%)"))
if (TTS_ONCHIP or os.getenv("LUAT_USE_TTS_ONCHIP") == "1") and not TLS_DISABLE then
LUAT_SCRIPT_SIZE = 64
LUAT_SCRIPT_OTA_SIZE = 48
elseif os.getenv("LUAT_EC618_LITE_MODE") == "1" then
LUAT_SCRIPT_SIZE = 448
LUAT_SCRIPT_OTA_SIZE = 284
else
LUAT_SCRIPT_SIZE = tonumber(conf_data:match("\r#define LUAT_SCRIPT_SIZE (%d+)") or conf_data:match("\n#define LUAT_SCRIPT_SIZE (%d+)"))
LUAT_SCRIPT_OTA_SIZE = tonumber(conf_data:match("\r#define LUAT_SCRIPT_OTA_SIZE (%d+)") or conf_data:match("\n#define LUAT_SCRIPT_OTA_SIZE (%d+)"))
end
print(string.format("script zone %d ota %d", LUAT_SCRIPT_SIZE, LUAT_SCRIPT_OTA_SIZE))
LUA_SCRIPT_ADDR = FLASH_FOTA_REGION_START - (LUAT_SCRIPT_SIZE + LUAT_SCRIPT_OTA_SIZE) * 1024
LUA_SCRIPT_OTA_ADDR = FLASH_FOTA_REGION_START - LUAT_SCRIPT_OTA_SIZE * 1024
script_addr = string.format("%X", LUA_SCRIPT_ADDR)
full_addr = string.format("%X", LUA_SCRIPT_OTA_ADDR)
-- print(FLASH_FOTA_REGION_START,LUAT_SCRIPT_SIZE,LUAT_SCRIPT_OTA_SIZE)
-- print(script_addr,full_addr)
end
end)
before_build(function(target)
if os.getenv("GCC_PATH") then
GCC_DIR = os.getenv("GCC_PATH").."/"
else
GCC_DIR = target:toolchains()[1]:sdkdir().."/"
end
if os.getenv("LSPD_MODE") == "enable" then
FLAGS = "-DLOW_SPEED_SERVICE_ONLY"
else
FLAGS = ""
end
if USER_PROJECT_NAME == "luatos" then
FLAGS = FLAGS .. " -D__LUATOS__ -DFLASH_AREA_SIZE=" .. string.format("%dK", 2944 - LUAT_SCRIPT_SIZE - LUAT_SCRIPT_OTA_SIZE)
end
os.exec(GCC_DIR .. "bin/arm-none-eabi-gcc -E " .. FLAGS .. " -I " .. SDK_PATH .. "/PLAT/device/target/board/ec618_0h00/common/inc" .. " -P " .. SDK_PATH .. "/PLAT/core/ld/ec618_0h00_flash.c" .. " -o " .. SDK_PATH .. "/PLAT/core/ld/ec618_0h00_flash.ld")
end)
after_build(function(target)
if os.getenv("GCC_PATH") then
GCC_DIR = os.getenv("GCC_PATH").."/"
else
GCC_DIR = target:toolchains()[1]:sdkdir().."/"
end
OUT_PATH = SDK_PATH .. "/out/" ..USER_PROJECT_NAME
if not os.exists(OUT_PATH) then
os.mkdir(OUT_PATH)
end
os.exec(GCC_DIR .. "bin/arm-none-eabi-objcopy -O binary $(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".elf $(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".bin")
-- io.writefile("$(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".list", os.iorun(GCC_DIR .. "bin/arm-none-eabi-objdump -h -S $(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".elf"))
io.writefile("$(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".size", os.iorun(GCC_DIR .. "bin/arm-none-eabi-size $(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".elf"))
-- io.cat("$(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".size")
os.exec(GCC_DIR .. "bin/arm-none-eabi-objcopy -O binary $(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".elf $(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".bin")
os.exec(GCC_DIR .."bin/arm-none-eabi-size $(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".elf")
os.cp("$(buildir)/"..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".bin", "$(buildir)/"..USER_PROJECT_NAME.."/ap.bin")
os.cp("$(buildir)/"..USER_PROJECT_NAME.."/*.bin", OUT_PATH)
os.cp("$(buildir)/"..USER_PROJECT_NAME.."/*.map", OUT_PATH)
os.cp("$(buildir)/"..USER_PROJECT_NAME.."/*.elf", OUT_PATH)
os.cp("./PLAT/comdb.txt", OUT_PATH)
---------------------------------------------------------
-------------- 这部分尚不能跨平台
local cmd = "-M -input ./PLAT/tools/ap_bootloader.bin -addrname BL_IMG_MERGE_ADDR -flashsize BOOTLOADER_FLASH_LOAD_SIZE -input $(buildir)/"..USER_PROJECT_NAME.."/ap.bin -addrname AP_IMG_MERGE_ADDR -flashsize AP_FLASH_LOAD_SIZE -input ./PLAT/prebuild/FW/lib/cp-demo-flash.bin -addrname CP_IMG_MERGE_ADDR -flashsize CP_FLASH_LOAD_SIZE -def ./PLAT/device/target/board/ec618_0h00/common/inc/mem_map.h "
if os.getenv("BINPKG_CROSS") then
-- 准备自定义打包程序
cmd = os.getenv("BINPKG_CROSS") .. cmd
else
if is_plat("windows") then
cmd = "./PLAT/tools/fcelf.exe " .. cmd
elseif is_plat("macosx") then
cmd = "bash ./fcelf-docker.sh " .. cmd
else
cmd = "./fcelf " .. cmd
end
end
cmd = cmd .. " -outfile " .. "./out/" ..USER_PROJECT_NAME.."/"..USER_PROJECT_NAME..".binpkg"
-- 如果所在平台没有fcelf, 可注释掉下面的行, 没有binpkg生成.
-- 仍可使用其他工具继续刷机
print("fcelf CMD --> ", cmd)
os.exec(cmd)
---------------------------------------------------------
import("lib.detect.find_file")
local path7z = nil
if is_plat("windows") then
path7z = "\"$(programdir)/winenv/bin/7z.exe\""
elseif is_plat("linux") or is_plat("macosx") then
path7z = find_file("7z", { "/usr/bin/", "/usr/local/bin/" })
if not path7z then
path7z = find_file("7zr", { "/usr/bin/"})
end
end
if path7z == nil then
print("7z not find")
return
end
import("core.base.json")
if USER_PROJECT_NAME == 'luatos' then
os.cp("$(projectdir)/project/luatos/pack", OUT_PATH)
local info_table = json.loadfile(OUT_PATH.."/pack/info.json")
if VM_64BIT then
info_table["script"]["bitw"] = 64
end
if script_addr then
info_table["download"]["script_addr"] = script_addr
info_table["rom"]["fs"]["script"]["size"] = LUAT_SCRIPT_SIZE
io.gsub(OUT_PATH.."/pack/config_ec618_usb.ini", "filepath = .\\script.bin\nburnaddr = 0x(%g+)", "filepath = .\\script.bin\nburnaddr = 0x"..script_addr)
end
if full_addr then
info_table["fota"]["full_addr"] = full_addr
end
json.savefile(OUT_PATH.."/pack/info.json", info_table)
os.cp(OUT_PATH.."/luatos.binpkg", OUT_PATH.."/pack")
os.cp(OUT_PATH.."/luatos.elf", OUT_PATH.."/pack")
os.cp(OUT_PATH.."/*.map", OUT_PATH.."/pack")
os.cp("./PLAT/comdb.txt", OUT_PATH.."/pack")
os.cp("./PLAT/device/target/board/ec618_0h00/common/inc/mem_map.h", OUT_PATH .. "/pack")
os.cp("$(projectdir)/project/luatos/inc/luat_conf_bsp.h", OUT_PATH.."/pack")
os.exec(path7z.." a -mx9 LuatOS-SoC_"..USER_PROJECT_NAME_VERSION.."_EC618.7z "..OUT_PATH.."/pack/* -r")
local ver = "_FULL"
if os.getenv("LUAT_EC618_LITE_MODE") == "1" then
ver = ""
end
if os.getenv("LUAT_USE_TTS") == "1" then
ver = "_TTS"
if os.getenv("LUAT_USE_TTS_ONCHIP") == "1" then
ver = "_TTS_ONCHIP"
end
end
os.mv("LuatOS-SoC_"..USER_PROJECT_NAME_VERSION.."_EC618.7z", OUT_PATH.."/LuatOS-SoC_"..USER_PROJECT_NAME_VERSION.."_EC618"..ver..".soc")
os.rm(OUT_PATH.."/pack")
else
if not os.exists(OUT_PATH.."/pack") then
os.mkdir(OUT_PATH.."/pack")
end
os.cp(OUT_PATH.."/*.binpkg", OUT_PATH.."/pack")
os.cp(OUT_PATH.."/*.elf", OUT_PATH.."/pack")
os.cp(OUT_PATH.."/*.map", OUT_PATH.."/pack")
os.cp("./PLAT/comdb.txt", OUT_PATH.."/pack")
os.cp("$(projectdir)/project/luatos/pack/info.json", OUT_PATH.."/pack")
local info_table = json.loadfile(OUT_PATH.."/pack/info.json")
info_table["rom"]["file"] = USER_PROJECT_NAME .. ".binpkg"
json.savefile(OUT_PATH.."/pack/info.json", info_table)
os.cp("./PLAT/device/target/board/ec618_0h00/common/inc/mem_map.h", OUT_PATH .. "/pack")
os.exec(path7z.." a -mx9 "..USER_PROJECT_NAME.."_ec618.7z "..OUT_PATH.."/pack/* -r")
os.mv(USER_PROJECT_NAME.."_ec618.7z", OUT_PATH.."/"..USER_PROJECT_NAME.."_ec618.soc")
os.rm(OUT_PATH.."/pack")
end
-- 计算差分包大小, 需要把老的binpkg放在根目录,且命名为 $项目名称.binpkg
if os.exists(USER_PROJECT_NAME .. ".binpkg") then
os.cp("./PLAT/tools/fcelf.exe", "tools/dtools/dep/fcelf.exe")
os.cp(OUT_PATH.."/"..USER_PROJECT_NAME..".binpkg", "tools/dtools/new.binpkg")
os.cp(USER_PROJECT_NAME .. ".binpkg", "tools/dtools/old.binpkg")
os.exec("tools\\dtools\\run.bat BINPKG delta.par " .. USER_PROJECT_NAME .. ".binpkg new.binpkg")
end
end)
target_end()