blob: 3d2d1dac55b80ce31910ad2ea5595051235448fe [file] [log] [blame]
--
-- Copyright 2023 Google LLC
--
-- 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
--
-- http://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.
set_project("CHERIoT soundstream demo")
local shodan_dir = os.getenv("ROOTDIR")
if shodan_dir == nil or shodan_dir == '' then
raise("ROOTDIR not set")
end
local cheriot_out_dir = os.getenv("CHERIOT_OUT_DIR")
if cheriot_out_dir == nil or cheriot_out_dir == '' then
raise("CHERIOT_OUT_DIR not set")
end
local sdkdir = path.join(shodan_dir, "sw/cheriot-rtos/sdk")
includes(sdkdir)
set_toolchains("cheriot-clang")
option("board")
set_default("sencha")
local matcha_dir = path.join(shodan_dir, "hw/matcha")
local dif_dir = path.join(matcha_dir, "sw/device/lib/dif")
local dif_autogen_dir = path.join(dif_dir, "autogen")
local opentitan_dir = path.join(shodan_dir, "hw/opentitan-upstream")
local matcha_gen_dir = path.join(cheriot_out_dir, "opentitan-gen/include/opentitan")
-- Support libraries
includes(path.join(sdkdir, "lib"))
includes(path.join(sdkdir, "lib/freestanding"))
-- Each driver operates in a compartment.
compartment("i2s")
add_files("i2s.cc")
add_files(path.join(dif_dir, "dif_i2s.c"),
path.join(dif_autogen_dir, "dif_i2s_autogen.c"))
add_includedirs(matcha_dir, matcha_gen_dir, opentitan_dir)
add_defines("CHERIOT_NO_AMBIENT_MALLOC")
compartment("mailbox")
add_files("mailbox.cc")
add_files(path.join(dif_dir, "dif_tlul_mailbox.c"),
path.join(dif_autogen_dir, "dif_tlul_mailbox_autogen.c"))
add_includedirs(matcha_dir, matcha_gen_dir, opentitan_dir)
add_defines("CHERIOT_NO_AMBIENT_MALLOC")
compartment("ml_top")
add_files("ml_top.cc")
add_files(path.join(dif_dir, "dif_ml_top.c"),
path.join(dif_autogen_dir, "dif_ml_top_autogen.c"))
add_includedirs(matcha_dir, matcha_gen_dir, opentitan_dir)
add_defines("CHERIOT_NO_AMBIENT_MALLOC")
-- Soundstream application.
compartment("soundstream")
add_files("soundstream.cc", "encode.cc")
add_files(path.join(matcha_dir, "hw/top_matcha/sw/autogen/top_matcha.c"));
add_includedirs(matcha_dir, matcha_gen_dir, opentitan_dir)
-- Firmware image.
firmware("soundstream-firmware")
add_deps("freestanding")
add_deps("debug", "i2s", "ml_top", "mailbox", "soundstream")
on_load(function(target)
target:values_set("board", "$(board)")
-- NB: trusted_stack_frames is a guess; +1'd for any
-- compartment error handler usage?
target:values_set("threads", {
{
compartment = "soundstream",
priority = 1,
entry_point = "entry",
stack_size = 0x1000, -- 4KB
trusted_stack_frames = 5
},
-- NB: stack sizes bumped for logging
{
compartment = "i2s",
priority = 1,
entry_point = "i2s_isr",
stack_size = 0x400, -- 512B
trusted_stack_frames = 3
},
{
compartment = "ml_top",
priority = 1,
entry_point = "ml_top_isr",
stack_size = 0x400, -- 512B
trusted_stack_frames = 3
},
{
compartment = "mailbox",
priority = 1,
entry_point = "mailbox_isr",
stack_size = 0x400, -- 512B
trusted_stack_frames = 3
}
}, {expand = false})
end)