samples: application_development: remove the code_relocation sample

covert this sample to a test cases

Signed-off-by: Hake Huang <hake.huang@oss.nxp.com>
This commit is contained in:
Hake Huang 2022-07-14 17:37:16 +08:00 committed by Fabio Baltieri
parent 45daf3b448
commit cedc99b8ed
10 changed files with 0 additions and 219 deletions

View File

@ -1,22 +0,0 @@
# SPDX-License-Identifier: Apache-2.0
cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(code_relocation)
FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
# Code relocation feature
zephyr_code_relocate(src/test_file1.c SRAM2)
zephyr_code_relocate(src/test_file2.c SRAM)
zephyr_code_relocate(src/test_file3.c SRAM2_TEXT)
zephyr_code_relocate(src/test_file3.c SRAM_DATA)
zephyr_code_relocate(src/test_file3.c SRAM2_BSS)
zephyr_code_relocate(../../../kernel/sem.c SRAM)
zephyr_linker_sources(SECTIONS custom-sections.ld)

View File

@ -1,9 +0,0 @@
.. _code_relocation:
Code relocation
#################
Overview
********
A simple example that demonstrates how relocation of code, data or bss sections
using a custom linker script.

View File

@ -1,6 +0,0 @@
/* SPDX-License-Identifier: Apache-2.0 */
SECTION_DATA_PROLOGUE(_CUSTOM_SECTION_NAME2,,)
{
KEEP(*(".custom_section.*"));
} GROUP_DATA_LINK_IN(RAMABLE_REGION, ROMABLE_REGION)

View File

@ -1,39 +0,0 @@
/*
* Copyright (c) 2013-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* @file
* @brief Linker command/script file
*
* Linker script for the Cortex-M platforms.
*/
#include <zephyr/linker/sections.h>
#include <zephyr/devicetree.h>
#include <zephyr/linker/linker-defs.h>
#include <zephyr/linker/linker-tool.h>
/** enable CONFIG_SRAM2 or any other partition in soc Kconfig,
* this is just an example to show relocation of code/data/bss script
*/
#if defined CONFIG_ARM
#define CONFIG_SRAM2 1
#define _SRAM2_DATA_SECTION_NAME .sram2_data
#define _SRAM2_BSS_SECTION_NAME .sram2_bss
#define _SRAM2_TEXT_SECTION_NAME .sram2_text
#define SRAM2_ADDR (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2)
#endif
#define RAM_SIZE2 (CONFIG_SRAM_SIZE * 512)
MEMORY
{
#ifdef CONFIG_SRAM2
SRAM2 (wx) : ORIGIN = (CONFIG_SRAM_BASE_ADDRESS + RAM_SIZE2), LENGTH = RAM_SIZE2
#endif
}
#include <zephyr/arch/arm/aarch32/cortex_m/scripts/linker.ld>

View File

@ -1,4 +0,0 @@
CONFIG_CODE_DATA_RELOCATION=y
CONFIG_HAVE_CUSTOM_LINKER_SCRIPT=y
CONFIG_CUSTOM_LINKER_SCRIPT="linker_arm_sram2.ld"
CONFIG_COVERAGE=n

View File

@ -1,13 +0,0 @@
sample:
description: Code data relocation Sample
name: code relocation
tests:
sample.application_development.code_relocation:
harness: console
harness_config:
type: one_line
regex:
- "Hello World! (.*)"
platform_allow: qemu_cortex_m3 mps2_an385 sam_e70_xplained
tags: linker
extra_sections: _SRAM2_RODATA_SECTION_NAME _SRAM_TEXT_SECTION_NAME _SRAM_RODATA_SECTION_NAME _SRAM_DATA_SECTION_NAME _CUSTOM_SECTION_NAME2

View File

@ -1,49 +0,0 @@
/*
* Copyright (c) 2018 Intel Corporation.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/kernel.h>
#include <zephyr/sys/printk.h>
/* This function will allow execute from sram region.
* This is needed only for this sample because by default all soc will
* disable the execute from SRAM.
* An application that requires that the code be executed from SRAM will
* have to configure the region appropriately in arm_mpu_regions.c.
*/
#ifdef CONFIG_ARM_MPU
#include <zephyr/arch/arm/aarch32/cortex_m/cmsis.h>
void disable_mpu_rasr_xn(void)
{
uint32_t index;
/* Kept the max index as 8(irrespective of soc) because the sram
* would most likely be set at index 2.
*/
for (index = 0U; index < 8; index++) {
MPU->RNR = index;
if (MPU->RASR & MPU_RASR_XN_Msk) {
MPU->RASR ^= MPU_RASR_XN_Msk;
}
}
}
#endif /* CONFIG_ARM_MPU */
extern void function_in_sram2(void);
extern void function_in_split_multiple(void);
void main(void)
{
#ifdef CONFIG_ARM_MPU
disable_mpu_rasr_xn();
#endif /* CONFIG_ARM_MPU */
printk("Address of main function %p\n\n", &main);
function_in_sram2();
function_in_split_multiple();
}

View File

@ -1,44 +0,0 @@
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/zephyr.h>
#include <zephyr/sys/printk.h>
uint32_t var_sram2_data = 10U;
uint32_t var_sram2_bss;
K_SEM_DEFINE(test, 0, 1);
const uint32_t var_sram2_rodata = 100U;
__in_section(custom_section, static, var) uint32_t var_custom_data = 1U;
extern void function_in_sram(int32_t value);
void function_in_custom_section(void);
void function_in_sram2(void)
{
/* Print values from sram2 */
printk("Address of function_in_sram2 %p\n", &function_in_sram2);
printk("Address of var_sram2_data %p\n", &var_sram2_data);
printk("Address of k_sem_give %p\n", &k_sem_give);
printk("Address of var_sram2_rodata %p\n", &var_sram2_rodata);
printk("Address of var_sram2_bss %p\n\n", &var_sram2_bss);
/* Print values from sram */
function_in_sram(var_sram2_data);
/* Print values which were placed using attributes */
printk("Address of custom_section, func placed using attributes %p\n",
&function_in_custom_section);
printk("Address of custom_section data placed using attributes %p\n\n",
&var_custom_data);
k_sem_give(&test);
}
__in_section(custom_section, static, fun) void function_in_custom_section(void)
{
return;
}

View File

@ -1,14 +0,0 @@
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/zephyr.h>
#include <zephyr/sys/printk.h>
void function_in_sram(int32_t value)
{
printk("Address of function_in_sram %p\n", &function_in_sram);
printk("Hello World! %s\n", CONFIG_BOARD);
}

View File

@ -1,19 +0,0 @@
/*
* Copyright (c) 2012-2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/zephyr.h>
#include <zephyr/sys/printk.h>
uint32_t var_file3_sram_data = 10U;
uint32_t var_file3_sram2_bss;
void function_in_split_multiple(void)
{
printk("Address of function_in_split_multiple %p\n",
&function_in_split_multiple);
printk("Address of var_file3_sram_data %p\n", &var_file3_sram_data);
printk("Address of var_file3_sram2_bss %p\n\n", &var_file3_sram2_bss);
}