Skip to content

Commit b8d4049

Browse files
am62ax: mcu-r5f: Add OSPI flash io example
-Add build support for ospi flash io example Fixes: SITSW-4814 Signed-off-by: Vaibhav Reddy <vaibhav.reddy@ti.com>
1 parent 97d7218 commit b8d4049

File tree

12 files changed

+980
-1
lines changed

12 files changed

+980
-1
lines changed

.metadata/.tirex/am62ax.content.tirex.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3243,6 +3243,39 @@
32433243
]
32443244
]
32453245
},
3246+
{
3247+
"resourceType": "project.ccs",
3248+
"resourceClass": [
3249+
"example"
3250+
],
3251+
"resourceSubClass": [
3252+
"example.general"
3253+
],
3254+
"description": "A Ospi Flash Io Example. CPU is MCU-R5FSS0-0 running FREERTOS.",
3255+
"name": "ospi_flash_io",
3256+
"location": "../../examples/drivers/ospi/ospi_flash_io/am62ax-sk/mcu-r5fss0-0_freertos/ti-arm-clang/example.projectspec",
3257+
"devtools": [
3258+
"AM62Ax_SK_EVM"
3259+
],
3260+
"kernel": [
3261+
"freertos"
3262+
],
3263+
"compiler": [
3264+
"ticlang"
3265+
],
3266+
"subCategories": [
3267+
"drivers",
3268+
"ospi",
3269+
"ospi_flash_io",
3270+
"mcu-r5fss0-0_freertos"
3271+
],
3272+
"mainCategories": [
3273+
[
3274+
"Examples",
3275+
"Development Tools"
3276+
]
3277+
]
3278+
},
32463279
{
32473280
"resourceType": "project.ccs",
32483281
"resourceClass": [

examples/drivers/ospi/ospi_flash_io/.project/project_am62ax.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ const includes_freertos_r5f = {
3535
],
3636
};
3737

38+
const libs_freertos_r5f = {
39+
common: [
40+
"freertos.am62ax.r5f.ti-arm-clang.${ConfigName}.lib",
41+
"drivers.am62ax.r5f.ti-arm-clang.${ConfigName}.lib",
42+
"board.am62ax.r5f.ti-arm-clang.${ConfigName}.lib",
43+
],
44+
};
45+
3846
const includes_freertos_a53 = {
3947
common: [
4048
"${MCU_PLUS_SDK_PATH}/source/kernel/freertos/FreeRTOS-Kernel/include",
@@ -202,10 +210,26 @@ const templates_freertos_a53 =
202210
}
203211
];
204212

213+
const templates_freertos_r5f =
214+
[
215+
{
216+
input: ".project/templates/am62ax/common/linker_mcu-r5f.cmd.xdt",
217+
output: "linker.cmd",
218+
},
219+
{
220+
input: ".project/templates/am62ax/freertos/main_freertos.c.xdt",
221+
output: "../main.c",
222+
options: {
223+
entryFunction: "ospi_flash_io_main",
224+
},
225+
}
226+
];
227+
205228
const buildOptionCombos = [
206229
{ device: device, cpu: "r5fss0-0", cgt: "ti-arm-clang", board: "am62ax-sk", os: "freertos"},
207230
{ device: device, cpu: "a53ss0-0", cgt: "gcc-aarch64", board: "am62ax-sk", os: "nortos"},
208231
{ device: device, cpu: "a53ss0-0", cgt: "gcc-aarch64", board: "am62ax-sk", os: "freertos"},
232+
{ device: device, cpu: "mcu-r5fss0-0", cgt: "ti-arm-clang", board: "am62ax-sk", os: "freertos"},
209233
];
210234

211235
function getComponentProperty() {
@@ -230,7 +254,16 @@ function getComponentBuildProperty(buildOption) {
230254
build_property.syscfgfile = syscfgfile;
231255
build_property.readmeDoxygenPageTag = readmeDoxygenPageTag;
232256

233-
if(buildOption.cpu.match(/r5f*/)) {
257+
if(buildOption.cpu.match(/mcu-r5f*/)){
258+
if(buildOption.os.match(/freertos*/) )
259+
{
260+
build_property.includes = includes_freertos_r5f;
261+
build_property.libdirs = libdirs_freertos;
262+
build_property.libs = libs_freertos_r5f;
263+
build_property.templates = templates_freertos_r5f;
264+
}
265+
}
266+
else if(buildOption.cpu.match(/r5f*/)) {
234267
build_property.defines = defines;
235268
build_property.libs = libs_nortos_dm_r5f;
236269
build_property.templates = templates_nortos_dm_r5f;
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/**
2+
* These arguments were used when this file was generated. They will be automatically applied on subsequent loads
3+
* via the GUI or CLI. Run CLI with '--help' for additional information on how to override these arguments.
4+
* @cliArgs --device "AM62Ax" --package "AMB" --part "Default" --context "mcu-r5fss0-0" --product "MCU_PLUS_SDK@07.03.01"
5+
* @versions {"tool":"1.20.0+3587"}
6+
*/
7+
8+
/**
9+
* Import the modules used in this configuration.
10+
*/
11+
const flash = scripting.addModule("/board/flash/flash", {}, false);
12+
const flash1 = flash.addInstance();
13+
const debug_log = scripting.addModule("/kernel/dpl/debug_log");
14+
const mpu_armv7 = scripting.addModule("/kernel/dpl/mpu_armv7", {}, false);
15+
const mpu_armv71 = mpu_armv7.addInstance();
16+
const mpu_armv72 = mpu_armv7.addInstance();
17+
const mpu_armv73 = mpu_armv7.addInstance();
18+
const mpu_armv74 = mpu_armv7.addInstance();
19+
const mpu_armv75 = mpu_armv7.addInstance();
20+
const mpu_armv76 = mpu_armv7.addInstance();
21+
const mpu_armv77 = mpu_armv7.addInstance();
22+
23+
/**
24+
* Write custom configuration values to the imported modules.
25+
*/
26+
flash1.$name = "CONFIG_FLASH0";
27+
flash1.serialFlashDriver.$name = "board_flash_serialFlash_serialflash0";
28+
flash1.serialFlashDriver.flashType = "SERIAL_NAND";
29+
flash1.serialFlashDriver.protocol = "1s_8s_8s";
30+
flash1.serialFlashDriver.peripheralDriver.$name = "CONFIG_OSPI0";
31+
flash1.serialFlashDriver.peripheralDriver.baudRateDiv = 8;
32+
flash1.serialFlashDriver.peripheralDriver.dmaEnable = true;
33+
flash1.serialFlashDriver.peripheralDriver.OSPI.$assign = "OSPI0";
34+
35+
const udma = scripting.addModule("/drivers/udma/udma", {}, false);
36+
const udma1 = udma.addInstance({}, false);
37+
udma1.$name = "CONFIG_UDMA0";
38+
flash1.serialFlashDriver.peripheralDriver.udmaDriver = udma1;
39+
40+
const udma_blkcopy_channel = scripting.addModule("/drivers/udma/udma_blkcopy_channel", {}, false);
41+
const udma_blkcopy_channel1 = udma_blkcopy_channel.addInstance({}, false);
42+
udma_blkcopy_channel1.$name = "CONFIG_UDMA_BLKCOPY_CH0";
43+
flash1.serialFlashDriver.peripheralDriver.udmaBlkCopyChannel = udma_blkcopy_channel1;
44+
45+
debug_log.enableUartLog = true;
46+
debug_log.uartLog.$name = "CONFIG_UART0";
47+
48+
mpu_armv71.size = 31;
49+
mpu_armv71.attributes = "Device";
50+
mpu_armv71.accessPermissions = "Supervisor RD+WR, User RD";
51+
mpu_armv71.allowExecute = false;
52+
mpu_armv71.$name = "REGISTER_REGION";
53+
54+
mpu_armv72.accessPermissions = "Supervisor RD+WR, User RD";
55+
mpu_armv72.$name = "TCMA";
56+
mpu_armv72.attributes = "NonCached";
57+
mpu_armv72.size = 7;
58+
59+
mpu_armv73.baseAddr = 0x41010000;
60+
mpu_armv73.size = 15;
61+
mpu_armv73.accessPermissions = "Supervisor RD+WR, User RD";
62+
mpu_armv73.$name = "TCMB";
63+
mpu_armv73.attributes = "NonCached";
64+
65+
mpu_armv74.accessPermissions = "Supervisor RD+WR, User RD";
66+
mpu_armv74.baseAddr = 0x79100000;
67+
mpu_armv74.size = 19;
68+
mpu_armv74.$name = "MSRAM";
69+
70+
mpu_armv75.baseAddr = 0x80000000;
71+
mpu_armv75.size = 31;
72+
mpu_armv75.$name = "DDR";
73+
74+
mpu_armv76.baseAddr = 0xFC40000;
75+
mpu_armv76.size = 8;
76+
mpu_armv76.allowExecute = false;
77+
mpu_armv76.attributes = "Device";
78+
mpu_armv76.$name = "FSS0_OSPI0_CTRL";
79+
80+
mpu_armv77.baseAddr = 0x60000000;
81+
mpu_armv77.attributes = "Device";
82+
mpu_armv77.allowExecute = false;
83+
mpu_armv77.$name = "FSS0_DAT_REG1";
84+
mpu_armv77.size = 27;
85+
86+
/**
87+
* Pinmux solution for unlocked pins/peripherals. This ensures that minor changes to the automatic solver in a future
88+
* version of the tool will not impact the pinmux you originally saw. These lines can be completely deleted in order to
89+
* re-solve from scratch.
90+
*/
91+
flash1.serialFlashDriver.peripheralDriver.OSPI.CLK.$suggestSolution = "OSPI0_CLK";
92+
flash1.serialFlashDriver.peripheralDriver.OSPI.CSn0.$suggestSolution = "OSPI0_CSn0";
93+
flash1.serialFlashDriver.peripheralDriver.OSPI.DQS.$suggestSolution = "OSPI0_DQS";
94+
flash1.serialFlashDriver.peripheralDriver.OSPI.D7.$suggestSolution = "OSPI0_D7";
95+
flash1.serialFlashDriver.peripheralDriver.OSPI.D6.$suggestSolution = "OSPI0_D6";
96+
flash1.serialFlashDriver.peripheralDriver.OSPI.D5.$suggestSolution = "OSPI0_D5";
97+
flash1.serialFlashDriver.peripheralDriver.OSPI.D4.$suggestSolution = "OSPI0_D4";
98+
flash1.serialFlashDriver.peripheralDriver.OSPI.D3.$suggestSolution = "OSPI0_D3";
99+
flash1.serialFlashDriver.peripheralDriver.OSPI.D2.$suggestSolution = "OSPI0_D2";
100+
flash1.serialFlashDriver.peripheralDriver.OSPI.D1.$suggestSolution = "OSPI0_D1";
101+
flash1.serialFlashDriver.peripheralDriver.OSPI.D0.$suggestSolution = "OSPI0_D0";
102+
debug_log.uartLog.MCU_UART.$suggestSolution = "MCU_USART0";
103+
debug_log.uartLog.MCU_UART.RXD.$suggestSolution = "MCU_UART0_RXD";
104+
debug_log.uartLog.MCU_UART.TXD.$suggestSolution = "MCU_UART0_TXD";
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
/*
2+
* Copyright (C) 2018-2024 Texas Instruments Incorporated
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions
6+
* are met:
7+
*
8+
* Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
*
11+
* Redistributions in binary form must reproduce the above copyright
12+
* notice, this list of conditions and the following disclaimer in the
13+
* documentation and/or other materials provided with the
14+
* distribution.
15+
*
16+
* Neither the name of Texas Instruments Incorporated nor the names of
17+
* its contributors may be used to endorse or promote products derived
18+
* from this software without specific prior written permission.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21+
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22+
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23+
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24+
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25+
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26+
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30+
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31+
*/
32+
33+
#include <stdlib.h>
34+
#include <kernel/dpl/DebugP.h>
35+
#include "ti_drivers_config.h"
36+
#include "ti_board_config.h"
37+
#include "ti_drivers_open_close.h"
38+
#include "ti_board_open_close.h"
39+
#include "FreeRTOS.h"
40+
#include "task.h"
41+
42+
#define MAIN_TASK_PRI (configMAX_PRIORITIES-1)
43+
44+
#define MAIN_TASK_SIZE (16384U/sizeof(configSTACK_DEPTH_TYPE))
45+
StackType_t gMainTaskStack[MAIN_TASK_SIZE] __attribute__((aligned(32)));
46+
47+
StaticTask_t gMainTaskObj;
48+
TaskHandle_t gMainTask;
49+
50+
void ospi_flash_io_main(void *args);
51+
52+
void freertos_main(void *args)
53+
{
54+
int32_t status = SystemP_SUCCESS;
55+
56+
/* Open drivers */
57+
Drivers_open();
58+
/* Open flash and board drivers */
59+
status = Board_driversOpen();
60+
DebugP_assert(status==SystemP_SUCCESS);
61+
62+
ospi_flash_io_main(NULL);
63+
64+
/* Close board and flash drivers */
65+
Board_driversClose();
66+
/* Close drivers */
67+
Drivers_close();
68+
69+
vTaskDelete(NULL);
70+
}
71+
72+
73+
int main()
74+
{
75+
/* init SOC specific modules */
76+
System_init();
77+
Board_init();
78+
79+
/* This task is created at highest priority, it should create more tasks and then delete itself */
80+
gMainTask = xTaskCreateStatic( freertos_main, /* Pointer to the function that implements the task. */
81+
"freertos_main", /* Text name for the task. This is to facilitate debugging only. */
82+
MAIN_TASK_SIZE, /* Stack depth in units of StackType_t typically uint32_t on 32b CPUs */
83+
NULL, /* We are not using the task parameter. */
84+
MAIN_TASK_PRI, /* task priority, 0 is lowest priority, configMAX_PRIORITIES-1 is highest */
85+
gMainTaskStack, /* pointer to stack base */
86+
&gMainTaskObj ); /* pointer to statically allocated task object memory */
87+
configASSERT(gMainTask != NULL);
88+
89+
/* Start the scheduler to start the tasks executing. */
90+
vTaskStartScheduler();
91+
92+
/* The following line should never be reached because vTaskStartScheduler()
93+
will only return if there was not enough FreeRTOS heap memory available to
94+
create the Idle and (if configured) Timer tasks. Heap management, and
95+
techniques for trapping heap exhaustion, are described in the book text. */
96+
DebugP_assertNoLog(0);
97+
98+
return 0;
99+
}

0 commit comments

Comments
 (0)