Skip to content

Commit

Permalink
platforms: Add cortex-m33 platforms and device configs
Browse files Browse the repository at this point in the history
Map from @platforms cpu flag to what gcc expects.
  • Loading branch information
afoxley authored and silvergasp committed Sep 26, 2023
1 parent 951e3b4 commit cf5b240
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
16 changes: 15 additions & 1 deletion devices/arm/cortex_m.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,18 @@ CORTEX_M7_FPU_DEVICE_CONFIG = device_config(
fpu = "fpv5-d16",
)

CORTEX_M_DEVICE_CONFIGS = [CORTEX_M0_DEVICE_CONFIG, CORTEX_M3_DEVICE_CONFIG, CORTEX_M4_FPU_DEVICE_CONFIG, CORTEX_M4_DEVICE_CONFIG, CORTEX_M7_FPU_DEVICE_CONFIG]
CORTEX_M33_DEVICE_CONFIG = device_config(
cpu = "armv8-m",
endian = "little",
float_abi = "soft",
fpu = "none",
)

CORTEX_M33_FPU_DEVICE_CONFIG = device_config(
cpu = "armv8-m",
endian = "little",
float_abi = "hard",
fpu = "fpv5-d16",
)

CORTEX_M_DEVICE_CONFIGS = [CORTEX_M0_DEVICE_CONFIG, CORTEX_M3_DEVICE_CONFIG, CORTEX_M4_FPU_DEVICE_CONFIG, CORTEX_M4_DEVICE_CONFIG, CORTEX_M7_FPU_DEVICE_CONFIG, CORTEX_M33_DEVICE_CONFIG, CORTEX_M33_FPU_DEVICE_CONFIG]
23 changes: 23 additions & 0 deletions platforms/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,29 @@ platform(
parents = [":cortex_m"],
)

platform(
name = "cortex_m33",
constraint_values = [
"@platforms//cpu:armv8-m",
],
exec_properties = {
"EXECUTOR": "cortex_m33"
},
parents = [":cortex_m3"]
)

platform(
name = "cortex_m33_fpu",
constraint_values = [
"@platforms//cpu:armv8-m",
"@bazel_embedded//constraints/fpu:fpv5-d16",
],
exec_properties = {
"EXECUTOR": "cortex_m33_fpu"
},
parents = [":cortex_m3"]
)

platform(
name = "stm32f2xx",
parents = [":cortex_m3"],
Expand Down
6 changes: 6 additions & 0 deletions toolchains/features/common/impl/gcc.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ def GccIncludeFeature(include_paths):
def GccAchitectureFeature(architecture, float_abi, endian, fpu):
if fpu == "none":
fpu = "auto"

# @platforms//cpu has armv8-m entry intended to match cortex m23, m33, m35p
# processors which all have the main instruction set. GCC needs this
# explicitly set when using arch flag.
if architecture == "armv8-m":
architecture = "armv8-m.main"
_ARCHITECTURE_FEATURE = feature(
name = "architecture",
enabled = True,
Expand Down
1 change: 1 addition & 0 deletions toolchains/gcc_arm_none_eabi/gcc_arm_none_toolchain.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ gcc_arm_none_toolchain_config = rule(
"armv6s-m",
"armv7-m",
"armv7e-m",
"armv8-m",
"armv8-m.base",
"armv8-m.main",
"iwmmxt",
Expand Down

0 comments on commit cf5b240

Please sign in to comment.