Skip to content

Commit b050662

Browse files
committed
[core] Use external FreeRTOS library
1 parent f69b4be commit b050662

10 files changed

+74
-43
lines changed

builder/family/beken-72xx.py

+10-18
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,16 @@
269269
)
270270

271271
# Sources - FreeRTOS
272+
freertos_opts = dict(
273+
CCFLAGS=[
274+
# build FreeRTOS port in ARM mode
275+
"+<-marm>",
276+
"-<-mthumb>",
277+
],
278+
)
279+
env.Replace(FREERTOS_PORT="beken-bdk", FREERTOS_PORT_DEFINE="BEKEN_BDK")
280+
queue.AddExternalLibrary("freertos", options=freertos_opts)
281+
queue.AddExternalLibrary("freertos-port", options=freertos_opts)
272282
queue.AddLibrary(
273283
name="bdk_freertos_thumb",
274284
base_dir=ROOT_DIR,
@@ -279,24 +289,6 @@
279289
"+<os/*>",
280290
],
281291
)
282-
queue.AddLibrary(
283-
name="bdk_freertos_arm",
284-
base_dir="$SDK_DIR",
285-
srcs=[
286-
"+<FreeRTOSv9.0.0/FreeRTOS/Source/**/*.c>",
287-
],
288-
includes=[
289-
"+<FreeRTOSv9.0.0/FreeRTOS/Source/include>",
290-
"+<FreeRTOSv9.0.0/FreeRTOS/Source/portable/Keil/ARM968es>",
291-
],
292-
options=dict(
293-
CCFLAGS=[
294-
# build FreeRTOS port in ARM mode
295-
"+<-marm>",
296-
"-<-mthumb>",
297-
],
298-
),
299-
)
300292

301293
# Sources - lwIP
302294
queue.AddExternalLibrary("lwip", port="bdk")

builder/family/realtek-ambz.py

+5-11
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,8 @@
9696
"+<component/common/drivers/wlan/realtek/src/osdep/lwip_intf.c>",
9797
"+<component/common/network/dhcp/dhcps.c>",
9898
"+<component/common/network/ssl/ssl_ram_map/ssl_ram_map.c>",
99-
"+<component/os/freertos/freertos_v8.1.2/Source/portable/MemMang/heap_5.c>",
100-
"+<component/os/freertos/freertos_v8.1.2/Source/portable/GCC/ARM_CM4F/port.c>",
101-
# "+<component/os/freertos/freertos_v8.1.2/Source/portable/IAR/ARM_CM4F/portasm.s>",
10299
"+<component/os/freertos/cmsis_os.c>",
103-
"+<component/os/freertos/freertos_v8.1.2/Source/croutine.c>",
104-
"+<component/os/freertos/freertos_v8.1.2/Source/event_groups.c>",
105100
"+<component/os/freertos/freertos_service.c>",
106-
"+<component/os/freertos/freertos_v8.1.2/Source/list.c>",
107-
"+<component/os/freertos/freertos_v8.1.2/Source/queue.c>",
108-
"+<component/os/freertos/freertos_v8.1.2/Source/tasks.c>",
109-
"+<component/os/freertos/freertos_v8.1.2/Source/timers.c>",
110101
"+<component/os/os_dep/device_lock.c>",
111102
"+<component/os/os_dep/osdep_service.c>",
112103
"+<component/common/mbed/targets/hal/rtl8711b/analogin_api.c>",
@@ -144,8 +135,6 @@
144135
includes=[
145136
"+<project/realtek_amebaz_va0_example/inc>",
146137
"+<component/os/freertos>",
147-
"+<component/os/freertos/freertos_v8.1.2/Source/include>",
148-
"+<component/os/freertos/freertos_v8.1.2/Source/portable/GCC/ARM_CM4F>",
149138
"+<component/os/os_dep/include>",
150139
"+<component/common/api/network/include>",
151140
"+<component/common/api>",
@@ -191,6 +180,11 @@
191180
),
192181
)
193182

183+
# Sources - FreeRTOS
184+
env.Replace(FREERTOS_PORT=env["FAMILY_NAME"], FREERTOS_PORT_DEFINE="REALTEK_AMB1")
185+
queue.AddExternalLibrary("freertos")
186+
queue.AddExternalLibrary("freertos-port")
187+
194188
# Sources - lwIP
195189
queue.AddExternalLibrary("lwip", port="amb1")
196190

builder/frameworks/arduino.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
exit(1)
5353

5454
# Sources - ArduinoCore-API
55-
queue.AddExternalLibrary("arduino_api")
55+
queue.AddExternalLibrary("arduino-api")
5656

5757
# Sources - board variant
5858
queue.AddLibrary(

builder/frameworks/base.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
CXXFLAGS=[
9898
"-Wno-literal-suffix",
9999
"-Wno-write-strings",
100-
"-Wno-psabi",
100+
"-Wno-psabi", # parameter passing for argument of type ... changed in GCC 7.1
101101
],
102102
CPPDEFINES=[
103103
("LIBRETUYA", 1),

builder/utils/libs-external.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from dataclasses import dataclass
44
from typing import Dict, List, Optional, Union
55

6+
from ltchiptool.util.dict import merge_dicts
67
from platformio.package.meta import PackageItem
78
from platformio.platform.base import PlatformBase
89
from SCons.Script import DefaultEnvironment, Environment
@@ -31,6 +32,7 @@ def env_add_external_library(
3132
queue,
3233
name: str,
3334
port: Optional[str] = None,
35+
options: Dict[str, List[str]] = {},
3436
):
3537
if port:
3638
name += f"-{port}"
@@ -46,16 +48,19 @@ def env_add_external_library(
4648
f"Version '{version}' of library '{name}' ({lib.package}) is not installed"
4749
)
4850

51+
opts_default = dict(
52+
CFLAGS=lib.flags,
53+
CPPDEFINES=[(k, v) for k, v in lib.defines.items()],
54+
LINKFLAGS=lib.linkflags,
55+
)
56+
options = merge_dicts(opts_default, options)
57+
4958
queue.AddLibrary(
5059
name=name.replace("-", "_"),
5160
base_dir=package.path,
5261
srcs=lib.sources,
5362
includes=lib.includes,
54-
options=dict(
55-
CFLAGS=lib.flags,
56-
CPPDEFINES=[(k, v) for k, v in lib.defines.items()],
57-
LINKFLAGS=lib.linkflags,
58-
),
63+
options=options,
5964
)
6065

6166

builder/utils/libs-queue.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from dataclasses import InitVar, dataclass, field
55
from glob import glob
66
from os.path import isdir, join
7-
from typing import Dict, Generator, List, Optional, Tuple
7+
from typing import Dict, Generator, List, Tuple
88

99
from ltchiptool.util.dict import merge_dicts
1010
from SCons.Script import DefaultEnvironment, Environment
@@ -127,8 +127,8 @@ def AddLibrary(self, **kwargs):
127127
self.options_public = merge_dicts(self.options_public, {key: option})
128128
self.queue.append(lib)
129129

130-
def AddExternalLibrary(self, name: str, port: Optional[str] = None):
131-
return self.env.AddExternalLibrary(self, name, port)
130+
def AddExternalLibrary(self, *args, **kwargs):
131+
return self.env.AddExternalLibrary(self, *args, **kwargs)
132132

133133
def AppendPublic(self, **kwargs):
134134
if "CPPPATH" in kwargs:

external-libs.json

+22-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
"+<.>"
4646
]
4747
},
48-
"arduino_api": {
48+
"arduino-api": {
4949
"package": "framework-arduino-api",
5050
"sources": [
5151
"+<api/Common.cpp>",
@@ -60,6 +60,27 @@
6060
"+<api/deprecated>"
6161
]
6262
},
63+
"freertos": {
64+
"package": "library-freertos",
65+
"sources": [
66+
"+<FreeRTOS/Source/*.c>"
67+
],
68+
"includes": [
69+
"+<FreeRTOS/Source/include>"
70+
]
71+
},
72+
"freertos-port": {
73+
"package": "library-freertos-port",
74+
"sources": [
75+
"+<./$FREERTOS_PORT/*.c>"
76+
],
77+
"includes": [
78+
"+<./$FREERTOS_PORT>"
79+
],
80+
"defines": {
81+
"FREERTOS_PORT_${FREERTOS_PORT_DEFINE}": "1"
82+
}
83+
},
6384
"lwip-amb1": {
6485
"package": "library-lwip",
6586
"sources": [

external-libs.schema.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
"type": "array",
1818
"items": {
1919
"type": "string",
20-
"pattern": "^[!+-]<[\\w/*.]+>$"
20+
"pattern": "^[!+-]<[$\\w/*.]+>$"
2121
}
2222
},
2323
"includes": {
2424
"type": "array",
2525
"items": {
2626
"type": "string",
27-
"pattern": "^[!+-]<[\\w/*.]+>$"
27+
"pattern": "^[!+-]<[$\\w/*.]+>$"
2828
}
2929
},
3030
"flags": {

platform.json

+11
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"any": "gccarmnoneeabi@~1.100301.0"
2828
},
2929
"libraries": {
30+
"freertos": "8.1.2",
3031
"lwip": {
3132
"1.4.1": "1.4.1-amb1",
3233
"2.0.0": "2.0.0-amb1",
@@ -53,6 +54,7 @@
5354
"any":"gccarmnoneeabi@~1.100301.0"
5455
},
5556
"libraries": {
57+
"freertos": "9.0.0",
5658
"lwip": {
5759
"2.0.2": "2.0.2-bdk",
5860
"2.1.0": "2.1.0-bdk",
@@ -72,6 +74,15 @@
7274
"base_url": "https://github.com/libretuya/lwip",
7375
"version_prefix": true
7476
},
77+
"library-freertos": {
78+
"type": "framework",
79+
"optional": true,
80+
"base_url": "https://github.com/libretuya/library-freertos"
81+
},
82+
"library-freertos-port": {
83+
"type": "framework",
84+
"version": "https://github.com/libretuya/library-freertos-port#2023.03.13"
85+
},
7586
"library-flashdb": {
7687
"type": "framework",
7788
"version": "https://github.com/libretuya/library-flashdb#1.2.0"

platform.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -188,13 +188,21 @@ def configure_default_packages(self, options, targets):
188188
continue
189189
for name, lib_versions in package["libraries"].items():
190190
package = f"library-{name}"
191+
if isinstance(lib_versions, str):
192+
# single version specified as string
193+
if name in versions:
194+
pkg_versions[package] = versions[name]
195+
else:
196+
pkg_versions[package] = lib_versions
197+
continue
198+
# mapping of versions to repo branches
191199
if name in versions and versions[name] in lib_versions:
192200
pkg_versions[package] = lib_versions[versions[name]]
193201
continue
194202
if "default" in lib_versions:
195203
pkg_versions[package] = lib_versions["default"]
196204

197-
# gather custom versions of other libraries
205+
# gather custom (user-set) versions of other libraries
198206
for name, version in versions.items():
199207
if name == "toolchain":
200208
continue

0 commit comments

Comments
 (0)