Skip to content

Fix memory reservation for Softdevice in NRF52_DK #7971

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#define MBED_APP_SIZE 0x80000
#endif

/* If app_start is 0, do not set aside space for the softdevice */
#if MBED_APP_START == 0
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x10000
#else
/* If softdevice is present, set aside space for it */
#if defined(SOFTDEVICE_PRESENT)
Copy link
Contributor

@0xc0170 0xc0170 Sep 3, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, MBED_APP_START is being removed, thus what specifies that there is app moved (bootlader in) ? I would expect to have a condition to check MBED_APP_START and then softdevice might change the values or am I missing something?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my understanding the original code made assumption that if your MBED_APP_START is 0 it implied that you are using SoftDevice, which is blocking the case where you don't have SoftDevice but have your own bootloader. This change makes the flow more logical.
If you have SoftDevice, we reserve RAM for you otherwise you get the complete RAM. There is no ambiguity in the interpretation now.

#define MBED_RAM_START 0x200031D0
#define MBED_RAM_SIZE 0xCE30
#else
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x10000
#endif

#define MBED_RAM0_START MBED_RAM_START
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
#define MBED_APP_SIZE 0x80000
#endif

/* If app_start is 0, do not set aside space for the softdevice */
#if MBED_APP_START == 0
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x10000
#else
/* If softdevice is present, set aside space for it */
#if defined(SOFTDEVICE_PRESENT)
#define MBED_RAM_START 0x200031D0
#define MBED_RAM_SIZE 0xCE30
#else
#define MBED_RAM_START 0x20000000
#define MBED_RAM_SIZE 0x10000
#endif

#define MBED_RAM0_START MBED_RAM_START
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ if (!isdefinedsymbol(MBED_APP_SIZE)) {
define symbol MBED_APP_SIZE = 0x80000;
}

/* If app_start is 0, do not set aside space for the softdevice */
if (MBED_APP_START == 0) {
define symbol MBED_RAM_START = 0x20000000;
define symbol MBED_RAM_SIZE = 0x10000;
} else {
/* If softdevice is present, set aside space for it */
if (isdefinedsymbol(SOFTDEVICE_PRESENT)) {
define symbol MBED_RAM_START = 0x200031D0;
define symbol MBED_RAM_SIZE = 0xCE30;
} else {
define symbol MBED_RAM_START = 0x20000000;
define symbol MBED_RAM_SIZE = 0x10000;
}

define symbol MBED_RAM0_START = MBED_RAM_START;
Expand Down
9 changes: 7 additions & 2 deletions tools/toolchains/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,8 +706,8 @@ def _add_all_regions(self, region_list, active_region_name):
self._add_defines_from_region(region)
if region.active:
for define in [
("%s_START" % active_region_name, region.start),
("%s_SIZE" % active_region_name, region.size)
("%s_START" % active_region_name, "0x%x" % region.start),
("%s_SIZE" % active_region_name, "0x%x" % region.size)
]:
define_string = self.make_ld_define(*define)
self.ld.append(define_string)
Expand Down Expand Up @@ -747,6 +747,11 @@ def set_config_data(self, config_data):
self.config_data = config_data
# new configuration data can change labels, so clear the cache
self.labels = None
# pass info about softdevice presence to linker (see NRF52)
if "SOFTDEVICE_PRESENT" in config_data[1]:
define_string = self.make_ld_define("SOFTDEVICE_PRESENT", config_data[1]["SOFTDEVICE_PRESENT"].macro_value)
self.ld.append(define_string)
self.flags["ld"].append(define_string)
self.add_regions()

# Creates the configuration header if needed:
Expand Down
4 changes: 2 additions & 2 deletions tools/toolchains/arm.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def name_mangle(name):

@staticmethod
def make_ld_define(name, value):
return "--predefine=\"-D%s=0x%x\"" % (name, value)
return "--predefine=\"-D%s=%s\"" % (name, value)

@staticmethod
def redirect_symbol(source, sync, build_dir):
Expand Down Expand Up @@ -426,7 +426,7 @@ def __init__(self, target, *args, **kwargs):
self.flags["ld"] += ["--import_cmse_lib_out=%s" % secure_file]
# Add linking time preprocessor macro __DOMAIN_NS
if target.core == "Cortex-M23-NS" or self.target.core == "Cortex-M33-NS":
define_string = self.make_ld_define("__DOMAIN_NS", 1)
define_string = self.make_ld_define("__DOMAIN_NS", "0x1")
self.flags["ld"].append(define_string)

asm_cpu = {
Expand Down
2 changes: 1 addition & 1 deletion tools/toolchains/gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def name_mangle(name):

@staticmethod
def make_ld_define(name, value):
return "-D%s=0x%x" % (name, value)
return "-D%s=%s" % (name, value)

@staticmethod
def redirect_symbol(source, sync, build_dir):
Expand Down
2 changes: 1 addition & 1 deletion tools/toolchains/iar.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def name_mangle(name):

@staticmethod
def make_ld_define(name, value):
return "--config_def %s=0x%x" % (name, value)
return "--config_def %s=%s" % (name, value)

@staticmethod
def redirect_symbol(source, sync, build_dir):
Expand Down