Skip to content

os/, build/configs/: Segregate board specific changes from mkldscript.py#7226

Open
namanjain7 wants to merge 1 commit intoSamsung:masterfrom
namanjain7:mkldscript_draft
Open

os/, build/configs/: Segregate board specific changes from mkldscript.py#7226
namanjain7 wants to merge 1 commit intoSamsung:masterfrom
namanjain7:mkldscript_draft

Conversation

@namanjain7
Copy link
Copy Markdown
Contributor

Refactor mkldscript.py file. Add common code in mkldscript.py and board specific address calculation to build/configs//scripts

@namanjain7 namanjain7 marked this pull request as draft March 31, 2026 11:05
@namanjain7
Copy link
Copy Markdown
Contributor Author

Removed support for common_.ld and app1_.ld
Passing values as arguments to Makefile.unix and loadable.mk using --defsym

@amandeep-samsung
Copy link
Copy Markdown
Contributor

@ewoodev : please review design so we can make changes accordingly in discussed design.

  • mkldscript does not have board specific code now.
  • related files are used for board specific address calculation
  • common_0.ld and app1_0.ld are not created now and variables are used to pass flash addresses in userspace_all.ld for XIP

Comment thread loadable_apps/loadable.mk Outdated
ifeq ($(CONFIG_XIP_ELF),y)
MEM_VARS := $(shell python $(TOPDIR)/tools/mkldscript.py $(CONFIG_APP1_BIN_NAME))
$(foreach v,$(MEM_VARS),$(eval $(v)))
APP1_LD_DEFS := \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This file is common including from app1 app2.

please check app2 case

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yes, we are adding both,

  1. app2 and also
  2. OTA index (just like before it was for both cases). We will take OTA index as argument and will fix it by defconfig as slot 0.

Comment thread os/tools/mkldscript.py Outdated
Comment on lines +89 to +99
get_flash_address(binary_type) # Get flash address and size from board specific code

offset = offset + part_size
PART_IDX = PART_IDX + 1
if binary_type == "common":
print("RAM_ADD={}".format(common_ram_start))
print("RAM_SIZE={}".format(hex(common_ram_size)))
elif binary_type == "app1":
print("RAM_ADD={}".format(app1_ram_start))
print("RAM_SIZE={}".format(app1_ram_size))
elif binary_type == "app2":
print("RAM_ADD={}".format(app2_ram_start))
print("RAM_SIZE={}".format(app2_ram_size))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

why everytime calculate and return only one?

it's better calculating once of argument at that time.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Code modified.
Now, when script is called for common binary, then addresses for app1, app2 will also be calculated and saved in json file. When call for app1, app2 comes, it will fetch from json cache file and return it directly without calculating.

Comment on lines +60 to +90
def get_flash_address(binary_name):
global offset
"""
Get flash address for specified binary (common/app1/app2) in dual OTA mode.
For rtl8730e, offset starts from base address and accumulates through partitions.
Returns FLASH_ADD and FLASH_SIZE for the specified binary.
"""
index = 0
ota_index = 1

current_offset = offset

for name in NAME_LIST:
part_size = int(SIZE_LIST[index]) * 1024

if name == "kernel":
ota_index = (ota_index + 1) % 2
elif name == binary_name:
if binary_name == "common":
binary_start = hex(current_offset + 0x10 + signing_offset)
binary_size = hex(part_size - 0x10 - signing_offset)
else:
binary_start = hex(current_offset + 0x30 + signing_offset)
binary_size = hex(part_size - 0x30 - signing_offset)

print("FLASH_ADD={}".format(binary_start))
print("FLASH_SIZE={}".format(binary_size))
return

current_offset = current_offset + part_size
index += 1
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This function is board specific?
i think, platform just needs only virture start address of kernel partition

@sunghan-chang
Copy link
Copy Markdown
Contributor

@namanjain7 This is pending for long time. Please let me know status.

@namanjain7
Copy link
Copy Markdown
Contributor Author

@namanjain7 This is pending for long time. Please let me know status.

Hello Mr. chang,
we have done the changes that need to be done.
there are some recent makefile changes, and we are merging it with our commit.
We will update ASAP when it's done.

@namanjain7
Copy link
Copy Markdown
Contributor Author

we have added dynamic ram start calculation for each partition.
the ram allocation starts from the end.
the script will be called everytime we build for common, app1, and app2.
currently, we are facing issues related to removing duplicate calculation. calculating app1 offset will require calculating common binary offset also which creates duplicate calculation. we are optimizing this.
this task is on priority and we will push the final version ASAP when done.

Comment thread os/tools/get_addr.py Outdated
print(sys.argv[5])

if __name__ == "__main__":
get_mem_config()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

please remove it

@namanjain7 namanjain7 force-pushed the mkldscript_draft branch 2 times, most recently from 00dffd1 to cc05d68 Compare April 9, 2026 15:43
@namanjain7
Copy link
Copy Markdown
Contributor Author

we will update flash addressing related changes after more verify

Comment thread os/Makefile.unix
Comment on lines +452 to +459
COMMON_BINARY_NAME=common
MEM_VARS := $(shell python $(TOPDIR)/tools/mkldscript.py $(COMMON_BINARY_NAME))
$(foreach v,$(MEM_VARS),$(eval $(v)))
COMMON_LD_DEFS := \
--defsym __FLASH_START_ADDRESS__=$(FLASH_ADD) \
--defsym __FLASH_SIZE__=$(FLASH_SIZE) \
--defsym __RAM_START_ADDRESS__=$(RAM_ADD) \
--defsym __RAM_SIZE__=$(RAM_SIZE)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this code is added severel code(common app1 app2)
how about make function??

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The common binary is build in Makefile.unix. So, this code will execute once.
For app1, app2, --> The makefile is loadable.mk
Both have different makefiles.

Comment thread os/tools/bin_mem_layout.py Outdated
cfg_file = os.path.join(os_folder, '.config')
build_folder = os.path.join(os_folder, '..', 'build')
output_folder = os.path.join(build_folder, 'output', 'bin')
saved_config_file_path = os.path.join(output_folder, 'mem_layout_cache.json')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

i'd like to know why this is needed.

which file is using this file?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

cfg_file ->used to get CONFIG_RAM_START, common app1 app2... binary size to get address.
build_folder, output_folder, saved_config_file_path -> For saving json file in output folder. This file will have config values extracted from .config file and memory values.

@namanjain7 namanjain7 force-pushed the mkldscript_draft branch 2 times, most recently from d22117d to bb87918 Compare April 15, 2026 11:28
@namanjain7 namanjain7 marked this pull request as ready for review April 15, 2026 11:28
@namanjain7
Copy link
Copy Markdown
Contributor Author

All issues resolved. We have tested in tp1x, tp1x plus, and ailite boards.

mkldscript.py was used to make .ld script containing flash and ram start address and size. The file contained code changes for both rtl8730e and bk7239n. This commit removes this file and make a common file and board specific file.
We added new file bin_mem_layout.py which is used to print the data. In makefile, we are reading the data and passing it as an argument in makefile, instead of directly importing .ld scripts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants