Skip to content

Commit

Permalink
targets: Add mimxrt595 FreeRTOS target
Browse files Browse the repository at this point in the history
Setup FreeRTOS toolchain for the m33 on the mimxrt595 EVK board.
Provides a concrete development target for drivers added to Pigweed that
use RTOS primitives.

Bug: b/269206309
Change-Id: I893cbcdafcfb417cb5ea5180e358bbadeac4e084
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/151314
Presubmit-Verified: CQ Bot Account <[email protected]>
Reviewed-by: Rob Mohr <[email protected]>
Reviewed-by: Carlos Chinchilla <[email protected]>
Commit-Queue: Austin Foxley <[email protected]>
  • Loading branch information
afoxley authored and CQ Bot Account committed Jun 23, 2023
1 parent ece3466 commit 80238af
Show file tree
Hide file tree
Showing 14 changed files with 1,667 additions and 6 deletions.
5 changes: 5 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ if (pw_third_party_mcuxpresso_SDK != "") {
_build_pigweed_default_at_all_optimization_levels("mimxrt595") {
toolchain_prefix = "$dir_pigweed/targets/mimxrt595_evk:mimxrt595_evk_"
}

_build_pigweed_default_at_all_optimization_levels("mimxrt595_freertos") {
toolchain_prefix =
"$dir_pigweed/targets/mimxrt595_evk_freertos:mimxrt595_evk_freertos_"
}
}

_build_pigweed_default_at_all_optimization_levels("stm32f429i") {
Expand Down
10 changes: 5 additions & 5 deletions pw_digital_io_mcuxpresso/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ if (pw_third_party_mcuxpresso_SDK != "") {

pw_test("mimxrt595_test") {
enable_if =
pw_third_party_mcuxpresso_SDK == "//targets/mimxrt595_evk:sample_sdk" &&
(pw_toolchain_SCOPE.name == "mimxrt595_evk_debug" ||
pw_toolchain_SCOPE.name == "mimxrt595_evk_size_optimized" ||
pw_toolchain_SCOPE.name == "mimxrt595_evk_speed_optimized")
pw_third_party_mcuxpresso_SDK == "//targets/mimxrt595_evk_freertos:sdk" &&
(pw_toolchain_SCOPE.name == "mimxrt595_evk_freertos_debug" ||
pw_toolchain_SCOPE.name == "mimxrt595_evk_freertos_size_optimized" ||
pw_toolchain_SCOPE.name == "mimxrt595_evk_freertos_speed_optimized")
sources = [ "mimxrt595_test.cc" ]
deps = [
":pw_digital_io_mcuxpresso",
"//targets/mimxrt595_evk:sample_sdk",
"//targets/mimxrt595_evk_freertos:sdk",
]
}

Expand Down
22 changes: 21 additions & 1 deletion pw_presubmit/py/pw_presubmit/pigweed_presubmit.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,27 @@ def gn_arm_build(ctx: PresubmitContext):
'pw_third_party_mcuxpresso_SDK': '//targets/mimxrt595_evk:sample_sdk',
'pw_C_OPTIMIZATION_LEVELS': _OPTIMIZATION_LEVELS,
},
ninja_targets=('mimxrt595',),
ninja_targets=('mimxrt595'),
)

gn_mimxrt595_freertos_build = build.GnGenNinja(
name='gn_mimxrt595_freertos_build',
path_filter=_BUILD_FILE_FILTER,
packages=('freertos', 'mcuxpresso'),
gn_args={
'dir_pw_third_party_freertos': lambda ctx: '"{}"'.format(
str(ctx.package_root / 'freertos')
),
'dir_pw_third_party_mcuxpresso': lambda ctx: '"{}"'.format(
str(ctx.package_root / 'mcuxpresso')
),
'pw_target_mimxrt595_evk_freertos_MANIFEST': '{}/{}'.format(
"$dir_pw_third_party_mcuxpresso", "EVK-MIMXRT595_manifest_v3_8.xml"
),
'pw_third_party_mcuxpresso_SDK': '//targets/mimxrt595_evk_freertos:sdk',
'pw_C_OPTIMIZATION_LEVELS': _OPTIMIZATION_LEVELS,
},
ninja_targets=('mimxrt595_freertos'),
)

gn_software_update_build = build.GnGenNinja(
Expand Down
82 changes: 82 additions & 0 deletions targets/mimxrt595_evk_freertos/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# Copyright 2023 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

load(
"//pw_build:pigweed.bzl",
"pw_cc_library",
)
load(
"//pw_build/bazel_internal:pigweed_internal.bzl",
"pw_linker_script",
)

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

pw_linker_script(
name = "flash_linker_script",
defines = [
"PW_BOOT_FLASH_BEGIN=0x08001180",
"PW_BOOT_FLASH_SIZE=0x001FEE80",
"PW_BOOT_HEAP_SIZE=200K",
"PW_BOOT_MIN_STACK_SIZE=1K",
"PW_BOOT_RAM_BEGIN=0x20080000",
"PW_BOOT_RAM_SIZE=0x00280000",
"PW_BOOT_VECTOR_TABLE_BEGIN=0x08001000",
"PW_BOOT_VECTOR_TABLE_SIZE=0x00000180",
],
linker_script = "mimxrt595_flash.ld",
)

pw_cc_library(
name = "boot",
srcs = [
"boot.cc",
"vector_table.c",
],
defines = [
"PW_MALLOC_ACTIVE=1",
],
target_compatible_with = [
"//pw_build/constraints/board:mimxrt595_evk",
"@platforms//cpu:armv8-m",
],
deps = [
":flash_linker_script",
"//pw_boot",
"//pw_boot_cortex_m",
"//pw_preprocessor",
"//pw_sys_io_mcuxpresso",
"@pigweed_config//:mcuxpresso_sdk",
],
alwayslink = 1,
)

pw_cc_library(
name = "freertos_config",
hdrs = [
"FreeRTOSConfig.h",
],
includes = ["./"],
)

pw_cc_library(
name = "tasks",
srcs = [
"tasks.c",
],
target_compatible_with = ["//pw_build/constraints/rtos:freertos"],
deps = ["@freertos"],
)
209 changes: 209 additions & 0 deletions targets/mimxrt595_evk_freertos/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# Copyright 2021 The Pigweed Authors
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
# use this file except in compliance with the License. You may obtain a copy of
# the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

import("//build_overrides/pigweed.gni")

import("$dir_pw_build/linker_script.gni")
import("$dir_pw_build/target_types.gni")
import("$dir_pw_docgen/docs.gni")
import("$dir_pw_malloc/backend.gni")
import("$dir_pw_third_party/freertos/freertos.gni")
import("$dir_pw_third_party/mcuxpresso/mcuxpresso.gni")
import("$dir_pw_toolchain/generate_toolchain.gni")
import("target_toolchains.gni")

generate_toolchains("target_toolchains") {
toolchains = pw_target_toolchain_mimxrt595_evk_freertos_list
}

declare_args() {
# When compiling with an MCUXpresso SDK, this variable is set to the path of
# the manifest file within the SDK installation. When set, a pw_source_set
# for a sample project SDK is created at
# "//targets/mimxrt595_evk_freertos:sdk".
pw_target_mimxrt595_evk_freertos_MANIFEST = ""

# This list should contain the necessary defines for setting linker script
# memory regions. While we don't directly use the pw_boot_cortex_m linker
# script, these are deliberately matching to make being able to later easier.
pw_target_mimxrt595_evk_freertos_LINK_CONFIG_DEFINES = []
}

config("pw_malloc_active") {
if (pw_malloc_BACKEND != "") {
defines = [ "PW_MALLOC_ACTIVE=1" ]
}
}

config("disable_warnings") {
cflags = [
"-Wno-cast-qual",
"-Wno-redundant-decls",
"-Wno-undef",
"-Wno-unused-parameter",
"-Wno-unused-variable",
]
visibility = [ ":*" ]
}

config("freestanding") {
cflags = [
"-ffreestanding",
"-fno-builtin",
]
asmflags = cflags
ldflags = cflags
visibility = [ ":*" ]
}

config("sdk_defines") {
defines = [
"CPU_MIMXRT595SFFOC_cm33",
"DEBUG_CONSOLE_TRANSFER_NON_BLOCKING",
"SDK_DEBUGCONSOLE=1",
]
visibility = [ ":*" ]
}

if (current_toolchain != default_toolchain) {
pw_linker_script("flash_linker_script") {
defines = pw_target_mimxrt595_evk_freertos_LINK_CONFIG_DEFINES
linker_script = "mimxrt595_flash.ld"
}
}

if (pw_third_party_mcuxpresso_SDK != "") {
# Startup and vector table for NXP MIMXRT595-EVK.
pw_source_set("boot") {
public_configs = [ ":pw_malloc_active" ]
deps = [
"$dir_pw_boot",
"$dir_pw_boot_cortex_m:armv8m",
"$dir_pw_malloc",
"$dir_pw_preprocessor",
"$dir_pw_sys_io_mcuxpresso",
pw_third_party_mcuxpresso_SDK,
]
if (pw_malloc_BACKEND != "") {
deps += [ "$dir_pw_malloc" ]
}
sources = [
"boot.cc",
"vector_table.c",
]
}
}

if (pw_third_party_mcuxpresso_SDK == "//targets/mimxrt595_evk_freertos:sdk") {
pw_mcuxpresso_sdk("sdk") {
manifest = pw_target_mimxrt595_evk_freertos_MANIFEST
include = [
"project_template.evkmimxrt595.MIMXRT595S",
"component.serial_manager_uart.MIMXRT595S",
"platform.drivers.power.MIMXRT595S",
"platform.drivers.lpc_gpio.MIMXRT595S",
"platform.drivers.pint.MIMXRT595S",
"utility.debug_console.MIMXRT595S",
]
exclude = [ "device.MIMXRT595S_startup.MIMXRT595S" ]

public_configs = [
":disable_warnings",
":freestanding",
":sdk_defines",
]

public_deps = [
":mimxrt595_config",
"$dir_pw_third_party/freertos",
]
}

config("config_public_includes") {
include_dirs = [ "board" ]
visibility = [ ":*" ]
}

config("config_public_defines") {
defines = [
"CPU_MIMXRT595SFFOC_cm33",
"DEBUG_CONSOLE_DISABLE_RTOS_SYNCHRONIZATION",
"FSL_RTOS_FREE_RTOS",
"FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE=1",
"SDK_DEBUGCONSOLE=1",
"SDK_OS_FREE_RTOS",
]
visibility = [ ":*" ]
}

# Project-specific board configuration.
pw_source_set("mimxrt595_config") {
public_configs = [
":config_public_defines",
":config_public_includes",
":disable_warnings",
":sdk__defines",
":sdk__includes",
]
}

# Project-specific FreeRTOS configurations.
config("freertos_config_public_includes") {
include_dirs = [ "." ]
visibility = [ ":*" ]
}

pw_source_set("freertos_config") {
public_configs = [
":config_public_defines",
":config_public_includes",
":disable_warnings",
":sdk__defines",
":sdk__includes",
":freertos_config_public_includes",
]
public = [ "FreeRTOSConfig.h" ]
}

# Project-specific FreeRTOS port.
_freertos_port_dir =
"$dir_pw_third_party_freertos/portable/GCC/ARM_CM33_NTZ/non_secure"
config("freertos_port_public_includes") {
include_dirs = [
"$_freertos_port_dir",
"$dir_pw_third_party_freertos/include",
]
visibility = [ ":*" ]
}

pw_source_set("freertos_port") {
public_configs = [ ":freertos_port_public_includes" ]
public = [
"$_freertos_port_dir/portasm.h",
"$_freertos_port_dir/portmacro.h",
]
configs = [ ":disable_warnings" ]
sources = [
"$_freertos_port_dir/port.c",
"$_freertos_port_dir/portasm.c",
"$dir_pw_third_party_freertos/portable/MemMang/heap_4.c",
"tasks.c",
]
deps = [ ":freertos_config" ]
}
}

pw_doc_group("target_docs") {
sources = [ "target_docs.rst" ]
}
Loading

0 comments on commit 80238af

Please sign in to comment.